Compare commits

...
Author SHA1 Message Date
Martin CarlbergandGitHub c59687b6e2 Fixed: Use latest version of actions as the old ones are deprecated 2024-04-10 11:34:50 +02:00
Martin CarlbergandGitHub c2bd9f26a7 Fixed: Github Action build with Node 20 and 21 too 2024-04-10 11:19:10 +02:00
Martin Carlberg f33ba954f5 Fixed: critical severity vulnerability in package xmldom 2024-01-09 14:28:15 +01:00
Martin Carlberg 150e44dcd5 Fixed: The objj2objcskeleton tool stop generating output if a SelectorLiteralExpression was used in the source file 2023-05-31 14:32:38 +02:00
Martin Carlberg 511ce4b07d Merge branch 'master' into node 2022-12-09 15:13:17 +01:00
Martin Carlberg aea3fb5f07 Merge remote-tracking branch 'origin/es2022' into node 2022-12-09 13:59:48 +01:00
Martin CarlbergandGitHub 5932a07eb2 Fixed: Make sure Jakefile both work for async and sync calls
The callback variable was not set if the call to initilize was synchronous.
It is now set before so both sync and async will work
2022-12-09 10:15:38 +01:00
Martin CarlbergandGitHub 2b07c4b662 Fixed: Make sure Jakefile both work for async and sync calls
The callback variable was not set if the call to initilize was synchronous.
It is now set before so both sync and async will work
2022-12-09 10:14:52 +01:00
Martin CarlbergandGitHub bc689b91dc Fixed: Added 'npm update' to use latest modules 2022-12-08 17:26:57 +01:00
Martin CarlbergandGitHub c6a42781e7 Fixed: Github Action build with Node 18 and 19 too 2022-12-08 14:25:01 +01:00
Martin Carlberg c92aedf433 Fixed: Quick fix for XcodeCapp so it will run without python2 scripts 2022-11-21 16:41:16 +01:00
cacaodevandMartin Carlberg 7857f92f19 FIXED: CPLikePredicateOperatorType was matching substrings
Fixes #2955
2022-11-21 16:33:56 +01:00
cacaodevandGitHub 9361e5d401 FIXED: CPLikePredicateOperatorType was matching substrings
Fixes #2955
2022-11-10 10:49:01 +01:00
Martin CarlbergandGitHub ad1862a253 Update CPURLConnection.j
New: Async method for requesting data
2022-10-06 11:24:56 +02:00
Martin Carlberg 4af137894a Fixed: Npm lock file with latest versions 2022-09-01 14:02:40 +02:00
Martin Carlberg 55aca1fde9 Fixed: Make sure we compile with es2022 as ecmaVersion in the parser 2022-09-01 13:53:52 +02:00
Alfred Wärnsäter 53e1e936d9 Reordered includes 2022-08-26 15:08:58 +02:00
Alfred Wärnsäter ff1448fb54 Fixed Objective-J framework using latest transpiler and parser 2022-08-26 12:25:40 +02:00
Alfred Wärnsäter 95fb19f311 New version 2022-08-25 17:57:57 +02:00
Alfred Wärnsäter 46d869a62f Updated lock file 2022-08-25 15:46:09 +02:00
Alfred Wärnsäter 03140dbf64 Updated Terser and added acorn walk dependency 2022-08-25 15:45:23 +02:00
Alfred Wärnsäter 052c96e05a Changes for compatibility with ES2022 transpiler 2022-08-25 15:34:19 +02:00
Alfred Wärnsäter 9a88f9c324 Added ES2022 as compile option 2022-08-25 15:32:43 +02:00
Alfred Wärnsäter 747ea627c9 Removed debugger statement 2022-08-25 15:30:02 +02:00
daboe01andMartin Carlberg 89c0ab405a Fixed: å and Å did not work well on scandinavian keyboards in CPTextView (#3031) 2022-04-04 10:23:17 +02:00
daboe01andGitHub 04c2b98ae4 Fixed: å and Å did not work well on scandinavian keyboards in CPTextView (#3031) 2022-04-04 10:16:37 +02:00
Martin Carlberg 24b36cdd95 Fixed: Allow space in path to .xib/.cib file when running nib2cib 2022-03-29 10:39:04 +02:00
Martin Carlberg 3e83bd2363 Revert "Fixed: Before this PR, nib2cib failed if a color well or a scrollable text view was added in a CPBox (#2994)"
This reverts commit 6544aff88e.
2022-03-21 16:25:24 +01:00
Martin Carlberg 5c91a08eaf Revert "Fixed: Before this PR, nib2cib failed if a color well or a scrollable text view was added in a CPBox (#2994)"
This reverts commit 6544aff88e.
2022-03-21 16:24:17 +01:00
Martin Carlberg edfba15d6f Merge branch 'master' into node 2022-03-21 15:55:08 +01:00
Didier KorthoudtandGitHub 48e786e8b5 Fixed: This PR adapts views and custom views decoding to fix "not ready view" bugs (#2917) 2022-03-21 15:50:44 +01:00
daboe01andGitHub 1282f1ac0e Removed: Flash support (#2903) 2022-03-21 15:46:54 +01:00
KrisandGitHub ee2fb61fdd Fixed: Changed Cappuccino.doxygen EXCLUDE_PATTERNS to exclude nothing. (#2680)
Classes such as CPArray are no longer shown in the generated documentation

This should fix #1956
2022-03-21 15:42:46 +01:00
Martin CarlbergandGitHub 68a113e7ee Fixed: New Cocoa api that replace old deprecated for calculating content and frame size of scroll view (#3023)
Old deprecated api did not work as it was accessing ivars _horizontalScroller and _verticalScroller from class method.
New Cocoa api is added as described in Apple Developer Documentation.

Also added type CPScrollerStyle
2022-03-21 15:25:09 +01:00
Martin CarlbergandGitHub 3cf3b76446 Fixed: Correct init of CPTextView when running nib2cib (#3014) 2022-03-21 15:24:34 +01:00
Didier KorthoudtandGitHub d7d561d3a9 Fixed: Aristo3 - New _CPImageAndTextView & theme parameter (#2951) 2022-03-21 15:23:16 +01:00
David SiawandGitHub 73eeda3c09 Fixed: strange lines that appear in Google Chrome (#2863) 2022-03-21 15:14:14 +01:00
Didier KorthoudtandGitHub 3d514b5010 Fixed: Aristo3 - Various _CPImageAndTextView bugs (#2914) 2022-03-21 14:28:21 +01:00
Didier KorthoudtandGitHub 93fc8d29cc Fixed: Before this PR, imagesize would provide image size in points (that is, taking care of the image resolution) instead of pixels (#2965) 2022-03-21 14:12:51 +01:00
Didier KorthoudtandGitHub 145bf65542 Fixed: Before this PR, outlet connection decoding was done before views are ready (#2959) 2022-03-21 14:10:53 +01:00
daboe01andGitHub f21555bb6c Fixed: Width of text sizing was slightly off in chrome due to a Chrome bug (#2975)
This is a real bug in chrome. see https://bugs.chromium.org/p/chromium/issues/detail?id=1192834

Also fixed: ellipsis clipping in segmented controls
and
fixed: tooltip wrapping issues from fractional pixels
2022-03-21 14:08:45 +01:00
Martin CarlbergandGitHub be072a283f Fixed: Basic support for on/off/mixed state images for menuitems from the Interface Builder (#2991) 2022-03-21 13:38:39 +01:00
David RichardsonandGitHub 9e8d51c94d New: Add additional manual test for scaleUnitSquareToSize (#2979)
Currently failing to match behaviour of Objective-C equivalent.
2022-03-21 13:37:24 +01:00
Didier KorthoudtandGitHub b3051a5bd0 Fixed: Before this PR, CPBox followed the autoresizesSubviews flags while Cocoa NSBox always autoresizes its subviews, whatever the flag is set to. (#2992) 2022-03-21 13:35:22 +01:00
Didier KorthoudtandGitHub a523cfc381 Fixed: Before this PR, CGContextSetShadow wasn't initializing the shadow color (#2966) 2022-03-21 13:33:00 +01:00
Didier KorthoudtandGitHub 6544aff88e Fixed: Before this PR, nib2cib failed if a color well or a scrollable text view was added in a CPBox (#2994) 2022-03-21 13:29:31 +01:00
Michael BachandGitHub 7c1fdbc720 Fixed: Modernise "document.write" in «index.html» to "innerHTML" (#2998) 2022-03-21 13:26:11 +01:00
daboe01andGitHub bd84804e32 Fixed: Usage of eval instead of JSON.parse for parsing JSON (#3016)
Using eval for parsing JSON is considered bad practice and is also slower
2022-03-21 13:07:44 +01:00
David RichardsonandGitHub 1f2a257bab Fixed: CPBox - Suppress superfluous warnings and expand documentation (#2996)
Warnings about borderColor, borderWidth, cornerRadius and fillColor are suppressed when boxType is CPBoxSeparator.
They are not relevant and needlessly clutter verbose output when debugging and should be suppressed.
2022-03-21 13:06:18 +01:00
daboe01andGitHub b0684929e2 Fixed: key event issues of handling escape in recent firefox … (#3020) 2022-03-21 13:02:37 +01:00
daboe01andGitHub 22dc587a8f Fixed: caret was blinking in non-editable text in CPTextView (#3022) 2022-03-21 13:00:40 +01:00
daboe01andMartin Carlberg 622fcf740e Update README.markdown
make wording of system requirements more concise
2022-03-21 12:58:55 +01:00
cacaodevandGitHub 77b59c8a18 Merge pull request #3024 from cappuccino/revert-2963-compile_deep_structured_project_in_browser
Revert "New: Support to compile deep structured project in the web browser"
2022-03-17 21:10:03 +01:00
cacaodevandGitHub 462a18930b Revert "New: Support to compile deep structured project in the web browser" 2022-03-17 21:07:16 +01:00
cacaodevandGitHub fb07def5fa Merge pull request #3017 from daboe01/fixed-sheet-animation-click-issue
fixed: freeze when clicking during sheet animation
2022-03-05 18:12:27 +01:00
cacaodevandGitHub a03ee6726e Merge pull request #2963 from mrcarlberg/compile_deep_structured_project_in_browser
New: Support to compile deep structured project in the web browser
2022-03-05 18:11:08 +01:00
daboe01 1ef49ef290 formatting 2022-01-23 13:42:12 +01:00
daboe01 76d52e07d4 fixed: freeze when clicking during sheet animation
previously, the app froze when clicking somewhere during sheet open/close animations.
these adversarial clicks are simply ignored by this PR
2022-01-23 13:39:33 +01:00
Martin Carlberg 044b0bb0d2 Fixed: NibApplication template for 'capp' to use correct build dir 2022-01-04 14:51:43 +01:00
Martin Carlberg 472b59ef80 Fixed: Allow space in path to .xib/.cib file 2022-01-04 14:51:43 +01:00
Martin Carlberg 6b559ce283 1.2.2 2021-12-03 14:02:00 +01:00
Martin Carlberg c17b806fd5 1.2.1 2021-12-03 14:00:14 +01:00
Martin Carlberg 1dcea8fe4c Added: .npmignore for easier "npm publish" 2021-12-03 14:00:02 +01:00
Martin Carlberg d72a52b9ce Merge branch 'master' into node 2021-12-03 12:36:27 +01:00
Martin Carlberg 61e01b08e5 Fixed: Rename the README back to the original name 2021-12-03 12:29:37 +01:00
Didier KorthoudtandGitHub 37756a5853 Fixed: nib2cib: checks if there's a defined superview in resizeWithOldSuperviewSize (#2995) 2021-11-23 13:47:54 +01:00
David RichardsonandGitHub b66690e304 New: Implement missing indexPath method for CPTreeNode (#2999) 2021-11-23 13:45:10 +01:00
Martin CarlbergandGitHub ccc6007bab Fixed: Bezel state instance variable _bezelState must remove current state when changing to a new state (#3001)
If the bezel state was changed and some attribute was set like an "image". The image would not be found as there were two states active and it would not match.
2021-11-23 13:42:36 +01:00
David RichardsonandGitHub 3179d56879 Fixed: Include commented code to hide mainMenu (#3008)
Add commented-out code to capp gen NibApplication template.
The technique itself is easy to forget and not obvious to newcomers.
It is included in the standard capp gen application template
and added here for completeness.
2021-11-23 13:41:30 +01:00
Martin CarlbergandGitHub b631032857 Fixed: Node build badge can be clicked to actions 2021-11-09 12:43:32 +01:00
Martin CarlbergandGitHub 49574d1c54 Fixed: Node build badge can be clicked to actions 2021-11-09 12:41:01 +01:00
Martin CarlbergandGitHub b7d7368ce6 Fixed: Include the Node build status badge at top 2021-11-09 11:49:30 +01:00
Martin CarlbergandGitHub e221156c11 Fixed: Changed name on Build & Test GitHub action 2021-11-09 11:43:39 +01:00
Martin CarlbergandGitHub 8e346acdce Fixed: Changed travis build badge to Github 2021-11-09 11:34:14 +01:00
Martin CarlbergandGitHub 7c36fa3f56 Fixed: "capp gen" template for NApplication uses environment variable CAPP_BUILD 2021-11-09 10:14:37 +01:00
Martin CarlbergandGitHub 642e254522 Fixed: Use upper case ENV variable 2021-11-09 10:07:35 +01:00
Martin CarlbergandGitHub 72aa1b8416 Fixed: Better name on the Build and Test Action 2021-11-08 17:11:43 +01:00
Martin CarlbergandGitHub edb1ef7f98 Fixed: Remove action on Node version 12 and 14
We use npm package-lock file version 2 and it is not supported by version 12 and 14
2021-11-08 13:21:40 +01:00
Martin CarlbergandGitHub 92beaba1d6 Fixed: Add Node version 12, 14 and 17 in action 2021-11-08 13:12:37 +01:00
Martin CarlbergandGitHub 3b61b1c85d Fixed: Use node branch 2021-11-08 13:07:40 +01:00
Martin CarlbergandGitHub a529e752b3 Create BuildAndTest.yml 2021-11-08 13:05:26 +01:00
Martin Carlberg d9791673df Fixed: Make sure we can build on Linux. Tested on Ubuntu 20.04 2021-11-07 13:41:01 +00:00
David RichardsonandGitHub a49a20e2c2 Fixed: nib2cib under Xcode 13 (#3006)
Backwards-compatible changes to accommodate different ibtool output from Xcode 13 onwards
2021-10-19 08:31:54 +02:00
Martin CarlbergandGitHub 8570476cff New: Added link to install the new Node version 2021-10-06 12:18:51 +02:00
Martin Carlberg d0923efa1a Fixed: Updated package-lock file. 2021-10-06 09:26:15 +02:00
Martin Carlberg eab8fe2d64 Fixed: Divided 'jake install' into 'jake dist' and 'jake install'
'jake dist' will do everything that 'jake install' does but creating the global symlinks
for the 'dist' binaries at the 'npm prefix' path.
2021-10-05 11:34:25 +02:00
Martin Carlberg c9e8b2970b Fixed: Moved out nib2cib functions to correct scope so they can be accessed by catch 2021-10-04 12:51:12 +02:00
Martin Carlberg 1440c156b2 Fixed: Make the path to the Frameworks directory for each package 2021-10-01 19:32:53 +02:00
Martin Carlberg ddfa4445ae Fixed: Move the 'objj' tool to the right place 2021-10-01 13:11:57 +02:00
Martin Carlberg 1f501e6429 Fixed: Make sure environment variables are included when running test-only 2021-10-01 13:10:46 +02:00
Martin Carlberg 7969f118de Fixed: Build in project home directory if no environment variables are set
Earlier the build directory was placed in the parent directory
2021-10-01 08:45:58 +02:00
Martin Carlberg 706166dc5c Fixed: Make sure we use the built parts of Cappuccino when building parts that is dependent of former.
This is done by passing the environment variable 'OBJJ_OPT' when spawning a new jake task. The content
of OBJJ_OPT will be parsed as arguments when starting an Objective-J tool
2021-09-29 09:18:12 +02:00
Martin Carlberg 4a8667e0f3 Fixed: Exit with error code when test cases did fail 2021-09-28 15:31:01 +02:00
Martin Carlberg 094fbcc67c Fixed: Move Terser from a development dependency to a regular dependency 2021-09-22 09:37:22 +02:00
Martin Carlberg d34c47c167 Fixed: Use preset variable from common.jake for build directory 2021-09-21 20:49:05 +02:00
Martin Carlberg 7226330514 Fixed: Create soft link to node_modules in a simpler way 2021-09-21 20:31:29 +02:00
Martin Carlberg 852b2bd5d9 Fixed: Missing enquote of path when creating build directory and soft link to node_modules 2021-09-21 17:56:14 +02:00
Martin Carlberg 3d8ecfad47 Fixed: Use unique temp directory for each run with nib2cib 2021-09-21 16:04:10 +02:00
Martin Carlberg 9e6f1e0dc3 Fixed: Timezone abbreviation was not working with the latest changes on all setups.
This is still not 100% but looks like it works a little bit better
2021-09-21 15:38:51 +02:00
Martin Carlberg 4deb7a3f51 Merge branch 'node' of github.com:cappuccino/cappuccino into node 2021-09-21 12:54:00 +02:00
Martin Carlberg 5b0b030435 Fixed: Exclude the dist folder except cappuccino/bin and objective-j/bin 2021-09-21 12:52:48 +02:00
Martin Carlberg 4edec2df2e 1.2.0 2021-09-21 12:34:10 +02:00
Martin Carlberg e0596bdf75 Fixed: Added latest package.json files 2021-09-21 12:34:04 +02:00
Martin Carlberg 6430463b5d Fixed: Included the latest binaries into the dist folder. 2021-09-21 12:31:45 +02:00
Martin Carlberg d9e27e549f Fixed: Removed compiler warnings in test case 2021-09-21 11:11:57 +02:00
Martin Carlberg 9f14dac5d2 Fixed: Cleanup of the output from our test cases 2021-09-21 11:11:25 +02:00
Martin Carlberg d70199ca58 Fixed: Asynchronous and output changes from the new Terser compressor 2021-09-21 11:09:09 +02:00
Martin Carlberg 6b1cdbd19c Fixed: Removed compiler warnings from test cases 2021-09-21 10:58:03 +02:00
Martin Carlberg 5b99757a0d Fixed: The compiler might inline the 'message send' call so we do it manually in these test cases. 2021-09-21 10:56:10 +02:00
Martin Carlberg 6c49116c68 Fixed: Use date string that is not as old as the previous one.
JavaScript now handles time a lot better. Times from before around 1900 is different in different
parts of the world so we just changed this test case to be a bit more modern.
2021-09-21 10:55:16 +02:00
Martin Carlberg 68f0cf27df Fixed: Bundle test cases must run asynchronous as a bundle will also load asynchronous in Node.
Also removed some compilation warnings from the test cases.
2021-09-21 10:51:17 +02:00
Martin Carlberg 89757e35e6 Fixed: Class Swapper should convert NSView -> CPView.
This is needed when a plain NSView is use without a Custom class name as it will otherwise try to create a NSView.
Also the Class Swapper is only used when the 'Instantiation' is check for 'Prefer code' under
the 'Runtime Behavior' header in the Document tab in Xcode. If this is not checked the '_CPCibCustomView'
is used instead of the Class Swapper.
2021-09-21 10:46:18 +02:00
Martin Carlberg 24bf09b70c Fixed: Abbreviation for a timezone is not handled in JavaScript. This changes makes it better but not perfect. 2021-09-21 10:30:26 +02:00
Martin Carlberg 0ed2709124 Fixed: Better message when loading a cib file and the class swapper doesn't find a class 2021-09-21 10:26:33 +02:00
Martin Carlberg a835202db1 Fixed: Adjusted test cases for Node. XMLHttpRequest now demands a protocol. 2021-09-20 11:00:37 +02:00
Martin Carlberg 830fbbab26 Fixed: Removed old Rhino adjustments in test cases 2021-09-20 10:51:14 +02:00
Martin Carlberg 119e11cfe2 Fixed: Allow 'await' for loading a bundle with the method 'loadWithDelegate:' 2021-09-20 09:19:05 +02:00
Martin Carlberg 511e18b44f Fixed: Wait for the bundle load to finish with the new async bundle load function 2021-09-17 21:55:48 +02:00
Martin Carlberg 2f00d93b22 Fixed: Must check in Node if path exists when doing 'fs.lstatSync' as it will throw if not. 2021-09-17 10:39:11 +02:00
Martin Carlberg 973fa1b978 Fixed: Misspelled function name 2021-09-17 10:37:03 +02:00
Martin Carlberg 79f40d24ae Fixed: Replace soft link to the directory 'node_modules' when it is already there. 2021-09-17 09:39:37 +02:00
Martin Carlberg fdff92e5c8 Fixed: Ask Node for a temporary directory instead of using '/tmp' 2021-09-17 09:38:29 +02:00
Martin Carlberg 653dd07162 Fixed: Include the tool 'objj2objcskeleton' in the installed binaries 2021-09-15 17:38:24 +02:00
Martin Carlberg b7968ca4a7 Fixed: Make sure output from the tool 'ojtest' gets to the terminal.
Also suspend stack trace etc. when the tests fails with a try ... catch.
2021-09-15 17:37:04 +02:00
Martin Carlberg 2a0a6449e5 Fixed: Converting the test cases in ToolTest.j to Node 2021-09-15 17:33:21 +02:00
Martin Carlberg b7c04d7d16 Fixed: Converted the tool 'objj2objcskeleton' for Node 2021-09-15 17:32:31 +02:00
Martin Carlberg ab4c87e69f Fixed: Removed warnings and cleanup for test cases when converting to Node 2021-09-15 17:31:20 +02:00
Martin Carlberg 8257632706 Fixed: When creating a method the function name can't start with '0_' 2021-09-15 17:28:07 +02:00
Martin Carlberg 3f8821b43b Fixed: Adjust arguments for the tool objj
This has changed now when running on Node.
2021-09-15 17:26:40 +02:00
Martin Carlberg f6b8bc0c45 Fixed: Include source files when compiling ojtest 2021-09-15 17:25:36 +02:00
Martin Carlberg 0618fa9bb2 Fixed: Added protocol to data source and delegate for outline view 2021-09-15 17:24:31 +02:00
Martin Carlberg 2e5a483dce Fixed: Added examples how to add macros in the 'capp gen' templates index[-debug].html files 2021-09-13 09:38:02 +02:00
Martin Carlberg e608e0dbf3 Fixed: Partly adapted Tooltest for Node 2021-09-10 15:56:12 +02:00
Martin Carlberg a88e316a94 Fixed: Compile OJTest with source map for easier debugging 2021-09-10 15:55:40 +02:00
Martin Carlberg 51ffa256ca Fixed: Preprocessor Output test adapted for Node 2021-09-10 15:55:01 +02:00
Martin Carlberg 52bd654850 Fixed: The new script for the ojtest tool must be in the dist/cappuccino/bin directory 2021-09-04 09:15:24 +02:00
Martin Carlberg 0518d479d3 Fixed: Included ojtest as binary in the package.json file 2021-09-03 16:28:23 +02:00
Martin Carlberg a893f3f5c1 Fixed: The tool ojtest now works with the new Node version. 2021-09-03 14:31:11 +02:00
Martin Carlberg 9c2f37b43f Fixed: The Tool nib2cib will give information of used Resource directory. 2021-09-02 12:44:48 +02:00
Martin Carlberg 0289ba17f1 Fixed: Add test task for Framework template used by the tool capp gen
Plus some minor bugfixes
2021-09-02 11:23:32 +02:00
Martin Carlberg 5db94e1e52 Fixed: Cleanup of the Jakefile template for Application and Framework used by the tool "capp gen" 2021-09-01 16:28:55 +02:00
Martin Carlberg a4bc08c29e Fixed: Moved enquote function to utils package.
This function was originally in the Narwhal package OS
2021-09-01 16:27:16 +02:00
Martin Carlberg b638d8e904 Fixed: From around Xcode 12.5.1 ibtool starts to create a folder with two files.
We have to check for this and take action. We don't know of this is a temporary thing as Apple has no
information about this change.
2021-08-30 16:29:43 +02:00
Martin Carlberg 251ce7fdad Fixed: Info.plist file with just whitespaces is not treated as an empty file in Node. Trim it and check length. 2021-08-27 09:08:19 +02:00
Martin Carlberg a2337a2969 Fixed: Can't use generic array of numbers when writing to file with Node 2021-08-27 09:04:51 +02:00
Martin Carlberg 0c803e26ca Fixed: Must expand path to absolute to be able to get application name. Was translated to wrong Node function when converting from Narwhal. 2021-08-27 09:03:58 +02:00
Martin Carlberg ab25fadb1e Fixed: Function for imagesize used wrong and non declared argument 2021-08-27 09:02:26 +02:00
Martin Carlberg e697f4eca7 Fixed: Better debugging experience 2021-08-27 09:01:19 +02:00
Martin Carlberg 80158a8982 Fixed: Cleanup of fontinfo and imagesize Jakefile 2021-08-27 08:59:45 +02:00
Martin Carlberg 55bcfacf3b Fixed: Moved common function used in Jakefiles that was declared all over the place to a file.js in @objj/utils. Also some general cleanup. 2021-08-25 09:32:58 +02:00
Martin Carlberg 52b7a82b4d Fixed: Cleanup of Jakefiles for better Node adaption 2021-08-24 10:58:12 +02:00
Martin Carlberg 471e605871 Fixed: removed debug log message 2021-08-23 11:14:12 +02:00
Alfred Wärnsäter 5c635f17a7 require node 14 as minimum 2021-08-20 14:22:11 +02:00
Alfred Wärnsäter c27d604780 removed print statement 2021-08-20 09:29:59 +02:00
Alfred Wärnsäter ddaf575719 fixed --version option in nib2cib 2021-08-20 09:29:34 +02:00
Alfred Wärnsäter 0757f2ea80 corrected instructions for Node alpha 2021-08-20 09:28:11 +02:00
Alfred Wärnsäter 3f8dfb6516 removed debugger statement 2021-08-20 09:27:03 +02:00
Alfred Wärnsäter 45ee25adc2 removed print statement 2021-08-20 09:26:13 +02:00
Alfred Wärnsäter fcfb3d4083 added bin dir from dist 2021-08-19 17:31:21 +02:00
Alfred Wärnsäter 357f8bd684 1.1.1 2021-08-19 16:36:38 +02:00
Alfred Wärnsäter 173cd8b4ad bumped npm version 2021-08-19 16:36:27 +02:00
Alfred Wärnsäter d2ca5994c8 1.2.0 2021-08-19 16:35:39 +02:00
Alfred Wärnsäter fe04d177af added more instructions 2021-08-19 16:35:19 +02:00
Alfred Wärnsäter 2a6b18bc1b added more instructions 2021-08-19 16:33:15 +02:00
Alfred Wärnsäter 152cd272f6 updated readme for Node alpha version 2021-08-19 16:07:26 +02:00
Alfred Wärnsäter abbdc139e8 now using sudo only when necessary 2021-08-19 13:59:43 +02:00
Alfred Wärnsäter 7226019b6a use npm prefix for install path 2021-08-19 13:30:40 +02:00
Alfred Wärnsäter 78ea29bd48 added dist to to gitignore 2021-08-19 11:15:27 +02:00
Alfred Wärnsäter 5c90d1f769 added binary part of dist dir 2021-08-19 11:14:38 +02:00
Alfred Wärnsäter 2ecea40fdc lots of Node fixes 2021-08-19 10:56:13 +02:00
Martin Carlberg 8d9c11b6f2 Fixed: Make sure we return the result from an executed file in the callback 2021-08-18 15:56:36 +02:00
Martin Carlberg afd23e3457 Fixed: Added file translation dictionary for the Foundation framework
This allows the Foundation framework to be compiled while loading the Application in the Browser
2021-08-17 16:47:06 +02:00
Alfred Wärnsäter ddeaad74d0 added jake stuff to bundletask 2021-08-10 12:31:48 +02:00
Alfred Wärnsäter a82472f509 removed unused dependancies 2021-08-10 12:29:43 +02:00
Alfred Wärnsäter 4a43e376ed modified capp to work with node 2021-08-10 12:27:50 +02:00
Alfred Wärnsäter 9ab82e1e5e removed console.log statement 2021-08-10 12:24:20 +02:00
Didier KorthoudtandGitHub 4b28d0c38b Fixed: setTextColor on a CPTextField would not take visual effect before an event (#2993) 2021-08-06 12:17:07 +02:00
Alfred Wärnsäter 1924cd1822 removed fs-extra dependancy 2021-08-06 11:02:55 +02:00
Alfred Wärnsäter 730b2dd874 removed glob dependancy 2021-08-06 10:36:04 +02:00
Alfred Wärnsäter 1c2b383838 removed uuid dependancy 2021-08-06 09:43:49 +02:00
Alfred Wärnsäter 0b99f83d6f fixed bug that broke the build process when building twice 2021-08-05 17:53:45 +02:00
Alfred Wärnsäter dc5b3f48e8 fixed watch functionality in nib2cib 2021-08-05 16:22:36 +02:00
Alfred Wärnsäter d17671c99e added parsing of command line arguments 2021-08-04 15:19:10 +02:00
Alfred Wärnsäter b69259e83b swapped print to console.log 2021-08-04 15:16:41 +02:00
Alfred Wärnsäter f2c80dc815 added node_modules to .gitignore 2021-08-04 15:15:12 +02:00
Alfred Wärnsäter cbc281b173 added terser as compressor 2021-08-04 09:25:36 +02:00
Alfred Wärnsäter 472f859bd8 basic support for nib2cib 2021-08-03 13:39:54 +02:00
Alfred Wärnsäter e71f650650 removal of print and debugger statements + added some more color 2021-07-30 15:35:57 +02:00
Alfred Wärnsäter e64c9d9cd4 starting to port the capp tool to node 2021-07-30 14:09:11 +02:00
Alfred Wärnsäter 87a1c6621c ported nib2cib from narwhal to node, it now build using objj-jake 2021-07-29 13:20:30 +02:00
Didier KorthoudtandGitHub 09f49c4afa Fixed: CPButton should not have the same label text size whatever the control size (#2990)
Adding font size definitions to Aristo2.
2021-07-29 12:38:25 +02:00
eba1b2f999 Fixed: CPSearchField's bezel did not resize (#2987)
Co-authored-by: Didier Korthoudt <didier.korthoudt@icloud.com>
2021-07-29 11:39:42 +02:00
daboe01andMartin Carlberg 8e026279ac fixed: CPButton's images were lost when becoming disabled 2021-07-29 11:30:55 +02:00
Alfred Wärnsäter 3605e99914 minor bugfixes and clean up 2021-07-28 10:12:24 +02:00
Alfred Wärnsäter 5e9d479cef AppKit and Themes are now buildable 2021-07-27 08:59:05 +02:00
David RichardsonandMartin Carlberg fb20463449 Fix Java version check to cleanly identify both Oracle and OpenJDK variants
Set minimum supported version to 8 to simplify this check.
Java 8 is the last variant from Oracle to be free and unencumbered, and is classified LTS.
It is also available from OpenJDK.
2021-07-05 11:07:53 +02:00
Alfred Wärnsäter f5db73342f changed some code in blendtask.j to older javascript 2021-07-01 16:45:39 +02:00
Alfred Wärnsäter 9b2dc23197 finished porting blendtask.j 2021-07-01 16:30:30 +02:00
Alfred Wärnsäter 067052e1a8 ported blendtask.j to node api 2021-07-01 16:17:43 +02:00
Alfred Wärnsäter 441e5fbc05 ported nib2cib to node the node api 2021-07-01 16:00:32 +02:00
Alfred Wärnsäter 0a2aae3bc2 some restructuring of the repo, trying to fix problems when building with node 2021-06-30 10:13:52 +02:00
Alfred Wärnsäter a76c798500 Merge remote-tracking branch 'mrcarlberg/compile_deep_structured_project_in_browser' into tmp 2021-06-23 10:45:34 +02:00
Alfred Wärnsäter c238ebeef4 major changes, very much WIP, experimenting with async 2021-06-22 14:04:31 +02:00
Alfred Wärnsäter 206eddbdbd further removal of narwhal APIs 2021-06-16 15:43:19 +02:00
Alfred Wärnsäter 45549cdbcf removing narwhal api from jakefiles 2021-06-14 13:17:14 +02:00
cacaodevandGitHub e043b6a8c5 Merge pull request #2978 from daboe01/nib2cib-update
fixed: some cib files have been outdated
2021-05-22 10:48:30 +02:00
daboe01 677076b89d fixed: some cib files have been outdated 2021-04-01 18:04:06 +02:00
cacaodev 77c9b99f74 Manual test exposing issue #2970 2021-03-07 20:46:44 +01:00
cacaodevandGitHub c8cdda0c18 Merge pull request #2962 from mrcarlberg/cptextview_more_ib_options
Fixed: CPTextView now handles more options from Interface Builder
2021-03-07 08:48:50 +01:00
daboe01andGitHub 41cd73703e Fixed: sharedApplication was instantiating the wrong class in subclasses of CPApplication (#2968)
Previously, CPApplication was hard-coded. This PR makes sharedApplication
instantiating the CPApp of the correct class.
2021-01-19 09:03:37 +01:00
cacaodevandGitHub 607e84c052 Merge pull request #2964 from mrcarlberg/compiler_remove_unused
Fixed: Removed unused variables and statements in compiler
2020-12-23 07:36:29 +01:00
Martin Carlberg 8416390631 Fixed: Removed unused variables and statements in compiler 2020-12-22 20:16:30 +01:00
Martin Carlberg 6094d25cfb New: Support to compile deep structured project in the web browser
A Cappuccino project has always needed to have a flat file structure to
be able to compile from source in the web browser.

A new dictionary can be added to the project's Info.plist with the key
'CPFileTranslationDictionary'. It should contain all the path
translations in the project to allow the Browser to find out where in
the file structure the source files are. Check in the AppKit framework
for an example.

Also, a include list can be added in the Info.plist for the key
'CPCompileIncludeFileArray'. The file in the list will be included
by a '#include' statement for each file that is compiled in this project

A last new feature is to add macros in the 'OBJJ_COMPILER_FLAGS' global
variable. It is usually declared in the index.html file. It is done
with the format '-Dmacroname[=macrodefinition]'.

An updated Info.plist file in the AppKit framework will allow the AppKit
to compile from the source in the web browser. The following things is
needed to get this to work:

1. Replace the AppKit folder in your project's Frameworks folder with a
copy of the AppKit folder from the Cappuccino project.
2. Add a copy of the built Aristo2.blend folder to the AppKit's Resource
folder.
3. Add "-DPLATFORM_DOM", "-DPLATFORM_BROWSER" and optionally "-DDEBUG"
to the global variable 'OBJJ_COMPILER_FLAGS' in the project's index.html
file.

The app load time will increase (about 3 seconds on a 2018 MacBook Pro)
as the AppKit framework is compiled from source.

The Foundation framework is not yet tested but it might be working by
adding info about the file structure in the Info.plist file.
2020-12-21 11:14:36 +01:00
cacaodevandGitHub c80504efae Merge pull request #2960 from mrcarlberg/cptextview_exposedrect
Fixed: Prevent crash in CPTextView when _exposedRect is nil
2020-12-19 15:19:19 +01:00
cacaodevandGitHub 2589033523 Merge pull request #2961 from mrcarlberg/radio_multiple_value_bindings_test
New: Unit test to illustrate multiple value bindings on radio buttons
2020-12-19 15:18:27 +01:00
Martin Carlberg f74fed5ee0 Fixed: CPTextView now handles more options from Interface Builder
The new options are:
1. Resizable Horizontally
2. Resizable Vertically
3. Max Size

Also two options from the Text Container is recognized:
1. Tracks text view width
2. Tracks text view height

The last two are needed to allow the text view to recalculate
the size of its content if the frame size is changed.
2020-12-16 11:29:11 +01:00
Martin Carlberg 01e295084c New: Unit test to illustrate multiple value bindings on radio buttons 2020-12-14 13:11:24 +01:00
Martin Carlberg 9f923941a8 Fixed: Prevent crash when _exposedRect is nil 2020-12-14 12:47:34 +01:00
Didier KorthoudtandGitHub 3aba03eb28 Fixed: Missing call to super in NSTabView.j (#2956) 2020-11-22 11:01:14 +01:00
Didier KorthoudtandGitHub 1107195ab6 Fixed: Modern Cocoa behavior, new theme parameters, Aristo3 CSS theme ready for CPTabView (#2936) 2020-11-20 08:33:56 +01:00
Didier KorthoudtandGitHub b67384cdd1 Fixed: Running condition where the value is set before the radio button is associated in a radio group (#2952) 2020-11-20 08:25:03 +01:00
David RichardsonandGitHub 59603b550e Fixed: "Loading…" animation using modern layout (#2953)
Correct vertical alignment in all modern browsers. IE no longer a target.
2020-11-20 08:22:45 +01:00
David RichardsonandGitHub c52f714149 Fixed: Version check for XcodeCapp compatibility with Big Sur (#2954) 2020-11-20 08:20:19 +01:00
Didier KorthoudtandGitHub 35420732d1 Fixed: Modern Cocoa behavior and Aristo3 CSS theme ready for CPDatePicker (#2935)
Also, clock hands can be manipulated
2020-11-06 16:27:07 +01:00
David RichardsonandGitHub 7f48b84292 Fixed: Update template for NibApplication's xib and cib to modern format (#2946) 2020-11-06 08:31:22 +01:00
Didier KorthoudtandGitHub 5110c5706f Fixed: Compilation warnings (#2950) 2020-11-06 07:25:21 +01:00
Didier KorthoudtandGitHub 633511acda Fixed: Before this PR, placing a CPTableView in a CPBox would break nib2cib (#2949) 2020-10-31 17:56:13 +01:00
Didier KorthoudtandGitHub 75d0a69c02 Fixed: uncorrect CPStepper rendering (#2948) 2020-10-30 10:58:34 +01:00
Didier KorthoudtandGitHub e6fe9396f8 Fixed: Change default bezel style to CPRoundRectBezelStyle for CPButton (#2947)
Also removes unwanted comments
2020-10-27 11:01:18 +01:00
Didier KorthoudtandGitHub 5c4107835b New: Aristo3 improvements for CPSearchField (#2934)
New theme parameters
Animations
Modern Cocoa behavior
Aristo3 CSS theme ready
2020-10-23 09:05:33 +02:00
Didier KorthoudtandGitHub 57cc90f89f New: Provides more information on an error message in CPScroller (#2931) 2020-10-23 08:43:59 +02:00
Didier KorthoudtandGitHub 7e08e48a8a New: Adds a new theme parameter "menu-offset" to CPPopUpButton instead of hard coded value (#2923) 2020-10-23 08:42:00 +02:00
Didier KorthoudtandGitHub 87719f1161 Fixed: Adds the missing isCSSBased method for CPView (#2945) 2020-10-12 08:51:49 +02:00
Didier KorthoudtandGitHub 99d7c8d824 New: Modern Cocoa behavior for Menus (#2929)
More theme parameters
Modern Cocoa behavior
First menubar item can be displayed specifically
All 3 control sizes are now managed
2020-10-09 15:52:54 +02:00
Didier KorthoudtandGitHub 1caf4f99cf Fixed: Correct / complete theme states for themed values on CPStepper (#2930) 2020-10-09 14:39:38 +02:00
Didier KorthoudtandGitHub 78b3887e4a New: CSS shadow, new theme parameters and Aristo3 CSS theme ready for CPWindow (#2927) 2020-10-09 14:29:10 +02:00
Didier KorthoudtandGitHub bb064aacd5 New: The ability to control CPPopoverWindow background color (#2928)
This introduces a Cappuccino specific behavior that permits to control the background color of the popover by setting a background color on the content view.
2020-10-09 13:37:47 +02:00
Didier KorthoudtandGitHub d9e8321d9e Fixed: CPButton's now set their font using [self font] (#2943)
The corresponding adaptation in CPControl was missing in the previous PR
2020-10-09 13:05:51 +02:00
Didier KorthoudtandGitHub 5f6df95e30 New: Modern Cocoa behavior and methods, ticked sliders and Aristo3 CSS theme ready (#2926) 2020-10-09 11:47:18 +02:00
Didier KorthoudtandGitHub ef779c346e New: Support modern Cocoa behavior regarding radio buttons groups. (#2941) 2020-10-09 09:35:56 +02:00
Martin CarlbergandGitHub c1543d4a2f Fixed: Loading cached theme attributes will miss previous cached values if superclass is done before subclass (#2892) 2020-10-02 16:01:30 +02:00
Didier KorthoudtandGitHub 9145e27009 Fixed: Aristo3 CSS theme ready and replaces setTextFieldBackgroundColor by setBackgroundColor for CPTextField (#2925) 2020-10-02 14:47:50 +02:00
Didier KorthoudtandGitHub 299f1a9102 Fixed: Aristo3 ready and compatible with new button state management for CPRadio (#2922) 2020-10-02 14:03:25 +02:00
bedaltonandGitHub 6eab438778 Fixed: CPKeyedArchiver method call does not match selector tested (#2904)
Delegate methods described on lines 76 and 85 are not the selectors
checked on lines 305 and line 302, but are the methods actually called
on the delegate on lines 195 and 225. This fix updates the method
selectors checked on the delegate, to match those defined and called
within the CPKeyedArchiver class.

Fixes #2679
2020-10-02 13:52:42 +02:00
Didier KorthoudtandGitHub 2a623fbb8c Fixed: correct mask values used to determine image position for NSButton.j (#2906) 2020-10-02 13:49:11 +02:00
Didier KorthoudtandGitHub 7bde091f1b FIXED: when using a custom view with subviews, subviews were presented in the reversed order (#2913) 2020-10-02 13:31:45 +02:00
Didier KorthoudtandGitHub 412baf7872 Fixed: Aristo3 ready and modern Cocoa behavior for CPBox (#2924) 2020-10-02 13:28:06 +02:00
Didier KorthoudtandGitHub 010057d9e1 New: CPCheckBox Aristo3 ready and compatible with new button state management (#2921) 2020-10-02 13:05:59 +02:00
Didier KorthoudtandGitHub 6c7d8df565 Aristo3: CPButton (#2920) 2020-10-02 12:59:32 +02:00
Didier KorthoudtandGitHub 92598da06f New: themable-system-font (#2919) 2020-10-02 12:55:32 +02:00
Didier KorthoudtandGitHub 601d6f7c6c New: class method to BKThemeDescriptor that enables a view to inherit theme values of another view (#2916) 2020-10-02 12:31:22 +02:00
Didier KorthoudtandGitHub e13cebaa3a NEW: Material icon image (#2909) 2020-10-02 12:13:00 +02:00
Didier KorthoudtandGitHub 5724868c5a Fixed: restorePreviousCSSState method for CPColor must be a class method for internal reasons (#2912) 2020-10-02 10:58:20 +02:00
Didier KorthoudtandGitHub 03972f0aec Fixed: The classname for CSS theming on CPImage was not specified in the correct DOM element (#2908) 2020-10-02 10:55:55 +02:00
Didier KorthoudtandGitHub 6143ec4180 Fixed: Theme compilation problem because of lack of rgba capability of the compiler environment.(#2910) 2020-09-11 09:01:33 +02:00
Didier KorthoudtandGitHub c30464ee77 New: This adds the CSS dictionaries to the description of the color (#2911) 2020-09-11 08:55:10 +02:00
cacaodevandGitHub 1e1e6456cd Merge pull request #2902 from daboe01/test-attributedString-replacing
new: unittest for replaceOccurrencesOfString:withString:options:range:
2020-09-02 18:26:14 +02:00
cacaodevandGitHub 6c46bb4756 Merge pull request #2940 from didierkorthoudt/031-CPViewAnimator-fix
FIXED: This PR fixes correct parameter type in CPViewAnimator -setAlphaValue
2020-09-02 18:21:45 +02:00
Didier Korthoudt 5ac6b1d1f1 Update CPViewAnimator.j
This fixes parameter type.
2020-08-30 10:01:11 +02:00
daboe01 9c95c9c6e9 formatting 2020-07-13 20:37:52 +02:00
daboe01 4b052e74f1 test whether range restriction works 2020-07-05 16:06:04 +02:00
daboe01 bd6b8e4b7f fixed: comparison between wrong objects 2020-07-03 21:27:48 +02:00
daboe01 26e8432bb0 debugging 2020-07-03 19:55:51 +02:00
daboe01 05f9fd22fe formatting 2020-07-03 19:36:06 +02:00
daboe01 8f5bde2797 new: unittest for replaceOccurrencesOfString:withString:options:range: 2020-07-02 19:38:34 +02:00
daboe01andGitHub 77fe16faec Fixed: background color attribute was ignored by CPTextView (#2899) 2020-07-01 16:33:07 +02:00
Martin CarlbergandGitHub 38dd776049 Fixed: JavaScriptCore (WebKit) has a limit at 65536 on number of arguments in a function. (#2891)
The compiler will crash for really large Objective-J files as the array with code segments will hit this limit.
The solution is to append the array segment by segment.
2020-06-30 20:53:28 +02:00
daboe01andGitHub 7e3c4074e4 New: replaceOccurrencesOfString:(CPString)target withString:(CPString… (#2900)
New: replaceOccurrencesOfString:(CPString)target withString:(CPString)replacement options:(int)options range:(CSRange)searchRange
2020-06-30 20:52:34 +02:00
cacaodevandGitHub 89c8f8e80f Merge pull request #2895 from mrcarlberg/bad_merge
Fixed: Removed old unused line from a bad manual merge
2020-05-05 08:38:05 +02:00
Martin Carlberg 7397e681f4 Fixed: Removed old unused line from a bad manual merge 2020-05-04 13:42:37 +02:00
Didier KorthoudtandGitHub e7d5afe90e New: Added dynamic attributes set for CSS based themes (#2701) 2020-04-06 13:10:34 +02:00
Didier KorthoudtandGitHub 2d9d354a05 Fixed: When a CPSearchField predicate was bound specifying a predicate format using more than one time the value of the search field ($value), only the first occurence was correctly set, others were set to null (#2777) 2020-04-06 13:03:57 +02:00
Didier KorthoudtandGitHub 60a686d75c Fixed: _CPMenuItemStandardView didn't take in account the left-margin theme attribute (#2689) 2020-04-06 09:18:31 +02:00
Didier KorthoudtandGitHub 89b70843c7 Fixed: Nib2cib was using hard coded frame adjustment for CPBox (#2761) 2020-04-06 09:17:05 +02:00
Didier KorthoudtandGitHub 617987f4a5 Fixed: CPTextField forced height to 29 instead of using theme value min-size (#2688) 2020-03-17 09:14:25 +01:00
daboe01andGitHub 5bb338d6ec New: CPTextField now supports the CPEditorRegistrationProtocol (#2169) 2020-03-11 10:30:00 +01:00
Didier KorthoudtandGitHub 8003d91c4a Fixed: [CPControl setTextColor:] was missing theme state attribute (#2828) 2020-03-11 10:20:04 +01:00
Didier KorthoudtandGitHub a4ef18ddab FIXED: Before this PR, only CPControl could use nib2cib-adjustment-frame. (#2831) 2020-03-11 10:17:14 +01:00
daboe01andGitHub 82e55b4761 Fixed: _glyphsFrames and _glyphsOffsets could be used uninitialized in CPTextView (#2886) 2020-03-03 17:04:52 +01:00
Didier KorthoudtandGitHub 3a51c386ca Fixed: Before this PR, a click in a not first key responder CPTextField would misplace the caret if text alignment was not CPLeftTextAlignment #2887
Adapts the calculation of where in the textfield text the mouse is clicked to take in account the text alignment
2020-03-03 17:02:42 +01:00
Didier KorthoudtandGitHub 9868519cc0 Fix: Before this PR, the method attributeBySettingValue ignored existing values #2888 2020-03-03 16:43:29 +01:00
Didier KorthoudtandGitHub 038c007915 FIXED: Before this PR, CPButton never declares that its label should be single line (#2889) 2020-03-03 13:44:07 +01:00
Didier KorthoudtandGitHub ba6350e24d NEW: CPSplitView modern Cocoa behavior implementation (#2876) 2020-02-21 14:32:53 +01:00
Martin CarlbergandGitHub 1c866931f3 New: The compiler will now create warnings for variables that are never read (#2871)
This new warning adds a lot of warnings in the Cappuccino frameworks. I have turned off
the warning in the Jakefiles when compiling most of the Cappuccino frameworks. But it is
on as default for any user projects.

So there is also a new feature to turn off/on warnings as a compiler flag.

These flags are (all flags are on as default):
-Wunused-but-set-variable                    Warning when a local variable is never read.
-Wshadow-ivar                                Warning when a local variable is shadowing an instance variable for the class.
-Wcreate-global-inside-function-or-method    Warning when creating a global variable inside a function or method.
-Wunknown-class-or-global                    Warning when a class or global variable is not known.
-Wunknown-ivar-type                          Warning when the type for an instance variable is not known.

To turn off a flag add a 'no-' prefix. Example: -Wno-unused-but-set-variable

For an example how to use it in a Jakefile please look at the Jakefiles in this commit.
2020-02-21 14:29:48 +01:00
cacaodevandGitHub b7aff28b5e Merge pull request #2884 from daboe01/documentation-for-attributedStringWithAttachment
fixed: documentation for attributedStringWithAttachment: was missing
2020-02-04 13:14:45 +01:00
cacaodevandGitHub f0897ffdf8 Merge pull request #2885 from mrcarlberg/predicate_not_equal_nil
Fixed: CPPredicate does never evaluate to true for 'something != nil'
2020-02-04 13:06:37 +01:00
Martin Carlberg f5937a6fad Fixed: CPComparisonPredicate does never evaluate to true for a predicate like 'something != nil'
An example:

var array = @[ @{@"Name": @"1"},
               @{@"Name": @"2", @"approveTime": @"Now"}
             ];

var predicate = [CPPredicate predicateWithFormat:@"approveTime != nil"];

CPLog(@"result: %@", [array filteredArrayUsingPredicate:predicate]); // result: <empty array>

If I run this in Cappuccino I get an empty array

If I run it in Cocoa on a Mac I get:

result: (
        {
        Name = 2;
        approveTime = Now;
    }
2020-01-31 14:24:29 +01:00
Martin CarlbergandGitHub 7dc77ed609 Fixed: Make sure we handle undefined when testing for nil values (#2862) 2020-01-31 13:43:58 +01:00
daboe01 d1bfe62a65 removed: obsolete fixme comment 2020-01-12 17:08:23 +01:00
daboe01 f7c8f24bff removed dead code 2020-01-11 15:13:30 +01:00
daboe01 055d63eeb5 formatting 2020-01-11 15:13:04 +01:00
daboe01 ef7f92ed15 fixed: documentation for attributedStringWithAttachment: was missing 2020-01-11 15:09:41 +01:00
daboe01andMartin Carlberg 8daa53dd3e Fixed: CPTextView keyboard issue in recent Firefox versions (#2874)
Wrong characters were sometimes emitted in keyboard events on Firefox
2020-01-07 12:34:39 +01:00
Martin CarlbergandGitHub 109003ae12 Fixed: Performance improvement on visibleRect when updating tracking areas (#2881)
Calculations of the visible rect can be a heavy operation as it depends of the superviews
visible rect. They have to be transformed and intersected together to create the result.
This calculation is a recursive operation that travels up the view hierarchy all the way
to the top.

Updating the tracking areas is also a recursive operation. But it travels down the view hierarchy
instead. It will calculate the new tracking area using the visible rect for the current view. For
each view it updates it will get the visible rect that has to travel all the way up the view
hierarchy to calculate it by transform and intersect them together. This results in that the visible
rect will be calculated for each view multible times. This makes it a very slow operation, specially
for deeper view hierarchies.

This fix will send along the visible rect for the superview when traveling down the
view hierarchy. This means that the visible rect does not need to travel up the view hierarchy
to be calculated. It will just need transform and intersect the provided rect for its superview
with the one from itself.
2020-01-06 12:48:40 +01:00
Martin CarlbergandGitHub 36f1abdbe6 Fixed: CPAppearance has much better performance now when views needs layout. (#2880)
This makes updating views much faster when they need layout. This will make resizing browser window and changing split views sizes much smoother.

The effectiveAppearance is inherited from the superview. The superviews appearance is passed along as it is recomputed down the view hierarchy.
Also the current appearance is saved on each view to make it possible to only change the theme states when the appearance is changed.
2020-01-06 12:35:38 +01:00
Martin CarlbergandGitHub 50519776e0 Fixed: Update Tracking areas only once when doing setFrame: (#2879)
This speed improvement is very notable when resizing a browser window of altering the size of split views.
The fix uses a variable on the window to control when to update the tracking areas.
If the view is not connected to a window the tracking areas will not be updated as they will
be when added to a window.
2020-01-06 12:32:35 +01:00
daboe01andMartin Carlberg 9e289574ff Fixed: attachment support was missing in CPTextView (#2872) 2019-12-19 09:08:33 +01:00
cacaodevandGitHub 2d96b06d4c Merge pull request #2878 from didierkorthoudt/CPButton-continous-bug
FIXED: Before this PR, disabled buttons that were continuous responded to mouse clicks
2019-12-17 13:27:06 +01:00
cacaodevandGitHub 0c706cfed2 Merge pull request #2866 from mrcarlberg/cpset_enumerator_use_stop_variable
Fixed: CPSet enumerateObjectsUsingBlock: will honor the stop variable
2019-12-16 11:27:37 +01:00
Didier Korthoudt 3f9e1c6c47 Continuous fix 2019-12-15 10:48:21 +01:00
jasperdebandMartin Carlberg 58c08cebd7 Fixed: Added underline support in CPTextView (#2875) 2019-12-06 09:12:31 +01:00
Martin CarlbergandGitHub fed0703ecf New: Allow lazy loading control for combined observer key paths (#2854)
This pull request adds a kvoValueForKey: method used by _CPKVOForwardingObserver for getting values.
The default action is to just return the valueForKey value.
Override this method if you want any other behavior.
It can be used to just return nil if you are implementing a lazy load behavior on a class.
It can allow a combined binding to observe this object without trigger any lazy loading.
2019-11-28 09:38:55 +01:00
Martin CarlbergandGitHub aaed1a934e Fixed: When in modal mode make sure a focus event will make the modal window the key window (#2867)
The default was to make the first window in the most background layer the key window if nothing else was used.
This does not work well if there is a modal window that should have all the attention.

This solution will first choose the modal window if in modal mode. If not the old variant is used.
2019-11-27 19:16:03 +01:00
Martin CarlbergandGitHub 11639af26e Fixed: Let the text field handle key commands when it is selectable. (#2868)
There was a problem introduced by pull request #2600 when trying to select and copy text in a selectable text field.
The problem only occurs when the text field is in a modal window.

It was caused by the modal run loop that is present as an eventListener on the CPApplication when in modal mode. It will
force a bail out from the sendEvent: method in CPApplication when trying to handle the event. As the check for key
equivalent is moved down by the #2600 pull request it will never be allowed to handle a copy command from the browser
menu or key equivalent.

The solution is to allow the text field to handle the event if it is selectable. This will also allow the text selection
to be altered from the keyboard with keys like shift-left/right/up/down arrow. Combinations like shift-option arrow also
work for whole word selection.
2019-11-26 09:20:47 +01:00
cacaodevandMartin Carlberg 623ad2b1dc Fixed: Previoulsly, clearsFilterPredicateOnInsertion was applied (removes filter predicate) when setting content or on content binding. (#2860)
With Tests: Foundation unit test.
Solves #2791
2019-11-12 14:02:35 +01:00
Brian M. PalmaandMartin Carlberg ac68fec6b1 FIXED: Add Dark Mode to XcodeCapp (#2856)
FIXED: Add Dark Mode to XcodeCapp

This commit also fixes an issue where two NSBox instances had a borderRadius of 100 (boxStatus and boxImport) in IB. The borderRadius values are now updated to be half the size of the height and width values, restoring the circle visual.

Update installation directory for XcodeCapp

- Replace $LOCAL_APPS_DIR with $USER_APPS_DIR
- Installation directory updated from /Applications to ~/Applications
2019-10-18 13:37:22 +02:00
Martin Carlberg dad49354aa Fixed: CPSet enumerateObjectsUsingBlock: will honor the stop variable
Test case also added.

Deprecated the very old behaviour that the block could return YES to abort the enumeration.
2019-10-18 13:01:04 +02:00
daboe01andMartin Carlberg ce4fa3c027 Fixed: Pressing capslock inserted whitespaces under certain conditions (#2857)
This was present in a CPTextView.

A press on caps lock should also result in a flagsChanged event.
An event should have the corresponding flag for caps lock in modifierFlags.
2019-09-10 08:34:07 +02:00
meelashandMartin Carlberg 02d1a12bf5 Fixed: Update nonworking link (#2859) 2019-09-02 09:23:17 +02:00
cacaodevandGitHub 78cbc3871e Merge pull request #2852 from mrcarlberg/msg_send_return_undefined_when_receiver_is_undefined
New: msgSend will return undefined instead of nil when the receiver is undefined.
2019-08-31 11:28:17 +02:00
daboe01andMartin Carlberg f9bb882ceb Formatting: make readme a litte more concise (#2858)
removed the wrong attribute 'demo' for our tutorials link
2019-08-26 09:24:58 +02:00
cacaodevandGitHub 87fc6bde1d Merge pull request #2853 from mrcarlberg/optimize_table_column_bindings_with_long_key_paths
Fixed: Optimization for bindings with longer key paths in table views.
2019-08-17 18:33:33 +02:00
Martin Carlberg f666367b5d Fixed: Optimization for bindings with longer key paths in table views.
This prevents a buildup of large arrays with a lot of values and then choose one row and throw away the rest. This is great for speed and a must for lazy loading.

Previous there was a optimization for this but it was only effective for short combined key path like 'a.b'. This pull request makes it effective for any kind of length of a combined key path like 'a.b.c.d...'.

This is done by returning the object at a row in the first found CPArray in the key path
that is divided in a first and second part.
The first part is never a combined key path. The second part can be a combined key path.
If this optimization is not done we will create an array with the valueForKeyPath value on each row and then pick
the wanted value for the row and throw away all the other rows. It is much more effective to first
pick the row and then do the valueForKeyPath on the rest of the key path.
2019-06-26 09:37:40 +02:00
Martin Carlberg 81c02f24c6 New: msgSend will return undefined instead of nil when the receiver is undefined.
The msgSend function has always returned nil if the receiver has been nil or undefined.
Example:

var a = undefined;
var b = [a someSelector]; // b = nil

The variable b is now nil.

This pull request adds the ability for the msgSend function to return undefined if the receiver is undefined. If the receiver is nil it still return nil.
The above example again:

var a = undefined;
var b = [a someSelector]; // b = undefined

The variable b is now undefined.

Background.
The use of nil in Objective-C corresponds to the use of null in C and C++ and stands for "no value". A fundamental function in Objective-C is when you send a message to a receiver that is nil the result is again a nil value. This can be very convenient as you don't need the check if a receiver is nil before sending a message to it.

Objective-J adds the ability the use class structures and message send functionality for Javascript in the same way as Objective-C adds this to C and C++. Javascript also has the value null and is handled in the same way for Objective-J. Javascript also has the value undefined that stands for "not yet defined". This can sometimes be confusing and many try to handle null and undefined as the same thing. This is almost what Objective-J and the Cappuccino frameworks always has been doing. They try to always check for both null and ``undefined and always return nil but never undefined. We can say that Objective-J understands undefined but will try to translate it to nil.

Why do we need this change.
Javascript has both null and undefined and Objective-J is a superset of Javascript. It is now very hard to use undefined in Objective-J code as it will always try to translate it to nil. There are some Javascript libraries that use both null and undefined values and they are very hard to use from Objective-J programs today.  Same if you decide to use nil and undefined as a value in your own Objective-J code. This small change will make undefined a full member of the Objective-J language. It should be as it is a superset of Javascript. The Cappuccino frameworks will still handle undefined but only return nil.

How will it impact.
Today most methods will never return undefined so this is a very limited problem. If any does this the main concern is if some code will only check for nil and not undefined.
Example:

var a = [someObject someSelector];
If (a === nil) a = 42;
...

If the variable someObject contains undefined the variable a will now be set to undefined instead of nil.  But the variable a will then never be set to 42.
The correct way is to check for both nil and undefined like this:

var a = [someObject someSelector];
If (a == nil) a = 42;
...
2019-06-24 17:36:15 +02:00
Didier KorthoudtandMartin Carlberg 1d01ed92d8 Fixed: CPSearchField, when no recent searches were done, the menu wasn’t showing, even if search categories were specified (#2846) 2019-06-13 16:30:53 +02:00
daboe01andMartin Carlberg 1a7ced34a7 Fixed: smart copy/paste cycle was leaving an additional whitespace on the LHS (#2776) 2019-06-13 16:17:52 +02:00
Martin CarlbergandGitHub 47ab94b5bc Fixed: If sourcemap is available include it when building with a nondebug version of the tools. (#2850)
The sourcemap was not included when building from command line with the release (the default) version of the tools.
2019-06-13 16:15:48 +02:00
Didier KorthoudtandMartin Carlberg bea0778acc Fixed: Before this PR, cell based table views that use specific font, reverted to standard font when selected/editing (#2845) 2019-06-13 16:14:48 +02:00
Didier KorthoudtandMartin Carlberg eeba5087b1 Fixed: Before this, under certain circumstances, CPControl didn't declare its tracking areas soon enough (#2827) 2019-06-13 16:12:52 +02:00
daboe01andMartin Carlberg 7bd8bf02f6 Fixed: Typo in function call to _CPDecimalSetZero and made the test case work properly (#2820) 2019-06-13 16:09:17 +02:00
Martin CarlbergandGitHub 378f87a634 Fixed: Temporary fix so finding the compiler can work both in the Narwhal and Node world (#2793) 2019-06-13 16:06:15 +02:00
Didier KorthoudtandMartin Carlberg 76dd5383ab Fixed: A «feature» of Xcode where IB sometimes stores NSFont values in the alternate image property. (#2844) 2019-06-13 16:04:59 +02:00
daboe01andMartin Carlberg 129ca185e4 Fixed: backspace triggered page back in FireFox (#2849) 2019-06-13 15:59:35 +02:00
daboe01andMartin Carlberg 1f4ef42625 Fixed: index.html and index-debug.html were outdated in the manual tests (#2848) 2019-06-13 15:58:34 +02:00
daboe01andMartin Carlberg eb55e4def6 Fixed: keyboard issues from FF66 alignmets to the other major browsers (#2847) 2019-05-24 12:57:57 +02:00
Alexandre WilhelmandGitHub acda834ad9 Merge pull request #2819 from daboe01/CPFontManager-duplicate-methods-removal
fixed: removed outdated duplicate method definitions in CPFontManager.j
2019-04-14 20:02:22 -07:00
Alexandre WilhelmandGitHub aba3e30d9c Merge pull request #2824 from daboe01/cpdocumentcontroller-return-type-fix
fixed: return type of openUntitledDocumentOfType:display:
2019-04-14 20:01:36 -07:00
Alexandre WilhelmandGitHub c9e55ff1dc Merge pull request #2825 from daboe01/CPTableHeaderView-return-type-fix
fixed: wrong return type of textField method in
2019-04-14 20:01:21 -07:00
Alexandre WilhelmandGitHub 013c5e9e58 Merge pull request #2826 from daboe01/cpproxy-return-type-fix
fixed: wrong return type of forward::
2019-04-14 20:01:07 -07:00
Didier Korthoudt 5e7f3dc24a Merge remote-tracking branch 'cappuccino/master' 2019-04-13 10:25:08 +02:00
daboe01 2ffa174900 fixed: wrong return type of forward:: 2019-04-08 14:42:23 +02:00
daboe01 26cbe17218 fixed: wrong return type of textField method in 2019-04-08 14:39:02 +02:00
daboe01 fc8f1dca4e fixed: return type of openUntitledDocumentOfType:display: 2019-04-08 14:32:06 +02:00
Alexandre WilhelmandGitHub 6b20a4f8f7 Merge pull request #2786 from didierkorthoudt/CPStepper-enabled-from-IB
FIXED: CPStepper was not receiving the enabled status from IB
2019-04-03 15:15:22 -07:00
Alexandre WilhelmandGitHub 091025a304 Merge pull request #2794 from mrcarlberg/initialize_missing_on_custom_root_class
Fixed: the class method +initialize was always sent even if the root class did not implement it.
2019-04-03 15:07:59 -07:00
Alexandre WilhelmandGitHub 1180789c0c Merge pull request #2823 from daboe01/CPBrowserDelegateMethodFix
fixed: CPBrowserDelegate_browser_imageValueForItem_ was defined twice
2019-04-03 14:37:33 -07:00
Alexandre WilhelmandGitHub ac056d4a06 Merge pull request #2822 from daboe01/cpcursor-fix
fixed: accidental creation of a global variable in CPCursor.j
2019-04-03 14:36:44 -07:00
Alexandre WilhelmandGitHub 7c196e098a Merge pull request #2821 from daboe01/CPGraphicsContext-typo-fix
fixed: typo in initWithGraphicsPort: declaration
2019-04-03 14:36:23 -07:00
daboe01 c612b13529 fixed: CPBrowserDelegate_browser_imageValueForItem_ was defined twice 2019-03-31 19:42:54 +02:00
daboe01 5f4c79f6c4 fixed: accidental creation of a global variable 2019-03-31 17:44:07 +02:00
daboe01 302cbf641e fixed: typo in initWithGraphicsPort: declaration 2019-03-31 17:37:44 +02:00
daboe01 4bc2e9ad44 fixed: removed outdated duplicate method definitions in CPFontManager.j 2019-03-31 17:24:03 +02:00
Alexandre WilhelmandGitHub 6853c4c212 Merge pull request #2779 from daboe01/textview-contextmenu
New: support contextmenus for CPTextView
2019-03-29 15:06:39 -07:00
Alexandre WilhelmandGitHub 800e15cfd0 Merge pull request #2803 from bedalton/fixed-return-type-CPPlatformPasteboard
Fixed: Return type CPPlatformPasteboard.j should return BOOL
2019-03-29 15:04:14 -07:00
Alexandre WilhelmandGitHub 873f184117 Merge pull request #2798 from bedalton/formatting-add-semi-colons-to-CPTextStorage
Formatting: Add semi-colons to CPTextStorage.j
2019-03-29 15:03:47 -07:00
Alexandre WilhelmandGitHub 3bae5cd5cb Merge pull request #2807 from bedalton/fixed-duplicate-method-in-cparraycontroller
Fixed: Duplicate method in CPArrayController
2019-03-29 15:03:26 -07:00
Alexandre WilhelmandGitHub 19300332e8 Merge pull request #2813 from bedalton/fixed-cpcontrol-misspelled-parameter-type
Fixed: CPControl misspelled parameter type
2019-03-29 15:02:12 -07:00
Alexandre WilhelmandGitHub 89d88c9644 Merge pull request #2811 from bedalton/formatting-remove-redundant-semi-colon-in-cptextview
Formatting: Remove redundant semi-colon in CPTextView
2019-03-29 15:01:52 -07:00
Alexandre WilhelmandGitHub 472014b1b1 Merge pull request #2812 from bedalton/fixed-cpwindowcontroller-returns-cpview
Fixed: Changed CPWindowController method return to CPView
2019-03-29 15:01:29 -07:00
Alexandre WilhelmandGitHub c094420428 Merge pull request #2810 from bedalton/fixed-cpscroller-return-style
Fixed: Change CPScroller's style method return type to int
2019-03-29 15:01:13 -07:00
Alexandre WilhelmandGitHub e948064063 Merge pull request #2809 from bedalton/fixed-cocolor-parameter-to-cpstring
Fixed: Changed CPColor parameter to CPString
2019-03-29 15:00:59 -07:00
Alexandre WilhelmandGitHub bdd3b7d2a5 Merge pull request #2808 from bedalton/fixed-cpbrowserdelegate-duplicate-method
Fixed: CPBrowserDelegate duplicate protocol method
2019-03-29 15:00:46 -07:00
Alexandre WilhelmandGitHub 404c37b54c Merge pull request #2800 from bedalton/fixed-mismatched-parameters-in-CPTextView
Fixed: mismatched parameters in CPTextView
2019-03-29 15:00:18 -07:00
Alexandre WilhelmandGitHub ac686a17fa Merge pull request #2799 from bedalton/fixed-mispelled-parameter-in-CPTextView
Fixed: Misspelled parameter in CPTextView.j
2019-03-29 14:59:55 -07:00
Alexandre WilhelmandGitHub bfc5068b5e Merge pull request #2796 from bedalton/formatting-remove-redundant-semi-colon-CPDatePicker
Formatting: Remove redundant semi-colon form CPDatePicker
2019-03-29 14:59:39 -07:00
Alexandre WilhelmandGitHub 649bee2330 Merge pull request #2806 from bedalton/fixed-cpbezier-path-nsinteger
Fixed: CPBezierPath using parameter type NSInteger
2019-03-29 14:59:18 -07:00
Alexandre WilhelmandGitHub 593587ea60 Merge pull request #2805 from bedalton/fixed-cpapplication-isactive-return-type
Fixed: CPApplication's isActive method return type
2019-03-29 14:59:02 -07:00
Alexandre WilhelmandGitHub 0ab81a7b32 Merge pull request #2804 from bedalton/fixed-_cpautocompletemenu-return-type
Fixed:  Changed void return to id in CPAutocompleteMenu.j
2019-03-29 14:58:50 -07:00
Alexandre WilhelmandGitHub 8bf937357c Merge pull request #2801 from bedalton/formatting-remove-semi-colon-_CPStandardWindowView
Formatting: Remove extraneous semi-colon _CPStandardWindowView.j
2019-03-29 14:58:16 -07:00
Alexandre WilhelmandGitHub 1e8b1fda81 Merge pull request #2797 from bedalton/fixed-return-type-_CPMenuBarWindow
Fixed: Return type in _CPMenuBarWindow
2019-03-29 14:57:43 -07:00
daniel cba9212150 Fixed: CPControl parameter type to CPVerticalTextAlignment
Parameter was set to type CPTextVerticalAlignment, but typedef was declared as CPVerticalTextAlignment. This commit fixes this mismatch
2019-03-29 11:58:51 -07:00
daniel a0a6c42227 Fixed: Change return in CPWindowController to CPView
In CPWindowController, method viewControllerContainerView, implies that it returns something, and it does. It returns the _viewControllerContainerView instance object, and return type should be changed from void to CPView
2019-03-28 15:19:59 -07:00
daniel c245d9de80 Formatting: Removed redundant semi-colon in CPTextField 2019-03-28 14:55:44 -07:00
daniel ca5cd8e09b Fixed: CPScroller's style method should have returned int
Despite returning an int and a comment stating it returns a value, CPScroller's style method had a return type of void.
2019-03-28 14:51:15 -07:00
daniel 34ac4cd23b Fixed: Changed CPColor parameter from string to CPString
Parameter type in CPColor was string, changed here to CPString, to make it more inline with other string parameter types.
2019-03-28 14:33:00 -07:00
daniel 8598fe8ad9 Revert "Fixed: Changed CPColor parameter type from string to CPString"
This reverts commit 06498672ab.
2019-03-28 14:32:00 -07:00
daniel 3699a31f28 Revert "Formatting: Removed extra semi-colon ThemeDescriptors.j"
This reverts commit 75cd5a75e1.
2019-03-28 14:31:17 -07:00
daniel 06498672ab Fixed: Changed CPColor parameter type from string to CPString
Parameter type in CPColor was string, changed here to CPString, to make it more inline with other string parameter types.
2019-03-28 14:29:50 -07:00
daniel cd3b92af7a Fixed:CPBrowserDelegate duplicate method
Method browser:imageValueForItem was defined twice in CPBrowserDelegate. Once on line 43, and the other on line 45. This removes the commit removed the second declaration
2019-03-28 14:26:08 -07:00
daniel e15cc29e2f Fixed: CPBezierPath used parameter types NSInteger
CPBezierPath has parameter type NSInteger. Assumed meant to be CPInteger
2019-03-28 14:19:09 -07:00
daniel dabeb066de Fixed: Duplicate method in CPArrayController.j
Method alwaysUsesMultipleValuesMarker is duplicated in class CPArrayController.j. Both methods have the same body and same selector, the only difference being their comments are slightly different. Both comments however communicate the same thing.
2019-03-28 14:11:28 -07:00
daniel c59e7cc456 Fixed: Changed CPApplication's isActive method return type to BOOL
Method has declared return type of void, despite the method returning a BOOL, and the name implying that it returns a BOOL
2019-03-28 14:08:00 -07:00
daniel 3c16bfef58 Fixed: Changed void return type to id in _CPAutocompleteMenu.j
tableView:objectValueForTableColumn:row: has return type set to void, despite returning an method call returning id. Similar methods also return id.
2019-03-28 14:01:31 -07:00
daniel ec24977d4e Revert "Fixed: changed void return type in _CPAutocompleMenu.j to id"
This reverts commit 10b4f57a0e.
2019-03-28 13:58:15 -07:00
daniel 10b4f57a0e Fixed: changed void return type in _CPAutocompleMenu.j to id
tableView:objectValueForTableColumn:row: has return type set to void, despite returning an method call returning id. Similar methods also return id.
2019-03-28 13:54:20 -07:00
daniel 75cd5a75e1 Formatting: Removed extra semi-colon ThemeDescriptors.j 2019-03-28 13:46:25 -07:00
daniel fb2d0ed170 Fixed: Return types in CPPlatformPasteboard.j should return BOOL
Method _mayRequireDOMPasteboardElementHack:flags had return type of void, despite returning a BOOL value, and also being annotated with a doc comment stating that it should return a BOOL value

Also some methods had return type "boolean", should possibly be BOOL
2019-03-28 13:42:39 -07:00
daniel d4e139eaf5 Fixed: Return type for method in CPPlatformPasteboard.j
Method return type is labeled as void despite returning a BOOL and the DOC comment stating that it should return a BOOL
2019-03-28 13:38:33 -07:00
daniel 49ef1276f6 Formatting: Removed extra semi-colon in _CPStandardWindowView.j 2019-03-28 13:32:56 -07:00
daniel 828788b643 Fixed: Mismatched parameter types in CPTextView
isBlinking had return type void, but returned a BOOL, and the method name implies that it returns a BOOL.

Some parameters were marked as integer, so were changed to int to coincide with most other names for integers.

setString had parameter type id, despite implying that parameter was a string, and the super class parameter being a string.
2019-03-28 13:21:34 -07:00
daniel 0ca8d7a258 Fixed: Mispelled DOMElement parameter in CPTextView.j 2019-03-28 13:12:30 -07:00
daniel 75de49d151 Formatting: Added potentially missing semi-colons in CPTextStorage 2019-03-28 13:08:19 -07:00
daniel d39e1c0c6e Fixed: Return type for font method should have been CPFont 2019-03-28 12:51:04 -07:00
daniel 8e7f201ca8 Formatting: Removed redundant semi-colon in CPDatePicker 2019-03-28 12:49:13 -07:00
daniel 85b2a9b0a0 Merge remote-tracking branch 'upstream/master' 2019-03-28 12:41:13 -07:00
Martin Carlberg d4e40faecc Fixed: the class method +initialize was always sent even if the root class did not implement it. Forwarding and Invocation worked also on the method.
To mimic Objective-C correctly the +initialize method should not be sent on a class hierarchy if it does not implement it.
Also the +initialize method should not allowed to be forwarded to another target with Invocation or any other forwarding mechanism.
Added test cases for this and cleaned up some test cases that succeeded for the wrong reason.

This change will not affect many projects as all classes inherit from CPObject.
2019-02-20 23:44:00 +01:00
Alexandre WilhelmandGitHub 0be913ab18 Merge pull request #2780 from daboe01/fixed-wrong-return-type-in-_CPCibClassSwapper
fixed: wrong return type in initializer of _CPCibClassSwapper
2019-02-06 16:58:44 -08:00
Alexandre WilhelmandGitHub bab30f3b61 Merge pull request #2781 from daboe01/fixed-wrong-return-type-in-shouldArchiveValueForKey-
fixed: wrong return type in shouldArchiveValueForKey:
2019-02-06 16:58:25 -08:00
Alexandre WilhelmandGitHub abb599c556 Merge pull request #2782 from daboe01/fixed-wrong-return-type-of-_menuWithName-
fixed: wrong return type of _menuWithName:
2019-02-06 16:57:59 -08:00
Alexandre WilhelmandGitHub 2b6c6e9ab3 Merge pull request #2783 from daboe01/fixed-wrong-return-type-of-backgroundColorForGlyphAtIndex-
fixed: wrong return type of backgroundColorForGlyphAtIndex:
2019-02-06 16:57:42 -08:00
Alexandre WilhelmandGitHub 0db0d744da Merge pull request #2784 from daboe01/fixed-wrong-return-type-in-isMovable
fixed: wrong return type in isMovable
2019-02-06 16:57:21 -08:00
Alexandre WilhelmandGitHub 6b9f2d29fc Merge pull request #2785 from daboe01/fixed-wrong-return-type-of-isMiniaturized
fixed: wrong return type of isMiniaturized
2019-02-06 16:56:49 -08:00
bedalton 2c141a5255 Revert "Fixed: CPMenuBarWindow did not return a value when expected"
This reverts commit 4f69a32700.
2019-01-04 17:24:14 -08:00
bedalton 4f69a32700 Fixed: CPMenuBarWindow did not return a value when expected
CPMenuBarWindows's font: method did not return a value when a CPFont was expected.
2019-01-04 17:24:05 -08:00
Didier Korthoudt 3d4c08ad20 CPStepper-enabled-from-IB 2018-10-27 12:01:57 +02:00
Didier Korthoudt 594d415976 Merge remote-tracking branch 'cappuccino/master' 2018-10-27 11:59:52 +02:00
daboe01 ae50fde4e1 fixed: wrong return type of isMiniaturized 2018-10-14 16:49:49 +02:00
daboe01 401461f1f0 fixed: wrong return type in isMovable 2018-10-14 13:36:53 +02:00
daboe01 676c6e106d fixed: wrong return type of backgroundColorForGlyphAtIndex: 2018-10-14 13:34:33 +02:00
daboe01 d0a066ccd3 fixed: wrong return type of _menuWithName: 2018-10-14 13:31:20 +02:00
daboe01 340e286277 fixed: wrong return type in shouldArchiveValueForKey: 2018-10-14 13:27:38 +02:00
daboe01 9211d41984 fixed: wrong return type in initializer of _CPCibClassSwapper 2018-10-14 13:24:03 +02:00
daboe01 686aa457d6 fixed: cut/copy did not autoenable 2018-10-07 21:22:37 +02:00
daboe01 1b1431f0d0 menu cleanup 2018-10-07 21:08:31 +02:00
daboe01 cbcb46597d fixed: syntax errors 2018-10-06 23:19:50 +02:00
daboe01 6644c85978 new: context menu support for CPTextView 2018-10-06 23:16:46 +02:00
Didier KorthoudtandMartin Carlberg dd781fd86b Fixed: Enabled state for CPSlider was not converted by nib2cib (#2775) 2018-09-17 09:11:36 +02:00
Didier Korthoudt 97209846ad Merge remote-tracking branch 'cappuccino/master' 2018-09-16 10:55:10 +02:00
Alexander Ljungberg 9744aa79b3 Fixed: doc generation crash due to bad UTF.
Not clear what's causing the problem, but the ± in CPDate.j get prefixed with some garbage bytes in the Doxygen output even that the input encoding looks fine.

The work-around for now is to just discard the bad bytes in the Python step. The output comes out correct (with the ± preserved).
2018-09-10 12:14:35 +01:00
Didier Korthoudt 801648fcfe Merge remote-tracking branch 'cappuccino/master' 2018-09-10 11:45:02 +02:00
Alexander Ljungberg 181fb9edb6 New: Dockerfile which helps test bootstrap itself. 2018-09-10 10:39:07 +01:00
Alexander Ljungberg 9ddbdfb80a Fixed: new rsync-base option always on.
Whether enabled or not, this new feature would try to rsync from the current folder.

Refs #2769.
2018-09-10 10:21:57 +01:00
Alexander Ljungberg 1cab88181d Fixed: XcodeCapp good build reporting failure.
After a recent change, a successful build of XcodeCapp actually resulted in the message "Unable to build  XcodeCapp."
2018-09-07 23:52:08 +01:00
Alexander Ljungberg 803cc6e402 New: bump XcodeCapp copyright year. 2018-09-07 23:49:20 +01:00
Alexander Ljungberg 2e0b9f5ea5 New: tweak flash view warning. 2018-09-07 23:16:31 +01:00
Alexander Ljungberg fe60311072 This is Cappuccino 1.0. 2018-09-06 18:38:52 +01:00
Alexander Ljungberg de4a1d1e93 Fixed: building the source link. 2018-09-03 14:54:48 +02:00
David RichardsonandMartin Carlberg de36a2f4d1 Fixed: Update XcodeCapp code and Jakefile to install properly and launch without crashing when built with Xcode 10/ macOSSDK10.14 (#2773)
Disable YRKSpinningProgressIndicator threaded animation (causing immediate crash on launch since Xcode 10 beta 6).
Simplify Jakefile build process to 'xcodebuild install' to avoid permissions problems when building (still requires sudo when using Cappuccino defaults).
Increment version number to 4.0.1 to reflect minor nature of change.
Update About window version number field to fully display and properly align longer version numbers.
2018-09-03 10:29:43 +02:00
David RichardsonandMartin Carlberg 57f6f3b318 New: Add --rsync-base option to bootstrap.sh (#2769)
Existing --copy-local option to use local cappuccino-base has following limitations which are cumbersome when updating bootstrap process
* local source must be a zip archive - which requires an extra step after making changes to source
* local zip archive is erased after install - which makes repetitive testing more difficult

This commit intended to allow testing of updates to cappuccino-base narwhal-jsc.
With macOS 10.14 and later, narwhal-jsc must use modern c++ standard library.
libedit must do the same, so the dependency reference to it is updated to version which is current at this time.
2018-08-31 14:51:20 +02:00
Didier KorthoudtandMartin Carlberg 8a3eb0d83b FIXED: This PR fixes a side effect of #2744 on table data views (#2767)
When a textField is used in a tableView, setValue forThemeAttribute
should refer to state CPThemeStateTableDataView instead of
CPThemeStateNormal as #2744 is now more accurate on states.
2018-08-31 09:14:54 +02:00
Didier KorthoudtandMartin Carlberg dd68b37a2a Fixed: CPButtonBar with actionPopupButton was outside the visible rect. Fixes #2770 (#2771) 2018-08-31 09:10:44 +02:00
cacaodev 96793b39ba Revert "Fixed: Define header-view-height attribute in ThemeDescriptors. (#2764)"
This reverts commit 9ad44e6dc2.
2018-08-30 16:02:48 +02:00
Didier Korthoudt aa4f91b3b0 Merge remote-tracking branch 'cappuccino/master' 2018-08-30 09:13:16 +02:00
cacaodevandMartin Carlberg 9ad44e6dc2 Fixed: Define header-view-height attribute in ThemeDescriptors. (#2764)
This is a better solution for problem introduced by  #2758
2018-08-29 14:28:02 +02:00
Didier KorthoudtandMartin Carlberg 988b3d27b8 Fixed: allowFadingOut side effect introduced by #2718 (#2768) 2018-08-29 11:27:50 +02:00
Didier Korthoudt 043cc13bb3 Merge remote-tracking branch 'cappuccino/master' 2018-08-27 23:24:52 +02:00
Didier KorthoudtandMartin Carlberg c0ee5f6563 Fixed: Problem with nib2cib introduced by #2758 (#2763) 2018-08-22 09:41:37 +02:00
cacaodevandMartin Carlberg f02d0ab1dd STYLE: refactoring using CPCharacterSet (#2762) 2018-08-22 09:18:21 +02:00
Didier Korthoudtandcacaodev ff6d17990f FIXED: Before this PR, starting a column drag within a scrolled down table would scroll the table content to the bottom (#2753)
Before this commit, in the method [view convertPoint:aPoint toView:aView] : aPoint was not in the coordinate system of view.
2018-08-21 19:26:42 +02:00
Didier Korthoudt 9be52f639d Merge remote-tracking branch 'cappuccino/master' 2018-08-21 11:22:22 +02:00
Didier KorthoudtandMartin Carlberg 586c419c46 Fixed: Before this PR, Nib2Cib wasn't using theme attribute "header-view-height" (#2758) 2018-08-21 09:26:40 +02:00
Didier KorthoudtandMartin Carlberg 73f02cc1bf NEW: Add first responder management based on content view to CPScrollView (#2757) 2018-08-21 09:14:21 +02:00
Didier KorthoudtandMartin Carlberg eb27d24923 Fixed: CPTableView-visual-problem(#2755) 2018-08-21 09:08:16 +02:00
Didier KorthoudtandMartin Carlberg eeb056d509 Fixed: CPCursor-fix-and-update, some cursors were badly or not displayed (#2752) 2018-08-20 13:35:18 +02:00
Didier KorthoudtandMartin Carlberg 3615912ce0 Fixed: Before this PR, loading of a CPTabView from a CIB file could crash the app (#2686) 2018-08-20 13:30:02 +02:00
Didier KorthoudtandMartin Carlberg 4518dfc0ca FIXED: CPSearchField was positionning its menu with hard coded offset (#2691) 2018-08-20 13:12:22 +02:00
Didier KorthoudtandMartin Carlberg d5a7e8938d CPTrackingArea-manual-test-fix (#2759) 2018-08-20 13:01:52 +02:00
Didier KorthoudtandMartin Carlberg 3d15844f7c CPTableView-bad-selection-color (#2756) 2018-08-20 12:55:35 +02:00
Didier KorthoudtandMartin Carlberg 62ed21b316 Fixed: Before this PR, when dragging a partially masked column, the dragged view was truncated (#2754) 2018-08-20 12:54:17 +02:00
daboe01andMartin Carlberg a178d43b01 Fixed: return key was not swallowed by textview but triggered the default button. (#2598) 2018-08-20 12:52:53 +02:00
daboe01andMartin Carlberg ef2152beea FIXED: click to key window in the background did not bring it forward (take 2) (#2705) 2018-08-20 12:48:58 +02:00
daboe01andMartin Carlberg e6475c1a9e Fixed: setMinSize: had no effect in platform windows (#2609) 2018-08-20 12:47:29 +02:00
daboe01andMartin Carlberg 091debd2a7 Fixed: deviation from cocoa when calling setTitle:'' (#2607) 2018-08-20 11:40:00 +02:00
daboe01andMartin Carlberg e7eff3e585 Fixed: attached sheets were not put to front after calls to makeKeyAndOrderFront: in code (#2606) 2018-08-20 11:34:21 +02:00
daboe01andMartin Carlberg 86a90e39d2 Fixed: key equivalent takes precedence over event tracking which is not the case in cocoa (#2600) 2018-08-20 11:31:36 +02:00
Didier KorthoudtandMartin Carlberg 2887fbb251 Edge-browser-detection (#2751) 2018-08-20 11:29:28 +02:00
daboe01andMartin Carlberg fa6177b56d Fixed: touch scrolling events to scrollviews also scrolled the document body (#2750) 2018-08-20 11:05:13 +02:00
Alexandre WilhelmandMartin Carlberg 78524cdde7 Fixed: deprecate FlashView, this old technology is now almost banned for all browser (#2748) 2018-08-20 10:59:27 +02:00
Didier KorthoudtandMartin Carlberg 6077d3f4c3 FIXED: _CPThemeAttribute valueForState was, under some circumstances, ignoring theme settings (#2744) 2018-08-20 10:50:08 +02:00
cacaodevandMartin Carlberg fd3acc456d FIXED: Before this commit, CPScrollerView was not correctly differentiating the scroller-width attribute (#2740)
between the vertical scroller and the horizontal scroller.
The scroller width was picked from a common CPScroller instance cached in CPScroller.
The bug was not visible because the method -_adjustScrollerSize was correcting the size repeatidly in the layout pass.
This was causing unnecessary calls to setFrame: in a performance sensitive method (triggered by scroll events).
The ScrollView is now picking the right width from the theme and a setFrame: call is skipped.

Tests: Manual/CPScrollView2/

TODO : The _adjustScrollerSize method should be enabled with a flag only when a width change is explicitely requested.
2018-08-20 10:36:59 +02:00
Didier Korthoudt 257fe6dd3f Merge remote-tracking branch 'cappuccino/master' 2018-08-16 14:54:27 +02:00
Alexandre WilhelmandGitHub cbb7cc93e9 Merge pull request #2739 from Rosch/origin/bugfix-cpdateformatter-german
FIXED: CPDateFormatter not ready for german dates. Fixes #2736
2018-08-10 18:15:16 -07:00
Alexandre WilhelmandGitHub 8b608c5cce Merge pull request #2745 from daboe01/removed--dead-code-from-nativehost
Removed:  dead code from nativehost
2018-08-10 17:58:03 -07:00
Alexandre WilhelmandGitHub 163fb14d0e Merge pull request #2746 from didierkorthoudt/CPTableView-viewWillMoveToWindow-fix
FIXED: In CPTableView, viewWillMoveToWindow was incorrectly removing an observer on the wrong window
2018-08-10 17:57:43 -07:00
Didier Korthoudt e4f87bd805 CPTableView-viewWillMoveToWindow-fix 2018-08-08 22:06:42 +02:00
Didier Korthoudt 864c7d96f1 Revert "NEW: Added automatic Xcode syntax coloring"
This reverts commit 0a497d8c3f.
2018-08-08 22:05:57 +02:00
daboe01 e35e87fb05 fixed: obsolete code remnants from nativehost 2018-08-08 19:19:58 +02:00
Didier Korthoudt 3246bdbc8b Merge remote-tracking branch 'cappuccino/master' 2018-08-08 11:03:03 +02:00
daboe01 710bb5fe1c Merge remote-tracking branch 'cappuccino/master' 2018-08-08 09:32:07 +02:00
bedaltonandcacaodev 53a52da709 Fixed: _CPObjectAnimator initialize method did not match superclass return (#2743)
* Fixed: _CPObjectAnimator initialize method did not match superclass return

_CPObject animator labeled return type as BOOL, not only is this value not returned, but the super class CPProxy's initialize method returns void. Changed return type to void in _CPObject animator, to match superclass
2018-08-03 08:28:05 +02:00
Martin Carlberg 4afbfc6e57 Revert "Removed: dead code and dom clutter from nativehost (#2608)"
This reverts commit 5bfafaf241.
2018-07-11 09:20:49 +02:00
daboe01 f7aa9efe13 Merge remote-tracking branch 'cappuccino/master' 2018-07-09 22:24:30 +02:00
Rosch 1fce0ee551 fix CPDateformatter for german dates 2018-07-08 09:15:58 +02:00
daboe01andMartin Carlberg ee695f9000 Fixed: CPSearchPanel did not support PredicateBindings (#2699) 2018-07-05 15:44:36 +02:00
daboe01andMartin Carlberg 8f99ebb577 Fixed: optical clutter, link duplications in readme (#2729) 2018-07-05 13:01:41 +02:00
daboe01andMartin Carlberg 5bfafaf241 Removed: dead code and dom clutter from nativehost (#2608) 2018-07-05 11:40:10 +02:00
Kjell NilssonandMartin Carlberg 64e1a2ce4b Fixed: Protocol selector signature spell error (#2734) 2018-07-05 11:25:38 +02:00
Didier Korthoudtandcacaodev 27883c5beb FIXED: This fixes problems with default theme attributes values in CPTableView (#2732) 2018-06-21 16:47:21 +02:00
Didier Korthoudt 2772725fe3 Merge remote-tracking branch 'cappuccino/master' 2018-06-17 08:55:10 +02:00
Didier Korthoudtandcacaodev 3f58a64827 FIXED: Before this PR, images specified in IB could crash the app at Cib loading (#2731) 2018-06-16 19:14:58 +02:00
Didier Korthoudt cb37c7d218 Merge remote-tracking branch 'cappuccino/master' 2018-06-16 12:25:12 +02:00
daboe01 45d951071f Merge remote-tracking branch 'cappuccino/master' 2018-06-12 13:13:57 +02:00
daboe01andMartin Carlberg 2ac60684fa Fixed: CPDateFormatter was agnostic for the German language (#2724) 2018-06-08 14:00:25 +02:00
daboe01andMartin Carlberg af71742110 Fixed: Update README.markdown 2018-06-08 13:57:13 +02:00
daboe01andMartin Carlberg 1adf27427a Fixed: The word Site changed to Application in index.html (#2723) 2018-06-04 13:51:15 +02:00
daboe01 082f78eefa Merge remote-tracking branch 'cappuccino/master' 2018-06-03 19:44:23 +02:00
cacaodevandGitHub a8a9ec0023 Fix typo in CPPredicateEditorTest
Fixes #2714
2018-06-02 08:18:01 +02:00
Didier Korthoudt df4f945bc6 Merge remote-tracking branch 'cappuccino/master' 2018-05-29 12:04:40 +02:00
daboe01andcacaodev ad756a5b86 fixed: some mouse events were not propagated when sheets are open (#2603)
* fixed: mouse dragged was not propagated to parent window when sheet was opened

* better detection for attached sheet
2018-05-29 07:17:41 +02:00
Didier Korthoudtandcacaodev 2ca99ba669 FIXED: Before this PR, CPScroller theme attribute knob-inset was partially used (#2720) 2018-05-29 07:15:47 +02:00
daboe01andcacaodev 6443575114 fixed: nib2cib was susceptible to IB button issue with alternateImage (#2721) 2018-05-28 21:10:40 +02:00
Didier Korthoudtandcacaodev 52a51d81f1 FIXED: Before this PR, legacy scroller won't ever loose its selected theme state (#2718) 2018-05-28 20:56:00 +02:00
Didier Korthoudtandcacaodev 7d20b06e52 FIXED: Before this PR, CPSearchField was handling cursor updates by direct DOM manipulation. This PR uses tracking areas. (#2684) 2018-05-28 20:46:28 +02:00
Didier Korthoudtandcacaodev ad9d8a7200 FIXED: When attaching an externally owned tracking area to a view, view tracking areas were not correctly handled (#2681)
This PR also removes the -removeAllTrackingAreas method.
2018-05-28 20:44:31 +02:00
Didier Korthoudt 44da699343 Merge remote-tracking branch 'cappuccino/master' 2018-05-23 23:49:51 +02:00
cacaodev 0a542f9be9 Revert "FIXED: _CPTableColumnHeaderView was using hard coded values instead of theme values (#2703)"
This reverts commit e27bb4de50.
2018-05-17 05:48:59 +02:00
Didier Korthoudt 8f1601ca55 Merge remote-tracking branch 'cappuccino/master' 2018-05-15 22:03:16 +02:00
Didier Korthoudtandcacaodev ff0ce164da FIXED: CPTabView tabs were not reacting as in modern Cocoa (#2694)
Before this commit, the segments of a tab view were selected at mouse down. Now, they are selected at mouse up and there is a visible feedback when tracking tabs.
2018-05-14 07:10:43 +02:00
Didier Korthoudtandcacaodev 3650c38aa9 FIXED: In CPSearchField, the space between the magnifier and the textfield was hard coded (#2690) 2018-05-13 19:49:18 +02:00
Didier Korthoudtandcacaodev 61d97338e2 FIXED: _CPMenuItemStandardView was bypassing theme for disabled text color (#2695) 2018-05-13 19:48:33 +02:00
Didier Korthoudtandcacaodev e27bb4de50 FIXED: _CPTableColumnHeaderView was using hard coded values instead of theme values (#2703) 2018-05-13 19:47:53 +02:00
Didier Korthoudtandcacaodev 4462d8bf22 CHANGED: CPSegmentedControl code refactoring (#2704) 2018-05-13 19:40:33 +02:00
Didier Korthoudt f23a8ac928 Merge remote-tracking branch 'cappuccino/master' 2018-05-12 01:05:02 +02:00
daboe01 9e1750ee13 Merge remote-tracking branch 'cappuccino/master' 2018-05-08 22:46:19 +02:00
Didier Korthoudtandcacaodev 5cd284cb36 FIXED: CPSearchField menu diverged from modern Cocoa (#2697) 2018-05-07 21:52:06 +02:00
daboe01andcacaodev 5ea58430fe fixed: typo in theme attribute name (#2683) 2018-05-07 20:05:49 +02:00
Didier Korthoudtandcacaodev acfbda0d91 FIXED: CPSearchMenu _updateSearchMenu wasn't disabling autoenabling of menu items (#2693) 2018-05-07 19:57:35 +02:00
Didier Korthoudtandcacaodev 437e5a62f1 FIXED: CPSearchField -(void)resetSearchButton was using valueForThemeAttribute instead of currentValueForThemeAttribute (#2692) 2018-05-07 19:57:01 +02:00
Didier Korthoudtandcacaodev bbb5aea77d FIXED: CPTableView was using hard coded values instead of theme attributes (#2698) 2018-05-07 19:54:46 +02:00
Didier Korthoudt b5d04f84e7 Merge remote-tracking branch 'cappuccino/master' 2018-05-06 20:44:07 +02:00
cacaodevandGitHub 93b12eb14f Revert "FIXED: click to key window in the background did not bring it forward" (#2702)
Fixes #2700
2018-05-06 14:07:25 +02:00
Didier Korthoudt 0aa67c4cf2 Merge remote-tracking branch 'cappuccino/master' 2018-05-05 23:26:35 +02:00
Didier Korthoudtandcacaodev 1c1affac5c FIXED: CPTableHeaderView was faulty using inset.right instead of inset.left 2018-05-05 10:47:24 +02:00
Didier Korthoudt 0919797edc Merge remote-tracking branch 'cappuccino/master' 2018-05-04 23:22:49 +02:00
Didier Korthoudtandcacaodev 94ac8fd837 FIXED: Before this PR, CPButton setImage was also changing the alternate image 2018-05-04 16:16:01 +02:00
cacaodevandGitHub ecc82b5b51 Fixed: Typo CGSizZero() -> CGSizeMakeZero()
In BadgedOutlineView.j from SmartFoldersDemo test application.
2018-05-02 19:38:37 +02:00
daboe01 add021fd67 Merge remote-tracking branch 'cappuccino/master' 2018-04-28 16:35:05 +02:00
Didier Korthoudt 2daf309d7d Merge remote-tracking branch 'cappuccino/master' 2018-04-27 14:15:30 +02:00
Didier KorthoudtandMartin Carlberg 20be4a40ea NEW: Add CSS theming support (#2613) 2018-04-27 09:27:01 +02:00
bedaltonandcacaodev 7de91da87a Fix: rename _placeHolderView and add accessors in CPTabView.j (#2678)
In CPTabView.j on line 706 method is called `[_source
_setPlaceholderView:aValue]; ` this method does not exist, and this
call could possibly be expecting the property `_placeHolderView` to
have an accessor method. To add the correct accessor method the case of
either the method call selector or the variable must change —
`_placeHolderView` vs `_placeholderView`. For this fix I selected the
`_placeholderView` spelling, as opposed to the alternative with the
capitalized “holder” in “placeholder.”

Fixes #2674
2018-04-13 12:09:46 +02:00
cacaodevandMartin Carlberg b8b48b533b Previously, animating frame origin was not working on recent versions of Gecko (Firefox). The format for the matrix value of the transform property was matrix(a,b,c,d,tx,ty) and tx and ty had the "px" suffix. According to this page, tx and ty were accept (#2677)
ed (in my understanding not required) to have this suffix before FireFox
16.

All parameters are now numbers without suffix and this code will work
for all FireFox versions supporting css animations.
2018-04-12 11:25:43 +02:00
daboe01andMartin Carlberg 535f981739 Fixed: TextView bindings wrote data on blur even when not editable (#2582) 2018-04-12 09:25:12 +02:00
cacaodevandGitHub 0404ac0395 Merge pull request #2602 from daboe01/issue2545
FIXED: click to key window in the background did not bring it forward
2018-04-12 09:11:57 +02:00
daboe01 f961625f03 fixed: some events were not propagated to the bridge window 2018-04-11 18:30:47 +02:00
daboe01andMartin Carlberg 7909bae065 Fixed: touch-scrolling did not work (#2612) 2018-04-09 13:19:18 +02:00
bedaltonandMartin Carlberg 7e6e117b17 Formatting: add semi-colon to CPTextContainer.j (#2675) 2018-04-09 12:40:41 +02:00
bedaltonandMartin Carlberg 314e64d7b1 Formatting: add semi-colon to CPTextView.j (#2676) 2018-04-09 12:40:11 +02:00
daniel 8c72e77e0d Merge remote-tracking branch 'cappuccino/master' 2018-04-08 12:07:30 -07:00
Alexandre WilhelmandGitHub 77eb6b358f Merge pull request #2626 from daboe01/fix-cptextview-backspace-issue
fixed: backspace did not trigger scrolling properly 927d6d2
2018-04-08 11:37:19 -07:00
Alexandre WilhelmandGitHub 25f86e2542 Merge pull request #2616 from bedalton/add-idea-to-gitignore
New: Add *.idea to .gitignore
2018-04-08 11:36:25 -07:00
Alexandre WilhelmandGitHub 8bc0461463 Merge pull request #2627 from bedalton/formatting-add-semi-colon-cpcolorpicker
Formatting: add missing semi-colon to CPColorPicker.j
2018-04-08 11:35:34 -07:00
Alexandre WilhelmandGitHub c9dd1ea71d Merge pull request #2628 from bedalton/formatting-add-semi-colon-cpdatepicker
Formatting: add missing semi-colons to CPDatePicker.j
2018-04-08 11:35:26 -07:00
Alexandre WilhelmandGitHub 85d3529bc3 Merge pull request #2629 from bedalton/formatting-add-semi-colon-cpdatepickertextfield
Formatting: add semi-colon CPDatePickerTextField.j
2018-04-08 11:35:10 -07:00
Alexandre WilhelmandGitHub 3aac8bb072 Merge pull request #2630 from bedalton/formatting-add-semi-colon-cpevent
Formatting: add missing semi-colons to CPEvent.j
2018-04-08 11:34:59 -07:00
Alexandre WilhelmandGitHub e9a7e21aca Merge pull request #2638 from bedalton/formatting-add-semi-colon-cptableview
Formatting: add semi colon to CPTableView.j
2018-04-08 11:34:47 -07:00
Alexandre WilhelmandGitHub fc0e4da33c Merge pull request #2641 from bedalton/formatting-add-semi-colon-cpwindow
Formatting: add missing semi-colons to CPWindow.j
2018-04-08 11:33:54 -07:00
Alexandre WilhelmandGitHub ef3c1315dd Merge pull request #2642 from bedalton/formatting-add-semi-colon-cpwindowcontroller
Formatting: add semi-colon to CPWindowController.j
2018-04-08 11:33:45 -07:00
Alexandre WilhelmandGitHub 5c12890faf Merge pull request #2643 from bedalton/formatting-add-semi-colon-to-cpfontpanel
Formatting: add semi-colon to CPFrontPanel.j
2018-04-08 11:33:33 -07:00
Alexandre WilhelmandGitHub c4fd5e0999 Merge pull request #2645 from bedalton/formatting-add-semi-colons-cpdatepickercalendar
Formatting: add missing semi-colons to _CPDatePickerCalendar.j
2018-04-08 11:33:24 -07:00
Alexandre WilhelmandGitHub d3c56d635d Merge pull request #2669 from bedalton/formatting-add-semi-colons-cpplatformwindow
Formatting: minor formatting updates in CPPlatformWindow+DOM.j
2018-04-08 11:32:58 -07:00
Alexandre WilhelmandGitHub c53cb49034 Merge pull request #2640 from bedalton/formatting-add-semi-colon-cpview
Formatting: add semi-colon to CPView.j
2018-04-08 11:32:44 -07:00
Alexandre WilhelmandGitHub d38463c5d9 Merge pull request #2631 from bedalton/formatting-add-semi-colon-cpfont
Formatting: add semi-colon to CPFont.j
2018-04-08 11:32:33 -07:00
Alexandre WilhelmandGitHub bc4b424f0e Merge pull request #2632 from bedalton/formatting-add-semi-colon-cpimage
Formatting: add semi-colon to CPImage.j
2018-04-08 11:32:23 -07:00
Alexandre WilhelmandGitHub 6bd4f3b7b4 Merge pull request #2633 from bedalton/formatting-add-semi-colon-cpkeyvaluebinding
Formatting: add missing semi-colon to CPKeyValueBinding
2018-04-08 11:32:13 -07:00
Alexandre WilhelmandGitHub d91d83f115 Merge pull request #2634 from bedalton/formatting-add-semi-colon-cplayoutmanager
Formatting: add missing semi-colon to CPLayoutManager.j
2018-04-08 11:32:02 -07:00
Alexandre WilhelmandGitHub 584b6ab219 Merge pull request #2639 from bedalton/formatting-add-semi-colon-cptokenfield
Formatting: add semi colon to  CPTokenField.j
2018-04-08 11:31:47 -07:00
Alexandre WilhelmandGitHub 04b155dbfb Merge pull request #2635 from bedalton/formatting-add-semi-colon-cpoutlineview
Formatting: add semi-colons to CPOutlineView.j
2018-04-08 11:31:35 -07:00
Alexandre WilhelmandGitHub ddc5488db7 Merge pull request #2636 from bedalton/formatting-add-semi-colon-cpprogressindicator
Formatting: add semi-colons to CPProgressIndicator.j
2018-04-08 11:31:23 -07:00
Alexandre WilhelmandGitHub 5c6906d5fd Merge pull request #2637 from bedalton/formatting-add-semi-colon-cpscrollview
Formatting: add missing semi-colon to CPScrollView.j
2018-04-08 11:31:08 -07:00
Alexandre WilhelmandGitHub 56fee5d286 Merge pull request #2657 from bedalton/formatting-remove-redundant-variable-declaration
Formatting: remove redundant variable in _CPRuleEditorViewSlice.j
2018-04-08 11:29:35 -07:00
Alexandre WilhelmandGitHub c4dcab04b6 Merge pull request #2656 from bedalton/formatting-remove-semi-colon-cplevelindicator
Formatting: Remove semi-colon after method header in CPLevelIndicator
2018-04-08 11:29:17 -07:00
Alexandre WilhelmandGitHub 8dd9a96769 Merge pull request #2655 from bedalton/formatting-update-semi-colons-in-cpimageandtextview
Formatting: fix possible misuse of commas in _CPImageAndTextView.j
2018-04-08 11:28:59 -07:00
Alexandre WilhelmandGitHub 6864015af6 Merge pull request #2654 from bedalton/formatting-declare-variable-in-CPColor
Formatting: formally declared variable before use in CPColor.j
2018-04-08 11:28:46 -07:00
Alexandre WilhelmandGitHub ebaa60e929 Merge pull request #2653 from bedalton/formatting-cptextview
Formatting: add semi-colons and comma to CPTextView.j
2018-04-08 11:28:24 -07:00
Alexandre WilhelmandGitHub ac9962c624 Merge pull request #2644 from bedalton/formatting-add-semi-colon-to-cpmenuitem
Formatting: add missing semi-colons to CPMenuItem.j
2018-04-08 11:27:57 -07:00
Alexandre WilhelmandGitHub ccd1773643 Merge pull request #2646 from bedalton/formatting-add-semi-colons-cphudwindowview
Formatting: add missing semi-colon to _CPHudWindowView.j
2018-04-08 11:27:46 -07:00
Alexandre WilhelmandGitHub ac970ff768 Merge pull request #2647 from bedalton/formatting-add-semi-colons-cpplatformpasteboard
Formatting: add semi-colons to CPPlatformPasteboard.j
2018-04-08 11:27:38 -07:00
Alexandre WilhelmandGitHub 53ff45425d Merge pull request #2648 from bedalton/formatting-add-semi-colons-cptablecolumn
Formatting: add semi-colon to CPTableColumn.j
2018-04-08 11:27:25 -07:00
Alexandre WilhelmandGitHub de435c741f Merge pull request #2649 from bedalton/formatting-add-semi-colons-cptextfield
Formatting: add semi-colons to CPTextField.j
2018-04-08 11:27:12 -07:00
Alexandre WilhelmandGitHub 1dc9a44aec Merge pull request #2650 from bedalton/formatting-add-semi-colons-cptoolbar
Formatting: add semi-colon to CPToolBar.j
2018-04-08 11:26:37 -07:00
Alexandre WilhelmandGitHub 0206379315 Merge pull request #2651 from bedalton/formatting-add-semi-colons-cptypesetter
Formatting: add missing semi-colons to CPTypesetter.j
2018-04-08 11:26:29 -07:00
Alexandre WilhelmandGitHub c39adbbbc5 Merge pull request #2652 from bedalton/formatting-add-semi-colons-to-cprtfparser
Formatting: add semi-colons to _CPRTFParser.j
2018-04-08 11:26:16 -07:00
Alexandre WilhelmandGitHub 061a15d4f7 Merge pull request #2658 from bedalton/formatting-remove-redundant-variable-cpsearchfield
Formatting: removed redundant variable in CPSearchField.j
2018-04-08 11:25:25 -07:00
Alexandre WilhelmandGitHub 7c2518f027 Merge pull request #2659 from bedalton/formatting-add-semi-colons-cpusernotification
Formatting: add semi colons CPUserNotification.j
2018-04-08 11:25:04 -07:00
Alexandre WilhelmandGitHub a07459454b Merge pull request #2660 from bedalton/formatting-add-semi-colons-nib2cib-converter
Formatting: add semi-colons to nib2cib/Converter.j
2018-04-08 11:24:56 -07:00
Alexandre WilhelmandGitHub 752f9d2694 Merge pull request #2661 from bedalton/fix-cpproxy-respondstoselector
Fix: CPProxy respondsToSelector incorrect parameter name
2018-04-08 11:24:42 -07:00
Alexandre WilhelmandGitHub 0a180f9e20 Merge pull request #2662 from bedalton/format-add-semi-colon-cpdateformatter
Format: add semi-colons to CPDateFormatter.j
2018-04-08 11:24:21 -07:00
Alexandre WilhelmandGitHub 6fff2e1c2f Merge pull request #2663 from bedalton/formatting-add-semi-colon-cparray-kvo
Formatting: add semi-colon CPArray+KVO.j
2018-04-08 11:24:07 -07:00
Alexandre WilhelmandGitHub 4266900d2e Merge pull request #2664 from bedalton/formatting-add-semi-colon-cpdictionary
Formatting: add semi-colon to CPDictionary.j
2018-04-08 11:23:47 -07:00
Alexandre WilhelmandGitHub a2a1d84bc0 Merge pull request #2665 from bedalton/formatting-add-semi-colon-cpindexset
Formatting: add semi-colons to CPIndexSet
2018-04-08 11:23:39 -07:00
Alexandre WilhelmandGitHub 7648c562f1 Merge pull request #2666 from bedalton/formatting-add-semi-colon-cpnotificationqueue
Formatting: add semi-colons to CPNotificationQueue.j
2018-04-08 11:23:21 -07:00
Alexandre WilhelmandGitHub 403fd30926 Merge pull request #2667 from bedalton/formatting-add-semi-colon-cppredicate
Formatting: add semi-colon to CPPredicate.j
2018-04-08 11:23:07 -07:00
Alexandre WilhelmandGitHub 17ccddf541 Merge pull request #2668 from bedalton/formatting-add-semi-colon-cptheme
Formatting: add semi-colon to CPTheme.j
2018-04-08 11:22:59 -07:00
Alexandre WilhelmandGitHub c24366fcec Merge pull request #2670 from bedalton/formatting-add-semi-colons-nib2cib-nib2cib
Formatting: add semi-colon to nib2cib/Nib2Cib.j
2018-04-08 11:22:31 -07:00
Alexandre WilhelmandGitHub 9a258a6265 Merge pull request #2671 from bedalton/formatting-add-semi-colon-nscustomerresource
Formatting: add semi colon NSCustomResource.j
2018-04-08 11:22:24 -07:00
Alexandre WilhelmandGitHub 4542ccbdc2 Merge pull request #2672 from bedalton/formatting-add-semi-colon-capp-main
Formatting: add semi-colon capp/main.j
2018-04-08 11:22:01 -07:00
Daniel 41d8ad2b86 Formatting: add semi-colons to capp/main.j 2018-04-07 17:20:00 -07:00
Daniel a3a2ee118e Formatting: add semi-colon to NSCustomResource.j 2018-04-07 17:17:19 -07:00
Daniel f285efc277 Formatting: add semi-colon to Nib2Cib.j 2018-04-07 17:15:36 -07:00
Daniel fbaf87ec6c Formatting: add missing semi-colon in CPTheme.j 2018-04-07 17:03:33 -07:00
Daniel a005a468a7 Formatting: add semi-colons to nib2cib/Converter.j 2018-04-07 16:40:52 -07:00
Daniel c8d01549ba Formatting: add semi-colon to CPUserNotification.j 2018-04-07 16:13:20 -07:00
daniel 23af4505dd Fix: CPProxy uses incorrect variable name in method call
On line 51 of CPProxy, `class_getInstanceMethod` is called with the
variable  `aSelector`, but this variable does not exist in the
context, but a variable named `selector` does. This fix changes the
method parameter from `selector` to `aSelector` to match the parameter
used within the method.
2018-04-07 15:37:19 -07:00
daniel 53cb6a5b3e Formatting: add missing semi-colons to CPNotificationQueue.j 2018-04-07 15:29:27 -07:00
daniel 765384ace1 Formatting: add semi-colons to CPIndexSet.j
Variable assignments terminated in commas instead of semi-colons
2018-04-07 15:26:52 -07:00
daniel d39e3e2f69 Formatting: add semi-colon to CPDictionary.j 2018-04-07 15:22:36 -07:00
daniel d75124066e Formatting: add semi-colons to CPDateFormatter.j 2018-04-07 15:20:08 -07:00
daniel f4400876da Formatting: add semi-colon to CPArray+KVO.j 2018-04-07 14:10:03 -07:00
daniel c222c5127f Formatting: add semi-colon to _CPPredicate.j 2018-04-07 14:07:43 -07:00
daniel 90d04956e6 Merge remote-tracking branch 'cappuccino/master' 2018-04-07 11:34:21 -07:00
cacaodevandGitHub 5d3b918339 Merge pull request #2624 from bedalton/formatting-add-semi-colon-cparraycontroller
Formatting: add semi-colon CPArrayController
2018-04-07 06:53:38 +02:00
cacaodevandGitHub eba0091764 Merge pull request #2623 from bedalton/formatting-add-semi-colon-cpapplication
Formatting: add semi-colon CPApplication
2018-04-07 06:53:13 +02:00
cacaodevandGitHub 7999cbbea3 Merge pull request #2622 from bedalton/formatting-add-semi-colon-cppopoverwindow
Formatting: add semi-colon CPPopoverWindow.j
2018-04-07 06:52:57 +02:00
cacaodevandGitHub cee7987b35 Merge pull request #2621 from bedalton/formatting-add-semi-colon-cptooltip
Formatting: add semi-colon to CPToolTip.j
2018-04-07 06:52:40 +02:00
cacaodevandGitHub d475c08024 Merge pull request #2620 from bedalton/formatting-add-semi-colon-cpdatepickerclock
Formatting: add semi colon CPDatePickerClock.j
2018-04-07 06:52:26 +02:00
cacaodevandGitHub d78f83ae49 Merge pull request #2619 from bedalton/formatting-move-redeclared-variable-in-cgpath
Formatting: remove redeclared variables in CGPath.j
2018-04-07 06:52:12 +02:00
cacaodevandGitHub df694f01e7 Merge pull request #2618 from bedalton/add-semi-colons-to-cgcontextvml
Formatting: add semi-colon to CGContextVML.j
2018-04-07 06:51:55 +02:00
cacaodevandGitHub f5d9cbb11b Merge pull request #2615 from bedalton/add-missing-semi-colon-to-cpkeyvaluebinding
Formatting : add missing semi-colon to CPKeyValueBinding.j
2018-04-07 06:51:35 +02:00
cacaodevandGitHub d802588abe Merge pull request #2617 from bedalton/add-missing-semi-colons-cgcontextcanvas
Formatting: Add missing semi-colons to CGContextCanvas.j
2018-04-07 06:51:01 +02:00
daboe01 927d6d2fc6 fixed: backspace did not trigger scrolling properly 2018-04-05 21:36:32 +02:00
daboe01 bab7595078 Merge remote-tracking branch 'cappuccino/master' 2018-04-05 21:26:43 +02:00
daniel 1ea9a6c57f Formatting: add missing semi-colon to CPWindowController.j 2018-04-04 15:14:06 -07:00
daniel f479d415d8 Formatting: add missing semi-colon in CPView.j 2018-04-04 15:13:03 -07:00
daniel f41e7be726 Formatting: add semi-colons to CPToolbar.j 2018-04-04 15:11:52 -07:00
daniel c1fe28124f Formatting: add semi-colons to CPTokenField 2018-04-04 15:10:17 -07:00
daniel 01a1e506e4 Formatting: add missing semi-colons to CPTextField.j 2018-04-04 15:08:21 -07:00
daniel e61aebb55d Formatting: minor formatting changes for CPTableView.j
Added missing semi-colon on line 3763.
Removed the redundant `var` keyword on line 4910
Removed the second redundant variable `CPTableViewHeaderViewKey` which
was declared with the same name and value twice in the same variable
block.
2018-04-04 15:06:00 -07:00
daniel bae5bafc62 Formatting: add semi-colon to CPTableColumn.j 2018-04-04 14:55:01 -07:00
daniel be6cb266de Merge remote-tracking branch 'cappuccino/master' 2018-04-04 14:50:00 -07:00
daniel 6f72edc2d9 Formatting: removed redundant variable in CPSearchField.j
Variable `searches` is defined in the method selector, and then
redeclared with the `var` keyword two lines later. Removed the
redundant declaration, moving the variable assignment to its own line.
2018-04-04 14:45:13 -07:00
daniel 29f66bdfed Formatting: add missing semi-colon to CPScrollView.j 2018-04-04 14:41:53 -07:00
daniel c1c6f5682c Formatting: add semi-colons to CPProgressIndicator.j 2018-04-04 14:40:46 -07:00
daniel a8a74a0246 Formatting: add semi-colons to CPOutlineView.j 2018-04-04 14:37:34 -07:00
daniel f9b867c3eb Formatting: Remove semi-colon after method header in CPLevelIndicator
On lines 295 and 304, the selector for two method declarations are
followed by a semi-colon. Not sure if this causes problems or not, but
removed anyways.
2018-04-04 14:36:07 -07:00
daniel 6c07f9a048 Formatting: add missing semi-colon to CPKeyValueBinding 2018-04-04 14:33:24 -07:00
daniel 573e0acafa Formatting: add semi-colon to CPImage.j
Variable value assignment terminated in comma, despite not being a
variable list. Replaced comma with semi-colon.
2018-04-04 14:25:59 -07:00
daniel 530c664967 Formatting: add semi-colon to CPFont.j 2018-04-04 14:19:26 -07:00
daniel 12c29c8387 Formatting: add missing semi-colons to CPEvent.j 2018-04-04 14:17:42 -07:00
daniel 6c7f61d90f Formatting: add missing semi-colon to CPColorPicker.j 2018-04-04 14:11:59 -07:00
daniel eb6d8d0bb3 Formatting: formally declared variable before use in CPColor.j
Variable `isVertical` is used throughout the function
`patternColorsFromPattern` in CPColor.j despite never being declared.
In this pull request, the variable is declared formally in the variable
list before its use.
2018-04-04 14:09:28 -07:00
daniel ef462973c7 Formatting: add semi-colon to CPArrayController.j 2018-04-04 13:33:53 -07:00
daniel aa7e49cfde Formatting: add semi-colon to CPApplication.j 2018-04-04 13:32:37 -07:00
daniel 186048676a Formatting: add semi-colon to _CPTooltip.j 2018-04-04 13:31:19 -07:00
daniel 0f40721cff Formatting: add semi-colon to _CPPopoverWindow.j 2018-04-04 13:29:40 -07:00
daniel 3799dd92fd Formatting: fix possible misuse of commas in _CPImageAndTextView.j 2018-04-04 10:50:04 -07:00
daniel 9ea1a2b1de Formatting: minor formatting updates in CPPlatformWindow+DOM.j
Missing semi-colon on line 1425.
Removed redundant `var` modifier on already declared variable on line
947.
Added variable declaration to variable used without declaration on line
970.
Removed redundant `var` modifier on already declared variable
`CPDOMEventGetClickCount` removed var on latter declaration as original
declaration has note stating it is to be declared at top so “so
compressor knows about them.”
2018-04-04 10:46:02 -07:00
daniel d8b27d122e Formatting: add semi-colons to CPPlatformPasteboard.j 2018-04-04 09:41:10 -07:00
daniel 15c3a6eae4 Formatting: add missing semi-colons to CPWindow.j 2018-04-04 09:38:43 -07:00
daniel 4fcc90d53e Formatting: add missing semi-colon to _CPHudWindowView.j 2018-04-04 09:28:31 -07:00
daniel 2619a50976 Formatting: add missing semi-colons to CPTypesetter.j 2018-04-04 09:27:12 -07:00
daniel de116c95d4 Formatting: add missing semi-colon to CPLayoutManager.j 2018-04-04 09:23:38 -07:00
daniel 47594c9b07 Formatting: add missing coma and semi-colons to CPTextField 2018-04-04 09:10:52 -07:00
daniel 1b9098b564 Merge remote-tracking branch 'cappuccino/master' into formatting-cptextview 2018-04-04 09:10:14 -07:00
daniel b0306eac87 Formatting: add semi-colon to CPFrontPanel.j 2018-04-04 09:07:06 -07:00
daniel 125e813d25 Formatting: add semi-colons to _CPRTFParser.j 2018-04-04 09:00:36 -07:00
daniel 8e0d4a70f2 Formatting: remove redundant variable in _CPRuleEditorViewSlice.j 2018-04-03 15:04:55 -07:00
daniel 0556fc68b0 Formatting: add missing semi-colons to CPMenuItem.j 2018-04-03 14:59:14 -07:00
daniel e9e2313159 Formatting: add missing semi-colons to CPDatePicker.j 2018-04-03 14:27:07 -07:00
daniel dbb2f03a43 Formatting: add semi-colon CPDatePickerTextField.j 2018-04-03 14:18:36 -07:00
daniel ed0dc2d887 Formatting: add semi-colon to _CPDatePickerClock.j 2018-04-03 12:59:51 -07:00
daniel 0a93f2d0b0 Formatting: add missing semi-colons to _CPDatePickerCalendar.j 2018-04-03 12:54:39 -07:00
daniel fd581cd65c Formatting: removed variable redeclaration in CGPath.j
Variables `arcStartX` and `arcStartY` are declared on 125 and 126, but
are later redeclared in an `else` statement on lines 135 and 136 with
the same equation and presumably the same value used in the initial
declaration.
Also added missing semi-colon
2018-04-03 12:46:56 -07:00
daniel 36702bc971 Formatting: add missing semi-colon to CGContextVML 2018-04-03 12:15:04 -07:00
daniel 0fc3eb38f1 Formatting: Add semi-colons to CGContextCanvas.j 2018-04-03 12:11:57 -07:00
daniel 73c8e945e9 New: add .idea to .gitignore
Prevent Intellij Idea metadata from being committed to git.
2018-04-03 12:07:01 -07:00
daniel b8420303ba Formatting: add missing semi-colon to CPKeyValueBinding.j 2018-04-03 10:55:17 -07:00
daniel 532bfcf937 Merge remote-tracking branch 'cappuccino/master' 2018-04-03 10:20:07 -07:00
cacaodevandGitHub f6d892023e Merge pull request #2604 from bedalton/overshadowing-variable-in-_CPCibObjectData
Fixed: Variable in if statement overshadows variable in enclosing block
2018-04-03 07:54:11 +02:00
daboe01 7f2977f4af fixed: wording in manual test 2018-04-02 08:33:50 +02:00
cacaodevandGitHub e246a2753b Merge pull request #2610 from daboe01/issue2605
fixed: wrong method invocation to delegate of CALayer (displayLayer:)
2018-03-31 12:35:33 +02:00
daboe01 6d06a26c31 fixed: typo in method invocation 2018-03-26 17:53:38 +02:00
Daniel 7cda21b60f Merge remote-tracking branch 'cappuccino/master' 2018-03-20 13:46:13 -07:00
Daniel 1db740039b Fixed: Variable in if statement overshadows variable in enclosing block
If statement variable ‘instantiatedObject’ on line 229 of
_CPCibObjectData.j overshadows a variable with the same name declared
on line 233 in the enclosing block. Variable is added to array outside
the enclosing if statement.

Refs: #2601
2018-03-20 11:36:19 -07:00
daboe01 df462774aa refactured front detection logic to own method _isFrontmostWindow
fixes travis error
2018-03-20 14:25:42 +01:00
daboe01 f55fa789c4 new: manual test for issue 2545 2018-03-18 22:33:49 +01:00
daboe01 488541f26e fixed: click to key window in the background did not bring it forward 2018-03-18 21:45:25 +01:00
daboe01 b404b1cf50 Merge remote-tracking branch 'cappuccino/master' 2018-03-08 15:43:23 +01:00
Martin CarlbergandGitHub 69370aa806 Merge pull request #2596 from mrcarlberg/triple_click_noneditable_selectable_empty_textfield
Fixed: Crash when triple click an empty CPTextField that is not editable but selectable
2018-03-08 09:17:57 +01:00
daboe01andMartin Carlberg b3ddd85b09 Fixed: Editing text in tableviews throws DOM exceptions under certain conditions in Chrome (#2563)
Previosly, we unflagged ```CPTextFieldInputDidBlur``` and ```CPTextFieldInputResigning``` before
the call to removeChild. This resulted in DOM exceptions in Chrome under certain conditions.
See https://stackoverflow.com/questions/21926083/failed-to-execute-removechild-on-node for
why we need to unflag ```CPTextFieldInputDidBlur``` and ```CPTextFieldInputResigning``` only after removing the element.

This apply to token fields also but with the corresponding flags. Also token fields now have the same behavior as the text field when bluring etc.
2018-03-08 09:17:15 +01:00
Martin Carlberg 033221fd01 Fixed: When triple click in an empty CPTextField that is not editable but selectable this call will crash as _DOMTextElement is nil.
This check will make sure it is not called when no element is present. This is the same way as it is done in other parts of this class.
2018-03-07 11:24:21 +01:00
Didier Korthoudt 1201fa38a8 Merge remote-tracking branch 'cappuccino/master' 2018-03-07 00:05:40 +01:00
Martin CarlbergandGitHub 32059c376e Fixed: Nib2Cib will replace a CPTextFieldCell with a CPTextField as Cappuccino does not use cells. When a binding or connection is made to a CPTextFieldCell the binding / connection will get lost when read as the cell is never stored in the cib file. (#2572)
This fix make sure that the binding / connection is made to the CPTextField instead of the cell by replacing the cell with the text field when reading the xib file. The same mechanism is used in NSButton and NSMatrix.

This fix allows view based TableView bindings from a text field cell to the table cell view in the Interface Builder in Xcode.
2018-03-06 09:09:57 +01:00
Martin CarlbergandGitHub 511d393c78 Merge pull request #2576 from mrcarlberg/cptextview_delegate
New: CPTextView delegate methods added
2018-03-06 09:07:55 +01:00
Martin CarlbergandGitHub 237601cf29 Merge pull request #2579 from mrcarlberg/xml-parser-node
Fixed: The property list test cases can now run on the Node engine.
2018-03-06 09:00:41 +01:00
daboe01andMartin Carlberg 928f14872e Fixed: call to nonexistent method (#2588) 2018-03-06 08:59:36 +01:00
Martin CarlbergandGitHub c6a9adf96c Merge pull request #2556 from daboe01/plainsliderfix
Fixed: legacy scrollers used Aristo1 artwork in Aristo2
2018-03-05 11:06:59 +01:00
Martin CarlbergandGitHub cdd00e0bd4 Merge pull request #2595 from daboe01/cpnumber-unarchiving-fix
Fixed: initWithCoder: called unimplemented method on the coder
2018-03-05 11:04:41 +01:00
Martin CarlbergandGitHub 2503d13402 Merge pull request #2594 from daboe01/CPSavePanel-missing-class-method
Fixed: +proposedFileURLWithDocumentName: was missing
2018-03-05 11:01:18 +01:00
daboe01andMartin Carlberg 2d97970d24 Fixed: numberWithInteger: was erroneously used instead of numberWithInt: (#2587) 2018-03-05 10:50:30 +01:00
Martin CarlbergandGitHub d8945e53ba Merge pull request #2593 from daboe01/CPCoder--remove-bitrot
Fixed: unused and broken code removed from CPCoder
2018-03-05 10:43:41 +01:00
daboe01andMartin Carlberg f18012d07b Fixed: removed erroneous call to sizeValue (#2589) 2018-03-05 10:36:22 +01:00
daboe01 104f8603b9 fixed: initWithCoder: called unimplemented method on the coder 2018-03-04 21:27:08 +01:00
daboe01 19bb083030 fixed: +proposedFileURLWithDocumentName: was missing 2018-03-04 18:40:33 +01:00
daboe01 ae575a19a0 fixed: unused broken code removed from CPCoder 2018-03-04 11:55:34 +01:00
cacaodevandGitHub 5f94d0a5c2 Typo: remove extra semi-colon 2018-02-28 15:33:16 +01:00
Korthoudt Didier f2fe1a7c17 Merge remote-tracking branch 'cappuccino/master' 2018-02-27 23:41:34 +01:00
cacaodevandGitHub 618e6a1604 Merge pull request #2591 from daboe01/_CPFunctionExpression.j-missing-if
fixed: fromObject:(id)object index:(id)anIndex failed to raise if arg…
2018-02-27 15:59:19 +01:00
cacaodevandGitHub cef294513a Merge pull request #2590 from daboe01/CPKeyValueObserving-fix-CPKeyValueChangeReplacement
FIXED: Typo in call to replaceObjectsAtIndexes in CPKeyValueObserving
2018-02-27 15:58:13 +01:00
daboe01 8550abadef fixed: fromObject:(id)object index:(id)anIndex failed to raise if argument was not CPDictionary or CPArray 2018-02-24 15:41:17 +01:00
daboe01 25c8b2d631 fixed: typo in call to replaceObjectsAtIndexes 2018-02-24 14:59:27 +01:00
Martin Carlberg e7b690205e Fixed: The property list test cases can now run on the Node engine.
The xml parser in the Node.js engine is more modern and can handle more cases. Our property list parser does not handle this. This fix makes the test cases for the property lists run on the Node.js engine.
2018-01-15 09:28:39 +01:00
Martin Carlberg 2403f8833a Fixed: Added an application description at the top of the window 2018-01-09 13:43:09 +01:00
Martin Carlberg 9f25743b4d Fixed: Never send CPTextViewDidChangeTypingAttributes notification when selection the same selection again. This is how Cocoa works. 2018-01-09 13:41:34 +01:00
Martin Carlberg f1c76f65cf Fixed: Added some comments on some methods 2018-01-09 13:37:35 +01:00
Martin Carlberg 7b39533410 New: Added manual test application to monitor order and number of calls for CPTextView delegate methods and notifications. 2018-01-08 14:11:55 +01:00
Martin Carlberg 1fe9c39dd5 Fixed: Test cases for the new or changed delegate methods and notifications. 2018-01-08 13:57:53 +01:00
Martin Carlberg 2b7be2e3f1 Fixed: Make sure the delegate methods and notifications are handled in the same way as in the Cooca frameworks.
CPTextViewDidChangeSelectionNotification should not be send if the text view is empty.
CPTextDidBeginEditingNotification is send when an edit is started.
CPTextDidEndEditingNotification is send when an edit is ending.

textShouldBeginEditing: delegate method is called to allow control if edit should start.
textShouldEndEditing: delegate method is called to allow control if edit should end.
2018-01-08 13:56:24 +01:00
Martin Carlberg 1ee9a3f279 Fixed: Check if the correct delegate method is implemented before calling it 2018-01-08 13:47:45 +01:00
Martin Carlberg 679acfb239 Fixed: Register the delegate as an observer on any notification that the delegate implement.
Also make sure we remove the observers if for example the view does not have a superview. This will make sure that the Notification Center is not hanging on to the view and delegate if the view is not used any more. Can cause a memory leak.
2018-01-08 13:44:47 +01:00
Martin Carlberg 3c7ab4b49b Fixed: Make the view aware of some more delegate methods 2018-01-08 13:20:03 +01:00
Martin Carlberg 3f062e1c0a Fixed: Make all method in CPTextDelegate and CPTextViewDelegate protocol optional. 2018-01-08 13:15:31 +01:00
Didier Korthoudt 0a497d8c3f NEW: Added automatic Xcode syntax coloring
In Xcode, Objective-C source files are automatically recognised and the usual syntax coloring is applied. With this PR, Xcode will do so for Objective-J source files.
2017-12-17 20:49:56 +01:00
Korthoudt Didier 462351f485 Merge remote-tracking branch 'cappuccino/master' 2017-12-17 20:06:35 +01:00
Martin CarlbergandGitHub c4cbb631a9 Merge pull request #2561 from mrcarlberg/compile_with_sourcemap
Full support for source map when debugging
2017-12-11 10:52:05 +01:00
Martin Carlberg 76f2d15b1b Fixed: Added the option to only inline message send function without also compress the output javascript file.
This allows us to inline the message send function in DEBUG mode. This is great when stepping into a method in the debugger as the message send function is not a separate function. Also the stack traces in the debugger is much more compact as the message send function is not there.
2017-12-08 14:02:11 +01:00
cacaodevandGitHub 5d63865ae5 Merge pull request #2546 from cacaodev/CPSplitView
CPSplitView -trackDivider: performance
2017-11-08 18:53:22 +01:00
daboe01 ad7c88fb45 Merge remote-tracking branch 'cappuccino/master' 2017-09-27 11:46:45 +02:00
daboe01 1af3877758 FIXED: scroll-knob was slightly too bold 2017-09-27 11:05:59 +02:00
Martin CarlbergandGitHub 146ce3b12b Merge pull request #2544 from FrankReh/pullreq/cleanup/old/unused/ensurePackageUpToDate
Remove: ensurePackageUpToDate() from common.jake
2017-09-26 08:43:41 +02:00
Martin CarlbergandGitHub bf67721ac4 Merge pull request #2548 from cacaodev/CPWindow-live-resize-notifications
CPWindow live resize notifications
2017-09-25 14:04:01 +02:00
Martin CarlbergandGitHub 436f736a8e Merge pull request #2543 from FrankReh/pullreq/cleanup/remove/property/sub_classes
Remove objj_class.sub_classes property
2017-09-22 13:03:54 +02:00
Martin Carlberg 1446e90dd9 Fixed: Use correct naming on function parameter. Also changed som comments to reflect the correct meaning of the parameter 2017-09-18 13:39:28 +02:00
Martin Carlberg 54716c03d1 Fixed: Missed new line when increment tokPos. Now we use the correct skip space function that will take care of things in correct manners. 2017-09-18 13:36:51 +02:00
daboe01 fad5e97e0a Merge remote-tracking branch 'cappuccino/master' into plainsliderfix 2017-09-14 09:10:56 +02:00
Martin Carlberg 8cf79590c5 Fixed: When target was ’self’ in a message send expression the source map was showing the wrong variable. 2017-09-12 13:17:49 +02:00
Martin Carlberg c6aafac6c8 Fixed: Compile Foundation and AppKit frameworks with source maps for the debug version. 2017-09-11 12:50:49 +02:00
Martin Carlberg 94a5995197 New: We now support source maps when compiling both from command line and in browsers.
To add source maps add the ”-S” flag to the Jake file when compiling from command line. In the browser you need to add the compiler option into your index.html file. It should look something like this:
OBJJ_COMPILER_FLAGS = [... , "SourceMap"];

All browsers has support for source maps but currently Chrome works best.
2017-09-11 12:49:59 +02:00
Martin CarlbergandGitHub 74081dc981 Merge pull request #2551 from mrcarlberg/compile_without_gcc
Compile without gcc [+2]
2017-09-11 11:14:44 +02:00
daboe01 7a593b13a7 Merge remote-tracking branch 'cappuccino/master' into plainsliderfix 2017-09-09 10:56:37 +02:00
Martin CarlbergandGitHub 25dc38b2b1 Merge pull request #2558 from daboe01/smartcopypastefixes
Fixed: smart copy/paste did not work properly [+1]
2017-09-08 09:09:26 +02:00
Alexandre WilhelmandGitHub 403b12f7b7 Merge pull request #2550 from cacaodev/CPAnimationContext
FIXED: CPAnimationContext completionHandler was not called under certain circumstances.
2017-09-07 18:21:56 -07:00
Alexandre WilhelmandGitHub cd223be88a Merge pull request #2557 from daboe01/placeholderselectablefix
fixed: cursor blinks for placeholder
2017-09-07 18:21:12 -07:00
Alexandre WilhelmandGitHub a6a3fca1e7 Merge pull request #2559 from daboe01/onpaste-ff-fix
Fixed: CPTextView's onpaste handler used non-standard window.event
2017-09-07 18:20:32 -07:00
daboe01 63815eb5c2 fixed: onpaste handler used window.event (non-standard)
broke paste on FF/win
2017-09-07 19:19:19 +02:00
daboe01 4444264830 formatting 2017-09-04 23:02:50 +02:00
daboe01 255f91f7ca fixed: cornerview looked odd without scroller margins 2017-09-04 22:59:34 +02:00
cacaodevandGitHub 700207d29b Merge pull request #2554 from cacaodev/cptableview-issue#2549
CPTableView: fix invisible dragged rows
2017-08-30 08:35:40 +02:00
daboe01 72d96e9a3b fixed: smart pasting did not work properly 2017-08-29 15:11:29 +02:00
daboe01 a55b6de1b4 removed: unused artwork from aristo2 2017-08-28 23:32:47 +02:00
daboe01 9faac05666 fixed: cursor blinks for placeholder 2017-08-23 23:07:42 +02:00
daboe01 7bf408aba0 fixed: legacy scrollers used aristo1 artwork in aristo2 2017-08-22 22:02:42 +02:00
daboe01 70ee391b33 Merge remote-tracking branch 'origin/master' 2017-08-22 14:40:47 +02:00
cacaodev f5eb1158db Fix issue 2549: table rows where invisible when dragging. 2017-07-28 21:35:24 +02:00
cacaodev 81916d0f45 FIXED: A grouping context does not inherit the completion handler ...
… from the current context.
Also removed CPAnimationContext -copy method. CPAnimationContext is not
CPCopying compliant.

TEST: CPAnimationContextTest ->
testCompletionHandlerWithoutAnimatorWithGrouping2
2017-07-25 12:04:58 +02:00
Alexander Ljungberg 76d77cc244 This will be Cappuccino 0.9.10. 2017-07-11 14:26:57 +01:00
cacaodev 03dccbe613 Add a manual test for the previous fixes.
The tests must be run independently because animations are launched at
the end of the current run loop.
2017-06-30 12:26:15 +02:00
cacaodev 1ccec65619 Add debug information 2017-06-30 12:03:29 +02:00
cacaodev b78e9062a1 CompletionHandlerAgent fire() is a one shot. 2017-06-30 12:03:09 +02:00
cacaodev dc87354702 CPAnimationContext setCompletionHandler: add an equality check 2017-06-30 12:00:08 +02:00
Martin Carlberg 033e8583db Fixed: A more robust prettify message function 2017-06-26 17:59:08 +02:00
Martin Carlberg d46b51fa9a Fixed: In Rhino a function must be declared before it is used even if it is in the same scope. 2017-06-26 17:58:13 +02:00
Martin Carlberg dd1dfdcfeb Fixed: Added a comment on tricky code line 2017-06-26 16:25:44 +02:00
Martin Carlberg c0233c803d Fixed: Removed old print statements for debugging 2017-06-26 16:24:51 +02:00
Martin Carlberg 1fa8c88f6b Fixed: Speed up of objj_msgSend function. Don’t need to use complex check if class is initialized. 2017-06-26 16:23:59 +02:00
Martin Carlberg 195b109a36 New: Added ’#include’ to the preprocessor, compiler and Cappuccino load system. Also a lot of bug fixes in the preprocessor 2017-06-26 16:19:56 +02:00
Martin Carlberg 994ac3fc8e Fixed: Support for more options to the objj tool 2017-06-26 16:04:01 +02:00
Martin Carlberg a8ec5cf5e9 New: Support to create source maps for the frameworks and applications 2017-06-26 16:03:20 +02:00
Martin Carlberg b4263aa3ec New: Make sure we can use String function ’startsWith’ and ’endsWith’ even if an older browser or Javascript engine is used. 2017-06-26 15:50:08 +02:00
Martin Carlberg 6456809a72 Fixed: Use semicolon on last line in #included files. The new preprocessor might think that the statement will continue on the next line.
Due to Javascript don’t need to have semicolon at end of statement there are times when the parser thinks the line continues on the next line.

For example we have a file.js:
var f = function(x)
{
	return x + x;
}

Now in another file we do:
#include file.js
(function(exports) {
a = 42;
})(exports.b)

There will be two different behaviors if the ’file.js’ has a semicolon at the end of the last line. This commit make sure we have the right behavior.
2017-06-26 15:45:02 +02:00
Martin Carlberg 024c0a3186 Fixed: Handle source maps if source-map.js is included from the index.html file.
To create source maps the compiler flag ”SourceMap” has to be added in the OBJJ_COMPILER_FLAGS array in the index.html file.
2017-06-22 11:05:16 +02:00
Martin Carlberg 560b1d48bc Merge branch 'master' of https://github.com/cappuccino/cappuccino 2017-06-22 10:46:53 +02:00
cacaodev bb2d860807 CPViewAnimator: guard in the frame updater function
… in case the transform property value is ‘none’.
2017-06-12 12:46:05 +02:00
cacaodev 6f1c0fa4a8 FIXED: CPAnimationContext completionHandler was not called
Previously, if a context group was not generating any animation (no
calls to animator or non implemented method in the animator proxy), the
completionHandler was not called.
If the end value (frame, frameorigin, frameSize) was equal to the start
value, the completionHandler was not called neither.

This commit makes sure that the completionHandlerAgent counter is
incremented by the count of animations that actually start.
2017-06-12 12:46:05 +02:00
cacaodev 35808e7bde FIXED: uninitialized ivar 2017-06-02 11:15:23 +02:00
cacaodev 1b4eeb35b3 Add a manual test CPWindowLiveResizeTest 2017-06-02 09:44:42 +02:00
cacaodev cee032bbc9 FIXED: send live resize notifications when the window animates
Like in cocoa, these notifications are not sent when a sheet is
displayed.
2017-06-02 09:42:59 +02:00
cacaodevandGitHub 9547b70743 Merge pull request #2542 from FrankReh/pullreq/cleanup/fix/unused/cachedSearchResults
Removed an unused variable: cachedSearchResults.
2017-05-30 19:29:14 +02:00
cacaodevandGitHub 5df8939d84 Merge pull request #2541 from FrankReh/pullreq/cleanup/fix/syntax/protocol_list
Fix aClass.protocol_list syntax
2017-05-30 19:27:53 +02:00
cacaodevandGitHub 0b9c689273 Merge pull request #2540 from FrankReh/pullreq/cleanup/fix/syntax/global-var-key
Make variable local: key
2017-05-30 19:25:25 +02:00
cacaodev ac193cd97a Test: Add liveResize testing in CPWindowResizeStyle manual test
The window title changes during live resize.
2017-05-30 19:06:50 +02:00
cacaodev 7355a60f16 Call _setupDOMDivider when necessary only
Previoulsy, the backgroundColor and url css properties where set at
each drawing pass.
2017-05-30 18:33:08 +02:00
cacaodev fb6f6325b5 CPSplitView: refactor trackDivider: using _dividerAtPoint:
instead of a for loop.
2017-05-23 08:17:16 +02:00
cacaodev 0f767d9dfc CPWindow: add CPWindowWillStartLiveResizeNotification and CPWindowDidEndLiveResizeNotification
Also fixed CPView -(BOOL)inLiveResize
If a view is added during a live resize, it will not receive a
willStart notif.
If a view is removed during a live resize it will not receive a Didend
notif.
2017-05-20 13:52:50 +02:00
cacaodev d1addcab91 CPSplitView: do not track events outside of a divider.
Added private method -_dividerAtIndex:
2017-05-13 19:46:39 +02:00
cacaodev 7a02cd794b Properly catch single-click, double-click, dragging on a divider
Previously, a double-click was also catched as a single-click on mouse
up,
dragging was handled is mouse down before tracking actually begins.

Manual test: added collapse capabilities to all split views.
2017-05-12 11:09:08 +02:00
cacaodev 258cd9209f CPSplitView: exit a loop when the current divider is found 2017-05-12 10:28:47 +02:00
Frank Rehwinkel 700f6022d9 Remove: ensurePackageUpToDate() from common.jake
Some unused code in common.jake that had referred to tusk.  Has not
been used in years.
2017-05-06 13:10:49 -04:00
Frank Rehwinkel a0f6b815e8 Removed an unused variable: cachedSearchResults.
It is polluting the global namespace.

Seven years ago this line was added and even then the variable wasn't
being used but it was a local variable so would have been hard to spot
unless a linter should catch things like that.

Then some four years ago it was accidently converted to a global
variable because the line above it ended in a semicolon rather than
a comma.  'use strict' didn't exist at the time this file was created
and hasn't been added in general yet.
2017-05-04 16:03:11 -04:00
Frank Rehwinkel 54477b8b8f Make variable local: key
This line of code was introduced years ago with a variable that
javascript is happy to add to the global name space.  Clearly it
was meant as a local variable.  Probably a cut and paste error
because other places in the code use the same syntax but there the
value is a local because the var statement for it appeared elsewhere
in the function.

Once code like this is cleaned up to use the new 'let' construct,
as well as 'use strict', mistakes like this will be much less likely
to go uncaught.
2017-05-04 16:01:53 -04:00
Frank Rehwinkel 6183f8d4e9 Fix aClass.protocol_list syntax
A long standing bug that never mattered because each class is
initialized with a protocol_list set to an empty array.  This
is not the case for the protocol objects but there the syntax
was correct already.
2017-05-04 15:58:47 -04:00
Frank Rehwinkel d98e247665 Remove objj_class.sub_classes property
From the first day this class was added to the repo, the sub_classes
property, which is initialized with an empty array, has gone unused.

Removing it.  A little less code.  A little subsequent processing
and memory used.
2017-05-04 15:57:14 -04:00
Martin Carlberg d0cd976246 Fixed: Get class method instead of instance method
When asking a protocol for a specific class method we asked each super protocol for an instance method.

Thanks Frank for finding this!
2017-04-11 12:30:16 +02:00
daboe01 15f6f6a90a Merge remote-tracking branch 'cappuccino/master' 2017-03-18 11:02:38 +01:00
cacaodevandGitHub f18074bf49 Merge pull request #2532 from cacaodev/CPWindowAnimator
New: Optional declarative layout for use in CoreAnimation (css animations).
Code refactor.
2017-03-13 08:34:01 +01:00
cacaodevandGitHub 3f64b74453 Merge pull request #2533 from cacaodev/CPCompatibility-SetFeature
NEW: CPCompatibility: add a function to set a feature externally.
```CPSetPlatformFeature(aFeature, aBool)```
2017-03-13 08:28:51 +01:00
cacaodev 1c86256f83 Add CPCSSAnimationFeature to CPCompatibility constants 2017-03-02 11:21:57 +01:00
cacaodev 98105ad4dc Merge branch 'CPCompatibility-SetFeature' into CPWindowAnimator-copy 2017-03-02 10:57:23 +01:00
cacaodev 6bf2d6c1ab Move css animation creation & frame updaters to CPViewAnimator
Reason: • consistency : animations handled by animator.
• Views can now animate several DOM elements. For example
a view with a nine part image need to animate its sub divs.

• Do not create any css animation when the start and end values are
equal and there is no intermediate values.

+ This commit adds an optional method to CPView
- (CGRect)frameRectOfView:(CPView)aView inSuperviewSize:(CGSize)aSize
Returns the frame of a view given its superview frame. This will allow
views implementing -layoutSubviews to gain an optional declarative
layout. The animation system will use this method to compute the end
value of an animation.
2017-03-02 10:30:09 +01:00
cacaodev cebd51aac1 reduce the number of args in a private method 2017-03-02 10:30:08 +01:00
cacaodev 42b8b3aa75 Ask the animator if periodic frame updates are needed 2017-03-02 10:30:08 +01:00
cacaodev c0eaf79d25 Remove jshashtable.js in favor of Map() 2017-03-02 10:30:07 +01:00
cacaodev fb2fe3eb63 Enable forced frame updates in CPViewAnimator 2017-03-02 10:30:07 +01:00
cacaodev 184d63f7eb Move the FrameUpdater function to CPViewAnimator 2017-03-02 10:30:07 +01:00
cacaodev 14ebd58c96 Move CFRunLoopObserver to CPRunLoop.j as a global function 2017-03-02 10:30:05 +01:00
cacaodev 3edddb8e91 Add CSSAnimation.description() function 2017-03-02 10:30:05 +01:00
cacaodev d2340dff1a Style, whitespace 2017-03-02 10:30:04 +01:00
cacaodev d30c6aec7d Fix label in demo (AutoSize checkbox) 2017-03-02 09:56:47 +01:00
cacaodev 4854b3e08f Fix typo 2017-03-02 09:48:12 +01:00
cacaodev facc748090 NEW: CPCompatibility add a function to set a feature externally.
CPSetPlatformFeature(aFeature, aBool)
2017-03-01 19:10:00 +01:00
cacaodevandGitHub 5c71612e34 Typo 2017-02-10 20:01:57 +01:00
cacaodevandGitHub f00a5fbaf4 Merge pull request #2531 from cacaodev/cptableview-diddragcolumn
FIXED: tableView:didDragTableColumn: was never sent
With tests.
Fixes #2530
2017-02-03 08:13:46 +01:00
cacaodev 34769da9cc FIXED: tableview:didDragTableColumn: was never sent
With manual test.
2017-02-02 09:36:48 +01:00
cacaodev 458e6ed531 FiXED: CPTableColumn description 2017-02-02 09:34:17 +01:00
daboe01 05814e9351 Merge remote-tracking branch 'cappuccino/master' 2017-01-26 19:55:12 +01:00
daboe01 b6c0b1b396 Merge remote-tracking branch 'cappuccino/master' 2017-01-19 20:03:10 +01:00
Martin CarlbergandGitHub 1a299d85b6 Merge pull request #2503 from enquora/master
Fix CPBox drawing artifacts when used in CPSeparator mode
2017-01-19 09:46:33 +01:00
David Richardson 1816274ebe Revert "Fix CPBox drawing artifacts when used in CPSeparator mode"
This reverts commit 7596c66703.
2017-01-17 11:59:26 -07:00
David Richardson b02e4c5308 Handle case when CPBox is used as a separator line having no title
If _titlePosition is correctly set to CPNoTitle value, class already handles removing title view from display.
Previously, _titlePosition was not correctly set, title view was left in place.
With no supplied value for title, outline of title view was rendered with visible artifacts.
2017-01-16 11:23:32 -07:00
Martin CarlbergandGitHub 12ed42e163 Merge pull request #2505 from HTPC-Schrauber/fix-RegEx
Fixed: RegEx for gcc > 4.9
2017-01-16 12:36:57 +01:00
Martin CarlbergandGitHub 6c9c135062 Merge pull request #2525 from daboe01/new-textview-bindings
New: bindings support for CPTextView + dragging improvements
2017-01-16 12:24:56 +01:00
Martin CarlbergandGitHub 6aea0160df Merge pull request #2508 from daboe01/fix-sizing-issue
Fixed: text-sizing by canvas and via DOM sizing differed by 1px
2017-01-16 12:20:06 +01:00
daboe01 30edd9e8dd Merge remote-tracking branch 'cappuccino/master' 2017-01-06 13:05:18 +01:00
David Richardson 7734402e8e Merge branch 'master' of https://github.com/cappuccino/cappuccino into enquora-master 2017-01-05 16:00:51 -07:00
daboe01 ace1332ca5 fixed: semipredicate issue caused typingAttributes being overwritten by placeholder attibutes 2016-12-28 23:16:03 +01:00
daboe01 baa313e8f8 fixed: insertion point was wrong sometimes when dragging beyond last character 2016-12-26 23:30:23 +01:00
daboe01 3d9aa24f3c formatting 2016-12-26 23:18:24 +01:00
daboe01 c287d457d6 formatting 2016-12-26 22:14:12 +01:00
daboe01 7537b27a58 fixed: pboad types were wrong when unarchiving from cib 2016-12-26 22:11:11 +01:00
daboe01 1f560c92fc fixed: dragging pasteboard was not respecting rich vs. plain 2016-12-26 21:49:36 +01:00
daboe01 74cd11c763 minor cleanup 2016-12-26 14:50:33 +01:00
daboe01 ee7d89331b fixed: selection dragging was broken by changes to insertText 2016-12-26 12:50:16 +01:00
daboe01 5b51077823 fixed: changing the selection was possible despite isSelectable returning NO 2016-12-26 12:35:23 +01:00
daboe01 d2f94d1945 formatting 2016-12-26 11:53:49 +01:00
daboe01 0170a099bb formatting 2016-12-26 11:50:25 +01:00
daboe01 2b893d0ea1 fixed: placeholder string was not supported in textview bindings 2016-12-26 11:47:33 +01:00
daboe01 a08da57cbb fixed: reverse setting did not work 2016-12-26 10:56:43 +01:00
daboe01 a313fe5a86 add basic binder + manual test 2016-12-26 09:40:58 +01:00
daboe01 544de699f6 Merge remote-tracking branch 'cappuccino/master' into new-textview-bindings 2016-12-24 20:46:26 +01:00
daboe01 d9d35b7f50 add binder class router 2016-12-24 20:46:12 +01:00
daboe01 7dbec00f0e Merge remote-tracking branch 'cappuccino/master' into new-textview-bindings 2016-12-18 21:07:21 +01:00
Martin CarlbergandGitHub 51b9b40c7e Merge pull request #2515 from daboe01/chrome-rich-paste-fix
fixed: native paste on chrome was not working as robustly as it should [+1]
2016-12-13 09:40:18 +01:00
daboe01 b2383a084a fixed: wrong name in CPTextView manual test 2016-12-12 22:32:00 +01:00
daboe01 61848c5e24 fixed: selection was not properly restored upon undo/redo 2016-12-12 20:29:19 +01:00
Martin CarlbergandGitHub 60b2f7d243 Merge pull request #2513 from daboe01/fix-combobox-scroll-issue
Fixed: legacy scrollers were not clickable under some circumstances
2016-12-12 13:16:01 +01:00
daboe01 d2a5e126ae fixed: native rich text was parsed when pasted into plain textview
+ newline fix in rtf parser
2016-12-11 22:42:43 +01:00
daboe01 9d7d8ddde9 fixed: native rich pasting pasted rich text into plain textviews 2016-12-11 14:05:51 +01:00
Martin CarlbergandGitHub 249ebeb4aa Merge pull request #2517 from daboe01/fix-initial-blinking-on-sheet
Fixed: caret did not blink in empty textview, e.g. when on freshly opened popover
2016-12-10 11:11:13 +01:00
daboe01 378c14d790 formatting 2016-12-09 23:53:08 +01:00
daboe01 30c1093c2f fixed: rich native pasting caused FF to flicker 2016-12-09 23:45:16 +01:00
daboe01 b966c8cb0b formatting 2016-12-09 21:35:42 +01:00
daboe01 38cddf029b fixed: rich native pasting was not using the rtf pasteboard type on chrome 2016-12-09 21:32:21 +01:00
Martin CarlbergandGitHub 6652a27781 Merge pull request #2518 from cacaodev/CPControl-usesSingleLine
New: Allow a text based control to stay on a single line when text wraps.
2016-12-09 15:13:28 +01:00
daboe01andcacaodev 08b067cfc5 fixed: cared was blinking during typing (#2519) 2016-12-04 13:33:24 +01:00
daboe01 4959b84b4c fixed: implicit casting of NULL aWith argument to string in _sizeWithFont:inWidth: 2016-12-02 22:08:48 +01:00
cacaodev d42562fdcb New: Allow a text based control to stay on a single line when wrapping
A private flag have been added in _CPImageAndTextView. It must be set
to YES when it does not make sense for a control to hold multiline text.
This is now the case for all CPSegmentedControl.

Test: In CPSegmentedControlTest, hit « Add Segment with flexible
width » button. The new label should be vertically centered.
2016-12-02 09:10:39 +01:00
Alexandre WilhelmandGitHub 1e0aacd811 Merge pull request #2511 from cacaodev/CPObjet-instancesImplementSelector
New: CPObject -instancesImplementSelector:(SEL)aSelector
2016-11-22 22:44:30 -08:00
daboe01 329469fe84 fixed: _textContainerOrigin.y was not respected when predicting the cared position in empty textview 2016-11-20 22:36:24 +01:00
daboe01 93b0c5a7e5 fixed: font height was nil under certain circumstances 2016-11-20 21:44:08 +01:00
daboe01 9e456fd315 Merge remote-tracking branch 'cappuccino/master' 2016-11-20 15:31:25 +01:00
daboe01andcacaodev 8203c71b03 fixed: CPTextView's needsPanelToBecomeKey did not return YES (#2512)
This is confirmed to conform to cocoa.
2016-11-17 16:43:54 +01:00
daboe01 80d1e9a9a7 fixed: ceiling the sizing width caused subtle issues with CPTextView 2016-11-15 22:43:24 +01:00
daboe01 3c27e57b19 fixed: native rich pasting curly braces crashed chrome 2016-11-15 21:02:04 +01:00
daboe01 b46b2f048d fixed: native paste on chrome was not working as robustly as it should 2016-11-14 23:09:04 +01:00
cacaodev 8d403f579c FIxed: IB connections in CPTabViewNibTest 2016-11-14 22:03:51 +01:00
daboe01 12b274ab43 formatting 2016-11-13 22:55:29 +01:00
daboe01 986cccb800 fixed: legacy scroller was not clickable under some circumstances 2016-11-12 23:03:45 +01:00
cacaodev 5da8728d6c New: CPObject instancesImplementSelector:(SEL)aSelector
Tests if instances of given class implement a selector.

With test.

Note: The naming is from cocoa where this method is semi-public.
2016-11-12 18:30:02 +01:00
daboe01 66c9a1e90a ceil is a better solution than adding one 2016-11-11 23:02:57 +01:00
daboe01 a1925e1d0b fixed: the canvas sizing and DOM sizing differed by 1px 2016-11-08 19:52:45 +01:00
daboe01 da0910b1e5 Merge remote-tracking branch 'cappuccino/master' 2016-11-08 19:34:28 +01:00
Didier Korthoudt 8dbbe34dfc Merge remote-tracking branch 'cappuccino/master' 2016-11-08 15:21:17 +01:00
cacaodev 947d552509 Fix merging 2016-11-07 22:57:33 +01:00
cacaodev 037bc4ea2b Test: demonstrate the new wantsPeriodicFrameUpdates animator property
In Tests/Manual/CPAnimatablePropertyContainerTest/
2016-11-07 22:26:30 +01:00
cacaodev cfbef141d8 CPAnimationContext: Inhibit DOM updates during size animation
Previously, during frame updates, we were writing the css values we
just read before.
Canvas sizing is preserved as it is needed when the view has custom
drawing.
2016-11-07 22:26:30 +01:00
cacaodev 410ad0dc09 Style: print debug logs in debug mode only 2016-11-07 22:26:29 +01:00
cacaodev 3d9b42f0c2 Style: CSSAnimation.j linting
Using default eslint config for js
2016-11-07 22:26:29 +01:00
Didier Korthoudtandcacaodev eeea21c882 Fixed: CPViewAnimator was not giving correct frame information (#2502)
Fixed: When only animating frameSize, there’s no matrix defined. This is now
correctly handled.
New: The animator can explicitly request frames updates when the frameOrigin 
keyPath changes with the new method [animator setWantsPeriodicFramesUpdates:YES]
2016-11-07 22:20:55 +01:00
Maik Opitz d94e5480c9 Merge branch 'fix-RegEx' of https://github.com/HTPC-Schrauber/cappuccino into fix-RegEx 2016-11-03 12:42:05 +00:00
Maik Opitz a5c8e87e6d Removed mistaken triplequotes 2016-11-03 12:33:39 +00:00
Maik Opitz 08f74201b6 RegEx angepasst 2016-11-02 16:21:03 +00:00
Maik Opitz 3a25c683b6 Regex nochmals angepasst 2016-11-02 16:48:10 +01:00
Maik Opitz fb43f8bf1a Regex nochmals angepasst 2016-11-02 16:45:01 +01:00
Maik Opitz bf082600c3 fixed RegEx with newer gcc versions 2016-11-01 15:46:40 +01:00
David Richardson 7596c66703 Fix CPBox drawing artifacts when used in CPSeparator mode
Suppress title positioning when CPBox used as a line or separator - by definition the title is null.
2016-10-31 16:21:46 -06:00
Didier Korthoudt e1bcf6c47e Merge remote-tracking branch 'cappuccino/master' 2016-10-31 16:11:38 +01:00
Alexander Ljungberg ef1d6c78ac Merge branch 'master' of github.com:cappuccino/cappuccino 2016-10-30 21:06:25 +00:00
Alexander Ljungberg f36406af08 Text tweak. 2016-10-30 21:05:54 +00:00
Alexandre WilhelmandGitHub 4b7d215d9d Merge pull request #2498 from daboe01/fixed--font-can-be-nil
Fixed:  font can be nil sometimes
2016-10-30 13:52:03 -07:00
daboe01 e09f12dc0b fixed: accessors for _font were not used sometimes 2016-10-26 19:58:21 +02:00
daboe01 efa7406741 fixed: typing font was nil in sometimes cib-generated textviews 2016-10-26 19:53:59 +02:00
daboe01 5a2181c064 Merge remote-tracking branch 'cappuccino/master' 2016-10-26 19:51:22 +02:00
cacaodev dda81b12da Revert "nib2cib: discard warnings in the nib file."
This reverts commit 4e11152e76.
2016-10-22 08:40:38 +02:00
Martin CarlbergandGitHub c4bf67d133 Merge pull request #2496 from cacaodev/cptabview-initial-selection
Fixed: CPTabView should not allow empty selection
2016-10-21 18:16:31 +02:00
daboe01 f355c8679d Merge remote-tracking branch 'cappuccino/master' 2016-10-21 17:38:56 +02:00
cacaodev 095864de39 Fixed: CPTabView should not allow empty selection
Before this commit, a tab view could have an empty selection with the
following circumstances:
- The tab view was not created in IB
- the Tab View selection had not binding management

With test.
2016-10-21 10:13:47 +02:00
cacaodevandGitHub 0eb196e852 CPTabView: load tab view items asynchronously when possible (#2479)
When an item created with +tabViewItemWithViewController:, the view is loaded asynchronously

Manual test CPTabViewNib have been modified to show a tab view item
managed by a view controller. Any setup happens in
-viewDidAppear: because we cannot use any more the
tabView:didSelectTabViewItem: delegate method.
2016-10-20 17:24:18 +02:00
cacaodevandGitHub 62e5d8d841 Fixed: type declaration 2016-10-20 08:48:01 +02:00
cacaodevandGitHub 2f82fb842d Merge pull request #2495 from daboe01/fixed--typo-in-CPControl-comment
Fixed:  typo in CPControl comment
2016-10-19 08:37:27 +02:00
daboe01 f9fa6abbad fixed: small typo in comment 2016-10-18 21:46:21 +02:00
cacaodevandGitHub 4b55a69150 Merge pull request #2447 from cacaodev/CPAnimationContext-fixes
Fixed: The animation was reverting back to its initial position.
Fixed: custom layout and custom drawing was not animated in Chrome and Firefox.
2016-10-17 22:01:15 +02:00
Martin CarlbergandGitHub 42e12fae24 Merge pull request #2485 from cacaodev/ibtool-warnings
nib2cib: discard warnings in the nib file.
2016-10-17 18:07:59 +02:00
daboe01andcacaodev 2f55d5130a fixed: typo in accessor setHorizontallyResizable: (#2494) 2016-10-16 21:24:30 +02:00
daboe01 cd4b47b397 Merge remote-tracking branch 'cappuccino/master' 2016-10-16 13:20:13 +02:00
daboe01andcacaodev 126cba1e94 Fixed: textsizing was wrong in safari (#2486)
* fixed: color panel creation in font panel init did break text sizing in safari

* fixed: font sizing did not robustly work on safari

* removal of dead code

* fixed: browser sniffing was not using the mechanisms from CPCompatibility.j

* fixed: blink and webkit engines must not be mutually exclusive

* improved documentation
2016-10-16 10:11:10 +02:00
daboe01 e4e894fa54 Merge remote-tracking branch 'cappuccino/master' 2016-10-15 17:10:59 +02:00
Martin CarlbergandGitHub 65f701d459 Merge pull request #2487 from daboe01/fixed--CPTextView-did-not-support-dragging-the-selection
Fixed: CPTextView did not support dragging the selection
2016-10-13 17:22:51 +02:00
Martin CarlbergandGitHub c2b7cc7964 Merge pull request #2302 from ahankinson/fix-cpview-formatting
Formatting: CPView
2016-10-13 16:55:46 +02:00
Martin CarlbergandGitHub 969d1dff2a Merge pull request #2492 from didierkorthoudt/cpview-updateTA-recursive-bug
Fixed: CPView setFrameSize was calling _updateTrackingAreas too often + empty overlappingTA test
2016-10-13 16:07:10 +02:00
Didier Korthoudt e0fab808b9 fix-overlappingTA-could-be-empty 2016-10-08 17:33:21 +02:00
Didier Korthoudt 77031d7082 Fixed: setFrameSize was calling _updateTrackingAreas too often 2016-10-06 22:54:32 +02:00
Didier Korthoudt 5a0f7ea706 Merge remote-tracking branch 'cappuccino/master' 2016-10-06 20:25:25 +02:00
daboe01 9d041c4b62 fixed: unnecessary safety margin for dragview width 2016-10-02 21:28:38 +02:00
daboe01 ec4d29c327 fixed: transaction issue from the undo manager 2016-10-02 10:34:30 +02:00
daboe01 5f8d8988e3 revert: move drag indicator uncoditionally to the right side 2016-10-01 20:21:52 +02:00
daboe01 a31912f710 fixed: insertion marker was off by one 2016-10-01 20:11:25 +02:00
daboe01 e0d42962e7 fixed: wrapping issue when dragging last word 2016-10-01 19:56:35 +02:00
daboe01 47688bf016 formatting 2016-10-01 18:32:19 +02:00
daboe01 39a695959d formatting 2016-10-01 18:29:47 +02:00
daboe01 71d45a67b7 fixed: dragging placeholder did not always look like dragged text 2016-10-01 18:28:44 +02:00
daboe01 8dc1369ba3 fixed: direct DOM manipulation on drag placeholder instead of using capp methods + formatting 2016-09-30 16:03:36 +02:00
daboe01 1206654d98 fixed: drag placeholder was CPTextField instead of CPTextView 2016-09-29 15:41:46 +02:00
daboe01 1492763d0c fixed: par issue in rtf parser 2016-09-28 20:55:30 +02:00
daboe01 285fafc464 rtf parser fix + formatting 2016-09-28 20:34:46 +02:00
daboe01 b15cc59b95 prettify drag placeholder 2016-09-28 19:42:59 +02:00
daboe01 55cfe31dfe fixed: selection did not work directly after aborted drag 2016-09-28 17:36:28 +02:00
daboe01 dafa6e0310 fixed: space escape was missed for rich text pasting 2016-09-28 17:31:39 +02:00
daboe01 4befe17cab fixed: target index in selection dragging was sometimes wrong 2016-09-28 17:24:39 +02:00
daboe01 2217b560cb formatting 2016-09-28 16:21:55 +02:00
daboe01 39d01a1da8 sizing correction for dragging 2016-09-28 16:15:31 +02:00
daboe01 4e14ad7821 basic support of text selection dragging 2016-09-28 15:12:26 +02:00
daboe01 aee5a2cbe4 refactor point conversion to private method _characterIndexFromEvent 2016-09-28 11:55:56 +02:00
daboe01 de2d5aec1a Merge remote-tracking branch 'cappuccino/master' 2016-09-27 19:34:06 +02:00
Martin CarlbergandGitHub bea03de562 Merge pull request #2068 from daboe01/NEW--CPTextView
New: CPTextView, CPTextStorage, CPTextContainer, CPLayoutManager and CPSimpleTypesetter + CPFontPanel + RTF parser/producer [+2]
2016-09-26 09:53:29 +02:00
Martin CarlbergandGitHub 0aeccbb02c Merge pull request #2462 from daboe01/pasteboard-type-fix
fixed: cappuccino pasteboad is always clobbered by system pasteboard
2016-09-26 09:49:41 +02:00
cacaodev 4e11152e76 nib2cib: discard warnings in the nib file. 2016-09-26 09:44:23 +02:00
Alexandre WilhelmandGitHub 5059028e8a Merge pull request #2484 from daboe01/fixed--documentation-of-autoscroll--was-missing
Fixed:  documentation of autoscroll:  was missing
2016-09-25 13:00:21 -07:00
daboe01 070e6cf848 fixed: documentation of autoscroll: was missing 2016-09-24 17:04:12 +02:00
daboe01 4187fe7261 Merge remote-tracking branch 'cappuccino/master' 2016-09-17 17:07:44 +02:00
daboe01 bdec147874 formatting 2016-09-17 16:34:39 +02:00
daboe01 189fc76dad fixed: highspeed typing issue 2016-09-16 23:59:09 +02:00
daboe01 c0a68005d4 fixed: native rich pasting was not working robustly enough in chrome 2016-09-16 23:09:54 +02:00
daboe01 8187e4cdc2 formatting 2016-09-16 19:22:13 +02:00
daboe01 cc98fd4167 fixed: keystroke duplication when shift is pressed immediately after 2016-09-16 19:21:12 +02:00
daboe01 422e014eff fixed ^a and ^e semantics 2016-09-16 18:32:14 +02:00
daboe01 dd4e044608 fixed: various tab related line height issues 2016-09-15 22:26:20 +02:00
daboe01 13fad1ca47 fixed regression: line spacing was odd when small line followed large line 2016-09-15 20:25:28 +02:00
daboe01 70aaa29016 removal of dead code 2016-09-14 22:38:50 +02:00
daboe01 7dcec9afcf fixed: infinite loop due to undo edge case 2016-09-14 22:20:33 +02:00
daboe01 608642fc25 formatting 2016-09-14 22:18:52 +02:00
cacaodevandGitHub dd62c08b09 FIXED: Fix a build error in XcodeCapp (#2480) 2016-09-09 21:03:17 +02:00
daboe01 315fc21eca fixed: setFrameSize: was iterating every character 2016-09-09 21:00:22 +02:00
daboe01 8cfd3aeda9 fixed: sizing cache was not set up correctly 2016-09-09 20:31:53 +02:00
cacaodevandGitHub 6061323c36 Test CPSegmentedControl enabled state (#2481) 2016-09-07 20:56:49 +02:00
cacaodev 17da8b04bf Remove references to CPAnimationTriggerOrderIn 2016-09-05 21:43:54 +02:00
daboe01 3a948406d5 optimisation: _indexOfObject used a method call instead of js property 2016-09-03 10:00:24 +02:00
daboe01 91c52f8ec8 Merge remote-tracking branch 'cappuccino/master' into NEW--CPTextView 2016-09-03 09:40:49 +02:00
daboe01 6076bbb554 Fixed: CPRange was not copied before altering its content 2016-09-02 19:50:57 +02:00
daboe01 f70d3359c4 removed: temporary debugging code 2016-09-01 21:46:41 +02:00
daboe01 2dbfbe36c3 fixed: lineheight and base wrap issue 2016-09-01 21:45:12 +02:00
daboe01 a25bd03566 fixed: container switch semantics 2016-09-01 20:37:35 +02:00
daboe01 109da1c2cc fixed: typsetting the paragraph geometry was not as fast as it could be 2016-09-01 20:08:34 +02:00
daboe01 9a48e25bb1 fixed: container geometry was not cached appropriately 2016-09-01 14:48:51 +02:00
daboe01 a3ade200a9 fixed: textContainers were not cached appropriately 2016-09-01 14:43:10 +02:00
daboe01 eb1901f03d fixed: comparison was not using the characterCode 2016-09-01 13:50:46 +02:00
daboe01 f8c7cdfc28 typesetter optimization: use integer constants instead of strings 2016-09-01 13:31:40 +02:00
daboe01 ea58d84b55 fixed: text sizing was slower than it should be
thanks mrcarlberg for spotting this
2016-09-01 13:25:12 +02:00
Martin CarlbergandGitHub 1360caaa81 Merge pull request #2467 from daboe01/tableview-cell-editing-fix-2-take
Fixed: tableview corruption when clicking on a cell-based control during an editing session
2016-09-01 06:08:14 +02:00
Alexandre WilhelmandGitHub 315a7b9e6a Merge pull request #2476 from daboe01/New-CGContextText
fixed: CoreGraphics does not have basic text drawing support
2016-08-30 17:43:55 -06:00
daboe01 79311d107b fixed: line fragements were searched linearly instead of using binary search 2016-08-27 22:54:09 +02:00
daboe01 77435fcbd7 fixed: void scanning for fragments during typesetting 2016-08-27 14:25:44 +02:00
Alexander Ljungberg 4395c07648 Merge branch 'fix-mobile-text-entry' 2016-08-25 13:28:29 +01:00
Martin CarlbergandGitHub f9cc77382a Merge pull request #2475 from daboe01/daboe01-readme-fix
Fixed: missing requirements for developers...
2016-08-24 16:45:19 +02:00
Martin CarlbergandGitHub e4fce08eff Merge pull request #2477 from daboe01/setTimeout-scrolling-fix
fixed: scrolling events are missed on slower maschines in chrome 52
2016-08-24 16:23:56 +02:00
Alexander Ljungberg 47196cbc55 Typos. 2016-08-19 14:57:57 +01:00
Alexander Ljungberg c0bf301434 Test: full manual test for the iOS hit test bug. 2016-08-19 14:35:44 +01:00
Alexander Ljungberg f6671f8561 Fixed: iOS virtual keyboard broke hit tests.
Without this fix, tapping on the screen while the virtual keyboard of iOS was open, and it had forced scrolling (due to the input being low on the screen), would cause incorrect mouse event locations. So you might tap on a text field below your current field to edit it and something entirely different would get selected.
2016-08-19 14:35:19 +01:00
Alexander Ljungberg 26aab2961b New: iOS Safari virtual keyboard "Done" button support.
Without this change, clicking the done button in iOS Safari would dismiss the virtual keyboard but then it would immediately come back (as we forced a refocus).

The fix is to no longer force a refocus since it turns out we don't need to anymore given another previous fix.
2016-08-19 13:07:43 +01:00
Alexander Ljungberg c233abe3a4 New: -CPEvent subtype. 2016-08-19 12:45:41 +01:00
Alexander Ljungberg beb3646bef New: test which demonstrates a hit test bug in iOS Safari. 2016-08-19 01:15:12 +01:00
Alexander Ljungberg eb8330a420 New: test which demonstrates an iOS virtual keyboard bug. 2016-08-18 23:53:25 +01:00
Alexander Ljungberg 7f3c2176f8 Fix typos. 2016-08-18 23:52:10 +01:00
Alexander Ljungberg 1d0fdd68f4 Formatting. 2016-08-18 23:51:35 +01:00
daboe01 b26c78828e make manual test more explicit 2016-08-17 21:16:16 +02:00
daboe01 85648c7f11 fixed: manual test was missing 2016-08-17 20:10:02 +02:00
daboe01 8588f446aa formatting 2016-08-17 19:17:47 +02:00
daboe01 d723c5c1c7 formatting 2016-08-17 19:16:57 +02:00
daboe01 7897f2489c fixed: setString: altered selection 2016-08-17 19:15:41 +02:00
daboe01 86e2e0a2c3 minor rewording 2016-08-17 19:06:20 +02:00
daboe01 e2349019a3 minor rewording 2016-08-17 19:05:04 +02:00
daboe01 e485044cfb remove mentioning of gcc and clang dependencies 2016-08-17 19:02:34 +02:00
daboe01 72d80e2857 fixed: scrolling events were missed on slower maschines in chrome 52 2016-08-16 20:53:49 +02:00
daboe01 79a4733698 fixed: CoreGraphics does not have basic text drawing support 2016-08-16 20:30:42 +02:00
daboe01 c64e1daa99 minor rewording 2016-08-15 21:21:53 +02:00
daboe01 d6b4933b05 Merge remote-tracking branch 'origin/daboe01-readme-fix' into daboe01-readme-fix
# Conflicts:
#	README.markdown
2016-08-15 21:20:48 +02:00
daboe01 bcf9cee0f8 more details and compiler dependencies 2016-08-15 21:20:19 +02:00
Alexander Ljungberg a2960a7997 Merge pull request #2463 from daboe01/cppasteboad-cleanup
CPPasteboad.j removal of dead code
2016-08-15 14:50:04 +01:00
daboe01andGitHub dac9874895 minor rewording 2016-08-12 17:16:52 +02:00
daboe01andGitHub a4d374ecb6 Fixed: missing requirements for developers...
... in README.markdown
2016-08-12 16:43:42 +02:00
Alexander Ljungberg 3e56c8ed8b Fixed: XcodeCapp nib2cib incorrect vs jake release.
This bug is similar to the previous one in that the effect was the same. If XcodeCapp was used to `nib2cib`, the `NSClasses` setting would be ignored.

The reason for this, apart from the previous bug, was that `nib2cib` needs to be run from the project folder in order to find the main `Info.plist` file.

The fix is to change the CWD to the project folder before building.
2016-08-10 13:23:01 +01:00
Alexander Ljungberg f4c11d14e7 Fixed: nib2cib'ed files different with jake release and jake deploy.
Without this fix, if you ran `nib2cib` on its own on your UI files you could get a different result than what `jake release` or `jake deploy` would produce. In particular the `NSClasses` setting would be ignored unless `jake release` was used.

The reason for this bug was that the main bundle was never loaded and so the `Info.plist` was not read. But when using `jake release` (and deploy) the main bundle and the `Info.plist` gets baked in so it's always automatically loaded.

The fix is to load the main bundle before checking its settings.
2016-08-10 13:22:04 +01:00
Alexander Ljungberg dde805931d New: show successfully loaded NSClasses in nib2cib verbose.
It's helpful to see which ones are loaded when troubleshooting nib2cib.
2016-08-10 13:22:04 +01:00
Alexandre WilhelmandGitHub fedc721432 Merge pull request #2439 from cacaodev/CPView-viewDidAppear
NEW: CPViewController -viewWill/DidAppear & viewWill/didDisappear
2016-08-09 23:06:10 -07:00
Alexandre WilhelmandGitHub b09cb24804 Merge pull request #2473 from enquora/capp
Move XcodeCapp 'Preferences' menuItem to standard position
2016-08-09 22:54:39 -07:00
Alexandre WilhelmandGitHub 80bfeb1a29 Merge pull request #2470 from daboe01/remove-rakefile
Fixed: obsolete file in root directory
2016-08-09 22:54:00 -07:00
David Richardson 63ad51a637 Move XcodeCapp 'Preferences' menuItem to standard position 2016-08-09 11:33:45 -06:00
daboe01 5ee6232bfc fixed: unused file in the root directory 2016-08-05 12:47:49 +02:00
daboe01 b7d399faf7 fixed: bold and italic extraction from dom for native paste 2016-08-01 09:17:05 +02:00
daboe01 28691bb8a0 improved formatting extraction from the dom in native paste operations 2016-08-01 08:50:24 +02:00
daboe01 fd61f35f78 fixed: rtf-color table was not written 2016-07-29 18:49:38 +02:00
daboe01 0505b59781 formatting 2016-07-29 17:32:48 +02:00
daboe01 a3601e5167 preparations for native rich paste 2016-07-29 17:31:40 +02:00
daboe01 99f63ab64d fixed: are double typing issue in webkit browsers 2016-07-29 16:28:17 +02:00
daboe01 bb2a9fe180 formatting 2016-07-24 17:45:26 +02:00
daboe01 e9c7c7ee4c fixed: editing state was deleted after committing a non-text-control 2016-07-24 17:43:45 +02:00
daboe01 ff7d4f237a fixed: hitTest: had side effects 2016-07-24 17:03:00 +02:00
daboe01 8bf9f8057e Merge remote-tracking branch 'cappuccino/master' 2016-07-24 16:44:00 +02:00
daboe01 27b0f531d7 fixed: more support for RTF for Pages.app 2016-07-17 15:19:40 +02:00
daboe01 01e96d3086 fixed: Pages.app rtf did not parse correctly 2016-07-17 15:00:35 +02:00
daboe01 95e7a7c8eb fixed: wrong comparison (for proper null handling) 2016-07-17 07:53:53 +02:00
daboe01 bbc2f4766e fixed: one other reference to _stateUID 2016-07-17 07:33:21 +02:00
Alexandre WilhelmandGitHub 12dde5154f Merge pull request #2461 from cacaodev/CPView-viewDidHide
FIXED: CPView received multiple -viewDidHide/Unhide messages
2016-07-11 07:46:16 -07:00
Alexandre WilhelmandGitHub 5bc3609ad7 Merge pull request #2464 from daboe01/remove-nativehost
Remove nativehost
2016-07-09 19:14:29 -07:00
daboe01 5c1cdea3c6 Removed: Obsoleted Nativehost stuff 2016-07-08 21:34:14 +02:00
daboe01 3da5b3a278 fixed: entering return blocked the nativeinputmanager 2016-07-01 18:26:01 +02:00
daboe01 9f6460ddae prevent certain race conditions in deadkey handling in FF and safari 2016-06-30 19:45:09 +02:00
daboe01 f1dcf85d7b turned off logging in RTF parser 2016-06-26 21:33:17 +02:00
daboe01 7b78edf38f fixed: removed dead code from obsoleted native pasteboard approach 2016-06-26 18:35:25 +02:00
daboe01 4a726a0c75 Merge remote-tracking branch 'cappuccino/master' 2016-06-26 18:27:33 +02:00
daboe01 5afa7e9fc3 fixed: rtf parser did not propagate paragraph style sometimes 2016-06-26 17:05:19 +02:00
daboe01 75c102f304 fixed: rtf-producer colortable dead index issue 2016-06-25 21:23:35 +02:00
daboe01 68f3c10055 fixed: only one color was supported on the pasteboard 2016-06-25 20:49:56 +02:00
daboe01 e9aeda2a34 fixed: _RTFProducer was referencing wrong colortbl entries 2016-06-25 20:09:56 +02:00
daboe01 45c7a110b6 prevent blinking during cursor navigation more robustly 2016-06-22 22:04:10 +02:00
daboe01 e438e6aedb fixed: same pasteboardtype was used for plain and rich text 2016-06-22 20:39:41 +02:00
daboe01 8dd888bcbd fixed: native pasteboard unconditionally overwrites capp-pasteboard 2016-06-21 20:56:56 +02:00
cacaodev 5f12291ac4 Fixed: add missing import 2016-06-20 19:34:00 +02:00
daboe01 e206d78a52 removed unused range parameter from _characterRangeForIndex 2016-06-19 13:51:53 +02:00
daboe01 d94a82b0a7 paragraph selection dragging fix 2016-06-19 13:45:41 +02:00
daboe01 3bee3d1701 improved: paragraph selection via triple click 2016-06-18 22:51:41 +02:00
daboe01 631352e1ef improved FF deadkey detection 2016-06-18 20:36:22 +02:00
daboe01 f2d5dee49e backspace fix 2016-06-18 19:49:11 +02:00
daboe01 2d578c7cd9 Merge remote-tracking branch 'cappuccino/master' 2016-06-18 19:18:41 +02:00
daboe01 b07ff100d1 fixed: function is missing 2016-06-18 19:18:23 +02:00
daboe01 b0c10b2248 Merge remote-tracking branch 'cappuccino/master' into NEW--CPTextView 2016-06-18 19:17:53 +02:00
daboe01 7b8249442d selection fixes 2016-06-18 17:59:26 +02:00
cacaodev 8221339318 Style 2016-06-18 13:40:27 +02:00
cacaodev b773af96b8 FIXED : css display attribute was incorrectly set 2016-06-18 13:40:14 +02:00
daboe01 dbc7808c70 code simplification 2016-06-18 11:58:42 +02:00
daboe01 77c5000f16 selection fix 2016-06-18 11:47:47 +02:00
daboe01 56928b6ca0 formatting 2016-06-18 11:46:10 +02:00
daboe01 8178dfe7bd revert: fixed: word granularity selection was not always correct 2016-06-18 11:43:50 +02:00
daboe01 0db6c667c6 fixed: word granularity selection was not always correct 2016-06-18 11:40:12 +02:00
cacaodev 2b0a642827 FIXED: CPView received multiple -viewDidHide/Unhide messages
FIXED: when a view is hidden by a hidden superview and added to a non
hidden superview, the -viewDidUnhide message is sent.

With test : CPViewTest.j
2016-06-18 11:29:47 +02:00
daboe01 f71c0f8cb8 selection fixes 2016-06-18 11:25:02 +02:00
daboe01 3782372f65 optimisations for native input manager 2016-06-17 18:31:44 +02:00
daboe01 9e35e42030 nativeinputmanager optmisations for safari 2016-06-16 20:36:12 +02:00
daboe01 7a8195e54c fixed: cursor extended selections did not copy in safari 2016-06-15 22:55:48 +02:00
daboe01 b50ee28693 fixed: the native input manager did not get the focus after recent safari update 2016-06-15 20:52:55 +02:00
Martin CarlbergandGitHub e134f910aa Merge pull request #2436 from mrcarlberg/updated_compiler
Fixed: Merged in the parser and compiler that is used in the node objj-runtime
2016-06-14 21:32:28 +02:00
daboe01 17eb6e47eb improve wordBoundaryRegex to recognize numbers 2016-06-12 13:08:10 +02:00
cacaodev 82ce626d8a Underscore prefix on private methods 2016-06-12 10:52:19 +02:00
cacaodev e063ff5e54 Remove CPAnimationTriggerOrderIn partial support. Adds a warning if someone tries to use it. 2016-06-12 10:20:26 +02:00
cacaodev 5aa98966bc Cucapp test for CPView animation
Tests for commits #1, #2, #3 of this PR
2016-06-12 10:12:08 +02:00
cacaodev fca2746a82 Fixed: custom layout and custom drawing was not animated
The bug was appearing with the following conditions:
keypath : frame , frameSize
browsers : Google Chrome, Firefox
2016-06-12 10:12:08 +02:00
cacaodev 7faffc2de7 Use cancelAnimationFrame when available 2016-06-12 10:12:07 +02:00
cacaodev 86a8a9dc85 Fixed: The animation was reverting back to its initial position.
Although the fill-mode property was correctly set to forwards allowing
the final state to persist, the animation-name property was deleted too
early . It was causing the animation to be cancelled and the initial
state restored.
2016-06-12 10:12:07 +02:00
daboe01 c13a0c1c26 fixed: selection semantics differed from macos 2016-06-11 20:53:05 +02:00
daboe01 6ce3c070b8 fixed: selection semantics differed from macos 2016-06-11 20:42:39 +02:00
daboe01 e1cb11da22 fixed: double clicking right to a word selected too much in some cases 2016-06-11 17:16:06 +02:00
daboe01 c628ea34b7 formatting 2016-06-11 17:11:55 +02:00
daboe01 33b7c726f6 fixed: whitespace double-clicking resulted in cross-paragraph selection 2016-06-11 16:40:28 +02:00
daboe01 6f3fd424e1 fixed: umlaute were treated as word bounderies 2016-06-11 16:18:18 +02:00
daboe01 b048ce9c8e formatting 2016-06-09 22:46:59 +02:00
daboe01 6a1040d659 fixed: setTextColor: issue second take 2016-06-09 22:35:50 +02:00
daboe01 fc05c28231 fixed: change in model did not propagate resize 2016-06-09 20:54:09 +02:00
daboe01 5d165bc6df Merge remote-tracking branch 'cappuccino/master' 2016-06-09 19:22:25 +02:00
daboe01 c139b5eabb Merge remote-tracking branch 'cappuccino/master' into NEW--CPTextView 2016-06-09 19:20:38 +02:00
cacaodev d6dd0e551d Revert "FIXED: CPView received multiple -viewDidHide/Unhide messages"
This reverts commit e58420b031.
2016-06-09 10:13:21 +02:00
Alexandre Wilhelm a84a7bb7c3 Merge pull request #2460 from daboe01/fixed-colorpicker-brightness-bar
Fixed: brightness_bar.png was not displayed in CPColorPicker
2016-06-09 00:59:17 -07:00
daboe01 7195ae6e46 Merge remote-tracking branch 'cappuccino/master' into NEW--CPTextView 2016-06-08 20:05:31 +02:00
daboe01 3c70b2f033 fixed: brightness_bar.png was not displayed in CPColorPicker because the size was not initialized 2016-06-08 19:54:44 +02:00
daboe01 c46340a830 Merge remote-tracking branch 'cappuccino/master' into fixed-colorpicker-brightness-bar 2016-06-08 19:45:16 +02:00
daboe01 8d703b1459 fixed: updates to storage were not propageted to the view 2016-06-08 19:23:37 +02:00
Alexandre Wilhelm f1145ef169 Merge pull request #2457 from cacaodev/CPView-viewDidHide
FIXED: CPView received multiple -viewDidHide/Unhide messages
2016-06-07 20:21:52 -07:00
Alexandre Wilhelm a28f9ceeba Merge pull request #2456 from didierkorthoudt/Fixed--right-mouse-clic-during-a-drag-operation-problem
Fixed: right mouse clic during a drag operation cancels it
2016-06-07 20:17:31 -07:00
Alexandre Wilhelm 1927bb4798 Merge pull request #2452 from didierkorthoudt/CPTextField-tracking-area-optimization
Fixed: CPTextField doesn't optimize tracking areas management
2016-06-07 12:07:11 -07:00
daboe01 d4c77f9786 fixed: Setting textColor only changes first lines color 2016-06-07 20:54:11 +02:00
daboe01 021f8d0331 revert fixed: premature optimization 2016-06-05 22:23:26 +02:00
daboe01 e7d25550ee fixed: premature optimization 2016-06-05 22:21:01 +02:00
daboe01 8227276437 fixed: tabstops were accidentally cornercutting relayout 2016-06-05 21:20:50 +02:00
daboe01 38ef76bcdc fixed: fist tabstop was not working correctly 2016-06-02 20:19:00 +02:00
daboe01 7faa0f60b4 fixed: accidental duplication of variable definition 2016-05-28 13:40:30 +02:00
daboe01 faebbb2b8a fixed: font css properties were not considered when assessing visual identity 2016-05-27 23:13:54 +02:00
daboe01 bc9beb1e87 new: render to dom only the visible stuff 2016-05-27 21:24:30 +02:00
daboe01 f161f723d7 fixed: mimetype of rtf 2016-05-27 17:39:51 +02:00
daboe01 6c94550de3 fixed: accidental creation of a global variable 2016-05-27 17:25:19 +02:00
daboe01 b39a45781a fixed: accidental creation of a global variable 2016-05-27 17:23:30 +02:00
Alexandre Wilhelm 9273c9ee10 Merge pull request #2455 from didierkorthoudt/CPColorPanel-platform-window
Fixed: CPColorPanel always opens in main platform window.
2016-05-25 11:36:28 -07:00
daboe01 e6285914b0 Merge remote-tracking branch 'cappuccino/master' into NEW--CPTextView 2016-05-24 11:29:11 +02:00
daboe01 7d2eb83a1b fixed: undo support for fontpanel 2016-05-24 10:56:19 +02:00
daboe01 7e622f1153 undo color: fallback for textcolor 2016-05-24 10:44:09 +02:00
daboe01 9b30a634b1 formatting 2016-05-24 10:42:33 +02:00
daboe01 e897d2ef81 fixed: missing undo support for textcolor 2016-05-24 10:39:23 +02:00
daboe01 f5b177dda8 fixed: passing range directly instead of copy 2016-05-24 10:24:57 +02:00
daboe01 5f51b5d565 revert: no not make copy of range 2016-05-24 10:13:08 +02:00
daboe01 8d7753fb40 formatting 2016-05-24 09:07:41 +02:00
daboe01 4c6f5744d8 fixed: setFont semantics are wrong 2016-05-24 09:07:03 +02:00
daboe01 43eb2932ba fixed: textColor only changes first lines color 2016-05-23 21:42:25 +02:00
daboe01 59de0e7a4a fixed: text sizing did not work for javascript function names 2016-05-23 17:14:13 +02:00
cacaodev 7b204cf910 Documentation for CPViewController -view*Appear methods 2016-05-23 16:06:05 +02:00
cacaodev b587a19a0f NEW: CPViewController -viewWill/DidAppear & -viewWill/DidDisappear
When a view belonging to a CPViewController is hidden, unhidden, added
or removed, its viewController receives the appropriate message.

Added AppKit/CPViewControllerTest.
2016-05-23 16:06:04 +02:00
cacaodev e58420b031 FIXED: CPView received multiple -viewDidHide/Unhide messages
FIXED: when a view is hidden by a hidden superview and added to a non
hidden superview, the -viewDidUnhide message is sent.

With test : CPViewTest.j
2016-05-23 15:39:47 +02:00
Didier Korthoudt 24313d6709 Fixed: right mouse clic during a drag operation cancels it 2016-05-22 22:14:05 +02:00
daboe01 7acb30b981 fixed: text wrapping in textviews from nibs was wrong 2016-05-22 20:33:41 +02:00
Didier Korthoudt 7454620aa2 Fixed: color panel always open in main platform window 2016-05-18 19:43:19 +02:00
Alexandre Wilhelm abb0799817 Merge pull request #2453 from daboe01/tableview-autoscroll
enable autoscrolling for tableview columns
2016-05-18 10:13:36 -07:00
Didier Korthoudt aebd28dbef CPTextField and CPTrackingArea: optimization and cursor management. 2016-05-18 11:09:06 +02:00
daboe01 152db9fb8e fixed: autoscrolling message was commented out 2016-05-17 20:37:33 +02:00
daboe01 980cd520cd fix travis failure 2016-05-15 11:58:22 +02:00
daboe01 373ec8b5a1 Merge remote-tracking branch 'cappuccino/master' into NEW--CPTextView 2016-05-15 11:57:52 +02:00
daboe01 bacb78e9e8 move background color fallbacks to +themeAttributes 2016-05-15 11:51:44 +02:00
cacaodev 333e112e37 Fixed: CPPredicateEditor predicate when the template has a CPFloatAttributeType 2016-05-15 10:06:52 +02:00
Philippe Fuentesandcacaodev 818d5d782f Fixed: date comparisons in CPPredicateEditor (#2449)
CPPredicateEditorRowTemplate has been modified to allow a correct comparision of date objects when using the CPDateAttributeType
Before this correction, the predicate format was using a string representation of a date instead of a date object.
2016-05-14 23:16:10 +02:00
daboe01 8774090086 formatting 2016-05-14 16:27:01 +02:00
daboe01 0ca65c6d61 fix travis 2016-05-14 13:10:37 +02:00
cacaodev c38daac646 Test: test for pr #2449
In CPPredicateEditor, tests that the input predicate is equal to the
output when the right control is editable.
2016-05-14 10:00:44 +02:00
cacaodev c31f5b1d59 Fixed: CPPredicateEditor in OJTest
OJTest is reading theme attributes from the class default. In
CPPredicateEditor implementation, nil check an attribute and change the
default of another attribute to be non null.
2016-05-14 09:57:29 +02:00
daboe01 2320a56a63 revert travis test 2016-05-13 20:51:25 +02:00
daboe01 07bd91b456 travis test 2016-05-13 20:34:24 +02:00
daboe01 803f7c3a4b formatting 2016-05-13 19:39:30 +02:00
cacaodev a1926982c6 Fixed: make CPObject implementsSelector: work with proxies and KVO swizzled classes 2016-05-12 21:43:44 +02:00
daboe01 b3306d50eb move selection color to the themes 2016-05-12 20:17:14 +02:00
Alexandre Wilhelm 3e6e5f95ec Merge pull request #2448 from cacaodev/CPViewController-async
Fixed: CPViewController isViewLoaded property in async mode
2016-05-11 12:20:48 -07:00
daboe01 df71fb42ac remove duplicate code 2016-05-10 22:41:08 +02:00
daboe01 fe81a354a3 formatting 2016-05-10 22:28:35 +02:00
daboe01 67ba2e49c3 workaround for FF crash in very large documents 2016-05-10 22:27:21 +02:00
daboe01 8dec42f295 fix missing font panel in manual test of CPTextView 2016-05-10 20:35:16 +02:00
daboe01 5942553370 make selection handling more mac like 2016-05-10 19:40:27 +02:00
Martin Carlbergandcacaodev ae5d31746e Dependent key paths use a relationship (#2431)
Fixed: When dependent key paths use a relationship, only the first added observer will observe the attribute for the relationship object.

Also, an optimisation on when the willChange… chain is running, there is no need to replace the observers as no new values are set yet. That will be done when the didChange… chain is running.
2016-05-09 22:14:20 +02:00
cacaodev 1c1976abbf Simple cucapp test for the CPViewController isViewLoaded property in async mode 2016-05-09 09:45:18 +02:00
cacaodev b3465ddf89 Fixed: CPViewController -isViewLoaded property was always NO in async mode (loadViewWithCompletionHandler:).
The async mode calls the completionHandler whereas the sync mode calls the -viewDidLoad method.
Both are now run within the will/did change block of the isViewLoaded property.
2016-05-08 23:09:50 +02:00
Alexandre Wilhelm f67fafdb8e Merge pull request #2446 from cacaodev/CPCollectionView-fixes
CPCollectionView content binding & minor code refactor
2016-05-08 11:16:34 -07:00
cacaodev ffcac677e0 Fixed: Manual test SmartFoldersDemo
The sheet was not closing when asked.
2016-05-07 21:14:35 +02:00
cacaodev a9d643aa55 OJTest for CPCollectionView selectionIndexes, CPCollectionViewItem isSelected, CPSelectionIndexesBinding and CPContentBinding. 2016-05-03 21:51:10 +02:00
cacaodev fa3647e8e5 Refactor selection with modern code.
Handle out of range errors when reflecting selection.
2016-05-03 21:50:41 +02:00
cacaodev db839f6d6d Rename _lockResizing to _inLiveResize
_inLiveResize is a CPView flag.
2016-05-03 21:50:20 +02:00
cacaodev 3a85d5b89f CPCollectionView content binding support 2016-05-03 21:50:20 +02:00
cacaodev 1575c2bc10 CPTableView ViewBasedCib test app: a bug in CPBox decoding was crashing the app. Remove the box until this bug is fixed. 2016-05-03 19:09:32 +02:00
cacaodev 57189183d6 Merge pull request #2444 from cacaodev/fixed-deprecated-getPropertyCSSValue
FIXED: in CPAnimationContext, 'Unknown function getPropertyCSSValue' error in chrome
2016-04-24 13:24:12 +02:00
cacaodev 01c5cf98df FIXED: Unknown function getPropertyCSSValue in Chrome
getPropertyCSSValue have been deprecated in chrome. Replacing with
getPropertyValue supported by all browsers.
2016-04-23 10:54:22 +02:00
Martin Carlberg 9ad2995168 Fixed: Some Javascript minifiers will convert ”\u2028” to a string with the actual line separator inside. It is not valid Javascript to have the actual character inside a string literal.
Instead of fixing bugs in different minifiers it is easier to rewrite this small function. The same applies to \u2029
2016-04-07 10:32:47 +02:00
Martin Carlberg 51fc6518e1 Fixed: Removed some trailing white spaces 2016-04-07 10:32:46 +02:00
Martin Carlberg 530db4e904 Fixed: Merged in the same parser and compiler that is used in the objj-runtime that is running on node.
The life will be easier to have the same in both environments.
Warnings and errors now don’t use read only properties for line and column information. So the test cases in Toolstest.j now work in modern JS engines.
It is also easier to set options for the compiler.
2016-04-07 10:32:46 +02:00
Alexandre Wilhelm cd92ebd69c Merge pull request #2437 from mrcarlberg/cpobjectcontroller_set_entity_name_from_code
Fixed: Setting entity name from code does not work
2016-04-06 18:15:23 -07:00
Alexandre Wilhelm 5c58552d91 Merge pull request #2438 from mrcarlberg/cppopupbutton_binding_select_is_done_before_content
Fixed: First popup item is always selected if selected binding value is set before content binding value
2016-04-06 18:14:53 -07:00
Antoine Mercadal 584aebf76b FIXED: used the master of cappuccino-base 2016-04-06 09:55:38 -07:00
Antoine Mercadal 43a2480699 Merge pull request #2430 from herbatnik/master
FIXED: Cursor key binding methods do not fire in IE11 #2365
2016-04-06 08:35:14 -07:00
Martin Carlberg 699503042f Fixed: First item is always selected if selected binding value is set before content binding value.
Test case is provided.
2016-04-05 23:22:29 +02:00
Martin Carlberg 02e71c23de Merge branch 'master' of https://github.com/cappuccino/cappuccino 2016-04-05 23:12:07 +02:00
Martin Carlberg c24c3868bb Merge pull request #2434 from Dogild/TrackingAreaTableViewHeader
Fixed: crash when having a CPTableViewHeader without a CPTableView
2016-04-05 19:49:27 +02:00
Martin Carlberg 5c60819668 Merge pull request #2432 from Dogild/CacheURLRequest
Fixed: cache control was not set properly in CPURLRequest
2016-04-05 19:05:59 +02:00
Martin Carlberg 480a125a20 Fixed: When setting entity name from code the _managedProxy will be null and the name will not be stored 2016-04-05 18:43:32 +02:00
Antoine Mercadal 598a6ebaed Merge pull request #2278 from cacaodev/CPAnimationContext
Animations: CPAnimationContext & animator
2016-04-04 09:57:55 -07:00
Alexandre Wilhelm 185ad5e747 Fixed: crash when having a CPTableViewHeader without a CPTableView
Previously, when having a CPTableViewHeader without a CPTableView, cappuccino just crashed.
We now check if _tableView is set before iterating on the tableview's columns.
2016-04-04 06:48:26 -07:00
Alexander Ljungberg 42d7e4312b Formatting of CPCache. 2016-04-02 01:20:23 +01:00
Alexander Ljungberg 41a741724f New: Sweden / Swedish as a possible locale. 2016-04-01 23:47:13 +01:00
Alexander Ljungberg 087e811586 Bump XcodeCapp copyright year. 2016-04-01 22:44:23 +01:00
Alexander Ljungberg fa07bc143e Fixed: missed some version number bumps in the 0.9.9 release. 2016-04-01 22:25:21 +01:00
Alexander Ljungberg e13f5ed730 Fixed: CPNumber intValue did not return an integer.
We expect this method to return a whole number like in Objective-C. This also goes for the related methods, `shortValue`, `longValue` and `longLongValue`.

Also adds more tests (in addition to the existing, already failing test).
2016-04-01 22:22:03 +01:00
Alexander Ljungberg 48108cebc9 Merge branch '0.9.9' 2016-04-01 01:05:40 +02:00
Alexander Ljungberg ecac17a00a This will be Cappuccino 0.9.9. 2016-03-29 23:32:12 +01:00
Alexandre Wilhelm 3ba215887c Merge pull request #2426 from mrcarlberg/source_url_fix
Fixed: //@ sourceURL=... is deprecated since many years ago.
2016-03-28 23:43:45 -07:00
Alexandre Wilhelm edbc1baf32 Merge pull request #2427 from cacaodev/cpbutton-image-scaling
NEW: nib2cib support for CPButton -imageScaling.
2016-03-28 23:43:22 -07:00
Alexandre Wilhelm 500fa7f314 Fixed: cache control was not set properly in CPURLRequest 2016-03-28 23:32:48 -07:00
Alexandre Wilhelm a10dfa4ab4 Merge pull request #2429 from mrcarlberg/integer_value
Fixed: Added ’integerValue’ method for CPNumber and CPString.
2016-03-27 09:20:12 -07:00
Martin Carlberg b208571ed7 Fixed: Formatting 2016-03-23 10:17:15 +01:00
Martin Carlberg c1ec27045c Fixed: Rhino does not support numbers starting with ’0’ 2016-03-23 09:35:19 +01:00
Martin Carlberg 111b12161c Added: test cases for ’intValue’ and ’integerValue’ methods on CPString and CPNumber 2016-03-23 09:02:09 +01:00
daboe01 d23d18933c altgr fix for recent FF 2016-03-22 20:39:28 +01:00
Marek Kresnicki f0e736962d FIXED: Cursor key binding methods do not fire in IE11 #2365 2016-03-21 11:23:51 +00:00
Alexandre Wilhelm b12d1491d4 Merge pull request #2415 from cacaodev/CPViewController-loadviewAsynchronously
NEW: CPViewController -loadViewAsynchronously:(Function/*view, error*/)
2016-03-20 19:40:20 -07:00
Alexandre Wilhelm 6d1a094b15 Merge pull request #2428 from cacaodev/CPSearchField-indentationLevel
CPSearchField: use CPMenuItem -setIndentationLevel:
2016-03-20 19:35:48 -07:00
daboe01 88d14792a4 do not select all on setString 2016-03-20 20:29:16 +01:00
Martin Carlberg 7780a98abe Fixed: Added ’integerValue’ method for CPNumber and CPString.
This makes the classes more compliant to Cocoa
2016-03-15 22:25:10 +01:00
cacaodev a1248db3e7 CPSearchField: use CPMenuItem -setIndentationLevel: now that it's available. 2016-03-13 16:09:27 +01:00
cacaodev 6fd2d12d3f Merge remote-tracking branch 'cappuccino/master' into CPAnimationContext 2016-03-12 23:29:46 +01:00
cacaodev 9fab52c044 NEW: nib2cib support for CPButton -imageScaling. With manual test CPButtonTest. Fixes #2425. 2016-03-12 22:18:46 +01:00
daboe01 a32f55d64e add fontpanel to manual test 2016-03-09 19:55:50 +01:00
Aparajita Fishman 96d2b001ea Merge branch 'tableview-edit-fix' 2016-03-08 15:04:55 -08:00
Martin Carlberg e38d6c9f9e Fixed: //@ sourceURL=... is deprecated since many years ago.
We have not changed it for support of older browsers.
Chrome version 51 and above writes a warning about it
in the console so it is time now.
2016-03-07 13:44:29 +01:00
Alexandre Wilhelm be129d243b Fixed: refactoring of CPTextView 2016-03-06 21:48:42 -08:00
Alexandre Wilhelm c85355986b Fixed: manual merged with master 2016-03-06 18:47:58 -08:00
Alexandre Wilhelm 310c0e8379 Merge pull request #2423 from mrcarlberg/cpobject_controller_extension
Allow CPObjectController to get more attributes from the xib/cib file.
2016-03-06 18:20:51 -08:00
Martin Carlberg f0dbffe4f8 Fixed: Formatting 2016-03-06 11:14:22 +01:00
Alexandre Wilhelm 598a482538 New: added gitter badge in the README 2016-03-05 13:38:23 -08:00
Alexandre Wilhelm a995f3ab52 Merge pull request #2424 from mrcarlberg/invalid_plist_fix
Does not throw exception if plist is not valid. It will return nil instead
2016-03-05 13:32:15 -08:00
Martin Carlberg ec5454de44 Merge branch 'cpobject_controller_extension' 2016-03-03 15:09:10 +01:00
Martin Carlberg ec55bddbd4 Fixed: Does not throw exception if plist is not valid. It will return nil instead. 2016-03-01 21:45:08 +01:00
Martin Carlberg 808591df56 Fixed: Allow CPObjectController to get more attributes from the xib/cib file. 2016-03-01 21:40:00 +01:00
Alexandre Wilhelm 96ae3da1e0 Merge pull request #2412 from cacaodev/CPArray-arrayByApplyingBlock-replace
Replace loops with the new -arrayByApplyingBlock: method
2016-02-18 20:25:24 -08:00
Alexandre Wilhelm 4f13df69c7 Merge pull request #2419 from Dogild/cappuccino-test-launched
Test: some manual tests were broken
2016-02-18 20:24:36 -08:00
Alexandre Wilhelm 6d305e4a84 Test: some manual tests were broken
This PR fixes the manual tests. We can no launch every manual tests of Cappuccino...
2016-02-13 11:36:42 -08:00
cacaodev d3dab982a1 Remove ignored argument _ in CPColorPanel 2016-02-07 11:54:16 +01:00
cacaodev 2f6adbae3c Documentation for -loadViewWithCompletionHandler:
Also clarified a note in -loadView doc.
2016-02-07 11:19:26 +01:00
cacaodev ccdc1eed5a Rename to loadViewWithCompletionHandler: 2016-02-07 11:17:53 +01:00
cacaodev 65dee154f7 Remove ignored argument _ 2016-02-06 20:39:49 +01:00
Alexandre Wilhelm 662db009de Merge pull request #2418 from mrcarlberg/build_with_space_in_path
Fixed: Allow build in directory with space in path
2016-02-05 12:05:35 -06:00
cacaodev d07d8f6857 _CPBlockExpression: replace loops with arrayByApplyingBlock: method 2016-02-04 21:51:37 +01:00
cacaodev 0327f6b1ea Merge remote-tracking branch 'cappuccino/master' into CPArray-arrayByApplyingBlock-replace 2016-02-04 21:46:10 +01:00
Martin Carlberg 16dea2ee09 Fixed: Allow build in directory with space in path 2016-02-03 17:26:24 +01:00
Alexandre Wilhelm 5e3fe139fc Fixed: @cappuccino is now a link in the README... 2016-02-02 13:05:46 -08:00
Alexandre Wilhelm 55d41fca05 New: added twitter account in the READMA 2016-02-02 13:05:01 -08:00
daboe01 0b7bb29557 setString selection fix 2016-01-26 19:16:12 +01:00
cacaodev 6b683bd02d Merge pull request #2402 from cacaodev/CPExpression-constructors
NEW : CPExpression +expressionForBlock:arguments:
                                   +expressionForConditional:trueExpression:falseExpression:
2016-01-25 10:22:18 +01:00
daboe01 8f1a498953 added credits to andrew 2016-01-24 15:33:21 +01:00
daboe01 293ed9065d fix chrome duplicate key inserts cursor 2016-01-24 15:24:12 +01:00
Aparajita Fishman 8908fb7ee0 Merge pull request #2414 from didierkorthoudt/CPTrackingArea-fixes2
FIXED: CPTrackingArea incorrect handling of view hierarchy updates while processing events
2016-01-23 07:02:03 -08:00
Didier Korthoudt 2877178b34 Formatting: following Aparajita's recommandations 2016-01-21 20:46:37 +01:00
Antoine Mercadal d527139f48 Merge pull request #2416 from didierkorthoudt/CPBox-contentView-incorrect-initWithCoder
FIXED: CPBox contentView incorrect initWithCoder
2016-01-20 15:11:37 -08:00
Didier Korthoudt b3d8180541 FORMATTING: added comment to workaround 2016-01-21 00:10:38 +01:00
Didier Korthoudt 3411c340ab FIXED: incorrect view hierarchy update 2016-01-20 23:50:22 +01:00
Didier Korthoudt 4482089712 FIXED: corrected replaceSubview parameters order 2016-01-20 22:08:10 +01:00
Didier Korthoudt c8ce2343d7 Merge remote-tracking branch 'cappuccino/master' 2016-01-20 21:43:35 +01:00
cacaodev d547d04277 NEW: CPViewController -loadViewAsynchronously:(Function/*view, error*/)
with manual test CPViewControllerTest
2016-01-20 11:54:02 +01:00
Aparajita Fishman 8f1191733b Fixed race condition when editing table cells
Previously, when double-clicking on a table cell to edit it, there was a possibility of a race condition. A refresh of the display was requested, then the run loop was passed through once. But it was possible for the display refresh to not be queued when the run loop was passed through, in which case the refresh would cancel the editing. Or at least I think that's what was happening.  ;-)

This commit (hopefully) eliminates the race condition by synchronously refreshing the layout and display.

Made some miscellaneous formatting fixes as well.
2016-01-19 23:12:11 -08:00
Antoine Mercadal 00bdbcf857 FIXED: only set a content view of CPBox if it is not a separator 2016-01-19 16:10:31 -08:00
Antoine Mercadal bf8070c42d Revert "FIXED: Bug introduced by https://github.com/cappuccino/cappuccino/commit/9fba72cbab42145dc585c01efd82ce645373c04e#diff-227ef108401c2160357ae3fc65018c65R620"
This reverts commit ad48381744.
2016-01-19 16:08:59 -08:00
Antoine Mercadal 346a0b84ae Merge branch 'master' of https://github.com/cappuccino/cappuccino 2016-01-19 13:28:17 -08:00
Antoine Mercadal ad48381744 FIXED: Bug introduced by https://github.com/cappuccino/cappuccino/commit/9fba72cbab42145dc585c01efd82ce645373c04e#diff-227ef108401c2160357ae3fc65018c65R620
The changes in CPBox were messing with the subviews encoding. This patch restores the previous behavior of CPBox.
The original bug might be reintroduced, but this was definitly not the good solution
2016-01-19 13:26:10 -08:00
Didier Korthoudt 0f30d7744d FIXED: CPTrackingArea incorrect handling of view hierarchy updates while processing events 2016-01-19 07:07:45 +01:00
cacaodev 095a978120 Replace loops with arrayByApplyingBlock: 2016-01-17 20:54:43 +01:00
cacaodev 1b72646772 Style: remove tabs 2016-01-17 20:54:20 +01:00
Didier Korthoudt a7b129147f Merge remote-tracking branch 'cappuccino/master' 2016-01-17 12:32:31 +01:00
cacaodev 6496a6643f Merge remote-tracking branch 'upstream/master' 2016-01-16 22:06:42 +01:00
cacaodev e172217427 Merge pull request #2404 from cacaodev/CPArray-mapUsingBlock
New: CPArray -arrayByApplyingBlock:
2016-01-16 19:25:07 +01:00
cacaodev 8c67eee4c8 (CPArray)arrayByApplyingBlock: documentation 2016-01-16 18:28:04 +01:00
Didier Korthoudt ca9039b8d5 Merge remote-tracking branch 'cappuccino/master' 2016-01-16 18:22:20 +01:00
Antoine Mercadal e260632a45 Merge pull request #2408 from slevenbits/xcodecapp-settings-tweaks
Fix some typos/grammar in XcodeCapp settings, plus improve layout.
2016-01-14 16:03:52 -08:00
Antoine Mercadal 678f4fca8a Merge pull request #2409 from primalmotion/predicate-fix
FIXED: CPPredicate's predicateFormat with a CPNull value as right exp…
2016-01-14 15:54:56 -08:00
Antoine Mercadal 5d88d07edc FIXED: CPPredicate's predicateFormat with a CPNull value as right expression wasn't working
Previously a CPPredicate created with format `value == nil` was converted back to `value == <CPNull @ xxxx>`

This patch ensures `predicateFormat` returns `value == nil`

Test added in CPPredicateTest.j
2016-01-14 15:50:24 -08:00
cacaodev 08aa591c65 NEW CPArray -arrayByApplyingBlock:(Function/*element, index*/)aBlock
Test for CPArray -arrayByApplyingBlock:
2016-01-14 21:57:57 +01:00
Alexander Ljungberg f2a8edb29f Fixed: some uneven margins and spacing in XcodeCapp settings.
The horizontal margin was larger than the vertical margin, and larger than the margin guideline for Cocoa.

Also one of the hint text lines was much closer to its textbox than the other two, and not well aligned within its textfield (should be right aligned).
2016-01-14 11:40:09 +00:00
Alexander Ljungberg 50d7e8dc3d Fixed: some typos/grammar in XcodeCapp settings. 2016-01-14 11:40:09 +00:00
Alexander Ljungberg 8403e36d4d New: arrange the kitchen sink test windows a little.
It just looks better.
2016-01-14 11:28:58 +00:00
Alexander Ljungberg 2dda326cc4 Fixed: radio button cropped in Theme Kitchen Sink test.
Without this fix the radio group was too short for Aristo 2 and as a result the bottom radio button had its bottom pixels cut off.
2016-01-14 11:20:31 +00:00
Antoine Mercadal 9002a8db04 Merge pull request #2407 from t00f/fix_2406_splitview
Test: Added a test that verifies CPSplitView behavior
2016-01-12 09:31:40 -08:00
Christophe Serafin 5ec5198dda Test: Added a test that verifies CPSplitView divider behavior when having only 1 subview.
Issue#2406 reported a behavior different from Cocoa Framework. This test validates that Cappuccino CPSplitView is working well when adding
and removing a subview. A CPSplitView that has only one subview should resize it to take the whole space available.

This PR adds a new test to Tests/Manual
2016-01-12 16:29:24 +01:00
Antoine Mercadal 0326b7d7ac Merge pull request #2405 from Dogild/CPBoxNib2CibFixed
Fixed: nib2cib on a NSBox fails when having a CPTableView in it
2016-01-05 13:08:04 -08:00
Aparajita Fishman 2f5e7f3b2d Allow custom formatters in xibs
Previously, adding a "Custom Formatter" (direct subclass of NSFormatter) to a cell in Xcode would cause a failure in nib2cib, because it didn't know how to deal with it.

This commit adds support for custom formatters in nib2cib (and thus in xibs), and updates the CPFormatter test app to demonstrate that this works.
2016-01-03 15:26:06 -08:00
daboe01 0e17658269 use fraction again in cursorUp 2015-12-31 10:42:33 +01:00
daboe01 87edda5972 more cursor up fixes 2015-12-30 21:16:02 +01:00
daboe01 ab8c3c2b75 granular selection refac 2015-12-30 17:35:14 +01:00
daboe01 44cef002ed make selection upon doubleclick more mac like 2015-12-30 15:41:36 +01:00
daboe01 bc80fe693a formatting 2015-12-30 14:49:06 +01:00
daboe01 1898b51dc2 fix for cursor up issue in multiple newlines 2015-12-30 14:39:41 +01:00
daboe01 a5dcf5958e updated credits section 2015-12-30 11:28:07 +01:00
Alexandre Wilhelm 9fba72cbab Fixed: nib2cib on a NSBox fails when having a CPTableView in it
Previously, when having a CPTableView in a CPBox, nib2cib failed due to a superview not defined yet. This was raised because in nib2cib we used the method setFrame on the CPBox to modify the frame of the CPBox (we need to modify this frame because the sizing difference between cappuccino and cocoa). We now directly modify the attribute _frame from the object and update the bounds in the same time.

This PR fixed another bug as well. Previously the contentView of the CPBox was not encoded, we now encode it. This allows us to get a full CPView object for the contentView, previously we got a weird (I have no idea how this object was created though...) object CPView with some missing attributes. This raised a crash because _trackingAreas or _themeState were not defined in this object.

Fixed #2400
2015-12-28 17:58:10 -08:00
cacaodev 912fdeaf09 Merge pull request #2403 from cacaodev/cptabviewitem-test
TEST: CPTabViewBindings manual test
Adds a test for tab view item label change.
2015-12-28 16:37:52 +01:00
cacaodev 36c417458d STYLE: replaced expression methods with accessors
Also added methods and documentation for the new methods:
-trueExpression, -falseExpression and -expressionBlock.
Completed documentation for -predicate and -arguments.
2015-12-27 22:08:30 +01:00
cacaodev f1591e593a Coding style 2015-12-27 22:03:35 +01:00
cacaodev 117ac0f5d6 FIXED: replace js Array.map function with capp API
Also fixed BlockExpression description to match a little more with
cocoa impl.
2015-12-27 19:31:05 +01:00
cacaodev e72a42fd2d FIXED: block & conditional expressions: support for CPPredicate -predicateWithSubstitutionVariables: 2015-12-27 19:28:03 +01:00
cacaodev e6e2f4c22c TEST: CPTabViewBindings manual test
Add test for pr #1921 *Label size not calculated when they change*

closes #1921
2015-12-27 18:19:48 +01:00
cacaodev 07b6e2b9f1 CPExpression +expressionForConditional:trueExpression:falseExpression:
Conditional Expression : an expression using different expressions for
evaluation, depending of a predicate result.

Support for predicate parsing: ```TERNARY(predicate, trueExpression,
falseExpression)```

With init, equal, evaluation, parsing tests.
2015-12-27 15:45:03 +01:00
cacaodev 5ab10f4024 NEW: CPExpression +expressionForBlock:arguments:
An expression that returns the result of evaluating a block.

With tests.
2015-12-27 15:44:36 +01:00
cacaodev 0ac08456bc Merge pull request #2401 from cacaodev/CPSubqueryExpression
FIXED: Subquery expressions were ignoring evaluation context
2015-12-26 00:12:13 +01:00
cacaodev 80a3549ef5 FIXED: Subquery expressions were ignoring evaluation context
When the predicate part of a subquery expression was containing
variables, the substitution was ignored.
Now, the subpredicate can contain variables that will be substituted
when calling evaluateWithObject:substitutionVariables:.

Added expression test and predicate parsing test.
2015-12-23 18:49:07 +01:00
Alexandre Wilhelm 770d5eb257 Fixed: nib2cib is broken due to the new feature CPTrackingArea. The array _trackingAres is not initialize when creating NS* object 2015-12-22 11:10:31 -08:00
Didier Korthoudt b32499f6ec Merge remote-tracking branch 'cappuccino/master' 2015-12-22 18:07:02 +01:00
Didier Korthoudt d9819d8b3d Merge remote-tracking branch 'cappuccino/master' 2015-12-22 08:03:54 +01:00
Aparajita Fishman 932b825818 Merge pull request #2395 from didierkorthoudt/CPTrackingArea
Implementation of CPTrackingArea
2015-12-21 15:23:51 -08:00
daboe01 a0cbc5822e speedup for chrome 2015-12-21 20:17:51 +01:00
Didier Korthoudt 2ab50c6b61 code style fixed 2015-12-20 09:29:54 +01:00
Didier Korthoudt d7426f6d35 Several fixes 2015-12-19 21:56:27 +01:00
Didier Korthoudt 8f15266f0a delayed cursorUpdates modification 2015-12-17 21:48:27 +01:00
Didier Korthoudt 936c7190c7 manual test update 2015-12-16 22:16:31 +01:00
Didier Korthoudt 3452984b8e 2 cases added 2015-12-16 19:29:14 +01:00
Didier Korthoudt 3e17890528 cursor tests in CPViewTest 2015-12-15 23:33:10 +01:00
Didier Korthoudt 2a7c50d356 events-during-drag-fix 2015-12-15 15:09:19 +01:00
Didier Korthoudt 05bca368c2 several-fixes 2015-12-10 18:29:34 +01:00
Didier Korthoudt 89c78f6030 unit-test-additions 2015-12-09 21:38:50 +01:00
Alexandre Wilhelm b59b0259ca Fixed: CPDateFormatter did not work with symbols MM and LL with the month of december 2015-12-09 10:51:51 -08:00
Didier Korthoudt e46e1b20de unit-test-v2 2015-12-08 23:09:20 +01:00
Didier Korthoudt 7089abcef2 missing-fix 2015-12-08 22:41:18 +01:00
Didier Korthoudt e6148a97a3 _CPWindowView-fix 2015-12-08 18:33:27 +01:00
Didier Korthoudt 9e40033a92 skipped-fix 2015-12-07 15:13:31 +01:00
Didier Korthoudt 08d4e19851 various-fixes
Following @aparajita indications
2015-12-07 14:58:42 +01:00
Didier Korthoudt dcc0768411 Unit-test+fix 2015-12-05 20:14:24 +01:00
Didier Korthoudt f14062c721 Style-fixes 2015-12-03 20:44:34 +01:00
Alexandre Wilhelm 0508b70658 Refactored: refactoring of the file CFHTTPRequest.js 2015-12-02 11:32:04 -08:00
Alexandre Wilhelm 04f8545397 Merge pull request #2368 from Rosch/master
Fix startup on IE10
2015-12-02 11:25:59 -08:00
cacaodev 633f985360 CFHTTPRequest : removed unused variable. 2015-12-02 17:51:49 +01:00
Didier Korthoudt a649a6ebac CIB-fix
For some (yet unknown) reason, when declaring a view with tracking area
in a CIB, there’s some weird things happening that try to use the
_trackingAreas array when it’s not yet initialized… So, replacing
_trackingAreas.length by [_trackingAreas count] resolves the problem.
2015-12-02 00:03:59 +01:00
Didier Korthoudt 634a8b4532 cocoadev-fix 2015-12-01 21:16:02 +01:00
Didier Korthoudt f3709a41e3 removeAllTrackingAreas 2015-12-01 21:06:55 +01:00
Didier Korthoudt 2bfebfee3c Manual-test-fix 2015-12-01 05:58:36 +01:00
Didier Korthoudt 76ab5fbf78 CPControl-fix 2015-11-30 09:07:33 +01:00
Didier Korthoudt c0b0c74638 CPTableHeaderView-fix 2015-11-30 05:49:11 +01:00
Didier Korthoudt 6c0b771758 CPSplitView-fix 2015-11-29 21:54:36 +01:00
Didier Korthoudt 2f983fc305 optimization 2015-11-29 15:37:33 +01:00
Antoine Mercadal 3cf0d60f5d Merge pull request #2399 from mrcarlberg/default_include_method_types
Default include type signatures for all kind of builds
2015-11-23 13:38:14 -08:00
Alexandre Wilhelm 751e76b453 Merge pull request #2396 from mrcarlberg/objj_runtime_method_type_accessors
Objective-J runtime method type accessor functions
2015-11-23 10:40:44 -08:00
Martin Carlberg c2f95f7953 Fixed: Runtime method argument functions will now comply to how Objective-C runtime works. 2015-11-23 10:48:15 +01:00
Didier Korthoudt 924b994df2 First updateTrackingAreas implementation 2015-11-21 17:25:43 +01:00
Didier Korthoudt b10de5e82c Code-refactoring 2015-11-21 09:20:28 +01:00
daboe01 65ffce8db2 sheet fix part 2 2015-11-20 20:45:21 +01:00
Martin Carlberg 58aeb2e40f Fixed: Add test cases 2015-11-20 14:54:23 +01:00
Martin Carlberg 141d737ca5 Fixed: Removed old function instead of mark it deprecated 2015-11-20 14:54:11 +01:00
Martin Carlberg d0fd53a2ca Added: Function method_getNumberOfArguments 2015-11-20 14:53:46 +01:00
Martin Carlberg 3e0a6ea2cf Fixed: Return NULL when out of bounce 2015-11-20 14:52:53 +01:00
Martin Carlberg 758ad3eb06 Fixed: Method types was not copied into new KVO implementation of a class that is observed with KVO.
Some test cases are also added for this.
2015-11-20 12:43:53 +01:00
Martin Carlberg b132a66707 Fixed: Compiler option 'IncludeTypeSignatures' is default turn on for all type of builds. It can optionally be turned off. 2015-11-20 12:33:00 +01:00
daboe01 f241f12ddb fix for textview on sheets 2015-11-19 20:03:36 +01:00
Didier Korthoudt e1daf9467c Code-style-fixes 2015-11-19 06:13:18 +01:00
Alexandre Wilhelm 5457ddb44f Fixed: ignored compiled nib file of xcodecapp when having xcodecapp folder in a XcodeCapp project 2015-11-18 13:09:39 -08:00
Alexandre Wilhelm 6fee13b0a5 Fixed: XcodeCapp did not ignore folder when sourcing them 2015-11-18 11:29:09 -08:00
Alexandre Wilhelm 2b17e173f5 Fixed: only reload the operations and errors dataview when they are currently displayed in XcodeCapp 2015-11-18 11:01:09 -08:00
cacaodev 569d4a5d8b Merge branch 'master' of git://github.com/cappuccino/cappuccino 2015-11-15 19:34:39 +01:00
Alexandre Wilhelm 51a88a23ac Fixed: removed files Lumberjack 2015-11-13 10:48:48 -08:00
Alexandre Wilhelm f41504ca57 Fixed: remove library CocoaLumberjack in XcodeCapp. This lib added memory leaks when using it in an NSOperation. We now simply use NSLog 2015-11-13 10:48:02 -08:00
Alexandre Wilhelm bacb7018cb Fixed: thread of the spinning was always launched even if the spinner was not displayed in XcodeCapp 2015-11-12 16:29:46 -08:00
Alexandre Wilhelm 671ed3c2fe Fixed: memory leak in XcodeCapp due to NSAppleScript. We now use osascript 2015-11-12 11:59:00 -08:00
Alexandre Wilhelm 372e994617 Fixed: XcodeCapp ignored by defaul the ressources folder 2015-11-11 13:24:18 -08:00
Martin Carlberg e4560df62f Fixed: Use correct property in decorator 2015-11-10 11:31:04 +01:00
Martin Carlberg 920daf7fde Fixed: Marked function 'method_getTypes' as deprecated 2015-11-10 11:30:29 +01:00
Martin Carlberg ad1a15faaa New: Added runtime functions 'method_copyReturnType' and 'method_copyArgumentType'. 2015-11-10 11:29:52 +01:00
Didier Korthoudt 459cf2e380 Tests/Manual TrackingArea test app 2015-11-08 19:46:19 +01:00
Didier Korthoudt 8d058a53fd CursorUpdate management + various fixes 2015-11-08 12:06:13 +01:00
Didier Korthoudt d864ae9fef Code style 2015-11-07 07:07:14 +01:00
Didier Korthoudt f1eeb61264 Fix: log traces removal 2015-11-06 15:05:34 +01:00
Didier Korthoudt 1418dd8b29 First submit for CPTrackingArea 2015-11-06 14:09:23 +01:00
cacaodev 0297980ca3 Merge branch 'master' of git://github.com/cappuccino/cappuccino 2015-11-02 19:46:36 +01:00
cacaodev 5e94aaa2cb Merge pull request #2391 from zittix/fix_initial_cptabview_selection
Fixed: default selection of a CPTabView item
2015-11-02 09:25:04 +01:00
Martin Carlberg b929a8fe2e Merge pull request #2389 from mrcarlberg/faster_theme_attribute
Faster theme attribute handling
2015-11-01 20:42:13 +01:00
Martin Carlberg 8c2f0bacf1 Merge pull request #2384 from mrcarlberg/even_faster_objj_msg_send
Speedup of the Cappuccino framework by more efficient objj_msgSend
2015-11-01 20:39:18 +01:00
Alexandre Wilhelm 0bc02de012 Fixed: method loadCibNamed:(CPString)aName owner:(id)anOwner is broken
Previously, the method CPBundle loadCibNamed:(CPString)aName owner:(id)anOwner was broken, it loaded the cib asynchronous instead of synchronous. This was due to bad refactoring of a previous commit refs#c5b250236fa662e3da04e442f4414f95d64d9308

This PR refactor this piece of code and make works the method synchronous as it should.

More information here : https://github.com/cappuccino/cappuccino/commit/c5b250236fa662e3da04e442f4414f95d64d9308#commitcomment-14109453
2015-11-01 08:57:06 -08:00
Alexandre Wilhelm 411a282063 Test: fixed manual test SmartFoldersDemo 2015-11-01 08:56:49 -08:00
Alexandre Wilhelm 6c4d55622b Fixed: travis was broken because variable named char 2015-10-31 18:09:53 -07:00
Alexandre Wilhelm e214bf3581 Refactoring: refacroting of the method charPositionOfString:(CPString)aString withFont:(CPFont)aFont forPoint:(CGPoint)aPoint refs#78e29d2bbfe43f5a8bda2e65d974f7effb8fcbd4 2015-10-31 14:50:41 -07:00
Alexandre Wilhelm 78e29d2bbf Fixed: position of cursor in a CPTextField was wrong when becoming firstResponder
Previously, when a CPTextField became firstResponder, the cursor was always set at the first position. Now it position it at the expected location.
2015-10-31 12:31:49 -07:00
Mathieu Monneyandcacaodev a93c10b794 Fixed: default selection of a CPTabView
The selected tab item view is now loaded correctly after awakeFromCib, which wasn't the case before.
2015-10-30 15:27:34 +01:00
Martin Carlberg 3240d6f11a Fixed: Added TODO comments that deprecated use should be remove in future release 2015-10-30 11:20:51 +01:00
Antoine Mercadal d5f38fe2f2 Merge pull request #2392 from Dogild/RunLoopBlock
New: added the method performBlock in CPRunLoop
2015-10-27 17:36:22 -07:00
Alexandre Wilhelm d4b1680727 Fixed: new CPPLatformWindow did not have a platformPasteboard. copy and paste did not work for other platformWindow except the main one 2015-10-27 12:08:10 -07:00
Alexandre Wilhelm b04e5760fb Test: added unittest for method stringByReplacingCharactersInRange of CPString 2015-10-27 12:06:47 -07:00
Martin Carlberg 42c629ca45 Fixed: Use ’;’ instead of ’,’ 2015-10-27 09:03:55 +01:00
Martin Carlberg 68f45beb20 Fixed: Code formatting 2015-10-27 09:03:26 +01:00
Mathieu MonneyandMathieu Monney ea95897bbd Fixed: default selection of a CPTabView
The selected tab item view is now loaded correctly after awakeFromCib, which wasn't the case before.
2015-10-27 08:09:17 +01:00
Alexandre Wilhelm 4d1dc0c949 New: added the method performBlock in CPRunLoop
Previously, we could only give a selector and a target for perform in the runLoop. Now we can give a block.
This feature is used in the CPTextField class. Previously, when we wanted to call a function at the end of the stack we used window.setTimeout, however due to HTML5 specifications this wasn't called just at the end of the stack but at least 4ms (more information here https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout#Minimum_delay_and_timeout_nesting). Now we give a block to perform, and this block will be performed in the next runloop.

Unittest has been added in Tests/Foundation/CPRunLoopTest.j
2015-10-26 15:36:13 -07:00
Martin Carlberg 9fc892f723 Fixed: Check if ’OBJJ_COMPILER_FLAGS’ exists in a correct way 2015-10-26 14:47:51 +01:00
Martin Carlberg 5541381afe Fixed: Only have one ’release’ option for Jake.
Removed the ’release-inline’ option when building as it is not practical to have two different options. The release build now always has inlined msgSend functions. If a release build is needed without inlined msgSend functions an edit of the ”-O2” option to ”-O” in the Jakefile is needed.
2015-10-26 09:53:39 +01:00
Martin Carlberg ed12bae6aa Fixed: Removed unused global variable 2015-10-23 16:38:12 +02:00
Martin Carlberg 1520c1ebab Fixed: Linting 2015-10-23 15:40:45 +02:00
Martin Carlberg 790190e5c3 Fixed: Removed code collecting statistic of theme attribute creation and some logging 2015-10-23 10:39:52 +02:00
Martin Carlberg 24889f7dcd Fixed: Adjust test cases 2015-10-23 10:19:14 +02:00
Martin Carlberg 8397685430 Fixed: Joined caches for theme attributes for better performance
Conflicts:
	AppKit/CPTheme.j
2015-10-23 10:19:02 +02:00
Martin Carlberg fc411c5c1c Fixed: Cache ThemeAttribute
Conflicts:
	AppKit/CPTheme.j
2015-10-23 10:18:03 +02:00
Martin Carlberg 3a91f43bbb Fixed: Test cases are working correctly 2015-10-21 12:26:39 +02:00
Martin Carlberg 5e1f1675b8 Fixed: Method ’_themeAttributes’ never saved anything in the cache 2015-10-21 12:26:31 +02:00
Martin Carlberg 9946987f69 Fixed: Cache ThemeState for better performance 2015-10-21 12:26:12 +02:00
Aparajita Fishman 526181a76b Fixed: CPImage -size returned internal object ref
Previously, CPImage -size returned a reference to the internal _size object, which allowed the caller to directly change _size. In Cocoa a copy of the size is returned.

This commit returns a copy of _size to ensure no unwanted side effects.
2015-10-16 16:20:24 -04:00
Alexandre Wilhelm ce8f8c05e1 Merge pull request #2385 from Dogild/CPNotificationQueue
New: added the class CPNotificationQueue
2015-10-14 11:18:41 -07:00
Martin Carlberg 3844b88f7e Fixed: The browser can’t promise when a javascript block will execute so compiler flags can be set after the files are compiled. This implementation works all the time. 2015-10-09 16:06:53 +02:00
Alexandre Wilhelm db3c232173 Fixed: add CPNotificationQueue.j in Foundation.j 2015-10-08 16:07:50 -07:00
Alexandre Wilhelm 22b77af9d3 New: added the class CPNotificationQueue
This PR adds the feature of CPNotificationQueue.

Cappuccino provides a framework for sending messages between objects within
a process called notifications. CPNotificationQueue objects (or simply notification queues)
act as buffers for notification centers (instances of CPNotificationCenter).
Whereas a notification center distributes notifications when posted,
notifications placed into the queue can be delayed until the end of the current pass through the run loop
or until the run loop is idle. Duplicate notifications can also be coalesced so that only one notification
is sent although multiple notifications are posted. A notification queue maintains notifications
(instances of C¨Notification) generally in a first in first out (FIFO) order.
When a notification rises to the front of the queue, the queue posts it to the notification center,
which in turn dispatches the notification to all objects registered as observers.

More informations here :https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationQueue_Class/index.html#//apple_ref/occ/instm/NSNotificationQueue/enqueueNotification:postingStyle:coalesceMask:forModes:

Unit-Tests in Tests/Foundation/CPNotificationQueueTest.j
2015-10-08 16:06:16 -07:00
Alexandre Wilhelm 3e29732e46 Fixed: OperationQueue for the CPNotificationCenter is not ignored anymore
Previously, the operationQueue given to the notificationCenter was ignored.

Tests in CPNotificationCenterTest.j
2015-10-08 11:23:07 -07:00
Alexandre Wilhelm 54e1efd794 Test: refactoring of the manual test CPURLConnectionAsyncTest 2015-10-08 11:17:12 -07:00
Alexandre Wilhelm 8809c1634f Merge pull request #2286 from cacaodev/CPURLConnection
CPURLConnection +sendAsynchronousRequest:queue:completionHandler:
2015-10-08 10:25:12 -07:00
cacaodev 13e1be1f74 CPURLConnectionAsyncTest manual test. 2015-10-07 18:04:28 +02:00
Martin Carlberg 26a123f5a8 Fixed: Added code generation unit test cases with inlined objj_msgSend functions for all tests in OutputTest. 2015-10-07 15:58:28 +02:00
Alexandre Wilhelm f062fda2f7 Fixed: optimization with layoutSubviews and viewWillLayout 2015-10-06 14:41:01 -07:00
Martin Carlberg e45e31d223 Fixed: Introduce ’jake install-inline’ task to generate the cappuccino framework with objj_msgSend function inlined. Also introduced options in ’index-debug.html’ templates to allow inline of objj_msgSend function when compiling in browser. 2015-10-06 13:34:28 +02:00
Martin Carlberg 101261ca63 Fixed: Optionally inline objj_msgSend function. Generate faster code for Array and Dictionary Literals. 2015-10-06 13:30:09 +02:00
Martin Carlberg 4ba9a19b5c Fixed: Speed improvements in objj_msgSend and objj_msgSendSuper functions. More efficient implementation of objj_method. 2015-10-06 13:27:10 +02:00
Alexandre Wilhelm f8eab7d611 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2015-10-02 16:03:04 -07:00
Alexandre Wilhelm 40a9f19352 Fixed: crash when opening a platformWindow with a popup blocker
Previously, when opening a CPPlatformWindow a crash happened when this new window was blocked by the browser (addblock, or browser feature).
Now when opening an external window, we check if the DOMWindow has been created.

This PR has modified the method isVisible of CPPlatformWindow. We now check if the _DOMWindow is not NULL and undefined.
2015-10-02 16:00:57 -07:00
Martin Carlberg 4b81e0d8af Merge pull request #2383 from mrcarlberg/use_more_fast_objj__msg_send
Use the faster objj_msgSend instead of the old slower objj_msgSend
2015-10-02 20:35:32 +02:00
Alexandre Wilhelm ea37bf8b45 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2015-10-02 11:10:01 -07:00
Alexandre Wilhelm c30f8b09b0 Fixed: warning when compiling in CPWindow, CPPanel and _CPCibKeyedUnarchiver 2015-10-02 11:09:48 -07:00
Alexandre Wilhelm 686f931fb4 Merge pull request #2343 from Dogild/Localization
New: first work on localization
2015-10-02 11:04:35 -07:00
Alexandre Wilhelm 1fe1e6f265 Merge pull request #2374 from Dogild/ThemeForObject
New: possibility to create a theme for every object of the Appkit
2015-10-02 10:35:02 -07:00
Alexandre Wilhelm 860decdac5 Fixed: CPColor and CPView implemented the category CPTheme 2015-10-02 10:12:50 -07:00
cacaodev d5b90c91f5 Merge pull request #2339 from cacaodev/CPTabView
CPTabView improvements
2015-10-02 14:00:17 +02:00
Martin Carlberg 20d6e365a1 Fixed: Use the faster objj_msgSend in nib2cib too. 2015-10-01 22:19:04 +02:00
Martin Carlberg e5e50c2220 Fixed: Use the faster objj_msgSend instead of the old slower objj_msgSend
In some places the objj_msgSend function is called directly. Most of the times the old slower version is called. This commit will use the never faster version instead.
2015-10-01 22:17:13 +02:00
cacaodev e8da7baee2 Perform operation on network error (try/catch). 2015-10-01 13:19:40 +02:00
cacaodev 8ab9e6bac7 NEW +sendAsynchronousRequest:queue:completionHandler: If queue is nil, run handler immediately.
NEW: CPURLConnection -operation method, CPError CPURLErrorDomain constant.

    CPURLConnection -operation gives access to the operation generated by the new CPURLConnection creator.
    This allows to create dependencies between operations and setup priorities early.
    When the connection fails with a status code 404 or is cancelled, the
    operation is also cancelled and
    the next operation in the queue is started.
2015-10-01 12:36:57 +02:00
Alexandre Wilhelm 9129301c89 Merge pull request #2381 from mrcarlberg/cp_dictionary_duplicate_keys_in_init
CPDictionary handles duplicate keys in correct way on init
2015-09-30 14:54:24 -07:00
Alexandre Wilhelm 9545e0145f Fixed: conflict with auto-merge in CPTextView 2015-09-30 11:31:32 -07:00
Alexandre Wilhelm 15d3e4023b Merge remote-tracking branch 'origin' into NEW--CPTextView 2015-09-30 11:30:18 -07:00
Alexandre Wilhelm 205e4dedd1 Test: updated test CPTextViewCibTest 2015-09-30 11:30:12 -07:00
Alexandre Wilhelm 324d796aca Fixed: issue with typingAttributes and selectingAttributes when the CPTextView was created from a xib 2015-09-30 11:29:55 -07:00
daboe01 5b31e8e9d8 tighten atomicity in kvb 2015-09-30 19:49:04 +02:00
daboe01 0afb62ee88 formatting 2015-09-30 19:46:18 +02:00
Martin Carlberg 1b0d053ab9 Fixed: Check the abbreviation from the correct place in the test 2015-09-30 18:15:32 +02:00
Martin Carlberg 5871c4f092 Fixed: Fixed test cases where CPTimeZone does not handle daylight saving time.
For example the method ’initWithName:’ will return different abbreviation depending on the order CPDictionary returns keys from the method ’keyEnumerator’. As this is undefined the answer can vary. Test cases now handle all cases.
2015-09-30 17:03:36 +02:00
Martin Carlberg 5d415e6679 Fixed: Speed improvement 2015-09-30 16:59:16 +02:00
Martin Carlberg 3a7384ec26 Fixed: CPDictionary initWithObjectsAndKeys was not compliant with Cocoa or the init method ’initWithObjects:forKeys:’ when duplicated keys was passed to the method.
Test cases are also added
2015-09-30 16:59:04 +02:00
daboe01 1d3a8bcacd fix for moveRight: with non-zero length selection 2015-09-30 12:19:04 +02:00
daboe01 dd187aef08 refactor rich copy: to CPTextView 2015-09-30 12:11:39 +02:00
daboe01 78b2c4d094 kvb fix for editable and selectable 2015-09-30 12:00:12 +02:00
Alexandre Wilhelm 32b7a314b1 Fixed: warning when compiling Foundation adn CPException 2015-09-29 15:36:22 -07:00
Alexandre Wilhelm c8d768c59a New: added protocol CPTheme 2015-09-29 12:54:32 -07:00
cacaodev 3ef1c9167f Merge remote-tracking branch 'upstream/master' into CPTabView
Conflicts:
	AppKit/CPTabView.j
2015-09-29 11:04:51 +02:00
Alexandre Wilhelm 36cdcbc3c1 Fixed: setupViewFlags was not called when creating a view from a xib
Previously, the method setupViewFlags was not called when creating from a xib. This issue was introduced by the commit #448c2a2

Fixed #2380
2015-09-28 11:37:37 -07:00
daboe01 83876532d0 fix cursor position in empty textview 2015-09-26 22:56:17 +02:00
daboe01 edc824d05e fix moveLeft line issue 2015-09-26 21:09:06 +02:00
daboe01 9a7869dd40 fix select the text just after you have deleted something 2015-09-26 21:03:58 +02:00
daboe01 1aa247d4da no selection after undo 2015-09-26 20:57:25 +02:00
Martin Carlberg 5db9f28b33 Merge pull request #2379 from mrcarlberg/fix_cparray_initWithObjects_count
Fixed: The init method ’initWithObjects:count:’ for CPArray did not work
2015-09-25 22:24:49 +02:00
Martin Carlberg 8599ad4a3c Fixed: The init method ’initWithObjects:count:’ for CPArray did not work on native CPJavaScriptArray when ’count’ is not the same as the length on the provided array.
A test case for this is also added in the test class CPArrayTest
2015-09-25 17:07:15 +02:00
Antoine Mercadal 448c2a27d4 Merge pull request #2375 from Dogild/AppearanceCrash
Fixed: crash when using a viewBased CPTableView with appearance
2015-09-23 15:51:50 -07:00
Alexandre Wilhelm f2f4fa1b98 Fixed: readded _viewClassFlags. We only displayRect the view if drawRect: or viewWillDraw is implemented. layoutSubviews is still called even if the subclass does not implement it 2015-09-23 15:00:40 -07:00
Alexandre Wilhelm 6f43a189c0 Merge remote-tracking branch 'origin' into AppearanceCrash 2015-09-23 14:44:06 -07:00
Roland Schwingel dd4de9822f Adjustment for (a)sync request with timeout to work on IE and other browsers 2015-09-23 19:16:20 +02:00
Alexandre Wilhelm c9e83e0517 Merge pull request #2362 from cacaodev/cpview-skip_settransform
FIXED: In CPView, the transformation matrix was set at each drawing pass, even if the matrix was the identity matrix.
2015-09-22 17:02:30 -07:00
Alexandre Wilhelm 4ac63950ad Fixed: toolTip does not work on a external window
Previously, the toolTip created for an external window where shown on the primary platform window. We now display it on the desired platformWindow.
2015-09-22 15:58:53 -07:00
Alexandre Wilhelm 7a0b2c958b Fixed: crash with CPRuleEditor when dragging the first row
Previously, cappuccinos crashed when dragging to the top the first row of a CPRuleEditor.
2015-09-22 15:01:19 -07:00
Alexandre Wilhelm 3fcc37e086 Fixed: CPTabView did not accept first mouse event
Previously, the CPTabView did not react with the first mouse event (for instance when a CPTabView was in a not focused window). Now it does as in cocoa.

To do that, the CPTavView override the method acceptsFirstMouse. Previously, the tabView had a CPBox, it now has a _CPTabViewBox. This new box reacts differently than the CPBox for the method hitTests. It now returns nil when the click was performed on the segmentedControl of the CPTabView, previously this same click would be handle byt the CPBox.
2015-09-22 14:33:14 -07:00
Roland Schwingel 55181cec8c Set timeout in XHR requests AFTER they are opened to get them to work with IE 2015-09-17 14:45:35 +02:00
cacaodev 41d259006e Merge remote-tracking branch 'upstream/master' into CPTabView 2015-09-14 18:57:12 +02:00
daboe01 93e8ec7f06 formatting 2015-09-02 09:04:39 +02:00
daboe01 ba1d1c3bac fix for recent FF update 2015-09-02 09:02:04 +02:00
daboe01 fbaff2b75b fix for FF40+ 2015-09-02 09:00:29 +02:00
daboe01 9774e8807b fix disappearing cursor 2015-08-31 23:40:18 +02:00
Alexandre Wilhelm b30103c790 New: added methods viewWillLayout and viewDidLayout
Previously, when a view was about to layout, only layoutSubviews was called. Now the methods viewWillLayout and viewDidLayout are called as well. This is like in Cocoa.

This PR fixed the issue with the appearance and the view based tableView. We now handle everything related with appearance when making the layout of a view.

This PR removed a small optimization in CPView. Now when making setNeedsLayout and setNeedsDisplay, the methods drawRect: and layoutSubviews are always called even if there are not override. (As in cocoa)
2015-08-28 11:11:28 -07:00
Alexandre Wilhelm bb9408b5d0 Merge branch 'master' into Localization 2015-08-27 15:16:12 -07:00
Alexandre Wilhelm 42c3c7bc48 Fixed: crash when using a viewBased CPTableView with appearance
Previously, when using a viewBased CPTableView Cappuccino just crashed.
This was due to the new appearance feature. Indeed, at the end of the method initWithCoder: of CPView, we set the appearance of the current view and the themeStates of the view and its subviews. For an unknown reason some of these subviews were not completely initialized (see comment line 3742), this made crashed cappuccino because _themeState was null.

To fix this issue, we send the method setAppearance when the current stack was performed. (Magic setTimeout...).

This is for sure not the ultimate best fix, but it's prevent to have a broken master. We will need in the future to fix this issue in a better way.
2015-08-25 16:46:00 -07:00
Alexandre Wilhelm 464040895c Fixed: remove log... 2015-08-21 16:06:25 -07:00
Alexandre Wilhelm 525747dc53 New: possibility to create a theme for every object of the Appkit
The purpose of this feature is to create theme for every object of the AppKit. Previously, we could not theme object like CPColor, however CPColor could be very interesting to theme, value like alternateSelectedControlColor were hard coded in the framework. With this PR, we can now theme a CPColor and take some values from the current theme of the application. Then, this PR offers the possibility to refactor the themeDescriptors, some classes contains theme attributes for other class (CPTabView and  CPTabViewItem for instance).

How doe it work ? A new category _CPObject+Theme.j has been added to the AppKit. This category contains every theme methods needed to theme an object (previously this category was in CPView). We add utils method like _encodeThemeObjectsWithCoder: and _decodeThemeObjectsWithCoder: in this category to be able to code and decode easily a coder for every object (this is generic).

This PR did not refactor the themeDescriptors, it only add this new mechanism for the methods alternateSelectedControlColor and secondarySelectedControlColor of CPColor. We will need to refactor that gradually
2015-08-21 15:54:00 -07:00
Alexandre Wilhelm c61d992559 Merge pull request #2373 from Dogild/menu-context
New: default menu system is now disable for every right click except for the CPTextField
2015-08-20 19:47:20 -07:00
Alexandre Wilhelm 2f79b079fd New: default menu system is now disable for every right click except for the CPTextField
Previously, when making a right click and when a cappuccino menu was not displayed, the system menu was displayed. Now we don't display this menu anymore as in cocoa. We only display when making a right click on a CPTextField.
2015-08-20 16:14:14 -07:00
Alexandre Wilhelm 655bc39d85 Fixed: blinking popover animation on Chrome and Opera
Previously, when opening a popover, the animation was blinking on Chrome and Opera.
To resolve (temporary I hope) this issue, we launch the last part of the animation at the beginning of the next runloop. We do that by wrapping the desired code in window.setTimeout(function(){},0).

A google chrome issue has been opened here : https://code.google.com/p/chromium/issues/detail?id=523044&thanks=523044&ts=1440095724
2015-08-20 11:36:57 -07:00
Roland Schwingel 1eb12d4fa0 Damned... corrected formatting 2015-08-20 14:57:28 +02:00
Roland Schwingel 2ab9186259 Fix Chrome warning when using synchronous XHR requests 2015-08-20 14:52:19 +02:00
Alexandre Wilhelm ab61aef985 Merge pull request #2371 from primalmotion/CPVisualEffectView
CPVisualEffectView & CPAppearance
2015-08-18 15:15:03 -07:00
Roland Schwingel 65b3e9f8c1 Merge remote-tracking branch 'upstream/master' 2015-08-18 14:10:21 +02:00
Alexandre Wilhelm 1f57aa1ea5 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2015-08-16 15:44:01 -07:00
Alexandre Wilhelm 340d827377 Fixed: command cmd+h did not work for the new XcodeCapp 2015-08-16 15:43:56 -07:00
Antoine Mercadal 5cd25e24e4 Merge pull request #2369 from tancred/preserve_boolean_type_when_parsing_predicate_constant_value_expressions
Fixed: preserve type of boolean values when parsing CPPredicate format
2015-08-14 13:55:18 -07:00
Antoine Mercadal 58afc92a26 Merge pull request #2370 from Dogild/new-cache-timeout-urlrequest
New: added timeout and cache feature in CPURLRequest
2015-08-14 13:51:20 -07:00
Alexandre Wilhelm acb9931fe6 Fixed: not possible to to synchrone request and set a timeout 2015-08-14 13:28:27 -07:00
Alexandre Wilhelm d4b035ac1a Fixed: style in CPURLConnection.j CPURLRequest.j CFHTTPRequest.js 2015-08-14 12:40:22 -07:00
Antoine Mercadal 403dd5c005 Updated CPVisualEffectViewTest
The test now show how to use the automatic theme state beased on
CPAppearance
2015-08-14 01:45:19 -07:00
Antoine Mercadal 7e4e1ec68f FIXED: lot's of error with CPAppearance 2015-08-14 01:44:22 -07:00
Antoine Mercadal 547764e3c1 FIXED: Always call [super awakeFromCib] in CPView subclasses 2015-08-14 01:43:55 -07:00
Antoine Mercadal 541a7974e0 NEW: effectiveAppearance and new CPThemeState
Each default (and only supported) CPAppearance now have an associated
theme state. As the appearance is correctly propagated in CPViews
hierarchy, it is now possible to have dark controls when the an
ancestor view has a dark appearance.

Added automated tests
2015-08-13 23:40:27 -07:00
Antoine Mercadal 6bf6f82cad Small refactoring 2015-08-13 21:29:33 -07:00
Antoine Mercadal 7be2325a95 Fix few mistakes 2015-08-13 21:12:04 -07:00
Antoine Mercadal fa1f739458 NEW: Support for basic CPVisualEffectView
This patch contains a very naive implementation of the
NSVisualEffectView. This will only work on very recent unreleased
version of Safari, but should be supported by all at some point. This
allow to use the Yosemite/iOS blurry effect.

Not all options are supported (especially the
`CPVisualEffectBlendingModeBehindWindow` mode…). But hey! it’s a start
:)

Tests in Manual/CPVisualEffectViewTest
2015-08-13 20:53:53 -07:00
Antoine Mercadal 20289ff81b fix two small bugs in CPApperance 2015-08-13 20:25:45 -07:00
Antoine Mercadal 6d67d30aee NEW: Initial support for CPAppearance
This patch adds the `CPAppearance` class and uses it where needed.
There is nearly no impact, but in `_CPPopoverWindowView` where the
`CPPopoverAppearance` needs to be converted to a `CPAppearance` object

nib2cib support has also been added.

*This patch brings no new functionality.*
2015-08-13 19:56:10 -07:00
Alexandre Wilhelm bd0bd2e087 New: added timeout and cache feature in CPURLRequest
This PR adds the possibility to set the timeout and the cache policy of a CPURLRequest.
For that, there are new things in the framework :

- CFHTTPRequest has now the functions setTimeout(), getTimeout() and isTimeoutRequest
- CPURLRequest has now the methods +requestWithURL:cachePolicy:timeoutInterval: and -initWithURL:cachePolicy:timeoutInterval:
- CPURLConnection does not call the delegate didReceiveData: when a request has timed out. I will call the delegate didFailWithError:
- Cache is now possible for a CPURLRequest, only CPURLRequestReturnCacheDataElseLoad, CPURLRequestReturnCacheDataDontLoad and CPURLRequestReloadIgnoringLocalCacheData are supported. By default CPURLRequestReloadIgnoringLocalCacheData.
- Default timeout has been set to 60sec as in cocoa.
- A request is considered as timeout when there isn't any response (text/xml/type) and when the status of the response is 0.
2015-08-13 17:08:59 -07:00
Antoine Mercadal 3d79799450 Do not fail Cappuccino installation if XcodeCapp build fails 2015-08-13 12:13:38 -07:00
Alexandre Wilhelm c99f9205b7 Merge pull request #2367 from primalmotion/xcodecapp4.0
Xcodecapp4.0
2015-08-12 11:26:55 -07:00
Malte Tancred 26bb54472f Fixed: preserve type of boolean values when parsing CPPredicate format
When parsing a predicate format that contains a constant boolean expression
(e.g., 'key = YES') the value of the returned constant value expression has
the wrong type. Instead of using native types as values, the parser uses
[CPNumber +numberWithBool:].

This commit changes the format parser (CPPredicateScanner) to use native
booleans for constant value expression.

There's a test case that checks the parse result and an additional test
that ensures boolean expressions evaluate as expected with different kinds
of objects. The latter test passed before the fix but was added to ensure
compliance with Cocoa.
2015-08-12 17:05:56 +02:00
Roland Schwingel 73e13fee37 Fix for startup on IE10. Reformatted patch 2015-08-11 09:03:21 +02:00
Roland Schwingel 205c1ac3b6 Fix startup on IE10 2015-08-10 17:08:28 +02:00
Antoine Mercadal d317744f05 Update pbxproj to auto deploy 2015-08-04 10:43:59 -07:00
Antoine Mercadal 47611b7615 NEW: XcodeCapp 4.0
XcodeCapp 4.0 is a major release of our beloved tool. In a nutshell it:

- allows to manage multiple projects simultaneously
- allows to follow operations and cancel them
- has a per project Error and Warning reporting
- supports capp_env as you can define additional paths and objj include path per project
- much more things
2015-08-04 10:35:23 -07:00
Antoine Mercadal 6420a51dd0 FIXED: crash when a cell based table view contains a dataview that contains an editable text field
Previously, CPTableView was listening to all end editing notifications in cell-based mode.
This caused a crash if the textfield is an actually subview of a dataview.

This patch ensures to listen only editing did end notification for direct subview of tableView.
2015-08-03 15:00:04 -07:00
Antoine Mercadal 7c17d5bac0 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2015-08-03 14:57:15 -07:00
Antoine Mercadal 0efd7c93c5 FIXED: Fonts from IB not correctly interpreted in OSX El Capitain
This patch adds support for the new way of defining the default font from Xcode 7 beta. The patch also supports the old explicit 'Lucida Grande' of previous version.
2015-07-29 23:39:07 -07:00
Alexandre Wilhelm 806be9551c New: added protocol CPURLConnectionDelegate 2015-07-23 14:38:06 -07:00
daboe01 b4dd3a9889 typing at the end fix 2015-07-18 17:44:18 +02:00
Alexandre Wilhelm 6b4a1b6758 New: Added gitter link in the readme
New: Added gitter link in the readme
2015-07-15 15:42:07 -07:00
daboe01 4510b69798 refacturing 2015-07-14 19:29:46 +02:00
daboe01 84a3ee209a fix cursor up newline issues 2015-07-09 20:45:23 +02:00
Antoine Mercadal d6b0fccbda FIXED: Previous patch by @dogild was not correctly setting the CSS class
This patch adds a reference to the current CSS selectable field in and
reset the style when user clicks on a different one.
2015-07-08 15:35:20 -07:00
Alexandre Wilhelm d1e31da2e5 Fixed: selection did not work in Cappuccino when doing a right click or dragging
Previously, the selection of a textField did not work as expected when the user did a right click or a drag even if the label was set to none selectable.
Now, with the css style user-select, a textField can only be selected if it is selectable and enable.

Credit to @primalmotion
2015-07-08 13:34:57 -07:00
Alexandre Wilhelm 923d32ee6d Test: finally put the init of the CPApplication in the instance method setUp. See previous commit #6fe9dae3d62af995f2481bfebdd706aeb0b21365 2015-07-07 15:04:29 -07:00
Alexandre Wilhelm 4b0fe879cb Test: [[CPApplication alloc] init]; in instance setUp method 2015-07-07 14:46:38 -07:00
Alexandre Wilhelm b87aeffcd8 Test: updated unittest 2015-07-07 14:29:50 -07:00
Alexandre Wilhelm 88aafec6e3 Merge branch 'master' into NEW--CPTextView 2015-07-07 14:29:15 -07:00
Alexandre Wilhelm 6fe9dae3d6 Fixed: AppKit unit-tests are not standalone
Previously, every AppKit tests used the same sharedApplication. Due to this implementation, a could not pass because a previous test made failed the current test. For instance, a test could fail because the window of the previous test resigned (just imagine a new window is the key window in the current test), and this resign could raise an error. The error was displayed for the current test thought this test was perfect !

We now instead of using sharedApplication create a new CPApplication per unit-test file in the class method setUp.
2015-07-07 14:12:19 -07:00
Alexandre Wilhelm 2cb6ddf3ca Fixed: document was not wrap in a #if PLATFORM 2015-07-07 11:14:56 -07:00
daboe01 799622a932 Merge remote-tracking branch 'upstream/master' into NEW--CPTextView 2015-07-07 18:24:54 +02:00
Alexandre Wilhelm 4c1e22b0f6 Fixed: travis failed because the unittests tried to display a layer
Previously, the unittests for the CPDatePicker broke the tests suite of cappuccino. A CPDatePicker uses a CALayer, and the CALayer display methods wasn't wrap in a #if PLATFOrM(DOM). Now it does, so during the tests we do not try to access do the element document anymore.

This PR fixes also some warnings when compiling.
2015-07-06 14:14:39 -07:00
daboe01 2283652704 add missing ivar 2015-07-05 22:50:21 +02:00
daboe01 33fb2daabf fix shift selection 2015-07-05 14:19:11 +02:00
daboe01 c79f59ec05 fix manual test title 2015-07-05 14:02:30 +02:00
daboe01 845aaad891 fix keywindow observer mechanics 2015-07-05 08:57:25 +02:00
daboe01 3c0b061220 cursor fixes 2015-07-04 21:18:40 +02:00
daboe01 af7de73f5c fix dom protection 2015-07-04 19:24:52 +02:00
daboe01 1a8a9f0047 make dom protection more stringent 2015-07-04 19:17:22 +02:00
daboe01 a3b4e8db44 fix non-working unit test 2015-07-04 17:42:07 +02:00
daboe01 f9e8875803 merge current master in 2015-07-04 16:46:24 +02:00
daboe01 e4c11d9a88 various fixes 2015-07-03 23:13:57 +02:00
daboe01 6d1d8da101 recursion fix 2015-07-03 22:56:58 +02:00
daboe01 77303e668f fix missing reference 2015-07-03 21:03:28 +02:00
daboe01 72725b91c7 fix undefined constant 2015-07-03 20:56:14 +02:00
daboe01 46f50f55c2 various baseline fixes 2015-07-03 20:03:53 +02:00
daboe01 5e880f6bfa Revert "_textContainer refac preparation"
This reverts commit 80cf88dcc1.
2015-07-03 17:26:20 +02:00
Alexandre Wilhelm 058a73f8a0 New: added delegate methods applicationShouldTerminate and applicationShouldTerminateMessage
This PR adds the delegate methods applicationShouldTerminate and applicationShouldTerminateMessage in CPApplicationDelegateProtocol.

The delegate applicationShouldTerminate does not exactly work as in Cocoa. In Cocoa, this method is called in CPApp -terminate, but in cappuccino it is called in the method onbeforeunload of the window. In JS, this is the only time where we can prevent to reload the HTML page. If the developer cancel to reload the page, the browser will ask the user if he wants to reload or not the page thought (natural behavior of js).

The method applicationShouldTerminateMessage allows you to define what will be the text displayed in the confirmation alert.

Test app in Tests/Manual/CPPlatformWindow/
2015-07-02 16:35:35 -07:00
Alexandre Wilhelm 1ad8d34ecb Fixed: fixed travis with datePicker test 2015-07-02 15:12:18 -07:00
Alexandre Wilhelm 3f9f926c8e New: added method closeAllPlatformWindows in CPPlatform
Added the method closeAllPlatformWindows in CPPlatform. This platform close all platform windows of the application (except the main one). This method is now used when reloading or leaving a cappuccino application, the application will now close every external window openend by the application.
2015-07-02 13:41:37 -07:00
daboe01 80cf88dcc1 _textContainer refac preparation 2015-07-02 19:56:54 +02:00
daboe01 dddc7f348f fix lineheight issue during wrapping 2015-07-02 19:48:12 +02:00
daboe01 ce45f2e114 move to end of line fix 2015-07-02 06:03:05 +02:00
daboe01 d22a7c0a63 FF copy paste fix 2015-07-01 22:52:01 +02:00
daboe01 59162155de caret loc refac 2015-07-01 07:20:17 +02:00
daboe01 0f347cd0b4 revert to capp pasteboard 2015-07-01 05:58:12 +02:00
Alexandre Wilhelm 1f983db47c Fixed: refactoring of the class _CPDatePickerTextField.j. We now use the method called by interpreteKeyEvents instead of handling the key equivalent in performKeyEquivalent 2015-06-29 14:28:28 -07:00
daboe01 dc50793733 cosmetics 2015-06-29 20:58:33 +02:00
daboe01 b98329f91c end of doc fix 2015-06-29 20:54:43 +02:00
daboe01 587d8fbfa9 fix caret position 2015-06-29 20:19:47 +02:00
daboe01 26a2e9ef53 capture mode for copy/paste 2015-06-29 19:43:23 +02:00
daboe01 e5ca98a1d3 fix baseline cross multiple fragments issue 2015-06-28 21:19:33 +02:00
daboe01 5bd5e9000e fix baseline issue with native input 2015-06-28 21:07:51 +02:00
daboe01 d566642c98 improved baseline support 2015-06-28 17:16:24 +02:00
daboe01 f81ddc60ec simplify baseline code 2015-06-28 16:20:06 +02:00
daboe01 6e0b20c921 prepare baseline support 2015-06-28 16:03:23 +02:00
daboe01 0c308b38c5 move to right end simplification 2015-06-28 15:18:59 +02:00
daboe01 8e0fdf68e4 move left/right of line fix 2015-06-28 12:36:40 +02:00
daboe01 9c7a9b5674 cursor up down fix 2015-06-27 16:13:10 +02:00
daboe01 0a49e31b30 add lastmarker to linefrag 2015-06-27 16:01:42 +02:00
daboe01 9478206202 simplify insertText: 2015-06-27 15:43:10 +02:00
daboe01 c86e6f5b88 fix rare invisibility bug 2015-06-27 13:58:58 +02:00
daboe01 87868acecd formatitng 2015-06-27 13:46:31 +02:00
daboe01 6d877754da focusForClipboard fixes 2015-06-27 13:10:53 +02:00
daboe01 dd5521a07c various native deadkey fixes 2015-06-27 13:03:41 +02:00
Alexandre Wilhelm 3a6a84917b New: added CPUserNotification and CPUserNotificationCenter in Foundation
This PR adds the features CPUserNotification and CPUserNotificationCenter in Foundation.
The CPUserNotificationCenter allows you to send user notification to the system.
Right now, we only propose what the W3C proposes. We can set for a notification the title, informativeText and the icon.
We only support local notification yet.

The protocol CPUserNotificationCenterDelegate has been added as well.

Test app in Tests/Manual/CPUserNotificationTest
2015-06-26 16:36:11 -07:00
daboe01 cca142ce86 smart paste at end fix 2015-06-25 20:48:30 +02:00
daboe01 fa3567cb9f fix arrow down last line 2015-06-25 06:03:02 +02:00
daboe01 7d22230b13 keyboard-selection-extension fix 2015-06-25 05:54:34 +02:00
Alexandre Wilhelm 9694c796e3 Revert "fix disappearing buttons"
This reverts commit 7323a5e393.

Fixed #2361
2015-06-24 14:35:23 -07:00
daboe01 1b7f684ab2 make safari fix more robust 2015-06-24 21:14:24 +02:00
daboe01 fef8f4d29c safari backspace fix 2015-06-23 20:36:57 +02:00
daboe01 0d7e945623 fix native cut 2015-06-22 20:30:44 +02:00
daboe01 13ea8eae77 fix initial platform paste 2015-06-21 14:20:14 +02:00
daboe01 cdb2ef3ac7 prevent dom-flickering 2015-06-20 19:11:05 +02:00
daboe01 f216e0198f harmonize capp and system pasteboards 2015-06-20 13:23:33 +02:00
daboe01 c5c3698f43 make undo work again 2015-06-19 23:26:14 +02:00
daboe01 299d3b9f60 formatting 2015-06-19 22:41:12 +02:00
daboe01 eaaebeaebb refactoring paste 2015-06-19 22:39:41 +02:00
daboe01 2ef2d2b9c5 fix native pasteboard support 2015-06-19 22:31:57 +02:00
Antoine Mercadal da6698b216 Merge branch 'master' into capp_env 2015-06-19 10:12:02 -07:00
Antoine Mercadal c9f391dfc1 Update the installation process 2015-06-19 10:11:40 -07:00
Antoine Mercadal 0f62926623 rename cappenv_deactivate to capp_env_deactivate 2015-06-19 09:59:14 -07:00
daboe01 a856b4027b formatting 2015-06-18 20:30:05 +02:00
daboe01 e2f72ecffc prepare baseline support 2015-06-18 20:23:00 +02:00
daboe01 d888bcd473 deadkey backspace safari fix 2015-06-17 20:10:19 +02:00
daboe01 0bfd5fa9a3 fix missing parameters to _flushRange 2015-06-16 19:04:50 +02:00
daboe01 9c05ccef69 preparations for baseline alignment 2015-06-16 18:59:38 +02:00
cacaodev c7eb2ffe5c Merge remote-tracking branch 'upstream/master' into cpview-skip_settransform 2015-06-15 21:10:05 +02:00
daboe01 5281b6df77 increase timeout on FF 2015-06-15 20:49:10 +02:00
daboe01 cd5bb6a309 fix deadkey after deadkey on FF 2015-06-15 20:45:58 +02:00
daboe01 94a44d7af4 remove dead code 2015-06-15 19:50:09 +02:00
daboe01 662050b89f formatting 2015-06-14 21:34:19 +02:00
daboe01 3f7f3140eb rich copy fixes 2015-06-14 21:24:40 +02:00
Alexandre Wilhelm a419694f70 Test: updated unit test ToolsTest.j. Fixed travis... 2015-06-13 21:58:09 -06:00
cacaodev 0a20f77b08 FIXED: In CPView, the transformation matrix was set at each drawing pass, even if the matrix was the identity matrix.
Now we check if the highDPI ratio is == 1 and skip the setTransform call in this case.
2015-06-13 21:06:17 +02:00
daboe01 dc11d18161 formatting 2015-06-12 17:32:22 +02:00
daboe01 cde83e9d7d smart paste fix 2015-06-12 17:28:48 +02:00
daboe01 1476fda014 backspace fix 2015-06-12 17:22:55 +02:00
daboe01 7a875f2db4 filter out apple command keys 2015-06-11 23:03:44 +02:00
daboe01 b868f37da5 remove call to super cancelOperation:sender 2015-06-10 06:41:15 +02:00
daboe01 9bef5a62dd formatting 2015-06-09 22:46:47 +02:00
daboe01 d1aff30c9e fix invisible deadkey at beginning of newline 2015-06-09 22:43:31 +02:00
daboe01 a356dafde0 enter deadkey on exit 2015-06-09 21:14:38 +02:00
daboe01 09477384fe illegal deadkey sequence fix 2015-06-09 19:26:41 +02:00
daboe01 6b923542e8 invisibility fix 2015-06-08 21:36:30 +02:00
daboe01 9722cf718c mouse down fix 2015-06-08 20:30:24 +02:00
daboe01 702b973c87 fix Dead key input element leaves margin on right 2015-06-08 20:25:56 +02:00
Alexandre Wilhelm 472372c9ed Test: updated unittest for the tools 2015-06-08 10:35:13 -07:00
Alexandre Wilhelm d358f0d27b Fixed: xml format now has the key sourcePath instead of path for the command objj and objj2objcskeleton 2015-06-08 10:30:54 -07:00
daboe01 d66bbd95f0 add native support for deadkeys 2015-06-07 21:18:27 +02:00
daboe01 aae498509b typing attributes refactoring 2015-06-07 21:00:25 +02:00
daboe01 4987fb5f15 fontpanel color well fix 2015-06-06 19:03:37 +02:00
daboe01 b1ed299286 fix for paragraph style not being carried forward 2015-06-03 22:13:17 +02:00
daboe01 679ac3e5b1 fix caret height on last line 2015-06-02 23:25:55 +02:00
daboe01 181ef788a3 caret height fix 2015-06-02 22:47:53 +02:00
daboe01 d2caa0953f various caret fixes 2015-06-02 22:23:32 +02:00
Alexandre Wilhelm 3f88e02587 New: added the option -n to specify the name of the cocoa files generated by objj2objcskeleton 2015-06-01 15:22:56 -07:00
Antoine Mercadal 245da9b422 Add capp_env 2015-06-01 15:20:20 -07:00
Alexandre Wilhelm 8cc075aff3 Fixed: objj2objcskeleton does not work with categories on cappuccino class
Previously, when making objj2objcskeleton on a category of a cappuccino class, the cocoa category was not a cocoa class but still a cappuccino class. For instance, a CPView category was still a CPView category instead of being a NSView category.

Fixed #2344
2015-06-01 14:35:12 -07:00
Alexandre Wilhelm 128a243166 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2015-06-01 13:53:56 -07:00
Alexandre Wilhelm 0e41365020 Fixed: some objj errors were not print in xml when necessary 2015-06-01 13:53:41 -07:00
daboe01 bd6d5ffbb9 formatting 2015-05-29 23:10:28 +02:00
Alexandre Wilhelm de7951f4db New: added build passing tag to the realm markdown 2015-05-27 18:38:10 -07:00
Alexandre Wilhelm bdbf1fbb43 Merge pull request #2348 from Dogild/BaseWritingDirection
New: added property baseWritingDirection in CPControl
2015-05-27 15:37:09 -07:00
Alexandre Wilhelm a7b6010ce2 Merge pull request #2358 from Dogild/CPScrollView-documentVisibleRect
Fixed: documentVisibleRect in CPScrollView does not return the expected result
2015-05-27 15:27:12 -07:00
Alexandre Wilhelm 5bba109873 Merge pull request #2346 from primalmotion/fix-popen
FIXED: Closes all streams after a OS.popen()
2015-05-27 15:25:36 -07:00
Alexandre Wilhelm d69ae60bcb Fixed: themeState of an editing CPTextField in a cell based CPTableView
Previously, when having a CPTableView cell based, the themeState of the textField were wrong. The text color was black as every textField was considered as editable. The CPTableView handled differently the textField, as long a textField is not editing, the textField is mark as non editable. Previously, the textFields were considered editable all the time.

More informations here : https://groups.google.com/forum/?fromgroups#!topic/objectivej/zImy4sj0Xz4
2015-05-27 14:57:28 -07:00
Alexandre Wilhelm a0277aba2e Merge pull request #2360 from Dogild/XMLOutputFormatObjj
New: added the option --xml-output-format for the command objj
2015-05-27 13:09:15 -07:00
Alexandre Wilhelm caba631db9 Test: updated ToolsTest.j 2015-05-27 12:38:56 -07:00
Alexandre Wilhelm 5095620005 Fixed: changed --xml-output-format to --xml in objj 2015-05-27 11:46:43 -07:00
Alexandre Wilhelm abcdc0875c Fixed: added option -x for objj and changed xml-output-format to --xml 2015-05-27 11:12:36 -07:00
daboe01 a4e41a57d7 make paragraph selection via triple click more mac like 2015-05-27 07:07:51 +02:00
daboe01 e8bb3864e3 smart delete 2015-05-26 07:37:13 +02:00
Alexandre Wilhelm 3e03d52fce Fixed: objj tests did only work on my system... 2015-05-25 15:22:30 -07:00
Alexandre Wilhelm 4f64d466fb Test: added unit test for option -xml-output-format of objj 2015-05-25 13:27:03 -07:00
Alexandre Wilhelm 3102c545ce Fixed: used url path (/Users/..) instead of absoluth path (file://Users/..) in the xml output format of objj 2015-05-25 13:26:37 -07:00
daboe01 3cd1066a8d backspace undo fix 2015-05-25 22:10:31 +02:00
daboe01 6494b7ea89 smart cut fix 2015-05-25 21:21:32 +02:00
Alexandre Wilhelm f232b327c0 Fixed: issue with options --objj-include-paths and --multifiles. Long options were not taken 2015-05-25 11:38:16 -07:00
Alexandre Wilhelm 204ed1f257 New: added the option --xml-output-format for the command objj
Previously, it was not possible to specify the desired output format of the command objj.
Now we can have either the default format or a xml format if --xml-output-format is added.
2015-05-25 11:20:55 -07:00
daboe01 2f5d13ac10 smart paste fix 2015-05-24 22:24:52 +02:00
Alexandre Wilhelm 65a379c8da Merge pull request #2359 from herbatnik/master
FIXED CPDatePicker AM/PM time format for GB locale
2015-05-21 17:24:01 -07:00
Marek Kresnicki 99df5fadbc Replaced confusing method _isEnglishFormat with _isAmericanFormat. Removed method was always true for US and GB locale while it shouldn't be. 2015-05-21 15:30:53 +01:00
daboe01 c8e6dca263 small refactoring of string sizing init 2015-05-20 19:42:03 +02:00
daboe01 9dec40eca7 init refactoring + cachekey fix 2015-05-20 05:58:32 +02:00
Alexandre Wilhelm 92cdb27e23 Fixed: documentVisibleRect in CPScrollView does not return the expected result
Previously, the method documentVisibleRect did not return the expected result. An issue happened when using this method on a scaled view. The converted rect was converted in the wrong context.

Unit test in Tests/AppKit/CPScrollViewTest.j

Fixed #2356
2015-05-19 14:30:09 -07:00
daboe01 4896043599 fix caching issue with numeric strings 2015-05-19 20:22:55 +02:00
daboe01 5f0ddeedd0 draw caret permantently during editing...
...or cursor navigation
2015-05-17 20:43:18 +02:00
daboe01 e679e760ee backspace fix 2015-05-17 20:23:41 +02:00
Alexandre Wilhelm a439688b3c Doc: move private variables to the top of files to not show them in the documentation 2015-05-15 09:55:17 -07:00
Antoine Mercadal 0d17757729 FIXED: CPPogressIndicator needs display when updateing it's state 2015-05-14 15:20:48 -07:00
Alexandre Wilhelm 899bbc2dbc Fixed: issue with determinate spinning progressBar annd value not between 0 and 100 2015-05-13 10:06:54 -07:00
Alexandre Wilhelm 57b68880db New: added indeterminate spinning progressBar
Previously, it wasn't possible to display an indeterminate spinning progressBar. Now we can as in cocoa.

Test app in Tests/Manual/CPProgressIndicator
2015-05-12 17:18:31 -07:00
Martin Carlberg 06c59763bc Merge pull request #2353 from Dogild/optionObjc
New: added option --objc to objj to generate objc files from a .j file
2015-05-12 09:19:08 +02:00
Alexandre Wilhelm 71c1d16c06 Test: fixed test ToolsTest.j 2015-05-11 21:52:04 -07:00
Alexandre Wilhelm 64c1b72481 Test: added unit test for objj2objcskeleton 2015-05-11 17:03:45 -07:00
Alexandre Wilhelm e5742e057d Fixed: issue with objj2objcskeleton and destination folder 2015-05-11 16:27:06 -07:00
Alexandre Wilhelm a9d6176fd2 New: added command objj2objskeleton. This feature is now not available from the command objj 2015-05-11 11:33:52 -07:00
cacaodev 1b0aa2a9b1 FIXED: test app merge issue with cib. Regenerated cib. 2015-05-11 10:37:00 +02:00
cacaodev a49c230bb2 FiXED: animatorClass when the receiver is a CPView custom subclass. 2015-05-11 10:34:12 +02:00
cacaodev b65749cf70 FIXED : setObject:nil in test app 2015-05-11 10:32:33 +02:00
cacaodev 0cf54a6a03 Fix a 'duplicate class' build error 2015-05-11 10:31:27 +02:00
cacaodev 4d77277f2d Merge branch 'master' of git://github.com/cappuccino/cappuccino into CPAnimationContext 2015-05-11 08:44:20 +02:00
daboe01 8b81506ed3 fix aWidth usecase 2015-05-11 05:56:52 +02:00
cacaodev 24c6509a61 FIXED: build error 'CPDictionary nil object'
CPViewAnimator : default mapping between css and capp props is now
lazily computed instead of a class var.
This was causing a build error because some values were not ready to be
read.
2015-05-10 19:23:41 +02:00
daboe01 3c32c4160d formatting 2015-05-10 18:03:42 +02:00
daboe01 1f912d86e1 small speed improvement
avoid the covering method send
2015-05-10 17:59:26 +02:00
daboe01 9c93ab0b6d fixed confusion between font an cssString 2015-05-10 15:30:40 +02:00
daboe01 6646a20a5d DOM protection 2015-05-10 15:22:56 +02:00
daboe01 92f471c476 move fontHeight to where it is needed 2015-05-10 15:19:26 +02:00
daboe01 4c7ce97650 measureText return type 2015-05-10 15:16:12 +02:00
daboe01 4d1fc994c0 refactor private sizing method to sizeWithFont: 2015-05-10 15:12:31 +02:00
daboe01 c4310c554e make DOM sizing faster 2015-05-10 13:37:36 +02:00
Antoine Mercadal c603326e58 Use try/finally to ensure popen streams are always closed 2015-05-09 10:22:13 -07:00
Alexandre Wilhelm a93e04a44e New: added option --objc to objj to generate objc files from a .j file
The command objj has now the option -c or --objc to generate objective-c files. The first arg is the file and the second the destination folder.

The objective-c class generated are basic and only contains IBOutlet and IBAction. To do that, the objective-c-parser is used. This parser is also used in xCodeCapp.
2015-05-08 23:05:58 -07:00
cacaodev db9e649f6e FIXED: missing return stmt in -indexOfTabViewItemWithIdenfier;
Refactored delegate notifications.
CPTabViewItem style.

Tests: All delegate methods are tested in CPTabViewNib manual test.
2015-05-07 22:35:02 +02:00
Alexandre Wilhelm c26aca4686 Fixed: memory leaks in CPSplitView with delegate 2015-05-04 16:43:37 -07:00
Alexandre Wilhelm f822268ae1 Test: updated manual test CPSplitViewTest 2015-05-04 16:43:13 -07:00
Alexandre Wilhelm 4ebcf40619 Fixed: make travis happy with DOM elements in CPTextView 2015-05-04 14:03:33 -07:00
Alexandre Wilhelm a884b94ac0 Test: fixe global var in CPTextViewTest.j 2015-05-04 14:02:46 -07:00
Alexandre Wilhelm 194e705982 Test: comment future test for CPTextView 2015-05-01 16:09:08 -07:00
Alexandre Wilhelm c77ec3bf20 Fixed: added coder for delegate of a CPTextView 2015-05-01 16:08:49 -07:00
Alexandre Wilhelm 0a1857249b Test: updated manual test CPTextViewCibTest 2015-05-01 16:08:30 -07:00
Alexandre Wilhelm 3be3a1f2e6 Merge pull request #2329 from daboe01/fix-issue-10
Added documentation for CPArray's hash method
2015-05-01 14:05:19 -07:00
Alexandre Wilhelm 62f9488829 New: added property baseWritingDirection in CPControl
This PR adds the support for baseWritingDirection in CPControl.
Support of nib2cib has been added as well.

Test app in Tests/Manual/CPTextFieldEditingStyleTest/
2015-05-01 12:11:03 -07:00
Antoine Mercadal 9bcaef192c Merge branch 'master' into fix-popen 2015-04-23 16:50:56 -07:00
Antoine Mercadal bcb1630f20 FIXED: Closes all streams after a OS.popen()
Previously, when popen was called, the 3 streams (stdin, stderr and stdourt) where never closed. This was the reason of the having an impossible number of open files.

This patch ensure all streams are closed after using them. This means that the ulimit trick is no more necessary
2015-04-23 16:46:01 -07:00
Alexandre Wilhelm 5f7922d7fd Fixed: crash in CPCib.j due to previous refactoring refs #c5b250236fa662e3da04e442f4414f95d64d9308 2015-04-22 16:21:24 -07:00
Alexandre Wilhelm 66b1d297ba Test: added unit test CPBundleTest 2015-04-22 15:11:47 -07:00
Alexandre Wilhelm eb4780a952 New: added protocol CPBundleDelegate 2015-04-22 15:11:19 -07:00
Alexandre Wilhelm 34f724a4a4 Fixed: capp_lint fixes 2015-04-22 11:22:44 -07:00
Alexandre Wilhelm c5b250236f New: support of base localization and nib localization 2015-04-21 18:26:28 -07:00
Alexandre Wilhelm e5b122ee61 New: added methods pathForResource:ofType, pathForResource:ofType:inDirectory: pathForResource:oftype:inDirectory:forLocalizations: 2015-04-21 18:25:58 -07:00
Alexandre Wilhelm 3b20021981 Test: updated test CPLocalizationTest 2015-04-21 18:24:50 -07:00
Alexandre Wilhelm a7d1f180a4 Test: updated manual test CPLocalizationTest to have base localization in the xib 2015-04-21 14:29:21 -07:00
Alexandre Wilhelm 68374e7c62 Fixed: fix minor issue with methods CPLocalizedStringFromTable and comment 2015-04-21 10:54:09 -07:00
Alexandre Wilhelm ba26a97ddc Test: updated test CPLocalizationTest 2015-04-21 10:53:36 -07:00
Alexandre Wilhelm 2db7ce8da1 New: added the methods CPLocalizedString CPLocalizedStringFromTable CPCopyLocalizedStringFromTableInBundle 2015-04-20 18:53:51 -07:00
Alexandre Wilhelm 6958da1adb Test: added manual test CPLocalizationTest 2015-04-20 18:53:17 -07:00
Alexandre Wilhelm cf48cd0ae5 Fixed: changed copyright of _CPLocalizableString.j 2015-04-20 10:15:05 -07:00
Alexandre Wilhelm b1b3966d41 Fixed compiling issue in CFBundle.js 2015-04-17 20:40:48 -07:00
Alexandre Wilhelm c171a37f24 New: first work on localization 2015-04-17 17:16:11 -07:00
Alexandre Wilhelm c13f1991c9 Fixed: removed stupid merging typo... 2015-04-13 16:18:46 -07:00
Alexandre Wilhelm da15cc4de7 Fixed: wrong nextValidKeyView in a CPScrollView
Previously, the nextValidKeyView was wrong when the views were in a scrollView. Cappuccino did not take in account the possibility of scrolling, the lowest views were considered as outside of the platformWindow.

Now, it works as cocoa! The nextValidKeyView is the good one in a scrollView.

This pull request fixes another issue as well. A CPTextField can now become firstResponder even if the textField is not visible (as in cocoa). Previously a jump of the (html)window occurred to the textField. Now, cappuccino will internally scroll if needed to the element, focus it and then go back to previous scrolling position.
2015-04-13 16:10:44 -07:00
Alexandre Wilhelm 44c686f494 Merge pull request #2323 from mrcarlberg/scroll_rect_to_visible_with_large_rect
Fixed: Method scrollRectToVisible:(CGRect)aRect in CPView didn’t work...
2015-04-13 13:12:27 -07:00
cacaodev 03bd5ad426 Fixed merge issue 2015-04-11 19:26:30 +02:00
cacaodev 914a3d71c2 Merge pull request #2342 from cacaodev/CPSegmentedControl-ni2cib
FIXED: segmented control height in nib2cib. Fixes #2341.
2015-04-11 10:03:50 +02:00
Alexandre Wilhelm 5c2e0935c6 Fixed: CPApplication does not send willBecomeActive and didBecomeActive when having the focus on the application again
Previously, when clicking somewhere else in the system, cappuccino did no raise the notifications willResignActive and didResignActive of the application. As well cappuccino did not raise the notifications willBecomeActive and didBecomeActive when the user was back on the application.

Now it does !

Test app in Test/Manual/CPPlatform
2015-04-10 12:59:05 -07:00
Alexandre Wilhelm e1ec604655 Test: updated manual test CPPlatformWindow 2015-04-10 11:11:22 -07:00
Alexandre Wilhelm 0dad10d6ab Fixed: notifications becomeActive and willActive were called even if the application was already active. The method run sends now an event CPAppKitDefined as in cocoa, this event will raise the notification becomeActive and willActive of the application when the application just finished to load 2015-04-10 10:57:34 -07:00
Alexandre Wilhelm 136138daab Fixed: CPTextField should not blur when resigning from a window which are not keyWindow 2015-04-10 10:55:48 -07:00
Alexandre Wilhelm 6efe563a69 Fixed: method _initOtherEventWithType: in CPEvent did not save the given windowNumber 2015-04-10 10:51:47 -07:00
Alexandre Wilhelm fd068443aa Fixed: keyWindow and mainWindow did not work when jumping from window to window when popover were open
Previously, when jumping from a platformWindow to another platformWindow where popover where opened, the wrong windows became key and main. This things occurred weird behavior of the platformWindows.

Now, it works as in cocoa, canBecomKeyWindow, becomeKeyWindow, becomeMainWindow, resignKeyWindow and resignMainWindow are called in the good order.
2015-04-09 15:14:33 -07:00
Alexandre Wilhelm 82d0f62d73 Added unittest for CPTextView 2015-04-08 13:53:10 -07:00
Alexandre Wilhelm 01ba6ddecd Fixed: floating windows did not become keyWindow and mainWindow of the application when jumping from platformWindow to another platformWindow
Previously, when having several platformWindows, jumping from another platform to another platform did not update the good key window of the application, specially when the expected windows was a panel.

Now it does. The CPPlatformWindow keeps a reference to the previous keyWindow when the window browser is about to blur. The we use this reference to update the keyWindow of the application.
2015-04-07 17:40:26 -07:00
Alexandre Wilhelm 769b379a8b Fixed: a CPPopover were closed when a click was made in another CPPlatformWindow 2015-04-07 17:39:35 -07:00
cacaodev 1b981e0695 FIXED: segmented control height in nib2cib
The -tile method now leaves the frame height unchanged instead of
sizingToFit the theme attribute « min-size ».
The « min-size » is still in use when we layout the ephemeral subviews.

This is how other controls with a min-size work.
Also added -minimumFrameSize. This CPControl subclass will return the
frame for sizeToFit, i.e. when you want to sync the frame attribute
with the minimum/visible height.

Tests : CPSegmentedControlTest & Nib2CibAlignment manual tests.

Fixes: #2341
2015-04-07 18:29:06 +02:00
Alexandre Wilhelm 9798b9fd50 Fixed: it was possible to scroll in a new platformWindow. The overflow style of the body of the plarformWindow was not set to hidden 2015-04-06 18:17:31 -07:00
Alexandre Wilhelm 10792c0bc6 New: Added listener onblur and onfocus on the CPPlatformWindow for updating keyWindow and firstResponder
Previously, when switching from a platformWindow to another platformWindow or to another application, Cappuccino did not behave as Cocoa, Cappuccino still considered that the window was key and main.

Now it works as in cocoa, the platform window lost its focus and is not the keyWindow and mainWindow of the cappuccino application.

Test app in Tests/Manual/CPPlatformWindow/
2015-04-06 17:37:08 -07:00
Alexandre Wilhelm 1c61afd3ee Test: updated CPPlatformWindow manual test 2015-04-06 17:36:53 -07:00
Alexandre Wilhelm 737ef583ee New: added delegate method windowDidMiniaturize: windowWillMiniaturize: and windowDidDeminiaturize: in CPWindow 2015-04-06 13:50:30 -07:00
Alexandre Wilhelm 7b4365bd8a New: added delegate method - (CPSize)windowWillResize:(CPWindow)sender toSize:(CPSize)aSize; in CPWindow 2015-04-06 13:34:36 -07:00
Alexandre Wilhelm 041fce743e New: added new options in nib2cib for CPTextView. It now supports the paragraphStyle, font and textColor 2015-03-31 18:17:57 -07:00
Alexandre Wilhelm ad4904a0ec Added nib2cib options _allowsUndo and _usesFontPanel for CPTextView 2015-03-31 16:38:47 -07:00
Alexandre Wilhelm 42a1bca64d Fixed: style in CPTextView 2015-03-31 16:08:16 -07:00
Alexandre Wilhelm 492a5bbb38 Fixed: memory leaks with delegate of CPTextStorage. Added protocol CPTextStorageDelegate 2015-03-31 15:48:15 -07:00
Alexandre Wilhelm c40ef22c20 New: create class _CPSelectionBox 2015-03-31 15:34:23 -07:00
Alexandre Wilhelm 783aac561a Fixed: capp_lint on AppKit/CPTextView 2015-03-31 15:14:15 -07:00
Alexandre Wilhelm 02245c150c Fixed: small issue due to refactoring 2015-03-31 15:10:59 -07:00
Alexandre Wilhelm 54a93775e4 Merge branch 'NEW--CPTextView' of https://github.com/daboe01/cappuccino into NEW--CPTextView 2015-03-31 15:05:53 -07:00
Alexandre Wilhelm ca778aac70 Merge remote-tracking branch 'origin' into NEW--CPTextView 2015-03-31 15:04:35 -07:00
Antoine Mercadal 007ca4c6b0 Merge pull request #2336 from cpasslack/cpasslack/corruptDecimalNumberAfterDecodingFix
Fixed: Encoding a [CPDecimalNumber zero] causes a corrupt CPDecimalNumbe...
2015-03-31 11:25:20 -07:00
Martin Carlberg b3dfce7b5a Fixed: Compared the rects minimum x value with it self instead of the visible minimum x value. Also fixed the test case to catch this. 2015-03-31 17:30:57 +02:00
cacaodev c75f1685c5 _CPObjectAnimator & CPViewAnimator
Make subclassing easier.
For a specific animator, can choose the implementation to invoke by
subclassing - (id) forwardingTargetForSelector:

The pattern for the animator class, if no -(id)animator is implemented,
is now <TargetClass>Animator by default and it searches for a
<TargetSuperClass>Animator if necessary.

NEW: Added support for CPAnimationTriggerOrderIn|Out animated key.
2015-03-31 00:33:28 +02:00
cacaodev db5b103ab3 Merge remote-tracking branch 'upstream/master' into CPAnimationContext 2015-03-30 22:20:46 +02:00
Alexander Ljungberg 1925b7b324 Merge branch 'refs/heads/0.9.8' 2015-03-29 13:39:28 +01:00
Alexander Ljungberg d39bcfb7bd Tests: new nil exception test for CPDictionary. 2015-03-29 13:16:51 +01:00
Alexander Ljungberg c7770c37d0 New: throw an exception on nil CPDictionary keys and values.
Previously only a deprecation warning was issued. This warning was scheduled to be removed in Cappuccino 0.9.8, this release.
2015-03-29 13:02:55 +01:00
Alexander Ljungberg ca2fb81247 This will be Cappuccino 0.9.8. 2015-03-29 12:45:10 +01:00
daboe01 b2f1c9e832 moved _CPCaret to the end 2015-03-28 21:06:28 +01:00
daboe01 cff4eebb74 caret refactoring + delegate notification fix 2015-03-28 20:59:17 +01:00
daboe01 a3aab5aeca prevent delegate related memory leaks 2015-03-28 19:59:33 +01:00
daboe01 63e5d8f7ea acceptsFirstResponder cleanup 2015-03-28 19:39:03 +01:00
daboe01 e4df7b10f6 _backgroundColor' is already declared for class CPText in superclass CPView 2015-03-28 15:27:37 +01:00
daboe01 f39a1e7d03 move inherited properties to CPText 2015-03-28 15:22:52 +01:00
daboe01 a473f6aa16 richTextPropery 2015-03-28 15:05:58 +01:00
daboe01 6907c24690 fix access to editable propery 2015-03-28 15:01:33 +01:00
daboe01 ef3d8a9277 fix access to selectable property 2015-03-28 14:59:13 +01:00
cacaodev 1a183b7f17 Merge remote-tracking branch 'upstream/master' into CPAnimationContext 2015-03-27 21:56:08 +01:00
cacaodev 88f7b30128 NEW: +tabViewItemWithViewController: 2015-03-27 14:38:59 +01:00
cacaodev 4b38389dc8 Update Manual test 2015-03-27 14:38:58 +01:00
cacaodev 865a45044f NEW: bindings support 2015-03-27 14:38:58 +01:00
cacaodev 7378d06bfd FIXED: CPTabView -insertTabViewItem:atIndex:
Before this commit, the tabViewItems and the segments were 2 different
collections. Any indexed change in the tabViewItems asked to re-sync
the segments making it difficult to maintain any persistent state. Now
the tabView items are the segments content.

Also fixed the selection update when items are removed.
See CPTabViewTest.j  and manual test Manual/CPTabViewNib/
2015-03-27 14:27:46 +01:00
Alexandre Wilhelm 55e19de8a1 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2015-03-26 10:41:33 -07:00
Alexandre Wilhelm 4d7cb06481 Fixed: changed theme attributes image-search-left-margin image-cancel-right-margin by image-search-inset and image-cancel-inset in CPSearchField 2015-03-26 10:41:21 -07:00
cacaodev 7179a2995d CPTabViewItem image support 2015-03-24 23:42:44 +01:00
cacaodev 2b853df75b Merge pull request #2337 from cacaodev/CPSegmentedControl-setSelectedSegment
FIXED: CPSegmentedControl -setSelectedSegment:-1
2015-03-24 23:21:54 +01:00
daboe01 ae6bcc2987 improve critically low performance in safari
by means of caching cheap sizing data.
2015-03-24 09:59:58 +01:00
Alexandre Wilhelm ed61e5c7f7 Added test file CPTextViewTest.j 2015-03-23 20:56:40 -07:00
Alexandre Wilhelm 3581ac5ebd Fixed: nib2cib with CPTextView works. Editable, Selectable, RichText, StringValue, BackgroundColor, InsertionPointColor works 2015-03-23 14:50:43 -07:00
Alexandre Wilhelm 1f369b47d7 Added hierarchy for nib2cib of a CPTextView. NSTextViewSharedData is a object to retrieve attributes of the CPTextView 2015-03-23 13:06:22 -07:00
Christian Passlack bb9049bef4 Code-styling to match official style-guide. 2015-03-23 20:45:31 +01:00
Christian Passlack 94f15aba40 Updated Test-Cases of CPNumberFormater and CPTextfield because of the
changes for fix #2332. The test-cased failed, because now a
a CPDecimalNumber has a different UID compared to a CPNumber with the same
value. That means isEqual: will return false. In the test-cases the formatter now
generates CPNumbers to make the two Numbers compareable via isEqual.
2015-03-23 20:30:01 +01:00
Alexandre Wilhelm b16b8388ef Merge pull request #2335 from t00f/cpsearchfield_update_frame
Fixed: CPSearchField alignment from nib2cib
2015-03-23 11:39:04 -07:00
Alexandre Wilhelm b1e89e7904 New: added themeAttributes image-search-left-margin and image-cancel-right-margin in CPSearchField 2015-03-23 10:45:43 -07:00
Christophe Serafin f48e2f3b18 Fixed alignement content-inset and images for control size small and mini. 2015-03-20 15:44:37 -07:00
cacaodev bd673a3f26 FIXED: CPSegmentedControl -setSelectedSegment:-1
previously, -setSelectedSegment:-1 was not visualy deselecting the
segments and selectedSegment was not set to -1.
2015-03-20 21:19:36 +01:00
Alexandre Wilhelm 51ec699649 Removed tmp files... 2015-03-20 12:23:38 -07:00
Alexandre Wilhelm ed6be510fb Fixed: first work on nib2cib for the CPTextView. The example does not crash anymore 2015-03-20 12:22:23 -07:00
Alexandre Wilhelm 55f05ba839 Fixed: warnings when compiling 2015-03-20 10:03:42 -07:00
Alexandre Wilhelm 17c9382a21 Merge remote-tracking branch 'origin' into NEW--CPTextView 2015-03-20 09:52:51 -07:00
Christian Passlack 43c0eda2be Fixed: Encoding a [CPDecimalNumber zero] causes a corrupt CPDecimalNumber after decoding
Previously, CPNumber and CPDecimalNumber shared the same method UID and CPNumberUIDs-Dictionary.
This leads to some unexpected errors for example a [CPDecimalNumber zero] which refers to itself after
decoding. CPDecimalNumber now overwrites the method UID and has its own UID-Dictionary.

Fixes #2332
2015-03-20 11:21:07 +01:00
Antoine Mercadal f2c5515317 Merge pull request #2334 from Dogild/ReloadDataTableViewRunLoop
Fixed: reloadData in CPTableView run the runLoop
2015-03-19 18:22:24 -07:00
Christophe Serafin c1441eb758 Updated Aristo and Aristo2 alignments 2015-03-18 18:46:26 -07:00
Alexandre Wilhelm cf92fb921d Fixed: aligment for mini and small CPComboBox were wrong 2015-03-18 13:57:42 -07:00
Christophe Serafin 559ca3e97b Fixed: CPSearchField alignment from nib2cib
CPSearchField were not properly aligned in Aristo2 theme.
This fix uses the nib2cib-adjustment-frame information to align it.
It also improve the Nib2CibAlignement test.
2015-03-18 08:26:26 -07:00
cacaodev 7c095175ab Merge pull request #2324 from cacaodev/CPSegmentedControl-indexed-mutation
CPSegmentedControl
FIXED: widthForSegment: and frameForSegment: now return the correct values when the segments sizeToFit
Added indexed accessors for the segment object
Improved tile performance
With manual and ojtest
2015-03-16 12:13:03 +01:00
Alexandre Wilhelm 3b2635014c Fixed: the developer need to perform the run loop to get some informations in CPTableView. Now, the run loop is performed by the tableview 2015-03-15 19:38:06 -07:00
cacaodev 755040444a Fixed selection updating again.
This time it’s right. CPSegmentedControl does in fact allow empty
selection (-1) in cocoa.
Updated ojtets.
2015-03-15 20:42:17 +01:00
Alexandre Wilhelm 59afb012b6 Fixed: make sure to lay out the tableView when calling the method editColumn:row:withEvent:select: 2015-03-14 16:18:22 -07:00
Alexandre Wilhelm 7d9a52301c Fixed: reloadData in CPTableView run the runLoop
Previously, when reloading a CPTableView the run loop was explicitly call to layout the tableView. This is not the case in Cocoa.
You can call several times the method reloadData and this will only lay out the tableView one time.
2015-03-14 14:25:04 -07:00
cacaodev 50a53181dc Merge remote-tracking branch 'origin/CPAnimationContext' into CPAnimationContext
Conflicts:
	AppKit/CoreAnimation/CPViewAnimator.j
	Tests/Manual/CPAnimatablePropertyContainerTest/Resources/MainMenu.cib
	Tests/Manual/CPAnimatablePropertyContainerTest/Resources/MainMenu.xib
2015-03-14 21:31:12 +01:00
cacaodev 36f6fec99f Merge remote-tracking branch 'upstream/master' into CPAnimationContext
Conflicts:
	AppKit/CPView.j
2015-03-14 21:18:18 +01:00
cacaodev 83eeb488f9 Remove xcodeproj 2015-03-14 20:14:19 +01:00
cacaodev 5394a35e1a NEW: add -tile : layout all segments
Refactor -tileWithSegment: that still accepts a control with zero
segments.
2015-03-14 20:09:35 +01:00
cacaodev 0cd68ff8f8 FIXED: selection update when segmentCount changes n->0 or 0->n
If the segment count is set to 0, the [self selectedSegment] now
correctly return -1 (like cocoa).
If the segment count is set to n from 0, the first segment is selected.
See manual test.
2015-03-14 20:02:43 +01:00
cacaodev e9ae8063db Allow nil completionFunction and fix fallback == nil 2015-03-13 18:52:05 +01:00
Martin Carlberg 1c4e23512b Merge pull request #2326 from mrcarlberg/duplicate_ivar_superclass
Duplicate ivar on superclass
2015-03-13 10:36:40 +01:00
Alexandre Wilhelm 51bdfa44b1 New: added the protocol CPScrollViewDelegate 2015-03-12 14:39:42 -07:00
Alexandre Wilhelm 98d0a397a3 Fixed: _clickedRow and _clickedColumn not updated as in correclty
Previously, the var clickedRow and clickedColumn were only updated with a doubleClick.
Now clickedRow and clickedColumn are updated in the scope of a trackMouse as in cocoa. Once the method stopTracking:at:mouseIsUp is called, clickedRow and clickedColumn are set to -1 again. This var can't be used outside a user event.
2015-03-11 10:18:21 -07:00
Antoine Mercadal 1dc060123d NEW: Closing a platform window will correctly close its main CPWindow
Previously, when closing a platform window using the browser close
button, the represented `CPWindow` was not correctly closed.

This patch ensure `-(void)close` is called correctly by using the DOM
`unload` event. Also, delegate method `- (void)windowWillClose:` is
correctly called.
2015-03-10 16:35:03 -07:00
Antoine Mercadal 14349cb583 Merge pull request #2240 from Dogild/PlatformOrderOUt
New: added method initWithWindow in CPPlatformWindow
2015-03-10 13:24:00 -07:00
Aparajita Fishman eca959034c Merge pull request #2330 from daboe01/fix-issue-1686
Clarification for CPTableColumn's binding documentation
2015-03-10 11:25:58 +13:00
cacaodev 9844550d6c Use the translate(x,y) property for frameOrigin animated keyPath
Also adds a startValue arg to the function translating Capp values to
css values (needed for translate because you translate the offset).
CPViewAnimator: when ensuing animations, separate the fallback (the
function executed when animation are not supported) and the completion
function executed when the animation ends.
Cleanup xib in manual test: removed controls.
2015-03-09 21:15:17 +01:00
cacaodev 82fcf08d84 Rename 2015-03-08 21:52:42 +01:00
daboe01 845a35a9b8 rewording 2015-03-08 20:49:01 +01:00
daboe01 0e4751ebee wording 2015-03-08 20:46:56 +01:00
daboe01 56badd44f3 updated binding documentation 2015-03-08 19:20:57 +01:00
daboe01 399b3fd198 documentation for the hash method 2015-03-08 19:03:35 +01:00
cacaodev 43a7ca7fe8 Style & doc
Added @ignore directive for private methods.
Changed a parameter naming
Moved some layout code from indexed accessors to public method.
Accessors should only deal with the model, not the layout.
2015-03-07 23:04:32 +01:00
cacaodev b951624ed3 Merge remote-tracking branch 'origin/CPAnimationContext' into CPAnimationContext
Conflicts:
	AppKit/CoreAnimation/CPAnimationContext.j
	AppKit/CoreAnimation/CPViewAnimator.j
2015-03-07 20:03:05 +01:00
cacaodev 1b21f2d1c7 CPView (Animation) : simplified CSS_DESCRIPTORS.
Now easiest to subclass and not much more verbose.
CPVIEW_PROPERTIES_DESCRIPTOR is, for a given CPView subclass, the
mapping between animated keypaths and css properties and between
animated values and css values.
2015-03-07 19:51:13 +01:00
cacaodev 43ea0effa2 Replace objj FrameUpdater with a js function.
Also uses the native function window.requestAnimationFrame();
Expected improvement: the effective redraws should now happen only when
needed.
browser support = same as css animations.
2015-03-07 19:45:06 +01:00
cacaodev 6df9b95dea Code style. NEW CPView -DOMElementForKeyPath:keyPath:
-DOMElementForKeyPath:keyPath returns the DOMElement animated by the
css Animation. This allow for an element different from the view
_DOMElement to be animated.
2015-03-07 19:38:48 +01:00
Antoine Mercadal 630aa53d98 Merge pull request #2321 from william57m/master
New: added the CPCache class
2015-03-05 18:08:18 -08:00
Antoine Mercadal 40c81b88d4 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2015-03-05 17:00:53 -08:00
Antoine Mercadal 027a317291 FIXED: Memory Leak with tooltips
Only populate the tooltips handler functions when necessary (when there is a tooltip and when the view is in a window) or clear them otherwise.

Tests in /Tests/AppKit/CPViewTest.j
2015-03-05 16:59:37 -08:00
Alexandre Wilhelm 81b538556d Fixed: removed unused var in CPScrollView.j 2015-03-04 13:01:32 -08:00
Alexandre Wilhelm 6aece1cf8c Fixed: changed default template for the generate ThemeDescriptor
Previously, the default template generated by capp gen for a new themeDescriptor project was not similar as the themeDescriptor of Aristo1 or 2.
This could confuse new developer who would like to create a new theme.
2015-03-03 22:50:39 -08:00
cacaodev cd7b9d31c9 Merge remote-tracking branch 'upstream/master' into CPAnimationContext 2015-03-03 23:03:10 +01:00
Martin Carlberg 03a6e6fc6a Fixed: Removed ivars that are already declared in superclass 2015-03-03 11:34:49 +01:00
Martin Carlberg 1d1aae03f3 Added: Test case for duplicate ivar in superclass 2015-03-03 11:33:50 +01:00
Martin Carlberg b47ad50d42 Fixed: Made the compiler manual test cases work again 2015-03-03 11:33:20 +01:00
Martin Carlberg a924fd0e7e Fixed: Generate compiler error when ivar is already declared in superclass 2015-03-03 11:32:18 +01:00
cacaodev 82ae908e6a Added Manual Test
Tests that widthForSegment: (the declared width) and frameForSegment:
(the effective frame) are disconnected.
Added a custom color for the divider.
2015-03-02 19:08:32 +01:00
Martin Carlberg 8e497e2a48 Fixed: Method scrollRectToVisible:(CGRect)aRect in CPView didn’t work correctly if aRect is larger then the visible rect.
If aRect is larger then the visible rect this method scrolled all they way to the opposite edge instead of the nearest.
2015-03-02 16:30:02 +01:00
daboe01 cbb4565a48 timer support for drag-scrolling 2015-03-01 21:16:49 +01:00
william57m 471fbee090 Formatting: code readability and tests improved 2015-03-01 13:05:22 -05:00
william57m d66de937d9 Formatting: to pass capp_lint and to respect Cappuccino's standards 2015-02-28 20:53:32 -05:00
cacaodev 3ea230fd17 Improved tests for segmented control
Added manual test showing fix for setLabel:forSegment for flexible
segments.
Added ojtest showing that the selection is preserved when a selected
segment is removed.
2015-02-27 13:33:11 +01:00
cacaodev 34bc571f80 FIXED: setSelected:forSegment:
Do not add to the themes array a reference to a deleted segment.
2015-02-27 11:47:42 +01:00
cacaodev db46804bfe NEW: -insertSegments:atIndexes: and -removeSegmentsAtIndexes:
These methods are not useful with the current public API but necessary
if we want to implement CPTabView insertion/deletion methods and the
CPContentBinding.
2015-02-27 11:47:22 +01:00
cacaodev 2bd0faac2e Update NSSegmentedControl.j (nib2cib) after the new titleWithChangedSegment: usage. 2015-02-27 11:47:21 +01:00
cacaodev a9a6e58d60 Simplified -tileWithChangedSegment:
Now tileWithChangedSegment: invalidates the frame of changed segments
and the following segments on the right. Then we just ask for the frame
of the last segment which will recompute all the invalidated frames and
give the total width of the container.
Added -intrinsicContentSize : the container size based on the sizes of
its segments.
2015-02-27 11:46:46 +01:00
william57m b40f980c62 New: added the CPCache class 2015-02-26 22:07:15 -05:00
cacaodev 12ac781ef8 FIXED: -widthForSegment: and - frameForSegment:
Previously, widthForSegment was returning the current width of a
segment.
Now we separate the 2 concepts: the segment width can only be set
explicitly with setWith:forSgment: or in IB. If the width is 0, it
means the actual frame sizeTofit. In this case, we compute lazily the
frame and frameForSegment: return the actual frame.
The frame is cached and can also be invalidate by setting it to a zero
frame, for example when the content of a segment changes and we need to
recompute it.
Use frameForSegment: in the code when we mean to get the real width as
opposed to the declared width.
2015-02-27 01:09:04 +01:00
cacaodev 8373ffbf10 Replace some direct ivar access with objj 2015-02-27 01:08:34 +01:00
cacaodev 0233dca884 FIXED: replace _segments[i] with [_segment objectAtIndex:i]
This will raise an out of bound exception if needed in the methods
whose  documentation says it should.
2015-02-26 15:28:16 +01:00
cacaodev c1a3162a54 FIXED: CPSegmentedControl uninitialized ivars 2015-02-26 15:28:15 +01:00
daboe01 fc2f5c3615 formatting 2015-02-26 05:55:04 +01:00
daboe01 3a5ac9df10 formatting 2015-02-26 05:53:37 +01:00
Alexandre Wilhelm 63f634af00 Merge pull request #2300 from ahankinson/fix-domserver-dead-code
Fixed: Remove unreachable code in CPDOMDisplayServer.h
2015-02-25 17:28:15 -08:00
Antoine Mercadal 9cb3eefdc4 Merge pull request #2319 from Dogild/TokenFieldkeyEquivalent
Fixed: CPApplication dispatch the event when having the auto complete menu of a CPTokenField opened
2015-02-25 11:34:44 -08:00
Antoine Mercadal 1c9e9da10f Merge pull request #2315 from Dogild/CPTableView-ViewAtColumn
New: Added method viewAtColumn:row:makeIfNecessary: in CPTableView
2015-02-25 11:31:36 -08:00
Antoine Mercadal 71c0ba63ca Merge pull request #2318 from cacaodev/CPTableView-columnbinding
FIXED: Exception when rows were removed in a table with binded columns.
2015-02-25 11:25:53 -08:00
Antoine Mercadal c04d3b2ace Merge pull request #2316 from Dogild/MethodSetNeedsLayout
New: added the method setNeedsLayout:
2015-02-25 11:23:45 -08:00
daboe01 e8497bb0cc typing attributes fix 2015-02-25 20:20:48 +01:00
Alexandre Wilhelm 3430349dd1 Fixed: CPApplication dispatch the event when having the auto complete menu of a CPTokenField opened
Previously, the CPApplication dispatched the current event when having the auto complete menu of a CPTokenField opened.
This occurs weird behavior. For instance when hitting enter on the menu and having a default button, the action of the button was triggered.
Now, the CPTokenField handles the key enter when the autocomplete menu is opened.
2015-02-25 10:16:56 -08:00
daboe01 fa6a5f75af fractional clicking support 2015-02-24 20:39:42 +01:00
daboe01 7b9eb4c87c color well font panel sync 2015-02-24 20:22:03 +01:00
cacaodev 808411bc0b FIXED: Exception when rows were removed in a table with binded columns.
Before this fix, the CPTableColumn binder was not correctly reloading
the table when the number of rows changed. Now we reload fully the
dataviews when the number of rows changes. If no rows are
inserted/deleted, there is an optimization: we just need to reload the
objectValues and leave the dataviews untouched.

With Test in Tests/AppKitCPTableViewTest.j
Fixes #2317
2015-02-24 16:15:20 +01:00
daboe01 c3ab510b57 fix copy paste of curly braces 2015-02-22 20:55:38 +01:00
Antoine Mercadal cbc653be37 Merge pull request #2313 from Dogild/UnionDistinct
New: added KVC operators unionOfObjects, distinctUnionOfObjects, unionOfArrays, distinctUnionOfArrays, distinctUnionOfSets
2015-02-21 11:38:26 -08:00
daboe01 e9efe5bbb7 fix cornercases 2015-02-21 20:01:53 +01:00
daboe01 a7c234b272 smart copy paste 2015-02-21 15:14:50 +01:00
Alexandre Wilhelm bb64d0dd54 New: added method needsLayout in CPView 2015-02-20 15:49:08 -08:00
Alexandre Wilhelm f82b478a77 New: added the method setNeedsLayout:
This PR adds the possibility to layout or not a CPView.
Previously, once setNeedsLayout was called on a CPView, it wasn't possible to cancel the layout of the view.
Now we can as in cocoa. The method setNeedsLayout will still work (it calls the method setNeedsLayout: with YES).

UnitTests in Tests/AppKit/CPViewTest.j
2015-02-20 14:36:27 -08:00
Alexandre Wilhelm 2028642efe Typo: removed console.error in CPTableView 2015-02-20 10:58:25 -08:00
Alexandre Wilhelm 9af9bd0c4c New: Added method viewAtColumn:row:makeIfNecessary: in CPTableView
This PR adds the method viewAtColumn:row:makeIfNecessary: in CPTableView.
This method first attempts to return an available view, which is generally in the visible area. If there is no available view, and makeIfNecessary is YES, a prepared temporary view is returned. If makeIfNecessary is NO, and the view is not available, nil will be returned.
An exception will be thrown if row is an invalid row index and if column is an invalid column index.
The returned result should generally not be held onto for longer than the current run loop cycle. Instead they should re-query the table view for the row view.

UnitTests in Tests/AppKit/CPTableViewTests.j
2015-02-20 10:54:45 -08:00
Alexandre Wilhelm 662bf83a88 Typo: type in _CPCollectionKVCOperators 2015-02-17 14:42:23 -08:00
Antoine Mercadal 2d474ccbda Merge pull request #2215 from Dogild/RetinaDisplayed
New: possibility to draw automatically in high DPI in canvas2D
2015-02-17 14:34:47 -08:00
Antoine Mercadal cec746d632 Merge pull request #2312 from cacaodev/CPTableView-issue2310
Fix for CPTableView issue #2310: wrong textcolor in unfocused table.
2015-02-17 14:32:45 -08:00
Alexandre Wilhelm 8371ac5b0d New: added KVC operators unionOfObjects, distinctUnionOfObjects, unionOfArrays, distinctUnionOfArrays, distinctUnionOfSets
This PR adds the KVC operators unionOfObjects, distinctUnionOfObjects, unionOfArrays, distinctUnionOfArrays, distinctUnionOfSets for array and set.

Unit-Tests Tests/Foundation/CPKVCArrayTest.j
Unit-Tests Tests/Foundation/CPSetTest.j
2015-02-17 00:14:48 -08:00
cacaodev f248788d14 Test for #2310 fix, CPTableView whitespace.
Note: It seems that CPThemeStateKeyWindow cannot be tested in the
console. A manual test with multiple windows and table views exists in
Manual/TableTest/OldTest/
2015-02-15 19:29:29 +01:00
cacaodev bf202f25dd Merge remote-tracking branch 'upstream/master' into CPTableView-issue2310 2015-02-15 18:44:32 +01:00
cacaodev 2d2472dbe9 FIXED: The firstResponder state of a table dataView was not correctly removed on dismiss. fixes #2310 2015-02-15 11:00:25 +01:00
Antoine Mercadal 3adfa3c2a8 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2015-02-12 16:01:59 -08:00
Antoine Mercadal bf05155c5e [FIXED] Merge issues
During a previous merge the call to ..willDisplayView:.. and
…willRemoveView:.. for delegate methods were removed from CPTableView
and CPOutlineView
2015-02-12 16:01:38 -08:00
Antoine Mercadal d50df6a6fc Merge pull request #2306 from Dogild/WarningAppkit
Fixed: compilation warning for NSTableHeaderView.j
2015-02-12 15:58:42 -08:00
Antoine Mercadal a2b38c8d05 Merge pull request #2307 from cacaodev/patch-1
CPTableView & CPTableHeaderView : style, typos, tabs.
2015-02-12 15:57:05 -08:00
Alexandre Wilhelm d546da8b5f Fixed: issue with scaling a view. The associated canvas now upadtes its size when having a zoom 2015-02-12 12:49:18 -08:00
Antoine Mercadal 7c60ffa88d Merge pull request #2311 from Dogild/PopoverPosition
Fixed: CPPopover position does not update each time
2015-02-11 12:36:34 -08:00
Alexandre Wilhelm 6b235ab083 Fixed: CPPopover position does not update each time
Previously, when the frame of a superview of the targetedView would update, the popover did not update its position.
Now it does by observing each frame of each superviews of the targetedView.
2015-02-10 22:58:03 -08:00
Antoine Mercadal 7c4cdef66d Merge pull request #2309 from Dogild/SegmentedControlNice
Fixed: CPSegmentedControl divider wrong color
2015-02-10 11:42:07 -08:00
Antoine Mercadal c0a2da443a Merge pull request #2308 from Dogild/InvalidDateCPDatePicker
Fixed: The CPDatePicker can take invalid date
2015-02-10 11:41:56 -08:00
Alexandre Wilhelm e53658759b Merge remote-tracking branch 'origin' into RetinaDisplayed 2015-02-09 18:03:29 -08:00
Alexandre Wilhelm 6dc4c1c03a Fixed: CPSegmentedControl divider wrong color
Previously, when clicking on segment, the divider did not have the expected color. Now they does.
2015-02-09 17:56:23 -08:00
Alexandre Wilhelm 818c3b6092 Typo in CPDatePicker 2015-02-09 16:46:08 -08:00
Alexandre Wilhelm 6e5dee13e1 Fixed: The CPDatePicker can take invalid date
Previously, the CPDatePicker could get an invalid javascript date.
Now it will raise an exception when getting an invalidate date.
2015-02-09 16:44:59 -08:00
Alexandre Wilhelm cae78622f6 Fixed comiling warning for the class CPTableHeaderView 2015-02-08 22:36:25 -08:00
cacaodev c5db677663 Style, typos, tabs. 2015-02-08 21:07:27 +01:00
Alexandre Wilhelm c6942daf74 Fixed: compilation warning for NSTableHeaderView.j
Previously, there was a warning when compiling the file  NSTableHeaderView.j
2015-02-06 17:11:06 -08:00
Antoine Mercadal ea644a2293 Merge pull request #2301 from krodelin/fix-setValue_forKey
Fixed: Wrong value parameter in CPObjectController>>setValue:forKey:
2015-02-06 16:00:30 -08:00
Antoine Mercadal 01e69ce2b0 Merge pull request #2303 from cacaodev/check-box-theming
FIXED: The text color of a checkbox inside a selected table row was black
2015-02-06 16:00:11 -08:00
Antoine Mercadal 187a017c4d Merge pull request #2305 from Dogild/DuplicateTests
Fixed: Duplicate unit-tests
2015-02-06 15:58:27 -08:00
Antoine Mercadal f9ce1d17c8 Merge pull request #1892 from cacaodev/CPTableView-enumerateRows
CPTableView formatting and fixes [+1]
2015-02-06 15:52:36 -08:00
Antoine Mercadal ef4cd6a4a7 [NEW] --theme option for capp tool
This patch provides a new option to capp. You can do

```objj
capp gen [-f] [-l]  -T CustomTheme1 -T  CustomTheme2 MyProject
```
This will copy/symlink custom theme(s) from your CAPP_BUILD into the
current project’s `Resources` folder
2015-02-06 11:31:25 -08:00
Alexandre Wilhelm 6a1543cb82 Fixed: Duplicate unit-tests
Previously, some unit-tests had the same name in a test file. Now they have unique name.
2015-02-03 16:46:49 -08:00
cacaodev 80c8dcacb3 Code Style 2015-02-02 20:15:44 +01:00
cacaodev 0ad2dea722 Merge remote-tracking branch 'upstream/master' into CPAnimationContext 2015-01-30 22:35:01 +01:00
cacaodev dec3c45f6c Merge remote-tracking branch 'upstream/master' into CPAnimationContext 2015-01-29 15:09:08 +01:00
cacaodev 32a73ad4b9 FIXED: The text color of a checkbox inside a selected table row was black.\n Now it is white. the text-color values match the CPTextField values for the same theme states 2015-01-28 14:45:35 +01:00
cacaodev 452e03b894 FIXED: remove observation in -init. It was already handled in -viewWillMoveToWindow: 2015-01-27 22:01:32 +01:00
cacaodev 01bdddaee4 Merge 34c7ded (CPSelectionHighlightStyleNone and mouse click) 2015-01-27 13:09:33 +01:00
cacaodev f7c82b0920 FIXED : -startObservingFirstResponder: remaining renaming. 2015-01-27 13:04:45 +01:00
cacaodev 820eeb7752 _stopObservingFirstResponder -> _stopObservingFirstResponderForWindow: 2015-01-25 17:30:14 +01:00
cacaodev 2e25ef6f81 Merge remote-tracking branch 'upstream/master' into CPTableView-enumerateRows
Conflicts:
	AppKit/CPTableHeaderView.j
	AppKit/CPTableView.j
	Tests/AppKit/CPTableViewTest.j
2015-01-25 17:25:32 +01:00
Andrew Hankinson 5736d2c9cc Formatting: CPView
Previously CPView used "==" as an equality checker. This commit changes these to use "===" for consistency.
2015-01-22 13:31:04 -05:00
Udo Schneider 056a1f6a33 Fixed: Wrong value parameter in CPObjectController>>setValue:forKey: 2015-01-21 23:53:49 +01:00
Andrew Hankinson f96e211cd6 Tests: New tests for CPDOMDisplayServer 2015-01-20 16:19:24 -05:00
Andrew Hankinson 0d473cbe18 Formatting
Adjusting line lengths
2015-01-20 16:17:03 -05:00
Andrew Hankinson 95514b05ca Fixed: Remove unreachable code in CPDOMDisplayServer.h
The DOM_OPTIMIZATION flag was not used by any of the current compilers. This resulted in unreachable code in CPDOMDisplayServer.h. This commit removes this code.
2015-01-20 14:16:23 -05:00
Antoine Mercadal a2c0b47908 Merge pull request #2297 from daboe01/datepicker-date-constraint
Fixed: CPDatePicker does not grey out dates outside of minDate and maxDate
2015-01-15 13:44:23 -08:00
Antoine Mercadal f2528b5e9a Merge pull request #2296 from ahankinson/fixed-inconsistent-DOM-method
Fixed: Inconsistent naming of CPDOMDisplayServerSetStyleBackgroundSize
2015-01-15 11:38:32 -08:00
Antoine Mercadal 02f301dae0 Merge pull request #2294 from ahankinson/fix-issue-2293
Fixed: CPStepper class method returns `id` instead of CPStepper type
2015-01-15 11:37:38 -08:00
daboe01 6c47fc9023 disable forbidden dates 2015-01-15 20:28:46 +01:00
Andrew Hankinson f03adf727b Fixed: Inconsistent naming of CPDOMDisplayServerSetStyleBackgroundSize
Previously the method `CPDOMDisplayServerSetStyleBackgroundSize` was named `CPDomDisplayServerSetStyleBackgroundSize`, which was inconsistent with the names of all other similar methods in the CPDOMDisplayServer.h file. This commit fixes this and updates all instances of its use in CPView.j.
2015-01-15 13:59:19 -05:00
Andrew Hankinson 77684dfe31 Merge branch 'refs/heads/master' into fix-issue-2293 2015-01-15 12:00:09 -05:00
Antoine Mercadal ee688d9ae4 Merge pull request #2295 from Dogild/showCase-theme-collectionView
Fixed: showcase of themes are broken
2015-01-15 08:50:25 -08:00
Alexandre Wilhelm 9b16d3624e Fixed: showcase of themes are broken
Previously the showcase of the themes were broken. This was due to a change of the CPCollectionView, previously we used to use the delegate collectionViewDidChange. This delegate method has been removed. We now use an observer on the selectionIndexes.
2015-01-14 17:15:37 -08:00
Andrew Hankinson dc622a9bd5 Merge branch 'refs/heads/master' into NEW--CPTextView 2015-01-14 17:23:50 -05:00
Andrew Hankinson 2fc75be3dd Fixed: CPStepper class method returns id instead of CPStepper type
Previously the CPStepper class returned the `CPStepper` type instead of the `id` type. This caused warnings to be raised when initializing subclasses of CPStepper.

This commit fixes this issue by specifying the `id` type in the return values.

Fixes #2293
2015-01-14 17:12:16 -05:00
Antoine Mercadal eb883bc51e Merge pull request #2272 from ahankinson/new-fixed-with-credentials-cpurl
Rework of withCredentials, CPURLRequest, and CPURLConnection
2015-01-14 11:51:14 -08:00
Antoine Mercadal fdc5ed93fc Merge pull request #2252 from ahankinson/fix-doxygen-config
Fixed: Doxygen configuration
2015-01-13 18:48:12 -08:00
Antoine Mercadal 148960eecd Merge pull request #2292 from Dogild/xcodecapp-panel-top
New: option to active or not xCodeCapp when opening the errors & warnings panel
2015-01-13 18:45:16 -08:00
Antoine Mercadal 0265fc36fa Merge pull request #2289 from Dogild/CheckBoxSize
Fixed: wrong default size of CPCheckBox when using constructor checkBoxWithTitle
2015-01-13 18:44:45 -08:00
Antoine Mercadal f4c2a0a7f8 Merge pull request #2290 from Dogild/rule-editor-button-jolie
Fixed: Predicate button were blurred for Aristo2
2015-01-13 18:43:46 -08:00
Antoine Mercadal de3eb861ed Merge pull request #2291 from Dogild/WarningTravis
Fixed: warnings when compiling cappuccino
2015-01-13 18:43:03 -08:00
Alexandre Wilhelm f5b64b4958 Fixed: compiling issue for the class CPShadow 2015-01-13 14:11:16 -08:00
Alexandre Wilhelm 20eb59d9b6 Fixed: compiling warning for the class CPInvocation 2015-01-13 13:57:22 -08:00
Alexandre Wilhelm ca1bb8e634 Fixed: compiling warning for the function CGContextDrawImage 2015-01-13 13:24:43 -08:00
Alexandre Wilhelm 6213c098ce New: option to active or not xCodeCapp when opening the errors & warnings panel
Previously, when xCodeCapp opened the errors & warnings panel, xcc was always the new active application of the system.
Now an option is available in the preferences of xcc to disable this possibility. If disable the errors & warnings panel will open itself, but your favorite text editor will still be the active application of your system (you will keep the focus).
2015-01-13 13:11:35 -08:00
Alexandre Wilhelm 31023a1a71 Fixed: warnings when compiling cappuccino
Previously, some warnings were raised when compiling Cappuccino.
2015-01-13 11:46:53 -08:00
Alexandre Wilhelm b963b9547b Fixed: Predicate button were blurred for Aristo2
Previously, the button + and - of a CPPredicateEditor were blurred for Aristo2. Now they are nice and not blurred anymore.
This PR also add a second state for the button, the button will be darker when clicking on it.

Fixes #2183
2015-01-12 18:26:53 -08:00
Alexandre Wilhelm fa4c0af78d Fixed: wrong default size of CPCheckBox when using constructor checkBoxWithTitle
Previously, the default size of a CPCheckBox created with the constructor method checkBoxWithTitle did not take in account the size of the checkBox view.
Now when calculating the size of the control, it will firstly calculate the size of the title and then add the size of the checkBox view and the offset.

Fixes #2281
2015-01-12 16:56:43 -08:00
Andrew Hankinson ef0e0432a7 Fixed: Generate Treeview and activate search engine. 2015-01-09 17:05:03 -05:00
Andrew Hankinson d16f2b54fe Merge branch 'refs/heads/master' into fix-doxygen-config 2015-01-09 16:56:49 -05:00
Antoine Mercadal a3a3da309c Merge branch 'DateException' of https://github.com/Dogild/cappuccino into Dogild-DateException 2015-01-09 10:41:52 -08:00
Alexandre Wilhelm fa7b71cabe Fixed: cappuccino raised an exception when the param of constructor method of a CPDate are not a string. It now raises an warning 2015-01-09 08:37:29 -08:00
Antoine Mercadal d3490f6a2e Merge pull request #2243 from ahankinson/new-CFError-CPError
New: CFError and Updated CPError
2015-01-08 17:33:31 -08:00
Antoine Mercadal 82dc126952 Merge pull request #2264 from Dogild/MemoryLeakTableView
Fixed: Memory leak in CPTableView, CPScrollView [+1]
2015-01-08 17:25:20 -08:00
Antoine Mercadal 6f90e765d4 Merge pull request #2269 from mrcarlberg/self_ref
Fixed: @ref did not generate self.x for an ivar x
2015-01-08 17:25:02 -08:00
Antoine Mercadal b1382e8e89 Merge pull request #2287 from cacaodev/CPOperationQueue-cancelOperation
FIXED : a CPOperation marked as cancelled was never started
2015-01-08 17:24:11 -08:00
Antoine Mercadal 0fb739935f Merge pull request #2288 from daboe01/fixed-sheet-positioning-
Fixed: -showRelativeToRect:ofView:preferredEdge is ignoring the positioning rectangle
2015-01-08 17:23:47 -08:00
Alexandre Wilhelm e49a9f1f06 Fixed: targetRect was assigned too late when displaying a popoverWindow. This var can be used before ordering the popoverWindow 2015-01-06 15:28:14 -08:00
Alexandre Wilhelm 0f5dd99167 Fixed: the method setContentSize: of the CPPopover did not take care about the rect given when displaying the popover 2015-01-06 15:20:02 -08:00
daboe01 2f9f3db198 remove accidental code duplication 2015-01-03 10:21:28 +01:00
daboe01 00ebc265d8 make _targetRect an ivar 2015-01-02 19:35:09 +01:00
daboe01 5995b42872 fixed: popover positioning 2014-12-25 17:37:18 +01:00
Andrew Hankinson 9edb0abda0 Fixed: Styling is removed from build docset; Existing docset is removed before moving a new one. 2014-12-19 15:14:08 -05:00
Andrew Hankinson eaa966e72b Fixed: docset will generate docs before running 2014-12-19 15:13:16 -05:00
Andrew Hankinson a48df23252 New: Jake command for building a Docset
This commit adds the `docset` command to jake, to create a Docset from a doxygen build. It adds a shell script to the "support" directory that manages the build, and includes an Info.plist file that gets copied to the Docset when built.
2014-12-19 13:16:05 -05:00
Antoine Mercadal 3aa8eb9533 Merge pull request #2267 from ahankinson/fix-zindex-on-body
Fixed: z-index of -1000 caused a blank screen in some browsers [+1]
2014-12-19 08:19:47 -08:00
cacaodev 3ddd1d5f21 Added CPAnimatablePropertyContainer protocol 2014-12-19 16:01:49 +01:00
cacaodev ea15f0690c FIXED: compilers warnings in _CPObjectAnimator 2014-12-18 23:40:56 +01:00
Andrew Hankinson 8751ef7439 Fixed: Wrap drawRect method in #if/#endif 2014-12-18 11:04:08 -05:00
Andrew Hankinson 8c393e3144 Fixed: removed self on _DOMElement
Also a bit of formatting.
2014-12-18 09:47:00 -05:00
Andrew Hankinson a3ef2a43ac Fix file modes on CPTextView files
Was 755; now 644
2014-12-17 20:48:29 -05:00
Andrew Hankinson d2b3029f67 Fixed: Removed local declaration of _DOMElement 2014-12-17 20:47:12 -05:00
Andrew Hankinson 3e800ec7c8 Fixing type for DOM Elements
This commit fixes the type for DOM Elements in CPTextView.j
2014-12-17 12:40:24 -05:00
Andrew Hankinson 47d963b585 Fixed: Forward declaration of classes and types
Typedef in the ObjJ compiler introduced a few new warnings in this branch. This commit fixes the warnings by either declaring a type or forward-declaring a class.
2014-12-17 12:39:39 -05:00
Andrew Hankinson 397ae3407e Merge branch 'refs/heads/master' into NEW--CPTextView
Conflicts:
	AppKit/CPControl.j
2014-12-17 12:11:27 -05:00
cacaodev e407eeea40 FIXED : travis build 2014-12-16 21:43:19 +01:00
cacaodev 873232d560 FIXED : a CPOperation marked as cancelled was never started (CPOperation -start) when managed in a queue.
FIXED : After an operation started, either from a queue or explicitely, its finished property was never set to true.

This was causing dependant operation to never be executed.
After this commit, cancelled operations are started (but not executed) and correctly marked as finished.

Tests: CPOperationQueueTest and CPOperationTest for an operation managed by a queue or run explicitely.
2014-12-16 18:43:08 +01:00
Alexandre Wilhelm 47cced540e Style: added missing semi-colon in CPComboBox 2014-12-10 10:31:38 -08:00
Alexandre Wilhelm 5b4bddc2e0 Fixed: removed stupid console.error(coucou).... 2014-12-10 10:29:46 -08:00
Alexandre Wilhelm cd511da678 Fixed: used _implementedDelegateMethods in CPComboBox at the same time in CPTextField. This occured some issues with the delegate of the comboBoxDelegate when using textField delegate. This commit fix a issue about the row height of a an element in the list of the comboBox 2014-12-10 10:25:10 -08:00
Antoine Mercadal c4fbef2dd3 Merge pull request #2280 from Dogild/RuleEditorDragging
Fixed: crash when dragging the first line of a RuleEditor above the field Any
2014-12-09 19:37:29 -08:00
Alexandre Wilhelm 92b997fb78 Fixed: crash when dragging the first line of a RuleEditor above the field Any
Previously, cappuccino crashed when dragging the first line of a CPRuleEditor above the field any.
Now we make sure, we can not drag over this limit.
2014-12-09 19:04:12 -08:00
Antoine Mercadal 05d602c313 Merge pull request #2279 from Dogild/CPDatePickerEnter
Fixed: CPDatePicker takes key code CPReturnKeyCode all the time
2014-12-09 18:11:38 -08:00
Antoine Mercadal e1d92bd630 Merge pull request #2265 from Dogild/FocusRingDatePicker
Fixed: CPDatePicker doesn't have a focusRing when editing
2014-12-09 17:42:59 -08:00
Antoine Mercadal 373951a75e Merge pull request #2275 from Dogild/ButtonBarRemove
Fixed: button are always removed from the superview in layoutSubviews
2014-12-09 17:40:27 -08:00
Antoine Mercadal f17898d43d Merge pull request #2276 from Dogild/PopoverWindowObserver
Fixed: wrong option for the observer in _CPPopoverWindow
2014-12-09 17:39:52 -08:00
Antoine Mercadal 129eef79a3 Merge pull request #2274 from kevin-xu/vim-typedef-supported
New: Highlighted "@typedef" in VIM.
2014-12-09 17:39:11 -08:00
Antoine Mercadal e3988e7b84 Merge pull request #2277 from t00f/cppredicate_editor
Fix controls' heights that are displayed in CPPredicateEditor
2014-12-09 17:38:53 -08:00
Alexandre Wilhelm 9174338140 Fixed: CPDatePicker takes key code CPReturnKeyCode all the time
Previously, the CPDatePicker took the key code CPReturnKeyCode all the time. It means, the key event wasn't redistributed to the other component, for example a defaultButton in a window.

Now instead of returning YES, it returns [super performKeyEquivalent:anEvent]
2014-12-09 17:26:02 -08:00
cacaodev 3f9e2d5d39 CPAnimationContext : add typedef for HashTable 2014-12-09 22:36:37 +01:00
cacaodev 31449552d1 Merge remote-tracking branch 'upstream/master' into CPAnimationContext
Conflicts:
	AppKit/CPView.j
2014-12-09 22:35:29 +01:00
Andrew Hankinson 642dc36c41 Test: Cross Origin Manual Test
This commit adds a manual testing application for checking Cross-origin behaviour in different browsers. A README file included in this application provides details on how to run the tests.
2014-12-09 16:07:43 -05:00
Christophe Serafin 1016c3e22f Fix controls' heights that are displayed in CPPredicateEditor
Lastly, we removed the usage of max-size to enable some controls like CPTextField to have
a specific height. This may caused a CPTextField to have a wrong height.
As all controls in a CPPredicateEditor have a CPControlSize to small, we now force their height to the minimum size.
2014-12-08 18:54:35 -08:00
Alexandre Wilhelm b74d49b0bf Fixed: changed option for observer in _CPPopoverWindow.j 2014-12-08 15:54:25 -08:00
Alexandre Wilhelm 8b29369b7e Fixed: wrong option for the observer in _CPPopoverWindow
Previously the option of the observer in _CPPopoverWindow were set to 0, now it's set to CPKeyValueObservingOptionNew.

This PR fix also another issue, the popoverWindow registered the observer in the wrong order. It firstly observed the frame of the sender and then removed it directly. Now it register when ordering front the popover and remove it when closing the popover
2014-12-08 15:36:31 -08:00
Alexandre Wilhelm cb5fe06e58 Fixed: button are always removed from the superview in layoutSubviews
Previously, the button of a CPButtonBar were always removed and readded in the method layoutSubviews.
Now we only remove the hidden button.
2014-12-08 15:29:28 -08:00
kevin-xu 4ebb2baf06 New: Highlighted "@typedef" in VIM.
"@typedef" should be highlighted since #2254.
2014-12-08 22:00:02 +08:00
Alexandre Wilhelm 0f4a938dfc Fixed: attributes of the listDelegate of a CPComboBox could crash cappuccino 2014-12-05 09:50:49 -08:00
Andrew Hankinson 2a16fb5e09 Fixed: Properly initialize the _withCredentials variable in CPURLRequest 2014-12-04 18:11:38 -05:00
Andrew Hankinson c22cf71099 New: Added CPCopying protocol to CPURLRequest
Previously it was not possible to deep-copy a CPURLRequest, which meant that a CPURLConnection could not keep track of both the original and modified versions of a request.

This commit adds the copy method to CPURLRequest.
2014-12-04 18:11:10 -05:00
Andrew Hankinson c739718710 New: CPURLConnection now has the originalRequest and currentRequest methods
Previously, CPURLConnection did not implement the originalRequest and currentRequest methods (added to Cocoa in 10.8).

This commit adds this functionality.

NB: this is dependent on CPURLRequest having deep-copy capabilities to make a copy of the original request, which has been added in another commit on this pull request.
2014-12-04 18:08:54 -05:00
Andrew Hankinson 2db9fd9657 Test: Expand Unit tests for CPURLConnection
These tests cover new methods added to CPURLConnection
2014-12-04 18:06:02 -05:00
Andrew Hankinson 56b613ff8a Tests: Unit tests for CPURLRequest 2014-12-04 18:05:38 -05:00
Andrew Hankinson cd2e9e29d4 Tests: Fixed tests for withCredentials 2014-12-04 16:37:34 -05:00
Andrew Hankinson d1917db47e Fixed: Reworked withCredentials for XMLHTTPRequests
Previously, the withCredentials parameter was accessed primarily through the CPURLConnection, which gave limited access to changing the request before it was sent off.

This commit removes withCredentials from CPURLConnection and places it on CPURLRequest so that it may be more easily modified prior to sending the request. This also simplifies the logic in CPURLConnection for creating and establishing connections with credentials.

In this commit, all CFHTTPRequests are assumed to not use withCredentials unless they are explicitly set. Setting [aURLRequest withCredentials] will set the withCredentials property on the underlying XMLHTTPRequest prior to the connection being opened.
2014-12-04 15:29:52 -05:00
Andrew Hankinson 8024f6a804 Fixed: Move CPURLRequest methods to @accessors
This commit changes the simple getters/setters from CPURLRequest to use @accessors.
2014-12-04 15:12:11 -05:00
Alexandre Wilhelm 46a0ce8e98 Fixed: wrong condition when setting the frame in CPWindow when ordering a view 2014-12-04 11:06:50 -08:00
Alexandre Wilhelm c7ccff914f Test: added basic test for ordering window 2014-12-02 16:48:44 -08:00
Alexandre Wilhelm 8efb6f8808 Test: added unit test for registered notification for the tableView 2014-12-02 16:39:07 -08:00
Alexandre Wilhelm 006bf72c17 Test: added unit test for registered notification for the scrollView 2014-12-02 16:38:55 -08:00
Alexandre Wilhelm ec3af04f29 Test: added tests for CPComboBox 2014-12-02 16:38:17 -08:00
Alexandre Wilhelm b45399a045 Test: added class notificationHelper with the method registeredNotificationsForObserver 2014-12-02 16:37:57 -08:00
Alexandre Wilhelm 12ed70fec2 Fixed: notifications CPWindowDidResignKeyNotification and CPWindowDidBecomeKeyNotification were not registered for a firstresponder textField when ordered again a window 2014-12-02 16:37:02 -08:00
Alexandre Wilhelm c3ce0a61b6 Fixed: type with the method _windowWillBeAddedToTheDOM in CPWindow 2014-12-02 10:03:13 -08:00
Andrew Hankinson 526e0725d8 Merge branch 'new-CFError-CPError' of github.com:ahankinson/cappuccino into new-CFError-CPError 2014-12-02 12:51:25 -05:00
Andrew Hankinson 7e4e0567ef Merge branch 'refs/heads/master' into new-CFError-CPError 2014-12-02 12:51:14 -05:00
Martin Carlberg ee13978115 Fixed: @ref did not generate self.x for an ivar x 2014-12-02 13:54:02 +01:00
Alexandre Wilhelm f5d847f320 Style: style in CPWindow 2014-12-01 16:08:49 -08:00
Alexandre Wilhelm 1df0da7509 Fixed: method addObservers and removeObservers were not call all the time when ordering or not a window 2014-12-01 16:07:48 -08:00
Alexandre Wilhelm e4bfd0ef5e Fixed: issue when opening a popUpList of a CPComboBox. We now firstly open the panel and then we modify the content of the panel, this occured an issue with the rendering of the view 2014-12-01 16:07:13 -08:00
Alexandre Wilhelm 2e66601c19 Fixed: memory leak in CPComboBox
Previously, when assigning a listDelegate to a CPComboBox, we never deleted the observers added by this method. Now we add and delete these observers in the method addObservers and removeObservers.

This PR fix another issue. Previously, the behavior of the panel of the comboBox wasn't the same as the one in Cocoa. Now, when closing the panel, the hit view won't be the first responder as it was. Cocoa works like this as well.
2014-12-01 14:22:39 -08:00
Alexandre Wilhelm 2484fb85e9 Fixed: warning raised by the compiler due to unknown type in var declarations 2014-12-01 14:22:06 -08:00
daboe01 5f2fee5a99 redo support added 2014-11-29 18:57:05 +01:00
Alexander Ljungberg b2557c38dd Merge pull request #2266 from zittix/patch-2
Docs: fixed bootstrap.sh URL due to github URL change
2014-11-28 23:20:59 +00:00
Alexandre Wilhelm 56acbfc85c Fixed: change == to === on CPTextField when assigning a delegateo 2014-11-28 10:00:27 -08:00
Alexandre Wilhelm 77f962eed4 Style: removed comment in CPDatePicker 2014-11-28 09:58:44 -08:00
Andrew Hankinson 18a6ecc79a Fixed: z-index of -1000 caused a blank screen in some browsers
Previously, a z-index value of -1000 caused some browsers to not display certain UI elements correctly. Setting this value to 0 instead seems to fix this.

This commit changes the default value in the templates generated by `capp gen`.

Fixes #2232, Refs #2194
2014-11-27 11:22:40 -05:00
Mathieu Monney c3fc6a087a Fixed URL, wasn't the tagged released one. 2014-11-27 13:30:31 +01:00
Mathieu Monney 02a47dc7b9 FIXED bootstrap URL due to github URL change. 2014-11-27 13:25:29 +01:00
Alexandre Wilhelm 30413e6f8f Merged conflict in CPComboBox 2014-11-26 16:00:03 -08:00
Alexandre Wilhelm 6ed7354884 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2014-11-26 15:57:40 -08:00
Alexandre Wilhelm 94f89acc84 Fixed: memory leaks when using a delegate with a CPTextField 2014-11-26 15:56:10 -08:00
Alexandre Wilhelm 392a6cfbca Fixed: memory leak when using a delegate with a CPComboBox 2014-11-26 15:55:50 -08:00
Alexandre Wilhelm e03b6b3824 Fixed: _postDidResizeNotificationWithOldWidth does not exists anymore, replace by _didResizeTableColumn:tableColumn:oldWidht: 2014-11-26 15:18:39 -08:00
Alexandre Wilhelm 51940cea3d Fixed: leak memory with CPTableViews delegate 2014-11-26 15:05:22 -08:00
Antoine Mercadal 5ab346e5d1 Merge pull request #2254 from primalmotion/objj-typedef-and-ivar-checks
Objj typedef and ivar checks
2014-11-26 13:40:56 -08:00
Antoine Mercadal 243024e232 Fix broken tests due to new objj type checks 2014-11-26 13:12:39 -08:00
Alexandre Wilhelm e62fd4dc00 Merged of CPCLipView 2014-11-26 13:09:51 -08:00
Alexandre Wilhelm 547522a0a4 Fixed: Memory leak in CPClipView
Previously, the CPClipView registered the documentView to the notificationCenter as an observer to be notified when the frame/bounds of the  documentView change.

Now, we don't use the notificationCenter anymore. The class CPView send a message to its superview (when it's a clipView) when the frame or bounds change. This fix the memory leak of the CPClipView

Fixed #2264
2014-11-26 13:06:03 -08:00
Alexandre Wilhelm 4fd3ce606a Merge branch 'FocusRingDatePicker' of https://github.com/Dogild/cappuccino into FocusRingDatePicker 2014-11-26 12:04:39 -08:00
Alexandre Wilhelm ad364b6184 Fixed: CPDatePicker doesn't have a focusRing when editing
Previously, the CPDatePicker didn't have a focus ring when an user was editing it.
Now it does. It works for Aristo1 and Aristo2.

Test App in Tests/Manual/CPDatePickerTest

Fixed #2263
2014-11-26 12:04:00 -08:00
Alexandre Wilhelm 3269ba10ec Fixed: CPDatePicker doesn't have a focusRing when editing
Previously, the CPDatePicker didn't have a focus ring when an user was editing it.
Now it does. It works for Aristo1 and Aristo2.

Test App in Tests/Manual/CPDatePickerTest
2014-11-26 12:01:40 -08:00
Antoine Mercadal b0a7fe4079 Merge branch 'master' into objj-typedef-and-ivar-checks
+ fixed new warnings from master

Conflicts:
	Foundation/CPNotificationCenter.j
2014-11-26 12:00:34 -08:00
Antoine Mercadal 31afae71d1 Typos 2014-11-26 11:52:25 -08:00
Antoine Mercadal e7ae969c8e Merge pull request #2261 from Dogild/CPNotificationBlock
New: added method addObserverForName:object::usingBlock: in CPNotificationCenter
2014-11-26 11:51:17 -08:00
Alexandre Wilhelm fc5bb7417f Fixed: removed useless comment in CPClipView.j 2014-11-26 10:20:07 -08:00
Alexander Ljungberg 81e6c5c2fa Merge branch 'master' of github.com:cappuccino/cappuccino 2014-11-26 11:07:57 +00:00
Alexander Ljungberg e9f73cbb45 Minor formatting. 2014-11-26 11:07:48 +00:00
Alexandre Wilhelm b36cc8f1e9 Fixed: Memory leak in CPTableView, CPScrollView
Prevously, when removing a CPTableView or a CPScrollView, the CPNotificationCenter kept a reference of these observers in the notification center.

Now, the CPNotificationCenter does only have a observer when necessary.
2014-11-25 17:33:17 -08:00
Andrew Hankinson 6f6938deb7 Fixed: Updated Comment 2014-11-25 17:58:17 -05:00
Andrew Hankinson b63bddacb0 Merge branch 'new-CFError-CPError' of github.com:ahankinson/cappuccino into new-CFError-CPError 2014-11-25 17:56:34 -05:00
Andrew Hankinson b1d56924e6 Fixed: Formatting 2014-11-25 17:56:04 -05:00
Andrew Hankinson 85d80e7ca0 Merge branch 'refs/heads/master' into new-CFError-CPError 2014-11-25 17:51:41 -05:00
Alexandre Wilhelm d481d9cca5 Fixed: added queue to the method addObserverForName:(CPString)aNotificationName object:(id)anObject queue:(id)queue usingBlock:(Function)block 2014-11-20 23:38:53 -08:00
Alexandre Wilhelm fe25dbd872 New: added method addObserverForName:object::usingBlock: in CPNotificationCenter
Previously, the method addObserverForName:object::usingBlock: didn't exist in Cappuccino.
Now it does.

To observe, you need to use the method - (id <CPObject>)addObserverForName:(CPString)aNotificationName object:(id)anObject usingBlock:(Function)block

To unregister observations, you pass the object returned by this method to removeObserver:. You must invoke removeObserver: or removeObserver:name:object:.

Test /Tests/Foundation/CPNotificationCenterTest.j

Fixed #2259
2014-11-20 15:24:23 -08:00
Antoine Mercadal 0dcc645f22 Fix a missing @class declaration 2014-11-20 11:50:18 -08:00
Antoine Mercadal f3090e7827 Update test cases 2014-11-20 11:44:51 -08:00
Antoine Mercadal 37b9895878 Add check to ensure a @class declaration is not already defined as a type 2014-11-20 11:44:32 -08:00
Antoine Mercadal d5b4d66272 Merge pull request #2260 from Dogild/MenuCrash
Fixed: CPMenu crash when opening a menu with items and then opening the menu without items
2014-11-19 16:29:45 -08:00
Antoine Mercadal 653f706f1b Update README 2014-11-19 16:29:05 -08:00
Antoine Mercadal d106e6485b Add some manual test cases for objj output 2014-11-19 16:23:56 -08:00
Antoine Mercadal 460a60440a Correctly set the type of datasource in CPComboBox 2014-11-19 14:53:38 -08:00
Antoine Mercadal 9e66c699e1 FIXED: prevent to declare a type that is already declared as a class and vice-versa 2014-11-19 14:35:33 -08:00
Antoine Mercadal 86d2431925 CPWebScriptObject is a class, not a typedef 2014-11-19 14:34:52 -08:00
Alexandre Wilhelm d30659c37c Fixed: CPMenu crash when opening a menu with items and then opening the menu without items
Previously, when opening a menu with items and then opening another menu without items, Cappuccino simply crashed. Now it works !
2014-11-19 14:27:19 -08:00
Antoine Mercadal 1402133c32 Merge pull request #2164 from daboe01/fixed--CPTextField-&-Bindings--data-updates-even-though-no-editing-has-taken-place
Fixed: textField bindings delete data in case of multiple selection after tabbing out with no editing
2014-11-17 12:49:15 -08:00
Antoine Mercadal 5a99e18d7c Merge pull request #2238 from Dogild/ChainSheetWindow
Fixed: unable to chain sheet in a window
2014-11-17 12:42:15 -08:00
Antoine Mercadal afe326c1c1 Merge pull request #2258 from t00f/fix_controlSize_height
Fixed: Enable CPTextField to have a specific height
2014-11-17 12:40:37 -08:00
Antoine Mercadal e40612a032 Merge pull request #2255 from ahankinson/fix-default-jakefile
Fixed: Environment configuration in Jakefile templates
2014-11-17 12:39:43 -08:00
Antoine Mercadal 9c6cca7db6 Merge pull request #2257 from primalmotion/textfield-multiline-support
NEW: Support for multiline mode in CPTextField
2014-11-17 12:39:00 -08:00
Christophe Serafin a5283a26ab Fixed: Enable CPTextField to have a specific height
When setting controlSize, CPTextfield height was forced to min-size height.
Now we check that the frame size is between the min and the max size. It allows to constrain
a CPControl to have a fixed height by specifying a min-size equivalent to the maxsize.
In CPTextField case, we only have a min-size which enable us to have a specific size.

Changes has been made in Aristo2 only.
2014-11-14 13:49:33 -08:00
Antoine Mercadal e2020fa7f2 Add CPAltEnterTextAreaFeature checking. FF doesn't add a cariage return on textarea when doing alt+enter 2014-11-13 00:17:29 -08:00
Antoine Mercadal de3f6d3e82 Add manual test 2014-11-13 00:10:37 -08:00
Antoine Mercadal e7cde2ca5f Add support for usesMultilineMode and fix wraps and scrolls in nib2cib 2014-11-13 00:10:22 -08:00
Antoine Mercadal 0c7b2ae702 NEW: Support for multiline mode in CPTextField
This patch adds support for CPTextField with multiline content. It uses
a DOM textarea when needed, instead of DOM input.

It also disable the spellchecking, fixes a bug where the input element was not
correctly resized when the frame changed, and refactor some code
2014-11-12 23:59:46 -08:00
Andrew Hankinson 1c822901e2 Merge branch 'master' of git://github.com/cappuccino/cappuccino into new-CFError-CPError 2014-11-12 16:41:10 -05:00
Antoine Mercadal 0cafb3fac5 FIXED: CPViewController coming from a XIB could call viewDidLoad two times
This patch ensure that CPViewController is never calling viewDidLoad more than one time.
2014-11-10 17:03:34 -08:00
Antoine Mercadal d8718cc20f Merge pull request #2256 from Dogild/PlatformWindowKey
Fixed: CPWindow doesn't take the event when moving from another platformWindow
2014-11-07 16:26:15 -08:00
Antoine Mercadal c484e4afe5 Merge pull request #2244 from ahankinson/fix-deprecate-nativehost
Fixed: NativeHost is no longer built by default
2014-11-07 15:48:50 -08:00
Antoine Mercadal e155cca65e Merge pull request #2245 from ahankinson/fix-cleanup-tools-folder
Fixed: Removed old CI scripts from the Tools directory
2014-11-07 15:48:25 -08:00
Antoine Mercadal 5cad5b095a Merge pull request #2250 from Dogild/CursorContentInset
Fixed: text cursor for CPTextField class doesn't take content-inset in account
2014-11-07 15:46:39 -08:00
Antoine Mercadal 2dff805d40 Merge pull request #2251 from Dogild/ThemeComboBox
Fixed: wrong content-inset for CPComboBox
2014-11-07 15:45:46 -08:00
Antoine Mercadal 0afd65539f Merge pull request #2253 from Dogild/XcodeCappNotificationXib
Fixed: notification xib converted wasn't displayed anymore
2014-11-07 15:43:26 -08:00
Alexandre Wilhelm 664d5777fd Fixed: CPWindow doesn't take the event when moving from another platformWindow
Previously, when moving from platformWindow to another platformWindow, the targeted window didn't get the new event because the keyWindow of the application was still set to the other platformWindow.

This PR fixes another issue about opening panel in a platformWindow. When opening a panel in a platformWindow, cappuccino set the new key window to the wrong platformWindow.
2014-11-07 15:43:18 -08:00
Antoine Mercadal 9a307269ca FIXED: CPButtonBar was not removing old button set from the view
This patch ensure that when we are using setButtons: old buttons are actually removed from the superview
2014-11-07 14:25:35 -08:00
Alexandre Wilhelm ab2657b795 Fixed compilation warning in nib2cib 2014-11-06 15:11:58 -08:00
Antoine Mercadal 57d435b6db NEW: .gitignore ignores .tm_properties 2014-11-06 14:59:40 -08:00
Andrew Hankinson de2e77cc86 Adding userInfo error keys and documenting CPURLError.j 2014-11-06 17:23:27 -05:00
Alexandre Wilhelm ee5e22c574 Merged 2014-11-06 13:30:26 -08:00
Alexandre Wilhelm 1ce6a630d2 Fixed: warnings from objj were displayed several times 2014-11-06 13:29:16 -08:00
Antoine Mercadal aee89b1f63 NEW: option to define if the reporting window should stay on top 2014-11-06 12:21:23 -08:00
Antoine Mercadal 0f791be195 FIXED: config warning issues 2014-11-06 12:20:56 -08:00
Antoine Mercadal 45248bcb65 FIXED: ivars warning fixes 2014-11-06 12:17:58 -08:00
Andrew Hankinson 3c092f36cb Merge branch 'refs/heads/master' into new-CFError-CPError 2014-11-06 14:34:30 -05:00
Andrew Hankinson 9a5afb70b5 Fixed: Environment configuration in Jakefile templates
Previously the Jakefile template for the capp utility would emit a template where the "configuration" build environment parameter could have multiple values. At the head of the file, the configuration parameter could be an environment variable composed of ENV['CONFIG'], ENV['CONFIGURATION'] or ENV['c']. It would default to "Debug".

However, other locations in this file did not use the detected configuration, and only looked at ENV['CONFIGURATION'] for the environment variable.

This commit fixes this by using the detected configuration environment variable as the build environment.
2014-11-06 13:40:47 -05:00
Antoine Mercadal f9275a70af FIXED: New warnings reveleaded by ivar type checking
This patch fixes all new warnings
2014-11-06 10:17:05 -08:00
Antoine Mercadal 8ee443a43c NEW: @typedef and ivar type warning
Previously, ObjJ was ignoring unknow ivar type. This patch adds some check to ensure the type is either a known class, the current class
itself, a global, a basic JS type or a declared custom type.

In order to declare custom types, this patch introduces the @typedef keyword.

For instance, this will throw a warning:

```objj
@import <Foundation/Foundation.j>

@implementation MyClass: CPObject
{
    NUSuppaType mode;
}
@end
```

This will not:

```objj
@import <Foundation/Foundation.j>

@typedef NUSuppaType

@implementation NUMyClass: CPObject
{
     NUSuppaType mode;
}
@end
```

Declared types are shared accross all application, one type can only be declared once.
2014-11-06 10:10:05 -08:00
Alexandre Wilhelm 26223bb383 Fixed: include path doesn't take the absolute path 2014-11-06 09:52:40 -08:00
Alexandre Wilhelm ea0c5e291f Fixed: notification xib converted wasn't displayed anymore
Previously, the notification xib converted didn't show up. Now it does again.

This PR fixes another issue. Now when checking the the compilation issues, we only pass objj file to the command objj.
2014-11-06 09:38:30 -08:00
Andrew Hankinson 8ef7cacdda Fixed: Doxygen configuration
The Doxygen configuration file caused warnings to appear about obsolete tags. (The version of doxygen that the file was created for was 1.7.1, which was released in 2010.)

This commit uses the automatic doxygen updater (doxygen -u) to update it to a more recent version (1.8.7).

Additionally, this commit changes the .doxygen file to build a docset by default. The effect of this is to simply emit a `Makefile` in the output directory that can be further used to compile a docset. Parameters for the project publisher and name were added for this docset.
2014-11-06 12:34:18 -05:00
Antoine Mercadal 6d956c6138 Merge branch 'xCodeCapp3.2' of https://github.com/Dogild/cappuccino
Conflicts:
	Tools/XcodeCapp/XcodeCapp/ProcessSourceOperation.m
2014-11-05 19:06:06 -08:00
Antoine Mercadal b028e62731 Merge pull request #2248 from Dogild/OBJJEnhancement
New: new options for the command objj
2014-11-05 19:03:36 -08:00
Alexandre Wilhelm fc43ec8185 Fixed: wrong content-inset for CPComboBox
Previously, the content-inset of a CPComboBox was wrong, the text of the controller was over the popUPButton.
2014-11-05 14:26:34 -08:00
Alexandre Wilhelm 491b5dcd6f Fixed: text cursor for CPTextField class doesn't take content-inset in account
Previously, the text cursor of the CPTextField didn't take in account the content-inset. This raised issue with class as the CPComboBox, when the mouse was over the popUpButton, there was still the text cursor instead of the default one.

Now it works as in Cocoa.
2014-11-05 14:13:08 -08:00
Alexandre Wilhelm 02bbe0e6f5 Fixed: removed unused constant 2014-11-05 13:07:25 -08:00
Alexandre Wilhelm b827b7ffce New: xCodeCapp 3.2, command objj on each processing files or on the entire project
This pull requests adds a nice feature to xCodeCapp, now each time a fill is processing, xCodeCapp will launch the command objj to check the compilation issues. If it finds something, it will show them up on the classic error panel. This basically show import warnings, warnings you don't catch with your browser but only during the build of the application.
Objj is only launched if no errors was found after the first parsing (the parser which translate a file to objective-c).

This feature can be disabled on the preferences panel.

The menu has a new menu item "Check Compilation Issues". This action will launch objj on each files of the project and shows warnings and errors found.

The command objj will take automatically the OBJJ_INCLUDE_PATH in the index.html or index-debug.html. This options can be disabled in the preferences panel as well.

This PR only works with the PR #2248
2014-11-05 12:57:03 -08:00
Antoine Mercadal 459374db1c FIXED: Open the popup list as a child window in CPComboBox 2014-11-05 11:35:14 -08:00
Alexandre Wilhelm 97a65059e5 Fixed: when using the option -m, objj doesn't process every files in a error is raised, now it does 2014-11-05 11:12:17 -08:00
Antoine Mercadal d629f4b501 STYLE: Make previous patch cleaner 2014-11-05 11:11:03 -08:00
Antoine Mercadal f486c02b5e FIXED: Some APIs in CPComboBox were broken
Previously, when setting font, alignement, intercellSpacing or itemHeight, CPComboBox was assuming the listDelegate was already created.
This patch stores the values in CPComboBox if the listDelegate is not ready, and apply them once it is.
2014-11-05 10:55:19 -08:00
Antoine Mercadal d63669ac22 Merge pull request #2242 from primalmotion/disable-flag-for-commonjs-environement
NEW: Environment variable to disable CommonJS environement building
2014-11-04 18:08:22 -08:00
Alexandre Wilhelm ad82b0064a Fixed: added options -m for objj. This option allows you to make objj on several files 2014-11-04 13:23:54 -08:00
Alexandre Wilhelm 58f2d7117a Test: removed test for capp_lint 2014-11-03 21:22:31 -08:00
Alexandre Wilhelm 735b0f8593 Revert "Test: removed test for capp_lint"
This reverts commit 2bf012100a.
2014-11-03 21:22:01 -08:00
Alexandre Wilhelm 2bf012100a Test: removed test for capp_lint 2014-11-03 21:02:15 -08:00
Alexandre Wilhelm 7abcc42a42 Test: updated test ToolTest.j. Added tests for capp_lint and objj 2014-11-03 19:55:02 -08:00
Alexandre Wilhelm 4d77e7dd6b Fixed: fixed issue with press, capp and nib2cib with the new command objj 2014-11-03 19:54:35 -08:00
Alexandre Wilhelm 5678fe3b83 Fixed: change option -p in objj by bash concept -- 2014-11-03 18:12:47 -08:00
Alexandre Wilhelm f74888419c Fixed: part of the code missing after the previous commit refs #f21dcb8265d78683f984aa70014e1fb91a191ae7 2014-11-03 15:33:37 -08:00
Alexandre Wilhelm f21dcb8265 New: Added option --parser/-p to the command objj
Previously it wasn't possible to specify a custom parser for the command objj. This is needed for xCodeCapp
2014-11-03 15:25:47 -08:00
Alexandre Wilhelm 5bd07716eb New: new options for the command objj
This pull requests adds the following feature for the command objj:

- Option -h or --help to get the help of the command
- Option -I or --objj-include-paths to specify the frameworks to be used
- Possibility to pass several files to the command, for example objj AppController.j Test.j
2014-11-03 14:49:25 -08:00
cacaodev db63c91f99 Manual/TableTest/ViewBasedCib: show how to bind in code a CPTableCellView subview 2014-11-03 16:59:42 +01:00
Andrew Hankinson c37f0cfaa9 Fixed: Removed old CI scripts from the Tools directory
The Tools directory contained some old scripts for a previous continuous integration system. Since we're using Travis now, these are no longer needed.
2014-11-01 12:20:03 -04:00
Andrew Hankinson 9621d76faa Fixed: NativeHost is no longer built by default
This commit removes NativeHost from the 'Tools' Jakefile, ensuring that it does not get built by default.

Fixes #2239
2014-11-01 12:10:23 -04:00
Andrew Hankinson 32c252393a Fixed: Broken unit test 2014-11-01 10:01:56 -04:00
Andrew Hankinson ef5d1d6e58 Fixed: Wrong method included on CPError 2014-11-01 09:27:12 -04:00
Andrew Hankinson 660d36e001 Updating CPError tests 2014-11-01 09:26:37 -04:00
Andrew Hankinson 2cc67f23ab New: CPError unit test 2014-11-01 09:12:35 -04:00
Andrew Hankinson 6fe3054738 New: Unit tests for CFError methods 2014-11-01 09:04:57 -04:00
Andrew Hankinson 7811521c08 New: CPURLError definitions
This commit adds support for the CPURLError codes, with underlying support provided by Foundation's CFURL Errors.
2014-11-01 09:03:08 -04:00
Andrew Hankinson 96135c9875 New: Toll-free bridged CPError with CFError
This commit changes CPError to use a toll-free bridge with CFError, matching Cocoa's implementation of this class.
2014-11-01 09:01:42 -04:00
Andrew Hankinson 0038eab6ab Add CFError and CFNetworkErrors to the Includes list 2014-11-01 08:59:35 -04:00
Andrew Hankinson a34e8fbc9a Fixed method calls for global CFError methods 2014-11-01 08:59:10 -04:00
Andrew Hankinson 0399b3daed Fixed: Renamed CPCoder method to match language
Previously CPCoder had a method named "encodeValueOfObjCType" which is a misnomer.

This commit renames the method to "encodeValueOfObjJType."
2014-11-01 07:41:51 -04:00
Antoine Mercadal 64a15db791 NEW: Environment variable to disable CommonJS environement building
This patch allows user to disable the commonJS build phase by setting the system environement variable IGNORE_ENV_COMMONJS.

For instance `export IGNORE_ENV_COMMONJS=1`
2014-10-31 18:39:55 -07:00
Andrew Hankinson 49cb446f8b New: Initial commit of CFNetworkErrors file
This commit adds constants for CFURL Errors to enable cross-compatibility with the Cocoa CF and CPURL error reporting functions
2014-10-31 17:15:52 -04:00
Andrew Hankinson 82c32d7dee New: Implementation of the CoreFoundation CFError
This commit adds an implementation of the CoreFoundation CFError classes and functions.
2014-10-31 17:14:55 -04:00
Alexandre Wilhelm 9c87c36644 Fixed: refactoring of CPPlatformWindow 2014-10-30 18:08:03 -07:00
Alexandre Wilhelm be9f5ad951 Fixed: issue when initialize with contentRect in CPPlatformWindow 2014-10-30 18:04:20 -07:00
Alexandre Wilhelm d065a0cbc4 New: added method initWithWindow in CPPlatformWindow
The constructor initWithWindow: initializes a new CPPlatformWindow and set the given CPWindow as a fullPlatformWindow and bridgless window.
When using this constructor, you don't need to work with the platformWindow anymore, you can use the method orderFront: and orderOut: of the CPWindow to open or close the CPPlatformWindow.
You can also use the method setFrame: of the CPWindow to automatically change the contentRect of the CPPlatformWindow. In one word we assume that the given CPWindow and the CPPlatformWindow will have the same behavior. When not using the constructor initWithWindow:, the method setFrame: of the given CPWindow won't do anything to the CPPlateformWindow.

Test app in Tests/Manual/CPPlatformWindow/
2014-10-30 17:35:09 -07:00
Alexandre Wilhelm 02dfa638ca Fixed: orderOut on a fullPlatformWindow doesn't close the parent platformWindow
Previously, when calling the method orderOut: on the full platform window of a CPPlatformWindow, cappuccino didn't close the parent CPPlatformWindow. When he does, this only works if the parent platformWindow is not the primary platform.

Test app in Tests/Manual/CPPlatformWindow/
2014-10-30 15:59:15 -07:00
Andrew Hankinson bd71e779c3 Merge branch 'refs/heads/master' into NEW--CPTextView 2014-10-30 14:35:47 -04:00
Alexandre Wilhelm bfd0ceac53 Typo: becauwe instead of because 2014-10-29 21:50:46 -07:00
Alexandre Wilhelm ba20936c17 Fixed: unable to chain sheet in a window
Previously when chaining sheet on the same window, Cappuccino crashed.
Now chaining a sheet in the delegate method of the method endSheet: will open the next sheet.

Now when opening a sheet, we check if another sheet is currently closing. If yes, we wait till we get the notification of the closing of the previous sheet. And then we open the next sheet.

Fixed #2159

Test app in Tests/Manual/AttachedSheet2/SheetWindowController.j
2014-10-29 15:04:55 -07:00
Antoine Mercadal 4b058a8c56 Merge pull request #2150 from daboe01/fix-cpcollectionview-height
FIXED: CPCollectionView height is too low [+1]
2014-10-28 16:23:50 -07:00
Antoine Mercadal 49ba0cab27 Merge pull request #2236 from Dogild/CPDatePickerTextDragged
New: possibility to drag in a textual CPDatePicker
2014-10-28 16:23:08 -07:00
Antoine Mercadal b9c4f888b9 Merge pull request #2235 from Dogild/CPTextFieldResetCursor
Fixed: cursor of CPTextField is not updated to default
2014-10-28 16:22:34 -07:00
Alexandre Wilhelm 09e3c5ecfc New: possibility to drag in a textual CPDatePicker
Previously it wasn't possible to update the selected element of a textual CPDatePicker when dragging.
Now we can as in Cocoa.
2014-10-28 13:31:27 -07:00
Alexandre Wilhelm b180f06c2a Fixed: cursor of CPTextField is not updated to default
Previously, when changing the mode of the CPTextField from editable to non-editable, the cursor wasn't set to default. Now it does.
2014-10-28 11:19:49 -07:00
Antoine Mercadal 90345addce Merge pull request #2234 from ahankinson/fix-nib2cib-secure-field-size
Fixed: CPSecureTextField size was not calculated correctly in nib2cib.
2014-10-27 13:51:53 -07:00
Antoine Mercadal 328172cfeb Merge pull request #2230 from Dogild/TableViewBezeledTextField
Fixed: bezeled is set to yes when making a right click on a non-selectable CPTextField in a cell of a CPTableView
2014-10-27 13:51:00 -07:00
Antoine Mercadal a75e5d914c Merge pull request #2233 from Dogild/cursorTextField
Fixed: arrow cursor when the cursor is hover a CPTextField
2014-10-27 13:50:38 -07:00
Andrew Hankinson a783479306 Fixed: CPSecureTextField size was not calculated correctly in nib2cib.
Previously, the Secure Text Field size was slightly smaller when placed using Interface Builder.

This commit adjusts the size in nib2cib by ensuring CPTextField _adjustNib2CibSize is called on CPSecureTextField.
2014-10-27 14:47:12 -04:00
Alexandre Wilhelm ecb557daa5 Fixed: optimization about setting the good cursor for a CPTextField 2014-10-27 10:09:33 -07:00
Alexandre Wilhelm d5e811f9f1 Fixed: exception descriptions in CPDate did not countain all of the needed informations 2014-10-26 21:27:10 -07:00
Alexandre Wilhelm 3e5a6986f9 Fixed: arrow cursor when the cursor is hover a CPTextField
Previously, when the cursor was hover a CPTextField the cursor was an arrow till we selected the textField.
Now when the cursor is hover a CPTextField, and if this textField is enabled and editable or selectable we show the selecting cursor. This is the default behavior in Cocoa as well.

Updated manual test Tests/Manual/CPTextField/
2014-10-24 23:26:48 -07:00
Antoine Mercadal 8e346f18bf Merge pull request #2231 from Dogild/TableViewFirstResponderNoneStyle
Fixed: hitTest method returns the wrong view in the CPTableView when the  selectionStyle is set to CPTableViewSelectionHighlightStyleNone
2014-10-24 14:47:41 -07:00
Alexandre Wilhelm 34c7dededf Fixed: hitTest method returns the wrong view in the CPTableView when the selectionStyle is set to CPTableViewSelectionHighlightStyleNone
Previously, when having a CPTableView with a selectionStyle set to CPTableViewSelectionHighlightStyleNone, we needed two clicks to be able to select or click on a control of the cell. Now we only need one click as in Cocoa.

This is fixed by changing the method hitTest and returning the good view which can become the firstResponder.
2014-10-24 14:06:42 -07:00
Alexandre Wilhelm e56cc85e96 Fixed: bezeled is set to yes when making a right click on a non-selectable CPTextField in a cell of a CPTableView
Previously, when making a right click on a non-selectable CPTextField which is contained in a dataView of a CPTableView set the bezel attribute to yes.

Now, when making this things, Cappuccino will check if the CPTextField if editable or not.
2014-10-23 16:24:04 -07:00
Antoine Mercadal 8d660ff386 Merge pull request #2226 from Dogild/SegementedControlFixed
Fixed: CPSegmentedControl doesn't support small and mini control
2014-10-23 13:50:40 -07:00
Antoine Mercadal 2e3c658bc8 Merge pull request #2229 from Dogild/WindowCloseFirstResponder
Fixed: CPWindow keeps a reference of its firstResponder when closing a window
2014-10-23 12:55:08 -07:00
Alexandre Wilhelm 7af50c3951 Fixed: style in CPSegmentedControl 2014-10-23 12:53:10 -07:00
Antoine Mercadal 0bbada27f3 Merge pull request #2228 from Dogild/unfocusedSelectionGradientColorsProto
Fixed: prototype of method unfocusedSelectionGradientColors is void
2014-10-23 12:01:27 -07:00
Alexandre Wilhelm fcd2b778ea Fixed: CPWindow keeps a reference of its firstResponder when closing a window
Previously, when closing a CPWindow, the window kept a reference of the firstResponder. This things raised an issue when opening a window again and asking the window to make the first responder to the same element as the one we had.

Now when closing a window, the window will update its firstResponder to nil.
2014-10-23 11:53:46 -07:00
Alexandre Wilhelm cbef08eeff Fixed: prototype of method unfocusedSelectionGradientColors is void
Previously the prototype method of unfocusedSelectionGradientColors as void, now it's CPColor
2014-10-23 10:59:54 -07:00
Alexandre Wilhelm 6d3f430b24 Fixed: constructor of CPDate can take string param
Previously, when making a CPDate with some constructors, we could pass a string or nil to create a date. For example it was allowed to do var date = [CPDate dateWithTimeIntervalSince1970:"10"];

Now this is not possible anymore and it works like in Cocoa, only number are authorized.
2014-10-22 17:27:46 -07:00
Alexandre Wilhelm e4516c19d3 Fixed: CPSegmentedControl doesn't support small and mini control
Previously, when changing the controlSize of a CPSegmentedControl, Cappuccino didn't have the theme to do that.
Now, Cappuccino supports the controlSize small and mini. Aristo and Aristo2 have new attributes for that.
The attribute theme "default-height" has been replaced by "min-size" and "max-size" (used everywhere else in Cappuccino).
The CPSegmentedControl has now the theme attribute "nib2cib-adjustment-frame".

This pull request fixed alignment issue when adding a CPSegmentedControl from xCode. In the method initWithCode, we didn't care about the divider thickness, now we do. This same method will also add leftovers pixel to have exactly the same size as in xCode. Leftovers pixels are here because FLOOR operation and size of the font.

Manual test in Tests/Manual/CPSegmentedControlTest
Manual test in Tests/Manual/Nib2CibAlignment
2014-10-22 15:29:40 -07:00
Antoine Mercadal 8eb52f9a88 FIXED: Previous commit about explicitely define the observing options broke the abolity to hide buttons in CPButtonBar
This patch ensure to correctly set the options
2014-10-20 19:36:48 -07:00
Antoine Mercadal f2956670cd Merge pull request #2224 from mrcarlberg/kvo_honor_options_when_creating_change_dictionary
KVO now honor options when creating change dictionary
2014-10-20 18:42:09 -07:00
daboe01 18d83b8c50 fix range exception when smart-cutting last word 2014-10-20 18:51:26 +02:00
Martin Carlberg 5b7afd72e3 Fixed: Test cases now use correct options for KVO change dictionaries 2014-10-09 19:30:05 +02:00
Martin Carlberg 643566bbfd Honor options when creating KVO change dictionary 2014-10-09 19:27:57 +02:00
Martin Carlberg 5e0e61b7e5 Don’t create old or new values in KVO change dictionary when doing bindings 2014-10-09 19:25:56 +02:00
Antoine Mercadal 608480c1d2 FIXED: popover window was not trapping next mouse event if delegate responds no to popoverShouldClose:
This patch fixes that by automatically trapping next mouse event if after a performClose, the popover is still visible
2014-10-01 14:48:47 -07:00
Antoine Mercadal 5979baa874 FIXED: - (BOOL)popoverShouldClose: was not called in transient and semi-transient mode
Previously, handlers of events that could make the popover to close were not calling CPPopover's performClose:. This patch ensure performClose: is called, and so delegates are consulted if the popover can be closed or not
2014-10-01 14:17:39 -07:00
cacaodev fc2e16dd4e Merge remote-tracking branch 'upstream/master' into CPTableView-enumerateRows
Conflicts:
	AppKit/CPTableView.j
2014-10-01 14:11:57 +02:00
Antoine Mercadal 73a2823d0b Merge pull request #2213 from mrcarlberg/error_cannot_find_protocol_declaration
Fixed: When the compiler can't find a protocol in a class declaration
2014-09-30 16:56:36 -07:00
Antoine Mercadal 804ffb826d Merge pull request #2219 from kevin-xu/narwhal.local.conf-fixed
Fixed: It cannot execute the "jake" commands correctly in the Cappuccino...
2014-09-30 16:55:57 -07:00
Antoine Mercadal 4bcbe577c6 Merge pull request #2172 from daboe01/Fixed--activateIgnoringOtherApps
Fixed: activateIgnoringOtherApps:shouldIgnoreOthe... missed call to _didBecomeActive
2014-09-30 16:55:27 -07:00
Antoine Mercadal 2b1b858776 Merge pull request #2221 from mrcarlberg/no_line_information_for_errors_on_line_zero
Fixed: No line information for compiler errors on the first line of a file
2014-09-30 16:52:25 -07:00
Antoine Mercadal 8089f52744 Merge pull request #2214 from kevin-xu/kevin-xu-branch
Fixed: objj.vim is too old and has some bugs.
2014-09-30 16:51:36 -07:00
Antoine Mercadal 3aaa887d68 Merge pull request #2223 from Dogild/InstanceCPTableDrawView
Fixed: Several views of _CPTableDrawView created when encoding and decoding a CPTableView
2014-09-30 16:50:21 -07:00
Alexandre Wilhelm b617d60b60 Fixed: Several views of _CPTableDrawView created when encoding and decoding a CPTableView
Previously, when encoding and decoding a CPTableView, the tableView had several _CPTableDrawView (in the subviews).
Now when encoding, we make sure to remove _CPTableDrawView from its superview.
2014-09-30 15:28:26 -07:00
Antoine Mercadal 321a5533df Merge pull request #2222 from Dogild/FirstResponderWindow
Fixed: firstResponder is lost when adding a firstResponder view to the same window
2014-09-30 10:42:46 -07:00
Alexandre Wilhelm 921fcbdcd0 Fixed: firstResponder is lost when adding a firstResponder view to the same window
Previously, when adding a view (which is the firstResponder of the window) to the same window, the firstResponder was set to nil.
Now it keeps the same firstResponder.
2014-09-29 19:19:17 -07:00
kevin-xu 06d0357f74 Fixed: objj.vim is too old and has some bugs.
objj.vim cannot highlight much syntax correctly, and it should be updated. I've modified objc.vim to objj.vim which reads javascript.vim in the beginning, and now it looks good. Because javascript.vim & c.vim must be loaded into objj.vim, so they should also be committed.

Fixes #2211
2014-09-28 21:17:44 -07:00
Martin Carlberg 2f7681f881 Fixed: No line information was provided for compiler errors on the first line of a file 2014-09-26 13:28:44 +02:00
cacaodev e156badef6 FIXED: After a column removal, columns were not at the right place and non exposed views from the removed column were not removed 2014-09-25 23:14:54 +02:00
cacaodev ae6d379cce Improve TestTableColumn manual test to expose a bug when resizing after a column remove 2014-09-25 23:12:25 +02:00
kevin-xu a822ec729a Fixed: It cannot execute the "jake" commands correctly in the Cappuccino repository directory when it's not the Apple OS.
When running the "jake" commands in the repository directory, it would print:

$ jake --help
narwhal/packages/narwhal-jsc/bin/narwhal-jsc: line 33: narwhal/packages/narwhal-jsc/bin/narwhal-jscore: No such file or directory

Now, it will print:

$ pwd
/home/kevin/workspace/Cappuccino
$ jake --help
Usage: jake [OPTIONS] targets...
-f --jakefile FILE: Use FILE as the jakefile.
-T --tasks: Display the tasks with descriptions, then exit.
-D --describe: Describe the tasks then exit.
-P --prereqs: Display the tasks and dependencies, then exit.
	-v --verbose: Log message to standard output.
-h --help: displays usage information (final option)

Fixes #2181
2014-09-24 21:33:31 -07:00
Antoine Mercadal 38370c7f2e Merge pull request #2203 from sbalay/dev
Add support to diacritic insensitive search in CPString rangeOfString:options:range: method
2014-09-24 12:37:57 -07:00
Antoine Mercadal 37f65eb3dd Merge pull request #2194 from daboe01/div-1-fix
Fixed: divs with negative z-indices are causing display issues in some versions of chrome.
2014-09-24 12:34:13 -07:00
Antoine Mercadal 9347ce2ede Merge pull request #2202 from RoosterDragon/master
Fixed: CPBinder unbindAllForObject did not work.
2014-09-24 12:33:11 -07:00
Antoine Mercadal c4a839f47a Merge pull request #2218 from RoosterDragon/ImageView-leak
Fixed: CPImageView no longer leaks due to image load notification.
2014-09-24 12:30:43 -07:00
Antoine Mercadal 43f7dcd08f Merge pull request #2204 from Dogild/CPDatePicker-CPTableView
Fixed: CPDatePicker in a CPTableView wrong behavior
2014-09-24 12:27:04 -07:00
Antoine Mercadal 71bfe4dd44 Merge pull request #2176 from Dogild/CPView-addSubview
Fixed: Methods viewDidMoveToSuperview viewDidMoveToWindow viewWillMoveToSuperview viewWillMoveToWindow not called as in Cocoa
2014-09-24 12:22:07 -07:00
Antoine Mercadal 5bc44e7190 Merge pull request #2210 from Dogild/CPDatePicker-action
Fixed: CPDatePicker send an action with the methods setObjectValue: and setDateValue: [+1]
2014-09-24 12:04:13 -07:00
Antoine Mercadal 84c1b92fdf Merge pull request #2207 from cacaodev/bindings-issue#2199
Fix bindings memory leak, avoid incompatible bindings
2014-09-24 11:57:26 -07:00
Alexandre Wilhelm be6e222d8d Fixed: memory leak in CPColorWell 2014-09-24 10:14:38 -07:00
RoosterDragon 7db488cdfb Fixed: CPImageView no longer leaks due to image load notification.
Previously, CPImageView would sometimes attach a notification to CPImageDidLoadNotification when the image was set, but would never remove this notification. The view could then leak memory as the notification center would be keeping a reference even if the view was no longer being used.

This commit fixes that issue by removing the observation once the image has loaded.

Fixes #2198.
2014-09-24 13:45:49 +01:00
cacaodev 1a414ac69c view-based table: always use the proto UID as view identifier
-setDataView: was not working because the caching system was picking
views cached with the column identifier which is persistent.

Test: CPTableViewTest -testLayout
2014-09-23 13:56:52 +02:00
cacaodev f82099143f CPTableView: -_reloadDataViewsImmediately -> -reloadData
CPTableColumn: binder:-setValueFor:  is a simple data reload.
2014-09-23 12:17:52 +02:00
Alexandre Wilhelm 93743b11b2 Fixed: typo in documentation in CPView.j 2014-09-22 10:13:51 -07:00
Alexandre Wilhelm a94696e037 Fixed: refactoring of the retina drawing feature 2014-09-21 22:46:46 -07:00
Alexandre Wilhelm 0255e8980b Fixed: remove stupid debug mode 2014-09-21 22:38:11 -07:00
Alexandre Wilhelm eff9c69069 Fixed: transform matrix for retina displayed is reset when changing the frame of the view 2014-09-21 22:35:50 -07:00
Antoine Mercadal ca8a70a1ee Merge pull request #2217 from Dogild/SelectedThemeStateTableView
Fixed: CPThemeStateSelectedDataView still set when removing a view
2014-09-19 13:10:31 -07:00
Alexandre Wilhelm 903cc8ee83 Fixed: CPThemeStateSelectedDataView still set when removing a view
Previously, when removing a view from a CPTableView, the themeState CPThemeStateSelectedDataView wasn't unset. Now it does.
2014-09-19 09:59:56 -07:00
cacaodev 2dccd2f30b NEW: ojtest for method - (void)getColumn:(Function)columnRef row:(Function)rowRef forView:(CPView)aView
This internal method is used for editing and public methods rowForView: and columnForView
2014-09-18 19:23:16 +02:00
cacaodev b775cbb3bf Merge remote-tracking branch 'upstream/master' into CPTableView-enumerateRows 2014-09-18 18:36:53 +02:00
Alexandre Wilhelm 79ef6f2f75 Fixed: dpi drawing didn't work when changing the frame of a view 2014-09-17 13:35:07 -07:00
Alexandre Wilhelm 451ac297d4 Fixed: change accessors for CPViewHighDPIDrawingEnabled 2014-09-17 10:52:22 -07:00
Alexandre Wilhelm 0fd8a4507c New: possibility to draw automatically in high DPI in canvas2D
Previously, Cappuccino didn't handle retina device when drawing for canvas2D. Now it does.
To do that, Cappuccino will firstly calculate the pixel ratio of the current device, then it needs to change the css style of the canvas by multiply it by the current pixel ratio and finally scale the canvas by this pixel ratio.

More information about high DPI drawing here : http://www.html5rocks.com/en/tutorials/canvas/hidpi/

Added the method `setAllowsHighDPIDrawing:` and `allowsHighDPIDrawing` to deactivate or activate this feature.

Fixed #2175
2014-09-17 10:27:26 -07:00
Martin Carlberg 13fe318110 Fixed: When the compiler can't find a protocol in a class declaration it now gives an understandable error.
This fixes #2212
2014-09-16 20:13:42 +02:00
daboe01 49c7e7ce2d style 2014-09-15 20:10:24 +02:00
daboe01 1af7d01d96 fix of resizing regression 2014-09-15 18:20:53 +02:00
daboe01 66c6938df0 changed selection drawing from canvas to DOM
fixes height limitation, is faster and looks better
2014-09-14 21:24:23 +02:00
daboe01 bb9fb04788 make triple clicks behave more apple like 2014-09-13 20:24:27 +02:00
daboe01 f5cf2b2b55 fix selecting last character 2014-09-13 20:13:08 +02:00
Antoine Mercadal b9b396a279 FIXED: using setHidden: for a button in buttonbar was not working
Previously, CPButtonBar was not updating its layout after changing the visibility of its buttons.
This patch adds makes CPButtonBar observersing the buttons and relayout if the visibility of one button is updated.
2014-09-12 14:42:27 -07:00
cacaodev a2755221d0 The cocoa behavior is:
Exclusive bindings are impossible in IB
Possible in code (tested with segmented control and selectedIndex & selectedTag) but then you get unexpected behavior. A segment can be selected after a click and then
changes to another segment.
After this commit, extra exclusive bindings are just ignored and we warn about it.
2014-09-12 22:33:50 +02:00
cacaodev 3e8afaeae4 Fixed: -removeTableColumn: now works without error. OJTest in AppKit/CPTableColumnTest.j, manual test in TableTest/TestTanleColumn/
Fixed: Added an out of bounds check to _unloadDataViews:...
Revert: revert -reloadData to the previous behavior where views & data were reloaded, not only data. That's what cocoa does for view based tables.
2014-09-11 23:14:21 +02:00
daboe01 43169ced69 fix of the fix 2014-09-11 10:45:27 +02:00
daboe01 708844857d make canvas sizing detection more robust 2014-09-11 10:22:50 +02:00
Alexandre Wilhelm 83ec89fa20 Fixed: CPDatePicker send an action with the methods setObjectValue: and setDateValue:
Previously, the CPDatePicker sent an action to the target when the method setObjectValue: and setDateValue were called.
Now it sends the action only when the user makes an action.

Fixed #2206
2014-09-10 12:54:16 -07:00
cacaodev 68b193a782 NEW: bind:toObject: ... now checks if another binding mutually exclusive is already binded. Throws an exception if this is the case.
Controls can implement -isExlusiveBinding: to determine if bindings are exclusive. Defaults to NO.
Exclusive bindings are mainly CPSelectedIndexBinding | CPSelectedTagBinding | CPSelectedValueBinding
2014-09-09 20:31:15 +02:00
Sebastian Balay fa5fd1e71c Add support to diacritic insensitive search in CPString rangeOfString:options:range: method
When searching by range, the option of diacritic insensitive search was not being contemplated

Also add support to strip variants of 'E' 'I' 'O' 'U' that were not implemented.
Source: http://www.ascii-code.com/
2014-09-08 10:01:12 -03:00
cacaodev abe2e544bb Merge remote-tracking branch 'upstream/master' into CPTableView-enumerateRows 2014-09-06 21:33:18 +02:00
cacaodev e051d02ad3 FIXED : CPBinder subclasses were keeping references to the source object in a class var.
This could cause memory leaks and was unnecessarily verbose.
CPPopUpButton , CPRadio and CPSegmentedControl now use a generic CPBinder method for searching the binder involved when the control is asked to reverse set the binding, typically after a user interaction.
Fixes #2199
TODO: prevent user to bind multiple selection bindings when these bindings are exclusive.
2014-09-06 20:35:41 +02:00
cacaodev a3796fe128 Added private method to CPBinder: + (void)_reverseSetValueFromExclusiveBinderForObject:(id)anObject
Usage: when a control is known to have exclusive bindings (like selected index/tag/value), use this method when
you don't know the binding name and want to send values to the binded object (via reverseSetValueFor:).
In CPBinder binderMap, picks the first binder matching the receiver class or subclass.
2014-09-06 20:22:51 +02:00
Alexandre Wilhelm c1e89bd1c3 Fixed: CPDatePicker in a CPTableView wrong behavior
Previously, when clicking on a CPDatePicker in a CPTableView, cappuccino didn't select the tableView row firstly.
Now it does as in cocoa.
The stepper still have the same behavior as a CPButton in a CPTableView.

refs #2201
2014-09-05 16:16:46 -07:00
Alexandre Wilhelm aded1dd4da Merged: manual merged 2014-09-05 13:00:48 -07:00
RoosterDragon 1e39281423 Fixed: CPBinder unbindAllForObject did not work.
Previously, calling CPBinder unbindObjectForKey would not actually unbind each of the bindings because it was passing the wrong object to the unbind method which would silently ignore the issue. The commit passes the correct parameter to allow unbinding to actually take place.

Fixes #2197.
2014-09-05 14:46:20 +01:00
Antoine Mercadal d92cc0f365 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2014-09-04 18:18:29 -07:00
Antoine Mercadal a5e39d1db3 Revert "Merge pull request #2158 from mrbannon/master"
This reverts commit 228a95f776, reversing
changes made to cf93b72edd.
2014-09-04 18:17:15 -07:00
Antoine Mercadal 7052ce9e63 Merge pull request #2196 from Dogild/BackSpaceTextField
Fixed: backspace on a none editable/enable field trigger the browser's page back button
2014-09-04 18:06:14 -07:00
Alexandre Wilhelm 8d036ab1d4 Fixed: backspace on a none editable/enable field trigger the browser's page back button
Previously, when hitting the backspace key on a none editable/enable field, this triggered the browser's back button.
Now it does not anymore.

All credits for @apajarita

Fixed #2189
2014-09-04 17:44:29 -07:00
Antoine Mercadal 48276f989f Fixed: - (CGSize)sizeWithFont:(CPFont)aFont inWidth:(float)aWidth adjust +1 to the computed size
The width computing of a string is always a little random, and that led to truncated labels. This patch adds
a pixel in width in order to fix any rounding errors.
2014-09-04 17:35:03 -07:00
Antoine Mercadal 57f2d3e26a Revert "Merge pull request #2152 from daboe01/Fix-for-missing-backgroundcolor-support-textfield"
This reverts commit 5c193f49df, reversing
changes made to 5b2ef77c2c.
2014-09-04 14:34:09 -07:00
Alexandre Wilhelm c4924e4005 Fixed: typo 2014-09-04 14:30:40 -07:00
Antoine Mercadal 5c193f49df Merge pull request #2152 from daboe01/Fix-for-missing-backgroundcolor-support-textfield
FIXED: CPTextField's setTextFieldBackgroundColor: has not effect
2014-09-04 14:05:21 -07:00
Antoine Mercadal 5b2ef77c2c Merge pull request #2195 from Dogild/BackgroundSizeFrameSize
Fixed: CSS style background-size doesn't change its value when changing a frameSize
2014-09-04 14:04:42 -07:00
Antoine Mercadal 371b660b33 Merge pull request #2072 from mrcarlberg/fix_accessors_in_categories_fails
Fixed: Ivars with accessors in a Category failed with duplicate ivar error
2014-09-04 14:02:53 -07:00
Antoine Mercadal 228a95f776 Merge pull request #2158 from mrbannon/master
Fixed: #2157 - fixed issue with InvalidStateError when using CPURLConnection in IE11
2014-09-04 13:59:13 -07:00
Antoine Mercadal cf93b72edd Merge pull request #2173 from daboe01/Fixed--collectionViewDidChangeSelection
Fixed: support for outdated collectionViewDidChangeSelection delegate method
2014-09-04 13:57:39 -07:00
Antoine Mercadal 90c60cc5e4 Merge pull request #2184 from daboe01/patch-1
Fixed: typo in scrollRectToVisible: documentation
2014-09-04 13:56:26 -07:00
Antoine Mercadal e79ab4f47a Merge pull request #2190 from Dogild/text-ColorDatePicker
Fixed: wrong text-color for CPDatePicker
2014-09-04 13:55:32 -07:00
Antoine Mercadal 4e946cbb27 Merge pull request #2185 from daboe01/backport-closebutton-aristo
Fixed: Aristo1 close button of inactive windows looks like as in active windows
2014-09-04 13:55:11 -07:00
Antoine Mercadal d5c5070e59 Merge pull request #2191 from t00f/fix#2182
Fixed truncated CPRadio / CPRadioGroup. #2182
2014-09-04 13:54:47 -07:00
Antoine Mercadal 50b3aabb76 Merge pull request #2192 from ratijas/master
-setFloat:forKey: @selector(aValue) -> @selector(floatValue)
2014-09-04 13:54:14 -07:00
Antoine Mercadal b2fd84192b Merge pull request #2193 from Dogild/DatePickerTableView
Fixed: CPDatePicker textual and graphical doesn't work in a CPTableView
2014-09-04 13:53:52 -07:00
Alexandre Wilhelm 1a7f7cb197 Fixed: CSS style background-size doesn't change its value when changing frameSize
Previously, when changing the frameSize of a CPView, the style background-size wasn't changed with.
This raised issue with threePartImage.

Fixed #2187
2014-09-04 13:42:25 -07:00
daboe01 ecab61929e formatting 2014-09-04 18:00:13 +02:00
daboe01 ab4f0f87ca bump zIndex by 1 to avoid -1 2014-09-04 17:51:59 +02:00
Alexandre Wilhelm ae5b3c4c2d Fixed: CPDatePicker textual and graphical doesn't work in a CPTableView
Previously, when using a textual or graphical CPDatePicker in a CPTableView Cappuccino crashed.
This PR fix this issue by adding the subviews of a CPDatePicker in the method layoutSubviews instead of in the initialization.

This PR add another feature on the graphical CPDatePicker, the button next and previous month are now in the mode continuous as in Cocoa.
2014-09-03 16:09:58 -07:00
ratijas 06240d1183 -setFloat:forKey: @selector(aValue) -> @selector(floatValue) 2014-09-03 16:08:21 +00:00
Christophe Serafin f3b3d8d759 Test: Update CPControlSize and Nib2CibAlignment tests to show CPRadioGroup truncated fix.
It removes unuseful grid image and adds CPRadio and CPRadioGroup into CPControlSize and Nib2CibAlignment tests.
2014-09-02 17:45:14 -07:00
Christophe Serafin 8420f6ccfe Fixed: CPRadioGroup were truncated
Since PR #2170, CPRadioGroup were truncated because they are specific components translated into a NSMatrix (CPView) object.
This fix sets CPRadio controlSize according to xCode value and uses its frame adjustment to adjust CPRadio inside a CPRadioGroup.
2014-09-02 17:39:33 -07:00
Alexandre Wilhelm f007ecf6c5 Fixed: wrong text-color for CPDatePicker
Previously the color of a CPDatePicker wasn't black as a CPTextField

Fixed #2188
2014-09-02 13:17:07 -07:00
daboe01 758a023267 style 2014-08-31 21:21:42 +02:00
daboe01 fe6a576d84 add special close button for inactive windows 2014-08-31 21:16:36 +02:00
daboe01 d4f2d99a6b Fixed: typo in scrollRectToVisible: documentation 2014-08-31 13:48:34 +02:00
Antoine Mercadal cb390325a6 Merge pull request #2170 from t00f/themeable-rule-editor
ControlSize management and CPRuleEditor/CPPredicateEditor alignments
2014-08-29 10:11:05 -07:00
Antoine Mercadal 1922ef974b Merge pull request #2180 from kevin-xu/kevin-xu-branch
Fixed: bootstrap.sh cannot filter the OpenRDK version key out correctly.
2014-08-28 22:42:01 -07:00
Alexandre Wilhelm de495aa1c5 Fixed: _removeObservers called in orderFront, we don't need this as addObservers and removeObservers work with boolean to check if the observers are set or not 2014-08-28 22:28:41 -07:00
Alexandre Wilhelm cf0b4c8f03 Fixed: added CPView test for the method addSubview 2014-08-28 22:23:20 -07:00
Alexandre Wilhelm aa4a4b07d8 Fixed: method viewWillMoveToWindow and viewDidMoveToWindow not called when when adding a view to a view without a window where the previous superview had a window 2014-08-28 22:22:50 -07:00
kevin-xu 75a4d8a2b9 Fixed: bootstrap.sh cannot filter the OpenRDK version key out correctly.
When running ./bootstrap.sh, it will print the error message:
"./bootstrap.sh: line 138: [: too many arguments"

This fix correct it by filtering out the OpenRDK Runtime Environment line.

Fixes #2179
2014-08-28 20:14:35 -07:00
Antoine Mercadal b92214461e FIXED: Some tooltips was truncated
This patch adds a small size adjustment when we compute the size of the
tooltip. It seems to fix all truncated tooltips problem.
2014-08-28 19:02:22 -07:00
Antoine Mercadal 3f4ba87079 FIXED: Tooltip content alignement was mistakely set to be justified
This patch ensure the tooltip content is left aligned correctly
2014-08-28 18:30:55 -07:00
Antoine Mercadal f1cfa14750 FIXED: buttons in CPButtonBar were never removed from the CPButtonBar
Previsouly, layoutSubview was layouting the visible buttons, but it was not removing them from
the buttonbar
2014-08-28 17:26:22 -07:00
daboe01 b24f5b6ad6 fixed unit test 2014-08-24 14:12:44 +02:00
Christophe Serafin 3dbce0e800 move DOMElement.style.backgroundSize to CPDomDisplayServerSetStyleBackgroundSize equivalent method 2014-08-22 10:09:09 -07:00
Christophe Serafin 872fd126f4 fix style 2014-08-22 10:07:56 -07:00
Christophe Serafin efca50c6ac fix style 2014-08-22 10:07:29 -07:00
Antoine Mercadal 3cf013b25b Merge pull request #2178 from Dogild/CPOUtlineView-fix-reuseItem
Fixed: crash of the CPOutlineView when reloading and changing an item to another parent
2014-08-21 10:42:58 -07:00
Alexandre Wilhelm 92a5fa19fb Fixed: crash of the CPOutlineView when reloading and changing an item to another parent
Previously, when reloading the CPOutlineView and changing an item to another parentItem, the CPOutlineView deleted the reference of the item.

Now, when removing old data to avoid memory leaks, the CPOutlineView checks if the pending item to delete doesn't have another parent item.
2014-08-20 18:32:20 -07:00
Alexandre Wilhelm 1fcf13d149 Fixed: added optimization for releasing observers 2014-08-20 16:13:59 -07:00
Alexandre Wilhelm bd20050db8 Fixed: added a boolean to avoid to addObservers seveal times 2014-08-20 15:23:10 -07:00
Alexandre Wilhelm ce0233d0a2 Fixed: revert commit abdf1156d4 for CPComboBox 2014-08-20 15:11:21 -07:00
daboe01 ce777348b3 cursor up/down+ frames protection 2014-08-20 23:09:53 +02:00
daboe01 c052325487 various fixes and cleanup 2014-08-20 22:39:15 +02:00
Alexandre Wilhelm 0479e9b3f3 Fixed: make sure to remove observers when opening a CPWindow 2014-08-19 17:52:24 -07:00
Alexandre Wilhelm abdf1156d4 Fixed: memory leaks with CPNotifications
Previously, when removing a view, Cappuccino didn't clean the notification center. The notification center kept in reference old views.

This PR fix this issue. When a CPView is added to a view, the methods _removeObservers and _addObservers are called. In these both methods we remove and add the observer to the notification center if needed. _removeObservers and _addObservers are called for the view and its subviews. These both methods are called through the method viewWillMoveToSuperview.

When a CPView is removed, we only call the method _removeObservers.
When a CPWindow is closed, we call the method _removeObservers on its contentView.
When a CPWindow is about to be opened, we call the method _removeObservers and _addObservers on its contentView.

Refs #1880
Refs #2024

Test app in Tests/Manual/AttachedSheet2/SheetWindowController.j
2014-08-19 17:45:01 -07:00
Alexandre Wilhelm 9ed30f563a Fixed: Methods viewDidMoveToSuperview viewDidMoveToWindow viewWillMoveToSuperview viewWillMoveToWindow not called as in Cocoa
Previously, when adding, removing, replacing a CPView, the framework didn't call the methods viewDidMoveToSuperview, viewDidMoveToWindow, viewWillMoveToSuperview and viewWillMoveToWindow as in Cocoa. Now it does.

The main change is that these methods will be called when removing a CPView.

Added unit-test in Tests/AppKit/CPViewTest.j
2014-08-19 14:26:26 -07:00
Christophe Serafin d1985bad3b update Nib2CibAlignment test 2014-08-18 13:09:51 -07:00
Christophe Serafin c83a4dc8e4 fix _adjustNib2CibSize calls 2014-08-18 13:09:15 -07:00
Christophe Serafin 5484bbf8bf fix Aristo and Aristo2 alignments 2014-08-18 13:08:47 -07:00
Christophe Serafin 62e8d70d74 fix _adjustNib2CibSize calls 2014-08-18 13:08:09 -07:00
Alexandre Wilhelm b2f1477b45 Fixed: wrong condition in CPApplication 2014-08-15 16:37:03 -07:00
Christophe Serafin 7323a5e393 fix disappearing buttons 2014-08-15 09:04:26 -07:00
Christophe Serafin f8205cc376 realign Aristo2 buttons for fix 6f9210 2014-08-15 08:20:46 -07:00
Antoine Mercadal 1b639ab978 Improve test XIB 2014-08-15 01:01:47 -07:00
Antoine Mercadal 4828f7478e Merge branch 'master' into themeable-rule-editor 2014-08-14 21:05:58 -07:00
Antoine Mercadal 9646f7039a Update XIB 2014-08-14 21:05:16 -07:00
Antoine Mercadal 6f921028de do not call again _adjustNib2CibSize 2014-08-14 21:04:57 -07:00
Antoine Mercadal 2508db0550 Remove usless computation 2014-08-14 21:04:32 -07:00
Antoine Mercadal 775141b7f7 Merge branch 'themeable-rule-editor' of https://github.com/t00f/cappuccino into themeable-rule-editor 2014-08-14 21:03:45 -07:00
Antoine Mercadal a2d9c1aa72 Merge pull request #2174 from Dogild/PopoverDelegate
Fixed: delegate popover did show not called with a none animate CPPopover
2014-08-14 20:59:29 -07:00
Christophe Serafin 4b639843ec fixed buttons positions and extended Nib2CibAlignment test 2014-08-14 18:18:08 -07:00
Christophe Serafin 464389a862 update nib2cib-adjustment-frame to match Nib2CibAlignment Test. Except for button in small and mini sizes 2014-08-14 14:17:57 -07:00
Alexandre Wilhelm 48b3eb259d Fixed: delegate popover did show not called with a none animate CPPopover
Previously, the delegate popoverDidShow wasn't called with an none animated CPPopover.
2014-08-14 14:10:37 -07:00
daboe01 4cebfbcd13 removed collectionViewDidChangeSelection 2014-08-14 22:57:05 +02:00
daboe01 1767cf8ad4 formatting+nil equality 2014-08-14 22:41:59 +02:00
daboe01 b1981bb70c fix activateIgnoringOtherApps:shouldIgnoreOthe... 2014-08-14 22:27:46 +02:00
Christophe Serafin 3dc581efbb introduce nib2cib-adjustment-frame as theme attribute to enbable proper control alignment 2014-08-14 10:54:38 -07:00
Christophe Serafin 655cc3256c remove arbitrary CONTROL_HEIGHT 2014-08-14 10:45:12 -07:00
daboe01 ce69410f49 revert of breaking change wrt backspace 2014-08-14 18:21:53 +02:00
daboe01 5f0be0cc7f make storage length zero more tolerant 2014-08-14 14:14:49 +02:00
Andrew Hankinson dca6347ea9 Fixed: Remove lingering references to i
Refs 75e347e8e3
2014-08-14 07:19:53 -04:00
daboe01 94c4db9072 fixed equality operator 2014-08-14 07:17:00 +02:00
Andrew Hankinson 7f63be2cd2 Formatting: Make if statement more readable
The if statement had a lot of sub-clauses. These were factored out into variable assignments.
2014-08-13 19:56:50 -04:00
Andrew Hankinson 1236dea4c5 Fixed: equality operators 2014-08-13 19:47:06 -04:00
Andrew Hankinson c5c46df613 Fixed: typo 2014-08-13 19:44:23 -04:00
Andrew Hankinson a96269150a Fixed: AppKit.j is alphabetized
CPTextView.j was out of alphabetical order. This commit fixes that.
2014-08-13 19:34:56 -04:00
Andrew Hankinson 75e347e8e3 Fixed: obscure use of variables
Previously, the counting variable "i" was used as a variable throughout this method, leading to the value of 'i' becoming unclear as the method progressed.

Additionally, a later loop in this method redeclared 'i', providing more confusion.

This commit renames 'i' to the more descriptive 'targetLine' and uses that in its place. The redeclared value of 'i' was also renamed to "newTargetLine".
2014-08-13 18:15:58 -04:00
daboe01 d641cc5057 fix fussy optimization 2014-08-14 00:12:02 +02:00
Christophe Serafin bf5b660cb5 fix background size with 1-part image 2014-08-12 17:26:43 -07:00
Christophe Serafin 712dc493ca remove CPDateFormater dependancy and CPString convertion 2014-08-12 15:42:03 -07:00
Christophe Serafin f4fba64ffb remove test on sendAction 2014-08-12 14:06:37 -07:00
Christophe Serafin 02430916cb add CPDatePicker without CPStepper in CPControlSize test demo 2014-08-12 13:58:05 -07:00
Christophe Serafin e3ad115698 correction based on primalmotion comments 2014-08-12 13:56:25 -07:00
Christophe Serafin c078bb04b2 Correction and optimizations based on Alex comments. Fix for CPDatePickerTest 2014-08-12 13:31:22 -07:00
Antoine Mercadal d95e133792 Merge pull request #2171 from Dogild/CPTextField-Platform
Fixed: Checking if a CPTextField is usable in a CPPlatformWindow
2014-08-12 12:11:50 -07:00
Alexandre Wilhelm a04f1045bc Fixed: Checking if a CPTextField is usable in a CPPlatformWindow
Previously, when a CPTextField was in a CPPlatformWindow, the checking of if the CPTextField was usable or not (depending on its position) in a CPPlatformWindow didn't take in account the content-inset of the CPTextField. Now it does.
2014-08-12 11:27:25 -07:00
daboe01 cf64145ff3 formatting 2014-08-12 16:06:49 +02:00
daboe01 195eca6b09 typesetter early exit in flushing fix 2014-08-12 15:48:31 +02:00
daboe01 b0ef077e48 fix typesetter nil bug 2014-08-12 15:12:19 +02:00
daboe01 e40a698d1a fixed accessor 2014-08-12 10:37:05 +02:00
daboe01 69c34b1b27 formatting 2014-08-12 08:33:28 +02:00
daboe01 4700c2583d fix acessor names 2014-08-12 08:29:28 +02:00
Christophe Serafin db6975e07a force size only for bordered buttons and bezeled textfields 2014-08-11 18:08:15 -07:00
Christophe Serafin 93127489e7 stop forcing font on CPButton and CPTextField. If the developper wants to set a bigger font it is possible in Cocoa 2014-08-11 17:25:31 -07:00
Christophe Serafin 83064294ac remove useless images and declaration 2014-08-11 15:04:35 -07:00
Christophe Serafin 0b64758360 adjust CPPopUpButton alignment 2014-08-11 15:04:06 -07:00
Christophe Serafin 4e1a2c04a5 create a CPControlSize Manual test to verify control sizes with a certain theme 2014-08-11 14:27:01 -07:00
Christophe Serafin 8412c1db21 enable autoresize theme images instead of creating small and mini images. Remove all existing small and mini images 2014-08-11 14:25:02 -07:00
Antoine Mercadal 18a7a9fdce Merge pull request #2168 from Dogild/CPOutlineView-fixed
Fixed: Memory leaks in CPOutlineView + corrupted itemInfos dictionary
2014-08-11 14:15:59 -07:00
Antoine Mercadal fc90d00354 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2014-08-11 12:47:12 -07:00
Antoine Mercadal 55861a8f44 FIXED: transient popovers were not close with right click
This patch ensure that is a popover is transient and the user right clicks outside, it closes properly.
2014-08-11 12:46:09 -07:00
Alexandre Wilhelm 4fbd307163 Fixed: refactoring of the class CPOutlineView 2014-08-09 15:10:25 -07:00
Alexandre Wilhelm 3e4c03852d Fixed: Memory leaks in CPOutlineView + corrupted itemInfos dictionary
Previously, when reloading a CPOutlineView with different datas than before, the CPOutlineView kept a reference of the previous datas.
Now, when reloading, the CPOutlineView will delete these references when we don't need it anymore. For that, the CPOutlineView will only try to delete the previous reference when we have reloaded the children of a node, otherwise it will keep the other references.

This PR fix some issue with the following methods :

- (BOOL)isExpandable:(id)anItem;
- (BOOL)isItemExpanded:(id)anItem;
- (CPInteger)rowForItem:(id)anItem;
- (CPInteger)levelForItem:(id)anItem;
- (id)itemAtRow:(CPInteger)aRow;
- (CPInteger)levelForItem:(id)anItem;
- (CPInteger)levelForRow:(CPInteger)aRow;

Previously these methods took care about not displayed items. Now they just work with displayed items.

Added unit-tests in Test/AppKit/CPOutlineViewTest.j

Test app in Test/Manual/CPOutlineViewTestCib
2014-08-08 15:05:24 -07:00
Christophe Serafin c8a04b998b update origin Y according to control Size 2014-08-07 18:27:01 -07:00
Christophe Serafin 568a652fb4 added default CPButton images 2014-08-07 18:26:32 -07:00
Christophe Serafin a2c9b5c042 added choices in list to test CPPredicateEditor with CPPopupButton 2014-08-07 16:51:36 -07:00
Christophe Serafin fd3a4b069d removes CPRuleEditorPopUpButton and use CPPopUpButton directly 2014-08-07 16:50:52 -07:00
Christophe Serafin 4aaafa6de7 fix CPDatePicker alignment in CPPredicateEditor. fixes #2162 2014-08-07 16:50:23 -07:00
Christophe Serafin 97475fb27b enable CPButton to use ControlSize management 2014-08-07 16:47:09 -07:00
Christophe Serafin 26e29df657 update CPRuleEditor to use small control size for each control. 2014-08-07 09:44:06 -07:00
Christophe Serafin 269ab3884a enable testing with boolean type 2014-08-07 09:43:07 -07:00
Christophe Serafin d15a853bf7 enable control size management on CPButton, CPPopUpButton, CPCheckbox, CPDatePicker, CPTexteField, CPStepper 2014-08-07 09:41:43 -07:00
Aparajita Fishman b3f7f440c8 Set user event flag based on presence of DOMEvent. 2014-08-06 08:08:53 -04:00
daboe01 6cf79a3c73 size should not be smaller than clipview 2014-08-06 13:31:31 +02:00
daboe01 2c110f7796 fixed: display error at bottom in case of resizing 2014-08-06 13:17:35 +02:00
Christophe Serafin c298c968f5 ignore xcodeproj directory 2014-08-05 17:35:25 -07:00
Christophe Serafin 5feac3a7ff allow using regular, small and mini sizes from xCode and from code using setControlSize method. Available on CPTextField, CPStepper, CPDatePicker only for the moment 2014-08-05 17:34:58 -07:00
Antoine Mercadal 215c1c53f5 Merge pull request #2166 from Dogild/PopoverAnimation
Fixed: CPPopover animation issue
2014-08-04 12:54:26 -07:00
Alexandre Wilhelm 7890085c6c Fixed: CPPopover animation issue
Previously, when opening a popover after another one, the CPPopover was blurred.
This occurred due to some CSS Transitions specification :

"Since this specification does not define when a style change event occurs, and thus what changes to computed values are considered simultaneous, authors should be aware that changing any of the transition properties a small amount of time after making a change that might transition can result in behavior that varies between implementations, since the changes might be considered simultaneous in some implementations but not others."

The fix consists to access to a transform value of the style of the _DOMElement to force it to recalculate the values.

More information here : https://code.google.com/p/chromium/issues/detail?id=388082

Fixed #2143
Test app in Test/Manual/CPPopover
2014-08-04 10:55:29 -07:00
daboe01 aebea0b57f Update CPTypesetter.j 2014-08-04 13:27:42 +02:00
daboe01 8684455ea5 make canvas sizing validity detection more robust 2014-08-04 13:22:38 +02:00
Christophe Serafin 12c427a9cf enable CPControl to use setControlSize. Created an example with CPStepper 2014-08-01 16:57:02 -07:00
daboe01 7cbb103376 fix selecting last newline error 2014-07-31 20:35:29 +02:00
daboe01 d686a0dadf reverseSetValuesFor: handle multiple selection 2014-07-30 21:09:41 +02:00
Antoine Mercadal eb186f550c Merge branch 'master' of https://github.com/cappuccino/cappuccino 2014-07-30 11:32:59 -07:00
Antoine Mercadal 01b631aea6 FIXED: Popover not showing in correct platform window.
This was fixed a month ago, but additional later commits added a dumb test preventing this to work correctly
2014-07-30 11:31:54 -07:00
Aparajita Fishman 293114f1a0 Fixed: delete methods erased entire field
Previously, the deleteForward:, deleteBackward: and delete: methods in CPTextField called setStringValue, which would consult a formatter, and if the formatter failed all of the text would be deleted.

Now the code has been refactored such that when one of the delete methods is invoked via a key event, the formatter is not used and the DOM event is used, which results in the expected behavior.

A bug in checking the selected range was also fixed in deleteForward:.

The CPFormatter test was updated with buttons to call the delete methods directly to ensure they work correctly when not invoked from a key event.

Closes #1997
2014-07-29 23:32:14 +04:00
Antoine Mercadal 20b92c03cb Merge pull request #2161 from Dogild/CPComboBoxDataSource
New: added protocol CPComboBoxDataSource
2014-07-29 11:22:37 -07:00
Antoine Mercadal b6d76eb84e Merge pull request #2163 from t00f/predicate_editor_with_date
set CPDatePicker elements to days, months, year when used within a CPPre...
2014-07-28 17:29:25 -07:00
Alexandre Wilhelm 25bb51f4a3 New: added protocol CPComboBoxDataSource
Added protocol CPComboBoxDataSource
2014-07-28 13:38:11 -07:00
Christophe Serafin 4a3f51e550 set CPDatePicker elements to days, months, year when used within a CPPredicateRowTemplate 2014-07-28 12:51:32 -07:00
Ryan Bannon d629a13499 Fix: https://github.com/cappuccino/cappuccino/issues/2157
Possible bug in XMLHTTPRequest.  Thanks to hmsimmonds for locating the following:

http://connect.microsoft.com/IE/feedback/details/795580/ie11-xmlhttprequest-incorrectly-throws-invalidstateerror-when-setting-responsetype

https://github.com/enyo/dropzone/issues/179

In short, setting the "withCredentials" flag must be done after open().
2014-07-23 16:58:02 -04:00
Alexander Ljungberg 07c0de71ec New: support line-by-line scrolling with old scroll wheel devices in Firefox.
Without this change, using a traditional scroll wheel mouse with discrete steps would result in very slow scrolling in Firefox.

With this fix we handle these events like in Cocoa: as "[im]preciseScrollingDeltas", which `CPScrollView` in turn knows to apply the configurable line scroll amount for. For backwards compatibility, [event deltaX] and [event deltaY] are premultiplied with a suitable constant, while [event scrollingDeltaX] and [event scrollingDeltaY] show the true values needed.

Browsers other than Firefox seem to always send pixel scrolling information even for old style scrolling devices, at least on the Mac, so are not affected by this change.

Fixes #2013.
2014-07-23 15:04:07 +01:00
Alexander Ljungberg 7470f4ffcf New: CPEvent scrollingDeltaX, scrollingDeltaY and hasPreciseScrollingDeltas.
Refs #2013.
2014-07-23 15:00:30 +01:00
Alexander Ljungberg 81f9748313 Merge pull request #2013 from daboe01/fix-scrollwheel-speed-on-firefox
Fixed: scroll wheel speed is way to low in firefox [+1]
2014-07-23 13:49:19 +01:00
Alexander Ljungberg 58928a5000 Formatting: CPDateFormatter changes and tests.
Refs #2155.
2014-07-22 12:49:35 +01:00
Alexander Ljungberg 4c44ede945 Merge pull request #2155 from krodelin/CPDateFormatter-emptyLanguages
Fixed: CPDateFormatter now works for non-"en" locales [+1]
2014-07-22 12:41:03 +01:00
Alexander Ljungberg d3c4105429 Formatting recent changes. 2014-07-22 12:09:06 +01:00
daboe01 9cf8ec5dd7 formatting 2014-07-20 19:55:49 +02:00
daboe01 f5187b1533 _characterRangeForUn...: ternary operator 2014-07-20 11:44:03 +02:00
daboe01 6230a65a79 removed useless unit test 2014-07-20 11:24:22 +02:00
Alexandre Wilhelm f13c96839e Fixed synthax in CPTextView 2014-07-19 19:07:08 -07:00
Alexandre Wilhelm 776f68c9dd Fixed style in CPTextView 2014-07-19 18:46:25 -07:00
Alexandre Wilhelm 714ed89a4c Merged 2014-07-19 16:58:59 -07:00
Antoine Mercadal ed307adb22 Merge pull request #2135 from Dogild/TokenFieldDelegate
Fixed: unsigned delegate methods of CPTokenField erased by CPTextField
2014-07-18 18:42:49 -07:00
Antoine Mercadal 8001688daf Merge pull request #2076 from cacaodev/issue2039
FIXED: Error when binding several objects to the same objectController [+1]
2014-07-18 18:42:18 -07:00
Antoine Mercadal 4c0687b9a5 Merge branch 'fix-menu-enabled-bindings' of https://github.com/daboe01/cappuccino into daboe01-fix-menu-enabled-bindings 2014-07-15 10:22:46 -07:00
Alexandre Wilhelm 33043dd8af Fixed: removed unsued code in CPTokenFieldTest 2014-07-13 21:25:35 -07:00
daboe01 0b2b29b7cf removed unit test 2014-07-12 14:09:59 +02:00
Alexandre Wilhelmanddaboe01 a41c0a0519 Fixed: Update test CPTextViewCibTest 2014-07-12 14:03:32 +02:00
Alexandre Wilhelmanddaboe01 026e28114e Added : added default NSTextView for nib2cib 2014-07-12 14:03:32 +02:00
Alexandre Wilhelmanddaboe01 0840719289 Added: added CPTextViewCibTest 2014-07-12 14:03:32 +02:00
daboe01 aad875e113 make the plain look as white as in cocoa 2014-07-12 14:03:32 +02:00
Alexandre Wilhelmanddaboe01 6b059d94ba Fixed: reduce size of the test of CPTextView 2014-07-12 14:03:32 +02:00
Alexandre Wilhelmanddaboe01 39eeaea7e7 Fixed: circular import with CPText
Previously CPText was in CPTextView.j, now it is in CPText.j.
It fixes some other circular import as well, fixes some global var to import.
Fixed some code style.
2014-07-12 14:03:32 +02:00
daboe01 81a8e91180 fix cut with empty selection 2014-07-12 13:58:39 +02:00
Alexandre Wilhelmanddaboe01 4fc6f6f59b Fixed: refactoring delegate methods 2014-07-12 13:58:39 +02:00
Alexandre Wilhelmanddaboe01 dd2f573f27 Fixed: changed a bit the readability of the file 2014-07-12 13:58:39 +02:00
Alexandre Wilhelmanddaboe01 ff8ddc431b New: Added protocol CPTextViewDelegate 2014-07-12 13:58:38 +02:00
daboe01 d703945aa3 corrected inheritance 2014-07-12 13:58:38 +02:00
Alexandre Wilhelmanddaboe01 f4aba5f9ea New: Added protocol CPTextDelegate 2014-07-12 13:58:38 +02:00
Alexandre Wilhelmanddaboe01 393113c3e3 Fixed: capp_lint 2014-07-12 13:58:38 +02:00
Alexandre Wilhelmanddaboe01 f2db18820a Fixed: CPLog.error is used instead of abstract exception 2014-07-12 13:58:38 +02:00
daboe01 e04d300e18 next try 2014-07-12 13:58:38 +02:00
daboe01 685f836f41 another try 2014-07-12 13:58:38 +02:00
daboe01 d4f5ad641a more dom protection 2014-07-12 13:58:38 +02:00
daboe01 007d437ee8 dom projection 2014-07-12 13:58:38 +02:00
daboe01 00e380e8d8 more dom protection 2014-07-12 13:58:38 +02:00
daboe01 56749d9494 protecting document access with PLATFORM(DOM) 2014-07-12 13:58:38 +02:00
daboe01 cf10d37c90 automated tests and cleanup 2014-07-12 13:58:38 +02:00
daboe01 f9de34e36d font panel fix 2014-07-12 13:58:38 +02:00
daboe01 aa889be140 formatting 2014-07-12 13:58:38 +02:00
daboe01 6da6838bde beginning/end of line navigation + cleanup 2014-07-12 13:58:37 +02:00
daboe01 07a0be303f smart cutting+cleanup 2014-07-12 13:58:37 +02:00
daboe01 ddbe0af290 fix <cr> issue 2014-07-12 13:58:37 +02:00
daboe01 e71f0f44a4 fix relayouting optimization bug 2014-07-12 13:58:37 +02:00
daboe01 39f3bc7100 better workaorund for chrome bug 2014-07-12 13:58:37 +02:00
daboe01 211a145e58 stability improvement 2014-07-12 13:58:37 +02:00
daboe01 d2339b915f spooky chrome fix 2014-07-12 13:58:37 +02:00
daboe01 24c2651745 reverting erroneous patch 2014-07-12 13:58:37 +02:00
daboe01 36e95b93b4 typesetter fix 2014-07-12 13:58:37 +02:00
daboe01 e7a44e0b15 removed debugging code 2014-07-12 13:58:37 +02:00
daboe01 fbdb21ac72 style 2014-07-12 13:58:37 +02:00
daboe01 c9522cf6ae more style 2014-07-12 13:58:37 +02:00
daboe01 7bf9d334ad style 2014-07-12 13:58:37 +02:00
daboe01 422ff93dcd added support for setWidthTracksTextView: 2014-07-12 13:58:37 +02:00
daboe01 eee1ea7a09 fontmanager fix 2014-07-12 13:58:36 +02:00
daboe01 b90e482add typo 2014-07-12 13:58:36 +02:00
daboe01 875b51720b more missing prototypes 2014-07-12 13:58:36 +02:00
daboe01 5272d4f9e3 style 2014-07-12 13:58:36 +02:00
daboe01 c980f4f6e3 prototypes+style 2014-07-12 13:58:36 +02:00
daboe01 89525330c4 formatting+prototypes 2014-07-12 13:58:36 +02:00
daboe01 806db24c0e formatting+ fix prototypes 2014-07-12 13:58:36 +02:00
daboe01 ba7d6df5a4 formatting 2014-07-12 13:58:36 +02:00
daboe01 112301e0e0 formatting 2014-07-12 13:58:36 +02:00
daboe01 c07065e457 more formatting 2014-07-12 13:58:36 +02:00
daboe01 b9e1afae17 formatting 2014-07-12 13:58:36 +02:00
daboe01 549b4a9ebf formatting 2014-07-12 13:58:36 +02:00
daboe01 fa9a3fb7c4 formatting 2014-07-12 13:58:36 +02:00
daboe01 ccb15f278a formatting 2014-07-12 13:58:36 +02:00
daboe01 f0fb4b8842 formatting 2014-07-12 13:58:35 +02:00
daboe01 dacaf293b2 fix of circular imports 2014-07-12 13:58:35 +02:00
daboe01 627d0e4e6f fix circular imports 2014-07-12 13:58:35 +02:00
daboe01 f32b9e26e0 eliminate warnings + style 2014-07-12 13:58:35 +02:00
daboe01 db2b1a0a35 typos 2014-07-12 13:58:35 +02:00
daboe01 f734a60c62 manual test 2014-07-12 13:58:35 +02:00
daboe01 9aa815c1ed CPTextView commit 2014-07-12 13:58:35 +02:00
Antoine Mercadal 1848f96efa FIXED: style 2014-07-10 11:39:43 -07:00
Antoine Mercadal 51440cc7f7 Merge branch 'FIXED--insertAttributedString-did-not-coalsece' of https://github.com/daboe01/cappuccino into daboe01-FIXED--insertAttributedString-did-not-coalsece 2014-07-10 11:38:37 -07:00
Antoine Mercadal 09f100c0c2 Merge branch 'fix-cfhttp-cpurl-2141-2138' of https://github.com/ahankinson/cappuccino into ahankinson-fix-cfhttp-cpurl-2141-2138 2014-07-09 15:45:28 -07:00
Antoine Mercadal a8b66abe15 Merge pull request #2151 from Dogild/EscapePanelRefac
Fixed: escape on a panel or popover breaks the key chain event
2014-07-09 14:12:50 -07:00
Antoine Mercadal 03c45a78a9 Merge branch 'popoverOpen' of https://github.com/Dogild/cappuccino into Dogild-popoverOpen 2014-07-09 14:06:12 -07:00
Alexandre Wilhelm 6574d4450f Fixed: style in _CPPopoverWindow 2014-07-07 20:55:48 -07:00
Alexandre Wilhelm d7f0ff84d6 Fixed: code style in CPPopover 2014-07-07 19:21:00 -07:00
Andrew Hankinson 5ef4c8e83e Fix: Remove _backgroundColor
This parameter exists on CPView, so it has been removed here. A note was added on the setter to identify that the parameter was defined in the superclass.
2014-07-02 08:34:40 +01:00
Andrew Hankinson 5ab48c6015 Fixed: Updated backgroundColor internal variable handling
Previously, _textFieldBackgroundColor was used as the internal variable, and getter/setter methods were explicitly declared to handle getting/setting this value.

This commit changes the name of the internal variable to match the Cocoa compliant method (backgroundColor/setBackgroundColor). It also declares an @accessor option to auto-generate the getter. The setter is explicitly declared because it needs to mark the object as needing display.

Additionally, the logic for the setting is moved from the older method, setTextFieldBackgroundColor, to the new one, setBackgroundColor, and a comment was made to clarify that the older one was deprecated with a link to this issue.
2014-07-01 16:48:21 +01:00
Udo Schneider 9119e08342 Fixed: CPDateFormatter now works for non-"en" locales
CPDateFormatter previously only defined symbols for "en"-locale. Using another locale simple yielded nil-results for most keys. This fix addresses this behavior by always returning the english symbols as default unless other symbols have been explicitly provided or set.
2014-07-01 00:26:51 +02:00
Udo Schneider ce82ce1444 Test: Added Tests for non-english locales
CPDateFormatter only supports the "en" locale by default. All other locales yield empty results for most symbols. The tests added ensure, that the english "default" values are returned if no specific data is available (which is currently the case for every locale except "en").
2014-07-01 00:23:44 +02:00
daboe01 bbffd3d113 correction of typos 2014-06-30 07:07:26 +02:00
daboe01 85cff2c0f3 changed test to use cocoa api 2014-06-30 05:57:10 +02:00
daboe01 9a0c621ad6 introduced cocoa methods for background color 2014-06-30 05:55:22 +02:00
Alexandre Wilhelm 5c66104d25 Fixed: methodsare public instead of private in CPPopover 2014-06-29 19:35:47 -07:00
Alexandre Wilhelm c642d76e91 Fixed: CPPopover doesn't handle semi-transient behavior 2014-06-29 19:17:56 -07:00
Alexandre Wilhelm 6d78ed3462 Fixed: CPPopover test doesn't handle semi-transient state 2014-06-29 19:17:17 -07:00
daboe01 437142ed7b manual test 2014-06-28 17:03:00 +02:00
daboe01 634c6dd455 apply to contentView instead of bezelView 2014-06-28 16:55:43 +02:00
daboe01 3652931be8 fix for missing textFieldBackgroundColor support 2014-06-28 15:20:27 +02:00
Alexandre Wilhelm 7de3022a4a Fixed: animation doesn't work as in cocoa 2014-06-27 13:50:16 -07:00
daboe01 f82e52b7a2 correction of height calculation 2014-06-26 18:06:50 +02:00
Alexandre Wilhelm c274f27810 Fixed: escape on a panel or popover breaks the key chain event
Previously when hitting escape on a CPPanel, the key chain event was broken.
Now when the user hit escape, cappuccino do the following process

- Check if the firstResponder or the chain of the nextResponder implement cancelOperation:
- If not, performKeyEquivalent on the firstResponder and so on
- If not, call the method cancel: on the firstResponder and the chain (not in the case of the CPPopover)

Previously, a complete: method was called if the user hit escape on a void window. This is not a feature of Cocoa, @apajarita or @aljunberg can you confirm that ?

This commit is related to the commit #2139
2014-06-25 18:08:26 -07:00
daboe01 88954b9bf6 fix cpcollectionview height issue 2014-06-25 20:54:18 +02:00
Antoine Mercadal f418f9de4c Merge pull request #2139 from Dogild/EscapePanel
Fixed: CPPanel and popover doesn't close when hitting escape
2014-06-24 17:45:27 -07:00
Antoine Mercadal 57f6ee7f78 Merge pull request #2140 from Dogild/DatePickerStepperValue
Fixed: CPDatePicker value is wrong when making a click on the stepper
2014-06-24 17:29:26 -07:00
Alexandre Wilhelm f8457bd918 Fixed: _closeOnBlur in CPPopover doesn't need accessors 2014-06-24 17:22:09 -07:00
Alexandre Wilhelm 71c1369365 Fixed: removed uelsee import in CPWindow 2014-06-24 17:20:31 -07:00
Alexandre Wilhelm b015a6ea6c Fixed: refactoring of the escape feature of the panel and popover 2014-06-24 17:18:13 -07:00
Alexandre Wilhelm 34072f3947 Fixed: stringValue is used instead of intValue 2014-06-24 16:53:31 -07:00
Antoine Mercadal 036b82afd9 Merge pull request #2134 from Dogild/CPTextFieldEditingStyle
Fixed: CPTextField doesn't update its style when editing [+1]
2014-06-24 16:44:05 -07:00
Antoine Mercadal 52b5b3f741 Merge pull request #2116 from Dogild/xCodeCappUpdatingCapp
New: updating Cappuccino from xCodeCapp
2014-06-24 16:43:05 -07:00
Aparajita Fishman c2f7f2ad27 Merge pull request #2148 from zittix/patch-2
Fixed: Crash of press tool due to theme attribute not set
2014-06-24 13:15:29 -04:00
Alexandre Wilhelm bc9c78acfe Fixed: wrong comment 2014-06-24 10:03:26 -07:00
Mathieu Monney 7bd27ebd52 Fixed: Crash of press tool due to theme attribute not set
When using the press tool, it can happen that one of the theme attribute is not set as not everything is instantiated. 

This fix makes sure that the attribute is set before accessing it to avoid any crash of the press tool.
2014-06-24 15:37:59 +02:00
Alexandre Wilhelm 43ed8be114 Fixed: popoverWillShow called when the popover is opened
Previously, the delegate popoverWillShow was called even if the popover was already shown. This PR fix this issue.
Also, it was possible to launch several times the method orderFront of the _CPPopoverWindow from the CPPopover.
For example with a double click on a button. Now the _CPPopoverWindow has a var isOpening and nothing else is possible during the opening of the popover (not possible to close or to click somewhere else etc etc). This work as in Cocoa.

Test app in Tests/Manual/CPPopover/
2014-06-23 17:29:18 -07:00
Andrew Hankinson a896fe7425 Test: New CFHTTPRequest test
This commit adds a new test for CFHTTPRequest, which at present only contains the test for withCredentials
2014-06-23 16:15:24 -04:00
Andrew Hankinson 6c52e4936f Tests: Updating test for CPURLConnection
This test checks to make sure the CPURLConnection withCredentials functionality works.
2014-06-23 16:14:21 -04:00
Andrew Hankinson 32657793c8 Formatting: CPURLConnection 2014-06-23 16:13:36 -04:00
Andrew Hankinson 63eb88c6ae Merge branch 'fix-cfhttp-cpurl-2141-2138' of github.com:ahankinson/cappuccino into fix-cfhttp-cpurl-2141-2138 2014-06-23 15:51:31 -04:00
Andrew Hankinson 28520cc493 Formatting: Cleaning up CPURLConnection
Removed some extra whitespace and added a newline at the end of the file.
2014-06-23 15:51:13 -04:00
Ryan Bannon 8be05b404c Fixed: change variable name
Changed "returnValue" to "connection" - more descriptive.

Ref: https://github.com/cappuccino/cappuccino/pull/2144#commitcomment-6769088
2014-06-23 15:47:40 -04:00
Alexandre Wilhelm 96b791b5f9 Fixed: fixed gangster's comment 2014-06-23 10:28:10 -07:00
Ryan Bannon ba9eac3ea4 Working #2144: Reintegrated changes from #2138 and fixed test fail.
Now using instance variables for withCredentials.  Also fixed test failure.
2014-06-23 13:08:36 -04:00
Alexandre Wilhelm 717841877f Fixed: typo in _CPDatePickerTextField.j 2014-06-22 13:18:03 -07:00
Aparajita Fishman cf06686d67 Merge pull request #2101 from mockingbird/fix-cpwindow-setcontentview-check
Have CPWindow setContentView check that the new view is not the same as the existing content view
2014-06-22 14:29:36 -04:00
Alexander Ljungberg 8d7594c96a Formatting and clean up.
Refs #2103.
2014-06-22 16:07:17 +01:00
Alexander Ljungberg ed36869f1d Test: complex message receiver.
Refs #2103.
2014-06-22 16:02:37 +01:00
Alexander Ljungberg ea3adc44fd Fixed: objj_msgSend_reset not resetting with fast objj_msgSend.
Refs #2103.
2014-06-22 14:29:40 +01:00
Alexander Ljungberg 5fafc97bc0 Merge branch 'master' into fastobjj 2014-06-22 13:05:32 +01:00
Alexander Ljungberg fba900707a Test: formatting, fix name of previous test.
Refs #2103.
2014-06-22 12:58:24 +01:00
Alexander Ljungberg 175a455d75 Test: add CPAutosizePerformance test to validate objj_msgSend speed improvements.
This test was written by cacaodev.

Refs #2103.
2014-06-22 12:57:11 +01:00
Andrew Hankinson ffcef907b3 Fixed: CPURLConnection now accepts withCredentials
From the original PR:

CPURLConnection was modified to reduce the withCredentials flag to a file-scope member. This has been done to facilitate use of withCredentials when a developer cannot modify the CPURLConnection manually (e.g. https://github.com/wireload/Ratatosk/blob/master/WLRemoteLink.j, line 466).

Refs #1296, #2138
2014-06-21 20:36:12 -04:00
Andrew Hankinson 33317782ea Fixed: CFHTTPRequest now accepts the withCredentials property
From the original PR:

Currently, CPURLConnection has no way to access the withCredential
property of an XMLHTTPRequest, meaning we can't utilize cross-domain
calls using CORS in our applications.

This commit adds the withCredentials property to CFHTTPRequest.

Refs #1296
2014-06-21 20:32:28 -04:00
Alexandre Wilhelm 3b9a0124fa Fixed: setTextColor of CPTextField changed the color of the placeholder
Previously, the method setTextColor changed the color of the placeholder as well.
Now it doesn't as in cocoa

Test app in Test/Manual/CPTextFieldEditingStyleTest
2014-06-19 21:05:17 -07:00
Alexandre Wilhelm 5d5d03fd4c Fixed: textField in CPTextFieldTest doens't have a placeholder 2014-06-19 21:05:06 -07:00
Alexandre Wilhelm 148f3172e6 Fixed: When closing a panel with escape, the delegates are not called
Previously, when closing a panel or popover with escape, the different delegates weren't called.
Now it does.
2014-06-18 18:58:08 -07:00
Alexandre Wilhelm 972c14225b Fixed: CPDatePicker value is wrong when making a click on the stepper
Previously, when making a click on the stepper of a textual CPDatePicker, the intern value of the stepper wasn't updated with the correct value of the CPDatePicker. This occurred when the user changed the dateValue in the delegate methods of the textField.
2014-06-18 18:30:29 -07:00
Alexandre Wilhelm ce86c757cd Fixed: missing bracket... 2014-06-18 16:39:26 -07:00
Alexandre Wilhelm cd6ffba9ac Fixed: CPPanel and popover doesn't close when hitting escape
Previously, a panel or a popover didn't close when the user hit the key escape.
Now it does. The panel or the popover will close on the keyDown event as in cocoa.

Test app in Tests/Manual/CPPanelTest/ and Tests/Manual/CPPopoverTests

Fixed #1767
2014-06-18 16:29:13 -07:00
Aparajita Fishman ab7209ceba Merge pull request #2137 from Asriwi/fix-popover-close-exception
Fixed: CPPopover not closing in some browsers
2014-06-15 16:05:01 -04:00
Aparajita Fishman 63cca6190f Merge pull request #2136 from daboe01/NEW--documentVisibleRect
NEW: support for documentVisibleRect
2014-06-14 22:04:07 -04:00
daboe01 0f2ec90064 documentVisibleRect support 2014-06-14 08:14:38 +02:00
Alexandre Wilhelm 4568dfabb9 Added: added unit test for CPTokenField 2014-06-12 10:58:11 -07:00
cacaodev e0772500c9 Merge remote-tracking branch 'upstream/master' into CPAnimationContext
Conflicts:
	AppKit/CPView.j
2014-06-11 20:24:46 +02:00
cacaodev 78c5522966 Merge remote-tracking branch 'upstream/master' into CPTableView-enumerateRows
Conflicts:
	AppKit/CPTableView.j
2014-06-11 19:42:33 +02:00
Alexander Ljungberg 2a78da6d07 Formatting and comment on table view first responder change.
Refs #2133.
2014-06-10 11:03:08 +02:00
Alexander Ljungberg c3505f865e Merge pull request #2133 from Dogild/TableViewTheme
Fixed: font cell of a CPTableView comes black when editing another cell
2014-06-10 10:53:37 +02:00
Alexandre Wilhelm 3364e6c63b Fixed: unsigned delegate methods of CPTokenField erased by CPTextField
Previously, the unsigned delegate methods _implementedDelegateMethods was erased by the CPTextField, so some delegate methods didn't work any more.
This PR just renames the unsigned delegate methods to _implementedTokenFieldDelegateMethods.
2014-06-09 14:34:08 -07:00
Alexandre Wilhelm a129f2c5c5 Fixed: CPTextField doesn't update its style when editing
Previously, the update of the style of an editing textField didn't work.
Now when editing, we can update the font, color, alignment and vertical-alignment of the textField

Test app in Tests/Manual/CPTextFieldEditingStyleTest/

Fixed #2057
2014-06-09 12:16:15 -07:00
cacaodev 770b0c7022 Here is an ojtest for this issue. 2014-06-07 18:34:59 +02:00
Antoine Mercadal 15a7a0459a Merge pull request #1927 from Alos/layoutSubview-fix
Fixed: CPTabView will now update its tab's labels when the layoutSubview...
2014-06-06 15:54:44 -07:00
Antoine Mercadal 6490858f43 Merge pull request #2131 from Dogild/datePickerShiftClick
New: Added feature to select a set of dates with a shift click in CPDatePicker
2014-06-06 15:42:40 -07:00
Antoine Mercadal aac6f75025 Merge pull request #2129 from Dogild/TyopDatePicker
Fixed: typo in CPDatePicker
2014-06-06 14:37:29 -07:00
Antoine Mercadal 86945218de Merge pull request #2132 from Dogild/ComboBoxModal
Fixed: CPComboBox doesn't work in modal.
2014-06-06 14:36:57 -07:00
Alexandre Wilhelm 718f79775e Fixed: Update test CPTextViewCibTest 2014-06-04 16:30:05 -07:00
Alexandre Wilhelm 4261c1768a Added : added default NSTextView for nib2cib 2014-06-04 16:29:45 -07:00
Alexandre Wilhelm 01603185c3 Added: added CPTextViewCibTest 2014-06-04 15:00:12 -07:00
daboe01 4632ba3ae5 double var fix 2014-06-04 20:38:51 +02:00
daboe01 38d63c3dc9 formatting 2014-06-04 20:33:30 +02:00
Alexandre Wilhelm c64e5a5799 Fixed: font cell of a CPTableView comes black when editing another cell
Previously, when editing a cell, the other cells of the tableView lost the themeState of the firstResponder.
Now the other cells, as the tableView, keep this state when a cell is editing.

Fixed #2133
2014-06-04 11:19:32 -07:00
daboe01 f1adf24f3b make the plain look as white as in cocoa 2014-06-04 18:34:46 +02:00
Alexandre Wilhelm 856765a775 Fixed: reduce size of the test of CPTextView 2014-06-03 21:15:21 -07:00
Alexandre Wilhelm 075da34cdb Fixed: circular import with CPText
Previously CPText was in CPTextView.j, now it is in CPText.j.
It fixes some other circular import as well, fixes some global var to import.
Fixed some code style.
2014-06-03 21:05:04 -07:00
Alexander Ljungberg 7c6ef51cb2 New: CPDate dateByAddingTimeInterval:.
Refs #2126.
2014-06-03 17:41:35 +01:00
Alexandre Wilhelm 1e1297378c Fixed: font cell of a CPTableView comes black when editing another cell
The font of a default dataView came black when editing another cell of the tableView.
Now it stays black.

Fixed #2130
2014-06-02 17:31:32 -07:00
daboe01 5ce543002d fix cut with empty selection 2014-06-02 20:39:53 +02:00
Alexandre Wilhelm ac53b30f25 Fixed: CPComboBox doesn't work in modal.
Previously a CPComboBox didn't work when its parent window was in modal. Now it works.

Fixed #2122
2014-06-01 21:18:14 -07:00
Alexandre Wilhelm a5448549b1 New: Added feature to select a set of dates with a shift click in CPDatePicker
Previously it wasn't possible to select a set of dates with a shift click, now we can.
This works only when the mode CPRangeDateMode is set.
It has the same behavior as in Cocoa.
2014-05-31 21:33:59 -07:00
Alexandre Wilhelm 700b1c50af Fixed: refactoring delegate methods 2014-05-30 12:27:43 -07:00
Alexandre Wilhelm 9e1c363a0a Fixed: changed a bit the readability of the file 2014-05-30 12:04:51 -07:00
Alexandre Wilhelm bbe3065f19 Merge branch 'NEW--CPTextView' of https://github.com/daboe01/cappuccino into NEW--CPTextView 2014-05-30 11:37:50 -07:00
Alexandre Wilhelm 1716a0ebca New: Added protocol CPTextViewDelegate 2014-05-30 11:37:37 -07:00
daboe01 ed66339e94 corrected inheritance 2014-05-30 20:36:14 +02:00
Alexandre Wilhelm 441774e61c New: Added protocol CPTextDelegate 2014-05-30 11:27:31 -07:00
Alexandre Wilhelm c6fd14afd2 Fixed: capp_lint 2014-05-30 11:12:29 -07:00
Alexandre Wilhelm 27ed9ca7fd Merge branch 'NEW--CPTextView' of https://github.com/daboe01/cappuccino into NEW--CPTextView 2014-05-30 10:58:29 -07:00
Alexandre Wilhelm 50fda906bd Fixed: CPLog.error is used instead of abstract exception 2014-05-30 10:49:10 -07:00
daboe01 6c7c60037b next try 2014-05-30 19:44:37 +02:00
daboe01 91a429ea77 another try 2014-05-30 19:19:15 +02:00
daboe01 2dbe01e90a more dom protection 2014-05-30 18:52:00 +02:00
daboe01 3d7dd41223 dom projection 2014-05-30 17:17:28 +02:00
Alexandre Wilhelm a83b9109bf Fixed: typo in CPDatePicker 2014-05-29 15:13:17 -07:00
Alexander Ljungberg fdb079548e Merge pull request #2103 from mrcarlberg/fast_msg_send
Fixed: Faster objj_msgSend
2014-05-29 21:51:57 +01:00
daboe01 91495c8595 more dom protection 2014-05-29 20:37:27 +02:00
daboe01 c3e997168a protecting document access with PLATFORM(DOM) 2014-05-29 20:31:55 +02:00
daboe01 c3e6f4f7b6 automated tests and cleanup 2014-05-29 16:27:07 +02:00
Antoine Mercadal effd837cd0 Merge pull request #2126 from Dogild/DatePickerTabIssue
Fixed: CPDatePicker firstResponder issue
2014-05-27 11:15:00 -07:00
Alexandre Wilhelm 089d564934 Fixed: CPDatePicker firstResponder issue
Previously, the textual datePicker didn't work because it couldn't become the firstResponder.
This PR fixed another issue as well. Previously it wasn't possible to modify a date when moving only with tab and when the datePicker came firstResponder with tabulation.
2014-05-27 10:12:02 -07:00
daboe01 e600ec95ed font panel fix 2014-05-25 09:27:54 +02:00
daboe01 cbd5853389 formatting 2014-05-24 19:32:25 +02:00
daboe01 4e3a086993 beginning/end of line navigation + cleanup 2014-05-24 08:53:53 +02:00
daboe01 5f23dfb034 smart cutting+cleanup 2014-05-23 21:46:59 +02:00
Alexander Ljungberg 90c65c2927 Merge pull request #2125 from Dogild/bootstrapRegex
Fixed: bootstrap doesn't handle specific OpenJDK Runtime Environment version
2014-05-23 11:55:14 -07:00
Alexandre Wilhelm 7958775c6a Fixed: bootstrap doesn't handle specific OpenJDK Runtime Environment version
Previously, bootstrap didn't handle some OpenJDK Runtime Environment version as: rhel-2.4.7.1.el6_5-x86_64 u55-b13.
Now it did, the regular expression to catch the version of the jdk was wrong.

Fixes #2113
2014-05-23 10:38:56 -07:00
daboe01 99f59490a3 fix <cr> issue 2014-05-23 13:14:29 +02:00
Antoine Mercadal ff99812c4d Merge pull request #2124 from Dogild/fakePaste
Fixed: Issue when making a paste with a right click
2014-05-22 16:45:16 -07:00
Alexandre Wilhelm 741ac31ba6 Fixed: Issue when making a paste with a right click
Previously when making a paste with a right click caused a crash because the location of the fake event was set to null.
This crash occurs only if the user didn't hit the keyboard yet.
Now, the location of the fake event takes the location of the last event of the app, who is the right click.
2014-05-22 15:17:40 -07:00
Antoine Mercadal f953b4dc0f FIXED: Warning when closing a popover for the first time
Previously, the _CPPopoverWindow was trying to remove itself as observer while it wasn't defined
as an observer. This would cause a warning. This patch encapsulates addObserver and removeObserver into methods
that actually check if it's already observing/not observing when trying to observe/not observe
2014-05-20 13:37:53 -07:00
daboe01 76ce921778 added manual test 2014-05-20 06:00:36 +02:00
daboe01 4819f3ca15 whitespace formatting 2014-05-13 21:07:41 +02:00
daboe01 48dd722db9 unit test for coalesce on insert 2014-05-13 20:51:53 +02:00
Alexandre Wilhelm 57c2613d37 Fixed: kDefaultXCCAutoShowNotificationOnCappLint is set to NO 2014-05-12 16:11:07 -07:00
Alexandre Wilhelm 804927f893 Fixed: Removed value bindings for Capp Lint in XCodeCapp .xib file. Reference to PR #2119 2014-05-12 16:09:43 -07:00
cacaodev da82887cc0 Merge remote-tracking branch 'upstream/master' into CPTableView-enumerateRows 2014-05-12 18:41:41 +02:00
Alexander Ljungberg f151920404 Fixed: table view selection text colour in Aristo 1.
This is the same fix as in a4702d48b4 but applied to Aristo 1.

Refs #2009, refs #2001.
2014-05-12 16:04:00 +01:00
Alexander Ljungberg 02f36a1abe New: theme kitchen sink manual test to exercise many themable controls in many states at once.
This test makes it easier to verify themes and theme tweaks.
2014-05-12 15:22:39 +01:00
Alexander Ljungberg c04041f110 New: ensure new first responder and key window states work well with all widgets. 2014-05-12 15:21:35 +01:00
Alexander Ljungberg a4702d48b4 Fixed: illegible white on grey text in table view.
If a table view row is selected its text will turn white to offset against the blue selection colour. However, when the table is not the first responder, or the window is in is not the key window, the light grey highlight colour is used instead, but the text remains white.

This fix ensures the text becomes black in this case by utilising the new first responder and key window theme states.

Fixes #2009, fixes #2001.
2014-05-12 15:21:08 +01:00
Alexander Ljungberg ba27a4cc4a Fixed: new first responder and key window theme states not always applied. 2014-05-12 15:17:49 +01:00
Alexander Ljungberg c28da78294 Fixed: nib2cib of segmented control would not convert enabled state. 2014-05-11 22:17:32 +01:00
Alexander Ljungberg 61f6ef4c19 Fixed: crash in CALayer when running non-DOM platform. 2014-05-11 22:11:43 +01:00
Alexander Ljungberg d46b9b5aad Fixed: text date picker stepper incorrectly enabled after decode.
Without this fix the textual date picker would properly disable the text field bit but not its stepper when unarchived.
2014-05-11 22:11:08 +01:00
Alexander Ljungberg 7fc014f5d9 Fixed: contentInset theme value read 2x in tool bar. 2014-05-11 22:09:23 +01:00
Alexander Ljungberg b28e0d15d8 Fixed: nib2cib of date picker would not convert enabled state.
Without this fix, if a disabled date picker was converted with nib2cib it would come out enabled.
2014-05-11 21:34:26 +01:00
Alexander Ljungberg 0cc1679f64 New: nib2cib support for the standard color panel toolbar item. 2014-05-11 16:39:53 +01:00
Alexander Ljungberg e7a0e9ac70 Fixed: nib2cib "The built in image NSRadioButton is not supported" error.
The nib2cib change which introduced support for the plus and minus template images in nib2cib also broke support for converting radio groups.

This fix restores that support.
2014-05-11 16:39:08 +01:00
Alexander Ljungberg 025a43ea4e New: CPThemeStateKeyWindow for CPView.
Every view in the key window now takes on the 'key window' theme state. This makes it easy to theme everything in inactive windows in more muted colours. Also, combined with the first responder theme state of the previous commit we can have visuals like "first responder but in an inactive window" for text views and such things.
2014-05-11 15:51:17 +01:00
Alexander Ljungberg 050fcf2ab8 New: CPThemeStateFirstResponder for CPView.
When a CPView becomes the first responder it now takes on the 'first responder' theme state, as does all its subviews. This allows it to naturally change appearance when it has the keyboard focus, such as with focus rings and brighter colour schemes.
2014-05-11 15:48:37 +01:00
Alexander Ljungberg c9642fcf35 Test: CPLevelIndicatorTest.
Refs #2071.
2014-05-09 23:24:50 +01:00
Alexander Ljungberg 79c257642c New: visual test for warning/critical state in CPLevelIndicator.
This change makes sure there is both a level indicator which goes into warning and critical display mode for low levels and one which goes into the same for high levels in the manual test for level indicator.

Refs #2071.
2014-05-09 23:04:02 +01:00
Alexander Ljungberg 4f9d9d7a1d Merge pull request #2071 from krodelin/feature-CPLevelIndicator
New: Added bidirectional CPLevelIndicator behaviour
2014-05-09 22:55:12 +01:00
Alexander Ljungberg f14ac355f0 Merge branch 'refs/heads/0.9.7' 2014-05-09 21:34:14 +01:00
Alexander Ljungberg 5111a527b9 This will be Cappuccino 0.9.7-1. 2014-05-09 19:36:10 +01:00
Alexander Ljungberg e0217477ce Merge pull request #2118 from ahankinson/fix-issue2117
Fixed: Variable scope in CPSegmentedControl.j
2014-05-09 19:10:54 +01:00
Alexander Ljungberg 5e3bad2a36 Merge branch 'master' of github.com:cappuccino/cappuccino 2014-05-09 19:07:34 +01:00
Andrew Hankinson 26d6450f0a Fixed: Variable scope in CPSegmentedControl.j
Previously, an errant semicolon resulted in improperly scoped variables in CPSegmentedControl.

This fix removes the semicolon in favour of a comma.

Fixes #2117
2014-05-09 13:15:47 -04:00
Aparajita Fishman 5923f7d859 Fixed: oops, it should have been single backslashes. 2014-05-08 17:40:51 -04:00
Aparajita Fishman 57f6a5ca8c Tweak: use continuation lines so the tmLanguage symbol parser works correctly. 2014-05-08 17:08:27 -04:00
Alexandre Wilhelm dd30ffa7ce Fixed: udpate file help.pages 2014-05-08 10:26:22 -07:00
Alexandre Wilhelm 8f5aa0ea16 Fixed: xCodeCapp documentation is outdated
Fixes #2114
2014-05-08 10:04:51 -07:00
Alexandre Wilhelm 1ddf21a256 Fixed: type in preferences for the update of cappuccino 2014-05-08 09:56:06 -07:00
Antoine Mercadal 9d8796c703 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2014-05-07 10:54:56 -07:00
Antoine Mercadal 59a97272bb FIXED: Crash due to tooltip trying to be attached to a window that is gone
Previously, _CPToolTip was not testing if the view and so parentWindow was still here. During the timer, it might be gone, which would cause crash. This patch ensure the window is still there before showing the tooltip
2014-05-07 10:52:57 -07:00
Alexandre Wilhelm e9d328a309 Merge remote-tracking branch 'origin' into xCodeCappUpdatingCapp 2014-05-06 23:49:49 -07:00
Alexandre Wilhelm 448f2913eb Fixed: Jake clean in xCodeCapp
Previously we used jake clean instead of jake clobber
2014-05-06 23:48:23 -07:00
Aparajita Fishman d92b630069 Merge pull request #1958 from GlennAustin/gla/NoOSX10.5
Fixed: Remove explicit use of Mac OS X 10.5 SDK, replace with "latest OS X"
2014-05-05 17:02:09 -04:00
Antoine Mercadal 584955caa8 FIXED: updateFrameWithSize: was always assuming the popver was open 2014-05-05 13:23:44 -07:00
Antoine Mercadal 951e81158c FIXED: popverWillShow was called to early and contentSize was returning 0,0 if popover was hidden 2014-05-05 13:22:55 -07:00
Antoine Mercadal 2a88e598ff FIXED: Crash when using setContentSize: on a popover that is not shown. 2014-05-05 12:52:58 -07:00
Alexandre Wilhelm 3e5e88b369 Fixed: fixed type in XcodeCapp 2014-05-05 09:50:16 -07:00
Alexandre Wilhelm 4806c52ba6 New: updating Cappuccino from xCodeCapp
This PR add the possibility to update cappuccino from xCodeCapp. How does it work :

- Create a temporary file for cappuccino
- Download Cappuccino. The downloaded Cappuccino will be either the last release or the last version of the master branch (option in the preference)
- Make a jake clean
- Make a jake install

There is a small window to follow the progress of the install (3 steps ; download - clean - install).
If there is a issue with the install, the developer will be notify with which step failed (xCodeCapp internally log everything).
The environment var CAPP_NOSUDO is set to 1. It means, if a developer did a bootstrap or a previous jake install in sudo, the update of cappuccino will fail.

Changed the credit of xCodeCapp and pass it to the version 3.1
2014-05-01 18:52:28 -07:00
Antoine Mercadal 86d186e279 Merge pull request #2112 from Dogild/PopoverContentSize
Fixed: CPPopover doesn't change his frame when changing the contentSize
2014-04-30 17:36:29 -07:00
Antoine Mercadal 5bf5388552 FIXED: setContentSize: to work when no window is initialized yet 2014-04-30 17:05:51 -07:00
Antoine Mercadal c19ed471ca Merge branch 'PopoverContentSize' of https://github.com/Dogild/cappuccino into Dogild-PopoverContentSize 2014-04-30 17:03:50 -07:00
Alexandre Wilhelm 9d694a1589 Fixed: setContentSize doesn't work when called several times
Previously when calling setContentSize several times, the final frame of the view was wrong.
I removed the animation as well. This doesn't work, and need a lot more of implementation.
2014-04-30 16:23:00 -07:00
Alexandre Wilhelm 4dadf0cb95 Fixed: CPPopover doesn't change his frame when with setContentSize
Previously when we changed the contentSize of an open popover, nothing happens.
Now, we the frame change and it's animated if needed
2014-04-30 15:38:13 -07:00
Alexandre Wilhelm de4bc67159 Fixed: the way to add the tooltip's window is wrong
Previously when adding a tooltip, we added it to the platformWindow.
Now we add id to the window of the targeted view.

Fixed #2110
2014-04-30 13:24:18 -07:00
Alexandre Wilhelm af37616e48 Fixed: CPToolTip still shown when closing window asynchronous …
When closing a windows asynchronous, the tooltip of views of the window could stay shown.
Fixed #2110
2014-04-29 16:43:32 -07:00
Antoine Mercadal 07f7ad0a05 FIXED: Crash when hit CMD+Z on a control in a CPPopover
Previously, there were collision in addition delegate bitmask identifiers between CPWindow and _CPPopoverWindow.
This patch fixes this collision
2014-04-23 11:28:41 -07:00
Antoine Mercadal fd355636d0 Merge pull request #2108 from Dogild/xCodeCappOptionsNotification
New: Added option in xCodeCapp for displaying error in notification
2014-04-22 18:29:46 -07:00
Alexandre Wilhelm e8528271ee Fixed: tableView doens't update its content with capp_lint 2014-04-22 11:42:19 -07:00
Alexandre Wilhelm 41ed80e0c4 Fixed: capp_lint in xCodeCapp doesn't care about xcodecapp-ignore 2014-04-21 19:11:48 -07:00
Alexandre Wilhelm e8fef8104d Fixed: check the entire project with capp_lint doesn't open the reporting window or a notification 2014-04-21 17:44:13 -07:00
Alexandre Wilhelm 30c48df1f0 Fixed: delegate of the notificationCenter is in AppController 2014-04-21 17:34:39 -07:00
Alexandre Wilhelm f14add2791 New: open reporting window when clickin on a notification in xCodeCapp 2014-04-21 17:30:12 -07:00
Antoine Mercadal 14cb6d21a9 FIXED: XCC Preferences Coherency
This patch fixes various UX weirdness with preferences and makes everything aligned.
2014-04-21 16:59:06 -07:00
Alexandre Wilhelm eaa607b48d New: Added option in xCodeCapp for displaying error in notification
Previously it wasn't possible to configure xCodeCapp to show or not errors/warnings and capp_lint with notifications
2014-04-21 15:34:12 -07:00
Antoine Mercadal 0bd2a032bb FIXED: Give basedir option to capp_lint from XCC or it won't work once completely built 2014-04-21 14:03:45 -07:00
Antoine Mercadal d6961889fb FIXED: Do not invoke sudo in install.sh for capp_lint 2014-04-21 11:14:57 -07:00
Antoine Mercadal 51ffd0d64a Revert "Revert "Fixed: path is wrong with local copy""
This reverts commit 6825e3f7ce.
2014-04-21 11:06:30 -07:00
Antoine Mercadal 120ac31394 Merge pull request #2106 from Dogild/CappLintxCode
New: Integration of capp_lint in xCodeCapp
2014-04-21 10:52:18 -07:00
Antoine Mercadal 4284b97b43 Merge pull request #2105 from Dogild/capp_lintInstall
New: capp_lint is installed with jake install
2014-04-21 10:41:36 -07:00
Alexandre Wilhelm d1615567e2 Fixed: xib of xCodeCapp is in format 5.1 2014-04-21 10:30:00 -07:00
daboe01 9ad3e50511 fixed: .insertAttributedString.. does not coalesce 2014-04-19 14:32:54 +02:00
cacaodev 45a59f9aec Code style
Rename _numberOfRowsDidChange -> _dataViewsNeedReloadAfterContentChange.
Subclasses use this method to tell if a full view reloading is needed
when calling -reloadData.
Currently CPOutlineView returns YES - this is the previous behavior.

Added private - (void)_reloadDataForRowIndexes:(CPIndexSet)rowIndexes
columnIndexes:(CPIndexSet)columnIndexes
This is the internal method for reloading objectValues only.
2014-04-19 09:10:51 +02:00
cacaodev 57408d18ae New: ojunit tests for CPTableView -reloadData & -removeTableColumn:
-removeTableColumn: is failing with an « index out of bounds » error.
2014-04-19 09:05:14 +02:00
Alexandre Wilhelm 372372a0aa Fixed: capp_lint doesn't handle protocol
Previously capp_lint didn't handle protocol. Now it does

Fixed #2060
2014-04-18 18:41:27 -07:00
Alexandre Wilhelm 7f35ff5fe5 Fixed: capp_lint for the entire project is not launch from a thread 2014-04-18 11:18:53 -07:00
Alexandre Wilhelm c28cd8a270 Fixed: capp_lint on the entire project doesn't remove the content of the error tableview 2014-04-18 10:47:00 -07:00
cacaodev 3a97db804f Merge remote-tracking branch 'upstream/master' into CPTableView-enumerateRows
Possible regression from #fe260a8
Regression: -reloadData does not reload views any more even if the table is empty (see CPOutlineViewCibTest).
BUG: -removeTableColumn: error.

Conflicts:
	AppKit/CPOutlineView.j
	AppKit/CPTableHeaderView.j
	AppKit/CPTableView.j
2014-04-18 18:12:55 +02:00
daboe01 4a44b35ea5 fix relayouting optimization bug 2014-04-18 17:17:01 +02:00
daboe01 47aafe9042 better workaorund for chrome bug 2014-04-18 13:28:51 +02:00
Alexandre Wilhelm 973940fcb2 New: Integration of capp_lint in xCodeCapp
Now capp_lint is fully integrated in xCodeCapp.
You can check the entire project with the menuitem of the app.
There is an option in the preference to make a capp_lint (on the file who was just processed) each time a file is processed by xCodeCapp.
Error of capp_lint are reported in the error tableView. The messages displayed the following informations : path of the file, line and error.
2014-04-17 18:26:25 -07:00
daboe01 53d94a1d3d stability improvement 2014-04-18 00:41:33 +02:00
daboe01 5dd3c7c8e8 spooky chrome fix 2014-04-18 00:36:18 +02:00
Martin Carlberg a740f60734 Fixed: Added test case 2014-04-17 16:18:21 +02:00
daboe01 0c2a13f27f reverting erroneous patch 2014-04-17 14:26:01 +02:00
daboe01 da0d3133df typesetter fix 2014-04-17 11:11:53 +02:00
Alexander Ljungberg 2b557a0f8d Merge pull request #2105 from Dogild/capp_lintInstall
New: capp_lint is installed with jake install
2014-04-17 09:40:07 +01:00
daboe01 7abd9a3db9 removed debugging code 2014-04-17 10:03:24 +02:00
daboe01 98b9f57e0e style 2014-04-17 10:00:50 +02:00
daboe01 e064ccd585 more style 2014-04-17 09:59:36 +02:00
daboe01 b5a63ed3fc style 2014-04-17 09:58:04 +02:00
daboe01 147edddb90 added support for setWidthTracksTextView: 2014-04-17 09:55:25 +02:00
Alexandre Wilhelm cd19fc7c81 New: capp_lint is installed with jake install
Previously we had to install capp_lint separately from Cappuccino.
Now capp_lint will be installed with Cappuccino.
Before capp_lint was installed in /urs/local/bin/, now it is in /usr/local/narwhal/bin/.
2014-04-16 16:49:40 -07:00
Alexander Ljungberg b5f9501001 Test: CPObject isSubclassOfClass. 2014-04-16 23:01:17 +01:00
Alexander Ljungberg 8c0cd28f64 Merge branch 'master' of github.com:cappuccino/cappuccino 2014-04-16 22:06:16 +01:00
Martin Carlberg e8e10d4224 Fixed: If receiver in the function objj_msgSend is a class we don't need to check if it is nil as a class can never be nil without the load has already failed. 2014-04-15 13:52:41 +02:00
Antoine Mercadal 3e187df75b FIXED: CPPopover transitionend not correctly called in random cases with Chrome 34
There are some weird race conditions happening in Chrome 34 regarding the transitionend event. Setting the timeout to 10ms is not noticealble for the user, and seems to fix the issue.
2014-04-14 15:19:49 -07:00
Martin Carlberg 88d2ed9e93 Fixed: Forgot to commit the files for the new test case 2014-04-14 18:39:34 +02:00
Martin Carlberg ab5674aa4e Fixed: Send message test cases now work. Also added a test case for send message with 'self' as receiver 2014-04-14 16:38:34 +02:00
Martin Carlberg 81e4b6b37b Fixed: If the function 'eval' is called it might have altered 'self' and from here on we check if 'self' is null before 'objj_msgSend' is called with 'self' as receiver 2014-04-14 16:37:21 +02:00
Martin Carlberg b1507952df Fixed: Checks if 'self' is nil only if self has a chance to be changed when sending messages 2014-04-11 15:41:32 +02:00
Martin Carlberg c4ac7cf375 Fixed: Remove use of hard coded call of objj_msgSend function 2014-04-11 10:47:28 +02:00
Martin Carlberg c23292db8a Fixed: Optimized msgSend code when receiver is an identifier.
If the receiver is an identifier and not an ivar that needs 'self.' infront there is no need to assign it to a temporary variable. Also if the identifier is 'self' there we assume it is not nil.
2014-04-10 18:27:19 +02:00
Alexander Ljungberg a350ffeaa1 Merge pull request #2103 from mrcarlberg/fast_msg_send
Fixed: Faster objj_msgSend
2014-04-10 11:23:59 +01:00
Martin Carlberg 0efb7e67c9 Fixed: Use new fast msgSend function for some foundation classes 2014-04-10 11:03:49 +02:00
Alexander Ljungberg a61e0f6cec Merge pull request #2103 from mrcarlberg/fast_msg_send
Fixed: Faster objj_msgSend
2014-04-10 09:45:55 +01:00
Martin Carlberg 0f5b36e9c5 Fixed: Code generated in test cases is corrected for the fast msgSend function 2014-04-09 17:02:28 +02:00
Martin Carlberg 93e7133076 Fixed: Got decorators working with the fast msgSend 2014-04-09 16:52:14 +02:00
Martin Carlberg 2411edd461 Fixed: Faster objj_msgSend
Conflicts:
	Objective-J/Runtime.js
2014-04-08 20:51:18 +02:00
Antoine Mercadal af83065df5 FIXED: Warning due to use of aDOMEvent.returnValue
This patch fixes a warning thrown by recent versions of Chrome about IE ways of doing. It simply uses aDOMEvent.returnValue if aDOMEvent.preventDefault() and aDOMEvent.cancelBubble if aDOMEvent.stopPropagation are not avavailable
2014-04-08 11:41:45 -07:00
Antoine Mercadal 1557c567d4 FIXED: crash due to wrong delegate bitmask 2014-04-03 15:56:04 -07:00
Antoine Mercadal 8bdaeab998 FIXED: Selection behavior when implementing selectionIndexesForProposedSelection
Previously, when delegates implemented tableView:selectionIndexesForProposedSelection:, the selection with arrow were broken. This patch ensure to try to select next/previous row if the current row cannot be selected.
It also cleans up the selection indexes when sending selectAll: as Cocoa does.
2014-04-03 14:10:00 -07:00
Antoine Mercadal 6825e3f7ce Revert "Fixed: path is wrong with local copy"
This reverts commit de2397fa05.
2014-04-03 12:35:44 -07:00
Antoine Mercadal 4602549ec8 STYLE: fix coding style issue 2014-04-03 11:34:33 -07:00
Antoine Mercadal a7b2df2450 Merge pull request #2082 from zittix/patch-2
FIXED: CPSegementedControl with nib2cib crashes
2014-04-03 11:33:27 -07:00
daboe01 3c0f6d3631 fix for menu enabled state not beeing visually updated upon change 2014-04-03 20:00:28 +02:00
Antoine Mercadal 7ac37b75f3 Merge pull request #2097 from Asriwi/fix-textfield-placeholder
Fixed: show placeholder string while editing empty CPTextField
2014-04-03 10:50:05 -07:00
Antoine Mercadal b1e6d57bf1 Merge pull request #2096 from daboe01/fix-text-clobbering-multiple-windows
Fixed: editing textFields on different windows can clobber each others contents
2014-04-03 10:45:12 -07:00
Antoine Mercadal f19c6a0a5b Merge pull request #2100 from Dogild/TableViewWillRemoveView
New: Added delegate tableView:willRemoveView:forTableColumn:row
2014-04-03 10:44:35 -07:00
Antoine Mercadal 789279fe76 Merge pull request #2098 from Dogild/CPBrowserDelegate
New: Added CPBrowserDelegate protocol
2014-04-03 10:43:37 -07:00
Antoine Mercadal 39a8d8803a Merge pull request #2095 from Dogild/CPControlDelegate
New: Added CPControlTextEditingDelegate and CPTextFieldDelegate protocol
2014-04-03 10:43:13 -07:00
Antoine Mercadal f4ce73fc0d Merge pull request #2094 from Dogild/CPWindowDelegateProtocol
New: Added CPWindowDelegate protocol
2014-04-03 10:42:44 -07:00
Antoine Mercadal cac9d9266c Merge pull request #2093 from Dogild/CPTokenFieldDelegate
New: Added CPTokenFieldDelegate protocol.
2014-04-03 10:42:27 -07:00
Antoine Mercadal 7e94d02fb7 Merge pull request #2092 from Dogild/CPRuleEditorDelegate
New: Added CPRuleEditorDelegate protocol
2014-04-03 10:42:10 -07:00
Antoine Mercadal f3913b1dd2 Merge pull request #2091 from Dogild/CPComboBoxDelegate
New: Added CPComboDelegate protocol
2014-04-03 10:41:40 -07:00
Antoine Mercadal 50fc716c15 Merge pull request #2090 from Dogild/CPMenuDelegateProtocol
New: Added protocol CPMenuDelegate
2014-04-03 10:41:21 -07:00
Antoine Mercadal 50412392f8 Merge pull request #2089 from Dogild/CPImageDelegateProtocol
New: Added protocol CPImageDelegate
2014-04-03 10:40:59 -07:00
Antoine Mercadal 1b80859022 Merge pull request #2088 from Dogild/CPSoundDelegateProtocole
New: Added protocol CPSoundDelegate
2014-04-03 10:40:42 -07:00
Antoine Mercadal c6bd758793 Merge pull request #2087 from Dogild/CPAnimationDelegateProtocol
New: Added protocol CPAnimationDelegate
2014-04-03 10:40:07 -07:00
Antoine Mercadal cd4d657815 Merge pull request #2086 from Dogild/SplitViewDelegateProtocol
New: Added CPSplitViewDelegate protocol
2014-04-03 10:39:28 -07:00
Antoine Mercadal a4852b7a21 Merge pull request #2085 from Dogild/CPPopoverDelegateProtocole
New: Added CPPopoverDelegate protocole
2014-04-03 10:39:07 -07:00
Antoine Mercadal 0b3c06abc0 Merge pull request #2083 from Dogild/CPDatePickerAltCommandButton
New: Graphical CPDatePicker clicking on the arrows with key mask Command/Control/Alternate
2014-04-03 10:38:35 -07:00
Alexander Ljungberg 1b351ad5bb New: + CPColor checkerBoardColor for debug use.
This color has a standard 'transparency' checkerboard pattern which is especially useful for our scrolling tests where it makes scrolling easy to visualise.

Refs #2078, #2079.
2014-04-03 11:38:11 +01:00
Alexander Ljungberg 1a1fc3ef21 Merge pull request #2079 from mockingbird/fix-osx-scrolling
Fix OS X scrolling issue.  Closes #2078.
2014-04-03 10:52:24 +01:00
Saikat Chakrabarti fa3f18c88b Have CPWindow setContentView check that the new view is not the same as the existing content view. 2014-04-02 22:56:22 -07:00
Alexandre Wilhelm 904454d737 New: added delegate outlineView:willRemoveView:forTableColumn:item: in CPOUtlineView 2014-04-02 19:27:40 -07:00
Alexandre Wilhelm c1fb54ecad New: Added delegate tableView:willRemoveView:forTableColumn:row
Added delegate tableView:willRemoveView:forTableColumn:row in CPTableView
2014-04-02 13:55:39 -07:00
Antoine Mercadal bd88b28310 Merge pull request #2099 from Dogild/bootstrap
Fixed: path is wrong with local copy
2014-04-01 18:26:30 -07:00
Alexandre Wilhelm de2397fa05 Fixed: path is wrong with local copy
Previously when using a local copy to install Cappuccino, we used to copy the local capp-base at /usr/local/narwhal and then we tried to move /usr/local/narwhal/cappuccino-cappuccino-base*/* to /usr/local/narwhal/. .
Now we move /usr/local/narwhal/cappuccino-base*/* to /usr/local/narwhal/. .
2014-04-01 18:09:14 -07:00
Alexandre Wilhelm 2513cf0969 New: Added CPBrowserDelegate protocol
Added CPBrowserDelegate protocol
Also, now, delegate methods are called as we are used to do it in Cappuccino
2014-03-30 18:27:12 -07:00
daboe01 15e16d86e4 fix for text clobbering when switching windows 2014-03-29 20:19:16 +01:00
Alexandre Wilhelm 26118ee881 New: Added CPControlTextEditingDelegate and CPTextFieldDelegate protocol
Added CPControlTextEditingDelegate and CPTextFieldDelegate protocol
2014-03-28 11:49:18 -07:00
Alexandre Wilhelm 232cf69006 Fixed: wonrd params for the method _sendDelegateWindowWillReturnUndoManager 2014-03-27 19:54:15 -07:00
Alexandre Wilhelm 9d2fba308d New: Added CPWindowDelegate protocol
Added CPWindowDelegate protocol
Also, now, delegate methods are called as we are used to do it in Cappuccino
2014-03-27 19:52:06 -07:00
Alexandre Wilhelm 1171c9a0b2 New: Added CPTokenFieldDelegate protocol.
Added CPTokenFieldDelegate protocol.
Also, now, delegate methods are called as we are used to do it in Cappuccino
2014-03-27 17:43:07 -07:00
Alexandre Wilhelm 9b397245f8 New: Added CPRuleEditorDelegate protocol
Added CPRuleEditorDelegate protocol.
Also, now, delegate methods are called as we are used to do it in Cappuccino
2014-03-27 15:25:38 -07:00
Alexandre Wilhelm 59b80ab8f6 New: Added CPComboDelegate protocol 2014-03-27 14:50:25 -07:00
Alexandre Wilhelm 18258877a8 New: Added protocol CPMenuDelegate
Added protocol CPMenuDelegate.
Also, now, delegate methods are called as we are used to do it in Cappuccino
2014-03-27 14:17:34 -07:00
Alexandre Wilhelm e2b12c730e Fixed: param of setDelegate: does not conform to protocol CPImageDelegate 2014-03-27 13:55:42 -07:00
Alexandre Wilhelm 0a85b4b383 New: Added protocol CPImageDelegate.
Added protocol CPImageDelegate.
Also, now, delegate methods are called as we are used to do it in Cappuccino
2014-03-27 13:52:59 -07:00
Alexandre Wilhelm d5af9806ea New: Added protocol CPSoundDelegate
Added protocol CPSoundDelegate.
Also, now, delegate methods are called as we are used to do it in Cappuccino
2014-03-27 13:33:32 -07:00
Alexandre Wilhelm 104761d064 Fixed: AppController of CPAnimationTest does not implement protocol CPAnimationDelegate 2014-03-27 12:21:38 -07:00
Alexandre Wilhelm 59065418ac Fixed: CPAnimationDelegate protocol methods are required 2014-03-27 12:19:51 -07:00
Alexandre Wilhelm 7ccdc50637 New: Added protocol CPAnimationDelegate
Added protocol CPAnimationDelegate.
Also, now, delegate methods are called as we are used to do it in Cappuccino

Test app in Tests/Manual/CPAnimationTest.
2014-03-27 12:11:22 -07:00
Alexandre Wilhelm f8ae61058e New: Added CPSplitViewDelegate protocol
Added the CPSplitViewDelegate protocol.
Also, now, delegate methods are called as we are used to do it in Cappuccino
2014-03-26 17:14:27 -07:00
Alexandre Wilhelm cc9d896cf8 New: Added CPPopoverDelegate protocole
Added CPPopopverDelegate protocole
2014-03-25 21:03:00 -07:00
Ashley Williams c5637ea29b Formatting: Fixed formatting in _CPPopoverWindow
Refs #2137
2014-03-24 05:08:36 -07:00
Ashley Williams be3c4abbce Fixed: CPPopover not closing in some browsers
In browsers without support for _DOMElement.removeEventListener CPPopover
throws an exception when closing, and the popover is not removed. This fix
checks for support implicitly using the _browserAnimates variable.
2014-03-23 21:05:56 -07:00
Ashley Williams d5c48567b3 Test: added manual test case to check for placeholder.
Refs #2049
2014-03-23 17:05:57 -07:00
Ashley Williams 5b4e7df856 Fixed: show placeholder string while editing empty CPTextField
Previously, selecting an empty text field hid the contentView, causing the placeholder string to dissapear. This fix leaves the contentView of the text field visible when the internal _stringValue is nil or empty.

Fixes #2049
2014-03-23 16:07:54 -07:00
Antoine Mercadal 23f04b3d09 Merge pull request #2080 from Dogild/CPButtonStateBezelStyleRoundRect-Theme
Fixed: CPRoundRectBezelStyle gives a CPNull ThemeState
2014-03-20 16:45:09 -07:00
Antoine Mercadal 050e3e86e3 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2014-03-20 16:35:12 -07:00
Antoine Mercadal c21d0c64a0 FIXED: dependency to tusk
Previously, jake install was calling tusk to ensure installed packages are up to date, and was used to install the new build. As tusk and all that narwhal suite is deprecated and causes more and more problems, this patch:

 - removes the up-to-date check: it's very likely that no package will never be updated anymore
 - uses a local function to install the freshly build
2014-03-20 16:28:57 -07:00
Alexandre Wilhelm 970b176fbf New: Graphical CPDatePicker clicking on the arrows with key mask Command/Control/Alternate
Now when clicking on the arrows with the key mask Command/Control or Alternate change the date to 1 year or 10 years as in Cocoa.
2014-03-20 15:57:25 -07:00
Antoine Mercadal 9e918cc717 NEW: Ability to perform offline bootstraping
Previously, bootstrap.sh was always trying to fetch cappuccino-base from github. This patch provides a new option "--copy-local [PATH]" that will let the user give a path of a local copy of the cappuccino-base zip. This can be pretty useful in an automated build system that cannot always access the internet.
2014-03-20 15:23:47 -07:00
Mathieu Monney 4a31467afb FIXED: CPSegementedControl with nib2cib crashes
When having a CPSegmentedControl within a a XIB files, nib2cib crashes with the following error:

```
'undefined' is not an object (evaluating 'self._themeStates[aSegment].without')
```

This pull request fixes the problem by making sure that the drawBezel method is called with a valid segment index when accessing the themeState.

Reduction: https://dl.dropboxusercontent.com/u/14629300/BugCPSegmentedControl.zip
2014-03-17 10:46:39 +01:00
Alexandre Wilhelm 86f07245d4 Fixed: CPRoundRectBezelStyle gives a CPNull ThemeState
Previously with the CPRoundRectBezelStyle we got a CPNull themeState. Now we get an instance of ThemeState with the theme CPButtonStateBezelStyleRoundRect. CPButtonStateBezelStyleRoundRect is equal to CPThemeState("roundRect").
2014-03-11 13:18:26 -07:00
Alexander Ljungberg d51f179c2d Fixed: error when running some XML tests with rhino.
This problem causes error in Travis that are not errors with JSC.
2014-03-10 22:44:00 +00:00
Saikat Chakrabarti 974942a736 Fix OS X scrolling issue. Closes #2078. 2014-03-10 14:37:49 -07:00
Alexander Ljungberg 31d17cada7 Merge pull request #2077 from mockingbird/fix-cpcheckbutton-theme-bug
Fix bug with unsetThemeState + more tests.
2014-03-10 19:27:04 +00:00
Saikat Chakrabarti 647686e68e Fix CPViewTest 2014-03-10 12:17:23 -07:00
Alexander Ljungberg 959212a95f Merge pull request #2077 from mockingbird/fix-cpcheckbutton-theme-bug
Fix bug with unsetThemeState + more tests.
2014-03-10 17:55:03 +00:00
Saikat Chakrabarti 45df8c0f74 Fix bug with unsetThemeState + more tests. 2014-03-09 15:15:11 -07:00
Alexander Ljungberg 1dbd41a746 Fixed: error in Internet Explorer if Info.plist was served with wrong content type.
Without this fix, in Internet Explorer the plist parser would only receive an empty XML document for the main Info.plist (and any other such loaded documents) if the server did not provide the content type "text/xml".

This fix parses the XML correctly even if there is no such content type.

Fixes #2051.
2014-03-06 14:16:00 +00:00
Alexander Ljungberg 8c43f4f628 Fixed: theoretical error while skipping whitespace in XML plists.
This fix ensures the PLIST_FIRST_CHILD() code gets to run both statements in the XML parsing while loop.

There's no obvious way to trigger an error due to this bug, but better correct than wrong.

Refs #2051.
2014-03-06 14:13:22 +00:00
Alexander Ljungberg 633445883e Test: CFPropertyList.propertyListFromXML.
These tests validate some basic edge cases with the parsing of XML plists.

Refs #2051.
2014-03-06 14:09:18 +00:00
Alexander Ljungberg e6acc3c336 Fixed: missing var, minor tweaks.
Refs #2073.
2014-03-06 14:03:46 +00:00
Alexander Ljungberg 90b947a7da Merge pull request #2073 from mockingbird/set-backed-cptheme
Change CPThemes to use sets instead of bitmasks. Closes #2015.
2014-03-06 12:25:47 +00:00
Saikat Chakrabarti b6b4015a82 Introduce .and and .without syntax for ThemeStates. 2014-03-01 23:26:20 -08:00
Saikat Chakrabarti 2fd8940c02 Allow array arguments to various methods that take ThemeStates 2014-03-01 23:11:24 -08:00
Saikat Chakrabarti 7408710761 Move placement of CPThemeStates cache to above the cache method for clarity. 2014-02-28 11:14:46 -08:00
Alexander Ljungberg e4a4dd3219 Merge pull request #2073 from mockingbird/set-backed-cptheme
Change CPThemes to use sets instead of bitmasks. Closes #2015.
2014-02-28 16:56:20 +00:00
Saikat Chakrabarti 745ad7cc34 Clean up the interface a bit to consolidate ThemeState methods onto one object. Keep CPThemeState as just a helper function. 2014-02-26 13:11:43 -08:00
cacaodev 821f8fea6f FIXED: Error when binding several objects to the same objectController.selection.keyPath and objectController selection changes. Fixes issue #2039 2014-02-26 15:07:44 +01:00
Saikat Chakrabarti b0d90bb612 ThemeState is a string now instead of an int on a CPView 2014-02-23 16:03:56 -08:00
daboe01 b439e0cfa0 symbolic constant 2014-02-22 20:33:17 +01:00
Saikat Chakrabarti 68952b273b Add a bunch of unit tests for CPTheme.j 2014-02-21 14:30:09 -08:00
Saikat Chakrabarti df148e4946 Fix a small typo in CPTheme.j themestate caching 2014-02-21 14:29:31 -08:00
Saikat Chakrabarti 8b2f2fe24d Add new unit tests for CPView 2014-02-21 13:11:08 -08:00
cacaodev 4b8a91fb8c Merge remote-tracking branch 'upstream/master' into CPAnimationContext
Conflicts:
	AppKit/CPCompatibility.j
2014-02-21 20:39:35 +01:00
Martin Carlberg ee668df440 Fixed: Ivars with accessors in a Category failed with duplicate ivar error 2014-02-21 12:27:52 +01:00
Udo Schneider 6cae917058 New: Added bidirectional CPLevelIndicator behaviour
Depending on whether min < max or max > min CPLevelIndicator changes the order of the normal/warning/critical color. This commit enables this behavior for both cases.
2014-02-21 08:43:00 +01:00
Saikat Chakrabarti cf99a7bf18 Fix bug that was turning dictionary keys into objects 2014-02-20 18:14:01 -08:00
Saikat Chakrabarti 727b519750 Remove unused method in CPTheme 2014-02-20 18:09:47 -08:00
Saikat Chakrabarti 861d093d80 All ThemeStates always have at least one state - the normal state 2014-02-20 17:52:16 -08:00
Saikat Chakrabarti c3d2decdec Fix bugs with CPThemeAttribute encoding and decoding 2014-02-20 17:30:28 -08:00
Saikat Chakrabarti d862d701f3 Add note to ThemeState object about it being private 2014-02-20 17:30:28 -08:00
Saikat Chakrabarti 883c4a185d Some cleanup of CPSegmentedControl.j 2014-02-20 17:30:28 -08:00
Saikat Chakrabarti 7eb35ef33d Clarify documentation for CPThemeState() 2014-02-20 17:30:28 -08:00
Saikat Chakrabarti 1563b0bf55 Get all tests to pass 2014-02-20 17:30:28 -08:00
Saikat Chakrabarti bad731c86f Fix subtracting theme states 2014-02-20 17:30:28 -08:00
Saikat Chakrabarti 5309cc5916 Change CPTheme implementation to fix how searching for a matching theme works 2014-02-20 17:30:28 -08:00
Saikat Chakrabarti f8ef6ab397 Fix accidental semicolon 2014-02-20 17:30:27 -08:00
Saikat Chakrabarti 9e61991ad2 Fix bug when setting themeStates in a themeAttribute 2014-02-20 17:30:27 -08:00
Saikat Chakrabarti c644e8a30f Change CPTheme to be hash-backed to make it a bit faster 2014-02-20 17:30:27 -08:00
Saikat Chakrabarti 45a237af16 Handle null inputs for subtracting CPThemes. 2014-02-20 17:30:27 -08:00
Saikat Chakrabarti 0450fdb542 Get jaking working 2014-02-20 17:30:27 -08:00
Saikat Chakrabarti 7d304fbd51 First round of changes to change theming system to use arrays and not bitmasks as their underlying datatype 2014-02-20 17:30:27 -08:00
Antoine Mercadal 33df895709 Merge pull request #2070 from primalmotion/doxygen-theme-refresh
NEW: Doxygen theme refresh [+3]
2014-02-20 12:25:20 -08:00
daboe01 4fb677ed23 fontmanager fix 2014-02-19 20:55:05 +01:00
daboe01 4f0bd7f461 typo 2014-02-18 20:08:39 +01:00
daboe01 01eecdb698 more missing prototypes 2014-02-18 20:07:29 +01:00
Antoine Mercadal 22ef6ca56a Merge pull request #2067 from Dogild/DatePickerOneDigit
Fixed: Textual CPDatePicker issue with number of digit
2014-02-17 15:34:26 -08:00
Antoine Mercadal 2e015c9816 NEW: Doxygen theme refresh
See screenshots attached to the PR for example.
2014-02-17 15:15:57 -08:00
Alos 1d40b5010e Merge branch 'layoutSubview-fix' of github.com:Alos/cappuccino into layoutSubview-fix
Conflicts:
	AppKit/CPTabView.j
2014-02-16 23:28:57 -06:00
Alos 9d25f1c073 Fixed layoutSubviews
Added missing setNeedsLayout
2014-02-16 23:25:22 -06:00
Alos 2a8de9cb28 Merge branch 'layoutSubview-fix' of github.com:Alos/cappuccino into layoutSubview-fix 2014-02-16 23:18:24 -06:00
Alos 67767ede17 Fixed layoutSubviews
Added missing setNeedsLayout
2014-02-16 23:16:38 -06:00
Alos 03db4d73ad Merge branch 'layoutSubview-fix' of github.com:Alos/cappuccino into layoutSubview-fix
Conflicts:
	AppKit/CPTabView.j
2014-02-16 23:07:36 -06:00
Alos fcb1f4665f Fixed an ugly merge 2014-02-16 22:38:41 -06:00
daboe01 5ca41a6fff style 2014-02-15 19:47:50 +01:00
daboe01 e4f71420fc prototypes+style 2014-02-15 12:43:09 +01:00
daboe01 d5456ed1db formatting+prototypes 2014-02-14 18:09:04 +01:00
daboe01 e3335c5843 formatting+ fix prototypes 2014-02-14 18:05:45 +01:00
Alexander Ljungberg 77ea0d3ea6 Merge pull request #2069 from Dogild/PreprocessBrew
Fixed: Wrong link to install homebrew
2014-02-13 22:34:32 +00:00
Alexandre Wilhelm 23ff035eb3 Fixed: Wrong link to install homebrew
Previously the link to install homebrew was wrong.
2014-02-13 13:38:36 -08:00
Alexander Ljungberg 9906173a3f Merge pull request #2066 from CarlRosell/master
Fixed: Broken Documentation.
2014-02-13 12:48:21 +00:00
Alexander Ljungberg c6dd18ce40 Fixed: typo. 2014-02-13 12:41:20 +00:00
Alexander Ljungberg a31ad2c367 Fixed: CPAttributedString isEqual: despite attribute differences.
As soon as a range reached the end of the string the equality test would end with a YES, without even comparing the final attribute dict.
2014-02-13 12:41:14 +00:00
Alexander Ljungberg 7e20422e20 Test: CPAttributedString coding. 2014-02-13 12:17:55 +00:00
Alexander Ljungberg bd2f63c232 Improve CPAttributedString coding.
Refs #2050.
2014-02-13 12:17:37 +00:00
Alexander Ljungberg 532a874ba6 Merge pull request #2050 from daboe01/NEW--archiving-for-CPAttributedString
NEW: CPCoding for CPAttributedString
2014-02-12 22:02:18 +00:00
Alexander Ljungberg 48fa46e0d5 Formatting: CPAttributedString.
Refs #2045.
2014-02-12 21:57:44 +00:00
Alexander Ljungberg f72119f1b6 Formatting: CPAttributedStringTest.
Refs #2045.
2014-02-12 21:57:44 +00:00
daboe01andAlexander Ljungberg 3063d53a2b more formatting 2014-02-12 21:57:44 +00:00
daboe01andAlexander Ljungberg e4163c5da4 formatting 2014-02-12 21:57:44 +00:00
daboe01andAlexander Ljungberg a34ae45b05 formatting 2014-02-12 21:57:44 +00:00
daboe01andAlexander Ljungberg d8e4f1150e more protection against edge cases 2014-02-12 21:57:44 +00:00
daboe01andAlexander Ljungberg c2534ae6da unit-tests + simplification 2014-02-12 21:57:44 +00:00
daboe01andAlexander Ljungberg 342ea97406 yet another minor fix 2014-02-12 21:57:43 +00:00
daboe01andAlexander Ljungberg 6f66c06111 fixed one last minor glitch 2014-02-12 21:57:43 +00:00
daboe01andAlexander Ljungberg aaeffe61a6 editing fix 2014-02-12 21:57:43 +00:00
daboe01andAlexander Ljungberg f5daa96c8e minor fix 2014-02-12 21:57:43 +00:00
daboe01andAlexander Ljungberg 67fed5f3d7 fixing editing semantics 2014-02-12 21:57:43 +00:00
daboe01 067e6bf93d formatting 2014-02-12 18:00:11 +01:00
daboe01 13dc31dc1f formatting 2014-02-12 07:14:49 +01:00
daboe01 7f6bf21270 more formatting 2014-02-12 07:13:21 +01:00
daboe01 d647258856 formatting 2014-02-12 05:59:34 +01:00
daboe01 1eb7ed5e9c formatting 2014-02-11 22:04:39 +01:00
daboe01 e78f1b05a7 formatting 2014-02-11 20:33:47 +01:00
Antoine Mercadal 4531b017b3 Merge pull request #2054 from cacaodev/CPPredicateEditor-dates
Fixed: support for dates (CPDatePicker) in CPPredicateEditor
2014-02-11 10:53:15 -08:00
Antoine Mercadal 101a03c38d Merge pull request #2044 from krodelin/fix-CPNumber-numberWithBool
Fixed: CPNumber>>numberWithBool: breaks CPComparisonPredicate
2014-02-11 10:51:43 -08:00
daboe01 e45140b7ea formatting 2014-02-10 21:28:25 +01:00
daboe01 41747a7a04 formatting 2014-02-10 21:25:56 +01:00
daboe01 e448430d8a fix of circular imports 2014-02-10 21:07:57 +01:00
daboe01 394b1a1602 fix circular imports 2014-02-10 06:02:28 +01:00
daboe01 85abd5a8c3 eliminate warnings + style 2014-02-09 11:00:25 +01:00
daboe01 b9e0eb5b76 typos 2014-02-08 21:14:56 +01:00
daboe01 a8eae73b66 manual test 2014-02-08 20:46:04 +01:00
daboe01 9edd8d6f66 CPTextView commit 2014-02-08 20:43:15 +01:00
Alexandre Wilhelm 8147f648a1 Fixed: Textual CPDatePicker issue with number of digit
Previously, the day/month/hour of the textual datePicker had always two digits, even when the number was under 10. For instance the day 8 was displayed 08.
Now it's like in cocoa, 8 is displayed 8.

Fixes #2059
2014-02-07 16:36:05 -08:00
Carl Rosell 30b1fa9c5b Docs: Added @class to make_headers documentation, 2014-02-05 10:05:58 +01:00
Carl Rosell fa66c2692f Fixed: Broken Documentation. 2014-02-05 09:29:25 +01:00
Antoine Mercadal 1814f6b545 FIXED: Crash when clicking on an empty CPTableView with variable row height.
Previously, clicking anywhere in an empty CPTableView with variable row height was causing a crash due to the code trying to find the latest cached row height. This patch adds a check to ensure the last cached row height is not nil.
2014-01-23 12:56:39 -08:00
Udo Schneider 9d04ad5097 Merge branch 'refactor-locale' into fix-CPNumber-numberWithBool 2014-01-23 21:46:09 +01:00
cacaodev 93b48ba973 Fixed: support for dates (CPDatePicker) in CPPredicateEditor
Before this commit, row templates and views belo,ging to them were copied via archiving/unarchiving.
This was causing problems when the view was not completely CPCoding compliant, like for CPDatePicker.

With this commit, template views use CPCopying (-copy method) when available.
Also added CPCopying for CPDatePicker as a category in CPPredicateEditor.

Test: in CPPredicateEditorTest, on the right panel, choose a keypath, operator, and select 'Dates' in the popup for the right expression.

Fixes #2041
2014-01-17 10:49:52 +01:00
Antoine Mercadal 047983d7bf Merge pull request #2052 from Dogild/CPDatePickerRefactor
Fixed : CPDatePicker textual issues
2014-01-14 16:04:17 -08:00
Alexandre Wilhelm ebccbf28a7 Fixed: issues with timeZone
This PR fixes several issues with the timeZone.
It also changes the way to "calculate" the date of the textual datePicker.
2014-01-14 15:12:10 -08:00
Alexandre Wilhelm 1dc84f9b58 Fixed: issue with _dateWithTimeZone when timeZone is null
Fixed the private method _dateWithTimeZone when aTimeZone is null
2014-01-14 15:10:55 -08:00
Antoine Mercadal 35f3987803 Merge pull request #2048 from mrcarlberg/cpdateformatter_relative_dont_work_in_jan
Fixed: RelativeDateFormating didn't work in January
2014-01-14 15:01:28 -08:00
Antoine Mercadal b6bd132066 Merge pull request #2037 from Dogild/protocolToolbar
New : Added protocol CPToolbarDelegate
2014-01-14 14:49:26 -08:00
Antoine Mercadal 3ce2f28303 Merge pull request #2036 from Dogild/protocolTabView
New : Added CPTabViewDelegate protocol
2014-01-14 14:48:59 -08:00
Antoine Mercadal 0d9cda8a85 Merge pull request #2035 from Dogild/protocolOutlineView
New : Added protocols CPOutlineViewDelegate and CPOutlineViewDataSource
2014-01-14 14:48:44 -08:00
Antoine Mercadal f2decc09a5 Merge pull request #2034 from Dogild/protocolApplication
New : Added CPApplicationDelegate protocol
2014-01-14 14:48:31 -08:00
Antoine Mercadal b1c55b23ee Merge pull request #2033 from Dogild/protocolCollectionView
New: Added CPCollectionViewDelegate protocol
2014-01-14 14:48:14 -08:00
Antoine Mercadal 4622600ab0 Merge pull request #2031 from Dogild/protocolTableView
New : Added protocols CPTableViewDelegate and CPTableViewDataSource
2014-01-14 14:47:39 -08:00
Antoine Mercadal 396358d4e5 Merge pull request #2032 from Dogild/protocolAlert
New : Added protocol CPAlertDelegate
2014-01-14 14:47:19 -08:00
Alexandre Wilhelm 8b975f50dd Fixed : CPDatePicker textual issues
This PR fixes several issues about the textual CPDatePicker :
- Fixed the issue about keyView loop when not assigning the nextKeyView
- Changed the behavior of the component when editing or deleting the date. It works as in cocoa now.
- Fixed bug about frameSize of each component when editing
- Fixed bug about NaN or null values
- Added optimization
- Refactoring the code
2014-01-10 08:52:25 -08:00
daboe01 a1ea371c73 NEW: CPCoding for CPAttributedString 2014-01-10 12:26:52 +01:00
Martin Carlberg acd5442246 Fixed: RelativeDateFormating didn't work in January and was inaccurate for some time intervals around when daylight saving time changed. 2014-01-09 17:16:05 +01:00
Udo Schneider d176dd0623 Fixed: CPNumber>>numberWithBool: breaks CPComparisonPredicate
Commit df2be92 breaks CPComparisonPredicate if one side of the comparison is a property which returns a BOOL.

CPPredicateParser parses literal BOOLs (YES/NO) into 0/1 using CPNumber>>numberWithBool:. CPComparisonPredicate however does not cast a BOOL from a property using numberWithBool:. E.g.

[[YES,NO] filteredArrayUsingPredicate:[CPPredicate predicateWithFormat:'self = YES']]
used to return [true], now it returns [].

This fix addresses the issue by "typecasting" the lhs/rhs values to numbers using CPNumber>>numberWithBool: if they are of type boolean.

Fixes #2028
2013-12-27 18:30:15 +01:00
Alexandre Wilhelm 68310bb479 Fixed: objectValueForTableColumn and numberOfRowsInTableView are required methods 2013-12-10 11:01:49 -08:00
Alexandre Wilhelm e822966464 Fixed: removed unused test case 2013-12-10 11:00:47 -08:00
Alexander Ljungberg febce68bc8 Test: don't run Travis setup quietly to make it easier to track setup errors. 2013-12-09 17:13:43 +00:00
Alexander Ljungberg fadffeedca New: make bootstrap.sh use Github with SSL.
This is the default for Github now and accessing the old bare http URL just causes a redirect to https.
2013-12-09 17:12:52 +00:00
Alexander Ljungberg 2fc501fe59 Fixed: CPDateFormatter stringFromDate:"" did not return a default date.
In Cocoa formatting an empty string actually results in a particular date. For consistency we should handle an empty string the same way.

Refs #2030.
2013-12-09 16:58:55 +00:00
Alexander Ljungberg 21aac76ba2 Fixed: CPDateFormatter getObjectValue: with nil errorDescription crash.
Like for all formatters, a nil errorDescription just means we don't care about the error description if there is an error.

Fixes #2030.
2013-12-09 16:39:53 +00:00
Alexandre Wilhelm fa3ebf2ca7 Fixed: CPAlertDelegate protocol does not implement CPObject protocol 2013-12-09 01:24:51 -08:00
Alexandre Wilhelm d2bf2539b5 Fixed: CPApplicationDelegate protocol does not implement CPObject protocol 2013-12-09 01:24:03 -08:00
Alexandre Wilhelm 8a0acedc94 Fixed: CPCollectionViewDelegate protocol does not implement CPObject protocol 2013-12-09 01:23:14 -08:00
Alexandre Wilhelm 11e5cd4f84 Fixed: CPOutlineViewDelegate and CPOutlineViewDataSource protocol do not implement CPObject protocol 2013-12-09 01:22:05 -08:00
Alexandre Wilhelm 27fdb3116c Fixed: CPTabViewDelegate protocol does not implement CPObject protocol 2013-12-09 01:21:01 -08:00
Alexandre Wilhelm b9c0c89a24 Fixed: CPTableViewDelegate and CPTableViewDataSource protocol do not implement CPObject protocol 2013-12-09 01:20:11 -08:00
Alexandre Wilhelm 8078889a09 Fixed: CPToolbarDelegate protocol do not implement CPObject protocol 2013-12-09 01:19:04 -08:00
Alexandre Wilhelm 5dd4266ccc New : Added protocol CPToolbarDelegate
This pr adds the protocol CPToolbarDelegate
Also, now, delegate methods are called as we are used to do it in Cappuccino.
2013-12-08 19:14:30 -08:00
Alexandre Wilhelm 7d14676bce New : Added CPTabViewDelegate protocol
This PR adds the CPTabViewDelegate protocol
2013-12-08 19:01:50 -08:00
Alexandre Wilhelm db113da121 New : Added protocols CPOutlineViewDelegate and CPOutlineViewDataSource
This PR add protocols CPOutlineViewDelegate and CPOutlineViewDataSource
2013-12-08 18:52:26 -08:00
Alexandre Wilhelm 5b2bfcef7d New : Added CPApplicationDelegate protocol
This PR add the protocol CPApplicationDelegate
2013-12-08 18:42:50 -08:00
Alexandre Wilhelm 4d266f4ad2 New: Added CPCollectionViewDelegate protocol
This PR adds the protocol CPCollectionViewDelegate.
Also, now the delegate methods are called like we are used to do it in Cappuccino.
2013-12-08 18:35:52 -08:00
Alexandre Wilhelm b81a325b28 Fixed : Remove unused method 2013-12-08 18:06:43 -08:00
Alexandre Wilhelm 09eca10eb6 New : Added protocol CPAlertDelegate
This PR adds the protocol CPAlertDelegate.
The delegate methods are called as we are used to in Cappuccino.
2013-12-08 18:01:06 -08:00
Alexandre Wilhelm 7b86465d7b New : Added protocols CPTableViewDelegate and CPTableViewDataSource
This PR adds protocols CPTableViewDelegate and CPTableViewDataSource

Unit test in Tests/AppKit/CPTableViewTest.j
2013-12-08 17:48:41 -08:00
Alexander Ljungberg 7662f89193 Update some more version numbers. 2013-11-28 19:51:15 +00:00
Alexander Ljungberg dbb59f57ea This will be Cappuccino 0.9.7. 2013-11-28 19:48:29 +00:00
Alexander Ljungberg c1f538ece5 Formatting: whitespace.
Refs #1974.
2013-11-28 18:39:01 +00:00
Alexander Ljungberg b4cabc97d1 Merge pull request #1974 from mrcarlberg/protocol
Protocol support for Objective-J
2013-11-28 17:18:16 +00:00
Antoine Mercadal cf2e66d7fe Merge pull request #2021 from Dogild/sheetDoubleClickBug
Fixed: when doubleClicking to open/close a sheet, issues with the parentWindow and the frameOrigin of the sheet
2013-11-25 15:49:08 -08:00
Martin Carlberg e511638962 Fixed: Cleaned up return and parameter types on methods. 2013-11-24 22:21:56 +01:00
Martin Carlberg 8419001810 Merge branch 'master' of https://github.com/cappuccino/cappuccino into protocol 2013-11-22 14:23:52 +01:00
Alexandre Wilhelm e058d2e143 Fixed: when doubleClicking to open/close a sheet, issues with the parentWindow and the frameOrigin of the sheet
When opening a sheet, with a double click the frame origin of the sheet changed and the parent disappeared.
This PR fix this issue.

Test app in Tests/Manual/AttachedSheet/AppController.j
2013-11-21 17:42:43 -08:00
daboe01 40da5a849d formatting 2013-11-19 20:14:35 +01:00
Antoine Mercadal 616f0c61ef Fixed: Typo introduced in previous PR merge 2013-11-18 16:26:50 -08:00
Antoine Mercadal d0ef8a2885 Merge pull request #2005 from adamsowinski/master
Fixes a bug with CPCursor push method.
2013-11-18 16:22:43 -08:00
Antoine Mercadal 985db21ed9 Merge pull request #1990 from spebbe/cpanimation_frame_rate
CPAnimation frame rate fixes.
2013-11-18 16:20:29 -08:00
Antoine Mercadal d0460ad202 Merge pull request #2017 from daboe01/fix-scrollview-sorting-while-editing
Fixed: _editingCellIndex is currently not considered when table columns are pressed
2013-11-18 16:08:57 -08:00
Antoine Mercadal 8ca7227185 Merge pull request #1970 from mrcarlberg/table_header_divider_thickness
New: Added themable attribute for divider thickness in table header view
2013-11-18 16:06:49 -08:00
Antoine Mercadal 6c8a21c1cc Merge pull request #1971 from mrcarlberg/table_view_grid_line_thickness
New: Added themable attribute for grid line thickness in table view
2013-11-18 16:06:01 -08:00
Antoine Mercadal 4a82dbc34d FIXED: Previous commit was actually missing to fill the drop view with the background color.
This patch restore the correct behavior and display corectly colors set as dropview-*-on-background-color
2013-11-15 17:59:41 -08:00
Antoine Mercadal 1cec1b0637 NEW: CPTableView drop view now supports theming
Previously, the style of the blueish view that shows up on CPTableView when user is about to drop something on it was hard coded.
This patch adds the following theme attributes in CPTableView

    // theme of the drop view for CPDragOperationOn on a non selected row
    dropview-on-background-color
    dropview-on-border-color
    dropview-on-border-width
    dropview-on-border-radius

    // theme of the drop view for CPDragOperationOn on a selected row
    dropview-on-selected-background-color
    dropview-on-selected-border-color
    dropview-on-selected-border-width
    dropview-on-selected-border-radius

    // theme of the drop view for CPDragOperationAbove on a non selected row
    dropview-above-border-color
    dropview-above-border-width

    // theme of the drop view for CPDragOperationAbove on a selected row
    dropview-above-selected-border-color
    dropview-above-selected-border-width

Aristo and Aristo2 have been updated, and use the same old hardcoded values.
2013-11-15 17:48:57 -08:00
Antoine Mercadal abd9506d40 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2013-11-15 10:40:10 -08:00
Antoine Mercadal 8f7a32141b FIXED: CPTextField was sometimes returning YES even if disabled
Preiviously, CPTextField's acceptsFirstResponder was returning YES even if the textfield was disabled.
This patch restore the correct Cocoa behavior.
2013-11-15 10:38:31 -08:00
daboe01 ff067374bc fix first responder assignment when pressing a header column 2013-11-15 10:55:05 +01:00
Alexander Ljungberg 6cbfa30652 Fixed: view coordinate conversion broken by previous commit.
Without this fix, -CPView convertPoint:fromView was broken due to the changes made in #1998. In particular, the transform for the fromView would be calculated and then just thrown away if the views were in the same window. This happened to work in some specific cases and the lack of unit tests concealed the error.

This fix properly applies the transforms when two views are in the same window without one of them necessarily being inside the other.

Refs #1998.
2013-11-04 00:03:31 +00:00
Adam Sowinski f5a1a6725d Simplified currentCursor assignment. 2013-10-29 23:35:04 +00:00
Antoine Mercadal 2508fa7a97 Merge pull request #1998 from Dogild/scaling-support
New: Added support for scaling in CPView
2013-10-29 12:54:12 -07:00
Antoine Mercadal 0b351ac2d7 Merge pull request #2011 from Dogild/CPTextMovements
New: Added Movement Codes for CPTextDidEndEditingNotification
2013-10-29 11:27:17 -07:00
Antoine Mercadal 24b44c2acf Merge pull request #2010 from daboe01/fix-textFields-on-different-windows-can-clobber-each-others-contents
Fixed: editing textFields on different windows can clobber each others contents
2013-10-29 11:23:00 -07:00
Alexandre Wilhelm 8f70cebefc Typo 2013-10-29 11:22:55 -07:00
Antoine Mercadal 6e7fc5c887 Merge pull request #2008 from Dogild/souldSelectTableColumnFix
Fixed: shouldSelectTableColumn isn't called in CPTableView and CPOutlineView
2013-10-29 11:22:01 -07:00
Alexandre Wilhelm 7f53d15e75 Fixed: the userInfo of the notification from textDidEndEditing is wrong
Previously, when overriding the method textDidEndEditing, the userInfo notification didn't contain the information about CPTextMovement
2013-10-29 11:13:48 -07:00
daboe01 ad170ed854 Fixed: scroll wheel speed is way to low in firefox
I increased scroll wheel speed to a sensible value
2013-10-29 17:33:12 +01:00
Alexander Ljungberg d3ab2a0f3d New: "//site.com/x" style URL support in CPURL and CFURL.
With this feature, CFURL and CPURL can now correctly transform a relative scheme URL starting with a double-slash.

For example, + CPURL URLWithString:@"//a.se/a" relativeToURL:@"ftp://b.se/c" would represent an absolute URL of "ftp://a.se/a".
2013-10-29 15:03:37 +00:00
Alexander Ljungberg af26523e36 New: text underline support for private _CPImageAndTextView.
This features presents a less hack-y way to underline text for those not afraid to use private, internal APIs.
2013-10-29 11:40:25 +00:00
Alexandre Wilhelm ebc1025fd9 New: Added Movement Codes for CPTextDidEndEditingNotification
This PR adds a new feature for CPControl. Now when leaving the control, the userInfo of the notification CPTextDidEndEditingNotification contains the last movements of the control as in COCOA

Test app in Tests/Manual/CPTextFieldMovementsTest
2013-10-29 01:20:00 -07:00
Adam Sowinski a96242324a Merge branch 'master' of https://github.com/cappuccino/cappuccino 2013-10-28 17:00:42 +00:00
daboe01 d1406e1b8f Fixed: editing textFields on different windows can clobber each others contents
Was be caused by resignFirstResponder not checking that the input owner is self.

Fixes #1983
2013-10-27 13:46:00 +01:00
Alexandre Wilhelm c22f489ee9 Fixed: shouldSelectTableColumn isn't called in CPTableView and CPOutlineView
Previously shouldSelectTableColumn wasn't called in CPTableView and CPOutlineView.
This PR resolves this issue, shouldSelectTableColumn is now called between selectionShouldChangeInTableView and tableViewSelectionIsChanging as in COCOA.

Test app Tests/Manual/TableTest/DelegateSelectionTest/
2013-10-24 22:13:35 -07:00
Antoine Mercadal 0ac74fe16e Merge pull request #2007 from krodelin/fix-CPNumber-numberWithBool
Fixed: Return a Number from CPNumber>>numberWithBool:
2013-10-24 10:37:05 -07:00
Udo Schneider df2be926a5 Fixed: Return a Number from CPNumber>>numberWithBool:
The Cocoa signature for this method
	+ (NSNumber *)numberWithBool:(BOOL)value
implies that a number is being returned. In Cappuccino a Boolean is returned.

This leads to some problems e.g. in
addObserver:forKeyPath:options:context: with CPKeyValueObservingOptionPrior
and observeValueForKeyPath:ofObject:change:context: with CPKeyValueObservingOptionPrior.

Setting CPKeyValueObservingOptionPrior leads to CPKeyValueChangeNotificationIsPriorKey being set to 1 (which should be equal to [NSNumber numberWithBool:YES] as documented in https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Protocols/NSKeyValueObserving_Protocol/Reference/Reference.html. The actual value though is true as [CPNumber numberWithBool:YES] does not return a number but a boolean. This commit fixes this issue.
2013-10-24 19:20:45 +02:00
Adam Sowinski 71ed0d6cfc Merge branch 'master' of https://github.com/cappuccino/cappuccino 2013-10-22 11:19:21 +01:00
Antoine Mercadal 2d96875574 Merge pull request #2004 from Dogild/comboBox-trapMouse
Fixed: CPComboBox don't close when clicking on the scroll
2013-10-21 14:25:20 -07:00
Antoine Mercadal 949c618ff1 Merge pull request #2006 from Dogild/outlineView-selectItem
Fixed: The delegate method shouldSelectItem doesn't work in CPOutlineView
2013-10-21 14:24:35 -07:00
Alexandre Wilhelm 8909576a0b Changed comment 2013-10-20 21:01:10 -07:00
Alexandre Wilhelm 0afc903138 Fixed: The delegate method shouldSelectItem doesn't work in CPOutlineView
Previously the delegate method shouldSelectItem didn't work in CPOutlineView.
It didn't work because the checking method _delegateRespondsToSelectionIndexesForProposedSelection and _delegateRespondsToShouldSelectRow didn't check if the real delegate of the outlineView implemented the methods
2013-10-20 20:57:42 -07:00
Adam Sowinski 8971972a28 Fixed a bug where currentCursor variable was assigned a CPNumber instance instead of CPCursor instance. 2013-10-21 00:26:27 +01:00
Alexandre Wilhelm 2df13b7ffc Fixed: CPComboBox don't close when clicking on the scroll
Previously CPComboBox don't close when clicking on the scroll, now it does

Fixed #1991
2013-10-19 00:40:19 -07:00
Antoine Mercadal bb6b5c1232 Merge pull request #2003 from Dogild/refactor-tableView
Fixed: shouldSelectRow was called with selectionIndexesForProposedSelect...
2013-10-18 13:03:49 -07:00
Alexandre Wilhelm ab1c689e4e Optimization with menu. Fixed issue with unsigned bit and delegate Fixed #1994 2013-10-18 12:01:33 -07:00
Alexandre Wilhelm 7bdedca350 Delegate WillDisplayView is called before setNeedsDisplay now 2013-10-18 11:55:40 -07:00
Alexandre Wilhelm e1eac245a7 Changed naming of the private delegate call. Fixed small bugs 2013-10-18 11:47:46 -07:00
Alexandre Wilhelm cf19aef382 Added method selectionIndexesForProposedSelection in CPOutlineView 2013-10-17 15:54:40 -07:00
Alexandre Wilhelm d6e40332c4 Removed comments 2013-10-17 14:32:34 -07:00
Alexandre Wilhelm 4b8a6ee674 Fixed: shouldSelectRow was called with selectionIndexesForProposedSelection
Previously the method shouldSelectRow was called even it's the method selectionIndexesForProposedSelection was implemented by the delegate. Now it works as in Cocoa.
The method selectionIndexesForProposedSelection is called when it has to be called, like in Cocoa.
This PR adds new methods to check and call the delegate/datasource methods more easily

Test app in Tests/Manual/TableTest/DelegateSelectionTest/
2013-10-17 14:26:19 -07:00
Antoine Mercadal 406a049380 Fixed: Previous commit was preventing to select in the void if selectionShouldChangeInTableView: was not implemented
This patch restore the correct behavior
2013-10-16 16:48:50 -07:00
Antoine Mercadal b2dc9c225c Merge pull request #1999 from Dogild/delegate-CPTableView-Methods
Fixed: Delegate method of CPTableView aren't call in the good order
2013-10-16 16:28:48 -07:00
Antoine Mercadal 86e94178e3 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2013-10-16 16:10:11 -07:00
Antoine Mercadal f75955bb04 Fixed: CPNumberFormatter minimum and maximum wrong encoding when set to nil
Previously, a decoded CPNumberFormatter was converting the minimum and maximum values to 0 if they were set to nil. This was causing unexpected behavior when creating a CPNumberFormatter from a xib. This patch actually decodes _minimum and _maximum values as objects to preserve nil.

Test added in Foundation/CPNumberFormatter.j
2013-10-16 16:07:00 -07:00
Alexandre Wilhelm f0a9696634 Fixed typo 2013-10-16 15:03:35 -07:00
Alexandre Wilhelm 016c267e69 Fixed: Delegate method of CPTableView aren't call in the good order
Previously the call of the delegate method of a CPTableView weren't call in the good order, specially the selecting method.
Now it works as in Cocoa.
Fixed typos

Test app in Tests/Manual/TableTest/DelegateSelectionTest
2013-10-16 15:01:28 -07:00
Antoine Mercadal f6028455b7 Merge pull request #1969 from Dogild/xCodeCappCreateProject
New: Added menu Create Project... in xCodeCapp
2013-10-15 14:05:12 -07:00
Antoine Mercadal ed99833894 Merge pull request #1996 from rgv151/master
PATCH: Implement shouldExpand/Collapse delegate for CPOutlineView
2013-10-15 14:04:46 -07:00
Alexandre Wilhelm ef5f26fd81 New: Added support for scaling in CPView
This PR adds the support of scaling in CPView.
There are two new public methods in CPView : -(void)scaleUnitSquareToSize: and -(void)setScaleSize:
-(void)scaleUnitSquareToSize: works exactly as in COCOA, it means if you set a first scale to 0.5 and then 0.5 again, the scaleSize of the view will be 0.25
-(void)setScaleSize: works with the value given. If you set 0.5 after you just seted 0.5 the scaleSize will be 0.5. This method is definitly better in using, specially when using the scaleSize binding with a slider.

Test app in Tests/Manual/ScalingTest
2013-10-15 14:03:26 -07:00
Antoine Mercadal 2f18218ce5 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2013-10-15 12:41:20 -07:00
Antoine Mercadal 0b5a98d3fe FIXED: lineBreakMode set to CPLineBreakByTruncating* was trimming consecutive white spaces
Previously, using a truncating line break mode on a CPTextField and setting the string value to "test      test" was displaying "test test". This patch changes the css white-space property from "nowrap" to "pre" which preserves the white spaces.
2013-10-15 12:39:03 -07:00
Bruce Doan 918543d617 Merge branch 'master' of https://github.com/cappuccino/cappuccino 2013-10-12 23:00:12 +07:00
Bruce Doan 6f8d6a5b25 Some minor fixes to pass the capp_lint checks 2013-10-09 00:09:30 +07:00
aparajita 95082c3263 Merge pull request #1982 from Dogild/MenuFix
Fixed: Menu disappears when opening a submenu
2013-10-07 04:29:20 -07:00
Bruce Doan 8503081a6f PATCH: Implement shouldExpand/Collapse delegate for CPOutlineView 2013-10-06 23:47:25 +07:00
Alexander Ljungberg 6efefbedcd Test: disabling a highlighted menu item should deselect it.
Refs #1762.
2013-09-23 11:24:54 +01:00
Alexander Ljungberg eef91c0240 Merge pull request #1976 from Dogild/HighlightedDisabledMenu
Fixed: a disabled CPMenuItem could still have a selected background
2013-09-23 11:22:27 +01:00
Björn Sperber 5cefce1cf0 Respect frameRate when scheduling timer in CPAnimation. Treat a frameRate of 0 as "really fast" instead of CPTimer default (10 fps). 2013-09-19 13:52:49 +02:00
Martin Carlberg f0e2daf6c7 Fixed: Add get and set instance methods to class definition when ivar has accessors.
This caused 'Method is not implemented' warnings when a class implemented protocol declared set and get methods as 'accessors' on an ivar.
2013-09-12 21:54:57 +02:00
Martin Carlberg 9f0d8c54e4 Fixed: Uses current protocolDefs when compiling accessors
This caused 'null is not an object' type error when class declaration with 'accessors' declared ivars was in the same file as the protocol it was conforming to.
2013-09-12 21:47:15 +02:00
Alexander Ljungberg b20d711922 Merge pull request #1984 from mrcarlberg/if-empty-statement
Fixed: Compiler now generates correct empty statement after 'if (a);'
2013-09-09 15:53:21 +01:00
Martin Carlberg 23fb618596 Fixed: Compiler now generates correct empty statement after 'if (a);'
Earlier the compiler generated the 'if' without the last ';' when a empty statement is used, with sometimes devastating result. The same if an empty statement was after the 'else'.

I have also added a test case for some different empty statement senarios.
2013-09-09 16:38:38 +02:00
Aparajita Fishman 2dff348cca Fixed: text fields in full platform windows could not be selected. 2013-09-02 22:14:16 -04:00
Martin Carlberg ba0604320e Fixed: Should be 'objj_allocateProtocol' and 'objj_registerProtocol' not 'objc_allocateProtocol' and 'objc_registerProtocol' 2013-08-31 15:33:32 +02:00
Martin Carlberg c979a69e6b Fixed: Compiler can now handle only @action/IBAction declared return type when checking for 'Conflicting return type' method declaration.
Also made the warning message point to correct return type token when type is not declared.
2013-08-28 11:23:55 +02:00
Aparajita Fishman 40e06a634e Fixed: background-color was rendering subviews invisible. 2013-08-26 13:50:42 -04:00
Aparajita Fishman 30441b109f Fixed: windows that were autoresized and not constrainable would obey the global CPWindowConstrainToScreen flag.
Previously, if a window had an autoresizingMask and was marked as not being constrained (for example _CPMenuBarWindow), and the CPWindowConstrainToScreen was set to NO, resizing the platform window would not autoresize the window.

This commit ensures that windows that autoresize but don't care about constraining will resize with the platform window no matter what.

Fixes #1981.
2013-08-23 18:28:40 -04:00
Alexandre Wilhelm f17fd6a448 Fixed: Menu disappears when opening a submenu
Previously when opening a submenu from a menu, the main menu disappears because a issue with the poolMenuWindow.
This PR fixes this bug.
It also handle more properly the case when an user is making several right clicks on a responder (origin problem with the ghost menu).

Fixed #1887
2013-08-23 13:59:11 -07:00
Martin Carlberg 0e4ad998d8 Fixed: Remove all protocols in objj_resetRegisterClasses 2013-08-22 16:54:19 +02:00
Martin Carlberg 9eebb0a64b Fixed: Pass correct node to error message when finding duplicated protocol 2013-08-22 16:53:22 +02:00
Martin Carlberg 9f7d0578e5 New: Added the basic protocols CPObject and CPCoding 2013-08-22 14:31:15 +02:00
Martin Carlberg 0afe21dd29 Fixed: Copy method descriptions to an array instead of JSObject 2013-08-22 12:37:29 +02:00
Martin Carlberg cfc682c165 Fixed: Protocol methods is now registered in the correct place 2013-08-22 12:36:29 +02:00
Martin Carlberg c326168e83 Fixed: Protocol definition in compiler was not created correct from protocol definition in the runtime 2013-08-22 12:35:16 +02:00
Martin Carlberg b8b96a17d7 Fixed: Check if global function exists in correct way 2013-08-22 12:34:14 +02:00
Martin Carlberg 48d98f7ebd Fixed: Added theme attribute 'divider-thickness' to wrong class when doing manual merge. 2013-08-20 11:22:39 +02:00
Martin Carlberg 7044c1cda4 Merge branch 'master' of https://github.com/cappuccino/cappuccino into table_header_divider_thickness 2013-08-20 09:44:17 +02:00
Alexander Ljungberg 594ea6e5cb Simplify. 2013-08-19 22:31:21 +01:00
Alexander Ljungberg 957a572bcd Fixed: missing imports. 2013-08-19 22:31:21 +01:00
Alexander Ljungberg 08eff6ec22 New: grey out Edit menu non applicable items for text fields.
Copy, cut and delete are now disabled if there's no selection in the active text field. Cut, paste and delete are greyed out if the text field is not editable (a label).

Refs #1964.
2013-08-19 22:31:21 +01:00
Alexander Ljungberg 3fb12f6382 Clean up. 2013-08-19 22:31:21 +01:00
Alexander Ljungberg 5958220bdd New: CPTextField deleteForward:.
This enables delete forward to be activated through action connections to text fields (or the first responder).
2013-08-19 22:31:21 +01:00
Alexander Ljungberg 648dc6e86c New: Edit > Delete menu item support for text fields.
This menu item deletes the current selection if there is one.

Refs #1964.
2013-08-19 22:31:21 +01:00
Alexander Ljungberg 9d43a559fe Fixed: - CPTextField deleteBackward: required selection.
According to the spec, deleteBackward: should remove the element before the insertion point if there is no selection (e.g. actually delete backwards).
2013-08-19 22:31:21 +01:00
Alexander Ljungberg 168738fb93 Return false for mouse handler if propagation is stopped.
Refs #1964.
2013-08-19 22:31:20 +01:00
Alexander Ljungberg 376b3a496e Fixed: copy and paste by Cappuccino Edit menu not working.
When the Edit menu is used to cut or to paste, Cappuccino needs to do all the work of making it happen. But the current code relied on the browser doing part of the work.

This fix adds new state so CPTextField can know if it should expect the browser to do some of the work or not.

Refs #1964.
2013-08-19 22:31:20 +01:00
Alexander Ljungberg 58d5d7d731 Fixed: selectable text deselected when a menu was clicked.
This made it impossible to select some (non-editable) text, and then to click a Cappuccino menu option like Edit > Copy. Upon the click of Edit, the just selected text would be lost.

This was caused by some very mysterious code focusing and blurring an input every time propagation was stopped. Since it wasn't documented, the snippet was just removed for now. If it turns out it was useful we'll need to add it back and make sure it's not called in this scenario (while documenting it properly).

Refs #1964.
2013-08-19 22:31:20 +01:00
Antoine Mercadal f637931ba7 FIXED: Bug introduced with my previous commit, preventing popover to open in some cases.
Previously, addChildWindow:ordered: was setting the platform window of the child window.
This patch restore the correct behaviour, and fix a bug with _CPAutocompleteMenu. Now the autocomplete menu is opened as a child of its textfield window using the correct platform window.
2013-08-15 19:40:40 -07:00
Alexandre Wilhelm ec4b348369 Fixed: a disabled CPMenuItem could still have a selected background
Previously it was possible to have a highlighted CPMenuItem for a disabled CPMenuItem. (To get that, select an item, close the menu, disabled the item manually and then open the menu again).
Now it is not possible to get this behavior.
2013-08-15 17:15:51 -07:00
Alexandre Wilhelm 879ede5d70 Changed the format of the xib to 4.6 2013-08-15 16:37:07 -07:00
Antoine Mercadal 1e7dd0dc59 FIXED: Bug that could open a child window in the wrong platform window
Previously, addChildWindow:ordered: did not set not the child window's platform window. This could result to open them in the wrong browser window. This patch makes sure to set the parent's platform window as the child window's platform window.
2013-08-15 13:33:50 -07:00
Aparajita Fishman f1077719fb Fixed: main div in index.html had wrong id.
The div's id was changed to cappuccino, and it was supposed to be cappuccino-body, which broke code that relied on the DOM remaining stable during startup.
2013-08-15 10:40:18 -04:00
Aparajita Fishman c9dae8ced4 Revert "Fixed: nib2cib used a temp file for plutil output instead of using stdout."
This reverts commit 4e4fc389d2. It wasn't working reliably.
2013-08-15 10:35:25 -04:00
Aparajita Fishman 4e4fc389d2 Fixed: nib2cib used a temp file for plutil output instead of using stdout.
Previously, nib2cib sent the output of plutil to a temp file, then read that file. plutil supports writing to stdout, which avoids the temp file completely, so that is what we do now.
2013-08-15 10:21:45 -04:00
Aparajita Fishman fa86c54fff Fixed: missing semicolon. 2013-08-15 10:21:45 -04:00
Alexander Ljungberg 2065c7fbc8 Fixed: CPTextField deleteBackward: leaving 1 character.
Previously if - CPTextField `deleteBackward:` was invoked without it being a browser backspace key event for an actively edited text field, the first character in the current selection would not be deleted.

This fix makes it so that `deleteBackward:` works properly from any caller. The fix also undoes a mistake in a recent previous commit which prevented the text field from visually updating after deletion.
2013-08-14 16:23:57 +01:00
Alexander Ljungberg 100efc6450 Formatting. 2013-08-13 11:00:48 +01:00
Aparajita Fishman 987d2a2d73 Formatting 2013-08-12 23:31:34 -04:00
Martin Carlberg 63dac5553e Fixed: Updated test case to include '@required' and '@optional' keywords 2013-08-12 22:46:26 +02:00
Martin Carlberg 0b75876283 Fixed: Moved incorrect positioned parenthesis to handle '@required' token 2013-08-12 22:44:35 +02:00
Martin Carlberg beec0c5293 Fixed: Handle '@required' before any method declarations 2013-08-12 22:43:03 +02:00
Martin Carlberg 672ed6ed0c Fixed: Handle protocol declaration with no method declarations 2013-08-12 22:41:36 +02:00
Aparajita Fishman d6f1c2bc57 Fixed: attempting to use an unsupported built in image in IB would generate an error, but not explain why.
Previously, attempting to use an unsupported built in image such as NSActionTemplate would generate an error message that said, "The image “NSActionTemplate” cannot be found." This would lead the user to think that there was something wrong with nib2cib, instead of understanding that only certain built in images are supported (currently NSAddTemplate and NSRemoveTemplate).

With this commit, an attempt to use an unsupported built in image (where built in is assumed to be any name that matches /^NS[A-Z][A-Za-z]+$/) results in the error message "The built in image “<name>” is not supported."
2013-08-12 15:18:07 -04:00
Martin Carlberg 3b8aedf5aa Merge branch 'master' of https://github.com/cappuccino/cappuccino into protocol 2013-08-12 18:25:00 +02:00
Alexander Ljungberg d40449c469 Ignore XCC .xcodeproj files in tests. 2013-08-12 17:03:31 +01:00
Alexander Ljungberg 8bdbb5d333 Fixed: _CPImageAndTextView unguarded platform access.
This could cause issues during jake deploy or unit testing.
2013-08-12 16:57:50 +01:00
Alexander Ljungberg 638d8de472 New: triple click selectable text field to select all.
This matches Cocoa behaviour. Cocoa also supports double click to select the current word but we currently don't know what word is being clicked. In some browsers (e.g. Safari) this will work natively. Chrome on the other hand selects something random after double click on a non editable div.
2013-08-12 16:57:07 +01:00
Alexander Ljungberg 03acecdec9 New: selectable textfield Select All (Cmd-A, Ctrl-A) support.
Like in Cocoa, a non-editable but selectable text can now be clicked and all text can be selected with the Edit > Select All option or the associated keyboard equivalent. Just like in Cocoa this works on selectable text labels as well (text fields without a bezel).
2013-08-12 16:44:46 +01:00
Martin Carlberg f74312dc42 Fixed: Allow type on return or parameter type to be a class if superclass or protocol declared it as 'id' 2013-08-12 16:55:35 +02:00
Martin Carlberg 2e216d7e9a Fixed: Make default return type to 'void' for '@action' or 'IBAction' marked method. 2013-08-12 16:53:19 +02:00
Alexander Ljungberg 0e7b592786 Fixed: certain editing actions allowed for disabled text fields. 2013-08-12 15:52:36 +01:00
Martin Carlberg 29d7833fcb Fixed: Renamed local variable that used reserved variable name ('arguments') 2013-08-12 16:52:07 +02:00
Martin Carlberg 4eba639c73 Fixed: Allow some tokens to be identifiers 2013-08-12 16:50:34 +02:00
Martin Carlberg 361f421816 Fixed: Added 'id' as a token and enforce that protocol can only follow 'id' as a Objective-J type 2013-08-12 16:49:39 +02:00
Martin Carlberg bb58a206a8 Fixed: Removed all warnings of conflicting return and parameter types caused by the new compiler 2013-08-12 16:46:14 +02:00
Alexander Ljungberg 4775b594f5 Test: extended copy and paste manual test.
This change adds selectable text fields and labels to the potential copy sources.

Refs #1972.
2013-08-12 15:44:22 +01:00
Alexander Ljungberg a90180a92f Fixed: CPTextField copy: only worked for editable text fields.
A non-editable text field does not use an input field, and so does not track what is selected within it. We will use a workaround for now but in a CoreText based text field in the future we'd be likely to always have a correct selectedRange and be able to remove this hack.

Fixes #1972.
2013-08-12 15:43:24 +01:00
Alexander Ljungberg 377618dcd4 New: non-editable but selectable text fields can become the first responder.
Without this change, text fields with setEditable:NO but setSelectable:YES could not become the first responder, and so would not listen for copy: events.

This change allows selectable fields to become the first responder, taking advantage of the distinction between first responder and first key responder maintained internally in CPTextField - a merely selectable field does not become the first key responder.

Refs #1972.
2013-08-12 15:41:10 +01:00
Martin Carlberg 1cfc8139b9 Fixed: Removed double declared ivar 2013-08-12 16:39:54 +02:00
Alexander Ljungberg 4b4ac5d8b7 Fixed: certain actions would edit a non-editable text field. 2013-08-12 15:36:16 +01:00
Martin Carlberg 7c2c2a3114 Fixed: Allow protocols in interface declaration 2013-08-12 09:40:20 +02:00
Alexandre Wilhelm c0dce226bf Changed capp_buid to cap_build.... 2013-08-11 23:24:38 -07:00
Alexandre Wilhelm 2fcf1f4ac4 Added: Creating project with symlinks
Previously it wasn't possible to create project with symlink.
Now you can set in the preferences of xCodeCapp if you want to create your project with symlink or not with a radioButton.
When launching xCodeCapp, the system will check if $CAPP_BUILD is defined or not. If not, the button in the preference will be disabled and a toolTip will advice how to create a $CAPP_BUILD variable.
2013-08-11 14:04:50 -07:00
Aparajita Fishman 8d47b3f048 Fixed: CGContextAddArc would fail if the path was empty.
Previously, CGContextAddArc would not work with an empty path. In Cocoa, CGContextAddArc implicitly starts a path, so it does not require a non-empty path.

This commit allows CGContextAddArc to be used with an empty path.
2013-08-10 17:51:20 -04:00
Aparajita Fishman 06e392ee22 Fixed: CPApplicationDidChangeScreenParametersNotification was sent once for each window.
Should be sent only once per resize.
2013-08-09 15:01:30 -04:00
Martin Carlberg d38125db13 New: Added Objective-J protocol support
The Objective-J parser and compiler now handles protocol syntax. The Objective-J runtime has new functions to handle protocols. The method 'conformsToProtocol:' has been added to CPObject as an instance and a class method.
2013-08-09 19:02:45 +02:00
Aparajita Fishman 3beb753c63 Fixed: when constraining a window resize, the horizontal margin was fixed (and too large).
Previously a fixed margin of 40px was maintained at the left/right of a window when resizing it, which was excessive.

Now the minimum size allowed during a resize is the same as the minimum margin allowed when moving a window, which is determined based on the type of window.
2013-08-09 09:16:43 -04:00
Aparajita Fishman d751fea510 Fixed: constraining window's to the screen did not respect a window's minSize.
Previously, when the platform window was resized, windows were moved/resized to stay within the virtual screen, but if the window had a minimum size, it was not respected.

This commit ensures that if a window has a minimum size, it will always be respected.
2013-08-09 09:12:07 -04:00
Aparajita Fishman 42ad40d10d New: sort the keys in CPDictionary -description.
This makes it easier to find an item in a large dictionary.
2013-08-09 08:28:37 -04:00
Aparajita Fishman 86e5c15e3c Formatting, optimizations. 2013-08-09 08:28:37 -04:00
Aparajita Fishman 6bec4064b5 Fixed: window width was not constrained when platform window was resized.
Previously window heights were constrained to the usable screen when the platform window (virtual screen) resized, but widths were not. The code was there to constrain the width, but it wasn't being used.

This commit ensures the width constraining code is executed.
2013-08-09 08:28:36 -04:00
Aparajita Fishman fc931902d7 New: notify when the platform window resizes.
The platform window is the virtual screen for Cappuccino windows. Per Cocoa, when the screen (platform window) resizes, CPApplicationDidChangeScreenParametersNotification is sent and the CPApplication delegate method applicationDidChangeScreenParameters: is called.
2013-08-09 08:28:36 -04:00
Aparajita Fishman d336c30ab6 New: moved application constants to a separate file. 2013-08-09 08:28:36 -04:00
Aparajita Fishman 9fb966d0ca Docs 2013-08-09 08:28:36 -04:00
Aparajita Fishman 3c2a2f39fc Fixed: resizing a window did not attempt to maintain a minimum margin on screen.
Previously, window moves were constrained such that a minimum margin of the window was visible on screen, but window resizes were not constrained, allowing the user to effectively move the window off screen.

Now resizes are constrained such that a minimum margin of the window is always visible on screen so that the window does not get "lost".
2013-08-09 08:28:36 -04:00
Aparajita Fishman 2183c6d383 New: added methods to globally turn off window constraining when resizing the platform window.
Previously, whenever the platform window (virtual screen) resized, windows were moved or resized to keep them on screen. This could not be easily overridden by the user.

Two class methods have been added:

CPWindow +setConstrainWindowsToUsableScreen:
CPWindow +constrainWindowsToUsableScreen

If +setConstrainWindowsToUsableScreen:NO is called, then resizing the platform window will not move or resize user windows.
2013-08-09 08:28:36 -04:00
Antoine Mercadal e61b6783b3 FIXED: Crash when the autocomplete menu of a Token Field is visible while one of the superviews is removed
Previously, _CPAutocompleteMenu was trying to relayout itself using its related textfield's window frame. This was
causing a crash if one of the CPTokenField's superview has been removed. This fix ensures to stop layouting if the related text field has no window anymore.
2013-08-06 16:04:39 -07:00
Martin Carlberg 7f089972bd New: Added themable attribute for divider thickness in table header view 2013-08-06 11:54:13 +02:00
Martin Carlberg 5a7c2e5617 New: Added themable attribute for grid line thickness in table view 2013-08-06 11:53:13 +02:00
Alexandre Wilhelm ceb22a47c5 New: Added menu Create Project... in xCodeCapp
Previously it wasn't possible to create a capp project from xCodeCapp.
Now you can create one from the menu item Create Project, xCodeCapp will load the project as the same time is no error occurs.
When choosing an existing project, xCodeCapp removes the old one (this is asked to the user, would you like to replace the files...).
In case of errors, the errors panel appears.
2013-08-06 00:41:38 -07:00
Aparajita Fishman 3c9435ed21 Fixed: FileRequest was broken under CommonJS.
The progress event was being used even under CommonJS, which broke file loading and thus jake deploy.
2013-08-02 19:05:57 -04:00
Aparajita Fishman 9e7346f1e8 New: new index.html with loading progress by default.
Previously, the index[-debug].html in the default capp templates did not include a loading progress function. We just had the plain spinner, which gave no visible sign of progress.

Now the capp templates include a progress function and a nice iOS7-ish progress thermometer	is displayed during loading (except when run directly from source). 'jake debug' and 'jake release' will now generate the application/image sizes needed to display loading progress. The old spinner.gif has been removed.

In addition, the message displayed when JavaScript is unavailable has been simplified and shows a link to www.enable-javascript.com instead of the missing link to our old site.
2013-08-02 17:49:45 -04:00
Aparajita Fishman 4221acf3fd New: added support for continuous load progress notification.
Previously, Cappuccino only called OBJJ_PROGRESS_CALLBACK when an executable or image sprite file was finished loading. Only a slow connection, this would result in long periods with no visible progress.

Now OBJJ_PROGRESS_CALLBACK is called continuously during download via the XHR progress event. All supported browsers except IE 9 support this event.
2013-08-02 17:33:59 -04:00
Aparajita Fishman b49a872806 Fixed: IE would scroll entire app to the left, leaving white space on the right.
Previously, in IE you could scroll the entire browser window to the right a very long way, leaving white space to the right of the Cappuccino app. This was caused by a 100,000px wide measurement span that was supposed to be positioned at left:-100,000 but was mistakenly at left:-10,000, which left 90,000px on screen.

This commit fixes the left position of that span, eliminating the ability to scroll the app.

Fixes #1725
2013-08-01 16:20:47 -04:00
Aparajita Fishman 655bc0348b Formatting 2013-07-30 09:40:18 -04:00
Aparajita Fishman 2b23374ec7 New: CPAlert supports custom didEnd selector or block.
Previously, unless you were using a sheet alert, there was no way to set a custom dismissal handler for an alert. In Cocoa alerts are synchronous, in Cappuccino they are asynchronous, which meant that a single dismissal handler had to handle all possible non-sheet alerts.

This commit adds several methods which add two ways to specify a custom dismissal handler: via delegate/selector, and via a block (function). The new methods are:

setDidEndSelector:
runModalWithDidEndBlock:
beginSheetModalForWindow:didEndBlock:

Note that didEnd blocks are transient and take precedence over didEnd selectors.

The CPAlertTest demo was updated to fix some bugs and added the ability to run the tests using blocks.
2013-07-29 13:06:57 -04:00
Aparajita Fishman 1df1c1e9ab Merge branch 'refs/heads/contentViewResizeFix' 2013-07-27 13:42:05 -04:00
Aparajita Fishman 084bc84160 Fixed: removed redundant code. 2013-07-27 13:41:35 -04:00
Aparajita Fishman d8281a6e22 Fixed: simplified the overlay scroller test, documented the technique.
Previously the inner element's offsetWidth was tested before and after setting the overflow to scroll. This is unnecessary, we can just set the overflow to scroll and test the outer element's clientWidth vs. offsetWidth. By definition, clientWidth does not include scrollbars, whereas offsetWidth does. So if they are equal then overlay scrollers must be in use.

Note that FireFox (as of version 22) does not support overlay scrollers, so even if the system does, Cappuccino will not on FireFox unless the programmer forces overlay scrollers.
2013-07-27 09:27:58 -04:00
Aparajita Fishman bdd29936d7 Fixed: test for fixed scrollbars was broken by a previous commit. 2013-07-26 23:38:20 -04:00
Aparajita Fishman f3f1f72ae2 Fixed: variable move in previous commit broke selection notifications. 2013-07-26 12:17:52 -04:00
Aparajita Fishman 2da6c88fad Fixed: constant name was misleading.
Previously CPTimerMinTimeInterval was used as a constant for the *default* time interval used when a timer was initialized with an interval <= 0. It isn't the minimum, it is possible to create a timer with an interval less than that constant's value.

The name has been changed to CPTimerDefaultTimeInterval to make it clearer what it's purpose is. It has also been changed to a #define, that will result in smaller generated code.
2013-07-26 02:08:14 -04:00
aparajita b03e354dbf Merge pull request #1965 from Dogild/Timer
Fixed: CPTimer didn't allow a timeInterval < 0.1
2013-07-25 23:01:14 -07:00
Aparajita Fishman 5b62773a39 Fixed: off-by-one in row calculation caused drawing problems with variable-height rows in CPTableView.
Previously, if the last row's height was increased, empty rows below would not be pushed down. This was due to an off-by-one in -_unboundedRowsInRect (now _exposedRowsInRect) which caused the incorrect rect of the last row to be retrieved.

This commit fixes that bug and also makes the following changes:

- Added FULL_ROW_HEIGHT(), ROW_BOTTOM() and HAS_VARIABLE_ROW_HEIGHTS() macros to make the code clearer.
- Documentation cleanup.
- Eliminated some intermediate variables.
- Rewrote -_rectOfRow to reduce redundant code and fixed some logic errors.
- Renamed some variables to make their intention clearer (to me at least).
- Added an out of bounds check in -rowAtPoint: before doing the relatively expensive binary search.
- In -noteHeightOfRowsWithIndexesChanged:, the first valid index is used instead of the first index (which might be invalid).
- Fixed a bug in -noteHeightOfRowsWithIndexesChanged: where row height was not set correctly if a row was not in the index set.
- Fixed incorrect use of CEIL in -_unboundedRowsInRect, it was wrapped around the divisor instead of the entire expression.
- Fixed drawBackgroundInClipRect: drawing one too many rows.
- Fixed -rowAtPoint not checking for x in bounds.

BREAKING CHANGE:
Previously, CPTableView -rowAtPoint would incorrectly return a valid row index when the x value was outside of the table's bounds. Now an out of bounds x value will return -1, which is consistent with Cocoa (and the intent of the method).
2013-07-25 10:48:11 -04:00
Aparajita Fishman 5c211b350e Docs 2013-07-24 19:21:56 -04:00
Aparajita Fishman 2c6ab1714f Fixed: stray theme slice. 2013-07-24 11:10:35 -04:00
Aparajita Fishman 17fe9b0f60 Formatting 2013-07-23 18:03:17 -04:00
Aparajita Fishman 639670e47d Formatting 2013-07-23 10:15:49 -04:00
Aparajita Fishman 27165db513 Fixed: menu items would not obey enabled bindings for auto-enabling menus.
Previously, the auto-enabling logic for CPMenu would not check to see if a menu item had enabled bindings, and would ignore the state determined by those bindings.

Now, if a menu is auto-enabling and an item has an enabled binding, the binding is used to set the enabled state of the item.
2013-07-22 22:20:40 -04:00
Aparajita Fishman 650bc77b2c Fixed: number formatter was called twice for every setObjectValue.
Previously setObjectValue checked for a formatted value, and then called [self stringValue], which ended up formatting the value again.

Now all of the cases (no formatter, formatter succeeds, formatter fails) are handled explicitly in setObjectValue, eliminating the extra call to the formatter.
2013-07-22 21:26:18 -04:00
Aparajita Fishman a5e62ed132 Fixed: NSMenu autoEnablesItems was not supported by nib2cib. 2013-07-22 21:13:15 -04:00
Alexandre Wilhelm 56963d65f3 Fixed: CPTimer don't allow to put timeInterval below 0.1
Previously it wasn't possible to set the timeInterval below 0.1.
Now you can do it and the timeInterval will set to 0.1 if the timeInterval is less or equal to 0 as in cocoa.

Cocoa specs here:
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/Reference/NSTimer.html
2013-07-22 15:20:10 -07:00
Aparajita Fishman 771370e64b Docs: typos 2013-07-21 22:30:20 -04:00
Aparajita Fishman 0bd670b2a3 Fixed: extraneous colon in https scheme test.
And whitespace formatting.
2013-07-20 13:23:05 -04:00
Aparajita Fishman e0af5d0573 Fixed: changed magic number to constant, add missing space after comma. 2013-07-20 12:05:53 -04:00
aparajita 23d2a71649 Merge pull request #1962 from BlairDuncan/CPTimerMinimumInterval
Fixed: CPTimer number of seconds interval set to 0.1 if less than or equal to 0.0
2013-07-20 09:02:13 -07:00
Blair Duncan 3419f6fbb4 Fixed: CPTimer number of seconds interval set to 0.1 if less than or equal to 0.0
Cocoa specs here:
 https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/Reference/NSTimer.html
...
"Parameters
seconds
The number of seconds between firings of the timer. If seconds is less than or equal to 0.0, this method chooses the nonnegative value of 0.1 milliseconds instead."
2013-07-18 09:33:12 -04:00
Aparajita Fishman 2ca020f3a9 Fixed: it seems setHidden must be called in CPView -initWithCoder.
Reverts change made in 64f962e29a.
2013-07-17 13:45:32 -04:00
Aparajita Fishman 778843593b Fixed: CPTextField would not become/resign key responder when first responder and unhidden/hidden.
Previously, no attempt was made to become/resign first key responder when a CPTextField was unhidden/hidden. This could lead to a case where a hidden CPTextField was made first responder, then unhidden (and have a focus ring), but would not receive key input.
2013-07-17 13:28:17 -04:00
Aparajita Fishman 64f962e29a Fixed: viewDidHide and viewDidUnhide were not called when being added to/removed from hidden ancestor.
Cocoa specifies that viewDidHide will be called when an unhidden view is added to a view hierarchy with a hidden ancestor view, and viewDidUnhide is called when an unhidden view is removed from a view hierarchy with a hidden ancestor view. This was not the case in Cappuccino.

This commit adds that functionality, and also removes a spurious viewDidHide/viewDidUnhide call that was generated as a side effect in initWithCoder.
2013-07-17 13:28:17 -04:00
Aparajita Fishman 90fe91d63e Formatting: @ignore requires /*! comment, whitespace cleanup 2013-07-17 13:28:17 -04:00
Alexander Ljungberg d404d027c2 Test: - CPImage initWithContentsOfFile:nil. 2013-07-15 10:48:58 +01:00
Alexander Ljungberg b0babdb7bb Formatting.
Refs #1959.
2013-07-15 10:48:14 +01:00
Alexander Ljungberg 0f53ceda30 Fixed: comparing a CPNumber vs nil or CPNull didn't throw an exception.
In Objective-C, both `[@34 compare:nil]` and `[@34 compare:[CPNull null]]` throw invalid argument exceptions.

This fix makes the same true in Objective-J.

Refs #1959.
2013-07-15 10:47:38 +01:00
Alexander Ljungberg 315e3fccf3 Formatting.
Refs #1959.
2013-07-15 10:36:48 +01:00
Alexander Ljungberg 2973743a0d Merge pull request #1959 from mrcarlberg/compare_sort_with_null
CPString 'compare:' method and sort using descriptors handles nil and CPNull in correct way
2013-07-15 10:28:43 +01:00
Aparajita Fishman 083310c44f Fixed: nib2cib did not allow xibs or images to be in subdirectories of Resources.
Previously, nib2cib would not correctly calculate the app/resource directories if the xib was in a subdirectory of Resources. Also, image resources in subdirectories did not have the subdirectory encoded with the image name.

Now xibs and images may be anywhere under Resources.

Fixes #1960.
2013-07-14 18:11:31 -04:00
Aparajita Fishman 54d13c8fc9 Fixed: CPImageView's _DOMImageElement was not created during initWithCoder.
Previously, _createDOMImageElement was not called until after [super initWithCoder] was called. But that call would end up in CPImageView -setObjectValue, which would attempt to access _DOMImageElement before it had been created.

Now _DOMImageElement is checked before being accessed or created.
2013-07-14 17:46:22 -04:00
Aparajita Fishman fbc869ad29 Fixed: in certain degenerate cases, CPTextField may not have a window within _isWithinUsablePlatformRect
Previously, a case could arise where a text field was set as the initial first responder but during cib loading was not yet assigned to a window. In this case _isWithinUsablePlatformRect would fail.

Now _isWithinUsablePlatformRect checks to make sure the text field has a window.
2013-07-14 15:59:23 -04:00
Martin Carlberg f52f11899a New: Sort using descriptors handles nil and CPNull in correct way
This is the same way as Cocoa works.
Also added test case.
2013-07-09 13:38:13 +02:00
Martin Carlberg fc403d679c New: CPString 'compare:' method handles nil and CPNull in correct way
This is the same way as Cocoa works.
Also added test case.
2013-07-09 13:37:12 +02:00
Alexander Ljungberg e8b2f2e39f Fixed: previous CPImageView revision not compiling with Rhino. 2013-07-08 17:28:48 +01:00
Alexander Ljungberg b258b1a164 New: appkit_tag_dom_elements now tags with UIDs too.
Tagging with UIDs can make it much easier to debug encoding/decoding related bugs where it's not clear that the right view ended up in the right spot.

The new data attribute is called "data-cappuccino-uid".

Also collect and simplify appkit_tag_dom_elements code a little.
2013-07-08 17:05:22 +01:00
Alexander Ljungberg 0badf30763 Simplify CPImageView code. 2013-07-08 17:02:41 +01:00
Alexander Ljungberg c68b174be5 Fixed: appkit_tag_dom_elements support by CPImageView.
Without this fix, the `appkit_tag_dom_elements` flag would only affect CPImageViews unarchived from a coder (e.g. in a collection view, from a cib). It would have no effect on a CPImageView created in code.

This change refactors the _DOMImageElement code to a shared method, reducing redundancy while fixing the bug.
2013-07-08 14:31:06 +01:00
Alexander Ljungberg d61d4ebbe7 Fixed: -CPImage initWithContentsOfFile:nil created broken image.
Without this fix, code like `[[[CPImage alloc] initWithContentsOfFile:nil] description]` would cause a crash.

This fix makes `[[CPImage alloc] initWithContentsOfFile:nil]` behave like its equivalent in Cocoa: it returns nil without warning or error.
2013-07-08 12:45:23 +01:00
Alexander Ljungberg e7ecd92cbc Fixed: custom CPWindow subclasses breaking flatten.
If a cib file had a custom CPWindow subclass, that cib file would not be properly processed by flatten as it'd fail to find the relevant class (the fact that the class can't be found is an issue in itself). This would cause an exception.

This fix makes CPCibWindowTemplate act similar to CPCibCustomView when the referenced class can't be found: it instantiates a regular CPWindow. This is sufficient for flatten's purposes.
2013-07-02 17:16:55 +01:00
Antoine Mercadal 93c27625b9 NEW: Added some themable attributes for CPPopover
The following theme attributes has been added
 - border-radius
 - stroke-width
 - shadow-size
 - shadow-blur
2013-06-28 17:48:32 -07:00
Glenn L. Austin 8d7c47a5e4 Fixed: Remove explicit use of Mac OS X 10.5 SDK, replace with "latest OS X"
The fontinfo and imagesize Xcode projects still explicitly refer to using the Mac OS X 10.5 SDK, while all other Xcode projects simply refer to the latest Mac OS X SDK, with no explicit OS version. This change modifies these two projects to mirror other Xcode projects in the project.

Fixes #1957
2013-06-28 10:26:44 -07:00
Alexander Ljungberg 6ef776e488 Fixed: - CPView nextValidKeyView infinite loop.
Previously, certain situations could easily lead to an infinite loop in - CPView nextValidKeyView. For instance, opening a sheet view with no responder returning YES for canBecomeKeyView would freeze Cappuccino.

This was caused by the cycle detection in nextValidKeyView not being able to pick up on cycles where the nextKeyView of the original receiver did not participate. Since content views often have a next key view inside of them, and the views inside rarely have a next key view back "up" to the content view, the content view would never be seen again even if there was a cycle.

This fix detects cycles at any level by remembering all previous visited responders.
2013-06-25 18:05:46 +01:00
Alexander Ljungberg d9e3542c34 Merge branch 'refs/heads/slevenbits-native-clipboard' 2013-06-17 00:54:41 +01:00
Alexander Ljungberg 093ac8cf54 Merge branch 'refs/heads/slevenbits-nsvalue-nib2cib' 2013-06-17 00:54:05 +01:00
Alexander Ljungberg 757c79d15c Refactor, restructure and simplify copy and paste handling.
This change brings nearly all copy and paste related into a single, self-contained class. This new class is still somewhat coupled to CPPlatformWindow+DOM.j in the sense that it's highly specific and meant to be called in a very specialised way. Despite this, it's still a significant decoupling and the new code is more readable and easier to follow.
2013-06-17 00:17:00 +01:00
Alexander Ljungberg 8dd252eee1 Cleanup: TableTest/Editing. 2013-06-16 13:23:22 +01:00
Alexander Ljungberg f318759a4a Fixed: menu items becoming permanently disabled, breaking e.g. Select All.
Without this fix, if a menu item was disabled it could only be automatically re-enabled if the menu item had a `validateMenuItem:` or `validateUserInterfaceItem:` enabled target.

This meant that for example if the Edit > Select All menu item was validated when the first responder was something like a collection view, it'd become disabled. If then the first responder was changed to a text field and revalidation occurred, the menu item would not become enabled and Select All would not be possible in the text field neither through the Edit menu nor the Cmd-A/Ctrl-A keyboard equivalent.

This fix ensures that menu item validation does not only take negative action (disabling enabled items which should be disabled), but also positive action (enabling disabled items which should be enabled), even when there's no `validateMenuItem:` or `validateUserInterfaceItem:`.
2013-06-16 13:22:44 +01:00
Alexander Ljungberg 85985add3c Fixed: objects without a superclass. 2013-06-15 17:53:54 +01:00
Alexander Ljungberg 9d435e0f8a Test: include an image in Copy and Paste test.
Image copy and paste to and from the system clipboard is not available in Cappuccino today. However, the image in the collection view can be used to test internal Cappuccino copy and paste (using Edit > Copy, Edit > Paste from the Cappuccino menu).
2013-06-15 17:53:17 +01:00
Alexander Ljungberg 2b0754c6a0 Simplify copy and paste code path.
This change begins to clean up the control flow of copy and paste. Before, copy and paste was dealt with partly in CPPlatformWindow, partly in CPApp and partly in CPTextField.

Now, CPApplication has been removed from the path, simplifying it down to the two more expected actors.
2013-06-15 17:08:11 +01:00
Alexander Ljungberg 0ead233cba Fixed: Safari "can't paste" code triggered even for a content editable target.
These targets might be rare but could occur in some Cappuccino text editor widget, in which case our standard native paste handling from Safari should work fine.
2013-06-15 14:42:15 +01:00
Alexander Ljungberg 5d07eb7316 Fixed: paste in Firefox.
The paste into input field hack requires that we don't stop the Cmd-V/Ctrl-V keydown propagation.
2013-06-15 13:23:01 +01:00
Alexander Ljungberg 198857e0ad Fixed: copying from a CPTextField would not actually but the string value in the Cappuccino pasteboard.
Without this fix, when text was copied from a CPTextField, the value would be copied into the system clipboard (if possible), but not into the Cappuccino pasteboard. This meant that the text could not be pasted back in Cappuccino using e.g. Edit > Paste from the Cappuccino menu.

This fix ensures the appropriate text is copied both into Cappuccino's pasteboard and the system clipboard (when possible).
2013-06-14 14:31:00 +01:00
Alexander Ljungberg a4aed913d7 Test: new copy and paste manual test.
This test makes it easy to test copy and paste both inside a Cappuccino app, and externally to and from other Cappuccino instances in other browser, or other applications, when using a text field or a collection view as the source/destination.
2013-06-14 14:27:40 +01:00
Alexander Ljungberg 613a20a639 New: native copy and paste support extended with copy and cut.
This fix switches to full native copy and paste in browsers which support it. This allows copy from anywhere - a collection view, a table view and so on - without the browser greying out the copy menu or beeping.

In the future this can easily be extended to copy and paste images as well.

This change also improves Safari paste support. In recent versions of Safari, pasting from the system clipboard into Cappuccino has been impossible. This remains impossible due to the lack of beforepaste events, but now the code cleanly switches to a Cappuccino-only paste at least.
2013-06-14 14:05:36 +01:00
Alexander Ljungberg e59389b0dd Fixed: crash in - CPArray/CPDictionary description containing self referential JS object.
Without this fix, certain JS contents could cause `- CPDictionary description` and `- CPArray description` to crash.

This change limits how deeply the description code will recurse before returning a default "…" description.
2013-06-13 20:14:22 +01:00
Alexander Ljungberg 22905745f1 Fixed: crash on -CPArray/CPDictionary description if a value was the window object.
Without this fix, code like `[@{ "a": window } description]` would crash with a "Maximum call stack size exceeded" exception.

Now`CPDescriptionOfObject()` function simply describes the window object as `window` rather than trying to serialise it into a huge description string.
2013-06-13 19:19:22 +01:00
Alexander Ljungberg d3a44cbc63 New: objj_getClassList().
This function obtains the list of registered classes at the time its called.
2013-06-13 18:18:13 +01:00
Alexander Ljungberg a9a0b1c7d9 New: JavaScript clipboard API support for pasting.
Without this feature, attempts to paste data into a Cappuccino app (outside of a text field) are handled by redirecting the paste into a hidden text field. Then a paste event is generated from whatever is captured in this field after a 0 timeout. This method is prone to timing related bugs where the paste event actually has an empty clipboard.

With this new feature we read the paste data directly from the browser's native paste event when the browser supports it (Chrome 10+, Safari 5+, Firefox 22+). This is much more dependable and may in the future also enable us to read other types of paste data such as images.
2013-06-13 13:26:16 +01:00
Alexander Ljungberg 72169e54d8 New: nib2cib support for runtime attributes of point, size, rect and range types.
This change adds nib2cib support for `NSValue` when the value represents a NSPoint, NSSize, NSRect or an NSRange, which enables user defined runtime attributes of these types to be set in Xcode and then properly decoded in a Cappuccino app.
2013-06-13 13:24:36 +01:00
Alexander Ljungberg bf94dd3a6e New: KVC setValue:forKey: now automatically unwraps CPValue.
This corresponds to the same KVC behaviour in Cocoa and is key when decoding cibs with certain properties set to struct values (such as NSSize).
2013-06-13 13:20:22 +01:00
Alexander Ljungberg fe79628034 Fixed: CGRectFromString made bad CGSizeFromString call.
Without this fix, CGRectFromString would call CGSizeFromString with a value like "{1, 2}}" (not the extra trailing "}"). Although CGSizeFromString didn't complain, it wasn't correct either.
2013-06-13 12:46:08 +01:00
Alexander Ljungberg 563300a16f Test: CGGeometry "string from" for point, size and rect. 2013-06-13 12:43:48 +01:00
Antoine Mercadal 29c336f7b8 Fixed: Wrong initial values for _lineDashesPhase and _lineDashes in CPBezierPath
Firefox is not accepting the initial values for these two attributes, making it crash with an ILLEGAL VALUE error in any application using CPBezierPath (especially ones with CPPredicateEditor that is using bezier path to draw the selection arrows.)
2013-06-12 13:21:46 -07:00
Alexander Ljungberg b0b0452647 Merge pull request #1943 from Dogild/EmptyTableView
Fixed: selection in a tableView without column
2013-06-12 13:07:40 +01:00
Alexander Ljungberg abd382d9c2 Merge pull request #1940 from krodelin/udos-Resources-Directory-in-Framework-Template
New: Added "Resources" directory to capp Framework template
2013-06-12 13:06:26 +01:00
Alexander Ljungberg 36c2672064 Merge pull request #1939 from Dogild/RemovedColumn
Fixed: removeTableColumn does not removes column from tableColumns array
2013-06-12 13:01:47 +01:00
Alexander Ljungberg 5bab2e1469 Merge pull request #1938 from ahankinson/fix-collectionview-shiftselect
Fixed: CPCollectionView range bounds exception if shift key was held for...
2013-06-12 12:55:10 +01:00
Alexander Ljungberg df7a6930c2 Test: expose a problem with - CPTabView insertTabViewItem:atIndex.
Refs #1920, #1921.
2013-06-12 12:31:30 +01:00
Alexander Ljungberg 45c75235a5 Merge pull request #1898 from ahankinson/fix-issue1396
Fixed: CPTokenField sends focus and blur notifications
2013-06-12 12:07:02 +01:00
Alexander Ljungberg 0d283231a2 New: automatically fix ulimit when possible.
Without this fix, trying to build Cappuccino or run a jake script with a too low `ulimit -n` would cause a fatal error.

This change will automatically increase the ulimit when possible and only error out when it's not. The automatic change does not permanently affect the terminal session as it only targets the soft limit.
2013-06-12 11:16:39 +01:00
Alexander Ljungberg 4652db7246 Formatting: semicolons. 2013-06-12 11:07:03 +01:00
Alexander Ljungberg 22dcacd8ce Fixed: remove non-standard CPDocument API "firstEligibleExistingWindowController".
This method did not actually do anything, and was not part of the expected CPDocument API.

Refs #1870.
2013-06-12 10:28:41 +01:00
Alexander Ljungberg e2339ee1c6 Formatting: whitespace.
Refs #1870.
2013-06-12 10:27:28 +01:00
Alexander Ljungberg 6ab650346b Merge pull request #1870 from BlairDuncan/documentControllerCurrentDocument
Fixed CPDocumentController missing method currentDocument
2013-06-12 10:20:25 +01:00
Blair Duncan 2cbc4d93bd Fixed: CPWindows contentView Autoresizes Subviews set in Cib is now honoured
Currently when a window is decoded from a cib, the contentView is set to always auto resize its subviews regardless of the setting in IB.
2013-06-07 07:05:44 -04:00
Alexandre Wilhelm 8bf2118b6e Fixed: selection in a tableView without column
Previously it was possible to select rows in a CPTableView even if there wasn't columns. It was also possible to make a drag/drop.
This PR fixes theses both problems.
2013-06-03 15:36:59 -07:00
Alexandre Wilhelm 566521f854 capp_lint 2013-06-03 11:32:05 -07:00
Alexandre Wilhelm c7c3bdd543 Fixed: CPTableView Drag and drop in void causes a crash
Previously the drag and drop and multiple selection from a void cells caused an exception.
With this fix, you can start a drag/drop and a multiple selection from a empty row.

Fixes #1857
2013-06-03 11:27:10 -07:00
Aparajita Fishman 50d3bfd456 Fixed: Frameworks/Source directory was being copied to Build 2013-06-01 15:48:02 -04:00
Udo Schneider 6a516873b7 New: Added "Resources" directory to cap Framework template
Added a new folder "Resources" in Tools/capp/Resources/Templates/Framework/. As the folder is empty be default for frameworks it contains a .gitignore file to be able to add it to git.

Motivation is to prevent (spelling) mistakes when manually creating a Resource folder for Frameworks (e.g. "Ressources").
2013-06-01 13:13:05 +02:00
Alexandre Wilhelm 827b9c4c57 Fixed small bugs with _reloadAllRows 2013-05-31 16:21:56 -07:00
Alexandre Wilhelm 3b48aafe66 Fixed: removeTableColumn does not removes column from tableColumns array
Previously the tableView didn't correctly remove a given tableColumn. It was removed in the method load (who is called by the layoutSubviews).
Now the tableColumns is removed before the layoutSubviews (as in cocoa).
It fixed also another problem, before this fixe it wasn't possible to remove all of the columns of a tableView (the last column was always displayed). This is fixed also

Fixes #1913

You can test that with the app of t00f
2013-05-31 16:11:11 -07:00
Andrew Hankinson 8d7e2f9ec6 Fixed: CPCollectionView range bounds exception if shift key was held for first selection
Previously, if you held down the shift key while making the first selection in a CPCollectionView it would raise an exception claiming {-1, XXX} was out of range. This was because `firstIndex` returns CPNotFound (-1) if nothing is selected.

In Cocoa, holding down the shift key while making the initial selection behaves as if you made an initial selection.

This commit catches a CPNotFound and sets the first index to the index of the item under the mouse pointer.
2013-05-31 17:19:09 -04:00
Alexander Ljungberg 295443f2e3 Merge pull request #1937 from mrcarlberg/colon_selector
Fixed: When selector is only a ':' in a send message statement the new compiler crashed.
2013-05-30 13:46:28 +01:00
Martin Carlberg 595736b8c6 Fixed: When selector is only a ':' in a send message statement the new compiler crashed.
The program below crashed on the last line with a 'null is not an object' error message. Also added a test case.

@implementation MyObject {
- (int):(int)a {
  return a;
}
@end
var a = [[MyObject alloc] init];
var b = [a:3];
2013-05-30 14:39:58 +02:00
Antoine Mercadal 8f17f904f2 Merge pull request #1935 from Dogild/CGPath
Fixed: CGPath is wrong when creating an arc
2013-05-29 10:11:39 -07:00
Aparajita Fishman 668eb1f8c4 Fixed: in some cases nib2cib would write to stdout, which wasn't captured by XcodeCapp.
Previously, only stderr was checked for response text. In some edge cases it would write an error message to stdout. In addition, the default error message provided when the return status was non-zero and the output was empty was implemented incorrectly.

Now all output from nib2cib is correctly captured.

Also updated help to indicate how to enable debug logging.
2013-05-25 19:23:10 -04:00
Aparajita Fishman 3159021d27 CPDatePicker fixes, optimizations, tweaks...
- CPImageInBundle() can't be used from a ThemeDescriptor. Replaced with PatternImage().
- DRY! Put clock image sizes in variables so they can be maintained in one place.
- When displayed from the theme showcase, the hand images in HandLayer -setImage: were still _CPCibCustomResources, not sure why. This condition is now explicitly handled by converting to the referenced image.
- Fixed a bug in _CPDatePickerClock -setEnabled where the sublayers would not update unless the event loop was pumped.
- Check for unchanged value in setters.
- Various code optimizations.
- Removed unnecessary method comments.
- Fixed typo in demo app.
2013-05-25 19:11:27 -04:00
Alexandre Wilhelm fc4413d56b Changed clockWise to isClockWise 2013-05-24 14:15:54 -07:00
Alexandre Wilhelm 8b7eb1815d Removed unused code 2013-05-24 13:40:46 -07:00
Alexandre Wilhelm cb187c3e8f Added tests 2013-05-24 11:53:47 -07:00
Alexandre Wilhelm 25f54c83ed Added method CGPathContainsPoint 2013-05-24 11:53:33 -07:00
Alexandre Wilhelm a79ac2e9e4 Removed unused code 2013-05-23 14:11:03 -07:00
Alexandre Wilhelm b5df5f730b Fixed: CGPath is wrong when creating an arc
Previously when creating a CGPath with an arc, the path was wrong. It added a line when it wasn't necessary and when it was necessary it added a line to a wrong point.
Now CGPath works like in cocoa (If the specified path already contains a subpath, Quartz implicitly adds a line connecting the subpath’s current point to the beginning of the arc. If the path is empty, Quartz creates a new subpath with a starting point set to the starting point of the arc.)

Test app in Tests/Manual/CGPath/AppController.j
2013-05-23 14:07:04 -07:00
Martin Carlberg a2257dab8f New: Empty loop test cases for compiler generator 2013-05-22 11:41:17 +02:00
Martin Carlberg ee4112b7f1 Fixed: Removed double spaces before '@ref' and '@selector' generated output from compiler.
'@ref' is generated to ' function(__input…' with the starting space if, for example, the code is 'return(@ref(a))'. This will create a space between 'return' and 'function(__input…'. When the compiler is generate the code this is not necessary.
2013-05-22 10:34:46 +02:00
Martin Carlberg 1d896c6ac9 Fixed: Code generator didn't generate ';' for empty loops
The line 'while (count--);' was generated to 'while (count--)'. The same with 'for(;;);' and 'for (a in []);'
2013-05-22 10:27:01 +02:00
Antoine Mercadal 42bc87d9ca Merge pull request #1934 from Dogild/showcase
Fixed: Aristo showcase is broken because CPDatePicker
2013-05-21 15:30:15 -07:00
Alexandre Wilhelm 85e71017d9 capp_lint and code style 2013-05-21 15:28:33 -07:00
Antoine Mercadal d8c8694c0d nib2cib the xib 2013-05-21 15:27:45 -07:00
Antoine Mercadal 305fbb8ce2 Merge branch 'RadialGradient' of https://github.com/Dogild/cappuccino into pr-1933 2013-05-21 15:18:25 -07:00
Alexandre Wilhelm 0c613f1dde Fixed bugs with showcase 2013-05-21 14:10:05 -07:00
Alexandre Wilhelm 14ab582a53 Fixed : Aristo showcase is broken because CPDatePicker
Previously the showcase of Aristo and Aristo2 didn't work because several bugs in the class CPDatePicker.

This PR fixes these problems :
- The first problem was when displaying a textual datePicker, the class tried to calculate different things for the calendar (good optimization as well).
- The second problem was about the calendar and the hands. It wasn't possible to display a PatternColor made with an image in a layer, now we use a PatternImage and the method CGContextDrawImage to draw the hands.
2013-05-21 13:53:16 -07:00
aparajita 6c2062c1f0 Merge pull request #1882 from ahankinson/fix-theme-disabled-controls
Theming fixes for disabled controls in Aristo2
2013-05-21 06:51:21 -07:00
Aparajita Fishman 7385f04d7f Fixed: theme showcase was failing due to various bugs. 2013-05-21 09:50:46 -04:00
Alexandre Wilhelm 9d76ab70fe Changed image for lineal gradient 2013-05-20 21:54:04 -07:00
Alexandre Wilhelm ce22cebf07 Removed the reverse colors (it was a bad idea) 2013-05-20 21:53:35 -07:00
Alexandre Wilhelm 22d66438fb Added test for linear/radial gradient 2013-05-20 19:08:44 -07:00
Alexandre Wilhelm de4e28b5cc Fixed bug with linear gradient when drawing it without CPGradient 2013-05-20 19:07:39 -07:00
Alexandre Wilhelm 5e0793c2ac Fixed small init bug in CPBezierPath 2013-05-20 19:06:48 -07:00
Alexandre Wilhelm 54dd027c15 Removes previous test 2013-05-20 19:06:08 -07:00
Alexandre Wilhelm ad33411ec6 New: CGContextDrawRadialGradient support
Canvas supports CGContextDrawRadialGradient as in cocoa. The CGGradientDrawingOptions is not actually supported.

Test app in Tests/Manual/CGCanvasContext
2013-05-20 15:08:46 -07:00
Aparajita Fishman 6bac934d0c Fixed: changed indentation of generated code to Cappuccino standard of 4 spaces. 2013-05-18 18:42:26 -04:00
Alexander Ljungberg 8c5015a0bc Test: verify compiler output for return statement without space.
Refs #1830.
2013-05-18 01:00:49 +01:00
Alexander Ljungberg 302138c257 Fixed: OutputTest reversed expectation and test value in error messages.
The message would read "expected x but was y", where y would actually be the correct expected value and x the wrong one.
2013-05-18 00:59:20 +01:00
Alexander Ljungberg 501310c058 Formatting: OldBrowserCompatibility.js.
Refs #1929.
2013-05-16 15:24:24 -07:00
Alexander Ljungberg cb2ba64a73 Merge branch 'master' of github.com:cappuccino/cappuccino 2013-05-16 14:18:46 -07:00
Alexander Ljungberg de1d6aad9c Test: check compiler output for selectors with keywords in them.
Refs #1929.
2013-05-16 14:17:31 -07:00
Aparajita Fishman 391ff7279d Fixed: capp_lint errors. 2013-05-16 15:02:45 -04:00
Alexander Ljungberg 1d1016f08e Test: reactivate the regex-simple-char-classes test.
This test failed with the old preprocessor but works fine now with the new compiler.

Refs #1929.
2013-05-16 11:15:03 -07:00
Alexander Ljungberg d040e60f60 Merge pull request #1929 from mrcarlberg/preprocess
Many compiler fixes
2013-05-16 10:03:38 -07:00
Martin Carlberg 3808427f24 Fixed: Accidental global variable 2013-05-16 16:15:29 +02:00
Martin Carlberg b3e6eb74b2 Fixed: Reset all the macros when compiling a new file in the default implementation of the macro store. 2013-05-16 12:07:44 +02:00
Martin Carlberg 392aafb360 Revert "Revert "New: Added test cases for some preprocess directives in OutputTest.j""
This reverts commit 5e6c89ca8b.

Conflicts:
	Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j
2013-05-16 12:05:57 +02:00
Martin Carlberg 6556ccef80 Fixed: Removed use of global variable 2013-05-16 11:26:01 +02:00
Martin Carlberg f96e934cf8 Fixed: Removed use of in some cases undefined global variables 2013-05-16 11:25:42 +02:00
Alexander Ljungberg 44a872659a New: type check - CPPasteBoard setString:forType:.
When this method is given e,g, an array or CPData, it now crashes early instead of the pasteboard exhibiting strange behaviour.
2013-05-15 08:47:43 -07:00
Martin Carlberg 256c5b83da Fixed: Typo, changed comma to semicolon 2013-05-15 15:35:03 +02:00
Martin Carlberg 5e6c89ca8b Revert "New: Added test cases for some preprocess directives in OutputTest.j"
This reverts commit 9b709b85a9.
2013-05-15 15:21:49 +02:00
Martin Carlberg bf4a5b2c9a Merge branch 'master' of https://github.com/cappuccino/cappuccino into preprocess 2013-05-15 09:08:26 +02:00
Alexander Ljungberg 6701117945 Fixed: [pasteboard declareTypes:… owner:nil]; would emit a warning.
Without this fix, declaring a type with a nil owner would cause a "DEPRECATED: object cannot be nil" warning to be issued.

This fix now allows a nil owner without warning.
2013-05-14 14:44:00 -07:00
Alexander Ljungberg f2d9ef7720 Test: - CPPasteboard setString:forType: and stringForType:. 2013-05-14 14:40:41 -07:00
Alexander Ljungberg 3fb0dd725a Fixed: CPLocale for English, United Kingdom had the wrong identifier. 2013-05-14 13:06:53 -07:00
Alexander Ljungberg a324cb3306 Fixed: CPLocale detection didn't work.
Previously, if the browser provided a language string such as "en-US", CPLocale would try to look up the locale for "en_EN", which wouldn't exist so it'd always select the default language.

This fix uses the browser provided language string fully to select the appropriate locale.
2013-05-14 13:03:31 -07:00
Alexander Ljungberg 2a9f3deb0e Merge pull request #1930 from mrcarlberg/cplocal_cant_handle_unknown_country_codes
Fixed: CPLocal can't handle unknown language codes
2013-05-14 12:00:39 -07:00
Alexander Ljungberg 89e81e97d1 Merge branch 'master' of github.com:cappuccino/cappuccino 2013-05-14 11:59:29 -07:00
Alexander Ljungberg b4fb4ba941 Formatting: CPLocale.
Tabs to spaces and other whitespace changes.
2013-05-14 11:59:17 -07:00
Aparajita Fishman eb859d42a4 Fixed: framework image names without @framework would cause nib2cib to fail.
I wasn't properly handling the case where _resourcePathForName would be called with a nil framework.
2013-05-14 07:54:08 -04:00
Martin Carlberg 9d86391bdb Fixed: CPLocal can't handle unknown language codes
When the language code is not known it still sets the current language code
to the unknown code instead of the defualt 'en_US' code.
This makes the test cases for CPDateFormatter fail when run on a foreign system.
2013-05-14 13:30:30 +02:00
Martin Carlberg 9b709b85a9 New: Added test cases for some preprocess directives in OutputTest.j
Also fixed so OutputTest.j now uses the new compiler instead of the old.
2013-05-14 10:31:29 +02:00
Alexander Ljungberg 9bde63923c Formatting: CPPredicateTest.
Refs #1914.
2013-05-13 22:27:39 -07:00
Alexander Ljungberg d7c676893d Merge pull request #1914 from mrcarlberg/predicate_expression_equals_nil
CPExpression and CPPredicate can't handle nil as argument in method isEqual:
2013-05-13 22:21:05 -07:00
Alexander Ljungberg 8bc8ae4e3b Merge pull request #1928 from mrcarlberg/ie_negative_width_height_crash
Fixed: IE8/9 (maybe 10 too) can't handle negative width or height.
2013-05-13 22:17:18 -07:00
Alexander Ljungberg 35b4e8f653 Merge pull request #1915 from Dogild/PopUpListComboBox
Fixed: CPComboBox popupList should close if mouse is clicked outside
2013-05-13 21:56:28 -07:00
Martin Carlberg 7837277cbe Merge branch 'master' of https://github.com/cappuccino/cappuccino into preprocess 2013-05-13 16:38:39 +02:00
Martin Carlberg 8145df9613 Fixed: Removed all uses of preprocess macros in the compiler 2013-05-13 16:23:12 +02:00
Martin Carlberg 9ffa184056 Fixed: IE8/9 can't handle negative style width or height.
Functions are used everywhere to set width or height in the DOM except in the method lockFocus. This will cause IE8/9 to report error if the width or height is negative in this method.
2013-05-13 15:12:59 +02:00
Sergio Felix d7b5382c32 Fixed: CPTabView will now update its tabs labels when the layoutSubviews method is called. Fixes 1926 2013-05-13 01:08:32 -05:00
Martin Carlberg ee9b04944a Merge branch 'master' of https://github.com/cappuccino/cappuccino into preprocess 2013-05-06 16:24:54 +02:00
Martin Carlberg e9ca7c7395 Fixed: IE8 Browser support.
The compiler can now run in IE8. Also found the use of the function .indexOf on Arrays in CPView.j.
It is not supported in IE8.

Added a new file (OldBrowserCompatibility.js) in the Objective-J framework that will add functions if they are not supported in the javascript runtime.
2013-05-06 16:17:09 +02:00
cacaodev 4d8f7c67d4 Fixed removeTableColumn: was not reloading views immediatly. Added test for issue 1913 in Manual/TableTest/TestTableColumn. Throws an exception when you click the button twice 2013-05-02 19:39:27 +02:00
Alexandre Wilhelm 736dffa334 capp_lint 2013-04-25 17:06:52 -07:00
Alexandre Wilhelm afdad97aad Added CPComboBox Aristo2 style 2013-04-24 17:47:30 -07:00
Alexandre Wilhelm 7e27de8a1e Updated slices 2013-04-24 17:46:53 -07:00
Martin Carlberg 14ee789df4 Fixed: Mark correct column position in 'Expected a Semicolon' errors in the parser. 2013-04-24 10:12:42 +02:00
Martin Carlberg b6fd6a15f0 Fixed: Removed extra spaces in code generation between 'else' and 'if' in 'else if' statements 2013-04-23 17:07:26 +02:00
Martin Carlberg e35bfaf96c Fixed: Better looking code generation with correct indentation for 'if' - 'else if' statements 2013-04-23 15:48:25 +02:00
Martin Carlberg ffdee8c3d7 Fixed: Method isEqual: can handle nil as an argument for CPExpression and CPPredicate including sub classes. 2013-04-23 12:58:07 +02:00
Martin Carlberg 8a94c33a64 New: Added test cases checking that a CPObject, CPExpression and CPPredicate is not equal nil.
CPExpression and CPPredicate can't handle nil as an argument to method isEqual:. These test cases checks that this is working.
2013-04-23 12:54:26 +02:00
cacaodev e53337bcdc Remove check in -hitTest: that was preventing reverse set binding 2013-04-13 21:39:20 +02:00
cacaodev e5d883f97e CAKeyframeAnimation
CPAnimatablePropertyContainer protocol (CPView)
CPAnimationContext
_CPObjectAnimator CPViewAnimator
CSS Animations wrapper

CPAnimatablePropertyContainerTest : animations of views with custom Layout / Regular Layout / Custom DrawRect: / No DrawRect: / Subviews / No Subviews and combinations of these situations.
controls animation (text field, button, popup, slider ...). They animate their size via their action.
2013-04-13 16:29:43 +02:00
cacaodev 548a55792c Merge remote-tracking branch 'upstream/master' into CPTableView-enumerateRows 2013-04-13 11:52:51 +02:00
cacaodev 43f0f2a0fd Simplified -numberOfRows
Added -_numberOfRows that computes the new number of rows. Removed the
nil check.

All tests in AppKit/CPTableViewTest are now passing with success.
2013-04-13 11:38:47 +02:00
cacaodev 7b1c696810 Fixed: CPTableViewTest: -deselectAll should send 1 CPtableViewSelectionDidChangeNotification, not 2.
Checked in cocoa.
Moved a failing test to the end of the method so it does not shadow other tests.
2013-04-12 19:48:07 +02:00
cacaodev 8d69c3764d Fixed: The data views were not loaded immediately
When reloading the table view, the actual loading (-load) is defered
until layout is needed (generally in the next run loop). This is an
advantage because it minimize reloads but in some case it is necessary
to force a reload, for example when we need to access data views, or
manually edit a view, or when we explicitely ask for a reload.
This commit adds _reloadDataViewsImmediately and make use of it when
necessary.

Tests: AppKit/CPTableViewTest -> -testEditCell
2013-04-12 19:35:03 +02:00
cacaodev 87acd9d7ee Fixed: in some circumstances, table views binded with the content binding were not correctly reloading the data.
Test: AppKit/WithOrWithoutbinding
2013-04-12 19:23:51 +02:00
cacaodev 06391c9de6 Fixed: data views were not reloaded after a CPTableColumn setDataView:
Cell-based table views with no identifier set for the table column:
Before this commit, the caching system was asking for a view identified
by the tableColumn UID. If the table column data view was changed
externaly, the previoulsy cached data views were loaded instead of the
new ones. The views are now identified by the -dataview UID.

Test: AppKit/TableTest -testLayout were a custom data view is set.
2013-04-12 19:21:16 +02:00
cacaodev b42b41216b Remove old code. Adds Equality check in -setDataView: 2013-04-12 19:08:27 +02:00
Martin Carlberg 689ab09555 New: Now supports 'defined' operator, which lets you check whether macros are defined in the middle of an ‘#if’.
Also the evaluation of expressions are now lazy.
2013-04-11 09:37:40 +02:00
Martin Carlberg 30ee1ad8cd New: Handles line continue token '\' on lines starting with '#'
We now support lines like this:
#define StopButtonTitle() \
        CPLocalizedString(@"Stop", @"Stop button title")
2013-04-11 09:32:41 +02:00
Andrew Hankinson 6ef5b46dd6 Fixed: CPTokenField sends focus and blur notifications
This commit adds notifications for focus and blur on CPTokenField.

Attached is a modified Manual CPTokenFieldTest that observes these notifications.

Fixes #1396
2013-04-07 20:50:50 -04:00
cacaodev 0a1d215560 Fixed: -reloadData: was not reloading views after a change in model rows count 2013-04-04 20:00:56 +02:00
cacaodev 44b6136ce2 Fixed CPOutlineView dragging column subclassing 2013-04-01 20:11:02 +02:00
cacaodev ba3c6023a8 Fixed CPOutlineView subclassing when settting CPThemeStateSelectedDataView 2013-04-01 20:11:02 +02:00
cacaodev be7f6ae7d1 Fixed CPOutlineView -reloadData and _layoutViewsForRowIndexes:columnIndexes: subclassing. 2013-04-01 20:11:02 +02:00
cacaodev 984c7a67f5 Fixed: -moveColumn:to: now preserve selected columns
Fixed: Starting a column drag is now faster.
Fixed: When dragging a selected column, selection is now drawn on the dragging view and the cursor is the closed hand.
Fixed: When dragging a table column, underlying columns were sliding according to the tracking location instead of the column lateral edges.
Fixed: In CPTableView, the drop indicator for rows could appear when dragging a column.

This commit creates directly the dragging column instead of relying on
built-in drag&drop. Also fixes a bug where the drop indicator would appear when
dragging a column if some rows were previously drag&dropped.
2013-04-01 20:08:37 +02:00
cacaodev a4bf6c1f7a Fixed: selectColumnIndexes:byExtendingSelection: returns early when there is no change in columns selection
Before this change, rows could be unselected even if the columns
selection did not change.
2013-04-01 20:08:36 +02:00
cacaodev 690ae1a7b6 Fixed: noteHeightOfRowsWithIndexesChanged: was not showing immediatly row height changes.
Todo: instead of reloading everything we should be able to just
relayout frames for visible views and then tile.
2013-04-01 19:52:37 +02:00
cacaodev eae9a10a7d Fixed: editingColumn and editingRow return the correct index in view based tables
Fixed: An edited view no longer send its action (view-based) or commit its object value (cell-based) when unexposed.
Fixed: Cell based tables support for editing any control, not just textfield and buttons.
2013-04-01 19:52:30 +02:00
cacaodev 7c6765b969 Fixed: After drag, views were cached.
This commit reverts #1478. It appears it is a bad idea to enqueue
visible views. The views generally stay in the cache forever and they
are repeatedly asked to be removed from the table at each load, causing
a performance penalty.
2013-04-01 19:50:41 +02:00
cacaodev a6c143a1c7 Fixed: -reloadDataForRowsIndexes:columnIndexes: behavior.
Fixed: Column dragging performance, content binding performance.

After this commit, -reloadDataForRowsIndexes:columnIndexes: reloads the data and the data only.
The -reloadData method no longer tries to reuse the views, instead it just reloads the data for visible views.
To flush and reload the views cache for visible rows, use _reloadDataViews.
To internaly layout the views geometry, use _layouViewsForRowIndexes:columnIndexes:

In CPTableView dragging column code, relayout the views whose frame changed instead of reloading everything.
2013-04-01 19:50:41 +02:00
cacaodev 714da0ab3b New: -enumerateAvailableViewsUsingBlock: and private -_enumerateViewsInRows:columns:usingBlock: and -_enumerateViewsInRows:tableColumns:usingBlock: methods.
New: preparedViewAtColumn:row:

These methods allow to enumerate visible data views or data views in specified columns and rows.
-enumerateAvailableViewsUsingBlock: is the counterpart of cocoa's -enumerateAvailableRowViewsUsingBlock: except that it enumerates data views instead of CPTableRowView and the block has an additional column parameter.

This commit reverses the way views are stored and accessed in the table view: rows>columns instead of columns>rows.
Applied the second method where it is relevant, making the code more compact and readable.
2013-04-01 19:49:41 +02:00
cacaodev 377ec37257 Fixed: In CPTrace, fixed error when an argument was not a cappuccino object.
Arguments such as CGPoint, CGRect and functions are now correctly
printed to the console.
2013-04-01 19:34:04 +02:00
Martin Carlberg 84df301f3e New: #if macro statement works for simple literals but not for macro identifiers and defined keyword 2013-03-28 22:43:26 +01:00
Andrew Hankinson 792a72af74 Fixed: Themed text values set via a single variable
Previously, the themed text values for controls were set directly on the control, which made modifying the theme values for text consistently across the controls difficult.

This commit introduces several file-scoped variables that are used to set the text colour, the disabled text colour for both regular and default controls, as well as a consistent text shadow colour for each of these as well.
2013-03-28 13:35:09 -04:00
Andrew Hankinson 8fee6578c2 Fixed: Minor typo in CPWindow comment 2013-03-28 10:36:46 -04:00
Andrew Hankinson 6d843e6aab Fixed: Removed duplicated method in CPToolbar
CPToolbar setDisplayMode has been implemented (L246). This commit removes a duplicate empty method that says it has not been implemented.
2013-03-28 10:19:08 -04:00
Martin Carlberg 2751f4fea9 New: Added missed #ifdef derective 2013-03-27 14:52:05 +01:00
Martin Carlberg c21cfeb28e New: Added #ifdef, #ifndef, #else, #endif and #undef macro derectives 2013-03-27 14:50:55 +01:00
Martin Carlberg 8707247008 New: Always generate code when compiling 2013-03-27 14:45:25 +01:00
Andrew Hankinson 3d0bde6763 Stepper disabled graphics update 2013-03-27 00:20:20 -04:00
Andrew Hankinson 11f509933e Typos 2013-03-26 23:40:19 -04:00
Andrew Hankinson 7078dd92dd Restoring the segmented control theme descriptor settings 2013-03-26 23:23:35 -04:00
Andrew Hankinson f5e0addbcc Restoring circular slider disabled graphics 2013-03-26 23:22:34 -04:00
Andrew Hankinson fd88ac509f Slight tweak to the disabled slider knob graphic
The stroke opacity is reduced from 35% to 20% to bring it in line with the stroke opacity of other disabled controls
2013-03-26 23:22:02 -04:00
Andrew Hankinson d267ddcafa Reverse earlier commits that removed some images
The segmented control disabled state is not applied via CSS opacity, so the segmented control images must be present.
2013-03-26 23:20:40 -04:00
Andrew Hankinson 9084e9ed18 Fixed: Text shadow offset on enabled controls
Previously, the text shadow offset on a control that was active (e.g., a button that was set to default, or the active segment of a segmented control) would have a text shadow applied to it if the button was also disabled.

This commit negates the text-shadow offset so that the text appears correctly.
2013-03-26 23:17:23 -04:00
Andrew Hankinson bf29a4faa9 Defined file-level variables for text colors
This commit defines file-level variables for the disabled text colour, the disabled text shadow colour, and the placeholder text colour. It also adds or replaces these values in the controls where appropriate.
2013-03-26 23:14:57 -04:00
Andrew Hankinson 615380a70c Standardizing disabled text theming for popup and pulldown buttons 2013-03-26 22:46:49 -04:00
Andrew Hankinson 20a2b2d330 Fixed: circular slider disabled image uses CSS opacity 2013-03-26 20:23:38 -04:00
Andrew Hankinson d50439161a Fixed: Combo box disabled state dims text
Previously, setting a CPComboBox to disabled would not dim the text. This commit fixes the theme state to include a setting for the text colour and text shadow colour.
2013-03-26 19:19:03 -04:00
Andrew Hankinson 7d6cdf1b7b Updated pulldown button disabled images
These updated images have an outer stroke opacity of 20%, compared to 35% for the active images
2013-03-26 19:01:08 -04:00
Andrew Hankinson abcb60ed4c Updated popup button disabled images
These updated images have an outer stroke opacity of 20%, compared to 35% for the active images
2013-03-26 19:00:52 -04:00
Andrew Hankinson 443b6ff4f9 Updated combo box disabled images
These updated images have an outer stroke opacity of 20%, compared to 35% for the active images
2013-03-26 19:00:14 -04:00
Andrew Hankinson de89eadcf2 Formatting and whitespace 2013-03-26 18:40:22 -04:00
Andrew Hankinson 4956218b10 Fixed: Change default disabled opacity
Previously some disabled controls would be set with an opacity of 0.35, which resulted in controls that were visually too light.

This commit changes the default disabled opacity to 0.5.

Refs #1788
2013-03-26 17:44:57 -04:00
Andrew Hankinson bcfaf3a37e Fix Pulldown Button disabled images
The new images are set at full opacity with the blue highlight colour removed
2013-03-26 17:43:02 -04:00
Andrew Hankinson b1c45e579a Fix CPPopupButton disabled images
The new images are set at full opacity with the blue highlight colour removed
2013-03-26 17:42:41 -04:00
Andrew Hankinson e627f60b16 Fix CPComboBox disabled images
The new images are set at full opacity with the blue highlight colour removed
2013-03-26 17:42:05 -04:00
Andrew Hankinson a368fe5825 Fix disabled theme for Aristo2 segmented controls
Disabled state is now set via CSS opacity alone
2013-03-26 13:39:46 -04:00
Andrew Hankinson 895a128ff7 Fix disabled theme for Aristo2 radio buttons
Disabled state is now set via CSS opacity alone
2013-03-26 13:33:55 -04:00
Andrew Hankinson 792a4dda7f Merge branch 'fix-theme-disabled-controls' of github.com:ahankinson/cappuccino into fix-theme-disabled-controls 2013-03-26 13:29:56 -04:00
Andrew Hankinson 4d828a01aa Fix disabled theme for Aristo2 checkboxes
Previously the Aristo2 checkboxes used dedicated images for disabled controls.

This commit removes the disabled controls and allows the disabled state to be set via CSS opacity on the "regular" checkbox controls.
2013-03-26 13:29:48 -04:00
Andrew Hankinson 195ee3ee2c Fix disabled theme for Aristo2 checkboxes
Previously the Aristo2 checkboxes used dedicated images for disabled controls.

This commit removes the disabled controls and allows the disabled state to be set via CSS opacity on the "regular" checkbox controls.
2013-03-26 13:23:11 -04:00
Blair Duncan 5868a4cefb added missing methods to CPDocumentController
documentForWindow
hasEditedDocuments

both are in cocoa
2013-03-21 11:15:25 -04:00
Blair Duncan 3178f0b57d Fixed CPDocumentController missing method currentDocument
In this commit I've added the currentDocument method to the document controller

Also removed the firstEligibleExistingWindowController method from CPDocument
It did nothing but add confusion as it was not used anywhere else in the frameworks.
And it is not in cocoa.
2013-03-21 10:38:06 -04:00
Martin Carlberg 89457845f9 Fixed: Made some smaller code generation changes to get better formatted compiled code 2013-03-21 14:32:21 +01:00
Martin Carlberg 53e98521f3 Merge branch 'master' of https://github.com/cappuccino/cappuccino into preprocess 2013-03-21 12:25:47 +01:00
Martin Carlberg 1842d7127a New: The generated code will now have correct indentation. 2013-03-21 11:33:13 +01:00
Martin Carlberg ecc1e774b9 New: Added macro/identifier concatenation with the '##' operator
Example:
#define first Martin
#define second Carlberg
var first##second = 13;

Compiles to:
var MartinCarlberg = 13;

Example 2:
#define _function(inline) function inline { return _##inline; }
#define _CGPointMake(x_, y_) { x:x_, y:y_ }
_function(CGPointMake(x, y))

Compiles to:
function CGPointMake (x, y) {
  return {x: x, y: y};
}
2013-03-20 21:00:36 +01:00
Martin Carlberg fa18095538 Fixed: Does not add extra parentheses for expression operators with the same precedence 2013-03-20 20:47:27 +01:00
Martin Carlberg 92ac8569b3 New: Full support for generate code instead of copy
The new compiler can now generate code. The old way of copy and alter the source
code is still supported.
2013-03-17 21:00:24 +01:00
Martin Carlberg 0c982b0999 Fixed: An ExpressionStatement with a Send message expression can be parsed wrongly
When a statement ends without a semicolon and a Send message expression is on the next line it was wrongly parsed as a single Send message expression. It should be an ExpressionStatement with a Send message expression inside.
2013-03-17 20:52:21 +01:00
Martin Carlberg bef0ca18c6 New: New option to generate code for the objjc tool
A new option flag '-G' can be added to let the compiler generate the code instead of copy and alter it from the source code
2013-03-17 20:45:34 +01:00
Martin Carlberg 22cdbd7ec7 Merge branch 'master' of https://github.com/cappuccino/cappuccino into preprocess
Conflicts:
	Objective-J/ObjJAcornCompiler.js
	Objective-J/acorn.js
2013-03-12 11:20:56 +01:00
Martin Carlberg 362f3b890e Added first try for compiler to generate code 2013-03-12 09:22:26 +01:00
Martin Carlberg c17053f71a Removed test line 2013-02-26 08:53:12 +01:00
Martin Carlberg e8e87b3b83 Added recursive token transformer and preprocessor tokenizer 2013-02-24 22:26:27 +01:00
Martin Carlberg 340f1e3258 Made the acorn parser able to run outside of the Cappuccino world 2013-02-24 22:25:00 +01:00
Martin Carlberg 529e703ddd Merge branch 'master' of https://github.com/cappuccino/cappuccino into objj_compiler2 2013-02-24 15:45:56 +01:00
Martin Carlberg 699ef14b4e Merge with latest acorn compiler 2013-02-21 12:57:19 +01:00
Martin Carlberg 8c68854d1d Fixed local variable that is declared as a global 2013-02-19 20:25:57 +01:00
Martin Carlberg 64a38a2aef Refactored how maybe warnings is handled and prepared for new "local variable hides global variable" warning. The warning is disabled because there are to many warning in the Cappuccino frameworks right now. 2013-02-19 20:22:42 +01:00
Martin Carlberg cccfe7268b Fixed better comment 2013-02-19 17:48:16 +01:00
Martin Carlberg c03697c0a6 Fixed support for IE8 2013-02-19 17:47:34 +01:00
Martin Carlberg 32bf87c0c3 Fixed typo 2013-02-19 17:46:24 +01:00
1727 changed files with 172816 additions and 78608 deletions
+34
View File
@@ -0,0 +1,34 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node build
on:
push:
branches: [ node ]
pull_request:
branches: [ node ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [17.x, 18.x, 19.x, 20.x, 21.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: echo "${PWD}/dist/cappuccino/bin" >> $GITHUB_PATH
- run: echo "${PWD}/dist/objective-j/bin" >> $GITHUB_PATH
- run: npm install
- run: npm update
- run: jake dist
- run: jake test-only
+12
View File
@@ -5,6 +5,7 @@ Demos
./Aristo
WebSite
.push-package
*.xcodeproj*
*.xcodeproj/*.pbxuser
*.xcodeproj/*.perspectivev3
xcuserdata/
@@ -12,5 +13,16 @@ xcuserdata/
*.xCodeSupport/
*.XcodeSupport/
*XcodeSupport/
Tests/Manual/**/*.xcodeproj
*.sublime-project
*.sublime-workspace
*.tm_properties
*.idea
node_modules
*.vscode
/dist/objective-j/objj-executable
/dist/objective-j/package.json
/dist/objective-j/lib
/dist/cappuccino/package.json
/dist/cappuccino/lib
+28
View File
@@ -0,0 +1,28 @@
.DS_Store
Frameworks
!/dist/objective-j/Frameworks
!/dist/cappuccino-j/Frameworks
Build
Demos
./Aristo
WebSite
.push-package
*.xcodeproj*
*.xcodeproj/*.pbxuser
*.xcodeproj/*.perspectivev3
xcuserdata/
!*.xcodeproj/project.pbxproj
*.xCodeSupport/
*.XcodeSupport/
*XcodeSupport/
Tests/Manual/**/*.xcodeproj
*.sublime-project
*.sublime-workspace
*.tm_properties
*.idea
node_modules
*.vscode
/dist/objective-j/objj-executable
/dist/objective-j/package.json
/dist/cappuccino/package.json
+1 -1
View File
@@ -1,6 +1,6 @@
language: node_js
node_js:
- 0.8
install: ./bootstrap.sh --quiet --noprompt --directory ./narwhal
install: ./bootstrap.sh --noprompt --directory ./narwhal
script: jake test
env: PATH="$TRAVIS_BUILD_DIR/narwhal/bin:$PATH" CAPP_BUILD="$TRAVIS_BUILD_DIR/Build" NARWHAL_ENGINE=rhino
+7 -2
View File
@@ -20,12 +20,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import "_CPObject+Theme.j"
@import "_CPToolTip.j"
@import "CALayer.j"
@import "CGGeometry.j"
@import "CPAccordionView.j"
@import "CPAlert.j"
@import "CPAnimation.j"
@import "CPAnimationContext.j"
@import "CPAppearance.j"
@import "CPApplication.j"
@import "CPArrayController.j"
@import "CPBezierPath.j"
@@ -59,8 +62,6 @@
@import "CPDocument.j"
@import "CPDocumentController.j"
@import "CPEvent.j"
@import "CPFlashMovie.j"
@import "CPFlashView.j"
@import "CPFont.j"
@import "CPFontManager.j"
@import "CPGradient.j"
@@ -98,14 +99,18 @@
@import "CPTabView.j"
@import "CPText.j"
@import "CPTextField.j"
@import "CPTextView.j"
@import "CPTokenField.j"
@import "CPToolbar.j"
@import "CPToolbarItem.j"
@import "CPTrackingArea.j"
@import "CPTreeNode.j"
@import "CPUserDefaultsController.j"
@import "CPView.j"
@import "CPViewAnimator.j"
@import "CPViewAnimation.j"
@import "CPViewController.j"
@import "CPVisualEffectView.j"
@import "CPWebView.j"
@import "CPWindow.j"
@import "CPWindowController.j"
+189 -82
View File
@@ -41,6 +41,10 @@
@global CPApp
var CPAlertDelegate_alertShowHelp_ = 1 << 0,
CPAlertDelegate_alertDidEnd_returnCode_ = 1 << 1;
@typedef CPAlertStyle
/*
@global
@group CPAlertStyle
@@ -59,6 +63,62 @@ CPCriticalAlertStyle = 2;
var bottomHeight = 71;
@protocol CPAlertDelegate <CPObject>
@optional
- (BOOL)alertShowHelp:(CPAlert)alert;
- (void)alertDidEnd:(CPAlert)theAlert returnCode:(int)returnCode;
@end
@implementation _CPAlertThemeView : CPView
+ (CPString)defaultThemeClass
{
return @"alert";
}
+ (CPDictionary)themeAttributes
{
return @{
@"size": CGSizeMake(400.0, 110.0),
@"content-inset": CGInsetMake(15, 15, 15, 50),
@"informative-offset": 6,
@"button-offset": 10,
@"message-text-alignment": CPJustifiedTextAlignment,
@"message-text-color": [CPColor blackColor],
@"message-text-font": [CPFont boldSystemFontOfSize:13.0],
@"message-text-shadow-color": [CPNull null],
@"message-text-shadow-offset": CGSizeMakeZero(),
@"informative-text-alignment": CPJustifiedTextAlignment,
@"informative-text-color": [CPColor blackColor],
@"informative-text-font": [CPFont systemFontOfSize:12.0],
@"informative-text-shadow-color": [CPNull null],
@"informative-text-shadow-offset": CGSizeMakeZero(),
@"image-offset": CGPointMake(15, 12),
@"information-image": [CPNull null],
@"warning-image": [CPNull null],
@"error-image": [CPNull null],
@"help-image": [CPNull null],
@"help-image-left-offset": 15,
@"help-image-pressed": [CPNull null],
@"suppression-button-y-offset": 0.0,
@"suppression-button-x-offset": 0.0,
@"default-elements-margin": 3.0,
@"suppression-button-text-color": [CPColor blackColor],
@"suppression-button-text-font": [CPFont systemFontOfSize:12.0],
@"suppression-button-text-shadow-color": [CPNull null],
@"suppression-button-text-shadow-offset": 0.0,
@"modal-window-button-margin-y": 0.0,
@"modal-window-button-margin-x": 0.0,
@"standard-window-button-margin-y": 0.0,
@"standard-window-button-margin-x": 0.0,
};
}
@end
/*!
@ingroup appkit
@@ -83,31 +143,33 @@ var bottomHeight = 71;
*/
@implementation CPAlert : CPObject
{
BOOL _showHelp @accessors(property=showsHelp);
BOOL _showSuppressionButton @accessors(property=showsSuppressionButton);
BOOL _showHelp @accessors(property=showsHelp);
BOOL _showSuppressionButton @accessors(property=showsSuppressionButton);
CPAlertStyle _alertStyle @accessors(property=alertStyle);
CPString _title @accessors(property=title);
CPView _accessoryView @accessors(property=accessoryView);
CPImage _icon @accessors(property=icon);
CPAlertStyle _alertStyle @accessors(property=alertStyle);
CPString _title @accessors(property=title);
CPView _accessoryView @accessors(property=accessoryView);
CPImage _icon @accessors(property=icon);
CPArray _buttons @accessors(property=buttons, readonly);
CPCheckBox _suppressionButton @accessors(property=suppressionButton, readonly);
CPArray _buttons @accessors(property=buttons, readonly);
CPCheckBox _suppressionButton @accessors(property=suppressionButton, readonly);
id _delegate @accessors(property=delegate);
id _modalDelegate;
SEL _didEndSelector;
id <CPAlertDelegate> _delegate @accessors(property=delegate);
id _modalDelegate;
SEL _didEndSelector @accessors(property=didEndSelector);
Function _didEndBlock;
unsigned _implementedDelegateMethods;
_CPAlertThemeView _themeView @accessors(property=themeView, readonly);
CPWindow _window @accessors(property=window, readonly);
int _defaultWindowStyle;
_CPAlertThemeView _themeView @accessors(property=themeView, readonly);
CPWindow _window @accessors(property=window, readonly);
int _defaultWindowStyle;
CPImageView _alertImageView;
CPTextField _informativeLabel;
CPTextField _messageLabel;
CPButton _alertHelpButton;
CPImageView _alertImageView;
CPTextField _informativeLabel;
CPTextField _messageLabel;
CPButton _alertHelpButton;
BOOL _needsLayout;
BOOL _needsLayout;
}
#pragma mark Creating Alerts
@@ -186,6 +248,30 @@ var bottomHeight = 71;
return self;
}
#pragma mark -
#pragma mark Delegate
/*!
Set the delegate of the receiver
@param aDelegate the delegate object for the alert.
*/
- (void)setDelegate:(id <CPAlertDelegate>)aDelegate
{
if (_delegate === aDelegate)
return;
_delegate = aDelegate;
_implementedDelegateMethods = 0;
if ([_delegate respondsToSelector:@selector(alertShowHelp:)])
_implementedDelegateMethods |= CPAlertDelegate_alertShowHelp_;
if ([_delegate respondsToSelector:@selector(alertDidEnd:returnCode:)])
_implementedDelegateMethods |= CPAlertDelegate_alertDidEnd_returnCode_;
}
#pragma mark Accessors
- (CPTheme)theme
@@ -218,22 +304,21 @@ var bottomHeight = 71;
[_themeView setValue:aValue forThemeAttribute:aName];
}
- (void)setValue:(id)aValue forThemeAttribute:(CPString)aName inState:(CPThemeState)aState
- (void)setValue:(id)aValue forThemeAttribute:(CPString)aName inState:(ThemeState)aState
{
[_themeView setValue:aValue forThemeAttribute:aName inState:aState];
}
/*! @deprecated
*/
- (void)setWindowStyle:(int)aStyle
/*! @deprecated */
- (void)setWindowStyle:(int)style
{
CPLog.warn("DEPRECATED: setWindowStyle: is deprecated. use setTheme: instead");
[self setTheme:(aStyle === CPHUDBackgroundWindowMask) ? [CPTheme defaultHudTheme] : [CPTheme defaultTheme]];
[self setTheme:(style === CPHUDBackgroundWindowMask) ? [CPTheme defaultHudTheme] : [CPTheme defaultTheme]];
}
/*! @deprecated
*/
/*! @deprecated */
- (int)windowStyle
{
CPLog.warn("DEPRECATED: windowStyle: is deprecated. use theme instead");
@@ -242,18 +327,19 @@ var bottomHeight = 71;
/*!
set the text of the alert's message
Set the text of the alert's message.
@param aText CPString containing the text
*/
- (void)setMessageText:(CPString)aText
- (void)setMessageText:(CPString)text
{
[_messageLabel setStringValue:aText];
[_messageLabel setStringValue:text];
_needsLayout = YES;
}
/*!
return the content of the message text
Return the content of the message text.
@return CPString containing the message text
*/
- (CPString)messageText
@@ -262,13 +348,13 @@ var bottomHeight = 71;
}
/*!
set the text of the alert's informative text
Set the text of the alert's informative text.
@param aText CPString containing the informative text
*/
- (void)setInformativeText:(CPString)aText
- (void)setInformativeText:(CPString)text
{
[_informativeLabel setStringValue:aText];
[_informativeLabel setStringValue:text];
_needsLayout = YES;
}
@@ -285,6 +371,7 @@ var bottomHeight = 71;
/*!
Sets the title of the alert window.
This API is not present in Cocoa.
@param aTitle CPString containing the window title
*/
- (void)setTitle:(CPString)aTitle
@@ -294,7 +381,7 @@ var bottomHeight = 71;
}
/*!
set the accessory view
Set the accessory view.
@param aView the accessory view
*/
@@ -305,7 +392,7 @@ var bottomHeight = 71;
}
/*!
set if alert shows the suppression button
Set if the alert shows the suppression button.
@param shouldShowSuppressionButton YES or NO
*/
@@ -596,6 +683,17 @@ var bottomHeight = 71;
[CPApp runModalForWindow:_window];
}
/*!
The same as \c runModal, but executes the code in \c block when the
alert is dismissed.
*/
- (void)runModalWithDidEndBlock:(Function /*(CPAlert alert, int returnCode)*/)block
{
_didEndBlock = block;
[self runModal];
}
/*!
Runs the receiver modally as an alert sheet attached to a specified window.
@@ -630,6 +728,20 @@ var bottomHeight = 71;
[self beginSheetModalForWindow:aWindow modalDelegate:nil didEndSelector:nil contextInfo:nil];
}
/*!
Runs the receiver modally as an alert sheet attached to a specified window.
Executes the code in \c block when the alert is dismissed.
@param window The parent window for the sheet.
@param block Code block to execute on dismissal
*/
- (void)beginSheetModalForWindow:(CPWindow)aWindow didEndBlock:(Function /*(CPAlert alert, int returnCode)*/)block
{
_didEndBlock = block;
[self beginSheetModalForWindow:aWindow modalDelegate:nil didEndSelector:nil contextInfo:nil];
}
#pragma mark Private
/*!
@@ -669,8 +781,7 @@ var bottomHeight = 71;
*/
- (@action)_showHelp:(id)aSender
{
if ([_delegate respondsToSelector:@selector(alertShowHelp:)])
[_delegate alertShowHelp:self];
[self _sendDelegateAlertShowHelp];
}
/*
@@ -697,61 +808,57 @@ var bottomHeight = 71;
*/
- (void)_alertDidEnd:(CPWindow)aWindow returnCode:(int)returnCode contextInfo:(id)contextInfo
{
if (_didEndSelector)
objj_msgSend(_modalDelegate, _didEndSelector, self, returnCode, contextInfo);
if (_didEndBlock)
{
if (typeof(_didEndBlock) === "function")
_didEndBlock(self, returnCode);
else
CPLog.warn("%s: didEnd block is not a function", [self description]);
_modalDelegate = nil;
_didEndSelector = nil;
if ([_delegate respondsToSelector:@selector(alertDidEnd:returnCode:)])
[_delegate alertDidEnd:self returnCode:returnCode];
// didEnd blocks are transient
_didEndBlock = nil;
}
else if (_modalDelegate)
{
if (_didEndSelector)
_modalDelegate.isa.objj_msgSend3(_modalDelegate, _didEndSelector, self, returnCode, contextInfo);
}
else if (_delegate)
{
if (_didEndSelector)
_delegate.isa.objj_msgSend2(_delegate, _didEndSelector, self, returnCode);
else
[self _sendDelegateAlertDidEndReturnCode:returnCode];
}
}
@end
@implementation _CPAlertThemeView : CPView
+ (CPString)defaultThemeClass
@implementation CPAlert (CPAlertDelegate)
/*!
@ignore
Call the delegate alertDidEnd:returnCode
*/
- (void)_sendDelegateAlertDidEndReturnCode:(int)returnCode
{
return @"alert";
if (!(_implementedDelegateMethods & CPAlertDelegate_alertDidEnd_returnCode_))
return;
[_delegate alertDidEnd:self returnCode:returnCode];
}
+ (id)themeAttributes
/*!
@ignore
Call the delegate alertShowHelp:
*/
- (BOOL)_sendDelegateAlertShowHelp
{
return @{
@"size": CGSizeMake(400.0, 110.0),
@"content-inset": CGInsetMake(15, 15, 15, 50),
@"informative-offset": 6,
@"button-offset": 10,
@"message-text-alignment": CPJustifiedTextAlignment,
@"message-text-color": [CPColor blackColor],
@"message-text-font": [CPFont boldSystemFontOfSize:13.0],
@"message-text-shadow-color": [CPNull null],
@"message-text-shadow-offset": CGSizeMakeZero(),
@"informative-text-alignment": CPJustifiedTextAlignment,
@"informative-text-color": [CPColor blackColor],
@"informative-text-font": [CPFont systemFontOfSize:12.0],
@"informative-text-shadow-color": [CPNull null],
@"informative-text-shadow-offset": CGSizeMakeZero(),
@"image-offset": CGPointMake(15, 12),
@"information-image": [CPNull null],
@"warning-image": [CPNull null],
@"error-image": [CPNull null],
@"help-image": [CPNull null],
@"help-image-left-offset": 15,
@"help-image-pressed": [CPNull null],
@"suppression-button-y-offset": 0.0,
@"suppression-button-x-offset": 0.0,
@"default-elements-margin": 3.0,
@"suppression-button-text-color": [CPColor blackColor],
@"suppression-button-text-font": [CPFont systemFontOfSize:12.0],
@"suppression-button-text-shadow-color": [CPNull null],
@"suppression-button-text-shadow-offset": 0.0,
@"modal-window-button-margin-y": 0.0,
@"modal-window-button-margin-x": 0.0,
@"standard-window-button-margin-y": 0.0,
@"standard-window-button-margin-x": 0.0,
};
if (!(_implementedDelegateMethods & CPAlertDelegate_alertShowHelp_))
return YES;
return [_delegate alertShowHelp:self];
}
@end
+113 -33
View File
@@ -26,25 +26,26 @@
@import "CAMediaTimingFunction.j"
/*
@global
@group CPAnimationCurve
*/
@protocol CPAnimationDelegate <CPObject>
@optional
- (BOOL)animationShouldStart:(CPAnimation)animation;
- (float)animation:(CPAnimation)animation valueForProgress:(float)progress;
- (void)animationDidEnd:(CPAnimation)animation;
- (void)animationDidStop:(CPAnimation)animation;
@end
var CPAnimationDelegate_animationShouldStart_ = 1 << 1,
CPAnimationDelegate_animation_valueForProgress_ = 1 << 2,
CPAnimationDelegate_animationDidEnd_ = 1 << 3,
CPAnimationDelegate_animationDidStop_ = 1 << 4;
@typedef CPAnimationCurve
CPAnimationEaseInOut = 0;
/*
@global
@group CPAnimationCurve
*/
CPAnimationEaseIn = 1;
/*
@global
@group CPAnimationCurve
*/
CPAnimationEaseOut = 2;
/*
@global
@group CPAnimationCurve
*/
CPAnimationLinear = 3;
ACTUAL_FRAME_RATE = 0;
@@ -80,17 +81,18 @@ ACTUAL_FRAME_RATE = 0;
*/
@implementation CPAnimation : CPObject
{
CPTimeInterval _lastTime;
CPTimeInterval _duration;
CPTimeInterval _lastTime;
CPTimeInterval _duration;
CPAnimationCurve _animationCurve;
CAMediaTimingFunction _timingFunction;
CPAnimationCurve _animationCurve;
CAMediaTimingFunction _timingFunction;
float _frameRate;
float _progress;
float _frameRate;
float _progress;
id _delegate;
CPTimer _timer;
id <CPAnimationDelegate> _delegate;
CPTimer _timer;
unsigned _implementedDelegateMethods;
}
/*!
@@ -214,9 +216,25 @@ ACTUAL_FRAME_RATE = 0;
Sets the animation's delegate.
@param aDelegate the new delegate
*/
- (void)setDelegate:(id)aDelegate
- (void)setDelegate:(id <CPAnimationDelegate>)aDelegate
{
if (_delegate === aDelegate)
return;
_delegate = aDelegate;
_implementedDelegateMethods = 0;
if ([_delegate respondsToSelector:@selector(animationShouldStart:)])
_implementedDelegateMethods |= CPAnimationDelegate_animationShouldStart_;
if ([_delegate respondsToSelector:@selector(animationDidEnd:)])
_implementedDelegateMethods |= CPAnimationDelegate_animationDidEnd_;
if ([_delegate respondsToSelector:@selector(animationDidStop:)])
_implementedDelegateMethods |= CPAnimationDelegate_animationDidStop_;
if ([_delegate respondsToSelector:@selector(animation:valueForProgress:)])
_implementedDelegateMethods |= CPAnimationDelegate_animation_valueForProgress_;
}
/*!
@@ -227,7 +245,7 @@ ACTUAL_FRAME_RATE = 0;
- (void)startAnimation
{
// If we're already animating, or our delegate stops us, animate.
if (_timer || _delegate && [_delegate respondsToSelector:@selector(animationShouldStart:)] && ![_delegate animationShouldStart:self])
if (_timer || ![self _sendDelegateAnimationShouldStart])
return;
if (_progress === 1.0)
@@ -236,7 +254,9 @@ ACTUAL_FRAME_RATE = 0;
ACTUAL_FRAME_RATE = 0;
_lastTime = new Date();
_timer = [CPTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(animationTimerDidFire:) userInfo:nil repeats:YES];
var timerInterval = _frameRate <= 0.0 ? 0.0001 : 1.0 / _frameRate;
_timer = [CPTimer scheduledTimerWithTimeInterval:timerInterval target:self selector:@selector(animationTimerDidFire:) userInfo:nil repeats:YES];
}
/*
@@ -258,8 +278,7 @@ ACTUAL_FRAME_RATE = 0;
[_timer invalidate];
_timer = nil;
if ([_delegate respondsToSelector:@selector(animationDidEnd:)])
[_delegate animationDidEnd:self];
[self _sendDelegateAnimationDidEnd];
}
}
@@ -274,8 +293,7 @@ ACTUAL_FRAME_RATE = 0;
[_timer invalidate];
_timer = nil;
if ([_delegate respondsToSelector:@selector(animationDidStop:)])
[_delegate animationDidStop:self];
[self _sendDelegateAnimationDidStop];
}
/*!
@@ -311,8 +329,8 @@ ACTUAL_FRAME_RATE = 0;
{
var t = [self currentProgress];
if ([_delegate respondsToSelector:@selector(animation:valueForProgress:)])
return [_delegate animation:self valueForProgress:t];
if ([self _delegateRespondsToAnimationValueForProgress])
return [self _sendDelegateAnimationValueForProgress:t];
if (_animationCurve == CPAnimationLinear)
return t;
@@ -328,6 +346,68 @@ ACTUAL_FRAME_RATE = 0;
@end
@implementation CPAnimation (CPAnimationDelegate)
/*!
@ignore
Check if the delegate responds to animation:valueForProgress:
*/
- (BOOL)_delegateRespondsToAnimationValueForProgress
{
return _implementedDelegateMethods & CPAnimationDelegate_animation_valueForProgress_;
}
/*!
@ignore
Call delegate animationShouldStart:
*/
- (BOOL)_sendDelegateAnimationShouldStart
{
if (!(_implementedDelegateMethods & CPAnimationDelegate_animationShouldStart_))
return YES;
return [_delegate animationShouldStart:self];
}
/*!
@ignore
Call delegate animation:valueForProgress:
*/
- (float)_sendDelegateAnimationValueForProgress:(float)aProgress
{
if (!(_implementedDelegateMethods & CPAnimationDelegate_animation_valueForProgress_))
return aProgress;
return [_delegate animation:self valueForProgress:aProgress];
}
/*!
@ignore
Call delegate animationDidEnd:
*/
- (void)_sendDelegateAnimationDidEnd
{
if (!(_implementedDelegateMethods & CPAnimationDelegate_animationDidEnd_))
return;
[_delegate animationDidEnd:self];
}
/*!
@ignore
Call delegate animationDidStop:
*/
- (void)_sendDelegateAnimationDidStop
{
if (!(_implementedDelegateMethods & CPAnimationDelegate_animationDidStop_))
return;
[_delegate animationDidStop:self];
}
@end
// currently used function to determine time
// 1:1 conversion to js from webkit source files
// UnitBezier.h, WebCore_animation_AnimationBase.cpp
+162
View File
@@ -0,0 +1,162 @@
/*
* CPAppearance.j
* AppKit
*
* Created by Antoine Mercadal.
* Copyright 2015, Cappuccino Project.
*
* 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 "CPTheme.j"
CPAppearanceNameAqua = @"CPAppearanceNameAqua";
CPAppearanceNameLightContent = @"CPAppearanceNameLightContent";
CPAppearanceNameVibrantDark = @"CPAppearanceNameVibrantDark";
CPAppearanceNameVibrantLight = @"CPAppearanceNameVibrantLight";
var _CPAppearanceCurrent = nil,
_CPAppearancesRegistry = @{};
@protocol CPAppearanceCustomization <CPObject>
@required
- (CPAppearance)appearance;
- (void)setAppearance:(CPAppearance)appearance;
- (CPAppearance)effectiveAppearance;
- (void)setEffectiveAppearance:(CPAppearance)appearance;
@end
CPThemeStateAppearanceAqua = CPThemeState("appearance-aqua");
CPThemeStateAppearanceLightContent = CPThemeState("appearance-light-content");
CPThemeStateAppearanceVibrantLight = CPThemeState("appearance-vibrant-light");
CPThemeStateAppearanceVibrantDark = CPThemeState("appearance-vibrant-dark");
/*!
@ingroup appkit
A CPAppareance represents the appearance of an to a subset of UI elements.
This is a very lightweight implementation of the NSAppearance system, but
We are using it for compliance, and especially for the CPVisualEffectView
*/
@implementation CPAppearance : CPObject
{
BOOL _allowsVibrancy @accessors(property=allowsVibrancy);
CPString _name;
}
#pragma mark -
#pragma mark Class Methods
/*! Returns the current default CPAppearance
*/
+ (CPAppearance)currentAppearance
{
if (!_CPAppearanceCurrent)
_CPAppearanceCurrent = [CPAppearance appearanceNamed:CPAppearanceNameAqua];
return _CPAppearanceCurrent;
}
/*! Sets the current default CPAppearance
@param appearance the new current appearance
*/
+ (void)setCurrentAppearance:(CPAppearance)anAppearance
{
_CPAppearanceCurrent = anAppearance;
}
/*! Returns the CPAppearance object with the given name
@param name the name of the appearance
*/
+ (CPAppearance)appearanceNamed:(CPString)aName
{
if (![_CPAppearancesRegistry containsKey:aName])
{
[_CPAppearancesRegistry setObject:[[CPAppearance alloc] initWithAppearanceNamed:aName bundle:nil]
forKey:aName];
}
return [_CPAppearancesRegistry objectForKey:aName];
}
#pragma mark -
#pragma mark Initialization
/*! Creates a CPAppearance object initialized to the specified appearance file in the specified bundle
This method does actually nothing special. It just creates a default appearance object
*/
- (id)initWithAppearanceNamed:(CPString)aName bundle:(CPBundle)bundle
{
if (self = [super init])
{
_name = aName;
_allowsVibrancy = YES;
if ([_CPAppearancesRegistry containsKey:aName])
[CPException raise:CPInternalInconsistencyException reason:"Appearance with name '" + aName + "' is already declared."];
[_CPAppearancesRegistry setObject:self forKey:aName];
}
return self;
}
#pragma mark -
#pragma mark Implementation
- (BOOL)isEqual:(id)anObject
{
if (![anObject isKindOfClass:CPAppearance])
return NO;
return self._name == anObject._name;
}
- (CPString)description
{
return @"<CPAppearance @" + [self UID] + @" name: " + _name + ">";
}
#pragma mark -
#pragma mark CPCoding
- (id)initWithCoder:(CPCoder)aCoder
{
if (self = [super init])
{
_name = [aCoder decodeObjectForKey:@"_name"];
_allowsVibrancy = [aCoder decodeBoolForKey:@"_allowsVibrancy"];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_name forKey:@"_name"];
[aCoder encodeBool:_allowsVibrancy forKey:@"_allowsVibrancy"];
}
@end
+103 -82
View File
@@ -22,6 +22,7 @@
@import <Foundation/CPBundle.j>
@import "CPApplication_Constants.j"
@import "CPCompatibility.j"
@import "CPColorPanel.j"
@import "CPCursor.j"
@@ -36,27 +37,31 @@
@import "CPWindowController.j"
@import "_CPPopoverWindow.j"
@typedef CPModalSession
var CPMainCibFile = @"CPMainCibFile",
CPMainCibFileHumanFriendly = @"Main cib file base name",
CPEventModifierFlags = 0;
CPApp = nil;
CPApplicationWillFinishLaunchingNotification = @"CPApplicationWillFinishLaunchingNotification";
CPApplicationDidFinishLaunchingNotification = @"CPApplicationDidFinishLaunchingNotification";
CPApplicationWillTerminateNotification = @"CPApplicationWillTerminateNotification";
CPApplicationWillBecomeActiveNotification = @"CPApplicationWillBecomeActiveNotification";
CPApplicationDidBecomeActiveNotification = @"CPApplicationDidBecomeActiveNotification";
CPApplicationWillResignActiveNotification = @"CPApplicationWillResignActiveNotification";
CPApplicationDidResignActiveNotification = @"CPApplicationDidResignActiveNotification";
@protocol CPApplicationDelegate <CPObject>
CPTerminateNow = YES;
CPTerminateCancel = NO;
CPTerminateLater = -1; // not currently supported
@optional
- (CPApplicationTerminateReply)applicationShouldTerminate:(CPApplication)sender;
- (CPString)applicationShouldTerminateMessage:(CPApplication)sender;
- (void)applicationDidBecomeActive:(CPNotification)aNotification;
- (void)applicationDidChangeScreenParameters:(CPNotification)aNotification;
- (void)applicationDidFinishLaunching:(CPNotification)aNotification;
- (void)applicationDidResignActive:(CPNotification)aNotification;
- (void)applicationWillBecomeActive:(CPNotification)aNotification;
- (void)applicationWillFinishLaunching:(CPNotification)aNotification;
- (void)applicationWillResignActive:(CPNotification)aNotification;
- (void)applicationWillTerminate:(CPNotification)aNotification;
CPRunStoppedResponse = -1000;
CPRunAbortedResponse = -1001;
CPRunContinuesResponse = -1002;
@end
var CPApplicationDelegate_applicationShouldTerminate_ = 1 << 0,
CPApplicationDelegate_applicationShouldTerminateMessage_ = 1 << 1;
/*!
@ingroup appkit
@@ -85,36 +90,38 @@ CPRunContinuesResponse = -1002;
*/
@implementation CPApplication : CPResponder
{
CPArray _eventListeners;
int _eventListenerInsertionIndex;
CPArray _eventListeners;
int _eventListenerInsertionIndex;
CPEvent _currentEvent;
CPWindow _lastMouseMoveWindow;
CPEvent _currentEvent;
CPWindow _lastMouseMoveWindow;
CPArray _windows;
CPWindow _keyWindow;
CPWindow _mainWindow;
CPWindow _previousKeyWindow;
CPWindow _previousMainWindow;
CPArray _windows;
CPWindow _keyWindow;
CPWindow _mainWindow;
CPWindow _previousKeyWindow;
CPWindow _previousMainWindow;
CPDocumentController _documentController;
CPDocumentController _documentController;
CPModalSession _currentSession;
CPModalSession _currentSession;
//
id _delegate;
BOOL _finishedLaunching;
BOOL _isActive;
id <CPApplicationDelegate> _delegate;
CPInteger _implementedDelegateMethods;
CPDictionary _namedArgs;
CPArray _args;
CPString _fullArgsString;
BOOL _finishedLaunching;
BOOL _isActive;
CPImage _applicationIconImage;
CPDictionary _namedArgs;
CPArray _args;
CPString _fullArgsString;
CPPanel _aboutPanel;
CPImage _applicationIconImage;
CPThemeBlend _themeBlend @accessors(property=themeBlend);
CPPanel _aboutPanel;
CPThemeBlend _themeBlend @accessors(property=themeBlend);
}
/*!
@@ -125,7 +132,7 @@ CPRunContinuesResponse = -1002;
+ (CPApplication)sharedApplication
{
if (!CPApp)
CPApp = [[CPApplication alloc] init];
CPApp = [[self alloc] init];
return CPApp;
}
@@ -160,11 +167,13 @@ CPRunContinuesResponse = -1002;
react to these events.
@param aDelegate the delegate object
*/
- (void)setDelegate:(id)aDelegate
- (void)setDelegate:(id <CPApplicationDelegate>)aDelegate
{
if (_delegate == aDelegate)
return;
_implementedDelegateMethods = 0;
var defaultCenter = [CPNotificationCenter defaultCenter],
delegateNotifications =
[
@@ -174,7 +183,8 @@ CPRunContinuesResponse = -1002;
CPApplicationDidBecomeActiveNotification, @selector(applicationDidBecomeActive:),
CPApplicationWillResignActiveNotification, @selector(applicationWillResignActive:),
CPApplicationDidResignActiveNotification, @selector(applicationDidResignActive:),
CPApplicationWillTerminateNotification, @selector(applicationWillTerminate:)
CPApplicationWillTerminateNotification, @selector(applicationWillTerminate:),
CPApplicationDidChangeScreenParametersNotification, @selector(applicationDidChangeScreenParameters:)
],
count = [delegateNotifications count];
@@ -204,6 +214,12 @@ CPRunContinuesResponse = -1002;
if ([_delegate respondsToSelector:selector])
[defaultCenter addObserver:_delegate selector:selector name:notificationName object:self];
}
if ([_delegate respondsToSelector:@selector(applicationShouldTerminate:)])
_implementedDelegateMethods |= CPApplicationDelegate_applicationShouldTerminate_;
if ([_delegate respondsToSelector:@selector(applicationShouldTerminateMessage:)])
_implementedDelegateMethods |= CPApplicationDelegate_applicationShouldTerminateMessage_
}
/*!
@@ -425,12 +441,7 @@ CPRunContinuesResponse = -1002;
{
// callback method for terminate:
if (didCloseAll)
{
if ([_delegate respondsToSelector:@selector(applicationShouldTerminate:)])
[self replyToApplicationShouldTerminate:[_delegate applicationShouldTerminate:self]];
else
[self replyToApplicationShouldTerminate:YES];
}
[self replyToApplicationShouldTerminate:[self _sendDelegateApplicationShouldTerminate]];
}
- (void)replyToApplicationShouldTerminate:(BOOL)terminate
@@ -444,16 +455,22 @@ CPRunContinuesResponse = -1002;
- (void)activateIgnoringOtherApps:(BOOL)shouldIgnoreOtherApps
{
if (_isActive)
return;
[self _willBecomeActive];
[CPPlatform activateIgnoringOtherApps:shouldIgnoreOtherApps];
_isActive = YES;
[self _willResignActive];
[self _didBecomeActive];
}
- (void)deactivate
{
if (!_isActive)
return;
[self _willResignActive];
[CPPlatform deactivate];
@@ -462,7 +479,7 @@ CPRunContinuesResponse = -1002;
[self _didResignActive];
}
- (void)isActive
- (BOOL)isActive
{
return _isActive;
}
@@ -479,6 +496,15 @@ CPRunContinuesResponse = -1002;
- (void)run
{
[self finishLaunching];
[self sendEvent:[CPEvent otherEventWithType:CPAppKitDefined
location:CGPointMakeZero()
modifierFlags:0
timestamp:[CPEvent currentTimestamp]
windowNumber:[_keyWindow windowNumber]
context:nil
subtype:nil
data1:nil
data2:nil]];
}
// Managing the Event Loop
@@ -587,8 +613,8 @@ CPRunContinuesResponse = -1002;
/* @ignore */
- (BOOL)_handleKeyEquivalent:(CPEvent)anEvent
{
return [[self keyWindow] performKeyEquivalent:anEvent] ||
[[self mainMenu] performKeyEquivalent:anEvent];
return [[self keyWindow] performKeyEquivalent:anEvent] ||
[[self mainMenu] performKeyEquivalent:anEvent];
}
/*!
@@ -602,34 +628,6 @@ CPRunContinuesResponse = -1002;
var theWindow = [anEvent window];
#if PLATFORM(DOM)
var willPropagate = [[theWindow platformWindow] _willPropagateCurrentDOMEvent];
// temporarily pretend we won't propagate the event. we'll restore the saved value later
// we do this outside the if so that changes user code might make in _handleKeyEquiv. are preserved
[[theWindow platformWindow] _propagateCurrentDOMEvent:NO];
#endif
// Check if this is a candidate for key equivalent...
if ([anEvent _couldBeKeyEquivalent] && [self _handleKeyEquivalent:anEvent])
{
#if PLATFORM(DOM)
var characters = [anEvent characters],
modifierFlags = [anEvent modifierFlags];
// Unconditionally propagate on these keys to solve browser copy paste bugs
if ((characters == "c" || characters == "x" || characters == "v") && (modifierFlags & CPPlatformActionKeyMask))
[[theWindow platformWindow] _propagateCurrentDOMEvent:YES];
#endif
return;
}
#if PLATFORM(DOM)
// if we make it this far, then restore the original willPropagate value
[[theWindow platformWindow] _propagateCurrentDOMEvent:willPropagate];
#endif
if ([anEvent type] == CPMouseMoved)
{
if (theWindow !== _lastMouseMoveWindow)
@@ -666,6 +664,11 @@ CPRunContinuesResponse = -1002;
_eventListenerInsertionIndex = _eventListeners.length;
// Check if this is a candidate for key equivalent...
if ([anEvent _couldBeKeyEquivalent] && [self _handleKeyEquivalent:anEvent])
// The key equivalent was handled.
return;
if (theWindow)
[theWindow sendEvent:anEvent];
}
@@ -981,7 +984,7 @@ CPRunContinuesResponse = -1002;
*/
- (void)setTarget:(id)aTarget selector:(SEL)aSelector forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue
{
_eventListeners.splice(_eventListenerInsertionIndex++, 0, _CPEventListenerMake(aMask, function (anEvent) { objj_msgSend(aTarget, aSelector, anEvent); }, shouldDequeue));
_eventListeners.splice(_eventListenerInsertionIndex++, 0, _CPEventListenerMake(aMask, function (anEvent) { if (aTarget != null) aTarget.isa.objj_msgSend1(aTarget, aSelector, anEvent); }, shouldDequeue));
}
/*!
@@ -1010,7 +1013,9 @@ CPRunContinuesResponse = -1002;
return;
}
[aSheet._windowView _enableSheet:YES inWindow:aWindow];
if (![aWindow attachedSheet])
[aSheet._windowView _enableSheet:YES inWindow:aWindow];
[aWindow _attachSheet:aSheet modalDelegate:aModalDelegate didEndSelector:didEndSelector contextInfo:contextInfo];
}
@@ -1197,7 +1202,7 @@ CPRunContinuesResponse = -1002;
[[self keyWindow] orderFront:self];
else if ([self mainWindow])
[[self mainWindow] makeKeyAndOrderFront:self];
else
else if ([self mainMenu])
[[self mainMenu]._menuWindow makeKeyWindow]; //FIXME this may not actually work
_previousKeyWindow = nil;
@@ -1215,6 +1220,22 @@ CPRunContinuesResponse = -1002;
userInfo:nil];
}
- (BOOL)_sendDelegateApplicationShouldTerminate
{
if (!(_implementedDelegateMethods & CPApplicationDelegate_applicationShouldTerminate_))
return YES;
return [_delegate applicationShouldTerminate:self];
}
- (CPString)_sendDelegateApplicationShouldTerminateMessage
{
if (!(_implementedDelegateMethods & CPApplicationDelegate_applicationShouldTerminateMessage_))
return @"You have attempted to leave this page. Are you sure you want to exit this page?";
return [_delegate applicationShouldTerminateMessage:self];
}
- (void)_didResignActive
{
if (self._activeMenu)
@@ -1337,7 +1358,7 @@ var _CPAppBootstrapperActions = nil;
{
var action = _CPAppBootstrapperActions.shift();
if (objj_msgSend(self, action))
if (self.isa.objj_msgSend0(self, action))
return;
}
@@ -1381,8 +1402,8 @@ var _CPAppBootstrapperActions = nil;
if (mainCibFile)
{
[mainBundle loadCibFile:mainCibFile
externalNameTable:@{ CPCibOwner: CPApp }
loadDelegate:self];
externalNameTable:@{ CPCibOwner: CPApp }
loadDelegate:self];
return YES;
}
@@ -1459,7 +1480,7 @@ var _CPAppBootstrapperActions = nil;
+ (void)cibDidFailToLoad:(CPCib)aCib
{
throw new Error("Could not load main cib file (Did you forget to nib2cib it?).");
throw new Error("Could not load main cib file. Did you forget to nib2cib it?");
}
+ (void)reset
+41
View File
@@ -0,0 +1,41 @@
/*
* CPApplication_Constants.j
* AppKit
*
* Created by Aparajita Fishman.
* Copyright 2013 The Cappuccino Project
*
* 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
*/
CPApp = nil;
CPApplicationWillFinishLaunchingNotification = @"CPApplicationWillFinishLaunchingNotification";
CPApplicationDidFinishLaunchingNotification = @"CPApplicationDidFinishLaunchingNotification";
CPApplicationWillTerminateNotification = @"CPApplicationWillTerminateNotification";
CPApplicationWillBecomeActiveNotification = @"CPApplicationWillBecomeActiveNotification";
CPApplicationDidBecomeActiveNotification = @"CPApplicationDidBecomeActiveNotification";
CPApplicationWillResignActiveNotification = @"CPApplicationWillResignActiveNotification";
CPApplicationDidResignActiveNotification = @"CPApplicationDidResignActiveNotification";
CPApplicationDidChangeScreenParametersNotification = @"CPApplicationDidChangeScreenParametersNotification";
@typedef CPApplicationTerminateReply
CPTerminateNow = YES;
CPTerminateCancel = NO;
CPTerminateLater = -1; // not currently supported
CPRunStoppedResponse = -1000;
CPRunAbortedResponse = -1001;
CPRunContinuesResponse = -1002;
+26 -27
View File
@@ -23,7 +23,7 @@
*/
@import <Foundation/CPIndexSet.j>
@import <Foundation/CPPredicate.j>
@import "CPObjectController.j"
@import "CPKeyValueBinding.j"
@@ -219,17 +219,6 @@
_clearsFilterPredicateOnInsertion = aFlag;
}
/*!
Whether the receiver will always return the multiple values marker when multiple
items are selected, even if the items have the same value.
@return BOOL YES if the receiver always uses the multiple values marker
*/
- (BOOL)alwaysUsesMultipleValuesMarker
{
return _alwaysUsesMultipleValuesMarker;
}
/*!
Sets whether the receiver should always return the multiple values marker when multiple
items are selected, even if the items have the same value.
@@ -282,7 +271,7 @@
if (_disableSetContent)
return;
if (value === nil)
if (value == nil)
value = [];
if (![value isKindOfClass:[CPArray class]])
@@ -308,27 +297,18 @@
class.
*/
if (_clearsFilterPredicateOnInsertion)
[self willChangeValueForKey:@"filterPredicate"];
// Don't use [super setContent:] as that would fire the contentObject change.
// We need to be in control of when notifications fire.
// Note that if we have a contentArray binding, setting the content does /not/
// cause a reverse binding set.
_contentObject = value;
if (_clearsFilterPredicateOnInsertion && _filterPredicate != nil)
[self __setFilterPredicate:nil]; // Causes a _rearrangeObjects.
else
[self _rearrangeObjects];
[self _rearrangeObjects];
if ([self preservesSelection])
[self __setSelectedObjects:oldSelectedObjects];
else
[self __setSelectionIndexes:oldSelectionIndexes];
if (_clearsFilterPredicateOnInsertion)
[self didChangeValueForKey:@"filterPredicate"];
}
/*!
@@ -563,7 +543,7 @@
*/
- (BOOL)setSelectionIndexes:(CPIndexSet)indexes
{
[self _selectionWillChange]
[self _selectionWillChange];
var r = [self __setSelectionIndexes:indexes avoidEmpty:NO];
[self _selectionDidChange];
return r;
@@ -629,6 +609,25 @@
return YES;
}
- (void)_selectionWillChange
{
// Push back all data from the dirty editors before it is too late.
var editorsCount = [_editors count];
while (editorsCount--)
{
var allBindings = [CPBinder allBindingsForObject:_editors[editorsCount]],
allKeys = [allBindings allKeys],
keysCount = allKeys.length;
while (keysCount--)
[[allBindings objectForKey:allKeys[keysCount]] reverseSetValueFor:allKeys[keysCount]];
}
[super _selectionWillChange];
}
/*!
Returns an array of the selected objects.
@@ -774,7 +773,7 @@
_filterPredicate = nil;
[self _rearrangeObjects];
}
else if (_filterPredicate === nil || [_filterPredicate evaluateWithObject:object])
else if (_filterPredicate == nil || [_filterPredicate evaluateWithObject:object])
{
// Insert directly into the array.
var pos = [_arrangedObjects insertObject:object inArraySortedByDescriptors:_sortDescriptors];
@@ -787,7 +786,7 @@
[_selectionIndexes shiftIndexesStartingAtIndex:pos by:1];
}
/*
else if (_filterPredicate !== nil)
else if (_filterPredicate != nil)
...
// Implies _filterPredicate && ![_filterPredicate evaluateWithObject:object], so the new object does
// not appear in arrangedObjects and we do not have to update at all.
@@ -887,7 +886,7 @@
_disableSetContent = NO;
if (_filterPredicate === nil || [_filterPredicate evaluateWithObject:object])
if (_filterPredicate == nil || [_filterPredicate evaluateWithObject:object])
{
// selectionIndexes change notification will be fired as a result of the
// content change. Don't fire manually.
+4 -2
View File
@@ -147,6 +147,8 @@ var DefaultLineWidth = 1.0;
{
_path = CGPathCreateMutable();
_lineWidth = [[self class] defaultLineWidth];
_lineDashesPhase = 0;
_lineDashes = [];
}
return self;
@@ -229,7 +231,7 @@ var DefaultLineWidth = 1.0;
/*!
Cocoa compatibility.
*/
- (void)getLineDash:(CPArrayRef)patternRef count:(NSInteger)count phase:(CGFloatRef)phaseRef
- (void)getLineDash:(CPArrayRef)patternRef count:(CPInteger)count phase:(CGFloatRef)phaseRef
{
return [self getLineDash:patternRef phase:phaseRef];
}
@@ -248,7 +250,7 @@ var DefaultLineWidth = 1.0;
/*!
Cocoa compatibility.
*/
- (void)setLineDash:(CPArray)aPattern count:(NSInteger)count phase:(CGFloat)aPhase
- (void)setLineDash:(CPArray)aPattern count:(CPInteger)count phase:(CGFloat)aPhase
{
[self setLineDash:aPattern phase:aPhase];
}
+375 -59
View File
@@ -22,21 +22,25 @@
@import "CPTextField.j"
@import "CPView.j"
@import <Foundation/CPGeometry.j>
// CPBoxType
@typedef CPBoxType
CPBoxPrimary = 0;
CPBoxSecondary = 1;
CPBoxSecondary = 1; // Deprecated
CPBoxSeparator = 2;
CPBoxOldStyle = 3;
CPBoxOldStyle = 3; // Deprecated
CPBoxCustom = 4;
// CPBorderType
@typedef CPBorderType
CPNoBorder = 0;
CPLineBorder = 1;
CPBezelBorder = 2;
CPGrooveBorder = 3;
// CPTitlePosition
@typedef CPTitlePosition
CPNoTitle = 0;
CPAboveTop = 1;
CPAtTop = 2;
@@ -55,12 +59,16 @@ CPBelowBottom = 6;
@implementation CPBox : CPView
{
CPBoxType _boxType;
CPBorderType _borderType;
CPBorderType _borderType; // deprecated
CPView _contentView;
CPView _boxView; // needed for CSS theming, will be transparent for non CSS themes
BOOL _transparent @accessors(getter=isTransparent);
CPString _title @accessors(getter=title);
int _titlePosition @accessors(getter=titlePosition);
CPString _title @accessors(getter=title);
int _titlePosition @accessors(getter=titlePosition);
CPTextField _titleView;
BOOL _cachedAutoresizesSubviews;
}
+ (Class)_binderClassForBinding:(CPString)aBinding
@@ -76,7 +84,7 @@ CPBelowBottom = 6;
return @"box";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"background-color": [CPNull null],
@@ -87,6 +95,14 @@ CPBelowBottom = 6;
@"inner-shadow-size": 6.0,
@"inner-shadow-color": [CPNull null],
@"content-margin": CGSizeMakeZero(),
@"title-font": [CPNull null],
@"title-left-offset": 5.0,
@"title-top-offset": 0.0,
@"title-color": [CPNull null],
@"nib2cib-adjustment-primary-frame": CGRectMake(4, -4, -8, -6),
@"content-adjustment": CGRectMakeZero(),
@"min-y-correction-no-title": 0,
@"min-y-correction-title": 0
};
}
@@ -111,16 +127,26 @@ CPBelowBottom = 6;
if (self)
{
_borderType = CPBezelBorder;
_borderType = CPGrooveBorder; // Was CPBezelBorder but Cocoa default is CPGrooveBorder
_boxType = CPBoxPrimary;
_titlePosition = CPNoTitle;
_titleView = [CPTextField labelWithTitle:@""];
[_titleView setFont:[self titleFont]];
[_titleView setTextColor:[self titleColor]];
_boxView = [[CPView alloc] initWithFrame:[self bounds]];
[_boxView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
_contentView = [[CPView alloc] initWithFrame:[self bounds]];
[_contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[self setAutoresizesSubviews:YES];
[self addSubview:_contentView];
[self addSubview:_boxView];
[_boxView setAutoresizesSubviews:YES];
[_boxView addSubview:_contentView];
[self sizeToFit];
}
return self;
@@ -152,6 +178,8 @@ CPBelowBottom = 6;
*/
- (CPBorderType)borderType
{
CPLog.warn("CPBox borderType is deprecated.");
return _borderType;
}
@@ -174,7 +202,8 @@ CPBelowBottom = 6;
return;
_borderType = aBorderType;
[self setNeedsDisplay:YES];
[self refreshDisplay];
}
/*!
@@ -214,13 +243,46 @@ CPBelowBottom = 6;
*/
- (void)setBoxType:(CPBoxType)aBoxType
{
if ((aBoxType == CPBoxSecondary) || (aBoxType == CPBoxOldStyle))
CPLog.warn("CPBox setBoxType: CPBoxSecondary and CPBoxOldStyle are deprecated.");
if (_boxType === aBoxType)
return;
_boxType = aBoxType;
[self setNeedsDisplay:YES];
[self refreshDisplay];
}
- (void)setTransparent:(BOOL)shouldBeTransparent
{
if (_transparent == shouldBeTransparent)
return;
_transparent = shouldBeTransparent;
[self _manageTitlePositioning];
}
#pragma mark -
#pragma mark Style properties which override theme values
/*!
The borderColor, borderWidth, cornerRadius and fillColor properties for the receiver
are only supported for boxes with boxType === CPBoxCustom and borderType === CPLineBorder.
Boxes with the Primary boxType have fixed values which are defined by the system theme.
Apple does support lineTypes of Groove and Bezel for boxes of type CPBoxCustom, CPBoxSecondary and CPBoxOldStyle,
but they are deprecated as of macOS 10.15.
Cappuccino has supported these in the past but no longer does so - both to simplify CSS-based theming and
to avoid the effort needed for supporting something which will be very short-lived.
These styles can be recreated as custom theme elements by developers, as needed.
Additionally, boxes with boxType === CPBoxSeparator (horizontal and vertical lines) have never allowed changing these values.
No warnings are generated for separator boxes.
*/
// See discussion above.
#pragma mark borderColor
- (CPColor)borderColor
{
return [self valueForThemeAttribute:@"border-color"];
@@ -228,12 +290,25 @@ CPBelowBottom = 6;
- (void)setBorderColor:(CPColor)color
{
if (_boxType === CPBoxSeparator)
{
return;
}
if ((_boxType !== CPBoxCustom) || (_borderType !== CPLineBorder))
{
CPLog.warn("CPBox setBorderColor: the box must be of type CPBoxCustom AND border of type CPLineBorder in order to use setBorderColor. Property is ignored.");
return;
}
if ([color isEqual:[self borderColor]])
return;
[self setValue:color forThemeAttribute:@"border-color"];
}
// See discussion above.
#pragma mark borderWidth
- (float)borderWidth
{
return [self valueForThemeAttribute:@"border-width"];
@@ -241,12 +316,25 @@ CPBelowBottom = 6;
- (void)setBorderWidth:(float)width
{
if (_boxType === CPBoxSeparator)
{
return;
}
if ((_boxType !== CPBoxCustom) || (_borderType !== CPLineBorder))
{
CPLog.warn("CPBox setBorderWidth: the box must be of type CPBoxCustom AND border of type CPLineBorder in order to use setBorderWidth. Property is ignored.");
return;
}
if (width === [self borderWidth])
return;
[self setValue:width forThemeAttribute:@"border-width"];
}
// See discussion above.
#pragma mark cornerRadius
- (float)cornerRadius
{
return [self valueForThemeAttribute:@"corner-radius"];
@@ -254,12 +342,25 @@ CPBelowBottom = 6;
- (void)setCornerRadius:(float)radius
{
if (_boxType === CPBoxSeparator)
{
return;
}
if ((_boxType !== CPBoxCustom) || (_borderType !== CPLineBorder))
{
CPLog.warn("CPBox setCornerRadius: the box must be of type CPBoxCustom AND border of type CPLineBorder in order to use setCornerRadius. Property is ignored.");
return;
}
if (radius === [self cornerRadius])
return;
[self setValue:radius forThemeAttribute:@"corner-radius"];
}
// See discussion above.
#pragma mark fillColor
- (CPColor)fillColor
{
return [self valueForThemeAttribute:@"background-color"];
@@ -267,6 +368,17 @@ CPBelowBottom = 6;
- (void)setFillColor:(CPColor)color
{
if (_boxType === CPBoxSeparator)
{
return;
}
if ((_boxType !== CPBoxCustom) || (_borderType !== CPLineBorder))
{
CPLog.warn("CPBox setFillColor: the box must be of type CPBoxCustom AND border of type CPLineBorder in order to use setFillColor. Property is ignored.");
return;
}
if ([color isEqual:[self fillColor]])
return;
@@ -283,21 +395,20 @@ CPBelowBottom = 6;
if (aView === _contentView)
return;
var borderWidth = [self borderWidth],
contentMargin = [self valueForThemeAttribute:@"content-margin"];
[aView setFrame:CGRectInset([self bounds], contentMargin.width + borderWidth, contentMargin.height + borderWidth)];
[aView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
// A nil contentView is allowed (tested in Cocoa 2013-02-22).
if (!aView)
[_contentView removeFromSuperview];
else if (_contentView)
[self replaceSubview:_contentView with:aView];
[_boxView replaceSubview:_contentView with:aView];
else
[self addSubview:aView];
[_boxView addSubview:aView];
_contentView = aView;
[self sizeToFit];
[self refreshDisplay];
}
- (CGSize)contentViewMargins
@@ -317,9 +428,14 @@ CPBelowBottom = 6;
{
var offset = [self _titleHeightOffset],
borderWidth = [self borderWidth],
contentMargin = [self valueForThemeAttribute:@"content-margin"];
contentMargin = [self valueForThemeAttribute:@"content-margin"],
contentAdjustment = [self valueForThemeAttribute:@"content-adjustment"],
minYCorrection = [self valueForThemeAttribute:(_titlePosition === CPNoTitle ? @"min-y-correction-no-title" : @"min-y-correction-title")];
[self setFrame:CGRectInset(aRect, -(contentMargin.width + borderWidth), -(contentMargin.height + offset[0] + borderWidth))];
[self setFrame:CGRectMake(aRect.origin.x - contentAdjustment.origin.x - contentMargin.width + borderWidth,
aRect.origin.y - contentAdjustment.origin.y - contentMargin.height + borderWidth - minYCorrection,
aRect.size.width + 2 * contentMargin.width - contentAdjustment.size.width,
aRect.size.height + 2 * contentMargin.height - contentAdjustment.size.height)];
}
- (void)setTitle:(CPString)aTitle
@@ -344,14 +460,42 @@ CPBelowBottom = 6;
- (CPFont)titleFont
{
return [_titleView font];
if ([self hasThemeAttribute:@"title-font"])
return [self valueForThemeAttribute:@"title-font"];
else
return [_titleView font];
}
- (void)setTitleFont:(CPFont)aFont
{
if ([aFont isEqual:[self titleFont]])
return;
if ([self hasThemeAttribute:@"title-font"])
[self setValue:aFont forThemeAttribute:@"title-font"];
[_titleView setFont:aFont];
}
- (CPColor)titleColor
{
if ([self hasThemeAttribute:@"title-color"])
return [self valueForThemeAttribute:@"title-color"];
else
return [_titleView textColor];
}
- (void)setTitleColor:(CPColor)aColor
{
if ([aColor isEqual:[self titleColor]])
return;
if ([self hasThemeAttribute:@"title-color"])
[self setValue:aColor forThemeAttribute:@"title-color"];
[_titleView setTextColor:aColor];
}
/*!
Return the text field used to display the receiver's title.
@@ -362,25 +506,39 @@ CPBelowBottom = 6;
return _titleView;
}
/*!
Return the rectangle in which the receivers title is drawn.
*/
- (CGRect)titleRect
{
return [_titleView frame];
}
- (void)_manageTitlePositioning
{
if (_titlePosition == CPNoTitle)
if ((_titlePosition == CPNoTitle) || _transparent)
{
[_titleView removeFromSuperview];
[self setNeedsDisplay:YES];
if (_boxType !== CPBoxSeparator)
[self sizeToFit];
[self refreshDisplay];
return;
}
[_titleView setStringValue:_title];
[_titleView sizeToFit];
[self addSubview:_titleView];
var titleLeftOffset = [self valueForThemeAttribute:@"title-left-offset"],
titleTopOffset = [self valueForThemeAttribute:@"title-top-offset"];
switch (_titlePosition)
{
case CPAtTop:
case CPAboveTop:
case CPBelowTop:
[_titleView setFrameOrigin:CGPointMake(5.0, 0.0)];
[_titleView setFrameOrigin:CGPointMake(titleLeftOffset, titleTopOffset)]; // FIXME: was 0.0
[_titleView setAutoresizingMask:CPViewNotSizable];
break;
@@ -388,39 +546,51 @@ CPBelowBottom = 6;
case CPAtBottom:
case CPBelowBottom:
var h = [_titleView frameSize].height;
[_titleView setFrameOrigin:CGPointMake(5.0, [self frameSize].height - h)];
[_titleView setFrameOrigin:CGPointMake(titleLeftOffset, [self frameSize].height - h - titleTopOffset)];
[_titleView setAutoresizingMask:CPViewMinYMargin];
break;
}
if (!_transparent)
[self addSubview:_titleView];
[self sizeToFit];
[self setNeedsDisplay:YES];
[self refreshDisplay];
}
- (void)sizeToFit
{
var contentFrame = [_contentView frame],
offset = [self _titleHeightOffset],
contentMargin = [self valueForThemeAttribute:@"content-margin"];
var offset = [self _titleHeightOffset],
size = [self frameSize];
if (!contentFrame)
[_boxView setFrame:CGRectMake(0, offset[1], size.width, size.height - offset[0])];
if (!_contentView)
return;
[_contentView setFrameOrigin:CGPointMake(contentMargin.width, contentMargin.height + offset[1])];
var boxSize = [_boxView frameSize],
contentMargin = [self valueForThemeAttribute:@"content-margin"],
contentAdjustment = [self valueForThemeAttribute:@"content-adjustment"],
borderWidth = [self valueForThemeAttribute:@"border-width"],
minYCorrection = [self valueForThemeAttribute:(_titlePosition === CPNoTitle ? @"min-y-correction-no-title" : @"min-y-correction-title")];
[_contentView setFrame:CGRectMake(contentAdjustment.origin.x + contentMargin.width - borderWidth,
contentAdjustment.origin.y + contentMargin.height - borderWidth + minYCorrection,
boxSize.width - 2 * contentMargin.width + contentAdjustment.size.width,
boxSize.height - 2 * contentMargin.height + contentAdjustment.size.height)];
}
- (float)_titleHeightOffset
- (CPArray)_titleHeightOffset
{
if (_titlePosition == CPNoTitle)
return [0.0, 0.0];
var titleTopOffset = [self valueForThemeAttribute:@"title-top-offset"];
switch (_titlePosition)
{
case CPAtTop:
return [[_titleView frameSize].height, [_titleView frameSize].height];
return [[_titleView frameSize].height + titleTopOffset, [_titleView frameSize].height + titleTopOffset];
case CPAtBottom:
return [[_titleView frameSize].height, 0.0];
return [[_titleView frameSize].height + titleTopOffset, 0.0];
default:
return [0.0, 0.0];
@@ -437,21 +607,24 @@ CPBelowBottom = 6;
- (void)drawRect:(CGRect)rect
{
if ([self isCSSBased] && (_boxType !== CPBoxCustom))
return;
var bounds = [self bounds];
switch (_boxType)
if (_boxType === CPBoxSeparator)
{
case CPBoxSeparator:
// NSBox does not include a horizontal flag for the separator type. We have to determine
// the type of separator to draw by the width and height of the frame.
if (CGRectGetWidth(bounds) === 5.0)
return [self _drawVerticalSeparatorInRect:bounds];
else if (CGRectGetHeight(bounds) === 5.0)
return [self _drawHorizontalSeparatorInRect:bounds];
break;
// NSBox does not include a horizontal flag for the separator type. We have to determine
// the type of separator to draw by the width and height of the frame.
if (CGRectGetWidth(bounds) === 5.0)
return [self _drawVerticalSeparatorInRect:bounds];
else if (CGRectGetHeight(bounds) === 5.0)
return [self _drawHorizontalSeparatorInRect:bounds];
}
if (_transparent)
return;
if (_titlePosition == CPAtTop)
{
bounds.origin.y += [_titleView frameSize].height;
@@ -472,9 +645,6 @@ CPBelowBottom = 6;
switch (_borderType)
{
case CPBezelBorder:
[self _drawBezelBorderInRect:bounds];
break;
case CPGrooveBorder:
case CPLineBorder:
[self _drawLineBorderInRect:bounds];
@@ -591,11 +761,83 @@ CPBelowBottom = 6;
@end
#pragma mark -
@implementation CPBox (CSSTheming)
- (void)layoutSubviews
{
if (![self isCSSBased] || (_boxType === CPBoxCustom))
return;
var bounds = [self bounds];
if (_boxType === CPBoxSeparator)
{
if (bounds.size.width === 5.0)
{
// Vertical separator
[_boxView setFrame:CGRectMake(2,0,1,bounds.size.height)];
}
else
{
// Horizontal separator
[_boxView setFrame:CGRectMake(0,2,bounds.size.width,1)];
}
[_boxView setBackgroundColor:[self valueForThemeAttribute:@"border-color"]];
return;
}
// All types of boxes (beside custom which is not covered here) always draw the same way, unless they are CPNoBorder.
if ((_borderType !== CPNoBorder) && !_transparent)
{
[_boxView setBackgroundColor:[self valueForThemeAttribute:@"background-color"]];
return;
}
// No border or transparent
[_boxView setBackgroundColor:nil];
}
- (BOOL)isCSSBased
{
return [[self theme] isCSSBased];
}
- (void)refreshDisplay
{
if ([self isCSSBased] && (_boxType !== CPBoxCustom))
[self setNeedsLayout:YES];
else
[self setNeedsDisplay:YES];
}
- (void)setAutoresizesSubviews:(BOOL)flag
{
// CPBox should always resize its subviews, like in Cocoa, whatever is the corresponding flag set.
// We have to keep the flag value as we could have to return it in -autoresizesSubview method.
_cachedAutoresizesSubviews = !!flag;
[super setAutoresizesSubviews:YES];
}
- (BOOL)autoresizesSubview
{
return _cachedAutoresizesSubviews;
}
@end
#pragma mark -
var CPBoxTypeKey = @"CPBoxTypeKey",
CPBoxBorderTypeKey = @"CPBoxBorderTypeKey",
CPBoxTitle = @"CPBoxTitle",
CPBoxTitlePosition = @"CPBoxTitlePosition",
CPBoxTitleView = @"CPBoxTitleView";
CPBoxTitleKey = @"CPBoxTitleKey",
CPBoxTitlePositionKey = @"CPBoxTitlePositionKey",
CPBoxTitleViewKey = @"CPBoxTitleViewKey",
CPBoxContentViewKey = @"CPBoxContentViewKey",
CPBoxBoxViewKey = @"CPBoxBoxViewKey";
@implementation CPBox (CPCoding)
@@ -608,16 +850,56 @@ var CPBoxTypeKey = @"CPBoxTypeKey",
_boxType = [aCoder decodeIntForKey:CPBoxTypeKey];
_borderType = [aCoder decodeIntForKey:CPBoxBorderTypeKey];
_title = [aCoder decodeObjectForKey:CPBoxTitle];
_titlePosition = [aCoder decodeIntForKey:CPBoxTitlePosition];
_titleView = [aCoder decodeObjectForKey:CPBoxTitleView] || [CPTextField labelWithTitle:_title];
_title = [aCoder decodeObjectForKey:CPBoxTitleKey];
_titlePosition = [aCoder decodeIntForKey:CPBoxTitlePositionKey];
_contentView = [self subviews][0];
// Important : see comment on encodeWithCoder below
_boxView = [aCoder decodeObjectForKey:CPBoxBoxViewKey];
if (!_boxView)
{
// We're coming from nib2cib.
_boxView = [[CPView alloc] initWithFrame:[self bounds]];
_titleView = [CPTextField labelWithTitle:_title];
}
else
{
// We're coming from elsewhere
_titleView = [aCoder decodeObjectForKey:CPBoxTitleViewKey];
}
_contentView = [aCoder decodeObjectForKey:CPBoxContentViewKey];
// FIXME: super-mega-hyper-trick : _contentView has a superview which is not normal !
// FIXME: (see encodeWithCoder to understand why this is not possible)
// FIXME: we fix this by hand. This is horrible so please find a structural solution !
if (_contentView)
_contentView._superview = nil;
[self setAutoresizesSubviews:YES];
[_contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[_boxView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[_boxView setAutoresizesSubviews:YES];
[self setAutoresizesSubviews:YES];
if (_contentView)
[_boxView setSubviews:@[_contentView]];
[self addSubview:_boxView];
[self addSubview:_titleView];
if (_boxType === CPBoxSeparator)
_titlePosition = CPNoTitle;
[_titleView setFont:[self titleFont]];
[_titleView setTextColor:[self titleColor]];
[self _manageTitlePositioning];
[self refreshDisplay];
}
return self;
@@ -625,13 +907,47 @@ var CPBoxTypeKey = @"CPBoxTypeKey",
- (void)encodeWithCoder:(CPCoder)aCoder
{
// We have to distinguish between 2 cases :
// - we come from nib2cib
// - we come from elsewhere
//
// When coming from nib2cib, we have no _boxView, _contentView, _titleView.
// We fix _contentView to be the first (and only) subview.
// They will have to be added on decoding.
//
// When coming from elsewhere, we remove _boxView (and thus _contentView) and _titleView
// from the view hierarchy as we'll already encode them via variables.
// They will be putted back during decoding. This way, we reduce the space and speed needed for coding.
var subviews = [self subviews];
if (!_boxView)
{
// We're coming from nib2cib.
_contentView = subviews[0];
[_contentView removeFromSuperview];
}
else
{
// We're coming from elsewhere.
[_boxView removeFromSuperview];
[_titleView removeFromSuperview];
}
[super encodeWithCoder:aCoder];
[self setSubviews:subviews];
[aCoder encodeInt:_boxType forKey:CPBoxTypeKey];
[aCoder encodeInt:_borderType forKey:CPBoxBorderTypeKey];
[aCoder encodeObject:_title forKey:CPBoxTitle];
[aCoder encodeInt:_titlePosition forKey:CPBoxTitlePosition];
[aCoder encodeObject:_titleView forKey:CPBoxTitleView];
[aCoder encodeObject:_title forKey:CPBoxTitleKey];
[aCoder encodeInt:_titlePosition forKey:CPBoxTitlePositionKey];
[aCoder encodeConditionalObject:_contentView forKey:CPBoxContentViewKey];
[aCoder encodeConditionalObject:_titleView forKey:CPBoxTitleViewKey];
[aCoder encodeConditionalObject:_boxView forKey:CPBoxBoxViewKey];
}
@end
+264 -82
View File
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/CPObject.j>
@import <Foundation/CPIndexSet.j>
@import "CPControl.j"
@@ -30,40 +31,84 @@
@global CPApp
@protocol CPBrowserDelegate <CPObject>
@optional
- (BOOL)browser:(CPBrowser)browser acceptDrop:(id)info atRow:(CPInteger)row column:(CPInteger)column dropOperation:(CPTableViewDropOperation)dropOperation;
- (BOOL)browser:(CPBrowser)browser canDragRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)column withEvent:(CPEvent )event;
- (BOOL)browser:(CPBrowser)browser isLeafItem:(id)item;
- (BOOL)browser:(CPBrowser)browser shouldSelectRowIndexes:(CPIndexSet)anIndexSet inColumn:(CPInteger)column;
- (BOOL)browser:(CPBrowser)browser writeRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)column toPasteboard:(CPPasteboard)pasteboard;
- (CPDragOperation)browser:(CPBrowser)browser validateDrop:(id)info proposedRow:(CPInteger)row column:(CPInteger)column dropOperation:(CPTableViewDropOperation)dropOperation;
- (CPImage)browser:(CPBrowser)browser imageValueForItem:(id)anItem;
- (CPImage)browser:(CPBrowser)browser draggingImageForRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)column withEvent:(CPEvent)event offset:(CGPoint)dragImageOffset;
- (CPIndexSet)browser:(CPBrowser)browser selectionIndexesForProposedSelection:(CPIndexSet)proposedSelectionIndexes inColumn:(CPInteger)column;
- (CPInteger)browser:(CPBrowser)browser numberOfChildrenOfItem:(id)item;
- (CPView)browser:(CPBrowser)browser draggingViewForRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)column withEvent:(CPEvent)event offset:(CGPoint)dragImageOffset;
- (id)browser:(CPBrowser)browser child:(CPInteger)index ofItem:(id)item;
- (id)browser:(CPBrowser)browser objectValueForItem:(id)item;
- (id)rootItemForBrowser:(CPBrowser)browser;
- (void)browser:(CPBrowser)browser didChangeLastColumn:(CPInteger)oldLastColumn toColumn:(CPInteger)column;
- (void)browser:(CPBrowser)browser didResizeColumn:(CPInteger)column;
- (void)browserSelectionIsChanging:(CPBrowser)browser;
- (void)browserSelectionDidChange:(CPBrowser)browser;
@end
var CPBrowserDelegate_browser_acceptDrop_atRow_column_dropOperation_ = 1 << 1,
CPBrowserDelegate_browser_canDragRowsWithIndexes_inColumn_withEvent_ = 1 << 2,
CPBrowserDelegate_browser_isLeafItem_ = 1 << 3,
CPBrowserDelegate_browser_shouldSelectRowIndexes_inColumn_ = 1 << 4,
CPBrowserDelegate_browser_writeRowsWithIndexes_inColumn_toPasteboard_ = 1 << 5,
CPBrowserDelegate_browser_validateDrop_proposedRow_column_dropOperation_ = 1 << 6,
CPBrowserDelegate_browser_draggingImageForRowsWithIndexes_inColumn_withEvent_offset_ = 1 << 7,
CPBrowserDelegate_browser_imageValueForItem_ = 1 << 8,
CPBrowserDelegate_browser_selectionIndexesForProposedSelection_inColumn_ = 1 << 9,
CPBrowserDelegate_browser_numberOfChildrenOfItem_ = 1 << 10,
CPBrowserDelegate_browser_draggingViewForRowsWithIndexes_inColumn_withEvent_offset_ = 1 << 11,
CPBrowserDelegate_browser_child_ofItem_ = 1 << 12,
CPBrowserDelegate_browser_objectValueForItem_ = 1 << 13,
CPBrowserDelegate_rootItemForBrowser_ = 1 << 14,
CPBrowserDelegate_browser_didChangeLastColumn_toColumn_ = 1 << 15,
CPBrowserDelegate_browser_didResizeColumn_ = 1 << 16,
CPBrowserDelegate_browserSelectionIsChanging_ = 1 << 17,
CPBrowserDelegate_browserSelectionDidChange_ = 1 << 18;
/*!
@ingroup appkit
@class CPBrowser
*/
@implementation CPBrowser : CPControl
{
id _delegate;
CPString _pathSeparator;
id <CPBrowserDelegate> _delegate;
CPString _pathSeparator;
unsigned _implementedDelegateMethods;
CPView _contentView;
CPScrollView _horizontalScrollView;
CPView _prototypeView;
CPView _contentView;
CPScrollView _horizontalScrollView;
CPView _prototypeView;
CPArray _tableViews;
CPArray _tableDelegates;
CPArray _tableViews;
CPArray _tableDelegates;
id _rootItem;
id _rootItem;
BOOL _delegateSupportsImages;
BOOL _delegateSupportsImages;
SEL _doubleAction @accessors(property=doubleAction);
SEL _doubleAction @accessors(property=doubleAction);
BOOL _allowsMultipleSelection;
BOOL _allowsEmptySelection;
BOOL _allowsMultipleSelection;
BOOL _allowsEmptySelection;
Class _tableViewClass @accessors(property=tableViewClass);
Class _tableViewClass @accessors(property=tableViewClass);
float _rowHeight;
float _imageWidth;
float _leafWidth;
float _minColumnWidth;
float _defaultColumnWidth @accessors(property=defaultColumnWidth);
float _rowHeight;
float _imageWidth;
float _leafWidth;
float _minColumnWidth;
float _defaultColumnWidth @accessors(property=defaultColumnWidth);
CPArray _columnWidths;
CPArray _columnWidths;
}
+ (CPString)defaultThemeClass
@@ -71,7 +116,7 @@
return "browser";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"image-control-resize": [CPNull null],
@@ -137,10 +182,71 @@
[CPKeyedArchiver archivedDataWithRootObject:_prototypeView]];
}
- (void)setDelegate:(id)anObject
- (void)setDelegate:(id <CPBrowserDelegate>)anObject
{
if (_delegate === anObject)
return;
_delegate = anObject;
_delegateSupportsImages = [_delegate respondsToSelector:@selector(browser:imageValueForItem:)];
_implementedDelegateMethods = 0;
_delegateSupportsImages = NO;
if ([_delegate respondsToSelector:@selector(browser:acceptDrop:atRow:column:dropOperation:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_acceptDrop_atRow_column_dropOperation_;
if ([_delegate respondsToSelector:@selector(browser:canDragRowsWithIndexes:inColumn:withEvent:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_canDragRowsWithIndexes_inColumn_withEvent_;
if ([_delegate respondsToSelector:@selector(browser:isLeafItem:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_isLeafItem_;
if ([_delegate respondsToSelector:@selector(browser:shouldSelectRowIndexes:inColumn:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_shouldSelectRowIndexes_inColumn_;
if ([_delegate respondsToSelector:@selector(browser:writeRowsWithIndexes:inColumn:toPasteboard:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_writeRowsWithIndexes_inColumn_toPasteboard_;
if ([_delegate respondsToSelector:@selector(browser:validateDrop:proposedRow:column:dropOperation:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_validateDrop_proposedRow_column_dropOperation_;
if ([_delegate respondsToSelector:@selector(browser:draggingImageForRowsWithIndexes:inColumn:withEvent:offset:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_draggingImageForRowsWithIndexes_inColumn_withEvent_offset_;
if ([_delegate respondsToSelector:@selector(browser:imageValueForItem:)])
{
_delegateSupportsImages = YES;
_implementedDelegateMethods |= CPBrowserDelegate_browser_imageValueForItem_;
}
if ([_delegate respondsToSelector:@selector(browser:selectionIndexesForProposedSelection:inColumn:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_selectionIndexesForProposedSelection_inColumn_;
if ([_delegate respondsToSelector:@selector(browser:numberOfChildrenOfItem:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_numberOfChildrenOfItem_;
if ([_delegate respondsToSelector:@selector(browser:draggingViewForRowsWithIndexes:inColumn:withEvent:offset:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_draggingViewForRowsWithIndexes_inColumn_withEvent_offset_;
if ([_delegate respondsToSelector:@selector(browser:child:ofItem:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_child_ofItem_;
if ([_delegate respondsToSelector:@selector(browser:objectValueForItem:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_objectValueForItem_;
if ([_delegate respondsToSelector:@selector(rootItemForBrowser:)])
_implementedDelegateMethods |= CPBrowserDelegate_rootItemForBrowser_;
if ([_delegate respondsToSelector:@selector(browser:didChangeLastColumn:toColumn:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_didChangeLastColumn_toColumn_;
if ([_delegate respondsToSelector:@selector(browser:didChangeLastColumn:)])
_implementedDelegateMethods |= CPBrowserDelegate_browser_didResizeColumn_;
if ([_delegate respondsToSelector:@selector(browserSelectionIsChanging:)])
_implementedDelegateMethods |= CPBrowserDelegate_browserSelectionIsChanging_;
if ([_delegate respondsToSelector:@selector(browserSelectionDidChange:)])
_implementedDelegateMethods |= CPBrowserDelegate_browserSelectionDidChange_;
[self loadColumnZero];
}
@@ -162,16 +268,13 @@
- (void)loadColumnZero
{
if ([_delegate respondsToSelector:@selector(rootItemForBrowser:)])
_rootItem = [_delegate rootItemForBrowser:self];
else
_rootItem = nil;
_rootItem = [self _sendDelegateRootItemForBrowser];
[self setLastColumn:-1];
[self addColumn];
}
- (void)setLastColumn:(int)columnIndex
- (void)setLastColumn:(CPInteger)columnIndex
{
if (columnIndex >= _tableViews.length)
return;
@@ -181,7 +284,7 @@
if (columnIndex > 0)
[_tableViews[columnIndex - 1] setNeedsDisplay:YES];
[_tableViews[columnIndex] setNeedsDisplay:YES];
[[_tableViews.slice(indexPlusOne) valueForKey:"enclosingScrollView"]
@@ -190,8 +293,7 @@
_tableViews = _tableViews.slice(0, indexPlusOne);
_tableDelegates = _tableDelegates.slice(0, indexPlusOne);
if ([_delegate respondsToSelector:@selector(browser:didChangeLastColumn:toColumn:)])
[_delegate browser:self didChangeLastColumn:oldValue toColumn:columnIndex];
[self _sendDelegateBrowserDidChangeLastColumn:oldValue toColumn:columnIndex];
[self tile];
}
@@ -291,7 +393,7 @@
[aTableView addTableColumn:column];
}
- (void)reloadColumn:(int)column
- (void)reloadColumn:(CPInteger)column
{
[[self tableViewInColumn:column] reloadData];
}
@@ -359,19 +461,19 @@
// ITEMS
- (id)itemAtRow:(int)row inColumn:(int)column
- (id)itemAtRow:(CPInteger)row inColumn:(CPInteger)column
{
return [_tableDelegates[column] childAtIndex:row];
return [_tableDelegates[column] childAtIndex:row] || nil;
}
- (BOOL)isLeafItem:(id)item
{
return [_delegate respondsToSelector:@selector(browser:isLeafItem:)] && [_delegate browser:self isLeafItem:item];
return (_implementedDelegateMethods & CPBrowserDelegate_browser_isLeafItem_) && [_delegate browser:self isLeafItem:item];
}
- (id)parentForItemsInColumn:(int)column
- (id)parentForItemsInColumn:(CPInteger)column
{
return [_tableDelegates[column] _item];
return [_tableDelegates[column] _item] || nil;
}
- (CPSet)selectedItems
@@ -493,9 +595,7 @@
{
_columnWidths[column] = aWidth;
if ([_delegate respondsToSelector:@selector(browser:didResizeColumn:)])
[_delegate browser:self didResizeColumn:column];
[self _sendDelegateBrowserDidResizeColumn:column];
[self tile];
}
@@ -610,15 +710,12 @@
if (column < 0 || column > [self lastColumn] + 1)
return;
if ([_delegate respondsToSelector:@selector(browser:selectionIndexesForProposedSelection:inColumn:)])
indexSet = [_delegate browser:self selectionIndexesForProposedSelection:indexSet inColumn:column];
indexSet = [self _sendDelegateBrowserSelectionIndexesForProposedSelection:indexSet inColumn:column];
if ([_delegate respondsToSelector:@selector(browser:shouldSelectRowIndexes:inColumn:)] &&
![_delegate browser:self shouldSelectRowIndexes:indexSet inColumn:column])
if (![self _sendDelegateBrowserShouldSelectRowIndexes:indexSet inColumn:column])
return;
if ([_delegate respondsToSelector:@selector(browserSelectionIsChanging:)])
[_delegate browserSelectionIsChanging:self];
[self _sendDelegateBrowserSelectionIsChanging];
if (column > [self lastColumn])
[self addColumn];
@@ -629,8 +726,7 @@
[self scrollColumnToVisible:column];
if ([_delegate respondsToSelector:@selector(browserSelectionDidChange:)])
[_delegate browserSelectionDidChange:self];
[self _sendDelegateBrowserSelectionDidChange];
}
- (void)setBackgroundColor:(CPColor)aColor
@@ -652,30 +748,6 @@
[_tableViews makeObjectsPerformSelector:@selector(registerForDraggedTypes:) withObject:types];
}
- (BOOL)canDragRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(int)columnIndex withEvent:(CPEvent)dragEvent
{
if ([_delegate respondsToSelector:@selector(browser:canDragRowsWithIndexes:inColumn:withEvent:)])
return [_delegate browser:self canDragRowsWithIndexes:rowIndexes inColumn:columnIndex withEvent:dragEvent];
return YES;
}
- (CPImage)draggingImageForRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(int)columnIndex withEvent:(CPEvent)dragEvent offset:(CGPoint)dragImageOffset
{
if ([_delegate respondsToSelector:@selector(browser:draggingImageForRowsWithIndexes:inColumn:withEvent:offset:)])
return [_delegate browser:self draggingImageForRowsWithIndexes:rowIndexes inColumn:columnIndex withEvent:dragEvent offset:dragImageOffset];
return nil;
}
- (CPView)draggingViewForRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(int)columnIndex withEvent:(CPEvent)dragEvent offset:(CGPoint)dragImageOffset
{
if ([_delegate respondsToSelector:@selector(browser:draggingViewForRowsWithIndexes:inColumn:withEvent:offset:)])
return [_delegate browser:self draggingViewForRowsWithIndexes:rowIndexes inColumn:columnIndex withEvent:dragEvent offset:dragImageOffset];
return nil;
}
@end
@implementation CPBrowser (CPCoding)
@@ -771,7 +843,7 @@
CPBrowser _browser @accessors;
}
- (void)initWithFrame:(CGRect)aFrame
- (id)initWithFrame:(CGRect)aFrame
{
if (self = [super initWithFrame:aFrame])
{
@@ -860,8 +932,6 @@
@end
@import <Foundation/CPObject.j>
@implementation _CPBrowserTableDelegate : CPObject
{
CPBrowser _browser @accessors;
@@ -902,22 +972,22 @@
[_browser selectRowIndexes:selectedIndexes inColumn:_index];
}
- (id)childAtIndex:(unsigned)index
- (id)childAtIndex:(CPUInteger)index
{
return [_delegate browser:_browser child:index ofItem:_item];
}
- (BOOL)tableView:(CPTableView)aTableView acceptDrop:(id)info row:(int)row dropOperation:(CPTableViewDropOperation)operation
- (BOOL)tableView:(CPTableView)aTableView acceptDrop:(id)info row:(CPInteger)row dropOperation:(CPTableViewDropOperation)operation
{
if ([_delegate respondsToSelector:@selector(browser:acceptDrop:atRow:column:dropOperation:)])
if (_browser._implementedDelegateMethods & CPBrowserDelegate_browser_acceptDrop_atRow_column_dropOperation_)
return [_delegate browser:_browser acceptDrop:info atRow:row column:_index dropOperation:operation];
else
return NO;
}
- (CPDragOperation)tableView:(CPTableView)aTableView validateDrop:(id)info proposedRow:(int)row proposedDropOperation:(CPTableViewDropOperation)operation
- (CPDragOperation)tableView:(CPTableView)aTableView validateDrop:(id)info proposedRow:(CPInteger)row proposedDropOperation:(CPTableViewDropOperation)operation
{
if ([_delegate respondsToSelector:@selector(browser:validateDrop:proposedRow:column:dropOperation:)])
if (_browser._implementedDelegateMethods & CPBrowserDelegate_browser_validateDrop_proposedRow_column_dropOperation_)
return [_delegate browser:_browser validateDrop:info proposedRow:row column:_index dropOperation:operation];
else
return CPDragOperationNone;
@@ -925,7 +995,7 @@
- (BOOL)tableView:(CPTableView)aTableView writeRowsWithIndexes:(CPIndexSet)rowIndexes toPasteboard:(CPPasteboard)pboard
{
if ([_delegate respondsToSelector:@selector(browser:writeRowsWithIndexes:inColumn:toPasteboard:)])
if (_browser._implementedDelegateMethods & CPBrowserDelegate_browser_writeRowsWithIndexes_inColumn_toPasteboard_)
return [_delegate browser:_browser writeRowsWithIndexes:rowIndexes inColumn:_index toPasteboard:pboard];
else
return NO;
@@ -980,7 +1050,7 @@
var imageView = [self layoutEphemeralSubviewNamed:@"image-view"
positioned:CPWindowAbove
relativeToEphemeralSubviewNamed:nil],
isHighlighted = [self themeState] & CPThemeStateSelectedDataView;
isHighlighted = [self hasThemeState:CPThemeStateSelectedDataView];
[imageView setImage: _isLeaf ? (isHighlighted ? _highlightedBranchImage : _branchImage) : nil];
[imageView setImageScaling:CPImageScaleNone];
@@ -995,7 +1065,7 @@
[aCoder encodeObject:_highlightedBranchImage forKey:"_CPBrowserLeafViewHighlightedBranchImageKey"];
}
- (void)initWithCoder:(CPCoder)aCoder
- (id)initWithCoder:(CPCoder)aCoder
{
if (self = [super initWithCoder:aCoder])
{
@@ -1008,3 +1078,115 @@
}
@end
@implementation CPBrowser (CPBrowserDelegate)
/*!
@ignore
Call delegate rootItemForBrowser:
*/
- (id)_sendDelegateRootItemForBrowser
{
if (!(_implementedDelegateMethods & CPBrowserDelegate_rootItemForBrowser_))
return nil;
return [_delegate rootItemForBrowser:self];
}
/*!
@ignore
Call delegate browser:didChangeLastColumn:toColumn:
*/
- (void)_sendDelegateBrowserDidChangeLastColumn:(CPInteger)lastColumn toColumn:(CPInteger)newColumn
{
if (!(_implementedDelegateMethods & CPBrowserDelegate_browser_didChangeLastColumn_toColumn_))
return;
[_delegate browser:self didChangeLastColumn:lastColumn toColumn:newColumn];
}
/*!
@ignore
Call delegate browser:didResizeColumn:
*/
- (void)_sendDelegateBrowserDidResizeColumn:(CPInteger)column
{
if (!(_implementedDelegateMethods & CPBrowserDelegate_browser_didResizeColumn_))
return;
[_delegate browser:self didResizeColumn:column];
}
/*!
@ignore
Call delegate browserSelectionIsChanging:
*/
- (void)_sendDelegateBrowserSelectionIsChanging
{
if (!(_implementedDelegateMethods & CPBrowserDelegate_browserSelectionIsChanging_))
return;
[_delegate browserSelectionIsChanging:self];
}
/*!
@ignore
Call delegate browser:shouldSelectRowIndexes:inColumn:
*/
- (BOOL)_sendDelegateBrowserShouldSelectRowIndexes:(CPIndexSet)anIndexSet inColumn:(CPInteger)aColumn
{
if (!(_implementedDelegateMethods & CPBrowserDelegate_browser_shouldSelectRowIndexes_inColumn_))
return YES;
return [_delegate browser:self shouldSelectRowIndexes:anIndexSet inColumn:aColumn];
}
/*!
@ignore
Call delegate browser:selectionIndexesForProposedSelection:inColumn:
*/
- (CPIndexSet)_sendDelegateBrowserSelectionIndexesForProposedSelection:(CPIndexSet)anIndexSet inColumn:(CPInteger)aColumn
{
if (!(_implementedDelegateMethods & CPBrowserDelegate_browser_selectionIndexesForProposedSelection_inColumn_))
return anIndexSet;
return [_delegate browser:self selectionIndexesForProposedSelection:anIndexSet inColumn:aColumn];
}
/*!
@ignore
Call delegate browserSelectionDidChange
*/
- (void)_sendDelegateBrowserSelectionDidChange
{
if (!(_implementedDelegateMethods & CPBrowserDelegate_browserSelectionDidChange_))
return;
[_delegate browserSelectionDidChange:self];
}
- (BOOL)canDragRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)columnIndex withEvent:(CPEvent)dragEvent
{
if (_implementedDelegateMethods & CPBrowserDelegate_browser_canDragRowsWithIndexes_inColumn_withEvent_)
return [_delegate browser:self canDragRowsWithIndexes:rowIndexes inColumn:columnIndex withEvent:dragEvent];
return YES;
}
- (CPImage)draggingImageForRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)columnIndex withEvent:(CPEvent)dragEvent offset:(CGPoint)dragImageOffset
{
if (_implementedDelegateMethods & CPBrowserDelegate_browser_draggingImageForRowsWithIndexes_inColumn_withEvent_offset_)
return [_delegate browser:self draggingImageForRowsWithIndexes:rowIndexes inColumn:columnIndex withEvent:dragEvent offset:dragImageOffset];
return nil;
}
- (CPView)draggingViewForRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)columnIndex withEvent:(CPEvent)dragEvent offset:(CGPoint)dragImageOffset
{
if (_implementedDelegateMethods & CPBrowserDelegate_browser_draggingViewForRowsWithIndexes_inColumn_withEvent_offset_)
return [_delegate browser:self draggingViewForRowsWithIndexes:rowIndexes inColumn:columnIndex withEvent:dragEvent offset:dragImageOffset];
return nil;
}
@end
+298 -197
View File
@@ -29,8 +29,7 @@
@import "CPWindow_Constants.j"
/* @group CPBezelStyle */
// IB style
@typedef CPBezelStyle
CPRoundedBezelStyle = 1; // Push
CPRegularSquareBezelStyle = 2; // Bevel
CPThickSquareBezelStyle = 3;
@@ -45,10 +44,12 @@ CPTexturedRoundedBezelStyle = 11; // Round Textured
CPRoundRectBezelStyle = 12; // Round Rect
CPRecessedBezelStyle = 13; // Recessed
CPRoundedDisclosureBezelStyle = 14; // Disclosure
CPInlineBezelStyle = 15; // Inline
CPHUDBezelStyle = -1;
/* @group CPButtonType */
@typedef CPButtonType
CPMomentaryLightButton = 0;
CPPushOnPushOffButton = 1;
CPToggleButton = 2;
@@ -72,13 +73,32 @@ CPPushInCellMask = CPPushInButtonMask;
CPChangeGrayCellMask = CPGrayButtonMask;
CPChangeBackgroundCellMask = CPBackgroundButtonMask;
CPButtonStateMixed = CPThemeState("mixed");
CPButtonStateBezelStyleRounded = CPThemeState("rounded");
CPButtonStateMixed = CPThemeState("mixed");
CPButtonStateBezelStyleRounded = CPThemeState("rounded"); // IB style : Push
CPButtonStateBezelStyleShadowlessSquare = CPThemeState("square"); // IB style : Square
CPButtonStateBezelStyleSmallSquare = CPThemeState("gradient"); // IB style : Gradient
CPButtonStateBezelStyleTexturedRounded = CPThemeState("textured-rounded"); // IB style : Textured rounded
CPButtonStateBezelStyleRoundRect = CPThemeState("roundRect"); // IB style : Round rect
CPButtonStateBezelStyleRecessed = CPThemeState("recessed"); // IB style : Recessed
CPButtonStateBezelStyleInline = CPThemeState("inline"); // IB style : Inline
CPButtonStateBezelStyleRegularSquare = CPThemeState("bevel"); // IB style : Bevel
CPButtonStateBezelStyleTextured = CPThemeState("textured"); // IB style : Textured
CPButtonStateBezelStyleDisclosure = CPThemeState("disclosure"); // IB style : Disclosure triangle
CPButtonStateBezelStyleRoundedDisclosure = CPThemeState("rounded-disclosure"); // IB style : Rounded disclosure
// add all future correspondance between bezel styles and theme state here.
var CPButtonBezelStyleStateMap = @{
CPRoundedBezelStyle: CPButtonStateBezelStyleRounded,
CPRoundRectBezelStyle: [CPNull null],
CPRoundedBezelStyle: CPButtonStateBezelStyleRounded,
CPShadowlessSquareBezelStyle: CPButtonStateBezelStyleShadowlessSquare,
CPSmallSquareBezelStyle: CPButtonStateBezelStyleSmallSquare,
CPTexturedRoundedBezelStyle: CPButtonStateBezelStyleTexturedRounded,
CPRoundRectBezelStyle: CPButtonStateBezelStyleRoundRect,
CPRecessedBezelStyle: CPButtonStateBezelStyleRecessed,
CPInlineBezelStyle: CPButtonStateBezelStyleInline,
CPRegularSquareBezelStyle: CPButtonStateBezelStyleRegularSquare,
CPTexturedSquareBezelStyle: CPButtonStateBezelStyleTextured,
CPDisclosureBezelStyle: CPButtonStateBezelStyleDisclosure,
CPRoundedDisclosureBezelStyle: CPButtonStateBezelStyleRoundedDisclosure
};
/// @cond IGNORE
@@ -107,7 +127,7 @@ CPButtonImageOffset = 3.0;
// NS-style Display Properties
CPBezelStyle _bezelStyle;
CPControlSize _controlSize;
ThemeState _bezelState;
CPString _keyEquivalent;
unsigned _keyEquivalentModifierMask;
@@ -117,7 +137,7 @@ CPButtonImageOffset = 3.0;
float _periodicDelay;
float _periodicInterval;
BOOL _isTracking;
BOOL _isHighlighted;
}
+ (Class)_binderClassForBinding:(CPString)aBinding
@@ -149,14 +169,22 @@ CPButtonImageOffset = 3.0;
return @"button";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"image": [CPNull null],
@"image-offset": 0.0,
@"image-vertical-offset": 0.0,
@"bezel-inset": CGInsetMakeZero(),
@"content-inset": CGInsetMakeZero(),
@"bezel-color": [CPNull null],
@"image-position": CPImageLeft,
@"vertical-alignment": CPCenterVerticalTextAlignment,
@"alignment": CPCenterTextAlignment,
@"image-scaling": CPImageScaleNone,
@"invert-image": NO,
@"invert-image-on-push": NO,
@"image-color": [CPNull null] // If null, image color follows text color
};
}
@@ -171,12 +199,6 @@ CPButtonImageOffset = 3.0;
if (self)
{
// Should we instead override the defaults?
[self setValue:CPCenterTextAlignment forThemeAttribute:@"alignment"];
[self setValue:CPCenterVerticalTextAlignment forThemeAttribute:@"vertical-alignment"];
[self setValue:CPImageLeft forThemeAttribute:@"image-position"];
[self setValue:CPImageScaleNone forThemeAttribute:@"image-scaling"];
[self setBezelStyle:CPRoundRectBezelStyle];
[self setBordered:YES];
@@ -188,8 +210,6 @@ CPButtonImageOffset = 3.0;
- (void)_init
{
_controlSize = CPRegularControlSize;
_keyEquivalent = @"";
_keyEquivalentModifierMask = 0;
@@ -200,6 +220,20 @@ CPButtonImageOffset = 3.0;
[self setButtonType:CPMomentaryPushInButton];
}
#pragma mark -
#pragma mark Control Size
- (void)setControlSize:(CPControlSize)aControlSize
{
[super setControlSize:aControlSize];
if ([self isBordered])
[self _sizeToControlSize];
}
#pragma mark -
// Setting the state
/*!
Returns a Boolean value indicating whether the button allows a mixed state.
@@ -246,30 +280,6 @@ CPButtonImageOffset = 3.0;
anObjectValue = CPOnState;
[super setObjectValue:anObjectValue];
switch ([self objectValue])
{
case CPMixedState:
[self unsetThemeState:CPThemeStateSelected];
[self setThemeState:CPButtonStateMixed];
if (_showsStateBy & (CPChangeGrayCellMask | CPChangeBackgroundCellMask))
[self setThemeState:CPThemeStateHighlighted];
else
[self unsetThemeState:CPThemeStateHighlighted];
break;
case CPOnState:
[self unsetThemeState:CPButtonStateMixed];
[self setThemeState:CPThemeStateSelected];
if (_showsStateBy & (CPChangeGrayCellMask | CPChangeBackgroundCellMask))
[self setThemeState:CPThemeStateHighlighted];
else
[self unsetThemeState:CPThemeStateHighlighted];
break;
case CPOffState:
[self unsetThemeState:CPThemeStateSelected | CPButtonStateMixed | CPThemeStateHighlighted];
}
}
/*!
@@ -292,7 +302,7 @@ CPButtonImageOffset = 3.0;
}
/*!
Sets the button's next state to \c aState.
Sets the button's state to the next available state.
@param aState Possible states are any of the CPButton globals:
\c CPOffState, \c CPOnState, \c CPMixedState
*/
@@ -366,12 +376,21 @@ CPButtonImageOffset = 3.0;
- (void)setImage:(CPImage)anImage
{
[self setValue:anImage forThemeAttribute:@"image"];
// This is needed when compiling themes
if (!_bezelState)
_bezelState = CPThemeStateNormal;
[self setValue:anImage forThemeAttribute:@"image" inState:_bezelState];
// if we omit this, images will disappear as soon as the button becomes disabled
[self setValue:anImage forThemeAttribute:@"image" inState:_bezelState.and(CPThemeStateDisabled)];
}
- (CPImage)image
{
return [self valueForThemeAttribute:@"image" inState:CPThemeStateNormal];
if (!_bezelState)
_bezelState = CPThemeStateNormal;
return [self valueForThemeAttribute:@"image" inState:_bezelState];
}
/*!
@@ -380,7 +399,8 @@ CPButtonImageOffset = 3.0;
*/
- (void)setAlternateImage:(CPImage)anImage
{
[self setValue:anImage forThemeAttribute:@"image" inState:CPThemeStateHighlighted];
[self setValue:anImage forThemeAttribute:@"image" inState:_bezelState.and(CPThemeStateHighlighted)];
[self setValue:anImage forThemeAttribute:@"image" inState:_bezelState.and(CPThemeStateSelected)];
}
/*!
@@ -388,7 +408,17 @@ CPButtonImageOffset = 3.0;
*/
- (CPImage)alternateImage
{
return [self valueForThemeAttribute:@"image" inState:CPThemeStateHighlighted];
return [self valueForThemeAttribute:@"image" inState:_bezelState.and(CPThemeStateSelected)];
}
- (void)setHoveredImage:(CPImage)anImage
{
[self setValue:anImage forThemeAttribute:@"image" inState:_bezelState.and(CPThemeStateHovered)];
}
- (CPImage)hoveredImage
{
return [self valueForThemeAttribute:@"image" inState:_bezelState.and(CPThemeStateHovered)];
}
- (void)setImageOffset:(float)theImageOffset
@@ -411,11 +441,6 @@ CPButtonImageOffset = 3.0;
_showsStateBy = aMask;
if (_showsStateBy & (CPChangeGrayCellMask | CPChangeBackgroundCellMask) && [self state] != CPOffState)
[self setThemeState:CPThemeStateHighlighted];
else
[self unsetThemeState:CPThemeStateHighlighted];
[self setNeedsDisplay:YES];
[self setNeedsLayout];
}
@@ -432,11 +457,8 @@ CPButtonImageOffset = 3.0;
_highlightsBy = aMask;
if ([self hasThemeState:CPThemeStateHighlighted])
{
[self setNeedsDisplay:YES];
[self setNeedsLayout];
}
[self setNeedsDisplay:YES];
[self setNeedsLayout];
}
- (CPInteger)highlightsBy
@@ -448,38 +470,47 @@ CPButtonImageOffset = 3.0;
{
switch (aButtonType)
{
case CPMomentaryLightButton: [self setHighlightsBy:CPChangeGrayCellMask | CPChangeBackgroundCellMask];
[self setShowsStateBy:CPNoCellMask];
break;
case CPMomentaryLightButton:
[self setHighlightsBy:CPChangeGrayCellMask | CPChangeBackgroundCellMask];
[self setShowsStateBy:CPNoCellMask];
break;
case CPMomentaryPushInButton: [self setHighlightsBy:CPPushInCellMask | CPChangeGrayCellMask | CPChangeBackgroundCellMask];
[self setShowsStateBy:CPNoCellMask];
break;
case CPMomentaryPushInButton:
[self setHighlightsBy:CPPushInCellMask | CPChangeGrayCellMask | CPChangeBackgroundCellMask];
[self setShowsStateBy:CPNoCellMask];
break;
case CPMomentaryChangeButton: [self setHighlightsBy:CPContentsCellMask];
[self setShowsStateBy:CPNoCellMask];
break;
case CPMomentaryChangeButton:
[self setHighlightsBy:CPContentsCellMask];
[self setShowsStateBy:CPNoCellMask];
break;
case CPPushOnPushOffButton: [self setHighlightsBy:CPPushInCellMask | CPChangeGrayCellMask | CPChangeBackgroundCellMask];
[self setShowsStateBy:CPChangeBackgroundCellMask | CPChangeGrayCellMask];
break;
case CPPushOnPushOffButton:
[self setHighlightsBy:CPPushInCellMask | CPChangeGrayCellMask | CPChangeBackgroundCellMask];
[self setShowsStateBy:CPChangeBackgroundCellMask | CPChangeGrayCellMask];
break;
case CPOnOffButton: [self setHighlightsBy:CPChangeGrayCellMask | CPChangeBackgroundCellMask];
[self setShowsStateBy:CPChangeGrayCellMask | CPChangeBackgroundCellMask];
break;
case CPOnOffButton:
[self setHighlightsBy:CPChangeGrayCellMask | CPChangeBackgroundCellMask];
[self setShowsStateBy:CPChangeGrayCellMask | CPChangeBackgroundCellMask];
break;
case CPToggleButton: [self setHighlightsBy:CPPushInCellMask | CPContentsCellMask];
[self setShowsStateBy:CPContentsCellMask];
break;
case CPToggleButton:
[self setHighlightsBy:CPPushInCellMask | CPContentsCellMask];
[self setShowsStateBy:CPContentsCellMask];
break;
case CPSwitchButton: [CPException raise:CPInvalidArgumentException
reason:"The CPSwitchButton type is not supported in Cappuccino, use the CPCheckBox class instead."];
case CPSwitchButton:
[CPException raise:CPInvalidArgumentException
reason:"The CPSwitchButton type is not supported in Cappuccino, use the CPCheckBox class instead."];
case CPRadioButton: [CPException raise:CPInvalidArgumentException
reason:"The CPRadioButton type is not supported in Cappuccino, use the CPRadio class instead."];
case CPRadioButton:
[CPException raise:CPInvalidArgumentException
reason:"The CPRadioButton type is not supported in Cappuccino, use the CPRadio class instead."];
default: [CPException raise:CPInvalidArgumentException
reason:"Unknown button type."];
default:
[CPException raise:CPInvalidArgumentException
reason:"Unknown button type."];
}
[self setImageDimsWhenDisabled:YES];
@@ -512,9 +543,20 @@ CPButtonImageOffset = 3.0;
_periodicInterval = anInterval;
}
- (void)highlight:(BOOL)shouldHighlight
{
if (_isHighlighted == shouldHighlight)
return;
_isHighlighted = shouldHighlight;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
- (void)mouseDown:(CPEvent)anEvent
{
if ([self isContinuous])
if ([self isEnabled] && [self isContinuous])
{
_continuousDelayTimer = [CPTimer scheduledTimerWithTimeInterval:_periodicDelay callback: function()
{
@@ -534,46 +576,12 @@ CPButtonImageOffset = 3.0;
[_target performSelector:_action withObject:self];
}
- (BOOL)startTrackingAt:(CGPoint)aPoint
{
_isTracking = YES;
var startedTracking = [super startTrackingAt:aPoint];
if (_highlightsBy & (CPPushInCellMask | CPChangeGrayCellMask))
{
if (_showsStateBy & (CPChangeGrayCellMask | CPChangeBackgroundCellMask))
[self highlight:[self state] == CPOffState];
else
[self highlight:YES];
}
else
{
if (_showsStateBy & (CPChangeGrayCellMask | CPChangeBackgroundCellMask))
[self highlight:[self state] != CPOffState];
else
[self highlight:NO];
}
return startedTracking;
}
- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
{
_isTracking = NO;
if (mouseIsUp && CGRectContainsPoint([self bounds], aPoint))
[self setNextState];
else
{
if (_showsStateBy & (CPChangeGrayCellMask | CPChangeBackgroundCellMask))
[self highlight:[self state] != CPOffState];
else
[self highlight:NO];
}
[self setNeedsLayout];
[self setNeedsDisplay:YES];
[self highlight:NO];
[self invalidateTimers];
}
@@ -594,7 +602,7 @@ CPButtonImageOffset = 3.0;
- (CGRect)contentRectForBounds:(CGRect)bounds
{
var contentInset = [self currentValueForThemeAttribute:@"content-inset"];
var contentInset = [self valueForThemeAttribute:@"content-inset" inState:[self _contentVisualState]];
return CGRectInsetByInset(bounds, contentInset);
}
@@ -621,7 +629,7 @@ CPButtonImageOffset = 3.0;
size = [contentView frameSize];
}
else
size = [([self title] || " ") sizeWithFont:[self currentValueForThemeAttribute:@"font"]];
size = [([self title] || " ") sizeWithFont:[self font]];
var contentInset = [self currentValueForThemeAttribute:@"content-inset"],
minSize = [self currentValueForThemeAttribute:@"min-size"],
@@ -677,86 +685,164 @@ CPButtonImageOffset = 3.0;
return [[_CPImageAndTextView alloc] initWithFrame:CGRectMakeZero()];
}
- (CPThemeState)_backgroundVisualState
{
var visualState = [self themeState] || CPThemeStateNormal, // Needed during theme compilation
currentState = [self state],
buttonIsOn = (currentState !== CPOffState);
if (_isHighlighted && (_highlightsBy & (CPPushInCellMask | CPChangeGrayCellMask)))
visualState = visualState.and(CPThemeStateHighlighted);
else
visualState = visualState.without(CPThemeStateHighlighted);
if (buttonIsOn && (_showsStateBy & (CPPushInCellMask | CPChangeGrayCellMask)))
visualState = visualState.and((currentState === CPOnState) ? CPThemeStateSelected : CPButtonStateMixed);
else
visualState = visualState.without(CPThemeStateSelected);
return visualState;
}
// Note : We have to split content and image visual states as, for example, radio buttons don't follow push buttons behavior
- (CPThemeState)_contentVisualState
{
var visualState = [self themeState] || CPThemeStateNormal, // Needed during theme compilation
currentState = [self state],
buttonIsOn = (currentState !== CPOffState);
// If the button is pushed (_isHighlighted), always add the highlighted state
if (_isHighlighted || (((_showsStateBy & CPChangeGrayCellMask) || (_showsStateBy & CPChangeBackgroundCellMask)) && buttonIsOn))
visualState = visualState.and(CPThemeStateHighlighted);
else
visualState = visualState.without(CPThemeStateHighlighted);
if (buttonIsOn && (_showsStateBy & CPContentsCellMask))
visualState = visualState.and((currentState === CPOnState) ? CPThemeStateSelected : CPButtonStateMixed);
else
visualState = visualState.without(CPThemeStateSelected);
return visualState;
}
- (CPThemeState)_imageVisualState
{
var visualState = [self themeState] || CPThemeStateNormal, // Needed during theme compilation
currentState = [self state],
buttonIsOn = (currentState !== CPOffState);
// Remove highlighted & selected theme states
visualState = visualState.without(CPThemeStateHighlighted);
visualState = visualState.without(CPThemeStateSelected);
// Note : We have to deal with special case where button is ON, highlightsBy and showsStateBy use content, and button is pushed
// BUT this should not be used for disclosure buttons !
if (_isHighlighted && buttonIsOn && (_highlightsBy & CPContentsCellMask) && (_showsStateBy & CPContentsCellMask) && (_bezelStyle !== CPDisclosureBezelStyle))
return visualState;
if (_isHighlighted && ((_highlightsBy & CPContentsCellMask) || (_highlightsBy & CPChangeGrayCellMask)))
visualState = visualState.and(CPThemeStateHighlighted);
if (buttonIsOn && (_showsStateBy & CPContentsCellMask))
visualState = visualState.and((currentState === CPOnState) ? CPThemeStateSelected : CPButtonStateMixed);
return visualState;
}
- (CPString)_currentTitle
{
var buttonIsOn = ([self state] !== CPOffState);
// Note : We have to deal with special case where button is ON, highlightsBy and showsStateBy use content, and button is pushed
if (_isHighlighted && buttonIsOn && (_highlightsBy & CPContentsCellMask) && (_showsStateBy & CPContentsCellMask))
return _title;
else if (_alternateTitle && ((_isHighlighted && (_highlightsBy & CPContentsCellMask)) || (buttonIsOn && (_showsStateBy & CPContentsCellMask))))
return _alternateTitle;
else
return _title;
}
- (CPImage)_currentImage
{
var visualState = [self _imageVisualState],
currentImage = [self valueForThemeAttribute:@"image" inState:visualState],
imageColor = [self valueForThemeAttribute:@"image-color" inState:visualState],
buttonIsOn = ([self state] !== CPOffState);
if ([currentImage isMaterialIconImage])
{
if (([self valueForThemeAttribute:@"invert-image" inState:visualState] || ([self valueForThemeAttribute:@"invert-image-on-push" inState:visualState] && (_isHighlighted || (((_showsStateBy & CPChangeGrayCellMask) || (_showsStateBy & CPChangeBackgroundCellMask)) && buttonIsOn)))))
currentImage = [currentImage invertedImage];
else if (imageColor && [imageColor isKindOfClass:CPColor])
// In some buttons, image color doesn't follow text color !
currentImage = [currentImage imageVersionWithColor:imageColor];
else
// By default, image color follows text color
currentImage = [currentImage imageVersionWithColor:[self valueForThemeAttribute:@"text-color" inState:[self _contentVisualState]]];
}
return currentImage;
}
- (void)layoutSubviews
{
var bezelView = [self layoutEphemeralSubviewNamed:@"bezel-view"
positioned:CPWindowBelow
relativeToEphemeralSubviewNamed:@"content-view"];
var bezelView = [self layoutEphemeralSubviewNamed:@"bezel-view"
positioned:CPWindowBelow
relativeToEphemeralSubviewNamed:@"content-view"],
[bezelView setBackgroundColor:[self currentValueForThemeAttribute:@"bezel-color"]];
var contentView = [self layoutEphemeralSubviewNamed:@"content-view"
contentView = [self layoutEphemeralSubviewNamed:@"content-view"
positioned:CPWindowAbove
relativeToEphemeralSubviewNamed:@"bezel-view"];
relativeToEphemeralSubviewNamed:@"bezel-view"],
if (contentView)
{
var title = nil,
image = nil;
image = [self _currentImage],
contentVisualState = [self _contentVisualState];
if (_isTracking)
{
if (_highlightsBy & CPContentsCellMask)
{
if (_showsStateBy & CPContentsCellMask)
{
title = ([self state] == CPOffState && _alternateTitle) ? _alternateTitle : _title;
image = ([self state] == CPOffState && [self alternateImage]) ? [self alternateImage] : [self image];
}
else
{
title = [self alternateTitle];
image = [self alternateImage];
}
}
else if (_showsStateBy & CPContentsCellMask)
{
title = ([self state] != CPOffState && _alternateTitle) ? _alternateTitle : _title;
image = ([self state] != CPOffState && [self alternateImage]) ? [self alternateImage] : [self image];
}
else
{
title = _title;
image = [self image];
}
}
else
{
if (_showsStateBy & CPContentsCellMask)
{
title = ([self state] != CPOffState && _alternateTitle) ? _alternateTitle : _title;
image = ([self state] != CPOffState && [self alternateImage]) ? [self alternateImage] : [self image];
}
else
{
title = _title;
image = [self image];
}
}
[bezelView setBackgroundColor:[self valueForThemeAttribute:@"bezel-color" inState:[self _backgroundVisualState]]];
[contentView setText:[self _currentTitle]];
[contentView setImage:image];
[contentView setText:title];
[contentView setImage:image];
[contentView setImageOffset:[self currentValueForThemeAttribute:@"image-offset"]];
[contentView setImageOffset:[self valueForThemeAttribute:@"image-offset" inState:contentVisualState]];
[contentView setImageVerticalOffset:[self valueForThemeAttribute:@"image-vertical-offset" inState:contentVisualState]];
[contentView setFont:[self currentValueForThemeAttribute:@"font"]];
[contentView setTextColor:[self currentValueForThemeAttribute:@"text-color"]];
[contentView setAlignment:[self currentValueForThemeAttribute:@"alignment"]];
[contentView setVerticalAlignment:[self currentValueForThemeAttribute:@"vertical-alignment"]];
[contentView setLineBreakMode:[self currentValueForThemeAttribute:@"line-break-mode"]];
[contentView setTextShadowColor:[self currentValueForThemeAttribute:@"text-shadow-color"]];
[contentView setTextShadowOffset:[self currentValueForThemeAttribute:@"text-shadow-offset"]];
[contentView setImagePosition:[self currentValueForThemeAttribute:@"image-position"]];
[contentView setImageScaling:[self currentValueForThemeAttribute:@"image-scaling"]];
[contentView setDimsImage:[self hasThemeState:CPThemeStateDisabled] && _imageDimsWhenDisabled];
}
[contentView setFont:[self font]];
[contentView setTextColor:[self valueForThemeAttribute:@"text-color" inState:contentVisualState]];
[contentView setAlignment:[self valueForThemeAttribute:@"alignment" inState:contentVisualState]];
[contentView setVerticalAlignment:[self valueForThemeAttribute:@"vertical-alignment" inState:contentVisualState]];
[contentView setLineBreakMode:[self valueForThemeAttribute:@"line-break-mode" inState:contentVisualState]];
[contentView _setUsesSingleLineMode:YES];
[contentView setTextShadowColor:[self valueForThemeAttribute:@"text-shadow-color" inState:contentVisualState]];
[contentView setTextShadowOffset:[self valueForThemeAttribute:@"text-shadow-offset" inState:contentVisualState]];
[contentView setImagePosition:[self valueForThemeAttribute:@"image-position"]];
[contentView setImageScaling:[self valueForThemeAttribute:@"image-scaling"]];
// We don't automatically dim material icon images as the color is driven by the theme
[contentView setDimsImage:[self hasThemeState:CPThemeStateDisabled] && _imageDimsWhenDisabled && ![image isMaterialIconImage]];
}
- (void)setBordered:(BOOL)shouldBeBordered
{
if (shouldBeBordered)
{
[self setThemeState:CPThemeStateBordered];
if (_bezelState)
_bezelState = _bezelState.and(CPThemeStateBordered);
else
_bezelState = CPThemeStateBordered;
}
else
{
[self unsetThemeState:CPThemeStateBordered];
if (_bezelState)
_bezelState = _bezelState.without(CPThemeStateBordered);
else
_bezelState = CPThemeStateNormal;
}
}
- (BOOL)isBordered
@@ -786,7 +872,7 @@ CPButtonImageOffset = 3.0;
{
var selfWindow = [self window];
if (selfWindow === aWindow || aWindow === nil)
if (selfWindow === aWindow || aWindow == nil)
return;
if ([selfWindow defaultButton] === self)
@@ -852,17 +938,7 @@ CPButtonImageOffset = 3.0;
[self setState:[self nextState]];
var shouldHighlight = NO;
if (_highlightsBy & (CPPushInCellMask | CPChangeGrayCellMask))
{
if (_showsStateBy & (CPChangeGrayCellMask | CPChangeBackgroundCellMask))
shouldHighlight = [self state] == CPOffState;
else
shouldHighlight = YES;
}
[self highlight:shouldHighlight];
[self highlight:YES];
try
{
@@ -874,8 +950,7 @@ CPButtonImageOffset = 3.0;
}
finally
{
if (shouldHighlight)
[CPTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(unhighlightButtonTimerDidFinish:) userInfo:nil repeats:NO];
[CPTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(unhighlightButtonTimerDidFinish:) userInfo:nil repeats:NO];
}
}
@@ -898,6 +973,22 @@ CPButtonImageOffset = 3.0;
[self setThemeState:newState];
_bezelStyle = aBezelStyle;
if (_bezelState && newState)
{
if (currentState)
_bezelState =_bezelState.without(currentState);
_bezelState = _bezelState.and(newState);
}
else
_bezelState = newState || CPThemeStateNormal;
// For disclosure triangle and rounded, we have to move away from
// what Xcode tells us as we implement visual behavior with images (so content)
// and not background
if ((_bezelStyle === CPDisclosureBezelStyle) || (_bezelStyle === CPRoundedDisclosureBezelStyle))
[self setShowsStateBy:CPContentsCellMask];
}
- (unsigned)bezelStyle
@@ -921,7 +1012,8 @@ var CPButtonImageKey = @"CPButtonImageKey",
CPButtonPeriodicDelayKey = @"CPButtonPeriodicDelayKey",
CPButtonPeriodicIntervalKey = @"CPButtonPeriodicIntervalKey",
CPButtonHighlightsByKey = @"CPButtonHighlightsByKey",
CPButtonShowsStateByKey = @"CPButtonShowsStateByKey";
CPButtonShowsStateByKey = @"CPButtonShowsStateByKey",
CPButtonBezelStyleKey = @"CPButtonBezelStyleKey";
@implementation CPButton (CPCoding)
@@ -970,6 +1062,12 @@ var CPButtonImageKey = @"CPButtonImageKey",
_keyEquivalentModifierMask = [aCoder decodeIntForKey:CPButtonKeyEquivalentMaskKey];
if ([aCoder containsValueForKey:CPButtonIsBorderedKey])
[self setBordered:[aCoder decodeBoolForKey:CPButtonIsBorderedKey]];
if ([aCoder containsValueForKey:CPButtonBezelStyleKey])
[self setBezelStyle:[aCoder decodeIntForKey:CPButtonBezelStyleKey]];
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
@@ -1004,6 +1102,9 @@ var CPButtonImageKey = @"CPButtonImageKey",
[aCoder encodeObject:_periodicDelay forKey:CPButtonPeriodicDelayKey];
[aCoder encodeObject:_periodicInterval forKey:CPButtonPeriodicIntervalKey];
[aCoder encodeBool:[self isBordered] forKey:CPButtonIsBorderedKey];
[aCoder encodeInt: [self bezelStyle] forKey:CPButtonBezelStyleKey];
}
@end
+42 -12
View File
@@ -26,7 +26,10 @@
@class CPSplitView
@global CPPopUpButtonStatePullsDown
@global CPKeyValueChangeOldKey
@global CPKeyValueChangeNewKey
@global CPKeyValueObservingOptionNew
@global CPKeyValueObservingOptionOld
@implementation CPButtonBar : CPView
{
@@ -67,7 +70,7 @@
[button addItemWithTitle:nil];
[[button lastItem] setImage:image];
[button setImagePosition:CPImageOnly];
[button setValue:CGInsetMake(0, 0, 0, 0) forThemeAttribute:"content-inset"];
[button setValue:CGInsetMake(0, 0, 0, 0) forThemeAttribute:"content-inset" inState:CPPopUpButtonStatePullsDown];
[button setPullsDown:YES];
@@ -79,7 +82,7 @@
return @"button-bar";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"resize-control-inset": CGInsetMake(0.0, 0.0, 0.0, 0.0),
@@ -109,6 +112,8 @@
- (void)awakeFromCib
{
[super awakeFromCib];
var view = [self superview],
subview = self;
@@ -129,10 +134,20 @@
- (void)setButtons:(CPArray)buttons
{
for (var i = [_buttons count] - 1; i >= 0; i--)
{
[_buttons[i] removeFromSuperview];
[_buttons[i] removeObserver:self forKeyPath:@"hidden"];
}
_buttons = [CPArray arrayWithArray:buttons];
for (var i = 0, count = [_buttons count]; i < count; i++)
for (var i = [_buttons count] - 1; i >= 0; i--)
{
[_buttons[i] addObserver:self forKeyPath:@"hidden" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld context:nil];
[_buttons[i] setBordered:YES];
}
[self setNeedsLayout];
}
@@ -218,8 +233,15 @@
count = [buttonsNotHidden count];
while (count--)
if ([buttonsNotHidden[count] isHidden])
[buttonsNotHidden removeObject:buttonsNotHidden[count]];
{
var button = buttonsNotHidden[count];
if ([button isHidden])
{
[button removeFromSuperview];
[buttonsNotHidden removeObject:button];
}
}
var currentButtonOffset = _resizeControlIsLeftAligned ? CGRectGetMaxX([self bounds]) + 1 : -1,
bounds = [self bounds],
@@ -250,15 +272,15 @@
currentButtonOffset += width - 1;
}
[button setValue:normalColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal | CPThemeStateBordered];
[button setValue:highlightedColor forThemeAttribute:@"bezel-color" inState:CPThemeStateHighlighted | CPThemeStateBordered];
[button setValue:disabledColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled | CPThemeStateBordered];
[button setValue:normalColor forThemeAttribute:@"bezel-color" inStates:[CPThemeStateNormal, CPThemeStateBordered]];
[button setValue:highlightedColor forThemeAttribute:@"bezel-color" inStates:[CPThemeStateHighlighted, CPThemeStateBordered, ]];
[button setValue:disabledColor forThemeAttribute:@"bezel-color" inStates:[CPThemeStateDisabled, CPThemeStateBordered]];
[button setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateBordered];
// FIXME shouldn't need this
[button setValue:normalColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal | CPThemeStateBordered | CPPopUpButtonStatePullsDown];
[button setValue:highlightedColor forThemeAttribute:@"bezel-color" inState:CPThemeStateHighlighted | CPThemeStateBordered | CPPopUpButtonStatePullsDown];
[button setValue:disabledColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled | CPThemeStateBordered | CPPopUpButtonStatePullsDown];
[button setValue:normalColor forThemeAttribute:@"bezel-color" inStates:[CPThemeStateNormal, CPThemeStateBordered, CPPopUpButtonStatePullsDown]];
[button setValue:highlightedColor forThemeAttribute:@"bezel-color" inStates:[CPThemeStateHighlighted, CPThemeStateBordered, CPPopUpButtonStatePullsDown]];
[button setValue:disabledColor forThemeAttribute:@"bezel-color" inStates:[CPThemeStateDisabled, CPThemeStateBordered, CPPopUpButtonStatePullsDown]];
[self addSubview:button];
}
@@ -274,6 +296,14 @@
}
}
- (void)observeValueForKeyPath:(CPString)keyPath ofObject:(id)object change:(CPDictionary)change context:(id)context
{
if ([change objectForKey:CPKeyValueChangeOldKey] == [change objectForKey:CPKeyValueChangeNewKey])
return;
[self setNeedsLayout];
}
- (void)setFrameSize:(CGSize)aSize
{
[super setFrameSize:aSize];
+62 -8
View File
@@ -94,21 +94,58 @@ CPCheckBoxImageOffset = 4.0;
[self takeStateFromKeyPath:aKeyPath ofObjects:objects];
}
- (CPImage)image
#pragma mark -
#pragma mark Override methods from CPButton
- (CGSize)_minimumFrameSize
{
return [self currentValueForThemeAttribute:@"image"];
var size = [super _minimumFrameSize],
contentView = [self ephemeralSubviewNamed:@"content-view"];
if (!contentView && [[self title] length])
{
var minSize = [self currentValueForThemeAttribute:@"min-size"],
maxSize = [self currentValueForThemeAttribute:@"max-size"];
// Here we always add the min size to the control which is the size of the view of the checkBox
size.width += minSize.width + CPCheckBoxImageOffset;
if (maxSize.width >= 0.0)
size.width = MIN(size.width, maxSize.width);
}
return size;
}
- (CPImage)alternateImage
- (CPThemeState)_contentVisualState
{
return [self currentValueForThemeAttribute:@"image"];
// Note : Behavior differs from CPButton as title doesn't follow the highlightsBy content flag
var visualState = [self themeState] || CPThemeStateNormal, // Needed during theme compilation
currentState = [self state];
if ((currentState !== CPOffState) && (_showsStateBy & CPContentsCellMask))
visualState = visualState.and((currentState === CPOnState) ? CPThemeStateSelected : CPButtonStateMixed);
return visualState;
}
- (BOOL)startTrackingAt:(CGPoint)aPoint
- (CPThemeState)_imageVisualState
{
var startedTracking = [super startTrackingAt:aPoint];
[self highlight:YES];
return startedTracking;
// Note : Behavior differs from CPButton as we don't force "not selected" theme state
// when button is highglighted and selected
var visualState = [self themeState] || CPThemeStateNormal, // Needed during theme compilation
currentState = [self state];
if (_isHighlighted && (_highlightsBy & CPContentsCellMask))
visualState = visualState.and(CPThemeStateHighlighted);
if ((currentState !== CPOffState) && (_showsStateBy & CPContentsCellMask))
visualState = visualState.and((currentState === CPOnState) ? CPThemeStateSelected : CPButtonStateMixed);
return visualState;
}
@end
@@ -139,3 +176,20 @@ CPCheckBoxImageOffset = 4.0;
}
@end
#pragma mark -
@implementation CPCheckBox (TableDataView)
// We overide here _CPObject+Theme setValue:forThemeAttribute as CPCheckBox can be used as tableView data view
// So, when outside a table data view, setValue:forThemeAttribute should store the value with the CPThemeStateNormal (default behavior)
// When inside a table data view, it should store the value with the CPThemeStateTableDataView. If not, the value won't be used if the
// theme defined a value for this attribute for state CPThemeStateTableDataView
- (void)setValue:(id)aValue forThemeAttribute:(CPString)aName
{
[super setValue:aValue forThemeAttribute:aName];
[super setValue:aValue forThemeAttribute:aName inState:CPThemeStateTableDataView];
}
@end
+5 -38
View File
@@ -46,49 +46,12 @@
return;
if (_documentView)
{
var defaultCenter = [CPNotificationCenter defaultCenter];
[defaultCenter
removeObserver:self
name:CPViewFrameDidChangeNotification
object:_documentView];
[defaultCenter
removeObserver:self
name:CPViewBoundsDidChangeNotification
object:_documentView];
[_documentView removeFromSuperview];
}
_documentView = aView;
if (_documentView)
{
[self addSubview:_documentView];
[self _observeDocumentView];
}
}
- (void)_observeDocumentView
{
var defaultCenter = [CPNotificationCenter defaultCenter];
[_documentView setPostsFrameChangedNotifications:YES];
[_documentView setPostsBoundsChangedNotifications:YES];
[defaultCenter
addObserver:self
selector:@selector(viewFrameChanged:)
name:CPViewFrameDidChangeNotification
object:_documentView];
[defaultCenter
addObserver:self
selector:@selector(viewBoundsChanged:)
name:CPViewBoundsDidChangeNotification
object:_documentView];
}
/*!
@@ -230,6 +193,11 @@
return [self scrollToPoint:CGPointMake(bounds.origin.x - deltaX, bounds.origin.y - deltaY)];
}
- (CGRect)documentVisibleRect
{
return [_documentView visibleRect];
}
@end
@@ -244,7 +212,6 @@ var CPClipViewDocumentViewKey = @"CPScrollViewDocumentView";
// Don't call setDocumentView: here. It calls addSubview:, but it's A) not necessary since the
// view hierarchy is fully encoded and B) dangerous if the subview is not fully decoded.
_documentView = [aCoder decodeObjectForKey:CPClipViewDocumentViewKey];
[self _observeDocumentView];
}
return self;
+314 -113
View File
@@ -31,6 +31,37 @@
@import "CPDragServer_Constants.j"
@import "CPPasteboard.j"
@import "CPView.j"
@import "CPKeyValueBinding.j"
@class _CPCollectionViewDropIndicator
var CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_ = 1 << 0,
CPCollectionViewDelegate_collectionView_canDragItemsAtIndexes_withEvent_ = 1 << 1,
CPCollectionViewDelegate_collectionView_writeItemsAtIndexes_toPasteboard_ = 1 << 2,
CPCollectionViewDelegate_collectionView_dragTypesForItemsAtIndexes_ = 1 << 3,
CPCollectionViewDelegate_collectionView_dataForItemsAtIndexes_forType_ = 1 << 4,
CPCollectionViewDelegate_collectionView_validateDrop_proposedIndex_dropOperation_ = 1 << 5,
CPCollectionViewDelegate_collectionView_didDoubleClickOnItemAtIndex_ = 1 << 6,
CPCollectionViewDelegate_collectionView_menuForItemAtIndex_ = 1 << 7,
CPCollectionViewDelegate_collectionView_draggingViewForItemsAtIndexes_withEvent_offset = 1 << 8;
@protocol CPCollectionViewDelegate <CPObject>
@optional
- (BOOL)collectionView:(CPCollectionView)collectionView acceptDrop:(id)draggingInfo index:(CPInteger)index dropOperation:(CPCollectionViewDropOperation)dropOperation;
- (BOOL)collectionView:(CPCollectionView)collectionView canDragItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)event;
- (BOOL)collectionView:(CPCollectionView)collectionView writeItemsAtIndexes:(CPIndexSet)indexes toPasteboard:(CPPasteboard)pasteboard;
- (CPArray)collectionView:(CPCollectionView)collectionView dragTypesForItemsAtIndexes:(CPIndexSet)indexes;
- (CPData)collectionView:(CPCollectionView)collectionView dataForItemsAtIndexes:(CPIndexSet)indices forType:(CPString)aType;
- (CPDragOperation)collectionView:(CPCollectionView)collectionView validateDrop:(id)draggingInfo proposedIndex:(CPInteger)proposedDropIndex dropOperation:(CPCollectionViewDropOperation)proposedDropOperation;
- (CPMenu)collectionView:(CPCollectionView)collectionView menuForItemAtIndex:(CPInteger)anIndex;
- (CPView)collectionView:(CPCollectionView)collectionView draggingViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)event offset:(CGPoint)dragImageOffset;
- (void)collectionView:(CPCollectionView)collectionView didDoubleClickOnItemAtIndex:(int)index;
@end
var HORIZONTAL_MARGIN = 2;
/*!
@ingroup appkit
@@ -42,10 +73,6 @@
@par Delegate Methods
@delegate - (void)collectionViewDidChangeSelection:(CPCollectionView)collectionView;
DEPRECATED: Please do not use.
@param collectionView the collection view who's selection changed
@delegate - (void)collectionView:(CPCollectionView)collectionView didDoubleClickOnItemAtIndex:(int)index;
Called when the user double-clicks on an item in the collection view.
@param collectionView the collection view that received the double-click
@@ -64,56 +91,61 @@
@param indices the indices to obtain drag types
@return an array of drag types (CPString)
*/
var HORIZONTAL_MARGIN = 2;
@implementation CPCollectionView : CPView
{
CPArray _content;
CPArray _items;
CPArray _content;
CPArray _items;
CPData _itemData;
CPCollectionViewItem _itemPrototype;
CPCollectionViewItem _itemForDragging;
CPMutableArray _cachedItems;
CPData _itemData;
CPCollectionViewItem _itemPrototype;
CPCollectionViewItem _itemForDragging;
CPMutableArray _cachedItems;
unsigned _maxNumberOfRows;
unsigned _maxNumberOfColumns;
unsigned _maxNumberOfRows;
unsigned _maxNumberOfColumns;
CGSize _minItemSize;
CGSize _maxItemSize;
CGSize _minItemSize;
CGSize _maxItemSize;
CPArray _backgroundColors;
CPArray _backgroundColors;
float _tileWidth;
float _tileWidth;
BOOL _isSelectable;
BOOL _allowsMultipleSelection;
BOOL _allowsEmptySelection;
CPIndexSet _selectionIndexes;
BOOL _isSelectable;
BOOL _allowsMultipleSelection;
BOOL _allowsEmptySelection;
CPIndexSet _selectionIndexes;
CGSize _itemSize;
CGSize _itemSize;
float _horizontalMargin;
float _verticalMargin;
float _horizontalMargin;
float _verticalMargin;
unsigned _numberOfRows;
unsigned _numberOfColumns;
unsigned _numberOfRows;
unsigned _numberOfColumns;
id _delegate;
id <CPCollectionViewDelegate> _delegate;
unsigned _implementedDelegateMethods;
CPEvent _mouseDownEvent;
CPEvent _mouseDownEvent;
BOOL _needsMinMaxItemSizeUpdate;
CGSize _storedFrameSize;
BOOL _needsMinMaxItemSizeUpdate;
CGSize _storedFrameSize;
BOOL _uniformSubviewsResizing @accessors(property=uniformSubviewsResizing);
BOOL _lockResizing;
BOOL _uniformSubviewsResizing @accessors(property=uniformSubviewsResizing);
CPInteger _currentDropIndex;
CPDragOperation _currentDragOperation;
CPInteger _currentDropIndex;
CPDragOperation _currentDragOperation;
_CPCollectionViewDropIndicator _dropView;
_CPCollectionViewDropIndicator _dropView;
}
+ (Class)_binderClassForBinding:(CPString)aBinding
{
if (aBinding == CPContentBinding)
return [_CPCollectionViewContentBinder class];
return [super _binderClassForBinding:aBinding];
}
- (id)initWithFrame:(CGRect)aFrame
@@ -158,7 +190,7 @@ var HORIZONTAL_MARGIN = 2;
_needsMinMaxItemSizeUpdate = YES;
_uniformSubviewsResizing = NO;
_lockResizing = NO;
_inLiveResize = NO;
_currentDropIndex = -1;
_currentDragOperation = CPDragOperationNone;
@@ -168,6 +200,51 @@ var HORIZONTAL_MARGIN = 2;
[self setAutoresizingMask:0];
}
#pragma mark -
#pragma mark Delegate
/*!
Set the delegate of the receiver
@param aDelegate the delegate object for the collectionView.
*/
- (void)setDelegate:(id <CPCollectionViewDelegate>)aDelegate
{
if (_delegate === aDelegate)
return;
_delegate = aDelegate;
_implementedDelegateMethods = 0;
if ([_delegate respondsToSelector:@selector(collectionView:acceptDrop:index:dropOperation:)])
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_;
if ([_delegate respondsToSelector:@selector(collectionView:canDragItemsAtIndexes:withEvent:)])
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_canDragItemsAtIndexes_withEvent_;
if ([_delegate respondsToSelector:@selector(collectionView:writeItemsAtIndexes:toPasteboard:)])
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_writeItemsAtIndexes_toPasteboard_;
if ([_delegate respondsToSelector:@selector(collectionView:dragTypesForItemsAtIndexes:)])
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_dragTypesForItemsAtIndexes_;
if ([_delegate respondsToSelector:@selector(collectionView:dataForItemsAtIndexes:forType:)])
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_dataForItemsAtIndexes_forType_;
if ([_delegate respondsToSelector:@selector(collectionView:validateDrop:proposedIndex:dropOperation:)])
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_validateDrop_proposedIndex_dropOperation_;
if ([_delegate respondsToSelector:@selector(collectionView:didDoubleClickOnItemAtIndex:)])
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_didDoubleClickOnItemAtIndex_;
if ([_delegate respondsToSelector:@selector(collectionView:menuForItemAtIndex:)])
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_menuForItemAtIndex_;
if ([_delegate respondsToSelector:@selector(collectionView:draggingViewForItemsAtIndexes:withEvent:offset:)])
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_draggingViewForItemsAtIndexes_withEvent_offset;
}
/*!
Sets the item prototype to \c anItem
@param anItem the new item prototype.
@@ -315,14 +392,7 @@ var HORIZONTAL_MARGIN = 2;
_isSelectable = isSelectable;
if (!_isSelectable)
{
var index = CPNotFound,
itemCount = [_items count];
// Be wary of invalid selection ranges since setContent: does not clear selection indexes.
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound && index < itemCount)
[_items[index] setSelected:NO];
}
[self _applySelectionToItems:NO];
}
/*!
@@ -376,31 +446,18 @@ var HORIZONTAL_MARGIN = 2;
{
if (!anIndexSet)
anIndexSet = [CPIndexSet indexSet];
if (!_isSelectable || [_selectionIndexes isEqual:anIndexSet])
return;
var index = CPNotFound,
itemCount = [_items count];
// Be wary of invalid selection ranges since setContent: does not clear selection indexes.
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) !== CPNotFound && index < itemCount)
[_items[index] setSelected:NO];
[self _applySelectionToItems:NO];
_selectionIndexes = anIndexSet;
var index = CPNotFound;
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) !== CPNotFound)
[_items[index] setSelected:YES];
[self _applySelectionToItems:YES];
var binderClass = [[self class] _binderClassForBinding:@"selectionIndexes"];
[[binderClass getBinding:@"selectionIndexes" forObject:self] reverseSetValueFor:@"selectionIndexes"];
if ([_delegate respondsToSelector:@selector(collectionViewDidChangeSelection:)])
{
CPLog.warn("The delegate method collectionViewDidChangeSelection: is deprecated and will be removed in a future version, please bind to selectionIndexes instead.");
[_delegate collectionViewDidChangeSelection:self];
}
}
/*!
@@ -455,21 +512,21 @@ var HORIZONTAL_MARGIN = 2;
[self tileIfNeeded:NO];
}
- (void)resizeSubviewsWithOldSize:(CPSize)oldBoundsSize
- (void)resizeSubviewsWithOldSize:(CGSize)oldBoundsSize
{
// Desactivate subviews autoresizing
}
- (void)resizeWithOldSuperviewSize:(CPSize)oldBoundsSize
- (void)resizeWithOldSuperviewSize:(CGSize)oldBoundsSize
{
if (_lockResizing)
if (_inLiveResize)
return;
_lockResizing = YES;
_inLiveResize = YES;
[self tile];
_lockResizing = NO;
_inLiveResize = NO;
}
- (void)tile
@@ -545,7 +602,7 @@ var HORIZONTAL_MARGIN = 2;
height = MAX(height, numberOfRows * (_minItemSize.height + _verticalMargin));
var itemSizeHeight = FLOOR(height / numberOfRows);
var itemSizeHeight = FLOOR(height / numberOfRows) - _verticalMargin;
if (maxItemSizeHeight > 0)
itemSizeHeight = MIN(itemSizeHeight, maxItemSizeHeight);
@@ -682,7 +739,7 @@ var HORIZONTAL_MARGIN = 2;
*/
- (void)setMinItemSize:(CGSize)aSize
{
if (aSize === nil || aSize === undefined)
if (aSize == nil)
[CPException raise:CPInvalidArgumentException reason:"Invalid value provided for minimum size"];
if (CGSizeEqualToSize(_minItemSize, aSize))
@@ -755,8 +812,8 @@ var HORIZONTAL_MARGIN = 2;
- (void)mouseUp:(CPEvent)anEvent
{
if ([_selectionIndexes count] && [anEvent clickCount] == 2 && [_delegate respondsToSelector:@selector(collectionView:didDoubleClickOnItemAtIndex:)])
[_delegate collectionView:self didDoubleClickOnItemAtIndex:[_selectionIndexes firstIndex]];
if ([_selectionIndexes count] && [anEvent clickCount] == 2)
[self _sendDelegateDidDoubleClickOnItemAtIndex:[_selectionIndexes firstIndex]];
}
- (void)mouseDown:(CPEvent)anEvent
@@ -784,6 +841,10 @@ var HORIZONTAL_MARGIN = 2;
var firstSelectedIndex = [[self selectionIndexes] firstIndex],
newSelectedRange = nil;
// This catches the case where the shift key is held down for the first selection.
if (firstSelectedIndex === CPNotFound)
firstSelectedIndex = index;
if (index < firstSelectedIndex)
newSelectedRange = CPMakeRange(index, (firstSelectedIndex - index) + 1);
else
@@ -826,7 +887,7 @@ var HORIZONTAL_MARGIN = 2;
[self tile];
}
- (void)setUniformSubviewsResizing:(float)flag
- (void)setUniformSubviewsResizing:(BOOL)flag
{
_uniformSubviewsResizing = flag;
[self tileIfNeeded:NO];
@@ -842,15 +903,6 @@ var HORIZONTAL_MARGIN = 2;
return _verticalMargin;
}
/*!
Sets the collection view's delegate
@param aDelegate the new delegate
*/
- (void)setDelegate:(id)aDelegate
{
_delegate = aDelegate;
}
/*!
Returns the collection view's delegate
*/
@@ -864,13 +916,13 @@ var HORIZONTAL_MARGIN = 2;
*/
- (CPMenu)menuForEvent:(CPEvent)theEvent
{
if (![[self delegate] respondsToSelector:@selector(collectionView:menuForItemAtIndex:)])
if (![self _delegateRespondsToCollectionViewMenuForItemAtIndex])
return [super menuForEvent:theEvent];
var location = [self convertPoint:[theEvent locationInWindow] fromView:nil],
index = [self _indexAtPoint:location];
return [_delegate collectionView:self menuForItemAtIndex:index];
return [self _sendDelegateMenuForItemAtIndex:index];
}
- (int)_indexAtPoint:(CGPoint)thePoint
@@ -888,12 +940,12 @@ var HORIZONTAL_MARGIN = 2;
return CPNotFound;
}
- (CPCollectionViewItem)itemAtIndex:(unsigned)anIndex
- (CPCollectionViewItem)itemAtIndex:(CPUInteger)anIndex
{
return [_items objectAtIndex:anIndex];
}
- (CGRect)frameForItemAtIndex:(unsigned)anIndex
- (CGRect)frameForItemAtIndex:(CPUInteger)anIndex
{
return [[[self itemAtIndex:anIndex] view] frame];
}
@@ -914,6 +966,20 @@ var HORIZONTAL_MARGIN = 2;
return frame;
}
- (void)_applySelectionToItems:(BOOL)select
{
var numberOfItems = [_items count];
[_selectionIndexes enumerateIndexesUsingBlock:function(idx, stop)
{
if (idx < numberOfItems)
[[_items objectAtIndex:idx] setSelected:select];
else {
stop(YES);
}
}];
}
@end
@implementation CPCollectionView (DragAndDrop)
@@ -928,7 +994,7 @@ var HORIZONTAL_MARGIN = 2;
*/
- (void)pasteboard:(CPPasteboard)aPasteboard provideDataForType:(CPString)aType
{
[aPasteboard setData:[_delegate collectionView:self dataForItemsAtIndexes:_selectionIndexes forType:aType] forType:aType];
[aPasteboard setData:[self _sendDelegateDataForItemsAtIndexes:_selectionIndexes forType:aType] forType:aType];
}
- (void)_createDropIndicatorIfNeeded
@@ -958,24 +1024,23 @@ var HORIZONTAL_MARGIN = 2;
(ABS(locationInWindow.y - mouseDownLocationInWindow.y) < 3))
return;
if (![_delegate respondsToSelector:@selector(collectionView:dragTypesForItemsAtIndexes:)])
if (![self _delegateRespondsToCollectionViewDragTypesForItemsAtIndexes])
return;
// If we don't have any selected items, we've clicked away, and thus the drag is meaningless.
if (![_selectionIndexes count])
return;
if ([_delegate respondsToSelector:@selector(collectionView:canDragItemsAtIndexes:withEvent:)] &&
![_delegate collectionView:self canDragItemsAtIndexes:_selectionIndexes withEvent:_mouseDownEvent])
if (![self _sendDelegateCanDragItemsAtIndexes:_selectionIndexes withEvent:_mouseDownEvent])
return;
// Set up the pasteboard
var dragTypes = [_delegate collectionView:self dragTypesForItemsAtIndexes:_selectionIndexes];
var dragTypes = [self _sendDelegateDragTypesForItemsAtIndexes:_selectionIndexes];
[[CPPasteboard pasteboardWithName:CPDragPboard] declareTypes:dragTypes owner:self];
var dragImageOffset = CGSizeMakeZero(),
view = [self _draggingViewForItemsAtIndexes:_selectionIndexes withEvent:_mouseDownEvent offset:dragImageOffset];
view = [self _sendDelegateDraggingViewForItemsAtIndexes:_selectionIndexes withEvent:_mouseDownEvent offset:dragImageOffset];
[view setFrameSize:_itemSize];
[view setAlphaValue:0.7];
@@ -992,14 +1057,6 @@ var HORIZONTAL_MARGIN = 2;
slideBack:YES];
}
- (CPView)_draggingViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)anEvent offset:(CGPoint)offset
{
if ([_delegate respondsToSelector:@selector(collectionView:draggingViewForItemsAtIndexes:withEvent:offset:)])
return [_delegate collectionView:self draggingViewForItemsAtIndexes:indexes withEvent:anEvent offset:offset];
return [self draggingViewForItemsAtIndexes:indexes withEvent:anEvent offset:offset];
}
- (CPView)draggingViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)event offset:(CGPoint)dragImageOffset
{
var idx = _content[[indexes firstIndex]];
@@ -1012,14 +1069,6 @@ var HORIZONTAL_MARGIN = 2;
return [_itemForDragging view];
}
- (BOOL)_canDragItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)anEvent
{
if ([self respondsToSelector:@selector(collectionView:canDragItemsAtIndexes:withEvent:)])
return [_delegate collectionView:self canDragItemsAtIndexes:indexes withEvent:anEvent];
return YES;
}
- (CPDragOperation)draggingEntered:(id)draggingInfo
{
var dropIndex = -1,
@@ -1057,16 +1106,14 @@ var HORIZONTAL_MARGIN = 2;
var result = CPDragOperationMove,
dropIndex = [self _dropIndexForDraggingInfo:draggingInfo proposedDropOperation:dropOperation];
if ([_delegate respondsToSelector:@selector(collectionView:validateDrop:proposedIndex:dropOperation:)])
if ([self _delegateRespondsToCollectionViewValidateDropProposedIndexDropOperation])
{
var dropIndexRef2 = @ref(dropIndex);
result = [_delegate collectionView:self validateDrop:draggingInfo proposedIndex:dropIndexRef2 dropOperation:dropOperation];
result = [self _sendDelegateValidateDrop:draggingInfo proposedIndex:dropIndexRef2 dropOperation:dropOperation];
if (result !== CPDragOperationNone)
{
dropIndex = dropIndexRef2();
}
}
dropIndexRef(dropIndex);
@@ -1100,7 +1147,7 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
var result = NO;
if (_currentDragOperation && _currentDropIndex !== -1)
result = [_delegate collectionView:self acceptDrop:draggingInfo index:_currentDropIndex dropOperation:1];
result = [self _sendDelegateAcceptDrop:draggingInfo index:_currentDropIndex dropOperation:1];
[self draggingEnded:draggingInfo]; // Is this correct ?
@@ -1318,13 +1365,14 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
[self interpretKeyEvents:[anEvent]];
}
- (void)setAutoresizingMask:(int)aMask
- (void)setAutoresizingMask:(unsigned)aMask
{
[super setAutoresizingMask:0];
}
@end
@implementation CPCollectionView (Deprecated)
- (CGRect)rectForItemAtIndex:(int)anIndex
@@ -1345,6 +1393,148 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
@end
@implementation CPCollectionView (CPCollectionViewDelegate)
/*
@ignore
Return YES if the delegate implements collectionView:validateDrop:proposedIndex:dropOperation:
*/
- (BOOL)_delegateRespondsToCollectionViewValidateDropProposedIndexDropOperation
{
return _implementedDelegateMethods & CPCollectionViewDelegate_collectionView_validateDrop_proposedIndex_dropOperation_;
}
/*
@ignore
Return YES if the delegate implements collectionView:menuForItemAtIndex:
*/
- (BOOL)_delegateRespondsToCollectionViewMenuForItemAtIndex
{
return _implementedDelegateMethods & CPCollectionViewDelegate_collectionView_menuForItemAtIndex_;
}
/*
@ignore
Return YES if the delegate implements collectionView:dragTypesForItemsAtIndexes:
*/
- (BOOL)_delegateRespondsToCollectionViewDragTypesForItemsAtIndexes
{
return _implementedDelegateMethods & CPCollectionViewDelegate_collectionView_dragTypesForItemsAtIndexes_;
}
/*!
@ignore
Call delegate collectionView:acceptDrop:index:dropOperation:
*/
- (BOOL)_sendDelegateAcceptDrop:(id)draggingInfo index:(CPInteger)index dropOperation:(CPCollectionViewDropOperation)dropOperation
{
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_))
return NO;
return [_delegate collectionView:self acceptDrop:draggingInfo index:index dropOperation:dropOperation];
}
/*!
@ignore
Call delegate collectionView:canDragItemsAtIndexes:withEvent:
*/
- (BOOL)_sendDelegateCanDragItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)anEvent
{
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_canDragItemsAtIndexes_withEvent_))
return YES;
return [_delegate collectionView:self canDragItemsAtIndexes:indexes withEvent:anEvent];
}
/*!
@ignore
Call delegate collectionView:writeItemsAtIndexes:toPasteboard:
*/
- (BOOL)_sendDelegateWriteItemsAtIndexes:(CPIndexSet)indexes toPasteboard:(CPPasteboard)pasteboard
{
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_writeItemsAtIndexes_toPasteboard_))
return NO;
return [_delegate collectionView:self writeItemsAtIndexes:indexes toPasteboard:pasteboard];
}
/*!
@ignore
Call delegate collectionView:dragTypesForItemsAtIndexes:
*/
- (CPArray)_sendDelegateDragTypesForItemsAtIndexes:(CPIndexSet)indexes
{
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_dragTypesForItemsAtIndexes_))
return [];
return [_delegate collectionView:self dragTypesForItemsAtIndexes:indexes];
}
/*!
@ignore
Call delegate collectionView:dataForItemsAtIndexes:forType:
*/
- (CPData)_sendDelegateDataForItemsAtIndexes:(CPIndexSet)indexes forType:(CPString)aType
{
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_dataForItemsAtIndexes_forType_))
return nil;
return [_delegate collectionView:self dataForItemsAtIndexes:indexes forType:aType];
}
/*!
@ignore
Call delegate collectionView:validateDrop:proposedIndex:dropOperation:
*/
- (CPDragOperation)_sendDelegateValidateDrop:(id)draggingInfo proposedIndex:(CPInteger)proposedDropIndex dropOperation:(CPCollectionViewDropOperation)proposedDropOperation
{
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_validateDrop_proposedIndex_dropOperation_))
return CPDragOperationNone;
return [_delegate collectionView:self validateDrop:draggingInfo proposedIndex:proposedDropIndex dropOperation:proposedDropOperation];
}
/*!
@ignore
Call delegate collectionView:didDoubleClickOnItemAtIndex:
*/
- (void)_sendDelegateDidDoubleClickOnItemAtIndex:(int)index
{
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_didDoubleClickOnItemAtIndex_))
return;
return [_delegate collectionView:self didDoubleClickOnItemAtIndex:index];
}
/*!
@ignore
Call delegate collectionView:menuForItemAtIndex:
*/
- (void)_sendDelegateMenuForItemAtIndex:(CPInteger)anIndex
{
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_menuForItemAtIndex_))
return nil;
return [_delegate collectionView:self menuForItemAtIndex:anIndex];
}
/*!
@ignore
Call delegate draggingViewForItemsAtIndexes:withEvent:offset:
*/
- (CPView)_sendDelegateDraggingViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)anEvent offset:(CGPoint)dragImageOffset
{
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_draggingViewForItemsAtIndexes_withEvent_offset))
return [self draggingViewForItemsAtIndexes:indexes withEvent:anEvent offset:dragImageOffset];
return [_delegate collectionView:self draggingViewForItemsAtIndexes:indexes withEvent:anEvent offset:dragImageOffset];
}
@end
var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey",
CPCollectionViewMaxItemSizeKey = @"CPCollectionViewMaxItemSizeKey",
CPCollectionViewVerticalMarginKey = @"CPCollectionViewVerticalMarginKey",
@@ -1404,3 +1594,14 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeK
}
@end
@implementation _CPCollectionViewContentBinder : CPBinder
{
}
- (void)setValue:(id)aValue forBinding:(CPString)aBinding
{
[_source setContent:aValue];
}
@end
+309 -11
View File
@@ -25,6 +25,7 @@
@import "CGColor.j"
@import "_CPObject+Theme.j"
@import "CPCompatibility.j"
@import "CPImage.j"
@@ -65,7 +66,8 @@ var cachedBlackColor,
cachedOrangeColor,
cachedPurpleColor,
cachedShadowColor,
cachedClearColor;
cachedClearColor,
cachedThemeColor;
/// @endcond
@@ -78,13 +80,37 @@ var cachedBlackColor,
<p>It also provides some class helper methods that
returns instances of commonly used colors.</p>
*/
@implementation CPColor : CPObject
@implementation CPColor : CPObject <CPTheme>
{
CPArray _components;
CPImage _patternImage;
CPString _cssString;
}
@global document
#pragma mark -
#pragma mark Theming
+ (CPString)defaultThemeClass
{
return "color";
}
+ (CPDictionary)themeAttributes
{
return @{
@"alternate-selected-control-color": [CPNull null],
@"secondary-selected-control-color": [CPNull null],
@"selected-text-background-color": [CPNull null],
@"selected-text-inactive-background-color": [CPNull null],
@"css-based": NO
};
}
#pragma mark -
#pragma mark Static methods
/*!
Creates a color in the RGB colorspace, with an alpha value.
@@ -241,7 +267,7 @@ var cachedBlackColor,
@return an initialized RGB color
*/
+ (CPColor)colorWithHexString:(string)hex
+ (CPColor)colorWithHexString:(CPString)hex
{
var rgba = hexToRGB(hex);
return rgba ? [[CPColor alloc] _initWithRGBA: rgba] : null;
@@ -436,14 +462,22 @@ var cachedBlackColor,
return cachedClearColor;
}
+ (CPColor)_cachedThemeColor
{
if (!cachedThemeColor)
cachedThemeColor = [self colorWithCalibratedWhite:0.0 alpha:0.0];
return cachedThemeColor;
}
+ (CPColor)alternateSelectedControlColor
{
return [[CPColor alloc] _initWithRGBA:[0.22, 0.46, 0.84, 1.0]];
return [[self _cachedThemeColor] valueForThemeAttribute:@"alternate-selected-control-color"];
}
+ (CPColor)secondarySelectedControlColor
{
return [[CPColor alloc] _initWithRGBA:[0.83, 0.83, 0.83, 1.0]];
return [[self _cachedThemeColor] valueForThemeAttribute:@"secondary-selected-control-color"];
}
/*!
@@ -467,6 +501,16 @@ var cachedBlackColor,
return [[CPColor alloc] _initWithCSSString: aString];
}
+ (CPColor)selectedTextBackgroundColor
{
return [[self _cachedThemeColor] valueForThemeAttribute:@"selected-text-background-color"] || [CPColor colorWithHexString:"99CCFF"];
}
+ (CPColor)_selectedTextBackgroundColorUnfocussed
{
return [[self _cachedThemeColor] valueForThemeAttribute:@"selected-text-inactive-background-color"] || [CPColor colorWithHexString:"CCCCCC"];
}
/* @ignore */
- (id)_initWithCSSString:(CPString)aString
{
@@ -489,6 +533,10 @@ var cachedBlackColor,
// use it (issue #1413.)
[self _initCSSStringFromComponents];
_theme = [CPTheme defaultTheme];
_themeState = CPThemeStateNormal;
[self _loadThemeAttributes];
return self;
}
@@ -502,6 +550,10 @@ var cachedBlackColor,
_components = components;
[self _initCSSStringFromComponents];
_theme = [CPTheme defaultTheme];
_themeState = CPThemeStateNormal;
[self _loadThemeAttributes];
}
return self;
@@ -509,7 +561,11 @@ var cachedBlackColor,
- (void)_initCSSStringFromComponents
{
var hasAlpha = CPFeatureIsCompatible(CPCSSRGBAFeature) && _components[3] != 1.0;
// Fix to avoid a problem when compiling a theme (missing the alpha component as theme compiler doesn't have CSS rgba capability)
var hasAlpha = YES;
#if PLATFORM(DOM)
hasAlpha = CPFeatureIsCompatible(CPCSSRGBAFeature) && _components[3] != 1.0;
#endif
_cssString = (hasAlpha ? "rgba(" : "rgb(") +
parseInt(_components[0] * 255.0) + ", " +
@@ -528,6 +584,10 @@ var cachedBlackColor,
_patternImage = anImage;
_cssString = "url(\"" + [_patternImage filename] + "\")";
_components = [0.0, 0.0, 0.0, 1.0];
_theme = [CPTheme defaultTheme];
_themeState = CPThemeStateNormal;
[self _loadThemeAttributes];
}
return self;
@@ -744,6 +804,9 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image
var description = [super description],
patternImage = [self patternImage];
if ([self isCSSBased])
return description + "\n" + [self cssDictionary]+ "\nBefore:\n" + [self cssBeforeDictionary] + "\nAfter:\n" + [self cssAfterDictionary];
if (!patternImage)
return description + " " + [self cssString];
@@ -813,11 +876,229 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image
return [CPColor colorWithRed:RAND() green:RAND() blue:RAND() alpha:1.0];
}
+ (CPColor)checkerBoardColor
{
// Thanks to cocco http://stackoverflow.com/a/18368212/76900.
return [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEX////MzMw46qqDAAAAEElEQVQImWNg+M+AFeEQBgB+vw/xfUUZkgAAAABJRU5ErkJggg=="]];
}
@end
#pragma mark -
#pragma mark CSS Theming
// The code below adds support for CSS theming with 100% compatibility with current theming system.
// The idea is to extend CPColor (and CPImage) with CSS components and adapt low level UI components to
// support this new kind of CPColor/CPImage. See CPImageView, CPView and _CPImageAndTextView.
//
// To create a CPColor that uses CSS, simply use the new class method :
// + (CPColor)colorWithCSSDictionary:(CPDictionary)aDictionary beforeDictionary:(CPDictionary)beforeDictionary afterDictionary:(CPDictionary)afterDictionary
// where beforeDictionary & afterDictionary are related to ::before & ::after pseudo-elements.
// If you don't need them, just use the simplified class method :
// + (CPColor)colorWithCSSDictionary:(CPDictionary)aDictionary
//
// Example :
// buttonCssColor = [CPColor colorWithCSSDictionary:@{
// @"background-color": A3ColorBackgroundWhite,
// @"border-color": A3ColorActiveBorder,
// @"border-style": @"solid",
// @"border-width": @"1px",
// @"border-radius": @"3px",
// @"box-sizing": @"border-box"
// }
// beforeDictionary:@{
// @"background-color": @"rgb(225,225,225)",
// @"bottom": @"3px",
// @"content": @"''",
// @"position": @"absolute",
// @"right": @"21px",
// @"top": @"3px",
// @"width": @"1px"
// }
// afterDictionary:@{
// @"content": @"''",
// @"bottom": @"3px",
// @"right": @"6px",
// @"top": @"1px",
// @"position": @"absolute",
// @"height": @"14px",
// @"width": @"9px",
// @"margin": @"2px 0px 2px 0px",
// @"background-image": @"url(%%packed.png)",
// @"background-position": @"0px -64px",
// @"background-repeat": @"no-repeat",
// @"background-size": @"100px 400px"
// }];
//
// Remark : Please note the special URL of the background image used in this example : url(%%packed.png)
// During theme loading, "%%" will be replaced by the path to the theme blend resources folder.
// Typically, a CSS theme will use some (rare) images all packed together in a single image resource (see packed.png in Aristo3 theme)
//
// Also, please note that if you don't use one of the CSS components, you can either set it to nil (best solution) or to an empty dictionary, like :
// aCssColor = [CPColor colorWithCSSDictionary:@{} beforeDictionary:nil afterDictionary:@{ ... }];
//
// You can use -(BOOL)isCSSBased to determine how to cope with it in your code.
// -(BOOL)hasCSSDictionary, -(BOOL)hasCSSBeforeDictionary and -(BOOL)hasCSSAfterDictionary are convience methods you can use.
//
// Remark : +(void)restorePreviousCSSState and -(DOMElement)applyCSSColorForView are meant to be used by low level UI widgets (like CPView) to implement
// CSS theme support.
@implementation CPColor (CSSTheming)
{
CPDictionary _cssDictionary @accessors(property=cssDictionary);
CPDictionary _cssBeforeDictionary @accessors(property=cssBeforeDictionary);
CPDictionary _cssAfterDictionary @accessors(property=cssAfterDictionary);
}
+ (CPColor)colorWithCSSDictionary:(CPDictionary)aDictionary
{
return [[CPColor alloc] _initWithCSSDictionary:aDictionary beforeDictionary:nil afterDictionary:nil];
}
+ (CPColor)colorWithCSSDictionary:(CPDictionary)aDictionary beforeDictionary:(CPDictionary)beforeDictionary afterDictionary:(CPDictionary)afterDictionary
{
return [[CPColor alloc] _initWithCSSDictionary:aDictionary beforeDictionary:beforeDictionary afterDictionary:afterDictionary];
}
- (id)_initWithCSSDictionary:(CPDictionary)aDictionary beforeDictionary:(CPDictionary)beforeDictionary afterDictionary:(CPDictionary)afterDictionary
{
self = [super init];
if (self)
{
_cssDictionary = aDictionary;
_cssBeforeDictionary = beforeDictionary;
_cssAfterDictionary = afterDictionary;
_components = [0.0, 0.0, 0.0, 1.0];
_theme = [CPTheme defaultTheme];
_themeState = CPThemeStateNormal;
[self _loadThemeAttributes];
}
return self;
}
- (BOOL)isCSSBased
{
return !!(_cssDictionary || _cssBeforeDictionary || _cssAfterDictionary);
}
- (BOOL)hasCSSDictionary
{
return ([_cssDictionary count] > 0);
}
- (BOOL)hasCSSBeforeDictionary
{
return ([_cssBeforeDictionary count] > 0);
}
- (BOOL)hasCSSAfterDictionary
{
return ([_cssAfterDictionary count] > 0);
}
+ (void)restorePreviousCSSState:(CPArrayRef)aPreviousStateRef forDOMElement:(DOMElement)aDOMElement
{
#if PLATFORM(DOM)
var aPreviousState = @deref(aPreviousStateRef);
for (var i = 0, count = aPreviousState.length; i < count; i++)
aDOMElement.style[aPreviousState[i][0]] = aPreviousState[i][1];
@deref(aPreviousStateRef) = @[];
#endif
}
- (DOMElement)applyCSSColorForView:(CPView)aView onDOMElement:(DOMElement)aDOMElement styleNode:(DOMElement)aStyleNode previousState:(CPArrayRef)aPreviousStateRef
{
#if PLATFORM(DOM)
var aPreviousState = @deref(aPreviousStateRef);
[_cssDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
{
[aPreviousState addObject:@[aKey, aDOMElement.style[aKey]]];
aDOMElement.style[aKey] = anObject;
}];
if ([self hasCSSBeforeDictionary] || [self hasCSSAfterDictionary])
{
// We need to create a unique class name
var styleClassName = @".CP" + [aView UID],
styleContent = @"";
if ([self hasCSSBeforeDictionary])
{
styleContent += styleClassName + @"::before { ";
[_cssBeforeDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
{
styleContent += aKey + ": " + anObject + "; ";
}];
styleContent += "} ";
}
if ([self hasCSSAfterDictionary])
{
styleContent += styleClassName + @"::after { ";
[_cssAfterDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
{
styleContent += aKey + ": " + anObject + "; ";
}];
styleContent += "} ";
}
var styleDescription = document.createTextNode(styleContent);
if (!aStyleNode)
{
aStyleNode = document.createElement("style");
aView._DOMElement.insertBefore(aStyleNode, aView._DOMElement.firstChild);
aStyleNode.appendChild(styleDescription);
}
else
{
aStyleNode.replaceChild(styleDescription, aStyleNode.firstChild);
}
[aView setDOMClassName:@"CP"+[aView UID]];
}
else
{
// no before/after so remove aStyleNode if existing
if (aStyleNode)
{
aView._DOMElement.removeChild(aStyleNode);
aStyleNode = nil;
}
}
// Return actualised values
@deref(aPreviousStateRef) = aPreviousState;
return aStyleNode;
#endif
}
@end
#pragma mark -
/// @cond IGNORE
var CPColorComponentsKey = @"CPColorComponentsKey",
CPColorPatternImageKey = @"CPColorPatternImageKey";
var CPColorComponentsKey = @"CPColorComponentsKey",
CPColorPatternImageKey = @"CPColorPatternImageKey",
CPColorCssDictionaryKey = @"CPColorCssDictionaryKey",
CPColorCssBeforeDictionaryKey = @"CPColorCssBeforeDictionaryKey",
CPColorCssAfterDictionaryKey = @"CPColorCssAfterDictionaryKey";
/// @endcond
@implementation CPColor (CPCoding)
@@ -829,9 +1110,17 @@ var CPColorComponentsKey = @"CPColorComponentsKey",
- (id)initWithCoder:(CPCoder)aCoder
{
if ([aCoder containsValueForKey:CPColorPatternImageKey])
return [self _initWithPatternImage:[aCoder decodeObjectForKey:CPColorPatternImageKey]];
self = [self _initWithPatternImage:[aCoder decodeObjectForKey:CPColorPatternImageKey]];
else if ([aCoder containsValueForKey:CPColorCssDictionaryKey])
self = [self _initWithCSSDictionary:[aCoder decodeObjectForKey:CPColorCssDictionaryKey]
beforeDictionary:[aCoder decodeObjectForKey:CPColorCssBeforeDictionaryKey]
afterDictionary:[aCoder decodeObjectForKey:CPColorCssAfterDictionaryKey]];
else
self = [self _initWithRGBA:[aCoder decodeObjectForKey:CPColorComponentsKey]];
return [self _initWithRGBA:[aCoder decodeObjectForKey:CPColorComponentsKey]];
[self _decodeThemeObjectsWithCoder:aCoder];
return self;
}
/*!
@@ -842,8 +1131,16 @@ var CPColorComponentsKey = @"CPColorComponentsKey",
{
if (_patternImage)
[aCoder encodeObject:_patternImage forKey:CPColorPatternImageKey];
else if (_cssDictionary)
{
[aCoder encodeObject:_cssDictionary forKey:CPColorCssDictionaryKey];
[aCoder encodeObject:_cssBeforeDictionary forKey:CPColorCssBeforeDictionaryKey];
[aCoder encodeObject:_cssAfterDictionary forKey:CPColorCssAfterDictionaryKey];
}
else
[aCoder encodeObject:_components forKey:CPColorComponentsKey];
[self _encodeThemeObjectsWithCoder:aCoder];
}
@end
@@ -1180,7 +1477,8 @@ var patternColorsFromPattern = function(pattern, attributes, imageFactory)
bottomHeight,
centerWidthHeight,
centerIsNil,
numParts;
numParts,
isVertical;
// positions are mandatory
if (pattern.indexOf("{position}") < 0)
+10 -9
View File
@@ -27,6 +27,9 @@
@import "CPView.j"
@class CPSlider
@class _CPColorPanelToolbar
@class _CPColorPanelSwatches
@class _CPColorPanelPreview
@global CPApp
@@ -68,7 +71,6 @@ var SharedColorPanel = nil,
*/
@implementation CPColorPanel : CPPanel
{
_CPColorPanelToolbar _toolbar;
_CPColorPanelSwatches _swatchView;
_CPColorPanelPreview _previewView;
@@ -481,13 +483,12 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
];
}
var cookieValue = eval(cookieValue),
result = [];
var cookieValue = JSON.parse(cookieValue);
for (var i = 0; i < cookieValue.length; i++)
result.push([CPColor colorWithHexString:cookieValue[i]]);
return result;
return [cookieValue arrayByApplyingBlock:function(value)
{
return [CPColor colorWithHexString:value];
}];
}
- (CPArray)saveColorList
@@ -576,7 +577,7 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
[aPasteboard setData:[CPKeyedArchiver archivedDataWithRootObject:_dragColor] forType:aType];
}
- (void)performDragOperation:(id <CPDraggingInfo>)aSender
- (void)performDragOperation:(id /*<CPDraggingInfo>*/)aSender
{
var location = [self convertPoint:[aSender draggingLocation] fromView:nil],
pasteboard = [aSender draggingPasteboard],
@@ -615,7 +616,7 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
return _colorPanel;
}
- (void)performDragOperation:(id <CPDraggingInfo>)aSender
- (void)performDragOperation:(id /*<CPDraggingInfo>*/)aSender
{
var pasteboard = [aSender draggingPasteboard];
+5 -2
View File
@@ -25,6 +25,8 @@
@import "CPView.j"
@class CPSlider
@class CPColorPanel
@class __CPColorWheel
@global CPColorPickerViewWidth
@global CPColorPickerViewHeight
@@ -123,7 +125,8 @@
_brightnessSlider = [[CPSlider alloc] initWithFrame:CGRectMake(0, (aFrame.size.height - 34), aFrame.size.width, 15)];
[_brightnessSlider setValue:15.0 forThemeAttribute:@"track-width"];
[_brightnessSlider setValue:[CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPColorPicker class]] pathForResource:@"brightness_bar.png"]]] forThemeAttribute:@"track-color"];
var brightnessImage = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPColorPicker class]] pathForResource:@"brightness_bar.png"] size:CGSizeMake(272, 20)];
[_brightnessSlider setValue:[CPColor colorWithPatternImage:brightnessImage] forThemeAttribute:@"track-color"];
[_brightnessSlider setMinValue:0.0];
[_brightnessSlider setMaxValue:100.0];
@@ -244,7 +247,7 @@
_blackWheelImage = new Image();
_blackWheelImage.src = path;
_blackWheelImage.style.opacity = "0";
_blackWheelImage.style.filter = "alpha(opacity=0)"
_blackWheelImage.style.filter = "alpha(opacity=0)";
_blackWheelImage.style.position = "absolute";
_DOMElement.appendChild(_wheelImage);
+42 -6
View File
@@ -58,7 +58,7 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
return @"colorwell";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"bezel-inset": CGInsetMakeZero(),
@@ -86,14 +86,12 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
_active = NO;
_color = [CPColor whiteColor];
[self setBordered:YES];
[self _registerForNotifications];
}
return self;
}
- (void)_registerForNotifications
- (void)_registerNotifications
{
var defaultCenter = [CPNotificationCenter defaultCenter];
@@ -110,6 +108,22 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
object:[CPColorPanel sharedColorPanel]];
}
- (void)_removeNotifications
{
var defaultCenter = [CPNotificationCenter defaultCenter];
[defaultCenter
removeObserver:self
name:_CPColorWellDidBecomeExclusiveNotification
object:nil];
[defaultCenter
removeObserver:self
name:CPWindowWillCloseNotification
object:[CPColorPanel sharedColorPanel]];
}
/*!
Sets whether the color well is bordered.
*/
@@ -241,6 +255,8 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
var colorPanel = [CPColorPanel sharedColorPanel];
[colorPanel setPlatformWindow:[[self window] platformWindow]];
[colorPanel setColor:_color];
[colorPanel orderFront:self];
}
@@ -312,6 +328,28 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
[contentBorderView setBackgroundColor:[self currentValueForThemeAttribute:@"content-border-color"]];
}
#pragma mark -
#pragma mark Observers method
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[self _registerNotifications];
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[self _removeNotifications];
}
@end
@implementation CPColorWellValueBinder : CPBinder
@@ -363,8 +401,6 @@ var CPColorWellColorKey = "CPColorWellColorKey",
_active = NO;
_color = [aCoder decodeObjectForKey:CPColorWellColorKey];
[self setBordered:[aCoder decodeBoolForKey:CPColorWellBorderedKey]];
[self _registerForNotifications];
}
return self;
+183 -82
View File
@@ -25,6 +25,27 @@
@import "_CPPopUpList.j"
// TODO : should conform to protocol CPTextFieldDelegate
@protocol CPComboBoxDelegate <CPObject>
@optional
- (void)comboBoxSelectionIsChanging:(CPNotification)aNotification;
- (void)comboBoxSelectionDidChange:(CPNotification)aNotification;
- (void)comboBoxWillPopUp:(CPNotification)aNotification;
- (void)comboBoxWillDismiss:(CPNotification)aNotification;
@end
@protocol CPComboBoxDataSource <CPObject>
@optional
- (CPString)comboBox:(CPComboBox)aComboBox completedString:(CPString)uncompletedString;
- (id)comboBox:(CPComboBox)aComboBox objectValueForItemAtIndex:(int)index;
- (int)comboBox:(CPComboBox)aComboBox indexOfItemWithStringValue:(CPString)stringValue;
- (int)numberOfItemsInComboBox:(CPComboBox)aComboBox;
@end
CPComboBoxSelectionDidChangeNotification = @"CPComboBoxSelectionDidChangeNotification";
CPComboBoxSelectionIsChangingNotification = @"CPComboBoxSelectionIsChangingNotification";
CPComboBoxWillDismissNotification = @"CPComboBoxWillDismissNotification";
@@ -32,6 +53,11 @@ CPComboBoxWillPopUpNotification = @"CPComboBoxWillPopUpNotification";
CPComboBoxStateButtonBordered = CPThemeState("button-bordered");
var CPComboBoxDelegate_comboBoxSelectionIsChanging_ = 1 << 0,
CPComboBoxDelegate_comboBoxSelectionDidChange_ = 1 << 1,
CPComboBoxDelegate_comboBoxWillPopUp_ = 1 << 2,
CPComboBoxDelegate_comboBoxWillDismiss_ = 1 << 3;
var CPComboBoxTextSubview = @"text",
CPComboBoxButtonSubview = @"button",
CPComboBoxDefaultNumberOfVisibleItems = 5,
@@ -40,17 +66,20 @@ var CPComboBoxTextSubview = @"text",
@implementation CPComboBox : CPTextField
{
CPArray _items;
_CPPopUpList _listDelegate;
CPComboBoxDataSource _dataSource;
BOOL _usesDataSource;
BOOL _completes;
BOOL _canComplete;
int _numberOfVisibleItems;
BOOL _forceSelection;
BOOL _hasVerticalScroller;
CPString _selectedStringValue;
BOOL _popUpButtonCausedResign;
BOOL _canComplete;
BOOL _completes;
BOOL _forceSelection;
BOOL _hasVerticalScroller;
BOOL _popUpButtonCausedResign;
BOOL _usesDataSource;
CGSize _intercellSpacing;
CPArray _items;
id <CPComboBoxDataSource> _dataSource;
CPInteger _implementedDelegateComboBoxMethods;
CPString _selectedStringValue;
float _itemHeight;
int _numberOfVisibleItems;
_CPPopUpList _listDelegate;
}
+ (CPString)defaultThemeClass
@@ -58,7 +87,7 @@ var CPComboBoxTextSubview = @"text",
return "combobox";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"popup-button-size": CGSizeMake(21.0, 29.0),
@@ -119,7 +148,9 @@ var CPComboBoxTextSubview = @"text",
return;
_hasVerticalScroller = flag;
[[_listDelegate scrollView] setHasVerticalScroller:flag];
if (_listDelegate)
[[_listDelegate scrollView] setHasVerticalScroller:_hasVerticalScroller];
}
- (CGSize)intercellSpacing
@@ -129,7 +160,13 @@ var CPComboBoxTextSubview = @"text",
- (void)setIntercellSpacing:(CGSize)aSize
{
[[_listDelegate tableView] setIntercellSpacing:aSize];
if (_intercellSpacing && CGSizeEqualToSize(aSize, _intercellSpacing))
return;
_intercellSpacing = aSize;
if (_listDelegate)
[[_listDelegate tableView] setIntercellSpacing:_intercellSpacing];
}
- (BOOL)isButtonBordered
@@ -152,10 +189,18 @@ var CPComboBoxTextSubview = @"text",
- (void)setItemHeight:(float)itemHeight
{
[[_listDelegate tableView] setRowHeight:itemHeight];
if (itemHeight === _itemHeight)
return;
// FIXME: This shouldn't be necessary, but CPTableView does not tile after setRowHeight
[[_listDelegate tableView] reloadData];
_itemHeight = itemHeight;
if (_listDelegate)
{
[[_listDelegate tableView] setRowHeight:_itemHeight];
// FIXME: This shouldn't be necessary, but CPTableView does not tile after setRowHeight
[[_listDelegate tableView] reloadData];
}
}
- (int)numberOfVisibleItems
@@ -171,7 +216,7 @@ var CPComboBoxTextSubview = @"text",
#pragma mark Setting a Delegate
- (id < CPComboBoxDelegate >)delegate
- (id <CPComboBoxDelegate>)delegate
{
return [super delegate];
}
@@ -182,48 +227,28 @@ var CPComboBoxTextSubview = @"text",
protocol, in actual fact it doesn't. Also note that the same
delegate may conform to the NSTextFieldDelegate protocol.
*/
- (void)setDelegate:(id < CPComboBoxDelegate >)aDelegate
- (void)setDelegate:(id <CPComboBoxDelegate>)aDelegate
{
var delegate = [self delegate];
if (aDelegate === delegate)
return;
var defaultCenter = [CPNotificationCenter defaultCenter];
if (delegate)
{
[defaultCenter removeObserver:delegate name:CPComboBoxSelectionIsChangingNotification object:self];
[defaultCenter removeObserver:delegate name:CPComboBoxSelectionDidChangeNotification object:self];
[defaultCenter removeObserver:delegate name:CPComboBoxWillDismissNotification object:self];
[defaultCenter removeObserver:delegate name:CPComboBoxWillPopUpNotification object:self];
}
_implementedDelegateComboBoxMethods = 0;
if (aDelegate)
{
if ([aDelegate respondsToSelector:@selector(comboBoxSelectionIsChanging:)])
[defaultCenter addObserver:delegate
selector:@selector(comboBoxSelectionIsChanging:)
name:CPComboBoxSelectionIsChangingNotification
object:self];
_implementedDelegateComboBoxMethods |= CPComboBoxDelegate_comboBoxSelectionIsChanging_;
if ([aDelegate respondsToSelector:@selector(comboBoxSelectionDidChange:)])
[defaultCenter addObserver:delegate
selector:@selector(comboBoxSelectionDidChange:)
name:CPComboBoxSelectionDidChangeNotification
object:self];
_implementedDelegateComboBoxMethods |= CPComboBoxDelegate_comboBoxSelectionDidChange_;
if ([aDelegate respondsToSelector:@selector(comboBoxWillPopUp:)])
[defaultCenter addObserver:delegate
selector:@selector(comboBoxWillPopUp:)
name:CPComboBoxWillPopUpNotification
object:self];
_implementedDelegateComboBoxMethods |= CPComboBoxDelegate_comboBoxWillPopUp_;
if ([aDelegate respondsToSelector:@selector(comboBoxWillDismiss:)])
[defaultCenter addObserver:delegate
selector:@selector(comboBoxWillDissmis:)
name:CPComboBoxWillDismissNotification
object:self];
_implementedDelegateComboBoxMethods |= CPComboBoxDelegate_comboBoxWillDismiss_;
}
[super setDelegate:aDelegate];
@@ -231,7 +256,7 @@ var CPComboBoxTextSubview = @"text",
#pragma mark Setting a Data Source
- (id < CPComboBoxDataSource >)dataSource
- (id <CPComboBoxDataSource>)dataSource
{
if (!_usesDataSource)
[self _dataSourceWarningForMethod:_cmd condition:NO];
@@ -239,10 +264,12 @@ var CPComboBoxTextSubview = @"text",
return _dataSource;
}
- (void)setDataSource:(id < CPComboBoxDataSource >)aSource
- (void)setDataSource:(id <CPComboBoxDataSource>)aSource
{
if (!_usesDataSource)
{
[self _dataSourceWarningForMethod:_cmd condition:NO];
}
else if (_dataSource !== aSource)
{
if (![aSource respondsToSelector:@selector(numberOfItemsInComboBox:)] ||
@@ -251,7 +278,9 @@ var CPComboBoxTextSubview = @"text",
CPLog.warn("Illegal %s data source (%s). Must implement numberOfItemsInComboBox: and comboBox:objectValueForItemAtIndex:", [self className], [aSource description]);
}
else
{
_dataSource = aSource;
}
}
}
@@ -369,49 +398,57 @@ var CPComboBoxTextSubview = @"text",
if (_listDelegate === aDelegate)
return;
var defaultCenter = [CPNotificationCenter defaultCenter];
if (_listDelegate)
{
[defaultCenter removeObserver:self name:_CPPopUpListWillPopUpNotification object:_listDelegate];
[defaultCenter removeObserver:self name:_CPPopUpListWillDismissNotification object:_listDelegate];
[defaultCenter removeObserver:self name:_CPPopUpListDidDismissNotification object:_listDelegate];
[defaultCenter removeObserver:self name:_CPPopUpListItemWasClickedNotification object:_listDelegate];
var oldTableView = [_listDelegate tableView];
if (oldTableView)
{
[defaultCenter removeObserver:self name:CPTableViewSelectionIsChangingNotification object:oldTableView];
[defaultCenter removeObserver:self name:CPTableViewSelectionDidChangeNotification object:oldTableView];
}
}
[self _removeObserversForListDelegate:_listDelegate];
_listDelegate = aDelegate;
// We only add the observers if the CPComboBox is displayed
if ([self window])
[self _addObserversForListDelegate:_listDelegate]
// Apply our text style to the list
[_listDelegate setFont:[self font]];
[_listDelegate setAlignment:[self alignment]];
[[_listDelegate scrollView] setHasVerticalScroller:_hasVerticalScroller];
if (_intercellSpacing)
[[_listDelegate tableView] setIntercellSpacing:_intercellSpacing];
if (_itemHeight)
[[_listDelegate tableView] setRowHeight:_itemHeight];
}
- (void)_addObserversForListDelegate:(_CPPopUpList)aDelegate
{
if (!aDelegate)
return;
var defaultCenter = [CPNotificationCenter defaultCenter];
[defaultCenter addObserver:self
selector:@selector(comboBoxWillPopUp:)
name:_CPPopUpListWillPopUpNotification
object:_listDelegate];
object:aDelegate];
[defaultCenter addObserver:self
selector:@selector(comboBoxWillDismiss:)
name:_CPPopUpListWillDismissNotification
object:_listDelegate];
object:aDelegate];
[defaultCenter addObserver:self
selector:@selector(listDidDismiss:)
name:_CPPopUpListDidDismissNotification
object:_listDelegate];
object:aDelegate];
[defaultCenter addObserver:self
selector:@selector(itemWasClicked:)
name:_CPPopUpListItemWasClickedNotification
object:_listDelegate];
object:aDelegate];
[[_listDelegate scrollView] setHasVerticalScroller:_hasVerticalScroller];
[[aDelegate scrollView] setHasVerticalScroller:_hasVerticalScroller];
var tableView = [_listDelegate tableView];
var tableView = [aDelegate tableView];
[defaultCenter addObserver:self
selector:@selector(comboBoxSelectionIsChanging:)
@@ -422,10 +459,27 @@ var CPComboBoxTextSubview = @"text",
selector:@selector(comboBoxSelectionDidChange:)
name:CPTableViewSelectionDidChangeNotification
object:tableView];
}
// Apply our text style to the list
[_listDelegate setFont:[self font]];
[_listDelegate setAlignment:[self alignment]];
- (void)_removeObserversForListDelegate:(_CPPopUpList)aDelegate
{
if (!aDelegate)
return;
var defaultCenter = [CPNotificationCenter defaultCenter];
[defaultCenter removeObserver:self name:_CPPopUpListWillPopUpNotification object:aDelegate];
[defaultCenter removeObserver:self name:_CPPopUpListWillDismissNotification object:aDelegate];
[defaultCenter removeObserver:self name:_CPPopUpListDidDismissNotification object:aDelegate];
[defaultCenter removeObserver:self name:_CPPopUpListItemWasClickedNotification object:aDelegate];
var oldTableView = [aDelegate tableView];
if (oldTableView)
{
[defaultCenter removeObserver:self name:CPTableViewSelectionIsChangingNotification object:oldTableView];
[defaultCenter removeObserver:self name:CPTableViewSelectionDidChangeNotification object:oldTableView];
}
}
- (int)indexOfItemWithObjectValue:(id)anObject
@@ -470,8 +524,6 @@ var CPComboBoxTextSubview = @"text",
if (!_listDelegate)
[self setListDelegate:[[_CPPopUpList alloc] initWithDataSource:self]];
[self _selectMatchingItem];
// Note the offset here is 1 less than the focus ring width because the outer edge
// of the focus ring is very transparent and it looks better if the list is closer.
if (CPComboBoxFocusRingWidth < 0)
@@ -482,6 +534,7 @@ var CPComboBoxTextSubview = @"text",
}
[_listDelegate popUpRelativeToRect:[self _borderFrame] view:self offset:CPComboBoxFocusRingWidth - 1];
[self _selectMatchingItem];
}
/*! @ignore */
@@ -511,7 +564,7 @@ var CPComboBoxTextSubview = @"text",
var selectedStringValue = [_listDelegate selectedStringValue];
if (selectedStringValue === nil)
if (selectedStringValue == nil)
return NO;
else
_selectedStringValue = selectedStringValue;
@@ -790,7 +843,17 @@ var CPComboBoxTextSubview = @"text",
// In FireFox this needs to be done in setTimeout, otherwise there is no caret
// We have to save the input element now, when we lose focus it will change.
var element = [self _inputElement];
window.setTimeout(function() { element.focus(); }, 0);
[[CPRunLoop mainRunLoop] performBlock:function()
{
// This will prevent to jump to the focused element
var previousScrollingOrigin = [self _scrollToVisibleRectAndReturnPreviousOrigin];
element.focus();
[self _restorePreviousScrollingOrigin:previousScrollingOrigin];
} argument:nil order:0 modes:[CPDefaultRunLoopMode]];
#endif
return NO;
@@ -817,13 +880,17 @@ var CPComboBoxTextSubview = @"text",
- (void)setFont:(CPFont)aFont
{
[super setFont:aFont];
[_listDelegate setFont:aFont];
if (_listDelegate)
[_listDelegate setFont:aFont];
}
- (void)setAlignment:(CPTextAlignment)alignment
{
[super setAlignment:alignment];
[_listDelegate setAlignment:alignment];
if (_listDelegate)
[_listDelegate setAlignment:alignment];
}
#pragma mark Pop Up Button Layout
@@ -894,7 +961,9 @@ var CPComboBoxTextSubview = @"text",
index = [_dataSource comboBox:self indexOfItemWithStringValue:stringValue]
}
else
{
index = [self indexOfItemWithObjectValue:stringValue];
}
[_listDelegate selectRow:index];
@@ -946,6 +1015,28 @@ var CPComboBoxTextSubview = @"text",
}
}
#pragma mark -
#pragma mark Observers method
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[self _addObserversForListDelegate:_listDelegate];
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[self _removeObserversForListDelegate:_listDelegate];
}
@end
@implementation CPComboBox (CPComboBoxDelegate)
@@ -953,24 +1044,36 @@ var CPComboBoxTextSubview = @"text",
/*! @ignore */
- (void)comboBoxSelectionIsChanging:(CPNotification)aNotification
{
if (_implementedDelegateComboBoxMethods & CPComboBoxDelegate_comboBoxSelectionIsChanging_)
[_delegate comboBoxSelectionIsChanging:[[CPNotification alloc] initWithName:CPComboBoxSelectionIsChangingNotification object:self userInfo:nil]];
[[CPNotificationCenter defaultCenter] postNotificationName:CPComboBoxSelectionIsChangingNotification object:self];
}
/*! @ignore */
- (void)comboBoxSelectionDidChange:(CPNotification)aNotification
{
if (_implementedDelegateComboBoxMethods & CPComboBoxDelegate_comboBoxSelectionDidChange_)
[_delegate comboBoxSelectionDidChange:[[CPNotification alloc] initWithName:CPComboBoxSelectionDidChangeNotification object:self userInfo:nil]];
[[CPNotificationCenter defaultCenter] postNotificationName:CPComboBoxSelectionDidChangeNotification object:self];
}
/*! @ignore */
- (void)comboBoxWillPopUp:(CPNotification)aNotification
{
if (_implementedDelegateComboBoxMethods & CPComboBoxDelegate_comboBoxWillPopUp_)
[_delegate comboBoxWillPopUp:[[CPNotification alloc] initWithName:CPComboBoxWillPopUpNotification object:self userInfo:nil]];
[[CPNotificationCenter defaultCenter] postNotificationName:CPComboBoxWillPopUpNotification object:self];
}
/*! @ignore */
- (void)comboBoxWillDismiss:(CPNotification)aNotification
{
if (_implementedDelegateComboBoxMethods & CPComboBoxDelegate_comboBoxWillDismiss_)
[_delegate comboBoxWillDismiss:[[CPNotification alloc] initWithName:CPComboBoxWillDismissNotification object:self userInfo:nil]];
[[CPNotificationCenter defaultCenter] postNotificationName:CPComboBoxWillDismissNotification object:self];
}
@@ -1039,11 +1142,9 @@ var CPComboBoxTextSubview = @"text",
// Directly nuke _items, [_items removeAll] will trigger an extra call to setContent
_items = [];
var values = [];
[anArray enumerateObjectsUsingBlock:function(object)
var values = [anArray arrayByApplyingBlock:function(object)
{
values.push([object description]);
return [object description];
}];
[self addItemsWithObjectValues:values];
+134 -18
View File
@@ -26,11 +26,13 @@
// Browser Engines
CPUnknownBrowserEngine = 0;
CPGeckoBrowserEngine = 1;
CPInternetExplorerBrowserEngine = 2;
CPKHTMLBrowserEngine = 3;
CPOperaBrowserEngine = 4;
CPWebKitBrowserEngine = 5;
CPGeckoBrowserEngine = 1 << 0;
CPInternetExplorerBrowserEngine = 1 << 1;
CPKHTMLBrowserEngine = 1 << 2;
CPOperaBrowserEngine = 1 << 3;
CPWebKitBrowserEngine = 1 << 4; // Safari + Chrome
CPBlinkBrowserEngine = 1 << 5; // Recent Chrome
CPEdgeBrowserEngine = 1 << 6;
// Operating Systems
CPMacOperatingSystem = 0;
@@ -46,7 +48,9 @@ CPHTMLDragAndDropFeature = 8;
CPJavaScriptInnerTextFeature = 9;
CPJavaScriptTextContentFeature = 10;
// In onpaste, oncopy and oncut events, the event has an event.clipboardData from which the current pasteboard contents can be read with event.clipboardData.getData.
CPJavaScriptClipboardEventsFeature = 11;
// window.clipboardData exists and can be read and written to at any time using window.clipboardData.getData/setData.
CPJavaScriptClipboardAccessFeature = 12;
CPJavaScriptCanvasDrawFeature = 13;
CPJavaScriptCanvasTransformFeature = 14;
@@ -76,11 +80,31 @@ CPInputOnInputEventFeature = 30;
CPFileAPIFeature = 31;
CPAltEnterTextAreaFeature = 32;
CPCSSAnimationFeature = 33;
CPBackspaceTriggersPageBack = 34;
/*
When an absolutely positioned div (CPView) with an absolutely positioned canvas in it (CPView with drawRect:) moves things on top of the canvas (subviews) don't redraw correctly. E.g. if you have a bunch of text fields in a CPBox in a sheet which animates in, some of the text fields might not be visible because the CPBox has a canvas at the bottom and the box moved form offscreen to onscreen. This bug is probably very related: https://bugs.webkit.org/show_bug.cgi?id=67203
*/
*/
CPCanvasParentDrawErrorsOnMovementBug = 1 << 0;
// The paste event is only sent if an input or textarea has focus.
CPJavaScriptPasteRequiresEditableTarget = 1 << 1;
// Redirecting the focus of the browser on keydown to an input for Cmd-V or Ctrl-V makes the paste fail.
CPJavaScriptPasteCantRefocus = 1 << 2;
/*
Safari calculates incorrect text size unless you set the canvas font even if it is already set
You can see the bug after disabling the workaround and opening any panel while typing.
You can use the font panel in the manual test for CPTextView.
Look out for a displaced cursor, i.e. after typing letters of small width, such as the 'i'.
https://bugs.webkit.org/show_bug.cgi?id=150224
*/
CPTextSizingAlwaysNeedsSetFontBug = 1 << 3;
var USER_AGENT = "",
PLATFORM_ENGINE = CPUnknownBrowserEngine,
PLATFORM_FEATURES = [],
@@ -90,6 +114,7 @@ var USER_AGENT = "",
// default these features to true
PLATFORM_FEATURES[CPInputTypeCanBeChangedFeature] = YES;
PLATFORM_FEATURES[CPInputSetFontOutsideOfDOM] = YES;
PLATFORM_FEATURES[CPAltEnterTextAreaFeature] = YES;
if (typeof window !== "undefined" && typeof window.navigator !== "undefined")
USER_AGENT = window.navigator.userAgent;
@@ -97,15 +122,15 @@ if (typeof window !== "undefined" && typeof window.navigator !== "undefined")
// Opera
if (typeof window !== "undefined" && window.opera)
{
PLATFORM_ENGINE = CPOperaBrowserEngine;
PLATFORM_ENGINE |= CPOperaBrowserEngine;
PLATFORM_FEATURES[CPJavaScriptCanvasDrawFeature] = YES;
}
// Internet Explorer
else if (typeof window !== "undefined" && window.attachEvent) // Must follow Opera check.
else if (typeof window !== "undefined" && (window.attachEvent || (!(window.ActiveXObject) && "ActiveXObject" in window))) // Must follow Opera check.
{
PLATFORM_ENGINE = CPInternetExplorerBrowserEngine;
PLATFORM_ENGINE |= CPInternetExplorerBrowserEngine;
// Features we can only be sure of with IE (no known independent tests)
PLATFORM_FEATURES[CPVMLFeature] = YES;
@@ -118,22 +143,44 @@ else if (typeof window !== "undefined" && window.attachEvent) // Must follow Ope
// Tested in Internet Explore 8 and 9.
PLATFORM_FEATURES[CPInputSetFontOutsideOfDOM] = NO;
// IE allows free clipboard access.
PLATFORM_FEATURES[CPJavaScriptClipboardAccessFeature] = YES;
}
// WebKit
// Edge
else if (USER_AGENT.indexOf("Edge/") != -1)
{
PLATFORM_ENGINE |= CPEdgeBrowserEngine;
PLATFORM_FEATURES[CPCSSRGBAFeature] = YES;
PLATFORM_FEATURES[CPHTMLContentEditableFeature] = YES;
PLATFORM_FEATURES[CPJavaScriptClipboardEventsFeature] = YES;
PLATFORM_FEATURES[CPJavaScriptClipboardAccessFeature] = NO;
PLATFORM_FEATURES[CPJavaScriptShadowFeature] = YES;
var versionStart = USER_AGENT.indexOf("Edge/") + "Edge/".length,
versionEnd = USER_AGENT.indexOf(" ", versionStart),
versionString = USER_AGENT.substring(versionStart, versionEnd),
versionDivision = versionString.indexOf('.'),
majorVersion = parseInt(versionString.substring(0, versionDivision)),
minorVersion = parseInt(versionString.substr(versionDivision + 1));
PLATFORM_FEATURES[CPJavaScriptRemedialKeySupport] = YES;
}
// Safari + Chrome (WebKit and Blink)
else if (USER_AGENT.indexOf("AppleWebKit/") != -1)
{
PLATFORM_ENGINE = CPWebKitBrowserEngine;
PLATFORM_ENGINE |= CPWebKitBrowserEngine;
// Features we can only be sure of with WebKit (no known independent tests)
PLATFORM_FEATURES[CPCSSRGBAFeature] = YES;
PLATFORM_FEATURES[CPHTMLContentEditableFeature] = YES;
if (USER_AGENT.indexOf("Chrome") === -1)
PLATFORM_FEATURES[CPHTMLDragAndDropFeature] = YES;
PLATFORM_FEATURES[CPJavaScriptClipboardEventsFeature] = YES;
PLATFORM_FEATURES[CPJavaScriptClipboardAccessFeature] = YES;
PLATFORM_FEATURES[CPJavaScriptClipboardAccessFeature] = NO;
PLATFORM_FEATURES[CPJavaScriptShadowFeature] = YES;
var versionStart = USER_AGENT.indexOf("AppleWebKit/") + "AppleWebKit/".length,
@@ -159,7 +206,17 @@ else if (USER_AGENT.indexOf("AppleWebKit/") != -1)
PLATFORM_FEATURES[CPInput1PxLeftPadding] = YES;
if (USER_AGENT.indexOf("Chrome") === CPNotFound)
{
PLATFORM_FEATURES[CPSOPDisabledFromFileURLs] = YES;
PLATFORM_FEATURES[CPHTMLDragAndDropFeature] = YES;
// https://bugs.webkit.org/show_bug.cgi?id=75891
PLATFORM_BUGS |= CPJavaScriptPasteRequiresEditableTarget;
// https://bugs.webkit.org/show_bug.cgi?id=39689
PLATFORM_BUGS |= CPJavaScriptPasteCantRefocus;
PLATFORM_BUGS |= CPTextSizingAlwaysNeedsSetFontBug;
}
else if ((window.chrome || (window.Intl && Intl.v8BreakIterator)) && 'CSS' in window)
PLATFORM_ENGINE |= CPBlinkBrowserEngine;
// Assume this bug was introduced around Safari 5.1/Chrome 16. This could probably be tighter.
if (majorVersion > 533)
@@ -169,15 +226,16 @@ else if (USER_AGENT.indexOf("AppleWebKit/") != -1)
// KHTML
else if (USER_AGENT.indexOf("KHTML") != -1) // Must follow WebKit check.
{
PLATFORM_ENGINE = CPKHTMLBrowserEngine;
PLATFORM_ENGINE |= CPKHTMLBrowserEngine;
}
// Gecko
else if (USER_AGENT.indexOf("Gecko") !== -1) // Must follow KHTML check.
{
PLATFORM_ENGINE = CPGeckoBrowserEngine;
PLATFORM_ENGINE |= CPGeckoBrowserEngine;
PLATFORM_FEATURES[CPJavaScriptCanvasDrawFeature] = YES;
PLATFORM_FEATURES[CPBackspaceTriggersPageBack] = YES;
var index = USER_AGENT.indexOf("Firefox"),
version = (index === -1) ? 2.0 : parseFloat(USER_AGENT.substring(index + "Firefox".length + 1));
@@ -188,8 +246,23 @@ else if (USER_AGENT.indexOf("Gecko") !== -1) // Must follow KHTML check.
if (version < 3.0)
PLATFORM_FEATURES[CPJavaScriptMouseWheelValues_8_15] = YES;
if (version >= 66)
PLATFORM_FEATURES[CPJavaScriptRemedialKeySupport] = YES;
// Some day this might be fixed and should be version prefixed. No known fixed version yet.
PLATFORM_FEATURES[CPInput1PxLeftPadding] = YES;
PLATFORM_FEATURES[CPAltEnterTextAreaFeature] = NO;
// This was supposed to be added in Firefox 22, but when testing with the latest beta as of 2013-06-14
// it does not seem to work. It seems to exhibit the CPJavaScriptPasteRequiresEditableTarget problem,
// and in addition doesn't seem to work with our native copy code either.
/*if (version >= 22.0)
{
PLATFORM_FEATURES[CPJavaScriptClipboardEventsFeature] = YES;
// TODO File a bug at https://bugzilla.mozilla.org/. In other browsers, one can return "false" from the
// beforepaste event to indicate a paste should be enabled even that the DOMEvent.target is not editable.
PLATFORM_BUGS |= CPJavaScriptPasteRequiresEditableTarget;
}*/
}
// Feature-specific checks
@@ -254,7 +327,7 @@ function CPPlatformHasBug(aBug)
function CPBrowserIsEngine(anEngine)
{
return PLATFORM_ENGINE === anEngine;
return PLATFORM_ENGINE & anEngine;
}
function CPBrowserIsOperatingSystem(anOperatingSystem)
@@ -290,6 +363,14 @@ else
CPRedoKeyEquivalentModifierMask = CPControlKeyMask;
}
/*!
Sets a feature with the given value.
*/
function CPSetPlatformFeature(aFeature, aBool)
{
PLATFORM_FEATURES[aFeature] = aBool;
}
/*!
Return the properly prefixed JS property for the given name. E.g. in a webkit browser,
CPBrowserStyleProperty('transition') -> WebkitTransition
@@ -323,6 +404,32 @@ function CPBrowserStyleProperty(aProperty)
r = candidates[PLATFORM_STYLE_JS_PROPERTIES['transition']] || nil;
break;
case 'transformorigin':
var candidates = {
'WebkitTransform' : 'WebkitTransformOrigin',
'MozTransform' : 'MozTransformOrigin',
'OTransform' : 'OTransformOrigin',
'msTransform' : 'MSTransformOrigin',
'transform' : 'transformOrigin'
};
r = candidates[PLATFORM_STYLE_JS_PROPERTIES['transform']] || nil;
break;
case 'animationend':
var candidates = {
'WebkitAnimation' : 'webkitAnimationEnd',
'MozAnimation' : 'animationend',
'OAnimation' : 'oAnimationEnd',
'msAnimation' : 'MSAnimationEnd',
'animation' : 'animationend'
};
r = candidates[PLATFORM_STYLE_JS_PROPERTIES['animation']] || nil;
break;
default:
var prefixes = ["Webkit", "Moz", "O", "ms"],
strippedProperty = aProperty.split('-').join(' '),
@@ -392,3 +499,12 @@ function CPBrowserCSSProperty(aProperty)
return browserProperty.toLowerCase();
}
function CPBrowserBackingStorePixelRatio(context)
{
return context.webkitBackingStorePixelRatio ||
context.mozBackingStorePixelRatio ||
context.msBackingStorePixelRatio ||
context.oBackingStorePixelRatio ||
context.backingStorePixelRatio || 1;
}
+259 -33
View File
@@ -23,23 +23,36 @@
@import <Foundation/CPFormatter.j>
@import <Foundation/CPTimer.j>
@import "CPFont.j"
@import "CPShadow.j"
@import "CPView.j"
@import "CPText.j"
@import "CPKeyValueBinding.j"
@import "CPTrackingArea.j"
@class CPFont
@global CPApp
CPLeftTextAlignment = 0;
CPRightTextAlignment = 1;
CPCenterTextAlignment = 2;
CPJustifiedTextAlignment = 3;
CPNaturalTextAlignment = 4;
@protocol CPControlTextEditingDelegate <CPObject>
@optional
- (void)controlTextDidBeginEditing:(CPNotification)aNotification;
- (void)controlTextDidChange:(CPNotification)aNotification;
- (void)controlTextDidEndEditing:(CPNotification)aNotification;
- (void)controlTextDidFocus:(CPNotification)aNotification;
- (void)controlTextDidBlur:(CPNotification)aNotification;
- (BOOL)control:(CPControl)control didFailToFormatString:(CPString)string errorDescription:(CPString)error;
@end
@typedef CPControlSize
CPRegularControlSize = 0;
CPSmallControlSize = 1;
CPMiniControlSize = 2;
// To get the theme state corresponding to a control size, use CPControlSizeThemeStates[controlSize]
CPControlSizeThemeStates = @[CPThemeStateControlSizeRegular, CPThemeStateControlSizeSmall, CPThemeStateControlSizeMini];
@typedef CPLineBreakMode
CPLineBreakByWordWrapping = 0;
CPLineBreakByCharWrapping = 1;
CPLineBreakByClipping = 2;
@@ -47,11 +60,13 @@ CPLineBreakByTruncatingHead = 3;
CPLineBreakByTruncatingTail = 4;
CPLineBreakByTruncatingMiddle = 5;
@typedef CPVerticalTextAlignment
CPTopVerticalTextAlignment = 1;
CPCenterVerticalTextAlignment = 2;
CPBottomVerticalTextAlignment = 3;
// Deprecated for use with images, use the CPImageScale constants
@typedef CPImageScaling
CPScaleProportionally = 0;
CPScaleToFit = 1;
CPScaleNone = 2;
@@ -61,6 +76,7 @@ CPImageScaleAxesIndependently = 1;
CPImageScaleNone = 2;
CPImageScaleProportionallyUpOrDown = 3;
@typedef CPCellImagePosition
CPNoImage = 0;
CPImageOnly = 1;
CPImageLeft = 2;
@@ -106,6 +122,10 @@ var CPControlBlackColor = [CPColor blackColor];
BOOL _trackingWasWithinFrame;
unsigned _trackingMouseDownFlags;
CGPoint _previousTrackingLocation;
CPControlSize _controlSize;
CPWritingDirection _baseWritingDirection @accessors(property=baseWritingDirection);
}
+ (CPDictionary)themeAttributes
@@ -115,13 +135,13 @@ var CPControlBlackColor = [CPColor blackColor];
@"vertical-alignment": CPTopVerticalTextAlignment,
@"line-break-mode": CPLineBreakByClipping,
@"text-color": [CPColor blackColor],
@"font": [CPFont systemFontOfSize:CPFontCurrentSystemSize],
@"font": [CPNull null],
@"text-shadow-color": [CPNull null],
@"text-shadow-offset": CGSizeMakeZero(),
@"image-position": CPImageLeft,
@"image-scaling": CPScaleToFit,
@"min-size": CGSizeMakeZero(),
@"max-size": CGSizeMake(-1.0, -1.0),
@"max-size": CGSizeMake(-1.0, -1.0)
};
}
@@ -152,7 +172,7 @@ var CPControlBlackColor = [CPColor blackColor];
}
/*!
Reverse set the binding iff the CPContinuouslyUpdatesValueBindingOption is set.
Reverse set the binding if the CPContinuouslyUpdatesValueBindingOption is set.
*/
- (void)_continuouslyReverseSetBinding
{
@@ -177,13 +197,97 @@ var CPControlBlackColor = [CPColor blackColor];
if (self)
{
_sendActionOn = CPLeftMouseUpMask;
_sendActionOn = CPLeftMouseUpMask;
_trackingMouseDownFlags = 0;
[self setControlSize:CPThemeStateControlSizeRegular];
[self updateTrackingAreas];
}
return self;
}
#pragma mark -
#pragma mark Control Size
/*!
Returns the control's control size
*/
- (CPControlSize)controlSize
{
return _controlSize;
}
/*!
Sets the control's size.
@param aControlSize the control's size
*/
- (void)setControlSize:(CPControlSize)aControlSize
{
if (_controlSize === aControlSize)
return;
[self unsetThemeState:[self _controlSizeThemeState]];
_controlSize = aControlSize;
[self setThemeState:[self _controlSizeThemeState]];
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
/*!
Gets the current theme state according to the current controlSize.
@return a CPThemeState
*/
- (ThemeState)_controlSizeThemeState
{
switch (_controlSize)
{
case CPSmallControlSize:
return CPThemeStateControlSizeSmall;
case CPMiniControlSize:
return CPThemeStateControlSizeMini;
case CPRegularControlSize:
default:
return CPThemeStateControlSizeRegular;
}
}
/*!
@ignore
Change frame size according to the theme control size theme constraints
Basically for height to min-size.
*/
- (void)_sizeToControlSize
{
var frameSize = [self frameSize],
minSize = [self currentValueForThemeAttribute:@"min-size"],
maxSize = [self currentValueForThemeAttribute:@"max-size"];
if (minSize.width > 0)
{
frameSize.width = MAX(minSize.width, frameSize.width);
if (maxSize.width > 0)
frameSize.width = MIN(maxSize.width, frameSize.width);
}
if (minSize.height > 0)
{
frameSize.height = MAX(minSize.height, frameSize.height);
if (maxSize.height > 0)
frameSize.height = MIN(maxSize.height, frameSize.height);
}
[self setFrameSize:frameSize];
}
#pragma mark -
/*!
Sets the receiver's target action.
@@ -322,11 +426,11 @@ var CPControlBlackColor = [CPColor blackColor];
_previousTrackingLocation = currentLocation;
}
- (void)setState:(int)state
- (void)setState:(CPInteger)state
{
}
- (int)nextState
- (CPInteger)nextState
{
return 0;
}
@@ -522,15 +626,15 @@ var CPControlBlackColor = [CPColor blackColor];
*/
- (CPString)stringValue
{
if (_formatter && _value !== undefined)
if (_formatter && _value != nil)
{
var formattedValue = [self hasThemeState:CPThemeStateEditing] ? [_formatter editingStringForObjectValue:_value] : [_formatter stringForObjectValue:_value];
if (formattedValue !== nil && formattedValue !== undefined)
if (formattedValue != nil)
return formattedValue;
}
return (_value === undefined || _value === nil) ? "" : String(_value);
return _value == nil ? @"" : String(_value);
}
/*!
@@ -539,7 +643,7 @@ var CPControlBlackColor = [CPColor blackColor];
- (void)setStringValue:(CPString)aString
{
// Cocoa raises an invalid parameter assertion and returns if you pass nil.
if (aString === nil || aString === undefined)
if (aString == nil)
{
CPLog.warn("nil or undefined sent to CPControl -setStringValue");
return;
@@ -607,7 +711,7 @@ var CPControlBlackColor = [CPColor blackColor];
if ([note object] != self)
return;
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidBeginEditingNotification object:self userInfo:@{ "CPFieldEditor": [note object] }];
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidBeginEditingNotification object:self userInfo:@{"CPFieldEditor": [note object]}];
}
- (void)textDidChange:(CPNotification)note
@@ -616,7 +720,7 @@ var CPControlBlackColor = [CPColor blackColor];
if ([note object] != self)
return;
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidChangeNotification object:self userInfo:@{ "CPFieldEditor": [note object] }];
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidChangeNotification object:self userInfo:@{"CPFieldEditor": [note object]}];
}
- (void)textDidEndEditing:(CPNotification)note
@@ -627,7 +731,49 @@ var CPControlBlackColor = [CPColor blackColor];
[self _reverseSetBinding];
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidEndEditingNotification object:self userInfo:@{ "CPFieldEditor": [note object] }];
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidEndEditingNotification object:self userInfo:[note userInfo]];
}
/*!
@ignore
Return the currentTextMovement needed by the delegate textDidEndEditing
This is going to check the currentEvent of the CPApp
*/
- (unsigned)_currentTextMovement
{
var currentEvent = [CPApp currentEvent],
keyCode = [currentEvent keyCode],
modifierFlags = [currentEvent modifierFlags];
switch (keyCode)
{
case CPEscapeKeyCode:
return CPCancelTextMovement;
case CPLeftArrowKeyCode:
return CPLeftTextMovement;
case CPRightArrowKeyCode:
return CPRightTextMovement;
case CPUpArrowKeyCode:
return CPUpTextMovement;
case CPDownArrowKeyCode:
return CPDownTextMovement;
case CPReturnKeyCode:
return CPReturnTextMovement;
case CPTabKeyCode:
if (modifierFlags & CPShiftKeyMask)
return CPBacktabTextMovement;
return CPTabTextMovement;
default:
return CPOtherTextMovement;
}
}
/*!
@@ -663,7 +809,7 @@ var CPControlBlackColor = [CPColor blackColor];
CPBottomVerticalTextAlignment
</pre>
*/
- (void)setVerticalAlignment:(CPTextVerticalAlignment)alignment
- (void)setVerticalAlignment:(CPVerticalTextAlignment)alignment
{
[self setValue:alignment forThemeAttribute:@"vertical-alignment"];
}
@@ -708,7 +854,12 @@ var CPControlBlackColor = [CPColor blackColor];
*/
- (void)setTextColor:(CPColor)aColor
{
[self setValue:aColor forThemeAttribute:@"text-color"];
[self setValue:aColor forThemeAttribute:@"text-color" inState:[self themeState]];
}
- (void)setTextColor:(CPColor)aColor inThemeStates:(CPArray)themeStates
{
[self setValue:aColor forThemeAttribute:@"text-color" inStates:themeStates];
}
/*!
@@ -766,7 +917,7 @@ var CPControlBlackColor = [CPColor blackColor];
*/
- (CPFont)font
{
return [self valueForThemeAttribute:@"font"];
return [self currentValueForThemeAttribute:@"font"] || [CPFont systemFontForControlSize:_controlSize];
}
/*!
@@ -813,7 +964,7 @@ var CPControlBlackColor = [CPColor blackColor];
/*!
Returns the image scaling of the control.
*/
- (CPImageScaling)imageScaling
- (CPUInteger)imageScaling
{
return [self valueForThemeAttribute:@"image-scaling"];
}
@@ -871,16 +1022,81 @@ var CPControlBlackColor = [CPColor blackColor];
return [self hasThemeState:CPThemeStateHighlighted];
}
#pragma mark -
#pragma mark Base writing direction
/*!
Sets the initial writing direction of the receiver
@param writingDirection - It could be CPWritingDirectionNatural, CPWritingDirectionLeftToRight, CPWritingDirectionRightToLeft
*/
- (void)setBaseWritingDirection:(CPWritingDirection)writingDirection
{
if (writingDirection == _baseWritingDirection)
return;
[self willChangeValueForKey:@"baseWritingDirection"];
_baseWritingDirection = writingDirection;
[self didChangeValueForKey:@"baseWritingDirection"];
#if PLATFORM(DOM)
var style;
switch (_baseWritingDirection)
{
case CPWritingDirectionNatural:
style = "initial";
break;
case CPWritingDirectionLeftToRight:
style = "ltr";
break;
case CPWritingDirectionRightToLeft:
style = "rtl";
break;
default:
style = "initial";
}
_DOMElement.style.direction = style;
#endif
}
@end
var CPControlValueKey = @"CPControlValueKey",
@implementation CPControl (CPTrackingArea)
{
CPTrackingArea _controlTrackingArea;
}
- (void)updateTrackingAreas
{
if (_controlTrackingArea)
[self removeTrackingArea:_controlTrackingArea];
_controlTrackingArea = [[CPTrackingArea alloc] initWithRect:CGRectMakeZero()
options:CPTrackingMouseEnteredAndExited | CPTrackingActiveInKeyWindow | CPTrackingInVisibleRect
owner:self
userInfo:nil];
[self addTrackingArea:_controlTrackingArea];
[super updateTrackingAreas];
}
@end
var CPControlActionKey = @"CPControlActionKey",
CPControlControlSizeKey = @"CPControlControlSizeKey",
CPControlControlStateKey = @"CPControlControlStateKey",
CPControlIsEnabledKey = @"CPControlIsEnabledKey",
CPControlTargetKey = @"CPControlTargetKey",
CPControlActionKey = @"CPControlActionKey",
CPControlSendActionOnKey = @"CPControlSendActionOnKey",
CPControlFormatterKey = @"CPControlFormatterKey",
CPControlIsEnabledKey = @"CPControlIsEnabledKey",
CPControlSendActionOnKey = @"CPControlSendActionOnKey",
CPControlSendsActionOnEndEditingKey = @"CPControlSendsActionOnEndEditingKey",
CPControlTargetKey = @"CPControlTargetKey",
CPControlValueKey = @"CPControlValueKey",
CPControlBaseWrittingDirectionKey = @"CPControlBaseWrittingDirectionKey";
__Deprecated__CPImageViewImageKey = @"CPImageViewImageKey";
@@ -907,6 +1123,11 @@ var CPControlValueKey = @"CPControlValueKey",
[self setSendsActionOnEndEditing:[aCoder decodeBoolForKey:CPControlSendsActionOnEndEditingKey]];
[self setFormatter:[aCoder decodeObjectForKey:CPControlFormatterKey]];
[self setControlSize:[aCoder decodeIntForKey:CPControlControlSizeKey]];
[self setBaseWritingDirection:[aCoder decodeIntForKey:CPControlBaseWrittingDirectionKey]];
[self updateTrackingAreas];
}
return self;
@@ -926,19 +1147,24 @@ var CPControlValueKey = @"CPControlValueKey",
var objectValue = [self objectValue];
if (objectValue !== nil)
if (objectValue != nil)
[aCoder encodeObject:objectValue forKey:CPControlValueKey];
if (_target !== nil)
if (_target != nil)
[aCoder encodeConditionalObject:_target forKey:CPControlTargetKey];
if (_action !== nil)
if (_action != nil)
[aCoder encodeObject:_action forKey:CPControlActionKey];
[aCoder encodeInt:_sendActionOn forKey:CPControlSendActionOnKey];
if (_formatter !== nil)
if (_formatter != nil)
[aCoder encodeObject:_formatter forKey:CPControlFormatterKey];
[aCoder encodeInt:_controlSize forKey:CPControlControlSizeKey];
[aCoder encodeInt:_baseWritingDirection forKey:CPControlBaseWrittingDirectionKey];
}
@end
+2
View File
@@ -37,6 +37,8 @@
CPString _expires;
}
@global document
/*!
Initializes a cookie with a given name \c aName.
@param the name for the cookie
Executable → Regular
+118 -45
View File
@@ -22,6 +22,8 @@ Cursor support by browser:
*/
@import <Foundation/CPObject.j>
@import "CPImage.j"
@import "CPCompatibility.j"
@global CPApp
@@ -30,6 +32,12 @@ var currentCursor = nil,
cursors = {},
ieCursorMap = {};
@typedef CPCursorPlatform
CPCursorPlatformNone = 0;
CPCursorPlatformMac = 1;
CPCursorPlatformWindows = 2;
CPCursorPlatformBoth = 3;
@implementation CPCursor : CPObject
{
CPString _cssString @accessors(readonly);
@@ -116,11 +124,15 @@ var currentCursor = nil,
- (void)push
{
currentCursor = cursorStack.push(self);
cursorStack.push(self);
currentCursor = self;
}
- (void)set
{
if (currentCursor === self)
return;
currentCursor = self;
#if PLATFORM(DOM)
@@ -152,7 +164,7 @@ var currentCursor = nil,
}
// Internal method that is used to return the system cursors. Caches the system cursors for performance.
+ (CPCursor)_systemCursorWithName:(CPString)cursorName cssString:(CPString)aString hasImage:(BOOL)doesHaveImage
+ (CPCursor)_nativeSystemCursorWithName:(CPString)cursorName cssString:(CPString)aString
{
var cursor = cursors[cursorName];
@@ -160,155 +172,216 @@ var currentCursor = nil,
{
var cssString;
if (doesHaveImage)
{
var themeResourcePath = [[[CPApp themeBlend] bundle] resourcePath],
extension = CPBrowserIsEngine(CPInternetExplorerBrowserEngine) ? @"cur" : @"png";
cssString = [CPString stringWithFormat:@"url(%@cursors/%@.%@), %@", themeResourcePath, cursorName, extension, aString];
}
// IE <= 8 does not support some cursors, map them to supported cursors
var ieLessThan9 = CPBrowserIsEngine(CPInternetExplorerBrowserEngine) && !CPFeatureIsCompatible(CPHTMLCanvasFeature);
if (ieLessThan9)
cssString = ieCursorMap[aString] || aString;
else
{
// IE <= 8 does not support some cursors, map them to supported cursors
var ieLessThan9 = CPBrowserIsEngine(CPInternetExplorerBrowserEngine) && !CPFeatureIsCompatible(CPHTMLCanvasFeature);
cssString = aString;
if (ieLessThan9)
cssString = ieCursorMap[aString] || aString;
else
cssString = aString;
}
cursor = [[CPCursor alloc] initWithCSSString:cssString];
cursors[cursorName] = cursor;
cursors[cursorName] = cursor = [[CPCursor alloc] initWithCSSString:cssString];
}
return cursor;
}
+ (CPCursor)_imageCursorWithName:(CPString)cursorName cssString:(CPString)aString
{
var cursor = cursors[cursorName];
if (typeof cursor === "undefined")
{
var themeResourcePath = [[[CPApp themeBlend] bundle] resourcePath],
extension = CPBrowserIsOperatingSystem(CPWindowsOperatingSystem) ? @"cur" : @"png",
cssString = [CPString stringWithFormat:@"url(%@cursors/%@.%@), %@", themeResourcePath, cursorName, extension, aString];
cursors[cursorName] = cursor = [[CPCursor alloc] initWithCSSString:cssString];
}
return cursor;
}
+ (CPCursor)_tryUsingNativeSystemCursorWithName:(CPString)cursorName cssString:(CPString)cssName onPlatform:(CPCursorPlatform)shouldUseNativeCursorOn fallingBackWithImageAndCSSPointer:(CPString)aString
{
var useNativeSystemCursor = (((shouldUseNativeCursorOn == CPCursorPlatformBoth) ||
((shouldUseNativeCursorOn == CPCursorPlatformMac) && CPBrowserIsOperatingSystem(CPMacOperatingSystem)) ||
((shouldUseNativeCursorOn == CPCursorPlatformWindows) && CPBrowserIsOperatingSystem(CPWindowsOperatingSystem)))
&& [CPCursor _nativeCursorExists:cssName]);
if (useNativeSystemCursor)
return [CPCursor _nativeSystemCursorWithName:cursorName cssString:cssName];
else
return [CPCursor _imageCursorWithName:cursorName cssString:aString];
}
+ (BOOL)_nativeCursorExists:(CPString)cursorCSSName
{
#if PLATFORM(DOM)
// FIXME: Trick until FF/Win & Chrome/Win correctly implement context-menu cursor
// They will answer that they implement it but they actually don't
if ([cursorCSSName isEqualToString:@"context-menu"] && CPBrowserIsOperatingSystem(CPWindowsOperatingSystem) && !CPBrowserIsEngine(CPInternetExplorerBrowserEngine) && !CPBrowserIsEngine(CPEdgeBrowserEngine))
return NO;
// Normal usage : try to set the cursor and check if resulting cursor is the one we tried to set.
// If yes, then the browser implements the cursor. If no (and usually we get "default"), then it doesn't.
var platformWindows = [[CPPlatformWindow visiblePlatformWindows] allObjects],
count = [platformWindows count];
if (count > 0)
{
var currentPlatformCursor = platformWindows[0]._DOMBodyElement.style.cursor;
platformWindows[0]._DOMBodyElement.style.cursor = cursorCSSName;
var doesExist = (platformWindows[0]._DOMBodyElement.style.cursor == cursorCSSName);
platformWindows[0]._DOMBodyElement.style.cursor = currentPlatformCursor;
return doesExist;
}
#endif
return NO;
}
+ (CPCursor)arrowCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"default" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"default"];
}
+ (CPCursor)crosshairCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"crosshair" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"crosshair"];
}
+ (CPCursor)IBeamCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"text" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"text"];
}
+ (CPCursor)pointingHandCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"pointer" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"pointer"];
}
+ (CPCursor)resizeNorthwestCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"nw-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"nw-resize"];
}
+ (CPCursor)resizeNorthwestSoutheastCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"nwse-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"nwse-resize"];
}
+ (CPCursor)resizeNortheastCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"ne-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"ne-resize"];
}
+ (CPCursor)resizeNortheastSouthwestCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"nesw-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"nesw-resize"];
}
+ (CPCursor)resizeSouthwestCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"sw-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"sw-resize"];
}
+ (CPCursor)resizeSoutheastCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"se-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"se-resize"];
}
+ (CPCursor)resizeDownCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"s-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"s-resize"];
}
+ (CPCursor)resizeUpCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"n-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"n-resize"];
}
+ (CPCursor)resizeLeftCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"w-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"w-resize"];
}
+ (CPCursor)resizeRightCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"e-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"e-resize"];
}
+ (CPCursor)resizeLeftRightCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"col-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"col-resize"];
}
+ (CPCursor)resizeEastWestCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"ew-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"ew-resize"];
}
+ (CPCursor)resizeUpDownCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"row-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"row-resize"];
}
+ (CPCursor)resizeNorthSouthCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"ns-resize" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"ns-resize"];
}
+ (CPCursor)operationNotAllowedCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"not-allowed" hasImage:NO];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"not-allowed"];
}
+ (CPCursor)dragCopyCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"copy" hasImage:YES];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"copy"];
}
+ (CPCursor)dragLinkCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"alias" hasImage:YES];
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"alias"];
}
+ (CPCursor)contextualMenuCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"context-menu" hasImage:YES];
return [CPCursor _tryUsingNativeSystemCursorWithName:CPStringFromSelector(_cmd)
cssString:@"context-menu"
onPlatform:CPCursorPlatformBoth
fallingBackWithImageAndCSSPointer:@"default"];
}
+ (CPCursor)openHandCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"move" hasImage:YES];
return [CPCursor _tryUsingNativeSystemCursorWithName:CPStringFromSelector(_cmd)
cssString:@"grab"
onPlatform:CPCursorPlatformMac
fallingBackWithImageAndCSSPointer:@"default"];
}
+ (CPCursor)closedHandCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"-moz-grabbing" hasImage:YES];
return [CPCursor _tryUsingNativeSystemCursorWithName:CPStringFromSelector(_cmd)
cssString:@"grabbing"
onPlatform:CPCursorPlatformMac
fallingBackWithImageAndCSSPointer:@"default"];
}
+ (CPCursor)disappearingItemCursor
{
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"auto" hasImage:YES];
return [CPCursor _imageCursorWithName:CPStringFromSelector(_cmd) cssString:@"default"];
}
+ (CPCursor)IBeamCursorForVerticalLayout
{
return [CPCursor _nativeSystemCursorWithName:CPStringFromSelector(_cmd) cssString:@"vertical-text"];
}
@end
+242 -96
View File
@@ -1,7 +1,7 @@
/* CPDatePicker.j
* AppKit
*
* Created by Alexandre Wilhelm
* Created by Alexandre Wilhelm
* Copyright 2012 <alexandre.wilhelmfr@gmail.com>
*
* This library is free software; you can redistribute it and/or
@@ -28,7 +28,6 @@
@import <Foundation/CPArray.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPDate.j>
@import <Foundation/CPDateFormatter.j>
@import <Foundation/CPLocale.j>
@import <Foundation/CPTimeZone.j>
@@ -60,25 +59,26 @@ CPEraDatePickerElementFlag = 0x0100;
*/
@implementation CPDatePicker : CPControl
{
BOOL _isBordered @accessors(getter=isBordered, setter=setBordered:);
BOOL _isBezeled @accessors(getter=isBezeled, setter=setBezeled:);
BOOL _drawsBackground @accessors(property=drawsBackground);
CPDate _dateValue @accessors(property=dateValue);
CPDate _minDate @accessors(property=minDate);
CPDate _maxDate @accessors(property=maxDate);
CPFont _textFont @accessors(property=textFont);
CPLocale _locale @accessors(property=locale);
//CPCalendar _calendar @accessors(property=calendar);
CPTimeZone _timeZone @accessors(property=timeZone);
id _delegate @accessors(property=delegate);
unsigned _datePickerElements @accessors(property=datePickerElements);
CPInteger _datePickerMode @accessors(property=datePickerMode);
CPInteger _datePickerStyle @accessors(property=datePickerStyle);
CPInteger _timeInterval @accessors(property=timeInterval);
BOOL _isBordered @accessors(getter=isBordered, setter=setBordered:);
BOOL _isBezeled @accessors(getter=isBezeled, setter=setBezeled:);
BOOL _drawsBackground @accessors(property=drawsBackground);
CPDate _dateValue @accessors(property=dateValue);
CPDate _minDate @accessors(property=minDate);
CPDate _maxDate @accessors(property=maxDate);
CPFont _textFont @accessors(property=textFont);
CPLocale _locale @accessors(property=locale);
//CPCalendar _calendar @accessors(property=calendar);
CPTimeZone _timeZone @accessors(property=timeZone);
id _delegate @accessors(property=delegate);
CPInteger _datePickerElements @accessors(property=datePickerElements);
CPInteger _datePickerMode @accessors(property=datePickerMode);
CPInteger _datePickerStyle @accessors(property=datePickerStyle);
CPInteger _timeInterval @accessors(property=timeInterval);
_CPDatePickerTextField _datePickerTextfield;
_CPDatePickerCalendar _datePickerCalendar;
BOOL _invokedByUserEvent;
unsigned _implementedCDatePickerDelegateMethods;
BOOL _isTextual;
id _datePickerComponent;
}
@@ -90,7 +90,7 @@ CPEraDatePickerElementFlag = 0x0100;
return @"datePicker";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"bezel-color": [CPColor clearColor],
@@ -135,15 +135,41 @@ CPEraDatePickerElementFlag = 0x0100;
@"clock-text-shadow-color": [CPColor clearColor],
@"clock-text-shadow-offset": CGSizeMakeZero(),
@"clock-font": [CPNull null],
@"second-hand-color": [CPColor clearColor],
@"hour-hand-color": [CPColor clearColor],
@"middle-hand-color": [CPColor clearColor],
@"minute-hand-color": [CPColor clearColor],
@"second-hand-image": [CPNull null],
@"hour-hand-image": [CPNull null],
@"middle-hand-image": [CPNull null],
@"minute-hand-image": [CPNull null],
@"size-clock": CGSizeMakeZero(),
@"second-hand-size": CGSizeMakeZero(),
@"hour-hand-size": CGSizeMakeZero(),
@"middle-hand-size": CGSizeMakeZero(),
@"minute-hand-size": CGSizeMakeZero(),
@"previous-button-size": CGSizeMakeZero(),
@"current-button-size": CGSizeMakeZero(),
@"next-button-size": CGSizeMakeZero(),
@"title-inset": [CPNull null],
@"day-label-inset": [CPNull null],
@"tile-content-inset": CGInsetMakeZero(),
@"tile-margin": [CPNull null],
@"tile-inset": CGInsetMakeZero(),
@"separator-color": [CPNull null],
@"separator-margin-width": 0,
@"separator-height": 0,
@"bezel-color-calendar-left": [CPNull null],
@"bezel-color-calendar-middle": [CPNull null],
@"bezel-color-calendar-right": [CPNull null],
@"tile-vertical-alignment": CPCenterVerticalTextAlignment,
@"tile-text-alignment": CPCenterTextAlignment,
@"hour-ampm-margin": 2,
@"time-separator-content-inset": CGInsetMakeZero(),
@"clock-second-hand-over": NO,
@"clock-draws-hours": NO,
@"clock-hours-font": [CPNull null],
@"clock-hours-text-color": [CPColor clearColor],
@"clock-hours-radius": 0,
@"calendar-clock-margin": 10,
@"clock-only-nib2cib-adjustment-frame": CPRectMakeZero(),
@"uses-focus-ring": NO
};
}
@@ -159,7 +185,7 @@ CPEraDatePickerElementFlag = 0x0100;
return [super _binderClassForBinding:theBinding];
}
- (id)_replacementKeyPathForBinding:(CPString)aBinding
- (CPString)_replacementKeyPathForBinding:(CPString)aBinding
{
if (aBinding == CPValueBinding)
return @"dateValue";
@@ -206,23 +232,58 @@ CPEraDatePickerElementFlag = 0x0100;
if (!_locale)
_locale = [CPLocale currentLocale];
if (!_timeZone)
_timeZone = [CPTimeZone systemTimeZone];
_datePickerComponent = nil;
_datePickerTextfield = [[_CPDatePickerTextField alloc] initWithFrame:[self bounds] withDatePicker:self];
[_datePickerTextfield setDateValue:_dateValue];
[self addSubview:_datePickerTextfield];
_datePickerCalendar = [[_CPDatePickerCalendar alloc] initWithFrame:[self bounds] withDatePicker:self];
[_datePickerCalendar setDateValue:_dateValue];
[_datePickerCalendar setHidden:YES];
[self addSubview:_datePickerCalendar];
[self _createComponents];
[self setNeedsDisplay:YES];
[self setNeedsLayout];
}
- (void)_createComponents
{
_isTextual = (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle) || (_datePickerStyle == CPTextFieldDatePickerStyle);
if (_datePickerComponent)
{
[_datePickerComponent removeFromSuperview];
_datePickerComponent = nil;
}
_datePickerComponent = [[(_isTextual ? _CPDatePickerTextField : _CPDatePickerCalendar) alloc] initWithFrame:[self bounds] withDatePicker:self];
[_datePickerComponent setDateValue:_dateValue];
[_datePickerComponent setControlSize:[self controlSize]];
[_datePickerComponent setDatePickerElements:_datePickerElements];
// FIXME: Don't know why but next line will cause theme compilation to fail...
// Workaround: added "if PLATFORM(DOM)"
#if PLATFORM(DOM)
[_datePickerComponent setEnabled:[self isEnabled]];
#endif
if (_isTextual)
// We need to transmit text color to the text field version (Cocoa doesn't permit adapting the calendar view text color)
[_datePickerComponent setTextColor:[self textColor]];
[self addSubview:_datePickerComponent];
}
#pragma mark -
#pragma mark Control Size
- (void)setControlSize:(CPControlSize)aControlSize
{
[super setControlSize:aControlSize];
[_datePickerComponent setControlSize:aControlSize];
if (_isTextual)
[self _sizeToControlSize];
}
#pragma mark -
#pragma mark Delegate methods
@@ -248,20 +309,8 @@ CPEraDatePickerElementFlag = 0x0100;
*/
- (void)layoutSubviews
{
[super layoutSubviews];
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
{
[_datePickerTextfield setHidden:NO];
[_datePickerCalendar setHidden:YES];
[_datePickerTextfield setNeedsLayout];
}
else
{
[_datePickerCalendar setHidden:NO];
[_datePickerTextfield setHidden:YES];
[_datePickerCalendar setNeedsLayout];
}
[_datePickerComponent setNeedsLayout];
[_datePickerComponent setNeedsDisplay:YES];
}
#pragma mark -
@@ -269,17 +318,20 @@ CPEraDatePickerElementFlag = 0x0100;
/*! Return the objectValue of the datePicker. The objectValue should take the timeZoneEffect
*/
- (void)objectValue
- (id)objectValue
{
// TODO : add timeZone effect. How to do it because js ???
return _dateValue
}
/*! Set the objectValue ofhe datePier. It has to be a CPDate
/*! Set the objectValue of the datePicker. It has to be a CPDate
@param aDateValue the dateValue
*/
- (void)setObjectValue:(CPDate)aValue
{
if (![aValue isKindOfClass:[CPDate class]])
return;
[self setDateValue:aValue];
}
@@ -291,6 +343,7 @@ CPEraDatePickerElementFlag = 0x0100;
if (aDateValue == nil)
return;
_invokedByUserEvent = NO;
[self _setDateValue:aDateValue timeInterval:_timeInterval];
}
@@ -300,6 +353,14 @@ CPEraDatePickerElementFlag = 0x0100;
*/
- (void)_setDateValue:(CPDate)aDateValue timeInterval:(CPTimeInterval)aTimeInterval
{
// Make sure to have a valid date and avoid NaN values
if (!isFinite(aDateValue))
{
[CPException raise:CPInvalidArgumentException
reason:@"aDateValue is not valid"];
return;
}
if (_minDate)
aDateValue = new Date (MAX(aDateValue, _minDate));
@@ -309,13 +370,17 @@ CPEraDatePickerElementFlag = 0x0100;
aTimeInterval = MAX(MIN(aTimeInterval, [_maxDate timeIntervalSinceDate:aDateValue]), [_minDate timeIntervalSinceDate:aDateValue]);
if ([aDateValue isEqualToDate:_dateValue] && aTimeInterval == _timeInterval)
{
[_datePickerComponent setDateValue:_dateValue];
return;
}
if (_implementedCDatePickerDelegateMethods & CPDatePicker_validateProposedDateValue_timeInterval)
{
// constrain timeInterval also
var aStartDateRef = function(x){if (typeof x == 'undefined') return aDateValue; aDateValue = x;}
var aTimeIntervalRef = function(x){if (typeof x == 'undefined') return aTimeInterval; aTimeInterval = x;}
var aStartDateRef = function(x){if (typeof x == 'undefined') return aDateValue; aDateValue = x;};
var aTimeIntervalRef = function(x){if (typeof x == 'undefined') return aTimeInterval; aTimeInterval = x;};
[_delegate datePicker:self validateProposedDateValue:aStartDateRef timeInterval:aTimeIntervalRef];
}
@@ -331,12 +396,10 @@ CPEraDatePickerElementFlag = 0x0100;
_timeInterval = (_datePickerMode == CPSingleDateMode)? 0 : aTimeInterval;
[self didChangeValueForKey:@"timeInterval"];
[self sendAction:[self action] to:[self target]];
if (_invokedByUserEvent)
[self sendAction:[self action] to:[self target]];
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
[_datePickerTextfield setDateValue:_dateValue];
else
[_datePickerCalendar setDateValue:_dateValue];
[_datePickerComponent setDateValue:_dateValue];
}
/*! Set the minDate of the datePicker
@@ -344,6 +407,9 @@ CPEraDatePickerElementFlag = 0x0100;
*/
- (void)setMinDate:(CPDate)aMinDate
{
if (_minDate === aMinDate)
return;
[self willChangeValueForKey:@"minDate"];
_minDate = aMinDate;
[self didChangeValueForKey:@"minDate"];
@@ -356,6 +422,9 @@ CPEraDatePickerElementFlag = 0x0100;
*/
- (void)setMaxDate:(CPDate)aMaxDate
{
if (_maxDate === aMaxDate)
return;
[self willChangeValueForKey:@"maxDate"];
_maxDate = aMaxDate;
[self didChangeValueForKey:@"maxDate"];
@@ -366,10 +435,34 @@ CPEraDatePickerElementFlag = 0x0100;
/*! Set the syle of the datePicker
@param aDatePickerStyle the datePicker style
*/
- (void)setDatePickerStyle:(CPDate)aDatePickerStyle
- (void)setDatePickerStyle:(CPInteger)aDatePickerStyle
{
if (_datePickerStyle === aDatePickerStyle)
return;
_datePickerStyle = aDatePickerStyle;
// This is needed in order to specify different theme attributes values for textual / graphical date picker
if (_datePickerStyle === CPClockAndCalendarDatePickerStyle)
[self setThemeState:CPThemeStateAlternateState];
else
[self unsetThemeState:CPThemeStateAlternateState];
// This is needed in order to specify different theme attributes values for with / without stepper textual date picker
if (_datePickerStyle === CPTextFieldAndStepperDatePickerStyle)
[self setThemeState:CPThemeStateComposedControl];
else
[self unsetThemeState:CPThemeStateComposedControl];
[self setControlSize:[self controlSize]];
if (_datePickerComponent)
{
// We already have a component so we need to update it
[_datePickerComponent resignFirstResponder];
[self _createComponents];
}
[self setNeedsDisplay:YES];
[self setNeedsLayout];
}
@@ -377,10 +470,16 @@ CPEraDatePickerElementFlag = 0x0100;
/*! Set the elements of the datePicker
@param aDatePickerElements the datePicker elements
*/
- (void)setDatePickerElements:(CPDate)aDatePickerElements
- (void)setDatePickerElements:(CPInteger)aDatePickerElements
{
if (_datePickerElements === aDatePickerElements)
return;
_datePickerElements = aDatePickerElements;
// Notify the component of the new value
[_datePickerComponent setDatePickerElements:_datePickerElements];
[self setNeedsDisplay:YES];
[self setNeedsLayout];
}
@@ -388,8 +487,11 @@ CPEraDatePickerElementFlag = 0x0100;
/*! Set the mode of the datePicker
@param aDatePickerMode the datePicker mode
*/
- (void)setDatePickerMode:(CPDate)aDatePickerMode
- (void)setDatePickerMode:(CPInteger)aDatePickerMode
{
if (_datePickerMode === aDatePickerMode)
return;
_datePickerMode = aDatePickerMode;
if (_datePickerMode == CPSingleDateMode)
@@ -415,6 +517,9 @@ CPEraDatePickerElementFlag = 0x0100;
*/
- (void)setLocale:(CPLocale)aLocale
{
if (_locale === aLocale)
return;
_locale = aLocale;
if (_formatter)
@@ -425,7 +530,9 @@ CPEraDatePickerElementFlag = 0x0100;
}
// This will update the textFields (usefull when changing with a date with pm and am)
[_datePickerTextfield setDateValue:_dateValue];
if (_isTextual)
[_datePickerComponent setDateValue:_dateValue];
[self setNeedsDisplay:YES];
[self setNeedsLayout];
}
@@ -436,6 +543,9 @@ CPEraDatePickerElementFlag = 0x0100;
*/
- (void)setBezeled:(BOOL)shouldBeBezeled
{
if (_isBezeled === shouldBeBezeled)
return;
_isBezeled = shouldBeBezeled;
if (shouldBeBezeled)
@@ -450,6 +560,9 @@ CPEraDatePickerElementFlag = 0x0100;
*/
- (void)setBordered:(BOOL)shouldBeBordered
{
if (_isBordered === shouldBeBordered)
return;
_isBordered = shouldBeBordered;
if (shouldBeBordered)
@@ -465,6 +578,22 @@ CPEraDatePickerElementFlag = 0x0100;
- (void)setTextFont:(CPFont)aFont
{
[self setFont:aFont];
if (_isTextual)
[_datePickerComponent setTextFont:aFont];
}
/*!
Sets the color of the control.
@param aColor
*/
- (void)setTextColor:(CPColor)aColor
{
[super setTextColor:aColor];
if (_isTextual)
[_datePickerComponent setTextColor:aColor];
// REM: in Cocoa, setTextColor has no effect on calendar view
}
/*! Sets the enabled status of the control. Controls that are not enabled can not be used by the user and obtain the CPThemeStateDisabled theme state.
@@ -474,8 +603,10 @@ CPEraDatePickerElementFlag = 0x0100;
{
[super setEnabled:aBoolean];
[_datePickerTextfield setEnabled:aBoolean];
[_datePickerCalendar setEnabled:aBoolean];
[_datePickerComponent setEnabled:aBoolean];
if (!aBoolean)
[self resignFirstResponder];
}
/*! Set the background color of the datePicker
@@ -492,6 +623,9 @@ CPEraDatePickerElementFlag = 0x0100;
*/
- (void)setDrawsBackground:(BOOL)aBoolean
{
if (_drawsBackground === aBoolean)
return;
[self willChangeValueForKey:@"drawsBackground"];
_drawsBackground = aBoolean;
[self didChangeValueForKey:@"drawsBackground"];
@@ -504,11 +638,16 @@ CPEraDatePickerElementFlag = 0x0100;
*/
- (void)setTimeZone:(CPTimeZone)aTimeZone
{
if (_timeZone === aTimeZone)
return;
[self willChangeValueForKey:@"timeZone"];
_timeZone = aTimeZone;
[self didChangeValueForKey:@"timeZone"];
[self setNeedsLayout];
[_datePickerComponent setDateValue:_dateValue];
}
@@ -519,12 +658,17 @@ CPEraDatePickerElementFlag = 0x0100;
*/
- (BOOL)becomeFirstResponder
{
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
[_datePickerTextfield _selecteTextFieldWithFlags:[[CPApp currentEvent] modifierFlags]];
else
return NO;
if (_isTextual)
{
if (![super becomeFirstResponder])
return NO;
return YES;
[_datePickerComponent _selectTextFieldWithFlags:[[CPApp currentEvent] modifierFlags]];
return YES;
}
return NO;
}
/*! Return YES
@@ -538,8 +682,8 @@ CPEraDatePickerElementFlag = 0x0100;
*/
- (BOOL)resignFirstResponder
{
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
[_datePickerTextfield resignFirstResponder];
if (_isTextual)
[_datePickerComponent resignFirstResponder];
return YES;
}
@@ -579,14 +723,6 @@ CPEraDatePickerElementFlag = 0x0100;
return [[_locale objectForKey:CPLocaleCountryCode] isEqualToString:@"US"];
}
/*! Check if we are in the english format or not. Depending on the locale
*/
- (BOOL)_isEnglishFormat
{
return [[_locale objectForKey:CPLocaleLanguageCode] isEqualToString:@"en"];
}
#pragma mark -
#pragma mark Key event
@@ -595,8 +731,8 @@ CPEraDatePickerElementFlag = 0x0100;
*/
- (void)keyDown:(CPEvent)anEvent
{
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
[_datePickerTextfield keyDown:anEvent];
if (_isTextual)
[_datePickerComponent keyDown:anEvent];
}
@end
@@ -622,19 +758,22 @@ var CPDatePickerModeKey = @"CPDatePickerModeKey",
if (self)
{
_textFont = [aCoder decodeObjectForKey:CPTextFontKey];
_minDate = [aCoder decodeObjectForKey:CPMinDateKey] || [CPDate distantPast];
_maxDate = [aCoder decodeObjectForKey:CPMaxDateKey] || [CPDate distantFuture];
_timeInterval = [aCoder decodeDoubleForKey:CPIntervalKey];
_datePickerMode = [aCoder decodeIntForKey:CPDatePickerModeKey];
_datePickerElements = [aCoder decodeIntForKey:CPDatePickerElementsKey];
_datePickerStyle = [aCoder decodeIntForKey:CPDatePickerStyleKey];
_locale = [aCoder decodeObjectForKey:CPLocaleKey];
_dateValue = [aCoder decodeObjectForKey:CPDateValueKey];
_backgroundColor = [aCoder decodeObjectForKey:CPBackgroundColorKey];
_drawsBackground = [aCoder decodeBoolForKey:CPDrawsBackgroundKey];
_isBordered = [aCoder decodeBoolForKey:CPBorderedKey];
[self setBordered:[aCoder decodeBoolForKey:CPBorderedKey]];
[self setDrawsBackground:[aCoder decodeBoolForKey:CPDrawsBackgroundKey]];
[self setDatePickerElements:[aCoder decodeIntForKey:CPDatePickerElementsKey]];
[self setDatePickerMode:[aCoder decodeIntForKey:CPDatePickerModeKey]];
[self setDatePickerStyle:[aCoder decodeIntForKey:CPDatePickerStyleKey]];
[self setMinDate:[aCoder decodeObjectForKey:CPMinDateKey] || [CPDate distantPast]];
[self setMaxDate:[aCoder decodeObjectForKey:CPMaxDateKey] || [CPDate distantFuture]];
[self setLocale:[aCoder decodeObjectForKey:CPLocaleKey]];
[self _init];
[self setTextFont:[aCoder decodeObjectForKey:CPTextFontKey]];
[self setTimeInterval:[aCoder decodeDoubleForKey:CPIntervalKey]];
[self setDateValue:[aCoder decodeObjectForKey:CPDateValueKey]];
}
return self
@@ -642,23 +781,30 @@ var CPDatePickerModeKey = @"CPDatePickerModeKey",
- (void)encodeWithCoder:(CPCoder)aCoder
{
// Before encoding, we remove all subviews as we'll recreate them at loading
while ([[self subviews] count] > 0)
[[[self subviews] lastObject] removeFromSuperview];
[super encodeWithCoder:aCoder];
[aCoder encodeDouble:_timeInterval forKey:CPIntervalKey];
[aCoder encodeInt:_datePickerMode forKey:CPDatePickerModeKey];
[aCoder encodeInt:_datePickerStyle forKey:CPDatePickerStyleKey];
[aCoder encodeInt:_datePickerElements forKey:CPDatePickerElementsKey];
[aCoder encodeObject:_minDate forKey:CPMinDateKey];
[aCoder encodeObject:_maxDate forKey:CPMaxDateKey]
[aCoder encodeObject:_dateValue forKey:CPDateValueKey];;
[aCoder encodeObject:_maxDate forKey:CPMaxDateKey];
[aCoder encodeObject:_dateValue forKey:CPDateValueKey];
[aCoder encodeObject:_textFont forKey:CPTextFontKey];
[aCoder encodeObject:_locale forKey:CPLocaleKey];
[aCoder encodeObject:_backgroundColor forKey:CPBackgroundColorKey];
[aCoder encodeObject:_drawsBackground forKey:CPDrawsBackgroundKey];
[aCoder encodeObject:_isBordered forKey:CPBorderedKey];
}
@end
// FIXME: add support for CPEditorRegistrationProtocol as implemented for CPTextField
@implementation _CPDatePickerValueBinder : CPBinder
{
}
@@ -688,4 +834,4 @@ var CPDatePickerModeKey = @"CPDatePickerModeKey",
self.setMilliseconds(99);
}
@end
@end
+98
View File
@@ -0,0 +1,98 @@
/* _CPDatePickerBox.j
* AppKit
*
* Created by Alexandre Wilhelm
* Copyright 2012 <alexandre.wilhelmfr@gmail.com>
*
* 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"
@class CPDatePicker
@implementation _CPDatePickerBox : CPView
{
CPDatePicker _datePicker @accessors(property=datePicker);
}
- (void)drawRect:(CGRect)aRect
{
[super drawRect:aRect];
if ([_datePicker isCSSBased])
return;
if ([_datePicker isBordered])
{
var context = [[CPGraphicsContext currentContext] graphicsPort],
borderWidth = [_datePicker valueForThemeAttribute:@"border-width"] / 2;
CGContextBeginPath(context);
CGContextSetStrokeColor(context, [_datePicker valueForThemeAttribute:@"border-color" inState:[_datePicker themeState]]);
CGContextSetLineWidth(context, [_datePicker valueForThemeAttribute:@"border-width"]);
CGContextMoveToPoint(context, borderWidth, borderWidth);
CGContextAddLineToPoint(context, aRect.size.width - borderWidth, borderWidth);
CGContextAddLineToPoint(context, aRect.size.width - borderWidth, aRect.size.height - borderWidth);
CGContextAddLineToPoint(context, borderWidth, aRect.size.height - borderWidth);
CGContextAddLineToPoint(context, borderWidth,borderWidth);
CGContextStrokePath(context);
CGContextClosePath(context);
}
}
- (CGRect)rectForEphemeralSubviewNamed:(CPString)aName
{
if (aName === "bezel-view")
return [self bounds];
return [super rectForEphemeralSubviewNamed:aName];
}
- (CPView)createEphemeralSubviewNamed:(CPString)aName
{
if (aName === "bezel-view")
{
var view = [[CPView alloc] initWithFrame:CGRectMakeZero()];
[view setHitTests:NO];
return view;
}
return [super createEphemeralSubviewNamed:aName];
}
- (void)layoutSubviews
{
if ([_datePicker isCSSBased])
{
var bezelView = [self layoutEphemeralSubviewNamed:@"bezel-view"
positioned:CPWindowBelow
relativeToEphemeralSubviewNamed:nil];
[bezelView setBackgroundColor:[_datePicker currentValueForThemeAttribute:@"bezel-color"]];
}
if ([_datePicker drawsBackground])
[self setBackgroundColor:[_datePicker backgroundColor]];
else
[self setBackgroundColor:[CPColor clearColor]];
}
@end
File diff suppressed because it is too large Load Diff
+441 -117
View File
@@ -1,4 +1,5 @@
/* _CPDatePickerClock.j
/*
* _CPDatePickerClock.j
* AppKit
*
* Created by Alexandre Wilhelm
@@ -19,41 +20,67 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/CPKeyedArchiver.j>
@import <Foundation/CPKeyedUnarchiver.j>
@import "CPView.j"
@import "CPTextField.j"
@import "CPImageView.j"
@import "CPImage.j"
@import "CALayer.j"
@class _CPCibCustomResource
@class CPDatePicker
@class HandImageLayer
@class HoursLayer
@class HandLayer
@global CPHourMinuteSecondDatePickerElementFlag
@global CPTextFieldAndStepperDatePickerStyle
@global CPTextFieldDatePickerStyle
@implementation _CPDatePickerClock : CPView
var RADIANS = Math.PI / 180;
@typedef _CPDatePickerClockHand
_CPDatePickerClockHours = 1;
_CPDatePickerClockMinutes = 2;
_CPDatePickerClockSeconds = 3;
@implementation _CPDatePickerClock : CPControl
{
BOOL _isEnabled;
CALayer _rootLayer;
CALayer _hourHandLayer;
CALayer _minuteHandLayer;
CALayer _secondHandLayer;
CALayer _middleHandLayer;
CPDatePicker _datePicker;
CPTextField _PMAMTextField;
BOOL _isEnabled;
HoursLayer _rootLayer;
HandLayer _hourHandLayer;
HandLayer _minuteHandLayer;
HandLayer _secondHandLayer;
CALayer _middleHandLayer;
CPDatePicker _datePicker;
CPTextField _PMAMTextField;
CALayer _currentHandLayer;
_CPDatePickerClockHand _currentHand;
CPInteger _currentRepresentedValue;
float _currentValueShift;
CPInteger _numberOfUnits;
BOOL _trackingHand;
CPInteger _representedHours;
CPInteger _representedMinutes;
CPInteger _representedSeconds;
BOOL _representedHourIsPM;
CPInteger _datePickerElements @accessors(getter=datePickerElements);
}
#pragma mark -
#pragma mark Init methods
/*! Init a new _CPDatePickerClock
@param aFrame
@param aDatePicker
@return a new instance of _CPDatePickerClock
*/
- (id)initWithFrame:(CGRect)aFrame datePicker:(CPDatePicker)aDatePicker
{
if (self = [super initWithFrame:aFrame])
{
_datePicker = aDatePicker;
_datePicker = aDatePicker;
_datePickerElements = [_datePicker datePickerElements];
_trackingHand = NO;
_PMAMTextField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
@@ -71,7 +98,7 @@
var middleHandSize = [_datePicker valueForThemeAttribute:@"middle-hand-size"],
minuteHandSize = [_datePicker valueForThemeAttribute:@"minute-hand-size"],
hourHandSize = [_datePicker valueForThemeAttribute:@"hour-hand-size"],
hourHandSize = [_datePicker valueForThemeAttribute:@"hour-hand-size"],
secondHandSize = [_datePicker valueForThemeAttribute:@"second-hand-size"];
// We use layer to make the rotation possible
@@ -95,145 +122,325 @@
[_middleHandLayer setAnchorPoint:CGPointMakeZero()];
[_middleHandLayer setPosition:CGPointMake(0.0, 0.0)];
_rootLayer = [CALayer layer];
_rootLayer = [[HoursLayer alloc] init];
[self setWantsLayer:YES];
[self setLayer:_rootLayer];
[_hourHandLayer setNeedsDisplay];
[_middleHandLayer setNeedsDisplay];
[_secondHandLayer setNeedsDisplay];
[_minuteHandLayer setNeedsDisplay];
[self _initHands];
[_rootLayer addSublayer:_hourHandLayer];
[_rootLayer addSublayer:_minuteHandLayer];
[_rootLayer addSublayer:_secondHandLayer];
[_rootLayer addSublayer:_middleHandLayer];
if ([_datePicker valueForThemeAttribute:@"clock-second-hand-over"])
{
[_rootLayer addSublayer:_middleHandLayer];
[_rootLayer addSublayer:_secondHandLayer];
}
else
{
[_rootLayer addSublayer:_secondHandLayer];
[_rootLayer addSublayer:_middleHandLayer];
}
[_rootLayer setDrawsHours:[_datePicker valueForThemeAttribute:@"clock-draws-hours"]];
[_rootLayer setNeedsDisplay];
}
return self;
}
#pragma mark -
#pragma mark Layout methods
/*! Layout the subviews
*/
- (void)layoutSubviews
- (void)_initHands
{
[super layoutSubviews];
var middleHandImage = [_datePicker currentValueForThemeAttribute:@"middle-hand-image"],
hourHandImage = [_datePicker currentValueForThemeAttribute:@"hour-hand-image"],
minuteHandImage = [_datePicker currentValueForThemeAttribute:@"minute-hand-image"],
secondHandImage = [_datePicker currentValueForThemeAttribute:@"second-hand-image"];
var bounds = [self bounds],
dateValue = [[_datePicker dateValue] copy];
// If hand images are true CPImage, we have to duplicate them to avoid
// the multiple delegates bug when multiple clocks are displayed
[dateValue _dateWithTimeZone:[_datePicker timeZone]];
if ([middleHandImage isKindOfClass:[CPImage class]])
middleHandImage = [middleHandImage duplicate];
[self setBackgroundColor:[_datePicker valueForThemeAttribute:@"bezel-color-clock" inState:[_datePicker themeState]]];
[_middleHandLayer setBackgroundHandColor:[_datePicker valueForThemeAttribute:@"middle-hand-color" inState:[_datePicker themeState]]];
[_hourHandLayer setBackgroundHandColor:[_datePicker valueForThemeAttribute:@"hour-hand-color" inState:[_datePicker themeState]]];
[_minuteHandLayer setBackgroundHandColor:[_datePicker valueForThemeAttribute:@"minute-hand-color" inState:[_datePicker themeState]]];
[_secondHandLayer setBackgroundHandColor:[_datePicker valueForThemeAttribute:@"second-hand-color" inState:[_datePicker themeState]]];
if ([hourHandImage isKindOfClass:[CPImage class]])
hourHandImage = [hourHandImage duplicate];
if ([_datePicker _isEnglishFormat])
{
if (dateValue.getHours() > 11)
[_PMAMTextField setStringValue:@"PM"]
else
[_PMAMTextField setStringValue:@"AM"];
if ([minuteHandImage isKindOfClass:[CPImage class]])
minuteHandImage = [minuteHandImage duplicate];
[_PMAMTextField sizeToFit];
[_PMAMTextField setFrameOrigin:CGPointMake(bounds.size.width / 2 - [_PMAMTextField frameSize].width / 2, bounds.size.height / 2 + 15)];
[_PMAMTextField setHidden:NO];
}
else
{
[_PMAMTextField setHidden:YES];
}
if ([secondHandImage isKindOfClass:[CPImage class]])
secondHandImage = [secondHandImage duplicate];
[_hourHandLayer setRotationRadians:[self _hourPositionRadianForDate:dateValue]];
[_minuteHandLayer setRotationRadians:[self _minutePositionRadianForDate:dateValue]];
[_secondHandLayer setRotationRadians:[self _secondPositionRadianForDate:dateValue]];
[_middleHandLayer setImage:middleHandImage];
[_hourHandLayer setImage:hourHandImage];
[_minuteHandLayer setImage:minuteHandImage];
[_secondHandLayer setImage:secondHandImage];
// Check if we have to display the hand second
if (([_datePicker datePickerElements] & CPHourMinuteSecondDatePickerElementFlag) == CPHourMinuteSecondDatePickerElementFlag)
[_secondHandLayer setHidden:NO];
else
[_secondHandLayer setHidden:YES];
[_hourHandLayer setNeedsDisplay];
[_middleHandLayer setNeedsDisplay];
[_secondHandLayer setNeedsDisplay];
[_minuteHandLayer setNeedsDisplay];
[_rootLayer setFont:[_datePicker currentValueForThemeAttribute:@"clock-hours-font"]];
[_rootLayer setTextColor:[_datePicker currentValueForThemeAttribute:@"clock-hours-text-color"]];
[_rootLayer setRadius:[_datePicker currentValueForThemeAttribute:@"clock-hours-radius"]];
[_rootLayer setNeedsDisplay];
}
#pragma mark -
#pragma mark Getter Setter methods
/*! Return the radian position of the hour
*/
- (float)_hourPositionRadianForDate:(CPDate)aDate
- (void)setDatePickerElements:(CPInteger)aDatePickerElements
{
var hours = aDate.getHours() + aDate.getMinutes() / 60;
_datePickerElements = aDatePickerElements;
return (360 * hours / 12) * (Math.PI / 180)
// Check if we have to display the hand second
// FIXME: Don't know why but next line will cause theme compilation to fail...
// Workaround: added "if PLATFORM(DOM)"
#if PLATFORM(DOM)
[_secondHandLayer setHidden:!((_datePickerElements & CPHourMinuteSecondDatePickerElementFlag) == CPHourMinuteSecondDatePickerElementFlag)];
#endif
}
/*! Return the radian position of the second
*/
- (float)_secondPositionRadianForDate:(CPDate)aDate
#pragma mark Layout methods
- (void)layoutSubviews
{
return (360 * aDate.getSeconds() / 60) * (Math.PI / 180)
// While tracking a hand, we don't want the whole thing to be relayouted at each mouse movement
if (_trackingHand)
return;
[self setBackgroundColor:[_datePicker currentValueForThemeAttribute:@"bezel-color-clock"]];
var dateValue = [[_datePicker dateValue] copy];
[dateValue _dateWithTimeZone:[_datePicker timeZone]];
_representedHours = dateValue.getHours();
_representedMinutes = dateValue.getMinutes();
_representedSeconds = dateValue.getSeconds();
_representedHourIsPM = (_representedHours > 11);
// Hours are expressed in 24 hours format, we need 12 hours format
_representedHours -= (_representedHourIsPM ? 12 : 0);
[self _updateHands];
// FIXME: Workaround. Seems that CALayer doesn't redraw without an event
[CALayer runLoopUpdateLayers];
}
/*! Return the radian position of the minute
*/
- (float)_minutePositionRadianForDate:(CPDate)aDate
- (void)_updateHands
{
var minutes = aDate.getMinutes() + aDate.getSeconds() / 60;
var bounds = [self bounds];
return (360 * minutes / 60) * (Math.PI / 180)
[_PMAMTextField setStringValue:_representedHourIsPM ? @"PM" : @"AM"];
[_PMAMTextField sizeToFit];
[_PMAMTextField setFrameOrigin:CGPointMake(bounds.size.width / 2 - [_PMAMTextField frameSize].width / 2, bounds.size.height / 2 + 15)];
[_hourHandLayer setRotationRadians:(360 * (_representedHours + _representedMinutes / 60) / 12) * RADIANS];
[_minuteHandLayer setRotationRadians:(360 * (_representedMinutes + _representedSeconds / 60) / 60) * RADIANS];
[_secondHandLayer setRotationRadians:(360 * _representedSeconds / 60) * RADIANS];
[_hourHandLayer setNeedsDisplay];
[_minuteHandLayer setNeedsDisplay];
[_secondHandLayer setNeedsDisplay];
// [_middleHandLayer setNeedsDisplay];
}
/*! Set enabled
@param aBoolean
*/
- (void)setEnabled:(BOOL)aBoolean
{
_isEnabled = aBoolean;
[_PMAMTextField setEnabled:aBoolean];
[_hourHandLayer setEnabled:aBoolean];
[_middleHandLayer setEnabled:aBoolean];
[_secondHandLayer setEnabled:aBoolean];
[_minuteHandLayer setEnabled:aBoolean];
#pragma mark Accessors
- (void)setEnabled:(BOOL)shouldEnable
{
shouldEnable = !!shouldEnable;
if (shouldEnable === _isEnabled)
return;
_isEnabled = shouldEnable;
[self _initHands];
[self setNeedsLayout];
}
#pragma mark Mouse actions
- (void)mouseDown:(CPEvent)anEvent
{
if (!_isEnabled)
return;
var currentLocation = [self convertPoint:[anEvent locationInWindow] fromView:nil];
if ([_secondHandLayer handIsHitAtPoint:currentLocation])
{
_currentHandLayer = _secondHandLayer;
_currentHand = _CPDatePickerClockSeconds;
_currentRepresentedValue = _representedSeconds;
_currentValueShift = 0;
_numberOfUnits = 60;
}
else if ([_minuteHandLayer handIsHitAtPoint:currentLocation])
{
_currentHandLayer = _minuteHandLayer;
_currentHand = _CPDatePickerClockMinutes;
_currentRepresentedValue = _representedMinutes;
_currentValueShift = _representedSeconds / 60;
_numberOfUnits = 60;
}
else if ([_hourHandLayer handIsHitAtPoint:currentLocation])
{
_currentHandLayer = _hourHandLayer;
_currentHand = _CPDatePickerClockHours;
_currentRepresentedValue = _representedHours;
_currentValueShift = _representedMinutes / 60;
_numberOfUnits = 12;
}
else
{
_currentHandLayer = nil;
_currentHand = CPNotFound;
_currentRepresentedValue = CPNotFound;
_currentValueShift = CPNotFound;
_numberOfUnits = CPNotFound;
}
if (_currentHandLayer)
[self trackMouse:anEvent];
}
- (BOOL)tracksMouseOutsideOfFrame
{
return YES;
}
- (BOOL)startTrackingAt:(CGPoint)aPoint
{
_trackingHand = YES;
return YES;
}
- (BOOL)continueTracking:(CGPoint)lastPoint at:(CGPoint)aPoint
{
var dx = aPoint.x -_bounds.size.width / 2,
dy = _bounds.size.height / 2 - aPoint.y,
angle = (PI_2 - ATAN2(dy,dx) + PI2) % PI2,
value = ROUND(angle * _numberOfUnits / PI2 - _currentValueShift) % _numberOfUnits;
if (value !== _currentRepresentedValue)
{
var movedForward = (_currentRepresentedValue > _numberOfUnits * 3/4) && (value < _numberOfUnits / 4),
movedBackward = (_currentRepresentedValue < _numberOfUnits / 4) && (value > _numberOfUnits * 3/4),
dateValue = [[_datePicker dateValue] copy];
[dateValue _dateWithTimeZone:[_datePicker timeZone]];
switch (_currentHand)
{
case _CPDatePickerClockHours:
if (movedForward || movedBackward)
{
_representedHourIsPM = !_representedHourIsPM;
if (movedForward && !_representedHourIsPM)
// Day++
dateValue.setDate(dateValue.getDate() + 1);
else if (movedBackward && _representedHourIsPM)
// Day--
dateValue.setDate(dateValue.getDate() - 1);
}
dateValue.setHours(value + (_representedHourIsPM ? 12 : 0));
break;
case _CPDatePickerClockMinutes:
if (movedForward)
// Hours++
dateValue.setHours(dateValue.getHours() + 1);
else if (movedBackward)
// Hours--
dateValue.setHours(dateValue.getHours() - 1);
dateValue.setMinutes(value);
break;
case _CPDatePickerClockSeconds:
if (movedForward)
// Minutes++
dateValue.setMinutes(dateValue.getMinutes() + 1);
else if (movedBackward)
// Minutes--
dateValue.setMinutes(dateValue.getMinutes() - 1);
dateValue.setSeconds(value);
break;
}
#if PLATFORM(DOM)
_datePicker._invokedByUserEvent = YES;
#endif
[_datePicker _setDateValue:dateValue timeInterval:[_datePicker timeInterval]];
#if PLATFORM(DOM)
_datePicker._invokedByUserEvent = NO;
#endif
// We have to adapt represented values
_representedHours = dateValue.getHours();
_representedMinutes = dateValue.getMinutes();
_representedSeconds = dateValue.getSeconds();
_representedHourIsPM = (_representedHours > 11);
// Hours are expressed in 24 hours format, we need 12 hours format
_representedHours -= (_representedHourIsPM ? 12 : 0);
switch (_currentHand) {
case _CPDatePickerClockHours:
_currentRepresentedValue = _representedHours;
break;
case _CPDatePickerClockMinutes:
_currentRepresentedValue = _representedMinutes;
break;
case _CPDatePickerClockSeconds:
_currentRepresentedValue = _representedSeconds;
break;
}
[self _updateHands];
}
return YES;
}
- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
{
_trackingHand = NO;
}
@end
#pragma mark -
@implementation HandLayer : CALayer
{
BOOL _isEnabled @accessors(setter=setEnabled:, getter=isEnabled);
CALayer _imageLayer;
float _rotationRadians;
CPImage _image;
HandImageLayer _imageLayer;
float _rotationRadians;
}
#pragma mark -
#pragma mark Init methods
/*! Init a new hand layer with an image. The image will be draw in a ImageLayer
@param anImage
@return a new instance of handLayer
*/
- (id)initWithSize:(CGSize)aSize
{
if (self = [super init])
{
_isEnabled = YES;
_imageLayer = [CALayer layer];
_imageLayer = [HandImageLayer layer];
_rotationRadians = 0;
[_imageLayer setDelegate:self];
@@ -241,15 +448,15 @@
[self addSublayer:_imageLayer];
}
return self;
}
#pragma mark -
#pragma mark Setter Getter methods
/*! Set the bounds of the layer. The imageLayer will be at the center of this bounds
@param aRect
/*!
Set the bounds of the layer. The imageLayer will be at the center of this bounds.
*/
- (void)setBounds:(CGRect)aRect
{
@@ -258,12 +465,22 @@
[_imageLayer setPosition:CGPointMake(CGRectGetMidX(aRect), CGRectGetMidY(aRect))];
}
/*! Set the rotation of the imageLayer
@param radians
*/
- (void)setImage:(CPImage)anImage
{
if (_image === anImage)
return;
if ([anImage isKindOfClass:[_CPCibCustomResource class]])
_image = [anImage imageFromCoder:nil];
else
_image = anImage;
[_imageLayer setNeedsDisplay];
}
- (void)setRotationRadians:(float)radians
{
if (_rotationRadians == radians)
if (_rotationRadians === radians)
return;
_rotationRadians = radians;
@@ -273,15 +490,122 @@
1.0, 1.0)];
}
- (void)setBackgroundHandColor:(CPColor)aColor
- (void)imageDidLoad:(CPImage)anImage
{
[_imageLayer setBackgroundColor:aColor];
[_imageLayer setNeedsDisplay];
}
- (void)setEnabled:(BOOL)aBoolean
- (void)drawLayer:(CALayer)aLayer inContext:(CGContext)aContext
{
_isEnabled = aBoolean;
[self setNeedsDisplay];
if ([_image loadStatus] != CPImageLoadStatusCompleted)
[_image setDelegate:self];
else
CGContextDrawImage(aContext, [aLayer bounds], _image);
}
- (BOOL)handIsHitAtPoint:(CGPoint)aPoint
{
return (!_isHidden && [_imageLayer hitTest:aPoint] === _imageLayer);
}
- (void)setNeedsDisplay
{
[super setNeedsDisplay];
[_imageLayer setNeedsDisplay];
}
@end
#pragma mark -
@implementation HandImageLayer : CALayer
{
CGRect _handBounds;
}
// We have to adapt hitTest so it only takes the hand into account (that's the top half of the image layer)
// We are also sure there's no sublayers
- (CALayer)hitTest:(CGPoint)aPoint
{
if (_isHidden)
return nil;
var point = CGPointApplyAffineTransform(aPoint, _transformToLayer);
return CGRectContainsPoint(_handBounds, point) ? self : nil;
}
- (void)setBounds:(CGRect)aBounds
{
if (CGRectEqualToRect(_bounds, aBounds))
return;
_handBounds = CGRectMakeCopy(aBounds);
_handBounds.size.height = _handBounds.size.height / 2;
[super setBounds:aBounds];
}
@end
#pragma mark -
@implementation HoursLayer : CALayer
{
BOOL _drawsHours;
CPFont _font @accessors(property=font);
CPColor _textColor @accessors(property=textColor);
float _radius @accessors(property=radius);
}
- (id)init
{
if (self = [super init])
{
_drawsHours = NO;
}
return self;
}
- (void)setDrawsHours:(BOOL)shouldDrawHours
{
shouldDrawHours = !!shouldDrawHours;
if (_drawsHours === shouldDrawHours)
return;
_drawsHours = shouldDrawHours;
[self setNeedsDisplay];
}
- (void)drawInContext:(CGContext)aContext
{
[super drawInContext:aContext];
if (_drawsHours)
{
var bounds = [self bounds],
centerX = bounds.size.width / 2,
centerY = bounds.size.height / 2;
CGContextSelectFont(aContext, _font);
CGContextSetFillColor(aContext, _textColor);
aContext.textBaseline = @"middle";
aContext.textAlign = @"center";
for (var i = 1, angle = 60.0, x, y; i < 13; i++, angle -= 30.0)
{
x = centerX + _radius * COS(angle * RADIANS);
y = centerY - _radius * SIN(angle * RADIANS);
aContext.fillText(i, x, y);
}
}
}
@end
+280
View File
@@ -0,0 +1,280 @@
/* _CPDatePickerDayView.j
* AppKit
*
* Created by Alexandre Wilhelm
* Copyright 2012 <alexandre.wilhelmfr@gmail.com>
*
* 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 "_CPDatePickerDayViewTextField.j"
@class CPDatePicker
@implementation _CPDatePickerDayView : CPControl
{
CPDate _date @accessors(property=date);
BOOL _isDisabled;
BOOL _isHighlighted;
BOOL _isSelected;
CPDatePicker _datePicker;
CPTextField _textField;
CPInteger _dayInWeek @accessors(property=dayInWeek);
BOOL _firstSelected @accessors(property=firstSelected);
BOOL _lastSelected @accessors(property=lastSelected);
}
#pragma mark Init methods
/*! Create a new instance of _CPDatePickerDayView
@param aFrame
@param aDatePicker
@return a new instance of _CPDatePickerDayView
*/
- (id)initWithFrame:(CGRect)aFrame withDatePicker:(CPDatePicker)aDatePicker
{
if (self = [super initWithFrame:aFrame])
{
[self setHitTests:NO];
_datePicker = aDatePicker;
// FIXME: Beginning with Aristo3, the text field is directly themed based on a new class _CPDatePickerDayViewTextField
if ([self isCSSBased])
{
_textField = [[_CPDatePickerDayViewTextField alloc] initWithFrame:aFrame];
}
else
{
_textField = [[CPTextField alloc] initWithFrame:aFrame];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-alignment"] forThemeAttribute:@"alignment"];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-vertical-alignment"] forThemeAttribute:@"vertical-alignment"];
var contentInset = [_datePicker valueForThemeAttribute:@"tile-content-inset"];
if (contentInset)
[_textField setValue:contentInset forThemeAttribute:@"content-inset"];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inState:CPThemeStateNormal] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inState:CPThemeStateSelected] forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inState:CPThemeStateDisabled] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inStates:[CPThemeStateDisabled, CPThemeStateSelected]] forThemeAttribute:@"font" inStates:[CPThemeStateDisabled, CPThemeStateSelected]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inStates:[CPThemeStateDisabled, CPThemeStateSelected]]forThemeAttribute:@"text-color" inStates:[CPThemeStateDisabled, CPThemeStateSelected]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inStates:[CPThemeStateDisabled, CPThemeStateSelected]] forThemeAttribute:@"text-shadow-color" inStates:[CPThemeStateDisabled, CPThemeStateSelected]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inStates:[CPThemeStateDisabled, CPThemeStateSelected]] forThemeAttribute:@"text-shadow-offset" inStates:[CPThemeStateDisabled, CPThemeStateSelected]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inState:CPThemeStateHighlighted] forThemeAttribute:@"font" inState:CPThemeStateHighlighted];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inState:CPThemeStateHighlighted] forThemeAttribute:@"text-color" inState:CPThemeStateHighlighted];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState:CPThemeStateHighlighted] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateHighlighted];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState:CPThemeStateHighlighted] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateHighlighted];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inStates:[CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"font" inStates:[CPThemeStateHighlighted, CPThemeStateSelected]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inStates:[CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"text-color" inStates:[CPThemeStateHighlighted, CPThemeStateSelected]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inStates:[CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"text-shadow-color" inStates:[CPThemeStateHighlighted, CPThemeStateSelected]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inStates:[CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"text-shadow-offset" inStates:[CPThemeStateHighlighted, CPThemeStateSelected]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"font" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"text-color" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"text-shadow-color" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"text-shadow-offset" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted]] forThemeAttribute:@"font" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted]] forThemeAttribute:@"text-color" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted]] forThemeAttribute:@"text-shadow-color" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted]];
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted]] forThemeAttribute:@"text-shadow-offset" inStates:[CPThemeStateDisabled, CPThemeStateHighlighted]];
}
[self addSubview:_textField];
[self setNeedsLayout];
}
return self;
}
#pragma mark -
#pragma mark Theme methods
/*! Set a theme
*/
- (BOOL)setThemeState:(ThemeState)aState
{
[_textField setThemeState:aState];
[super setThemeState:aState];
}
/*! Unset a theme
*/
- (BOOL)unsetThemeState:(ThemeState)aState
{
[_textField unsetThemeState:aState];
[super unsetThemeState:aState];
}
#pragma mark -
#pragma mark Getter methods
/*! Select the tile
*/
- (void)setSelected:(BOOL)shouldBeSelected
{
if (_isSelected === shouldBeSelected)
return;
_isSelected = shouldBeSelected;
if (_isSelected)
[self setThemeState:CPThemeStateSelected];
else
[self unsetThemeState:CPThemeStateSelected];
}
/*! Disabled the tile (used for previous and next month tile)
*/
- (void)setDisabled:(BOOL)shouldBeDisabled
{
if (_isDisabled === shouldBeDisabled)
return;
_isDisabled = shouldBeDisabled;
if (_isDisabled)
[self setThemeState:CPThemeStateDisabled];
else
[self unsetThemeState:CPThemeStateDisabled];
}
- (BOOL)isDisabled
{
return _isDisabled;
}
/*! Highlight the tile (used for current day)
*/
- (void)setHighlighted:(BOOL)shouldBeHighlighted
{
if (_isHighlighted === shouldBeHighlighted)
return;
_isHighlighted = shouldBeHighlighted;
if (_isHighlighted)
[self setThemeState:CPThemeStateHighlighted];
else
[self unsetThemeState:CPThemeStateHighlighted];
}
/*! Set the stringValue of the tile
@param aStringValue
*/
- (void)setStringValue:(CPString)aStringValue
{
[_textField setStringValue:aStringValue];
}
#pragma mark -
#pragma mark Layout methods
/*! Layout the subviews
*/
- (void)layoutSubviews
{
if ([_datePicker isCSSBased])
{
var attributeName = @"bezel-color-calendar";
if (_isSelected)
{
if (_firstSelected && !_lastSelected)
attributeName = @"bezel-color-calendar-left";
else if (_lastSelected && !_firstSelected)
attributeName = @"bezel-color-calendar-right";
else if (!_firstSelected && !_lastSelected)
{
if (_dayInWeek == 0)
attributeName = @"bezel-color-calendar-left";
else if (_dayInWeek == 6)
attributeName = @"bezel-color-calendar-right";
else
attributeName = @"bezel-color-calendar-middle";
}
}
[self setBackgroundColor:[_datePicker valueForThemeAttribute:attributeName inState:[self themeState]]];
return;
}
var bounds = [self bounds];
[_textField sizeToFit];
[_textField setFrameOrigin:CGPointMake(bounds.size.width / 2 - [_textField frameSize].width / 2 + [_datePicker valueForThemeAttribute:@"border-width"], bounds.size.height / 2 - [_textField frameSize].height / 2)];
}
- (void)setFrame:(CGRect)aFrame
{
[super setFrame:aFrame];
[_textField setFrame:CGRectMake(0, 0, aFrame.size.width, aFrame.size.height)];
}
/*! Drawrect
*/
- (void)drawRect:(CGRect)aRect
{
[super drawRect:aRect];
if ([_datePicker isCSSBased])
return;
var themeState = [self themeState],
context = [[CPGraphicsContext currentContext] graphicsPort];
if (themeState.hasThemeState(CPThemeStateSelected))
{
[self setBackgroundColor:[_datePicker valueForThemeAttribute:@"bezel-color-calendar" inState:themeState]];
CGContextSetLineWidth(context, [_datePicker valueForThemeAttribute:@"border-width"]);
CGContextSetStrokeColor(context, [_datePicker valueForThemeAttribute:@"border-color" inState:themeState]);
CGContextAddRect(context, [self bounds]);
CGContextStrokeRect(context, [self bounds]);
}
else
{
// Clear color, because the original color of a tile is handle by his superview
[self setBackgroundColor:[CPColor clearColor]];
}
}
@end
@@ -0,0 +1,48 @@
/* _CPDatePickerDayViewTextField.j
* AppKit
*
* Created by Alexandre Wilhelm
* Copyright 2012 <alexandre.wilhelmfr@gmail.com>
*
* 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 "CPTextField.j"
@implementation _CPDatePickerDayViewTextField : CPTextField
+ (CPString)defaultThemeClass
{
return @"datePickerDayViewTextField";
}
+ (CPDictionary)themeAttributes
{
return @{
@"min-size": CGSizeMakeZero(),
@"content-inset": CGInsetMakeZero(),
@"text-color": [CPColor blackColor],
@"text-shadow-color": [CPColor clearColor],
@"text-shadow-offset": CGSizeMakeZero(),
@"font": [CPNull null],
@"vertical-alignment": CPCenterVerticalTextAlignment,
@"alignment": CPCenterTextAlignment,
};
}
@end
@@ -0,0 +1,577 @@
/* _CPDatePickerElementTextField.j
* AppKit
*
* Created by Alexandre Wilhelm
* Copyright 2012 <alexandre.wilhelmfr@gmail.com>
*
* 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 "CPTextField.j"
@class CPDatePicker
@class _CPDatePickerElementView
CPDatePickerElementTextFieldBecomeFirstResponder = @"CPDatePickerElementTextFieldBecomeFirstResponder";
CPDatePickerElementTextFieldAMPMChangedNotification = @"CPDatePickerElementTextFieldAMPMChangedNotification";
var CPZeroKeyCode = 48,
CPNineKeyCode = 57,
CPMajAKeyCode = 65,
CPMajPKeyCode = 80,
CPAKeyCode = 97,
CPPKeyCode = 112;
CPMonthDateType = 0;
CPDayDateType = 1;
CPYearDateType = 2;
CPHourDateType = 3;
CPSecondDateType = 4;
CPMinuteDateType = 5;
CPAMPMDateType = 6;
/*! An element textField
*/
@implementation _CPDatePickerElementTextField : CPTextField
{
_CPDatePickerElementTextField _nextTextField @accessors(property=nextTextField);
_CPDatePickerElementTextField _previousTextField @accessors(property=previousTextField);
_CPDatePickerElementView _datePickerElementView @accessors(property=datePickerElementView);
CPDatePicker _datePicker @accessors(setter=setDatePicker:);
int _dateType @accessors(getter=dateType);
int _maxNumber @accessors(getter=maxNumber);
int _minNumber @accessors(getter=minNumber);
BOOL _firstEvent;
CPTimer _timerEdition;
}
+ (CPString)defaultThemeClass
{
return @"datePickerElementTextField";
}
+ (CPDictionary)themeAttributes
{
return @{
@"content-inset": CGInsetMake(1.0, 0.0, 0.0, 0.0),
@"bezel-color": [CPNull null],
@"min-size": CGSizeMakeZero()
};
}
- (id)init
{
if (self = [super init])
{
_firstEvent = YES;
}
return self;
}
/*! @ignore */
- (BOOL)acceptsFirstResponder
{
return [_datePicker isEnabled];
}
/*! Set the dateType of the textField
*/
- (void)setDateType:(int)aDateType
{
_dateType = aDateType;
switch (aDateType)
{
case CPMonthDateType:
_minNumber = 1;
_maxNumber = 12;
break;
case CPDayDateType:
_minNumber = 1;
_maxNumber = 31;
break;
case CPYearDateType:
_minNumber = 0;
_maxNumber = 9999;
break;
case CPHourDateType:
_minNumber = 0;
_maxNumber = 23;
break;
case CPSecondDateType:
_minNumber = 0;
_maxNumber = 59;
break;
case CPMinuteDateType:
_minNumber = 0;
_maxNumber = 59;
break;
}
}
/*! Return the maxNumber of the textField
*/
- (int)maxNumber
{
if (_dateType == CPDayDateType)
return [[_datePicker dateValue] _daysInMonth];
return _maxNumber;
}
/*! Return the maxNumber of the textField depending of the maxDate
*/
- (int)_maxNumberWithMaxDate
{
var maxDate = [_datePicker maxDate],
date = [_datePicker dateValue];
if (maxDate)
{
switch (_dateType)
{
case CPMonthDateType:
if (maxDate.getFullYear() == date.getFullYear())
return maxDate.getMonth();
break;
case CPDayDateType:
if (maxDate.getFullYear() == date.getFullYear() && maxDate.getMonth() == date.getMonth())
return maxDate.getDate();
break;
case CPYearDateType:
return maxDate.getFullYear();
case CPHourDateType:
if (maxDate.getFullYear() == date.getFullYear() && maxDate.getMonth() == date.getMonth() && maxDate.getDate() == date.getDate())
return maxDate.getHours();
break;
case CPSecondDateType:
if (maxDate.getFullYear() == date.getFullYear() && maxDate.getMonth() == date.getMonth() && maxDate.getDate() == date.getDate() && maxDate.getHours() == date.getHours() && maxDate.getMinutes() == date.getMinutes())
return maxDate.getSeconds();
break;
case CPMinuteDateType:
if (maxDate.getFullYear() == date.getFullYear() && maxDate.getMonth() == date.getMonth() && maxDate.getDate() == date.getDate() && maxDate.getHours() == date.getHours())
return maxDate.getMinutes();
break;
}
}
return _maxNumber;
}
/*! Set the stringValue of the textField. This is going to check if there is 2 or 4 letters. If not it adds a space. Check also the maxDate
It's called when the user is editing with the keyboard
@param aStringValue a CPString
*/
- (void)setValueForKeyEvent:(CPEvent)anEvent
{
var keyCode = [anEvent keyCode];
if (keyCode != CPDeleteKeyCode && keyCode != CPDeleteForwardKeyCode && keyCode < CPZeroKeyCode || keyCode > CPNineKeyCode)
return;
var newValue = [self stringValue].replace(/\s/g, ''),
length = [newValue length],
eventKeyValue = parseInt([anEvent characters]).toString();
if (keyCode == CPDeleteKeyCode || keyCode == CPDeleteForwardKeyCode)
{
[_timerEdition invalidate];
_timerEdition = nil;
newValue = [newValue substringToIndex:(length - 1)];
}
else
{
if (!_timerEdition)
{
_timerEdition = [CPTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(_timerKeyEvent:) userInfo:nil repeats:NO];
if (_firstEvent || !length)
newValue = eventKeyValue;
else
newValue = parseInt(newValue).toString() + eventKeyValue;
}
else
{
var newFireDate = [CPDate date];
newFireDate.setSeconds(newFireDate.getSeconds() + 2);
[_timerEdition setFireDate:newFireDate];
newValue = parseInt(newValue).toString() + eventKeyValue;
}
}
if (parseInt(newValue) > [self _maxNumberWithMaxDate] || ([_datePicker _isAmericanFormat] && _dateType == CPHourDateType && parseInt(newValue) > 12))
return;
_firstEvent = NO;
[super setObjectValue:newValue];
}
/*!
End of the timer
*/
- (void)_timerKeyEvent:(id)sender
{
var stringValue = [self stringValue];
_timerEdition = nil;
if ([stringValue length])
{
if ([_datePicker _isAmericanFormat] && [self dateType] == CPHourDateType)
{
var isAMHour = [[self superview] _isAMHour];
if (!isAMHour && stringValue != 12)
stringValue = parseInt(stringValue) + 12;
if (stringValue == 12 && !isAMHour)
stringValue = 12;
else if (stringValue == 12)
stringValue = 0;
}
[self setObjectValue:stringValue];
}
}
/*!
We force to end the timer
*/
- (void)_invalidTimer
{
if (_timerEdition)
{
[_timerEdition invalidate];
_timerEdition = nil;
}
}
/*!
We force to end the timer and to update the objectValue of the datePicker
*/
- (void)_endEditing
{
if (_timerEdition)
[_timerEdition invalidate];
_timerEdition = nil;
var objectValue = [self stringValue];
if (![objectValue length])
objectValue = [self objectValue];
if ([_datePicker _isAmericanFormat] && [self dateType] == CPHourDateType)
{
var isAMHour = [[self superview] _isAMHour];
if (!isAMHour && objectValue != 12)
objectValue = parseInt(objectValue) + 12;
if (objectValue == 12 && !isAMHour)
objectValue = 12;
else if (objectValue == 12)
objectValue = 0;
}
[self setObjectValue:objectValue];
}
/*! Set the stringValue of the TextField. Add some zeros of there isn't 2/4 letters in the value. It's called at the end of the editing process
@param aStringValue a CPString
*/
- (void)setStringValue:(CPString)aStringValue
{
if (_dateType == CPYearDateType)
{
while ([aStringValue length] < 4)
aStringValue = "0" + aStringValue;
}
else if (_dateType != CPAMPMDateType)
{
if (_dateType == CPHourDateType && [_datePicker _isAmericanFormat])
{
var value = parseInt(aStringValue);
if (value == 0)
value = 12;
else if (value > 12)
value = value - 12;
aStringValue = value.toString();
}
while ([aStringValue length] < 2)
{
if (_dateType == CPSecondDateType || _dateType == CPMinuteDateType)
aStringValue = @"0" + aStringValue;
else
aStringValue = @" " + aStringValue;
}
}
[super setObjectValue:aStringValue];
}
/*! Set the objectValue. This will update the dateValue of the datePicker also. It's called with the binding of the stepper or arrows
This is not going to update the objectValue of the control !!! It updates the dateValue of the datePicker who's going to update the datePickerTextField if necessary
It's a bit tricky
@param aObjectValue
*/
- (void)setObjectValue:(id)anObjectValue
{
var dateValue = [[_datePicker dateValue] copy],
lengthString = [[self stringValue] length],
objectValue = parseInt(anObjectValue);
switch (_dateType)
{
case CPMonthDateType:
if (objectValue == 0 || !lengthString)
{
[self setStringValue:(dateValue.getMonth() + 1).toString()];
return;
}
var dateNextMonth = [dateValue copy];
dateNextMonth.setDate(1);
dateNextMonth.setMonth(parseInt(anObjectValue) - 1);
var numberDayNextMonth = [dateNextMonth _daysInMonth];
if (numberDayNextMonth < [dateValue _daysInMonth] && dateValue.getDate() > numberDayNextMonth)
[_datePickerElementView setDayDateValue:numberDayNextMonth.toString()];
[super setObjectValue:objectValue];
break;
case CPDayDateType:
if (objectValue == 0 || !lengthString)
{
[self setStringValue:dateValue.getDate().toString()];
return;
}
[super setObjectValue:objectValue];
break;
case CPYearDateType:
if (objectValue == 0 || !lengthString)
{
[self setStringValue:dateValue.getFullYear().toString()];
return;
}
[super setObjectValue:objectValue];
break;
case CPHourDateType:
if (!lengthString)
{
[self setStringValue:dateValue.getHours().toString()];
return;
}
[super setObjectValue:objectValue];
break;
case CPSecondDateType:
if (!lengthString)
{
[self setStringValue:dateValue.getSeconds().toString()];
return;
}
[super setObjectValue:objectValue];
break;
case CPMinuteDateType:
if (!lengthString)
{
[self setStringValue:dateValue.getMinutes().toString()];
return;
}
[super setObjectValue:objectValue];
break;
}
var newDateValue = [_datePickerElementView dateValue],
timeZone = [_datePicker timeZone];
if (timeZone)
{
var secondsFromGMT = [timeZone secondsFromGMTForDate:newDateValue],
secondsFromGMTTimeZone = [timeZone secondsFromGMT];
newDateValue.setSeconds(newDateValue.getSeconds() + secondsFromGMT - secondsFromGMTTimeZone);
}
#if PLATFORM(DOM)
_datePicker._invokedByUserEvent = YES;
#endif
[_datePicker _setDateValue:newDateValue timeInterval:[_datePicker timeInterval]];
#if PLATFORM(DOM)
_datePicker._invokedByUserEvent = NO;
#endif
}
#pragma mark -
#pragma mark Mouse event
/*! Mouse down event. Launch a notification to notif the new first responder textField
*/
- (void)mouseDown:(CPEvent)anEvent
{
if (![self isEnabled])
return;
[super mouseDown:anEvent];
[[CPNotificationCenter defaultCenter] postNotificationName:CPDatePickerElementTextFieldBecomeFirstResponder object:[[self superview] superview] userInfo:[CPDictionary dictionaryWithObject:self forKey:@"textField"]];
}
#pragma mark -
#pragma mark Theme functions
/*! Set the theme CPThemeStateSelected
*/
- (void)makeSelectable
{
[self setThemeState:CPThemeStateSelected];
[_datePicker setThemeState:CPThemeStateEditing];
}
/*! Unsert the theme CPThemeStateSelected
*/
- (void)makeDeselectable
{
_firstEvent = YES;
[self unsetThemeState:CPThemeStateSelected];
[_datePicker unsetThemeState:CPThemeStateEditing];
}
#pragma mark -
#pragma mark Override
/*!
We override this method to get all the time the good width
*/
- (CGSize)_minimumFrameSize
{
var frameSize = [self frameSize],
contentInset = [self currentValueForThemeAttribute:@"content-inset"],
minSize = [self currentValueForThemeAttribute:@"min-size"],
maxSize = [self currentValueForThemeAttribute:@"max-size"],
lineBreakMode = [self lineBreakMode],
text = (_dateType == CPYearDateType) ? @"0000" : (_dateType == CPMonthDateType) ? @"10" : @"00",
textSize = CGSizeMakeCopy(frameSize),
font = [self currentValueForThemeAttribute:@"font"];
textSize.width -= contentInset.left + contentInset.right;
textSize.height -= contentInset.top + contentInset.bottom;
if (_dateType == CPAMPMDateType)
text = [self stringValue];
if (frameSize.width !== 0 &&
![self isBezeled] &&
(lineBreakMode === CPLineBreakByWordWrapping || lineBreakMode === CPLineBreakByCharWrapping))
{
textSize = [text sizeWithFont:font inWidth:textSize.width];
}
else
{
textSize = [text sizeWithFont:font];
// Account for possible fractional pixels at right edge
textSize.width += 1;
}
// Account for possible fractional pixels at bottom edge
textSize.height += 1;
frameSize.height = textSize.height + contentInset.top + contentInset.bottom;
if ([self isBezeled])
{
frameSize.height = MAX(frameSize.height, minSize.height);
if (maxSize.width > 0.0)
frameSize.width = MIN(frameSize.width, maxSize.width);
if (maxSize.height > 0.0)
frameSize.height = MIN(frameSize.height, maxSize.height);
}
else
frameSize.width = textSize.width + contentInset.left + contentInset.right;
frameSize.width = MAX(frameSize.width, minSize.width);
return frameSize;
}
- (CGRect)bezelRectForBounds:(CGRect)bounds
{
return CGRectMakeCopy(bounds);
}
@end
#pragma mark -
@implementation _CPDatePickerElementSeparator : CPTextField
+ (CPString)defaultThemeClass
{
return @"datePickerElementSeparator";
}
+ (CPDictionary)themeAttributes
{
return @{
@"content-inset": CGInsetMake(1.0, 0.0, 0.0, 0.0),
@"min-size": CGSizeMakeZero()
};
}
@end
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,306 @@
/* _CPDatePickerHeaderView.j
* AppKit
*
* Created by Alexandre Wilhelm
* Copyright 2012 <alexandre.wilhelmfr@gmail.com>
*
* 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 "CPControl.j"
@import "CPTextField.j"
@import "CPButton.j"
@class CPDatePicker
var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"],
CPShortWeekDayNameArrayUS = [@"Su", @"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa"],
CPShortWeekDayNameArrayFr = [@"L", @"M", @"M", @"J", @"V", @"S", @"D"],
CPShortWeekDayNameArrayDe = [@"M", @"D", @"M", @"D", @"F", @"S", @"S"],
CPShortWeekDayNameArrayEs = [@"L", @"M", @"X", @"J", @"V", @"S", @"D"],
CPShortMonthNameArrayEn = [@"Jan", @"Feb", @"Mar", @"Apr", @"May", @"Jun", @"Jul", @"Aug", @"Sep", @"Oct", @"Nov", @"Dec"],
CPShortMonthNameArrayFr = [@"janv.", String.fromCharCode(102, 233, 118, 46), @"mars", @"apr.", @"mai", @"juin", @"juil.", String.fromCharCode(97, 111, 251, 116), @"sept.", @"oct.", @"nov.", String.fromCharCode(100, 233, 99, 46)],
CPShortMonthNameArrayDe = [@"Jan", @"Feb", String.fromCharCode(77, 228, 114), @"Apr", @"Mai", @"Jun", @"Jul", @"Aug", @"Sep", @"Okt", @"Nov", @"Dez"],
CPShortMonthNameArrayEs = [@"ene", @"feb", @"mar", @"abr", @"may", @"jun", @"jul", @"ago", @"sep", @"oct", @"nov", @"dic"];
@implementation _CPDatePickerHeaderView : CPControl
{
CPArray _dayLabels;
CPArray _monthNames;
CPButton _nextButton;
CPButton _previousButton;
CPButton _currentButton;
CPDatePicker _datePicker;
CPDate _date;
CPTextField _title;
}
#pragma mark Init methods
/*! Init a new instance of _CPDatePickerHeaderView
@param aFrame
@param aDatePicker
@return a new instance of _CPDatePickerHeaderView
*/
- (id)initWithFrame:(CGRect)aFrame datePicker:(CPDatePicker)aDatePicker delegate:(id)aDelegate
{
self = [super initWithFrame:aFrame];
if (self)
{
_datePicker = aDatePicker;
// Title
_title = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[_title setValue:[_datePicker valueForThemeAttribute:@"title-font" inState:CPThemeStateNormal] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_title setValue:[_datePicker valueForThemeAttribute:@"title-text-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_title setValue:[_datePicker valueForThemeAttribute:@"title-text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_title setValue:[_datePicker valueForThemeAttribute:@"title-text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_title setValue:[_datePicker valueForThemeAttribute:@"title-font" inState:CPThemeStateDisabled] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_title setValue:[_datePicker valueForThemeAttribute:@"title-text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_title setValue:[_datePicker valueForThemeAttribute:@"title-text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_title setValue:[_datePicker valueForThemeAttribute:@"title-text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[self addSubview:_title];
_dayLabels = [CPArray array];
// Days
for (var i = 0, count = [[self _dayNames] count]; i < count; i++)
{
var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[label setValue:[_datePicker valueForThemeAttribute:@"tile-text-alignment"] forThemeAttribute:@"alignment"];
var contentInset = [_datePicker valueForThemeAttribute:@"tile-content-inset"];
if (contentInset)
[label setValue:contentInset forThemeAttribute:@"content-inset"];
[label setValue:[_datePicker valueForThemeAttribute:@"weekday-font" inState:CPThemeStateNormal] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[label setValue:[_datePicker valueForThemeAttribute:@"weekday-text-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[label setValue:[_datePicker valueForThemeAttribute:@"weekday-text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[label setValue:[_datePicker valueForThemeAttribute:@"weekday-text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[label setValue:[_datePicker valueForThemeAttribute:@"weekday-font" inState:CPThemeStateDisabled] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[label setValue:[_datePicker valueForThemeAttribute:@"weekday-text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[label setValue:[_datePicker valueForThemeAttribute:@"weekday-text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[label setValue:[_datePicker valueForThemeAttribute:@"weekday-text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_dayLabels addObject:label];
[self addSubview:label];
}
// Arrows
var size = [_datePicker valueForThemeAttribute:@"previous-button-size"];
_previousButton = [[CPButton alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
[_previousButton setButtonType:CPMomentaryChangeButton];
[_previousButton setBordered:NO];
[_previousButton setImage:[_datePicker valueForThemeAttribute:@"arrow-image-left"]];
[_previousButton setAlternateImage:[_datePicker valueForThemeAttribute:@"arrow-image-left-highlighted"]];
[self addSubview:_previousButton];
size = [_datePicker valueForThemeAttribute:@"next-button-size"];
_nextButton = [[CPButton alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
[_nextButton setButtonType:CPMomentaryChangeButton];
[_nextButton setBordered:NO];
[_nextButton setImage:[_datePicker valueForThemeAttribute:@"arrow-image-right"]];
[_nextButton setAlternateImage:[_datePicker valueForThemeAttribute:@"arrow-image-right-highlighted"]];
[self addSubview:_nextButton];
size = [_datePicker valueForThemeAttribute:@"current-button-size"];
_currentButton = [[CPButton alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
[_currentButton setButtonType:CPMomentaryChangeButton];
[_currentButton setBordered:NO];
[_currentButton setImage:[_datePicker valueForThemeAttribute:@"circle-image"]];
[_currentButton setAlternateImage:[_datePicker valueForThemeAttribute:@"circle-image-highlighted"]];
[self addSubview:_currentButton];
[_previousButton setTarget:aDelegate];
[_previousButton setAction:@selector(_clickArrowPrevious:)];
[_previousButton setContinuous:YES];
[_nextButton setTarget:aDelegate];
[_nextButton setAction:@selector(_clickArrowNext:)];
[_nextButton setContinuous:YES];
[_currentButton setTarget:aDelegate];
[_currentButton setAction:@selector(_currentMonth:)];
[self setNeedsLayout];
}
return self;
}
#pragma mark -
#pragma mark Getter Setter methods
/*! Return the day names depending on the CPLocale of the datePicker
@return an array
*/
- (CPArray)_dayNames
{
switch ([[_datePicker locale] objectForKey:CPLocaleLanguageCode])
{
case @"en":
// Check if it's in the american format. If yes the week will begin the sunday
if ([_datePicker _isAmericanFormat])
return CPShortWeekDayNameArrayUS;
else
return CPShortWeekDayNameArrayEn;
break;
case @"es":
return CPShortWeekDayNameArrayEs;
break;
case @"de":
return CPShortWeekDayNameArrayDe;
break;
case @"fr":
return CPShortWeekDayNameArrayFr;
break;
default:
return CPShortWeekDayNameArrayEn;
break;
}
}
/*! Return the month names depending on the CPLocale of the datePicker
@return an array
*/
- (CPArray)_monthNames
{
switch ([[_datePicker locale] objectForKey:CPLocaleLanguageCode])
{
case @"en":
return CPShortMonthNameArrayEn;
break;
case @"es":
return CPShortMonthNameArrayEs;
break;
case @"de":
return CPShortMonthNameArrayDe;
break;
case @"fr":
return CPShortMonthNameArrayFr;
break;
default:
return CPShortMonthNameArrayEn;
break;
}
}
/*! Set the monthDate of the header
@aMonthDate the new monthDate
*/
- (void)setMonthForDate:(CPDate)aMonthDate
{
_date = aMonthDate;
[self setNeedsLayout];
}
/*! Set enabled
@param aBoolean
*/
- (void)setEnabled:(BOOL)aBoolean
{
[_previousButton setEnabled:aBoolean];
[_nextButton setEnabled:aBoolean];
[_currentButton setEnabled:aBoolean];
[_dayLabels makeObjectsPerformSelector:@selector(setEnabled:) withObject:aBoolean];
[_title setEnabled:aBoolean];
}
#pragma mark -
#pragma mark Layout methods
/*! Layout the subviews
*/
- (void)layoutSubviews
{
var bounds = [self bounds],
dayNames = [self _dayNames],
width = CGRectGetWidth(bounds),
buttonInset = [_datePicker valueForThemeAttribute:@"arrow-inset"],
numberOfLabels = [_dayLabels count],
labelWidth = width / numberOfLabels,
sizeButtonLeft = [[_datePicker valueForThemeAttribute:@"arrow-image-left"] size],
sizeButtonRight = [[_datePicker valueForThemeAttribute:@"arrow-image-right"] size],
sizeButtonCircle = [[_datePicker valueForThemeAttribute:@"circle-image"] size],
sizeTileWidth = [_datePicker valueForThemeAttribute:@"size-tile"].width,
titleInset = [_datePicker valueForThemeAttribute:@"title-inset"],
dayLabelInset = [_datePicker valueForThemeAttribute:@"day-label-inset"];
// Arrows
[_nextButton setFrame:CGRectMake(width - [_nextButton frameSize].width - buttonInset.right, buttonInset.top, sizeButtonRight.width, sizeButtonRight.height)];
[_currentButton setFrame:CGRectMake(CGRectGetMinX([_nextButton frame]) - sizeButtonCircle.width - buttonInset.left - buttonInset.right, buttonInset.top, sizeButtonCircle.width, sizeButtonCircle.height)];
[_previousButton setFrame:CGRectMake(CGRectGetMinX([_currentButton frame]) - sizeButtonLeft.width - buttonInset.left - buttonInset.right, buttonInset.top, sizeButtonLeft.width, sizeButtonLeft.height)];
var firstDayTileX;
// Weekday label
for (var i = 0; i < numberOfLabels; i++)
{
var dayLabel = _dayLabels[i];
[dayLabel setStringValue:dayNames[i]];
if (dayLabelInset) // Beginning with Aristo3
{
var thisWidth = ROUND((i+1) * sizeTileWidth) - ROUND(i * sizeTileWidth);
[dayLabel sizeToFit];
[dayLabel setFrame:CGRectMake(dayLabelInset.left + ROUND(i * sizeTileWidth), dayLabelInset.top, thisWidth, [dayLabel frameSize].height)];
}
else
{
[dayLabel sizeToFit];
[dayLabel setFrameOrigin:CGPointMake(sizeTileWidth * (i + 1) - sizeTileWidth / 2 - [dayLabel frameSize].width / 2, 23)];
if (i == 0)
firstDayTileX = sizeTileWidth * (i + 1) - sizeTileWidth / 2 - [dayLabel frameSize].width / 2;
}
}
// Title
[_title setStringValue:[CPString stringWithFormat:@"%s %i", [self _monthNames][_date.getMonth()], _date.getFullYear()]];
[_title sizeToFit];
if (titleInset) // Beginning with Aristo3
[_title setFrameOrigin:CGPointMake(titleInset.left, titleInset.top)];
else
[_title setFrameOrigin:CGPointMake(firstDayTileX, 6)];
}
@end
@@ -0,0 +1,636 @@
/* _CPDatePickerMonthView.j
* AppKit
*
* Created by Alexandre Wilhelm
* Copyright 2012 <alexandre.wilhelmfr@gmail.com>
*
* 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 "CPControl.j"
@import "_CPDatePickerDayView.j"
@class CPDatePicker
@global CPSingleDateMode
@global CPRangeDateMode
@implementation _CPDatePickerMonthView : CPControl
{
BOOL _isMonthJustChanged;
CPArray _dayTiles;
CPDate _clickDate;
CPDate _dragDate;
CPDate _date;
CPDate _previousMonth @accessors(property=previousMonth);
CPDate _nextMonth @accessors(property=nextMonth);
CPDatePicker _datePicker;
CPEvent _eventDragged;
CPTimer _timerMonth;
id _delegate;
int _indexDayTile;
}
#pragma mark Init methods
/*! Init a _CPDatePickerMonthView
@param aFrame
@param aDatePicker
@return a new _CPDatePickerMonthView
*/
- (id)initWithFrame:(CGRect)aFrame datePicker:(CPDatePicker)aDatePicker delegate:(id)aDelegate
{
if (self = [super initWithFrame:aFrame])
{
_delegate = aDelegate;
_isMonthJustChanged = NO;
_indexDayTile = -1;
_datePicker = aDatePicker;
_dayTiles = [CPArray array];
// Create tiles
for (var i = 0; i < 42; i++)
{
var dayView = [[_CPDatePickerDayView alloc] initWithFrame:CGRectMakeZero() withDatePicker:_datePicker];
[self addSubview:dayView];
[_dayTiles addObject:dayView];
}
[self setNeedsLayout];
}
return self;
}
#pragma mark -
#pragma mark Getter Setter methods
/*! Set the monthDate of the component
@param aDate
*/
- (void)setMonthForDate:(CPDate)aDate
{
if (_dragDate)
{
if (_dragDate.getMonth() != _date.getMonth())
_isMonthJustChanged = YES;
_date = [_dragDate copy];
}
else
{
_date = [aDate copy];
}
if (![aDate isEqualToDate:[CPDate distantFuture]])
{
// Reset the date to the first day of the month & midnight
_date.setDate(1);
[_date _resetToMidnight];
// There must be a better way to do this.
var firstDay = [_date copy];
firstDay.setDate(1);
// Set the previous and next month date. This is usefull for the tile of the next/previous month
_previousMonth = new Date(firstDay.getTime() - 86400000);
_previousMonth.setDate(1);
_nextMonth = new Date(firstDay.getTime() + (([_date _daysInMonth] + 1) * 86400000));
_nextMonth.setDate(1);
}
[self reloadData];
if (_isMonthJustChanged)
{
var dayTile = [_dayTiles objectAtIndex:_indexDayTile];
if ([dayTile date].getMonth() == _date.getMonth())
{
[self mouseDragged:_eventDragged];
}
else
{
if ([dayTile date].getMonth() - _date.getMonth() == 1 || [dayTile date].getFullYear() - _date.getFullYear() == 1)
_timerMonth = [CPTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(_timerNextMonthEvent:) userInfo:nil repeats:NO];
else
_timerMonth = [CPTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(_timerPreviousMonthEvent:) userInfo:nil repeats:NO];
}
}
}
- (void)monthDate
{
return _date;
}
/*! Return the size of a tile
*/
- (CGSize)tileSize
{
return [_datePicker valueForThemeAttribute:@"size-tile"];
}
/*! Return the first index day of the month
*/
- (int)startOfWeekForDate:(CPDate)aDate
{
var day = aDate.getDay();
// American people begins the week the sunday
if (![_datePicker _isAmericanFormat])
return (day + 6) % 7;
return day;
}
/*! Set enabled
@param aBoolean
*/
- (void)setEnabled:(BOOL)aBoolean
{
[super setEnabled:aBoolean];
[self reloadData];
}
/*! Return the index of tile depending of the giving event
@param anEvent
@return an index
*/
- (CPInteger)indexOfTileForEvent:(CPEvent)anEvent
{
var locationInView = [self convertPoint:[anEvent locationInWindow] fromView:nil],
tileSize = [self tileSize],
borderWidth = [_datePicker valueForThemeAttribute:@"border-width"],
margin = [_datePicker valueForThemeAttribute:@"tile-margin"] || CGSizeMakeZero(),
tileInset = [_datePicker valueForThemeAttribute:@"tile-inset"] || CGInsetMakeZero();
// Get the week row
var rowIndex = FLOOR((locationInView.y - tileInset.top - margin.height) / (tileSize.height + 2 * margin.height + borderWidth)),
columnIndex = FLOOR((locationInView.x - tileInset.left) / (tileSize.width + 2 * margin.width + borderWidth));
columnIndex = MIN(MAX(columnIndex, 0), 6);
rowIndex = MIN(MAX(rowIndex, 0), 5);
var tileIndex = (rowIndex * 7) + columnIndex;
return tileIndex;
}
#pragma mark -
#pragma mark Reload data
/*! Reload the data
*/
- (void)reloadData
{
if (!_date)
return;
var currentMonth = _date,
startOfMonthDay = [self startOfWeekForDate:currentMonth],
daysInPreviousMonth = [_previousMonth _daysInMonth],
firstDayToShowInPreviousMonth = daysInPreviousMonth - startOfMonthDay,
currentDate = new Date(_previousMonth.getFullYear(), _previousMonth.getMonth(), firstDayToShowInPreviousMonth),
now = [CPDate date],
dateValue = [_datePicker dateValue];
// Update the tiles
for (var i = 0; i < [_dayTiles count]; i++)
{
var dayTile = _dayTiles[i];
// Increment to next day
currentDate.setTime(currentDate.getTime() + 90000000);
[currentDate _resetToMidnight];
var isPresentMonth = (now.getMonth() == currentDate.getMonth()
&& now.getFullYear() == currentDate.getFullYear());
[dayTile setDate:[currentDate copy]];
[dayTile setStringValue:currentDate.getDate()];
[dayTile setDisabled:/*![self isEnabled] ||*/ currentDate.getMonth() !== currentMonth.getMonth() || currentDate < [_datePicker minDate] || currentDate > [_datePicker maxDate]];
[dayTile setHighlighted:isPresentMonth && currentDate.getDate() == now.getDate()];
}
// Select the dates
[self _selectDate:[_datePicker dateValue] timeInterval:[_datePicker timeInterval]];
}
#pragma mark -
#pragma mark Select methods
/*! Select one date or several date depending of the giving interval
@param aStartDate
@param anInterval;
*/
- (void)_selectDate:(CPDate)aStartDate timeInterval:(CPInteger)anInterval
{
var endDate = [[CPDate alloc] initWithTimeInterval:anInterval sinceDate:aStartDate],
tilesCount = [_dayTiles count];
aStartDate = [aStartDate copy];
[aStartDate _resetToMidnight];
[endDate _resetToMidnight];
var firstSelected = NO;
for (var i = 0; i < tilesCount; i++)
{
var tile = _dayTiles[i],
tileDate = [[tile date] copy],
selected = NO;
[tileDate _resetToMidnight];
if (aStartDate)
selected = tileDate >= aStartDate && tileDate <= endDate;
// Select a tile
[tile setSelected:selected];
// If we are disabled, we have to disable selected tiles so they will appear disabled
[tile setDisabled:[tile isDisabled] || (selected && ![self isEnabled])];
if (selected)
{
if (!firstSelected)
{
firstSelected = YES;
[tile setFirstSelected:YES];
}
else
[tile setFirstSelected:NO];
[tile setLastSelected:NO];
}
else
{
if (firstSelected)
{
firstSelected = NO;
// As there was a first selected and we are now on an unselected tile,
// we are sure that i > 0
[_dayTiles[i-1] setLastSelected:YES];
}
}
}
}
#pragma mark -
#pragma mark Layout methods
/*! Tile the view
*/
- (void)tile
{
var tileSize = [self tileSize],
width = tileSize.width,
height = tileSize.height,
tilesCount = [_dayTiles count],
borderWidth = [_datePicker valueForThemeAttribute:@"border-width"],
margin = [_datePicker valueForThemeAttribute:@"tile-margin"],
tileInset = [_datePicker valueForThemeAttribute:@"tile-inset"],
thisWidth,
thisX,
dayInWeek,
weekInMonth,
tileFrame,
tileIndex;
// Set the frame of the tiles
for (tileIndex = 0; tileIndex < tilesCount; tileIndex++)
{
dayInWeek = tileIndex % 7;
weekInMonth = (tileIndex - dayInWeek) / 7;
tileFrame;
if (margin) // Beginning with Aristo3
{
thisX = ROUND(dayInWeek * (width + 2 * margin.width));
thisWidth = ROUND((dayInWeek+1) * (width + 2 * margin.width)) - thisX;
tileFrame = CGRectMake(tileInset.left + thisX, tileInset.top + margin.height + weekInMonth * (height + 2 * margin.height), thisWidth + borderWidth, height + borderWidth);
}
else
tileFrame = CGRectMake(dayInWeek * width, weekInMonth * height, width + borderWidth, height + borderWidth);
[_dayTiles[tileIndex] setFrame:tileFrame];
[_dayTiles[tileIndex] setDayInWeek:dayInWeek];
}
[self reloadData];
}
/*! Layout the subviews
*/
- (void)layoutSubviews
{
[super layoutSubviews];
[self tile];
[_dayTiles makeObjectsPerformSelector:@selector(setNeedsLayout)];
}
/*! Draw the component. This draws the border of the tile.
The selected tile are drawed in the drawRect method of the tile. But the unselected tile here.
It avoids some problems with tiles over other tiles (otherwise the color of the tile border would be different).
Rememeber that the first pixel of a tile are over the last pixel of the last tile (because the border)
*/
- (void)drawRect:(CGRect)aRect
{
[super drawRect:aRect];
if ([_datePicker isCSSBased])
{
// We just have to draw the separator (if any)
// No separator color means no separator
var separatorColor = [_datePicker valueForThemeAttribute:@"separator-color"],
separatorHeight = [_datePicker valueForThemeAttribute:@"separator-height"],
separatorMarginWidth = [_datePicker valueForThemeAttribute:@"separator-margin-width"];
if (separatorColor)
{
var context = [[CPGraphicsContext currentContext] graphicsPort],
bounds = [self bounds];
CGContextBeginPath(context);
CGContextSetStrokeColor(context, separatorColor);
CGContextSetLineWidth(context, separatorHeight);
CGContextMoveToPoint(context, separatorMarginWidth, 0.5);
CGContextAddLineToPoint(context, bounds.size.width - separatorMarginWidth, 0.5);
CGContextStrokePath(context);
CGContextClosePath(context);
}
return;
}
var context = [[CPGraphicsContext currentContext] graphicsPort],
width = [self tileSize].width,
height = [self tileSize].height,
isBorderPair = ([_datePicker valueForThemeAttribute:@"border-width"] % 2) == 0;
CGContextBeginPath(context);
CGContextSetStrokeColor(context, [_datePicker valueForThemeAttribute:@"border-color" inState:[_datePicker themeState]]);
CGContextSetLineWidth(context, [_datePicker valueForThemeAttribute:@"border-width"]);
if ([_datePicker isBordered])
{
for (var i = 0; i < 6; i++)
{
var y = i * height;
// Very usefull to avoid to have a line of two pixels instead one
if (!isBorderPair)
y += 0.5;
CGContextMoveToPoint(context, 0, y);
CGContextAddLineToPoint(context, [self bounds].size.width, y);
}
for (var i = 0; i < 7; i++)
{
var x = i * width;
// Very usefull to avoid to have a line of two pixels instead one
if (!isBorderPair)
x += 0.5;
CGContextMoveToPoint(context, x, 0);
CGContextAddLineToPoint(context, x, [self bounds].size.height);
}
}
else
{
var y = 0;
// Very usefull to avoid to have a line of two pixels instead one
if (!isBorderPair)
y += 0.5;
CGContextMoveToPoint(context, 0, y);
CGContextAddLineToPoint(context, [self bounds].size.width, y);
}
CGContextStrokePath(context);
CGContextClosePath(context);
}
#pragma mark -
#pragma mark Mouse event
/*! Mouse down event
*/
- (void)mouseDown:(CPEvent)anEvent
{
if (![self isEnabled])
return;
var dayTile = [_dayTiles objectAtIndex:[self indexOfTileForEvent:anEvent]],
dateTile = [[dayTile date] copy],
dateValue = [_datePicker dateValue];
_clickDate = [dateTile copy];
_dragDate = nil;
_indexDayTile = -1;
_eventDragged = nil;
#if PLATFORM(DOM)
_datePicker._invokedByUserEvent = YES;
#endif
// Check if we have to change or not the month of the component
if ([dayTile date].getMonth() == _date.getMonth())
{
if ([_datePicker datePickerMode] == CPRangeDateMode && [anEvent modifierFlags] & CPShiftKeyMask)
{
var dateValueAtMidnight = [[_datePicker dateValue] copy];
[dateValueAtMidnight _resetToMidnight];
if (dateTile < dateValueAtMidnight)
{
var interval;
if (dateTile == dateValueAtMidnight)
interval = [_datePicker timeInterval];
else
interval = ([dateValueAtMidnight timeIntervalSinceDate:dateTile] + [_datePicker timeInterval]);
[_datePicker _setDateValue:[self _hoursMinutesSecondsFromDatePickerForDate:dateTile] timeInterval:interval];
}
else if ([[dayTile date] isEqualToDate:dateValueAtMidnight])
{
[_datePicker _setDateValue:[self _hoursMinutesSecondsFromDatePickerForDate:dateTile] timeInterval:0];
}
else
{
[_datePicker _setDateValue:[self _hoursMinutesSecondsFromDatePickerForDate:[dateValueAtMidnight copy]] timeInterval:([dateTile timeIntervalSinceDate:dateValueAtMidnight])];
}
// Be sure to display the good month
[_delegate setDateValue:dateTile];
}
else
{
var minDate = [[_datePicker minDate] copy],
maxDate = [[_datePicker maxDate] copy];
[minDate _resetToMidnight];
[maxDate _resetToLastSeconds];
if (dateTile >= minDate && dateTile <= maxDate)
[_datePicker _setDateValue:[self _hoursMinutesSecondsFromDatePickerForDate:dateTile] timeInterval:0];
}
}
else
{
// Check the year and the month. The year is usefull when changing from Jan to Dec.
if (_date.getMonth() - [dayTile date].getMonth() == 1 || _date.getFullYear() - [dayTile date].getFullYear() == 1)
[_delegate _displayPreviousMonth];
else
[_delegate _displayNextMonth];
}
#if PLATFORM(DOM)
_datePicker._invokedByUserEvent = NO;
#endif
}
/*! Mouse dragged event
*/
- (void)mouseDragged:(CPEvent)anEvent
{
if (![self isEnabled] || !CGRectContainsPoint([self bounds],[self convertPoint:[anEvent locationInWindow] fromView:nil]))
return;
var dayTile = [_dayTiles objectAtIndex:[self indexOfTileForEvent:anEvent]],
dateTile = [[dayTile date] copy],
dateValue = [_datePicker dateValue];
_dragDate = [dateTile copy];
_indexDayTile = [self indexOfTileForEvent:anEvent];
_eventDragged = anEvent;
#if PLATFORM(DOM)
_datePicker._invokedByUserEvent = YES;
#endif
if ([_datePicker datePickerMode] == CPSingleDateMode)
{
// Check if we have to change or not the month of the component
if ([dayTile date].getMonth() == _date.getMonth())
{
[_timerMonth invalidate];
_isMonthJustChanged = NO;
[_datePicker _setDateValue:[self _hoursMinutesSecondsFromDatePickerForDate:dateTile] timeInterval:0];
}
else if (!_isMonthJustChanged)
{
[_timerMonth invalidate];
_isMonthJustChanged = NO;
// Check the year and the month. The year is usefull when changing from Jan to Dec.
if (_date.getMonth() - [dayTile date].getMonth() == 1 || _date.getFullYear() - [dayTile date].getFullYear() == 1)
[_delegate _displayPreviousMonth];
else
[_delegate _displayNextMonth];
}
}
else
{
if (dateTile.getMonth() == _date.getMonth() || !_isMonthJustChanged)
{
[_timerMonth invalidate];
_isMonthJustChanged = NO;
var dateValueAtMidnight = [[_datePicker dateValue] copy];
[dateValueAtMidnight _resetToMidnight];
if (dateTile < _clickDate)
[_datePicker _setDateValue:[self _hoursMinutesSecondsFromDatePickerForDate:dateTile] timeInterval:[_clickDate timeIntervalSinceDate:dateTile]];
else if ([[dayTile date] isEqualToDate:_clickDate])
[_datePicker _setDateValue:[self _hoursMinutesSecondsFromDatePickerForDate:dateTile] timeInterval:0];
else
[_datePicker _setDateValue:[self _hoursMinutesSecondsFromDatePickerForDate:_clickDate] timeInterval:[dateTile timeIntervalSinceDate:dateValueAtMidnight]];
}
}
#if PLATFORM(DOM)
_datePicker._invokedByUserEvent = NO;
#endif
}
- (void)mouseUp:(CPEvent)anEvent
{
[_timerMonth invalidate];
_dragDate = nil;
_clickDate = nil;
_isMonthJustChanged = NO;
_indexDayTile = -1;
_eventDragged = nil;
}
#pragma mark -
#pragma mark Timer
- (void)_timerNextMonthEvent:(CPEvent)anEvent
{
if (_isMonthJustChanged)
{
_dragDate.setMonth(_date.getMonth() + 1);
[_delegate _displayNextMonth];
}
}
- (void)_timerPreviousMonthEvent:(CPEvent)anEvent
{
if (_isMonthJustChanged)
{
_dragDate.setMonth(_date.getMonth() - 1);
[_delegate _displayPreviousMonth];
}
}
#pragma mark -
#pragma mark Date methods
- (CPDate)_hoursMinutesSecondsFromDatePickerForDate:(CPDate)aDate
{
var dateValue = [_datePicker dateValue];
aDate.setHours(dateValue.getHours());
aDate.setMinutes(dateValue.getMinutes());
aDate.setSeconds(dateValue.getSeconds());
return aDate;
}
@end
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -69,7 +69,7 @@
aNewObject._controller = self;
aNewObject._key = aKey;
if (aValue !== nil)
if (aValue != nil)
[aNewObject setValue:aValue];
return aNewObject;
@@ -98,7 +98,7 @@
var iter = [[CPSet setWithArray:allKeys] objectEnumerator],
obj;
while ((obj = [iter nextObject]) !== nil)
while ((obj = [iter nextObject]) != nil)
if (![_excludedKeys containsObject:obj])
[array addObject:[self _newObjectWithKey:obj value:nil]];
+33 -38
View File
@@ -244,11 +244,6 @@ var CPDocumentUntitledCount = 0;
{
}
- (CPWindowController)firstEligibleExistingWindowController
{
return nil;
}
// Creating and managing window controllers
/*!
Creates the window controller for this document.
@@ -261,6 +256,7 @@ var CPDocumentUntitledCount = 0;
- (void)makeViewAndWindowControllers
{
var viewCibName = [self viewCibName],
windowCibName = [self windowCibName],
viewController = nil,
windowController = nil;
@@ -268,31 +264,21 @@ var CPDocumentUntitledCount = 0;
if ([viewCibName length])
viewController = [[CPViewController alloc] initWithCibName:viewCibName bundle:nil owner:self];
// If we have a view controller, check if we have a free window for it.
if (viewController)
windowController = [self firstEligibleExistingWindowController];
// From a cib if we have one.
if ([windowCibName length])
windowController = [[CPWindowController alloc] initWithWindowCibName:windowCibName owner:self];
// If not, create one.
if (!windowController)
// If not you get a standard window capable of displaying multiple documents and view
else if (viewController)
{
var windowCibName = [self windowCibName];
var view = [viewController view],
viewFrame = [view frame];
// From a cib if we have one.
if ([windowCibName length])
windowController = [[CPWindowController alloc] initWithWindowCibName:windowCibName owner:self];
viewFrame.origin = CGPointMake(50, 50);
// If not you get a standard window capable of displaying multiple documents and view
else if (viewController)
{
var view = [viewController view],
viewFrame = [view frame];
var theWindow = [[CPWindow alloc] initWithContentRect:viewFrame styleMask:CPTitledWindowMask | CPClosableWindowMask | CPMiniaturizableWindowMask | CPResizableWindowMask];
viewFrame.origin = CGPointMake(50, 50);
var theWindow = [[CPWindow alloc] initWithContentRect:viewFrame styleMask:CPTitledWindowMask | CPClosableWindowMask | CPMiniaturizableWindowMask | CPResizableWindowMask];
windowController = [[CPWindowController alloc] initWithWindow:theWindow];
}
windowController = [[CPWindowController alloc] initWithWindow:theWindow];
}
if (windowController && viewController)
@@ -529,7 +515,9 @@ var CPDocumentUntitledCount = 0;
alert("There was an error retrieving the document.");
objj_msgSend(session.delegate, session.didReadSelector, self, NO, session.contextInfo);
var theDelegate = session.delegate;
theDelegate.isa.objj_msgSend3(theDelegate, session.didReadSelector, self, NO, session.contextInfo);
}
else
{
@@ -554,7 +542,9 @@ var CPDocumentUntitledCount = 0;
_writeRequest = nil;
objj_msgSend(session.delegate, session.didSaveSelector, self, NO, session.contextInfo);
var theDelegate = session.delegate;
theDelegate.isa.objj_msgSend3(theDelegate, session.didSaveSelector, self, NO, session.contextInfo);
[self _sendDocumentSavedNotification:NO];
}
}
@@ -567,14 +557,15 @@ var CPDocumentUntitledCount = 0;
*/
- (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)aData
{
var session = aConnection.session;
var session = aConnection.session,
theDelegate = session.delegate;
// READ
if (aConnection == _readConnection)
{
[self readFromData:[CPData dataWithRawString:aData] ofType:session.fileType error:nil];
objj_msgSend(session.delegate, session.didReadSelector, self, YES, session.contextInfo);
theDelegate.isa.objj_msgSend3(theDelegate, session.didReadSelector, self, YES, session.contextInfo);
}
else
{
@@ -583,7 +574,7 @@ var CPDocumentUntitledCount = 0;
_writeRequest = nil;
objj_msgSend(session.delegate, session.didSaveSelector, self, YES, session.contextInfo);
theDelegate.isa.objj_msgSend3(theDelegate, session.didSaveSelector, self, YES, session.contextInfo);
[self _sendDocumentSavedNotification:YES];
}
}
@@ -594,10 +585,11 @@ var CPDocumentUntitledCount = 0;
*/
- (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError
{
var session = aConnection.session;
var session = aConnection.session,
theDelegate = session.delegate;
if (_readConnection == aConnection)
objj_msgSend(session.delegate, session.didReadSelector, self, NO, session.contextInfo);
theDelegate.isa.objj_msgSend3(theDelegate, session.didReadSelector, self, NO, session.contextInfo);
else
{
@@ -611,7 +603,7 @@ var CPDocumentUntitledCount = 0;
alert("There was an error saving the document.");
objj_msgSend(session.delegate, session.didSaveSelector, self, NO, session.contextInfo);
theDelegate.isa.objj_msgSend3(theDelegate, session.didSaveSelector, self, NO, session.contextInfo);
[self _sendDocumentSavedNotification:NO];
}
}
@@ -872,21 +864,24 @@ var CPDocumentUntitledCount = 0;
[self canCloseDocumentWithDelegate:self shouldCloseSelector:@selector(_document:shouldClose:context:) contextInfo:{delegate:delegate, selector:selector, context:info}];
else if ([delegate respondsToSelector:selector])
objj_msgSend(delegate, selector, self, YES, info);
delegate.isa.objj_msgSend3(delegate, selector, self, YES, info);
}
- (void)_document:(CPDocument)aDocument shouldClose:(BOOL)shouldClose context:(Object)context
{
var theDelegate = context.delegate;
if (aDocument === self && shouldClose)
[self close];
objj_msgSend(context.delegate, context.selector, aDocument, shouldClose, context.context);
if (theDelegate != null)
theDelegate.isa.objj_msgSend3(theDelegate, context.selector, aDocument, shouldClose, context.context);
}
- (void)canCloseDocumentWithDelegate:(id)aDelegate shouldCloseSelector:(SEL)aSelector contextInfo:(Object)context
{
if (![self isDocumentEdited])
return [aDelegate respondsToSelector:aSelector] && objj_msgSend(aDelegate, aSelector, self, YES, context);
return [aDelegate respondsToSelector:aSelector] && aDelegate.isa.objj_msgSend3(aDelegate, aSelector, self, YES, context);
_canCloseAlert = [[CPAlert alloc] init];
@@ -915,8 +910,8 @@ var CPDocumentUntitledCount = 0;
if (returnCode === 0)
[self saveDocumentWithDelegate:delegate didSaveSelector:selector contextInfo:context];
else
objj_msgSend(delegate, selector, self, returnCode === 2, context);
else if (delegate != null)
delegate.isa.objj_msgSend3(delegate, selector, self, returnCode === 2, context);
_canCloseAlert = nil;
}
+40 -3
View File
@@ -106,7 +106,7 @@ var CPSharedDocumentController = nil;
@param aType the type of the new document
@param shouldDisplay whether to display the document on screen
*/
- (void)openUntitledDocumentOfType:(CPString)aType display:(BOOL)shouldDisplay
- (CPDocument)openUntitledDocumentOfType:(CPString)aType display:(BOOL)shouldDisplay
{
var theDocument = [self makeUntitledDocumentOfType:aType error:nil];
@@ -253,6 +253,14 @@ var CPSharedDocumentController = nil;
return _documents;
}
/*!
Returns the CPDocument object associated with the main window.
*/
- (CPDocument)currentDocument
{
return [[[CPApp mainWindow] windowController] document];
}
/*!
Adds \c aDocument under the control of the receiver.
@param aDocument the document to add
@@ -271,6 +279,33 @@ var CPSharedDocumentController = nil;
[_documents removeObjectIdenticalTo:aDocument];
}
/*!
Returns the document object whose window controller
owns a specified window.
*/
- (CPDocument)documentForWindow:(CPWindow)aWindow
{
return [[aWindow windowController] document];
}
/*!
Returns a Boolean value that indicates whether the receiver
has any documents with unsaved changes.
*/
- (BOOL)hasEditedDocuments
{
var iter = [_documents objectEnumerator],
obj;
while ((obj = [iter nextObject]) != nil)
{
if ([obj isDocumentEdited])
return YES;
}
return NO;
}
- (CPString)defaultType
{
return [_documentTypes[0] objectForKey:@"CPBundleTypeName"];
@@ -367,8 +402,10 @@ var CPSharedDocumentController = nil;
}
}
if ([context.delegate respondsToSelector:context.selector])
objj_msgSend(context.delegate, context.selector, self, [[self documents] count] === 0, context.context);
var theDelegate = context.delegate;
if ([theDelegate respondsToSelector:context.selector])
theDelegate.isa.objj_msgSend3(theDelegate, context.selector, self, [[self documents] count] === 0, context.context);
}
@end
+1
View File
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@typedef CPDragOperation
CPDragOperationNone = 0;
CPDragOperationCopy = 1 << 1;
CPDragOperationLink = 1 << 1;
+127 -3
View File
@@ -28,11 +28,20 @@
@import "CPCompatibility.j"
@import "CGGeometry.j"
@import "CPText.j"
@import "CPTrackingArea.j"
@class CPTextField
@class CPWindow
@class CPGraphicsContext
@global CPApp
@global CPNewlineCharacter
@global CPCarriageReturnCharacter
@global CPEnterCharacter
@typedef DOMEvent
@typedef CPEventType
var _CPEventPeriodicEventPeriod = 0,
_CPEventPeriodicEventTimer = nil,
@@ -57,7 +66,7 @@ var _CPEventPeriodicEventPeriod = 0,
CPWindow _window;
Number _windowNumber;
CPString _characters;
CPString _charactersIgnoringModifiers
CPString _charactersIgnoringModifiers;
BOOL _isARepeat;
unsigned _keyCode;
DOMEvent _DOMEvent;
@@ -68,6 +77,16 @@ var _CPEventPeriodicEventPeriod = 0,
float _deltaX;
float _deltaY;
float _deltaZ;
float _scrollingDeltaX;
float _scrollingDeltaY;
BOOL _hasPreciseScrollingDeltas;
#if PLATFORM(DOM)
BOOL _suppressCappuccinoCut;
BOOL _suppressCappuccinoPaste;
#endif
CPTrackingArea _trackingArea;
}
/*!
@@ -127,6 +146,27 @@ var _CPEventPeriodicEventPeriod = 0,
timestamp:aTimestamp windowNumber:aWindowNumber context:aGraphicsContext eventNumber:anEventNumber clickCount:aClickCount pressure:aPressure];
}
/*!
Creates a new mouse tracking event.
@param anEventType the event type
@param aPoint the location of the cursor in the window specified by \c aWindowNumber
@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 CPWindow where the event occurred
@param aGraphicsContext the graphics context where the event occurred
@param anEventNumber a number for this event
@param aTrackingArea the tracking area that triggered the event
@throws CPInternalInconsistencyException if an invalid event type is provided
@return the new mouse event
*/
+ (id)enterExitEventWithType:(CPEventType)anEventType location:(CGPoint)aPoint modifierFlags:(unsigned)modifierFlags
timestamp:(CPTimeInterval)aTimestamp windowNumber:(int)aWindowNumber context:(CPGraphicsContext)aGraphicsContext
eventNumber:(int)anEventNumber trackingArea:(CPTrackingArea)aTrackingArea
{
return [[self alloc] _initEnterExitEventWithType:anEventType location:aPoint modifierFlags:modifierFlags timestamp:aTimestamp windowNumber:aWindowNumber context:aGraphicsContext eventNumber:anEventNumber trackingArea:aTrackingArea];
}
/*!
Creates a new custom event.
@@ -158,7 +198,9 @@ var _CPEventPeriodicEventPeriod = 0,
// Make sure these are 0 rather than nil.
_deltaX = 0;
_scrollingDeltaX = 0;
_deltaY = 0;
_scrollingDeltaY = 0;
_deltaZ = 0;
}
@@ -185,6 +227,28 @@ var _CPEventPeriodicEventPeriod = 0,
return self;
}
/* @ignore */
- (id)_initEnterExitEventWithType:(CPEventType)anEventType location:(CGPoint)aPoint modifierFlags:(unsigned)modifierFlags
timestamp:(CPTimeInterval)aTimestamp windowNumber:(int)aWindowNumber context:(CPGraphicsContext)aGraphicsContext
eventNumber:(int)anEventNumber trackingArea:(CPTrackingArea)aTrackingArea
{
if ((anEventType != CPMouseEntered) && (anEventType != CPMouseExited) && (anEventType != CPCursorUpdate))
[CPException raise:CPInternalInconsistencyException reason:"Invalid event type"];
if (self = [self _initWithType:anEventType])
{
_location = CGPointCreateCopy(aPoint);
_modifierFlags = modifierFlags;
_timestamp = aTimestamp;
_context = aGraphicsContext;
_eventNumber = anEventNumber;
_trackingArea = aTrackingArea;
_window = [CPApp windowWithWindowNumber:aWindowNumber];
}
return self;
}
/* @ignore */
- (id)_initKeyEventWithType:(CPEventType)anEventType location:(CGPoint)aPoint modifierFlags:(unsigned int)modifierFlags
timestamp:(CPTimeInterval)aTimestamp windowNumber:(int)aWindowNumber context:(CPGraphicsContext)aGraphicsContext
@@ -220,6 +284,7 @@ var _CPEventPeriodicEventPeriod = 0,
_subtype = aSubtype;
_data1 = aData1;
_data2 = aData2;
_windowNumber = aWindowNumber;
}
return self;
@@ -273,6 +338,14 @@ var _CPEventPeriodicEventPeriod = 0,
return _type;
}
/*!
Returns the subtype of the event.
*/
- (CPEventType)subtype
{
return _subtype;
}
/*!
Returns the event's associated window.
*/
@@ -412,6 +485,31 @@ var _CPEventPeriodicEventPeriod = 0,
return _deltaZ;
}
- (BOOL)hasPreciseScrollingDeltas
{
return !!_hasPreciseScrollingDeltas;
}
/*!
Returns the change in points on the x-axis for a mouse movement, unless hasPreciseScrollingDeltas is NO,
in which case the change is measured in number of "lines" or "rows" and needs to be multiplied as appropriate
to get change in pixels.
*/
- (float)scrollingDeltaX
{
return _scrollingDeltaX;
}
/*!
Returns the change in points on the y-axis for a mouse movement, unless hasPreciseScrollingDeltas is NO,
in which case the change is measured in number of "lines" or "columns" and needs to be multiplied as appropriate
to get change in pixels.
*/
- (float)scrollingDeltaY
{
return _scrollingDeltaY;
}
- (BOOL)_triggersKeyEquivalent:(CPString)aKeyEquivalent withModifierMask:aKeyEquivalentModifierMask
{
if (!aKeyEquivalent)
@@ -473,6 +571,24 @@ var _CPEventPeriodicEventPeriod = 0,
return !firstResponderIsText;
}
/*!
Return YES if this event is a part of processing a browser controlled cut or paste event
where the browser will go ahead and do the work of cutting or pasting within the input
element after processing of this event. The implication is that it should not be done by
the CPTextField (or whatever else is controlling the input) since this would result in
nothing being cut (because the field already cut the text out), or a double paste
(because the field pasted as well as the browser).
*/
- (BOOL)_platformIsEffectingCutOrPaste
{
#if PLATFORM(DOM)
return _suppressCappuccinoCut || _suppressCappuccinoPaste;
#else
return NO;
#endif
}
/*!
Generates periodic events every \c aPeriod seconds.
@@ -492,7 +608,7 @@ var _CPEventPeriodicEventPeriod = 0,
*/
+ (void)stopPeriodicEvents
{
if (_CPEventPeriodicEventTimer === nil)
if (_CPEventPeriodicEventTimer == nil)
return;
window.clearTimeout(_CPEventPeriodicEventTimer);
@@ -523,6 +639,14 @@ var _CPEventPeriodicEventPeriod = 0,
}
}
- (CPTrackingArea)trackingArea
{
if ((_type !== CPMouseEntered) && (_type !== CPMouseExited) && (_type !== CPCursorUpdate))
[CPException raise:CPInternalInconsistencyException format:@"You can't call trackingArea for events of type %#x", _type];
return _trackingArea;
}
@end
function _CPEventFirePeriodEvent()
-85
View File
@@ -1,85 +0,0 @@
/*
* CPFlashMovie.j
* AppKit
*
* Created by Francisco Tolmasky.
* 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>
/*!
@ingroup appkit
@class CPFlashMovie
CPFlashMovie is used to represent a Flash movie in the Cappuccino framework.
*/
@implementation CPFlashMovie : CPObject
{
CPString _filename;
}
/*!
Creates a new Flash movie with the swf at \c aFileName.
@param aFilename the swf to load
@return the initialized CPFlashMovie
*/
+ (id)flashMovieWithFile:(CPString)aFilename
{
return [[self alloc] initWithFile:aFilename];
}
/*!
Initializes the Flash movie.
@param aFilename the swf to load
@return the initialized CPFlashMovie
*/
- (id)initWithFile:(CPString)aFilename
{
self = [super init];
if (self)
_filename = aFilename;
return self;
}
- (CPString)filename
{
return _filename;
}
@end
var CPFlashMovieFilenameKey = "CPFlashMovieFilenameKey";
@implementation CPFlashMovie (CPCoding)
- (id)initWithCoder:(CPCoder)aCoder
{
_filename = [aCoder decodeObjectForKey:CPFlashMovieFilenameKey];
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_filename forKey:CPFlashMovieFilenameKey];
}
@end
-212
View File
@@ -1,212 +0,0 @@
/*
* CPFlashView.j
* AppKit
*
* Created by Francisco Tolmasky.
* 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 "CPFlashMovie.j"
@import "CPView.j"
var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
/*!
@ingroup appkit
*/
@implementation CPFlashView : CPView
{
CPFlashMovie _flashMovie;
CPDictionary _params;
CPDictionary _paramElements;
#if PLATFORM(DOM)
DOMElement _DOMParamElement;
DOMElement _DOMObjectElement;
#endif
}
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
if (self)
{
#if PLATFORM(DOM)
if (!CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
{
_DOMObjectElement = document.createElement(@"object");
_DOMObjectElement.id = [self elementID];
_DOMObjectElement.width = @"100%";
_DOMObjectElement.height = @"100%";
_DOMObjectElement.style.top = @"0px";
_DOMObjectElement.style.left = @"0px";
_DOMObjectElement.type = @"application/x-shockwave-flash";
_DOMParamElement = document.createElement(@"param");
_DOMParamElement.name = @"movie";
_DOMObjectElement.appendChild(_DOMParamElement);
_DOMElement.appendChild(_DOMObjectElement);
}
else
[self _rebuildIEObjects];
#endif
}
return self;
}
- (void)setFlashMovie:(CPFlashMovie)aFlashMovie
{
if (_flashMovie == aFlashMovie)
return;
_flashMovie = aFlashMovie;
#if PLATFORM(DOM)
if (!CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
{
_DOMParamElement.value = [aFlashMovie filename];
_DOMObjectElement.data = [aFlashMovie filename];
}
else
[self _rebuildIEObjects];
#endif
}
- (CPFlashMovie)flashMovie
{
return _flashMovie;
}
- (void)setFlashVars:(CPDictionary)aDictionary
{
var varString = @"",
enumerator = [aDictionary keyEnumerator],
key;
if (key = [enumerator nextObject])
varString = [varString stringByAppendingFormat:@"%@=%@", key, [aDictionary objectForKey:key]];
while (key = [enumerator nextObject])
varString = [varString stringByAppendingFormat:@"&%@=%@", key, [aDictionary objectForKey:key]];
if (!_params)
_params = @{};
[_params setObject:varString forKey:@"flashvars"];
[self setParameters:_params];
}
- (CPDictionary)flashVars
{
return [_params objectForKey:@"flashvars"];
}
- (void)setParameters:(CPDictionary)aDictionary
{
#if PLATFORM(DOM)
if (_paramElements && !CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
{
var elements = [_paramElements allValues],
count = [elements count];
for (var i = 0; i < count; i++)
_DOMObjectElement.removeChild([elements objectAtIndex:i]);
}
#endif
if (!_params)
_params = aDictionary;
else
[_params addEntriesFromDictionary:aDictionary];
#if PLATFORM(DOM)
if (!CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
{
_paramElements = @{};
var enumerator = [_params keyEnumerator],
key;
while (_DOMObjectElement && (key = [enumerator nextObject]) !== nil)
{
var param = document.createElement(@"param");
param.name = key;
param.value = [_params objectForKey:key];
_DOMObjectElement.appendChild(param);
[_paramElements setObject:param forKey:key];
}
}
else
[self _rebuildIEObjects];
#endif
}
- (CPDictionary)parameters
{
return _params;
}
#if PLATFORM(DOM)
- (void)_rebuildIEObjects
{
_DOMElement.innerHTML = @"";
if (![_flashMovie filename])
return;
var paramString = [CPString stringWithFormat:@"<param name='movie' value='%@' />", [_flashMovie filename]],
paramEnumerator = [_params keyEnumerator],
key;
while ((key = [paramEnumerator nextObject]) !== nil)
paramString = [paramString stringByAppendingFormat:@"<param name='%@' value='%@' />", key, [_params objectForKey:key]];
_DOMObjectElement = document.createElement(@"object");
_DOMElement.appendChild(_DOMObjectElement);
_DOMObjectElement.outerHTML = [CPString stringWithFormat:@"<object id=%@ classid=%@ width=%@ height=%@>%@</object>", [self elementID], IEFlashCLSID, CGRectGetWidth([self bounds]), CGRectGetHeight([self bounds]), paramString];
}
#endif
- (CPString)elementID
{
return @"CPFV_" + [self UID];
}
- (void)mouseMoved:(id)sommit
{
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
}
- (void)mouseDragged:(CPEvent)anEvent
{
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
}
- (void)mouseDown:(CPEvent)anEvent
{
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
}
- (void)mouseUp:(CPEvent)anEvent
{
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
}
@end
+157 -15
View File
@@ -24,6 +24,9 @@
@import <Foundation/CPBundle.j>
@import "CPView.j"
@import "CPFontDescriptor.j"
@import "_CPObject+Theme.j"
@import "CPControl.j"
CPFontDefaultSystemFontFace = @"Arial, sans-serif";
CPFontDefaultSystemFontSize = 12;
@@ -37,12 +40,15 @@ CPFontCurrentSystemSize = -1;
// For internal use only by this class and subclasses
_CPFontSystemFacePlaceholder = "_CPFontSystemFacePlaceholder";
var _CPFontCache = {},
_CPSystemFontCache = {},
_CPFontSystemFontFace = CPFontDefaultSystemFontFace,
_CPFontSystemFontSize = 12,
_CPFontFallbackFaces = CPFontDefaultSystemFontFace.split(", "),
_CPFontStripRegExp = new RegExp("(^\\s*[\"']?|[\"']?\\s*$)", "g");
var _CPFontCache = {},
_CPSystemFontCache = {},
_CPFontSystemFontFace = CPFontDefaultSystemFontFace,
_CPFontSystemFontSize = CPFontDefaultSystemFontSize,
_CPFontSystemFontSizeSmall = CPFontDefaultSystemFontSize - 1,
_CPFontSystemFontSizeMini = CPFontDefaultSystemFontSize - 2,
_CPFontFallbackFaces = CPFontDefaultSystemFontFace.split(", "),
_CPFontStripRegExp = new RegExp("(^\\s*[\"']?|[\"']?\\s*$)", "g"),
_CPFontSystemFontFaceSpecified = NO;
#define _CPRealFontSize(aSize) (aSize <= 0 ? _CPFontSystemFontSize : aSize)
@@ -108,7 +114,7 @@ following:
<string>Asap</string>
@endcode
*/
@implementation CPFont : CPObject
@implementation CPFont : CPObject <CPTheme>
{
CPString _name;
float _size;
@@ -122,6 +128,22 @@ following:
CPString _cssString;
}
+ (CPString)defaultThemeClass
{
return @"font";
}
+ (CPDictionary)themeAttributes
{
return @{
@"system-font-face": [CPNull null],
@"system-font-style": [CPNull null],
@"system-font-size-regular": [CPNull null],
@"system-font-size-small": [CPNull null],
@"system-font-size-mini": [CPNull null]
};
}
+ (void)initialize
{
if (self !== [CPFont class])
@@ -133,7 +155,10 @@ following:
systemFontFace = [[CPBundle bundleForClass:[CPView class]] objectForInfoDictionaryKey:@"CPSystemFontFace"];
if (systemFontFace)
{
_CPFontSystemFontFace = _CPFontNormalizedNames(systemFontFace);
_CPFontSystemFontFaceSpecified = YES;
}
var systemFontSize = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPSystemFontSize"];
@@ -141,7 +166,62 @@ following:
systemFontSize = [[CPBundle bundleForClass:[CPView class]] objectForInfoDictionaryKey:@"CPSystemFontSize"];
if (systemFontSize)
{
_CPFontSystemFontSize = systemFontSize;
_CPFontSystemFontFaceSpecified = YES;
}
}
+ (void)initializeSystemFontFromTheme:(CPTheme)aTheme
{
// If something was specified via +initialize (from an Info.plist file), don't do anything
if (_CPFontSystemFontFaceSpecified)
return;
// Reset all system font caches
_CPSystemFontCache = {};
// Now, try to get information from the theme
var systemFontFace = [aTheme valueForAttributeWithName:@"system-font-face" forClass:[CPFont class]];
if (systemFontFace)
{
[self _invalidateSystemFontCache];
_CPFontSystemFontFace = _CPFontNormalizedNames(systemFontFace);
}
var systemFontSize = [aTheme valueForAttributeWithName:@"system-font-size-regular" forClass:[CPFont class]];
if (systemFontSize)
{
[self _invalidateSystemFontCache];
_CPFontSystemFontSize = systemFontSize;
}
systemFontSize = [aTheme valueForAttributeWithName:@"system-font-size-small" forClass:[CPFont class]];
if (systemFontSize)
{
[self _invalidateSystemFontCache];
_CPFontSystemFontSizeSmall = systemFontSize;
}
systemFontSize = [aTheme valueForAttributeWithName:@"system-font-size-mini" forClass:[CPFont class]];
if (systemFontSize)
{
[self _invalidateSystemFontCache];
_CPFontSystemFontSizeMini = systemFontSize;
}
// Is there something to add to the global syle definition ?
var systemFontStyle = [aTheme valueForAttributeWithName:@"system-font-style" forClass:[CPFont class]];
if (systemFontStyle)
{
// Yes, so install it in the DOM Style element
document.getElementsByTagName("STYLE")[0].innerHTML += "\n" + [aTheme setCSSResourcesPathInString:systemFontStyle];
}
}
/*!
@@ -162,7 +242,7 @@ following:
if (normalizedFaces === _CPFontSystemFontFace)
return;
[self _invalidateSystemFontCache]
[self _invalidateSystemFontCache];
_CPFontSystemFontFace = aFace;
}
@@ -174,20 +254,19 @@ following:
return _CPFontSystemFontSize;
}
+ (float)systemFontSizeForControlSize:(CPControlSize)aSize
+ (CPFont)systemFontForControlSize:(CPControlSize)aSize
{
// TODO These sizes should be themable or made less arbitrary in some other way.
switch (aSize)
{
case CPSmallControlSize:
return _CPFontSystemFontSize - 1;
return [self systemFontOfSize:_CPFontSystemFontSizeSmall];
case CPMiniControlSize:
return _CPFontSystemFontSize - 2;
return [self systemFontOfSize:_CPFontSystemFontSizeMini];
case CPRegularControlSize:
default:
return _CPFontSystemFontSize;
return [self systemFontOfSize:_CPFontSystemFontSize];
}
}
@@ -208,7 +287,7 @@ following:
var systemSize = String(_CPFontSystemFontSize),
currentSize = String(CPFontCurrentSystemSize);
for (key in _CPSystemFontCache)
for (var key in _CPSystemFontCache)
{
if (_CPSystemFontCache.hasOwnProperty(key) &&
(key.indexOf(systemSize) === 0 || key.indexOf(currentSize) === 0))
@@ -314,6 +393,10 @@ following:
_isItalic = isItalic;
_isSystem = isSystem;
_theme = [CPTheme defaultTheme];
_themeState = CPThemeStateNormal;
[self _loadThemeAttributes];
if (isSystem)
{
_name = aName;
@@ -431,8 +514,61 @@ following:
_lineHeight = [metrics objectForKey:@"lineHeight"];
}
- (CPControlSize)controlSizeCorrespondingToFontSize
{
switch (_size)
{
case _CPFontSystemFontSizeSmall:
return CPSmallControlSize;
case _CPFontSystemFontSizeMini:
return CPMiniControlSize;
default:
// If we can't find a corresponding size, return regular control size
return CPRegularControlSize;
}
}
@end
@implementation CPFont(DescriptorAdditions)
- (id)_initWithFontDescriptor:(CPFontDescriptor)fontDescriptor
{
var aName = [fontDescriptor objectForKey: CPFontNameAttribute] ,
aSize = [fontDescriptor pointSize],
isBold = [fontDescriptor symbolicTraits] & CPFontBoldTrait,
isItalic = [fontDescriptor symbolicTraits] & CPFontItalicTrait;
return [self _initWithName:aName size:aSize bold:isBold italic:isItalic system:NO];
}
+ (CPFont)fontWithDescriptor:(CPFontDescriptor)fontDescriptor size:(float)aSize
{
var aName = [fontDescriptor objectForKey: CPFontNameAttribute],
isBold = [fontDescriptor symbolicTraits] & CPFontBoldTrait,
isItalic = [fontDescriptor symbolicTraits] & CPFontItalicTrait;
return [self _fontWithName:aName size:aSize || [fontDescriptor pointSize] bold:isBold italic:isItalic];
}
- (CPFontDescriptor)fontDescriptor
{
var traits = 0;
if ([self isBold])
traits |= CPFontBoldTrait;
if ([self isItalic])
traits |= CPFontItalicTrait;
return [[CPFontDescriptor fontDescriptorWithName:_name size:_size] fontDescriptorWithSymbolicTraits:traits];
}
@end
var CPFontNameKey = @"CPFontNameKey",
CPFontSizeKey = @"CPFontSizeKey",
CPFontIsBoldKey = @"CPFontIsBoldKey",
@@ -454,7 +590,11 @@ var CPFontNameKey = @"CPFontNameKey",
isItalic = [aCoder decodeBoolForKey:CPFontIsItalicKey],
isSystem = [aCoder decodeBoolForKey:CPFontIsSystemKey];
return [self _initWithName:fontName size:size bold:isBold italic:isItalic system:isSystem];
self = [self _initWithName:fontName size:size bold:isBold italic:isItalic system:isSystem];
[self _decodeThemeObjectsWithCoder:aCoder];
return self;
}
/*!
@@ -468,6 +608,8 @@ var CPFontNameKey = @"CPFontNameKey",
[aCoder encodeBool:_isBold forKey:CPFontIsBoldKey];
[aCoder encodeBool:_isItalic forKey:CPFontIsItalicKey];
[aCoder encodeBool:_isSystem forKey:CPFontIsSystemKey];
[self _encodeThemeObjectsWithCoder:aCoder];
}
@end
+213 -31
View File
@@ -22,9 +22,14 @@
@import <Foundation/CPObject.j>
@import "CPControl.j"
@import "CPFont.j"
@import "CPFontDescriptor.j"
@global CPApp
@class CPFontPanel
@global document
CPItalicFontMask = 1 << 0;
CPBoldFontMask = 1 << 1;
@@ -41,7 +46,20 @@ CPUnitalicFontMask = 1 << 24;
var CPSharedFontManager = nil,
CPFontManagerFactory = Nil;
CPFontManagerFactory = nil,
CPFontPanelFactory = nil;
/*
modifyFont: sender's tag
*/
CPNoFontChangeAction = 0;
CPViaPanelFontAction = 1;
CPAddTraitFontAction = 2;
CPSizeUpFontAction = 3;
CPSizeDownFontAction = 4;
CPHeavierFontAction = 5;
CPLighterFontAction = 6;
CPRemoveTraitFontAction = 7;
/*!
@ingroup appkit
@@ -59,6 +77,8 @@ var CPSharedFontManager = nil,
BOOL _multiple @accessors(getter=isMultiple, setter=setMultiple:);
CPDictionary _activeChange;
unsigned _fontAction;
}
// Getting the Shared Font Manager
@@ -83,6 +103,15 @@ var CPSharedFontManager = nil,
{
CPFontManagerFactory = aClass;
}
/*!
Sets the class that will be used to create the application's
Font panel.
*/
+ (void)setFontPanelFactory:(Class)aClass
{
CPFontPanelFactory = aClass;
}
- (id)init
{
@@ -163,35 +192,6 @@ var CPSharedFontManager = nil,
return ([aFont isBold] ? CPBoldFontMask : 0) | ([aFont isItalic] ? CPItalicFontMask : 0);
}
- (CPFont)convertFont:(CPFont)aFont
{
if (!_activeChange)
return aFont;
var addTraits = [_activeChange valueForKey:@"addTraits"];
if (addTraits)
aFont = [self convertFont:aFont toHaveTrait:addTraits];
return aFont;
}
- (CPFont)convertFont:(CPFont)aFont toHaveTrait:(CPFontTraitMask)addTraits
{
if (!aFont)
return nil;
var shouldBeBold = ([aFont isBold] || (addTraits & CPBoldFontMask)) && !(addTraits & CPUnboldFontMask),
shouldBeItalic = ([aFont isItalic] || (addTraits & CPItalicFontMask)) && !(addTraits & CPUnitalicFontMask),
shouldBeSize = [aFont size];
// XXX On the current platform there will always be a bold/italic version of each font, but still leave
// || aFont in here for future platforms.
aFont = [CPFont _fontWithName:[aFont familyName] size:shouldBeSize bold:shouldBeBold italic:shouldBeItalic] || aFont;
return aFont;
}
- (CPFont)convertFont:(CPFont)aFont toFace:(CPString)aTypeface
{
if (!aFont)
@@ -209,7 +209,8 @@ var CPSharedFontManager = nil,
- (@action)addFontTrait:(id)sender
{
var tag = [sender tag];
_activeChange = tag === nil ? @{} : @{ @"addTraits": tag };
_activeChange = tag == nil ? @{} : @{ @"addTraits": tag };
_fontAction = CPAddTraitFontAction;
[self sendAction];
}
@@ -219,6 +220,187 @@ var CPSharedFontManager = nil,
return [CPApp sendAction:_action to:_target from:self];
}
/*!
This method open the font panel, create it if necessary.
@param sender The object that sent the message.
*/
- (CPFontPanel)fontPanel:(BOOL)createIt
{
var panel = nil,
panelExists = [CPFontPanelFactory sharedFontPanelExists];
if ((panelExists) || (!panelExists && createIt))
panel = [CPFontPanelFactory sharedFontPanel];
return panel;
}
/*!
Convert a font to have the specified Font traits. The font is unchanged expect for the specified Font traits.
Using CPUnboldFontMask or CPUnitalicFontMask will respectively remove Bold and Italic traits.
@param aFont The font to convert.
@param fontTrait The new font traits mask.
@result The converted font or \c aFont if the conversion failed.
*/
- (CPFont)convertFont:(CPFont)aFont toHaveTrait:(CPFontTraitMask)fontTrait
{
var attributes = [[[aFont fontDescriptor] fontAttributes] copy],
symbolicTrait = [[aFont fontDescriptor] symbolicTraits];
if (fontTrait & CPBoldFontMask)
symbolicTrait |= CPFontBoldTrait;
if (fontTrait & CPItalicFontMask)
symbolicTrait |= CPFontItalicTrait;
if (fontTrait & CPUnboldFontMask) /* FIXME: this only change CPFontSymbolicTrait what about CPFontWeightTrait */
symbolicTrait &= ~CPFontBoldTrait;
if (fontTrait & CPUnitalicFontMask)
symbolicTrait &= ~CPFontItalicTrait;
if (fontTrait & CPExpandedFontMask)
symbolicTrait |= CPFontExpandedTrait;
if (fontTrait & CPSmallCapsFontMask)
symbolicTrait |= CPFontSmallCapsTrait;
if (![attributes containsKey:CPFontTraitsAttribute])
[attributes setObject:[CPDictionary dictionaryWithObject:[CPNumber numberWithUnsignedInt:symbolicTrait]
forKey:CPFontSymbolicTrait]
forKey:CPFontTraitsAttribute];
else
[[attributes objectForKey:CPFontTraitsAttribute] setObject:[CPNumber numberWithUnsignedInt:symbolicTrait]
forKey:CPFontSymbolicTrait];
return [[aFont class] fontWithDescriptor:[CPFontDescriptor fontDescriptorWithFontAttributes:attributes] size:0.0];
}
/*!
Convert a font to not have the specified Font traits. The font is unchanged expect for the specified Font traits.
@param aFont The font to convert.
@param fontTrait The font traits mask to remove.
@result The converted font or \c aFont if the conversion failed.
*/
- (CPFont)convertFont:(CPFont)aFont toNotHaveTrait:(CPFontTraitMask)fontTrait
{
var attributes = [[[aFont fontDescriptor] fontAttributes] copy],
symbolicTrait = [[aFont fontDescriptor] symbolicTraits];
if ((fontTrait & CPBoldFontMask) || (fontTrait & CPUnboldFontMask)) /* FIXME: see convertFont:toHaveTrait: about CPFontWeightTrait */
symbolicTrait &= ~CPFontBoldTrait;
if ((fontTrait & CPItalicFontMask) || (fontTrait & CPUnitalicFontMask))
symbolicTrait &= ~CPFontItalicTrait;
if (fontTrait & CPExpandedFontMask)
symbolicTrait &= ~CPFontExpandedTrait;
if (fontTrait & CPSmallCapsFontMask)
symbolicTrait &= ~CPFontSmallCapsTrait;
if (![attributes containsKey:CPFontTraitsAttribute])
[attributes setObject:[CPDictionary dictionaryWithObject:[CPNumber numberWithUnsignedInt:symbolicTrait]
forKey:CPFontSymbolicTrait]
forKey:CPFontTraitsAttribute];
else
[[attributes objectForKey:CPFontTraitsAttribute] setObject:[CPNumber numberWithUnsignedInt:symbolicTrait]
forKey:CPFontSymbolicTrait];
return [[aFont class] fontWithDescriptor:[CPFontDescriptor fontDescriptorWithFontAttributes:attributes] size:0.0];
}
/*!
Convert a font to have specified size. The font is unchanged expect for the specified size.
@param aFont The font to convert.
@param aSize The new font size.
@result The converted font or \c aFont if the conversion failed.
*/
- (CPFont)convertFont:(CPFont)aFont toSize:(float)aSize
{
var descriptor = [aFont fontDescriptor];
return [[aFont class] fontWithDescriptor: descriptor size:aSize]
}
- (void)orderFrontFontPanel:(id)sender
{
[[self fontPanel:YES] orderFront:sender];
}
- (void)modifyFont:(id)sender
{
_fontAction = [sender tag];
[self sendAction];
if (_selectedFont)
[self setSelectedFont:[self convertFont:_selectedFont] isMultiple:NO];
}
/*!
This method causes the receiver to send its action message.
@param sender The object that sent the message. (a Font panel)
*/
- (void)modifyFontViaPanel:(id)sender
{
_fontAction = CPViaPanelFontAction;
if (_selectedFont)
[self setSelectedFont:[self convertFont:_selectedFont] isMultiple:NO];
[self sendAction];
}
/*!
Convert a font according to current font changes, provided by the object that initiated the font change.
@param aFont The font to convert.
@result The converted font or \c aFont if the conversion failed.
*/
- (CPFont)convertFont:(CPFont)aFont
{
var newFont = nil;
switch (_fontAction)
{
case CPNoFontChangeAction:
newFont = aFont;
break;
case CPViaPanelFontAction:
newFont = [[self fontPanel:NO] panelConvertFont:aFont];
break;
case CPAddTraitFontAction:
newFont = aFont;
if (!_activeChange)
break;
var addTraits = [_activeChange valueForKey:@"addTraits"];
if (addTraits)
newFont = [self convertFont:aFont toHaveTrait:addTraits];
break;
case CPSizeUpFontAction:
newFont = [self convertFont:aFont toSize:[aFont size] + 1.0]; /* any limit ? */
break;
case CPSizeDownFontAction:
if ([aFont size] > 1)
newFont = [self convertFont:aFont toSize:[aFont size] - 1.0];
/* else CPBeep() :-p */
break;
default:
CPLog.trace(@"-[" + [self className] + " " + _cmd + "] unsupported font action: " + _fontAction + " aFont unchanged");
newFont = aFont;
break;
}
return newFont;
}
@end
var _CPFontDetectSpan,
+6 -5
View File
@@ -70,11 +70,12 @@ CPGradientDrawsAfterEndingLocation = kCGGradientDrawsAfterEndLocation;
{
if (self = [super init])
{
var cgColors = [],
count = [someColors count],
colorSpace = [aColorSpace CGColorSpace] || CGColorSpaceCreateDeviceRGB;
for (var i = 0; i < count; i++)
cgColors.push(CGColorCreate(colorSpace, [someColors[i] components]));
var colorSpace = [aColorSpace CGColorSpace] || CGColorSpaceCreateDeviceRGB,
cgColors = [someColors arrayByApplyingBlock:function(color)
{
return CGColorCreate(colorSpace, [color components])
}];
_gradient = CGGradientCreateWithColors(colorSpace, cgColors, someLocations);
}
+4 -4
View File
@@ -43,10 +43,10 @@ function CPDrawTiledRects(
if (sides.length != grays.length)
[CPException raise:CPInvalidArgumentException reason:@"sides (length: " + sides.length + ") and grays (length: " + grays.length + ") must have the same length."];
var colors = [];
for (var i = 0; i < grays.length; ++i)
colors.push([CPColor colorWithCalibratedWhite:grays[i] alpha:1.0]);
var colors = [grays arrayByApplyingBlock:function(gray)
{
return [CPColor colorWithCalibratedWhite:gray alpha:1.0];
}];
return CPDrawColorTiledRects(boundsRect, clipRect, sides, colors);
}
+1 -1
View File
@@ -92,7 +92,7 @@ var CPGraphicsContextCurrent = nil,
@param aGraphicsPort the graphics port to initialize with
@return the initialized context
*/
- (id)initWithGraphicsPort:(CPContext)aGraphicsPort
- (id)initWithGraphicsPort:(CGContext)aGraphicsPort
{
self = [super init];
+465 -18
View File
@@ -26,10 +26,28 @@
@import <Foundation/CPRunLoop.j>
@import <Foundation/CPString.j>
@import <Foundation/CPData.j>
@import <Foundation/CPKeyedArchiver.j>
@import <Foundation/CPKeyedUnarchiver.j>
@import "CGGeometry.j"
@import "CPCompatibility.j"
@class CPColor
@global document
@protocol CPImageDelegate <CPObject>
@optional
- (void)imageDidLoad:(CPImage)anImage;
- (void)imageDidError:(CPImage)anImage;
- (void)imageDidAbort:(CPImage)anImage;
@end
var CPImageDelegate_imageDidLoad_ = 1 << 1,
CPImageDelegate_imageDidError_ = 1 << 2,
CPImageDelegate_imageDidAbort_ = 1 << 3;
CPImageLoadStatusInitialized = 0;
CPImageLoadStatusLoading = 1;
CPImageLoadStatusCompleted = 2;
@@ -71,9 +89,7 @@ function CPImageInBundle()
if (typeof(arguments[1]) === "number")
{
if (arguments[1] !== nil && arguments[1] !== undefined)
size = CGSizeMake(arguments[1], arguments[2]);
size = CGSizeMake(arguments[1], arguments[2]);
bundle = arguments[3];
}
else if (typeof(arguments[1]) === "object")
@@ -119,14 +135,15 @@ function CPAppKitImage(aFilename, aSize)
*/
@implementation CPImage : CPObject
{
CGSize _size;
CPString _filename;
CPString _name;
CGSize _size;
CPString _filename;
CPString _name;
id _delegate;
unsigned _loadStatus;
id <CPImageDelegate> _delegate;
unsigned _loadStatus;
unsigned _implementedDelegateMethods;
Image _image;
Image _image;
}
- (id)init
@@ -136,14 +153,19 @@ function CPAppKitImage(aFilename, aSize)
/*!
Initializes the image, by associating it with a filename. The image
denoted in \c aFilename is not actually loaded. It will
be loaded once needed.
denoted in \c aFilename is not actually loaded. It will be loaded
once needed.
@param aFilename the file containing the image
@param aSize the image's size
@return the initialized image
*/
- (id)initByReferencingFile:(CPString)aFilename size:(CGSize)aSize
{
// Quietly return nil like in Cocoa, rather than crashing later.
if (aFilename == nil)
return nil;
self = [super init];
if (self)
@@ -226,7 +248,7 @@ function CPAppKitImage(aFilename, aSize)
var canvas = document.createElement("canvas"),
ctx = canvas.getContext("2d");
canvas.width = _image.width,
canvas.width = _image.width;
canvas.height = _image.height;
ctx.drawImage(_image, 0, 0);
@@ -255,7 +277,7 @@ function CPAppKitImage(aFilename, aSize)
*/
- (CGSize)size
{
return _size;
return CGSizeMakeCopy(_size);
}
+ (id)imageNamed:(CPString)aName
@@ -314,9 +336,22 @@ function CPAppKitImage(aFilename, aSize)
Sets the receiver's delegate.
@param the delegate
*/
- (void)setDelegate:(id)aDelegate
- (void)setDelegate:(id <CPImageDelegate>)aDelegate
{
if (_delegate === aDelegate)
return;
_delegate = aDelegate;
_implementedDelegateMethods = 0;
if ([_delegate respondsToSelector:@selector(imageDidLoad:)])
_implementedDelegateMethods |= CPImageDelegate_imageDidLoad_;
if ([_delegate respondsToSelector:@selector(imageDidError:)])
_implementedDelegateMethods |= CPImageDelegate_imageDidError_;
if ([_delegate respondsToSelector:@selector(imageDidAbort:)])
_implementedDelegateMethods |= CPImageDelegate_imageDidAbort_;
}
/*!
@@ -413,6 +448,11 @@ function CPAppKitImage(aFilename, aSize)
return NO;
}
- (BOOL)isMaterialIconImage
{
return NO;
}
- (CPString)description
{
var filename = [self filename],
@@ -452,7 +492,7 @@ function CPAppKitImage(aFilename, aSize)
postNotificationName:CPImageDidLoadNotification
object:self];
if ([_delegate respondsToSelector:@selector(imageDidLoad:)])
if (_implementedDelegateMethods & CPImageDelegate_imageDidLoad_)
[_delegate imageDidLoad:self];
}
@@ -461,7 +501,7 @@ function CPAppKitImage(aFilename, aSize)
{
_loadStatus = CPImageLoadStatusReadError;
if ([_delegate respondsToSelector:@selector(imageDidError:)])
if (_implementedDelegateMethods & CPImageDelegate_imageDidError_)
[_delegate imageDidError:self];
}
@@ -470,12 +510,235 @@ function CPAppKitImage(aFilename, aSize)
{
_loadStatus = CPImageLoadStatusCancelled;
if ([_delegate respondsToSelector:@selector(imageDidAbort:)])
if (_implementedDelegateMethods & CPImageDelegate_imageDidAbort_)
[_delegate imageDidAbort:self];
}
@end
#pragma mark -
#pragma mark CSS Theming
// The code below adds support for CSS theming with 100% compatibility with current theming system.
// The idea is to extend CPImage (and CPColor) with CSS components and adapt low level UI components to
// support this new kind of CPColor/CPImage. See CPImageView, CPView and _CPImageAndTextView.
//
// To create a CPImage that uses CSS, simply use the new class method :
// + (CPImage)imageWithCSSDictionary:(CPDictionary)aDictionary beforeDictionary:(CPDictionary)beforeDictionary afterDictionary:(CPDictionary)afterDictionary size:(CGSize)aSize
// where beforeDictionary & afterDictionary are related to ::before & ::after pseudo-elements.
// If you don't need them, just use the simplified class method :
// + (CPImage)imageWithCSSDictionary:(CPDictionary)aDictionary size:(CGSize)aSize
//
// Examples :
// regularImageNormal = [CPImage imageWithCSSDictionary:@{
// @"border-color": A3ColorActiveBorder,
// @"border-style": @"solid",
// @"border-width": @"1px",
// @"border-radius": @"50%",
// @"box-sizing": @"border-box",
// @"background-color": A3ColorBackgroundWhite,
// @"transition-duration": @"0.35s",
// @"transition-property": @"all",
// @"transition-timing-function": @"ease"
// }
// size:CGSizeMake(16,16)];
//
// imageSearch = [CPImage imageWithCSSDictionary:@{
// @"background-image": @"url(%%packed.png)",
// @"background-position": @"-16px -32px",
// @"background-repeat": @"no-repeat",
// @"background-size": @"100px 400px"
// }
// size:CGSizeMake(16,16)];
//
// Remark : Please note the special URL of the background image used in this example : url(%%packed.png)
// During theme loading, "%%" will be replaced by the path to the theme blend resources folder.
// Typically, a CSS theme will use some (rare) images all packed together in a single image resource (see packed.png in Aristo3 theme)
//
// Also, please note that if you don't use one of the CSS components, you can either set it to nil (best solution) or to an empty dictionary, like :
// aCssImage = [CPImage imageWithCSSDictionary:@{} beforeDictionary:nil afterDictionary:@{ ... }];
//
// You can use -(BOOL)isCSSBased to determine how to cope with it in your code.
// -(BOOL)hasCSSDictionary, -(BOOL)hasCSSBeforeDictionary and -(BOOL)hasCSSAfterDictionary are convience methods you can use.
//
// Remark : -(DOMElement)applyCSSImageForView is meant to be used by low level UI widgets (like CPImageView and _CPImageAndTextView) to implement CSS theme support.
//
// In some circumstances, you may have to clear a CSS image. You can do this easily by replacing your current image with the special dummy empty CSS image :
// [CPImage dummyCSSImageOfSize:CGSizeMake(someWidth, someHeight)]
@implementation CPImage (CSSTheming)
{
CPDictionary _cssDictionary @accessors(property=cssDictionary);
CPDictionary _cssBeforeDictionary @accessors(property=cssBeforeDictionary);
CPDictionary _cssAfterDictionary @accessors(property=cssAfterDictionary);
CGSize _displaySize;
}
+ (CPImage)imageWithCSSDictionary:(CPDictionary)aDictionary size:(CGSize)aSize
{
return [[CPImage alloc] initWithCSSDictionary:aDictionary beforeDictionary:nil afterDictionary:nil size:aSize];
}
+ (CPImage)imageWithCSSDictionary:(CPDictionary)aDictionary beforeDictionary:(CPDictionary)beforeDictionary afterDictionary:(CPDictionary)afterDictionary size:(CGSize)aSize
{
return [[CPImage alloc] initWithCSSDictionary:aDictionary beforeDictionary:beforeDictionary afterDictionary:afterDictionary size:aSize];
}
+ (CPImage)dummyCSSImageOfSize:(CGSize)aSize
{
// This is used to clear a previous CSS image
return [[CPImage alloc] initWithCSSDictionary:@{} beforeDictionary:nil afterDictionary:nil size:aSize];
}
+ (CPImage)imageWithMaterialIconNamed:(CPString)iconName size:(CGSize)size
{
return [_CPMaterialIconImage imageWithIconNamed:iconName size:size];
}
+ (CPImage)imageWithMaterialIconNamed:(CPString)iconName size:(CGSize)size color:(CPColor)color
{
return [_CPMaterialIconImage imageWithIconNamed:iconName size:size color:color];
}
- (id)initWithCSSDictionary:(CPDictionary)aDictionary beforeDictionary:(CPDictionary)beforeDictionary afterDictionary:(CPDictionary)afterDictionary size:(CGSize)aSize
{
self = [super init];
if (self)
{
_size = CGSizeMakeCopy(aSize);
_filename = @"CSS image";
_loadStatus = CPImageLoadStatusCompleted;
_cssDictionary = aDictionary;
_cssBeforeDictionary = beforeDictionary;
_cssAfterDictionary = afterDictionary;
_displaySize = CGSizeMakeCopy(aSize);
}
return self;
}
- (BOOL)isCSSBased
{
return !!(_cssDictionary || _cssBeforeDictionary || _cssAfterDictionary);
}
- (BOOL)hasCSSDictionary
{
return ([_cssDictionary count] > 0);
}
- (BOOL)hasCSSBeforeDictionary
{
return ([_cssBeforeDictionary count] > 0);
}
- (BOOL)hasCSSAfterDictionary
{
return ([_cssAfterDictionary count] > 0);
}
- (DOMElement)applyCSSImageForView:(CPView)aView onDOMElement:(DOMElement)aDOMElement styleNode:(DOMElement)aStyleNode previousState:(CPArrayRef)aPreviousStateRef
{
#if PLATFORM(DOM)
// First, restore previous CSS styling before applying the new one
var aPreviousState = @deref(aPreviousStateRef);
for (var i = 0, count = aPreviousState.length; i < count; i++)
aDOMElement.style[aPreviousState[i][0]] = aPreviousState[i][1];
aPreviousState = @[];
// Then apply new CSS styling
[_cssDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
{
[aPreviousState addObject:@[aKey, aDOMElement.style[aKey]]];
aDOMElement.style[aKey] = anObject;
}];
if (_cssBeforeDictionary || _cssAfterDictionary)
{
// We need to create a unique class name
var styleClassName = @".CP" + [aView UID],
styleContent = @"";
if (_cssBeforeDictionary)
{
styleContent += styleClassName + @"::before { ";
[_cssBeforeDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
{
styleContent += aKey + ": " + anObject + "; ";
}];
styleContent += "} ";
}
if (_cssAfterDictionary)
{
styleContent += styleClassName + @"::after { ";
[_cssAfterDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
{
styleContent += aKey + ": " + anObject + "; ";
}];
styleContent += "} ";
}
var styleDescription = document.createTextNode(styleContent);
if (!aStyleNode)
{
aStyleNode = document.createElement("style");
aView._DOMElement.insertBefore(aStyleNode, aView._DOMElement.firstChild);
aStyleNode.appendChild(styleDescription);
}
else
{
aStyleNode.replaceChild(styleDescription, aStyleNode.firstChild);
}
aDOMElement.className = @"CP"+[aView UID];
}
else
{
// no before/after so remove aStyleNode if existing
if (aStyleNode)
{
aView._DOMElement.removeChild(aStyleNode);
aStyleNode = nil;
}
}
// Return actualised values
@deref(aPreviousStateRef) = aPreviousState;
return aStyleNode;
#endif
}
- (BOOL)_shouldBeResized
{
return NO;
}
@end
var CPImageCSSDictionaryKey = @"CPImageCSSDictionaryKey",
CPImageCSSBeforeDictionaryKey = @"CPImageCSSBeforeDictionaryKey",
CPImageCSSAfterDictionaryKey = @"CPImageCSSAfterDictionaryKey";
#pragma mark -
@implementation CPImage (CPCoding)
/*!
@@ -485,7 +748,10 @@ function CPAppKitImage(aFilename, aSize)
*/
- (id)initWithCoder:(CPCoder)aCoder
{
return [self initWithContentsOfFile:[aCoder decodeObjectForKey:@"CPFilename"] size:[aCoder decodeSizeForKey:@"CPSize"]];
if ([aCoder containsValueForKey:CPImageCSSDictionaryKey])
return [self initWithCSSDictionary:[aCoder decodeObjectForKey:CPImageCSSDictionaryKey] beforeDictionary:[aCoder decodeObjectForKey:CPImageCSSBeforeDictionaryKey] afterDictionary:[aCoder decodeObjectForKey:CPImageCSSAfterDictionaryKey] size:[aCoder decodeSizeForKey:@"CPSize"]];
else
return [self initWithContentsOfFile:[aCoder decodeObjectForKey:@"CPFilename"] size:[aCoder decodeSizeForKey:@"CPSize"]];
}
/*!
@@ -496,10 +762,180 @@ function CPAppKitImage(aFilename, aSize)
{
[aCoder encodeObject:_filename forKey:@"CPFilename"];
[aCoder encodeSize:_size forKey:@"CPSize"];
// CSS Styling
if ([self isCSSBased])
{
[aCoder encodeObject:_cssDictionary forKey:CPImageCSSDictionaryKey];
[aCoder encodeObject:_cssBeforeDictionary forKey:CPImageCSSBeforeDictionaryKey];
[aCoder encodeObject:_cssAfterDictionary forKey:CPImageCSSAfterDictionaryKey];
}
}
@end
#pragma mark -
@implementation _CPMaterialIconImage : CPImage
{
CPMutableDictionary _cachedColorVersions;
CPColor _cachedInvertedColor;
}
+ (_CPMaterialIconImage)imageWithIconNamed:(CPString)iconName size:(CGSize)size
{
return [[_CPMaterialIconImage alloc] initWithIconName:iconName size:size];
}
+ (_CPMaterialIconImage)imageWithIconNamed:(CPString)iconName size:(CGSize)size color:(CPColor)color
{
return [[_CPMaterialIconImage alloc] initWithIconName:iconName size:size color:color];
}
+ (_CPMaterialIconImage)imageWithIconNamed:(CPString)iconName size:(CGSize)size color:(CPColor)color additionalCSSDictionary:(CPDictionary)additionalCSSDictionary
{
return [[_CPMaterialIconImage alloc] initWithIconName:iconName size:size color:color additionalCSSDictionary:additionalCSSDictionary];
}
- (CPDictionary)_baseMaterialIconCSSDictionaryForIconName:(CPString)iconName size:(CGSize)size
{
return @{
@"width": size.width + @"px",
@"height": size.height + @"px",
@"top": @"0px",
@"left": @"0px",
@"content": @"'" + iconName + @"'",
@"position": @"absolute",
@"z-index": @"300",
@"font-family": @"'Material Icons'",
@"font-weight": @"normal",
@"font-style": @"normal",
@"font-size": MIN(size.width, size.height) + @"px",
@"display": @"inline-block",
@"line-height": @"1",
@"text-transform": @"none",
@"letter-spacing": @"normal",
@"word-wrap": @"normal",
@"white-space": @"nowrap",
@"direction": @"ltr",
@"-webkit-font-smoothing": @"antialiased",
@"text-rendering": @"optimizeLegibility",
@"-moz-osx-font-smoothing": @"grayscale",
@"font-feature-settings": @"'liga'"
};
}
- (_CPMaterialIconImage)initWithIconName:(CPString)iconName size:(CGSize)size
{
return [super initWithCSSDictionary:@{}
beforeDictionary:@{}
afterDictionary:[self _baseMaterialIconCSSDictionaryForIconName:iconName size:size]
size:size];
}
- (_CPMaterialIconImage)initWithIconName:(CPString)iconName size:(CGSize)size color:(CPColor)color
{
var materialIconCSSDictionary = [self _baseMaterialIconCSSDictionaryForIconName:iconName size:size];
[materialIconCSSDictionary setObject:[color cssString] forKey:@"color"];
return [super initWithCSSDictionary:@{}
beforeDictionary:@{}
afterDictionary:materialIconCSSDictionary
size:size];
}
- (void)addRotationEffectWithAngle:(float)angle
{
[self addCSSDictionary:@{
@"transform": @"rotate("+angle+"deg)",
@"transition": @"transform 0.35s ease"
}];
}
- (void)addCSSDictionary:(CPDictionary)additionalCSSDictionary
{
[_cssAfterDictionary addEntriesFromDictionary:additionalCSSDictionary];
}
- (void)setSize:(CGSize)aSize
{
[self _setDisplaySize:aSize];
[super setSize:aSize];
}
- (void)_setDisplaySize:(CGSize)aSize
{
if (CGSizeEqualToSize(_displaySize, aSize))
return;
_displaySize = CGSizeMakeCopy(aSize);
[_cssAfterDictionary setObject:(aSize.width + @"px") forKey:@"width"];
[_cssAfterDictionary setObject:(aSize.height + @"px") forKey:@"height"];
[_cssAfterDictionary setObject:(MIN(aSize.width, aSize.height) + @"px") forKey:@"font-size"];
}
- (BOOL)_shouldBeResized
{
return YES;
}
- (BOOL)isMaterialIconImage
{
return YES;
}
- (_CPMaterialIconImage)invertedImage
{
if (!_cachedInvertedColor)
{
var sourceCSSColor = [_cssAfterDictionary objectForKey:@"color"] || @"rgba(0,0,0,1)",
sourceColor = [CPColor colorWithCSSString:sourceCSSColor];
_cachedInvertedColor = [CPColor colorWithRed:(1-[sourceColor redComponent])
green:(1-[sourceColor greenComponent])
blue:(1-[sourceColor blueComponent])
alpha:[sourceColor alphaComponent]];
}
return [self imageVersionWithColor:_cachedInvertedColor];
}
- (_CPMaterialIconImage)imageVersionWithColor:(CPColor)aColor
{
// We can't just set the color in the cssAfterDictionary as this would not be noticed as a new image,
// so -setImage won't do anything, so no visual refresh won't occur.
// The trick here is to keep in cache a clone of this image for each needed color.
var colorCSSString = [aColor cssString];
if (!_cachedColorVersions)
_cachedColorVersions = @{};
var cachedColorVersion = [_cachedColorVersions objectForKey:colorCSSString];
if (!cachedColorVersion)
{
cachedColorVersion = [self duplicate];
[cachedColorVersion _setCSSColor:colorCSSString];
[_cachedColorVersions setObject:cachedColorVersion forKey:colorCSSString];
}
return cachedColorVersion;
}
- (void)_setCSSColor:(CPString)aCSSColor
{
[_cssAfterDictionary setObject:aCSSColor forKey:@"color"];
}
@end
#pragma mark -
@implementation CPThreePartImage : CPObject
{
CPArray _imageSlices;
@@ -640,3 +1076,14 @@ var CPNinePartImageImageSlicesKey = @"CPNinePartImageImageSlicesKey";
}
@end
#pragma mark -
@implementation CPImage (Duplication)
- (CPImage)duplicate
{
return [CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:self]];
}
@end
+77 -41
View File
@@ -29,6 +29,9 @@
@global CPImagesPboardType
@global appkit_tag_dom_elements
@global document
@typedef CPImageAlignment
CPImageAlignCenter = 0;
CPImageAlignTop = 1;
CPImageAlignTopLeft = 2;
@@ -87,26 +90,59 @@ var CPImageViewEmptyPlaceholderImage = nil;
if (self)
{
#if PLATFORM(DOM)
_DOMImageElement = document.createElement("img");
_DOMImageElement.style.position = "absolute";
_DOMImageElement.style.left = "0px";
_DOMImageElement.style.top = "0px";
if ([CPPlatform supportsDragAndDrop])
{
_DOMImageElement.setAttribute("draggable", "true");
_DOMImageElement.style["-khtml-user-drag"] = "element";
}
CPDOMDisplayServerAppendChild(_DOMElement, _DOMImageElement);
_DOMImageElement.style.visibility = "hidden";
[self _createDOMImageElement];
#endif
}
return self;
}
- (void)_createDOMImageElement
{
#if PLATFORM(DOM)
var image = [self objectValue],
isCSSBasedImage = [image isCSSBased],
isIMGImageElement = _DOMImageElement && (_DOMImageElement.nodeName == "IMG");
// First, check if we need to destroy a current DOM image element. This is the case if :
// - we have one but not the right one (that is a DIV but needing an IMG, and vice versa)
if (_DOMImageElement)
{
if ((isIMGImageElement && isCSSBasedImage) || (!isIMGImageElement && !isCSSBasedImage))
{
// OK, destroy it
_DOMElement.removeChild(_DOMImageElement);
_DOMImageElement = nil;
// CSS styling cleaning
_cssStylePreviousState = @[];
_cssStyleNode = nil;
}
else
return;
}
_DOMImageElement = document.createElement(isCSSBasedImage ? "div" : "img");
_DOMImageElement.style.position = "absolute";
_DOMImageElement.style.left = "0px";
_DOMImageElement.style.top = "0px";
if ([CPPlatform supportsDragAndDrop])
{
_DOMImageElement.setAttribute("draggable", "true");
_DOMImageElement.style["-khtml-user-drag"] = "element";
}
_DOMImageElement.style.visibility = "hidden";
AppKitTagDOMElement(self, _DOMImageElement);
CPDOMDisplayServerAppendChild(_DOMElement, _DOMImageElement);
#endif
}
/*!
Returns the view's image.
*/
@@ -138,7 +174,15 @@ var CPImageViewEmptyPlaceholderImage = nil;
var newImage = [self objectValue];
#if PLATFORM(DOM)
_DOMImageElement.src = newImage ? [newImage filename] : [CPImageViewEmptyPlaceholderImage filename];
[self _createDOMImageElement];
if ([newImage isCSSBased])
_cssStyleNode = [newImage applyCSSImageForView:self
onDOMElement:_DOMImageElement
styleNode:_cssStyleNode
previousState:@ref(_cssStylePreviousState)];
else
_DOMImageElement.src = newImage ? [newImage filename] : [CPImageViewEmptyPlaceholderImage filename];
#endif
var size = [newImage size];
@@ -164,6 +208,7 @@ var CPImageViewEmptyPlaceholderImage = nil;
- (void)imageDidLoad:(CPNotification)aNotification
{
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPImageDidLoadNotification object:[self objectValue]];
[self hideOrDisplayContents];
[self setNeedsLayout];
@@ -253,7 +298,7 @@ var CPImageViewEmptyPlaceholderImage = nil;
[self setNeedsDisplay:YES];
}
- (unsigned)imageScaling
- (CPUInteger)imageScaling
{
return [self currentValueForThemeAttribute:@"image-scaling"];
}
@@ -401,6 +446,18 @@ var CPImageViewEmptyPlaceholderImage = nil;
#endif
}
#if PLATFORM(DOM)
if ([image isCSSBased] && [image _shouldBeResized])
{
[image _setDisplaySize:CGSizeMake(ROUND(width), ROUND(height))];
_cssStyleNode = [image applyCSSImageForView:self
onDOMElement:_DOMImageElement
styleNode:_cssStyleNode
previousState:@ref(_cssStylePreviousState)];
}
#endif
_imageRect = CGRectMake(x, y, width, height);
if (_hasShadow)
@@ -488,7 +545,7 @@ var CPImageViewEmptyPlaceholderImage = nil;
[_source setImage:image];
}
- (void)valueForBinding:(CPString)aBinding
- (id)valueForBinding:(CPString)aBinding
{
var image = [_source image];
@@ -517,28 +574,12 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
*/
- (id)initWithCoder:(CPCoder)aCoder
{
#if PLATFORM(DOM)
_DOMImageElement = document.createElement("img");
_DOMImageElement.style.position = "absolute";
_DOMImageElement.style.left = "0px";
_DOMImageElement.style.top = "0px";
_DOMImageElement.style.visibility = "hidden";
if ([CPPlatform supportsDragAndDrop])
{
_DOMImageElement.setAttribute("draggable", "true");
_DOMImageElement.style["-khtml-user-drag"] = "element";
}
if (typeof(appkit_tag_dom_elements) !== "undefined" && !!appkit_tag_dom_elements)
_DOMImageElement.setAttribute("data-cappuccino-view", [self className]);
#endif
self = [super initWithCoder:aCoder];
if (self)
{
#if PLATFORM(DOM)
_DOMElement.appendChild(_DOMImageElement);
[self _createDOMImageElement];
#endif
[self setHasShadow:[aCoder decodeBoolForKey:CPImageViewHasShadowKey]];
@@ -564,17 +605,12 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
// We do this in order to avoid encoding the _shadowView, which
// should just automatically be created programmatically as needed.
if (_shadowView)
{
var actualSubviews = _subviews;
_subviews = [_subviews copy];
[_subviews removeObjectIdenticalTo:_shadowView];
}
[_shadowView removeFromSuperview];
[super encodeWithCoder:aCoder];
if (_shadowView)
_subviews = actualSubviews;
[self addSubview:_shadowView];
[aCoder encodeBool:_hasShadow forKey:CPImageViewHasShadowKey];
[aCoder encodeInt:_imageAlignment forKey:CPImageViewImageAlignmentKey];
+50 -6
View File
@@ -35,6 +35,7 @@
var exposedBindingsMap = @{},
bindingsMap = @{};
@typedef CPBindingOperationKind
var CPBindingOperationAnd = 0,
CPBindingOperationOr = 1;
@@ -70,6 +71,20 @@ var CPBindingOperationAnd = 0,
return [[bindingsMap objectForKey:[anObject UID]] objectForKey:aBinding];
}
+ (void)_reverseSetValueFromExclusiveBinderForObject:(id)anObject
{
var bindersByBindingName = [bindingsMap objectForKey:[anObject UID]];
[bindersByBindingName enumerateKeysAndObjectsUsingBlock:function(binding, binder, stop)
{
if ([binder isKindOfClass:[self class]])
{
[binder reverseSetValueFor:binding];
stop(YES);
}
}];
}
+ (CPDictionary)infoForBinding:(CPString)aBinding forObject:(id)anObject
{
var theBinding = [self getBinding:aBinding forObject:anObject];
@@ -116,7 +131,7 @@ var CPBindingOperationAnd = 0,
count = allKeys.length;
while (count--)
[anObject unbind:[bindings objectForKey:allKeys[count]]];
[anObject unbind:allKeys[count]];
[bindingsMap removeObjectForKey:[anObject UID]];
}
@@ -142,7 +157,7 @@ var CPBindingOperationAnd = 0,
[self _updatePlaceholdersWithOptions:options forBinding:aName];
[aDestination addObserver:self forKeyPath:aKeyPath options:CPKeyValueObservingOptionNew context:aBinding];
[aDestination addObserver:self forKeyPath:aKeyPath options:0 context:aBinding];
var bindings = [bindingsMap objectForKey:[_source UID]];
@@ -159,6 +174,24 @@ var CPBindingOperationAnd = 0,
return self;
}
+ (BOOL)isBindingAllowed:(CPString)aBinding forObject:(id)anObject
{
if ([[anObject class] isBindingExclusive:aBinding])
{
var bindingsForObject = [bindingsMap objectForKey:[anObject UID]],
allBindings = [bindingsForObject allKeys],
count = [allBindings count];
while (count--)
{
if ([[anObject class] isBindingExclusive:allBindings[count]])
return NO;
}
}
return YES;
}
- (void)raiseIfNotApplicable:(id)aValue forKeyPath:(CPString)keyPath options:(CPDictionary)options
{
if (aValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption])
@@ -260,7 +293,7 @@ var CPBindingOperationAnd = 0,
// If the value is nil AND the source doesn't respond to setPlaceholderString: then
// we set the value to the placeholder. Otherwise, we do not want to short cut the process
// of setting the placeholder that is based on the fact that the value is nil.
if ((aValue === undefined || aValue === nil || aValue === [CPNull null])
if ((aValue == nil || aValue === [CPNull null])
&& ![_source respondsToSelector:@selector(setPlaceholderString:)])
aValue = [options objectForKey:CPNullPlaceholderBindingOption] || nil;
@@ -387,6 +420,11 @@ var CPBindingOperationAnd = 0,
return [CPBinder class];
}
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return NO;
}
- (CPArray)exposedBindings
{
var exposedBindings = [],
@@ -415,6 +453,11 @@ var CPBindingOperationAnd = 0,
if (!anObject || !aKeyPath)
return CPLog.error("Invalid object or path on " + self + " for " + aBinding);
if (![CPBinder isBindingAllowed:aBinding forObject:self])
{
CPLog.warn([self description] + " : cannot bind " + aBinding + " because another binding with the same functionality is already in use.");
return;
}
//if (![[self exposedBindings] containsObject:aBinding])
// CPLog.warn("No binding exposed on " + self + " for " + aBinding);
@@ -610,7 +653,7 @@ var CPBindingOperationAnd = 0,
keyPath = [info objectForKey:CPObservedKeyPathKey],
value = [object valueForKeyPath:keyPath];
if (value === nil || value === undefined)
if (value == nil)
{
[_source setEnabled:NO];
return;
@@ -753,7 +796,7 @@ var CPBindingOperationAnd = 0,
else
value = [theBinding transformValue:value withOptions:options];
if (value === nil || value === undefined)
if (value == nil)
value = @"";
result.value = result.value.replace("%{" + _patternPlaceholder + count + "}@", [value description]);
@@ -814,7 +857,7 @@ var CPBindingOperationAnd = 0,
- (id)initWithName:(CPString)aName
{
if (self = [super init])
_name = aName
_name = aName;
return self;
}
@@ -875,6 +918,7 @@ CPTextColorBinding = @"textColor";
CPTitleBinding = @"title";
CPToolTipBinding = @"toolTip";
CPValueBinding = @"value";
CPAttributedStringBinding = @"attributedString";
CPValueURLBinding = @"valueURL";
CPValuePathBinding = @"valuePath";
CPDataBinding = @"data";
+20 -12
View File
@@ -22,14 +22,11 @@
@import "CPControl.j"
@import "CPWindow_Constants.j"
@import "CPSlider.j"
@global CPApp
CPTickMarkBelow = 0;
CPTickMarkAbove = 1;
CPTickMarkLeft = CPTickMarkAbove;
CPTickMarkRight = CPTickMarkBelow;
@typedef CPLevelIndicatorStyle
CPRelevancyLevelIndicatorStyle = 0;
CPContinuousCapacityLevelIndicatorStyle = 1;
CPDiscreteCapacityLevelIndicatorStyle = 2;
@@ -62,7 +59,7 @@ CPRatingLevelIndicatorStyle = 3;
return "level-indicator";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"bezel-color": [CPNull null],
@@ -105,10 +102,21 @@ CPRatingLevelIndicatorStyle = 3;
var filledColor = [self valueForThemeAttribute:@"color-normal"],
value = [self doubleValue];
if (value <= _criticalValue)
filledColor = [self valueForThemeAttribute:@"color-critical"];
else if (value <= _warningValue)
filledColor = [self valueForThemeAttribute:@"color-warning"];
if (_warningValue < _criticalValue)
{
if (value >= _criticalValue)
filledColor = [self valueForThemeAttribute:@"color-critical"];
else if (value >= _warningValue)
filledColor = [self valueForThemeAttribute:@"color-warning"];
}
else
{
if (value <= _criticalValue)
filledColor = [self valueForThemeAttribute:@"color-critical"];
else if (value <= _warningValue)
filledColor = [self valueForThemeAttribute:@"color-warning"];
}
for (var i = 0; i < segmentCount; i++)
{
@@ -279,7 +287,7 @@ CPRatingLevelIndicatorStyle = 3;
[self setNeedsLayout];
}
- (void)setWarningValue:(double)warningValue;
- (void)setWarningValue:(double)warningValue
{
if (_warningValue === warningValue)
return;
@@ -288,7 +296,7 @@ CPRatingLevelIndicatorStyle = 3;
[self setNeedsLayout];
}
- (void)setCriticalValue:(double)criticalValue;
- (void)setCriticalValue:(double)criticalValue
{
if (_criticalValue === criticalValue)
return;
+133 -38
View File
@@ -30,6 +30,17 @@
@global CPApp
@protocol CPMenuDelegate <CPObject>
@optional
- (void)menuWillOpen:(CPMenu)aMenu;
- (void)menuDidClose:(CPMenu)aMenu;
@end
var CPMenuDelegate_menuWillOpen_ = 1 << 1,
CPMenuDelegate_menuDidClose_ = 1 << 2;
CPMenuDidAddItemNotification = @"CPMenuDidAddItemNotification";
CPMenuDidChangeItemNotification = @"CPMenuDidChangeItemNotification";
CPMenuDidRemoveItemNotification = @"CPMenuDidRemoveItemNotification";
@@ -50,26 +61,27 @@ var _CPMenuBarVisible = NO,
*/
@implementation CPMenu : CPObject
{
CPMenu _supermenu;
CPMenu _supermenu;
CPString _title;
CPString _name;
CPString _title;
CPString _name;
CPFont _font;
CPFont _font;
float _minimumWidth;
float _minimumWidth;
CPMutableArray _items;
CPMutableArray _items;
BOOL _autoenablesItems;
BOOL _showsStateColumn;
BOOL _autoenablesItems;
BOOL _showsStateColumn;
id _delegate;
id <CPMenuDelegate> _delegate;
unsigned _implementedDelegateMethods;
int _highlightedIndex;
_CPMenuWindow _menuWindow;
int _highlightedIndex;
_CPMenuWindow _menuWindow;
CPEvent _lastCloseEvent;
CPEvent _lastCloseEvent;
}
// Managing the Menu Bar
@@ -152,7 +164,7 @@ var _CPMenuBarVisible = NO,
+ (void)_setOrRemoveMenuBarAttribute:(id)aValue forKey:(id)aKey
{
if (aValue === nil)
if (aValue == nil)
[_CPMenuBarAttributes removeObjectForKey:aKey];
else
[_CPMenuBarAttributes setObject:aValue forKey:aKey];
@@ -278,7 +290,7 @@ var _CPMenuBarVisible = NO,
@param aMenuItem the item to insert
@param anIndex the index in the menu to insert the item.
*/
- (void)insertItem:(CPMenuItem)aMenuItem atIndex:(unsigned)anIndex
- (void)insertItem:(CPMenuItem)aMenuItem atIndex:(CPUInteger)anIndex
{
[self insertObject:aMenuItem inItemsAtIndex:anIndex];
}
@@ -291,7 +303,7 @@ var _CPMenuBarVisible = NO,
@param anIndex the index location in the menu for the new item
@return the new menu item
*/
- (CPMenuItem)insertItemWithTitle:(CPString)aTitle action:(SEL)anAction keyEquivalent:(CPString)aKeyEquivalent atIndex:(unsigned)anIndex
- (CPMenuItem)insertItemWithTitle:(CPString)aTitle action:(SEL)anAction keyEquivalent:(CPString)aKeyEquivalent atIndex:(CPUInteger)anIndex
{
var item = [[CPMenuItem alloc] initWithTitle:aTitle action:anAction keyEquivalent:aKeyEquivalent];
@@ -335,7 +347,7 @@ var _CPMenuBarVisible = NO,
Removes the item at the specified index from the menu
@param anIndex the index of the item to remove
*/
- (void)removeItemAtIndex:(unsigned)anIndex
- (void)removeItemAtIndex:(CPUInteger)anIndex
{
[self removeObjectFromItemsAtIndex:anIndex];
}
@@ -621,7 +633,7 @@ var _CPMenuBarVisible = NO,
*/
- (void)update
{
if (![self autoenablesItems])
if (!_autoenablesItems)
return;
var items = [self itemArray];
@@ -633,14 +645,25 @@ var _CPMenuBarVisible = NO,
if ([item hasSubmenu])
continue;
var validator = [CPApp targetForAction:[item action] to:[item target] from:item];
// If there are enabled bindings for the item, they override anything else
var binder = [CPBinder getBinding:CPEnabledBinding forObject:item];
if (binder)
{
[binder setValueFor:CPEnabledBinding];
[[_menuWindow _menuView] tile];
return;
}
var validator = [CPApp targetForAction:[item action] to:[item target] from:item],
shouldBeEnabled = YES;
if (!validator)
{
// If targetForAction: returns nil, it could be that there is no action.
// If there is an action and nil is returned, no valid target could be found.
if ([item action] || [item target])
[item setEnabled:NO];
shouldBeEnabled = NO;
else
{
// Check to see if there is a target binding with an invalid selector
@@ -655,16 +678,18 @@ var _CPMenuBarVisible = NO,
selector = [options valueForKey:CPSelectorNameBindingOption];
if (target && selector && ![target respondsToSelector:CPSelectorFromString(selector)])
[item setEnabled:NO];
shouldBeEnabled = NO;
}
}
}
else if (![validator respondsToSelector:[item action]])
[item setEnabled:NO];
shouldBeEnabled = NO;
else if ([validator respondsToSelector:@selector(validateMenuItem:)])
[item setEnabled:[validator validateMenuItem:item]];
shouldBeEnabled = [validator validateMenuItem:item];
else if ([validator respondsToSelector:@selector(validateUserInterfaceItem:)])
[item setEnabled:[validator validateUserInterfaceItem:item]];
shouldBeEnabled = [validator validateUserInterfaceItem:item];
[item setEnabled:shouldBeEnabled];
}
[[_menuWindow _menuView] tile];
@@ -843,6 +868,9 @@ var _CPMenuBarVisible = NO,
+ (void)popUpContextMenu:(CPMenu)aMenu withEvent:(CPEvent)anEvent forView:(CPView)aView withFont:(CPFont)aFont
{
// This is needed when we are making several rights click
[[_CPMenuManager sharedMenuManager] cancelActiveMenu];
[aMenu _menuWillOpen];
if (!aFont)
@@ -851,8 +879,6 @@ var _CPMenuBarVisible = NO,
var theWindow = [aView window],
menuWindow = [_CPMenuWindow menuWindowWithMenu:aMenu font:aFont];
[_CPMenuWindow poolMenuWindow:menuWindow];
[menuWindow setBackgroundStyle:_CPMenuWindowPopUpBackgroundStyle];
var constraintRect = [CPMenu _constraintRectForView:aView],
@@ -928,9 +954,19 @@ var _CPMenuBarVisible = NO,
// Managing the Delegate
- (void)setDelegate:(id)aDelegate
- (void)setDelegate:(id <CPMenuDelegate>)aDelegate
{
if (_delegate === aDelegate)
return;
_delegate = aDelegate;
_implementedDelegateMethods = 0;
if ([_delegate respondsToSelector:@selector(menuWillOpen:)])
_implementedDelegateMethods |= CPMenuDelegate_menuWillOpen_;
if ([_delegate respondsToSelector:@selector(menuDidClose:)])
_implementedDelegateMethods |= CPMenuDelegate_menuDidClose_;
}
- (id)delegate
@@ -940,10 +976,7 @@ var _CPMenuBarVisible = NO,
- (void)_menuWillOpen
{
var delegate = [self delegate];
if ([delegate respondsToSelector:@selector(menuWillOpen:)])
[delegate menuWillOpen:self];
[self _sendDelegateMenuWillOpen];
}
- (void)_menuDidClose
@@ -952,10 +985,7 @@ var _CPMenuBarVisible = NO,
// when a click on the button itself caused the menu to close.
_lastCloseEvent = [CPApp currentEvent];
var delegate = [self delegate];
if ([delegate respondsToSelector:@selector(menuDidClose:)])
[delegate menuDidClose:self];
[self _sendDelegateMenuDidClose];
}
// Handling Tracking
@@ -1048,7 +1078,7 @@ var _CPMenuBarVisible = NO,
Sends the action of the menu item at the specified index.
@param anIndex the index of the item
*/
- (void)performActionForItemAtIndex:(unsigned)anIndex
- (void)performActionForItemAtIndex:(CPUInteger)anIndex
{
var item = _items[anIndex];
@@ -1101,7 +1131,7 @@ var _CPMenuBarVisible = NO,
}
}
- (void)_menuWithName:(CPString)aName
- (CPMenu)_menuWithName:(CPString)aName
{
if (aName === _name)
return self;
@@ -1119,6 +1149,36 @@ var _CPMenuBarVisible = NO,
@end
@implementation CPMenu (CPMenuDelegate)
/*!
@ignore
Call delegate menuWillOpen
*/
- (void)_sendDelegateMenuWillOpen
{
if (!(_implementedDelegateMethods & CPMenuDelegate_menuWillOpen_))
return;
[_delegate menuWillOpen:self];
}
/*!
@ignore
Call delegate menuDidClose
*/
- (void)_sendDelegateMenuDidClose
{
if (!(_implementedDelegateMethods & CPMenuDelegate_menuDidClose_))
return;
[_delegate menuDidClose:self];
}
@end
@implementation CPMenu (CPKeyValueCoding)
- (CPUInteger)countOfItems
@@ -1180,7 +1240,8 @@ var _CPMenuBarVisible = NO,
var CPMenuTitleKey = @"CPMenuTitleKey",
CPMenuNameKey = @"CPMenuNameKey",
CPMenuItemsKey = @"CPMenuItemsKey",
CPMenuShowsStateColumnKey = @"CPMenuShowsStateColumnKey";
CPMenuShowsStateColumnKey = @"CPMenuShowsStateColumnKey",
CPMenuAutoEnablesItemsKey = @"CPMenuAutoEnablesItemsKey";
@implementation CPMenu (CPCoding)
@@ -1202,7 +1263,7 @@ var CPMenuTitleKey = @"CPMenuTitleKey",
_showsStateColumn = ![aCoder containsValueForKey:CPMenuShowsStateColumnKey] || [aCoder decodeBoolForKey:CPMenuShowsStateColumnKey];
_autoenablesItems = YES;
_autoenablesItems = ![aCoder containsValueForKey:CPMenuAutoEnablesItemsKey] || [aCoder decodeBoolForKey:CPMenuAutoEnablesItemsKey];
[self setMinimumWidth:0];
}
@@ -1225,6 +1286,40 @@ var CPMenuTitleKey = @"CPMenuTitleKey",
if (!_showsStateColumn)
[aCoder encodeBool:_showsStateColumn forKey:CPMenuShowsStateColumnKey];
if (!_autoenablesItems)
[aCoder encodeBool:_autoenablesItems forKey:CPMenuAutoEnablesItemsKey];
}
@end
#pragma mark -
@implementation CPMenu (CSSTheming)
+ (void)setNamedValue:(CPString)aName forKey:(CPString)aKey inAttributes:(CPDictionary)aDictionary forTheme:(CPTheme)aTheme
{
var value = [aTheme valueForAttributeWithName:aName forClass:_CPMenuView];
if (value)
[aDictionary setObject:value forKey:aKey];
else
[aDictionary removeObjectForKey:aKey];
}
+ (void)updateMenuBarAttributesWithTheme:(CPTheme)aTheme
{
var newAttributes = @{};
[CPMenu setNamedValue:@"menu-bar-text-color" forKey:@"CPMenuBarTextColor" inAttributes:newAttributes forTheme:aTheme];
[CPMenu setNamedValue:@"menu-bar-title-color" forKey:@"CPMenuBarTitleColor" inAttributes:newAttributes forTheme:aTheme];
[CPMenu setNamedValue:@"menu-bar-text-shadow-color" forKey:@"CPMenuBarTextShadowColor" inAttributes:newAttributes forTheme:aTheme];
[CPMenu setNamedValue:@"menu-bar-title-shadow-color" forKey:@"CPMenuBarTitleShadowColor" inAttributes:newAttributes forTheme:aTheme];
[CPMenu setNamedValue:@"menu-bar-highlight-color" forKey:@"CPMenuBarHighlightColor" inAttributes:newAttributes forTheme:aTheme];
[CPMenu setNamedValue:@"menu-bar-highlight-text-color" forKey:@"CPMenuBarHighlightTextColor" inAttributes:newAttributes forTheme:aTheme];
[CPMenu setNamedValue:@"menu-bar-highlight-text-shadow-color" forKey:@"CPMenuBarHighlightTextShadowColor" inAttributes:newAttributes forTheme:aTheme];
[CPMenu setMenuBarAttributes:newAttributes];
}
@end
+19 -4
View File
@@ -24,14 +24,17 @@
@import "_CPMenuManager.j"
@class _CPMenuView
@class CPMenu
@class CPMenuItem
@global CPMenuDidAddItemNotification
@global CPMenuDidChangeItemNotification
@global CPMenuDidRemoveItemNotification
@global document
@implementation _CPMenuBarWindow : CPPanel
{
CPMenu _menu;
CPView _highlightView;
CPArray _menuItemViews;
@@ -129,10 +132,12 @@
- (void)setColor:(CPColor)aColor
{
var targetView = [[CPTheme defaultTheme] valueForAttributeWithName:@"css-based" forClass:CPView] ? [[self contentView] superview] : [self contentView];
if (!aColor)
[[self contentView] setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-window-background-color" forClass:_CPMenuView]];
[targetView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-window-background-color" forClass:_CPMenuView]];
else
[[self contentView] setBackgroundColor:aColor];
[targetView setBackgroundColor:aColor];
}
- (void)setTextColor:(CPColor)aColor
@@ -277,6 +282,16 @@
[menuItemView setTextColor:_textColor];
[menuItemView setHidden:[item isHidden]];
// If first menu item has tag -1 and if there is a special theme value menu-bar-window-first-item-font,
// set the corresponding font. This is used to set bold on the first item of the menubar (à la Cocoa)
if ((index == 0) && ([item tag] == -1))
{
var firstItemFont = [[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-window-first-item-font" forClass:_CPMenuView];
if (firstItemFont)
[item setFont:firstItemFont];
}
[menuItemView synchronizeWithMenuItem];
[contentView addSubview:menuItemView];
@@ -350,7 +365,7 @@
- (CPFont)font
{
[CPFont systemFontOfSize:[CPFont systemFontSize]];
return [CPFont systemFontOfSize:[CPFont systemFontSize]];
}
- (void)tile
+48 -26
View File
@@ -28,6 +28,8 @@
@class CPWindow
@class _CPMenuWindow
@class _CPMenuView
@class CPMenuItem
@global CPApp
@@ -223,7 +225,7 @@ var STICKY_TIME_INTERVAL = 0.4,
_lastGlobalLocation = globalLocation;
// If the item isn't enabled its as if we clicked on nothing.
if (![activeItem isEnabled] || [activeItem _isMenuBarButton])
if ([activeItem _isMenuBarButton])
{
activeItemIndex = CPNotFound;
activeItem = nil;
@@ -352,7 +354,23 @@ var STICKY_TIME_INTERVAL = 0.4,
if ([activeMenuContainer isMenuBar])
newMenuOrigin = CGPointMake(CGRectGetMinX(activeItemRect), CGRectGetMaxY(activeItemRect));
else
newMenuOrigin = CGPointMake(CGRectGetMaxX(activeItemRect), CGRectGetMinY(activeItemRect));
{
// New theme attributes to have more precise submenus positioning
var defaultTheme = [CPTheme defaultTheme],
themeDeltaX = [defaultTheme valueForAttributeWithName:@"menu-window-submenu-delta-x" forClass:_CPMenuView],
themeDeltaY = [defaultTheme valueForAttributeWithName:@"menu-window-submenu-delta-y" forClass:_CPMenuView],
themeFirstDeltaY = [defaultTheme valueForAttributeWithName:@"menu-window-submenu-first-level-delta-y" forClass:_CPMenuView],
activeMenuIndex = [_menuContainerStack indexOfObject:activeMenuContainer],
deltaX = themeDeltaX ? themeDeltaX : 0,
deltaY = themeDeltaY ? themeDeltaY : 0;
if (themeFirstDeltaY && (activeMenuIndex == 1) && [_menuContainerStack[0] isMenuBar])
deltaY += themeFirstDeltaY;
newMenuOrigin = CGPointMake(CGRectGetMaxX(activeItemRect)+deltaX, CGRectGetMinY(activeItemRect)+deltaY);
}
newMenuOrigin = [activeMenuContainer convertBaseToGlobal:newMenuOrigin];
@@ -407,6 +425,15 @@ var STICKY_TIME_INTERVAL = 0.4,
[menu cancelTracking];
}
- (void)cancelActiveMenu
{
if (CPApp._activeMenu)
{
[self completeTracking];
_menuContainerStack = [];
}
}
- (void)completeTracking
{
var trackingMenu = [self trackingMenu];
@@ -544,7 +571,7 @@ var STICKY_TIME_INTERVAL = 0.4,
var iter = [selectorNames objectEnumerator],
obj;
while ((obj = [iter nextObject]) !== nil)
while ((obj = [iter nextObject]) != nil)
{
var aSelector = CPSelectorFromString(obj);
@@ -571,6 +598,8 @@ var STICKY_TIME_INTERVAL = 0.4,
[self selectNextItemBeginningWith:_keyBuffer inMenu:menu];
_lastGlobalLocation = nil;
}
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:NO];
}
- (void)selectNextItemBeginningWith:(CPString)characters inMenu:(CPMenu)menu
@@ -578,7 +607,7 @@ var STICKY_TIME_INTERVAL = 0.4,
var iter = [[menu itemArray] objectEnumerator],
obj;
while ((obj = [iter nextObject]) !== nil)
while ((obj = [iter nextObject]) != nil)
{
if ([obj isHidden] || ![obj isEnabled])
continue;
@@ -716,39 +745,32 @@ var STICKY_TIME_INTERVAL = 0.4,
- (void)moveDown:(CPMenu)menu
{
var index = menu._highlightedIndex + 1;
var index = menu._highlightedIndex + 1,
item;
// Search for the next enabled item
while ((index < [menu numberOfItems]) && (item = [menu itemAtIndex:index]) && ([item isSeparatorItem] || [item isHidden] || ![item isEnabled]))
index++;
if (index < [menu numberOfItems])
{
[menu _highlightItemAtIndex:index];
var item = [menu highlightedItem];
if ([item isSeparatorItem] || [item isHidden] || ![item isEnabled])
[self moveDown:menu];
}
else if (menu == [CPApp mainMenu])
[menu _highlightItemAtIndex:0];
}
- (void)moveUp:(CPMenu)menu
{
var index = menu._highlightedIndex - 1;
var index = menu._highlightedIndex - 1,
item;
if (index < 0)
{
if (index != CPNotFound || menu == [CPApp mainMenu])
[menu _highlightItemAtIndex:[menu numberOfItems] - 1];
// Search for the previous enabled item
while ((index >= 0) && (item = [menu itemAtIndex:index]) && ([item isSeparatorItem] || [item isHidden] || ![item isEnabled]))
index--;
return;
}
[menu _highlightItemAtIndex:index];
var item = [menu highlightedItem];
if ([item isSeparatorItem] || [item isHidden] || ![item isEnabled])
[self moveUp:menu];
if (index >= 0)
[menu _highlightItemAtIndex:index];
else if (menu == [CPApp mainMenu])
[menu _highlightItemAtIndex:[menu numberOfItems] - 1];
}
- (void)insertNewline:(CPMenu)menu
+42 -3
View File
@@ -25,6 +25,9 @@
@import "CPWindow.j"
@import "_CPMenuManager.j"
@class _CPMenuView
@class CPMenuItem
var _CPMenuWindowPool = [],
_CPMenuWindowPoolCapacity = 5,
@@ -72,7 +75,8 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
+ (void)poolMenuWindow:(_CPMenuWindow)aMenuWindow
{
if (!aMenuWindow || _CPMenuWindowPool.length >= _CPMenuWindowPoolCapacity)
// FIXME :the poolMenuWindow is called too many times somewhere....
if (!aMenuWindow || _CPMenuWindowPool.length >= _CPMenuWindowPoolCapacity || [_CPMenuWindowPool containsObject:aMenuWindow])
return;
_CPMenuWindowPool.push(aMenuWindow);
@@ -409,13 +413,28 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
{
// Don't return indexes of items that aren't visible.
if (!CGRectContainsPoint([_menuClipView bounds], [_menuClipView convertPoint:aPoint fromView:nil]))
return NO;
return CPNotFound;
return [_menuView itemIndexAtPoint:[_menuView convertPoint:aPoint fromView:nil]];
}
@end
#pragma mark -
@implementation _CPMenuWindow (CSSTheming)
- (void)_setThemeIncludingDescendants:(CPTheme)aTheme
{
[[self contentView] _setThemeIncludingDescendants:aTheme];
[_menuView _setThemeIncludingDescendants:aTheme];
[_menuView tile];
}
@end
#pragma mark -
/*
@ignore
*/
@@ -434,7 +453,7 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
return "menu-view";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"menu-window-more-above-image": [CPNull null],
@@ -446,6 +465,7 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
@"menu-bar-window-background-color": [CPNull null],
@"menu-bar-window-background-selected-color": [CPNull null],
@"menu-bar-window-font": [CPNull null],
@"menu-bar-window-first-item-font": [CPNull null],
@"menu-bar-window-height": 30.0,
@"menu-bar-window-margin": 10.0,
@"menu-bar-window-left-margin": 10.0,
@@ -463,6 +483,9 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
@"menu-general-icon-new": [CPNull null],
@"menu-general-icon-save": [CPNull null],
@"menu-general-icon-open": [CPNull null],
@"menu-window-submenu-delta-x": 0.0,
@"menu-window-submenu-delta-y": 0.0,
@"menu-window-submenu-first-level-delta-y": 0.0
};
}
@@ -549,6 +572,7 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
[view setFrameOrigin:CGPointMake(0.0, y)];
[view _setThemeIncludingDescendants:[CPTheme defaultTheme]];
[self addSubview:view];
var size = [view minSize],
@@ -579,3 +603,18 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
}
@end
#pragma mark -
@implementation _CPMenuView (CSSTheming)
- (void)_setThemeIncludingDescendants:(CPTheme)aTheme
{
[self setTheme:aTheme];
[_menuItemViews makeObjectsPerformSelector:@selector(_setThemeIncludingDescendants:) withObject:aTheme];
for (var i = 0, items = [[self menu] itemArray], count = [items count]; i < count; i++)
[[items[i] _menuItemView] _setThemeIncludingDescendants:aTheme];
}
@end
+28 -5
View File
@@ -166,6 +166,9 @@ var CPMenuItemStringRepresentationDictionary = @{
if (_isEnabled === isEnabled)
return;
if (!isEnabled && [self isHighlighted])
[_menu _highlightItemAtIndex:CPNotFound];
_isEnabled = !!isEnabled;
[_menuItemView setDirty];
@@ -502,7 +505,7 @@ CPOffState
if (_submenu)
{
[_submenu setSupermenu:_menu];
[_submenu setTitle:[self title]]
[_submenu setTitle:[self title]];
[self setTarget:_menu];
[self setAction:@selector(submenuAction:)];
@@ -840,7 +843,7 @@ CPControlKeyMask
[item setTarget:_target];
[item setAction:_action];
[item setEnabled:_isEnabled];
[item setHidden:_isHidden]
[item setHidden:_isHidden];
[item setTag:_tag];
[item setState:_state];
[item setImage:_image];
@@ -894,6 +897,20 @@ CPControlKeyMask
@end
#pragma mark -
@implementation CPMenuItem (CSSTheming)
- (void)_setThemeIncludingDescendants:(CPTheme)aTheme
{
[_view _setThemeIncludingDescendants:aTheme];
[_menuItemView _setThemeIncludingDescendants:aTheme];
}
@end
#pragma mark -
var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
CPMenuItemTitleKey = @"CPMenuItemTitleKey",
@@ -908,6 +925,9 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
CPMenuItemImageKey = @"CPMenuItemImageKey",
CPMenuItemAlternateImageKey = @"CPMenuItemAlternateImageKey",
CPMenuItemOnStateImageKey = @"CPMenuItemOnStateImageKey",
CPMenuItemOffStateImageKey = @"CPMenuItemOffStateImageKey",
CPMenuItemMixedStateImageKey = @"CPMenuItemMixedStateImageKey",
CPMenuItemSubmenuKey = @"CPMenuItemSubmenuKey",
CPMenuItemMenuKey = @"CPMenuItemMenuKey",
@@ -952,9 +972,9 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
_image = [aCoder decodeObjectForKey:CPMenuItemImageKey];
_alternateImage = [aCoder decodeObjectForKey:CPMenuItemAlternateImageKey];
// CPImage _onStateImage;
// CPImage _offStateImage;
// CPImage _mixedStateImage;
_onStateImage = [aCoder decodeObjectForKey:CPMenuItemOnStateImageKey];
_offStateImage = [aCoder decodeObjectForKey:CPMenuItemOffStateImageKey];
_mixedStateImage = [aCoder decodeObjectForKey:CPMenuItemMixedStateImageKey];
// This order matters because setSubmenu: needs _menu to be around.
_menu = [aCoder decodeObjectForKey:CPMenuItemMenuKey];
@@ -1000,6 +1020,9 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
ENCODE_IFNOT(CPMenuItemImageKey, _image, nil);
ENCODE_IFNOT(CPMenuItemAlternateImageKey, _alternateImage, nil);
ENCODE_IFNOT(CPMenuItemOnStateImageKey, _onStateImage, nil);
ENCODE_IFNOT(CPMenuItemOffStateImageKey, _offStateImage, nil);
ENCODE_IFNOT(CPMenuItemMixedStateImageKey, _mixedStateImage, nil);
ENCODE_IFNOT(CPMenuItemSubmenuKey, _submenu, nil);
ENCODE_IFNOT(CPMenuItemMenuKey, _menu, nil);
+6 -5
View File
@@ -25,6 +25,7 @@
@class _CPMenuBarWindow
@class _CPMenuView
@class CPMenuItem
@implementation _CPMenuItemMenuBarView : CPView
{
@@ -49,7 +50,7 @@
return "menu-item-bar-view";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"horizontal-margin": 9.0,
@@ -84,25 +85,25 @@
return self;
}
- (CPColor)setTextColor:(CPColor)aColor
- (void)setTextColor:(CPColor)aColor
{
_textColor = aColor;
[self setNeedsLayout];
}
- (CPColor)setTextShadowColor:(CPColor)aColor
- (void)setTextShadowColor:(CPColor)aColor
{
_textShadowColor = aColor;
[self setNeedsLayout];
}
- (CPColor)setHighlightTextColor:(CPColor)aColor
- (void)setHighlightTextColor:(CPColor)aColor
{
_highlightTextColor = aColor;
[self setNeedsLayout];
}
- (CPColor)setHighlightTextShadowColor:(CPColor)aColor
- (void)setHighlightTextShadowColor:(CPColor)aColor
{
_highlightTextShadowColor = aColor;
[self setNeedsLayout];
+19 -4
View File
@@ -31,7 +31,9 @@
+ (id)view
{
return [[self alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 10.0)];
var themedHeight = [[CPTheme defaultTheme] valueForAttributeWithName:@"menu-item-separator-view-height" forClass:_CPMenuItemStandardView];
return [[self alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, (themedHeight ? themedHeight : 10.0))];
}
- (id)initWithFrame:(CGRect)aFrame
@@ -47,12 +49,25 @@
- (void)drawRect:(CGRect)aRect
{
var context = [[CPGraphicsContext currentContext] graphicsPort],
bounds = [self bounds];
bounds = [self bounds],
height = CGRectGetMaxY(bounds),
themedHeight = [[CPTheme defaultTheme] valueForAttributeWithName:@"menu-item-separator-height" forClass:_CPMenuItemStandardView],
lineHeight = themedHeight ? themedHeight : 1.0;
CGContextBeginPath(context);
CGContextMoveToPoint(context, CGRectGetMinX(bounds), FLOOR(CGRectGetMidY(bounds)) - 0.5);
CGContextAddLineToPoint(context, CGRectGetMaxX(bounds), FLOOR(CGRectGetMidY(bounds)) - 0.5);
CGContextSetLineWidth(context, lineHeight);
if (!!((height - lineHeight) % 2))
{
CGContextMoveToPoint(context, CGRectGetMinX(bounds), FLOOR(CGRectGetMidY(bounds)) - 0.5);
CGContextAddLineToPoint(context, CGRectGetMaxX(bounds), FLOOR(CGRectGetMidY(bounds)) - 0.5);
}
else
{
CGContextMoveToPoint(context, CGRectGetMinX(bounds), FLOOR(CGRectGetMidY(bounds)));
CGContextAddLineToPoint(context, CGRectGetMaxX(bounds), FLOOR(CGRectGetMidY(bounds)));
}
CGContextSetStrokeColor(context, [[CPTheme defaultTheme] valueForAttributeWithName:@"menu-item-separator-color" forClass:_CPMenuItemStandardView]);
CGContextStrokePath(context);
+102 -23
View File
@@ -24,6 +24,9 @@
@import "CPImageView.j"
@import "_CPImageAndTextView.j"
@class CPMenuItem
@implementation _CPMenuItemStandardView : CPView
{
CPMenuItem _menuItem @accessors(property=menuItem);
@@ -38,6 +41,8 @@
_CPImageAndTextView _imageAndTextView;
_CPImageAndTextView _keyEquivalentView;
CPView _submenuIndicatorView;
BOOL _hasSubmenuIndicatorImage;
}
+ (CPString)defaultThemeClass
@@ -45,13 +50,14 @@
return "menu-item-standard-view";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"submenu-indicator-color": [CPNull null],
@"menu-item-selection-color": [CPNull null],
@"menu-item-text-shadow-color": [CPNull null],
@"menu-item-text-color": [CPNull null],
@"menu-item-disabled-text-color": [CPColor lightGrayColor],
@"menu-item-default-off-state-image": [CPNull null],
@"menu-item-default-off-state-highlighted-image": [CPNull null],
@"menu-item-default-on-state-image": [CPNull null],
@@ -59,12 +65,17 @@
@"menu-item-default-mixed-state-image": [CPNull null],
@"menu-item-default-mixed-state-highlighted-image": [CPNull null],
@"menu-item-separator-color": [CPNull null],
@"menu-item-separator-height": 1.0,
@"menu-item-separator-view-height": 10.0,
@"left-margin": 3.0,
@"right-margin": 17.0,
@"state-column-width": 14.0,
@"indentation-width": 17.0,
@"vertical-margin": 4.0,
@"vertical-offset": 0.0,
@"right-columns-margin": 30.0,
@"submenu-indicator-image": [CPNull null],
@"submenu-indicator-highlighted-image": [CPNull null]
};
}
@@ -87,6 +98,7 @@
_stateView = [[CPImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 0.0)];
[_stateView setImageScaling:CPImageScaleNone];
[_stateView setImageAlignment:CPImageAlignCenter];
[self addSubview:_stateView];
@@ -105,9 +117,24 @@
[self addSubview:_keyEquivalentView];
_submenuIndicatorView = [[_CPMenuItemSubmenuIndicatorView alloc] initWithFrame:CGRectMake(0.0, 0.0, 8.0, 10.0)];
// Do we have a submenu indicator image specified in the theme ?
_hasSubmenuIndicatorImage = !![self valueForThemeAttribute:@"submenu-indicator-image"];
if (_hasSubmenuIndicatorImage)
{
// Yes, then use an imageView
_submenuIndicatorView = [[CPImageView alloc] initWithFrame:CGRectMakeZero()];
[_submenuIndicatorView setImageAlignment:CPImageAlignCenter];
}
else
{
// No, then use self drawing _CPMenuItemSubmenuIndicatorView
_submenuIndicatorView = [[_CPMenuItemSubmenuIndicatorView alloc] initWithFrame:CGRectMake(0.0, 0.0, 8.0, 10.0)];
[_submenuIndicatorView setColor:[self valueForThemeAttribute:@"submenu-indicator-color"]];
}
[_submenuIndicatorView setColor:[self valueForThemeAttribute:@"submenu-indicator-color"]];
[_submenuIndicatorView setAutoresizingMask:CPViewMinXMargin];
[self addSubview:_submenuIndicatorView];
@@ -121,7 +148,7 @@
- (CPColor)textColor
{
if (![_menuItem isEnabled])
return [CPColor lightGrayColor];
return [self valueForThemeAttribute:@"menu-item-disabled-text-color"];
if (_highlighted)
return [CPColor whiteColor];
@@ -145,11 +172,24 @@
_font = aFont;
}
- (CPFont)font
{
// Menu item font is forced local font or _menuItem font or system font
return _font || [_menuItem font] || [CPFont systemFontOfSize:CPFontCurrentSystemSize];
}
// FIXME: update is called 2 times at each display. Find why and fix.
- (void)update
{
var x = [self valueForThemeAttribute:@"left-margin"] + [_menuItem indentationLevel] * [self valueForThemeAttribute:@"indentation-width"],
height = 0.0,
hasStateColumn = [[_menuItem menu] showsStateColumn];
hasStateColumn = [[_menuItem menu] showsStateColumn],
myFont = [self font],
// When possible, use specific vertical margin/offset value based on font size (which could have been set by control size)
correspondingControlSize = [myFont controlSizeCorrespondingToFontSize],
verticalMargin = [self valueForThemeAttribute:@"vertical-margin" inState:CPControlSizeThemeStates[correspondingControlSize]],
verticalOffset = [self valueForThemeAttribute:@"vertical-offset" inState:CPControlSizeThemeStates[correspondingControlSize]];
if (hasStateColumn)
{
@@ -159,27 +199,32 @@
switch ([_menuItem state])
{
case CPOnState:
[_stateView setImage:[self valueForThemeAttribute:@"menu-item-default-on-state-image"]];
[_stateView setImage:[_menuItem onStateImage] || [self valueForThemeAttribute:@"menu-item-default-on-state-image" inState:CPControlSizeThemeStates[correspondingControlSize]]];
break;
case CPOffState:
[_stateView setImage:[self valueForThemeAttribute:@"menu-item-default-off-state-image"]];
[_stateView setImage:[_menuItem offStateImage] || [self valueForThemeAttribute:@"menu-item-default-off-state-image" inState:CPControlSizeThemeStates[correspondingControlSize]]];
break;
case CPMixedState:
[_stateView setImage:[self valueForThemeAttribute:@"menu-item-default-mixed-state-image"]];
[_stateView setImage:[_menuItem mixedStateImage] || [self valueForThemeAttribute:@"menu-item-default-mixed-state-image" inState:CPControlSizeThemeStates[correspondingControlSize]]];
break;
default:
break;
}
var stateViewFrameOrigin = [_stateView frameOrigin];
stateViewFrameOrigin.x = x;
[_stateView setFrameOrigin:stateViewFrameOrigin];
x += [self valueForThemeAttribute:@"state-column-width"];
}
else
[_stateView setHidden:YES];
[_imageAndTextView setFont:[_menuItem font] || _font];
[_imageAndTextView setFont:myFont];
[_imageAndTextView setVerticalAlignment:CPCenterVerticalTextAlignment];
[_imageAndTextView setImage:[_menuItem image]];
[_imageAndTextView setText:[_menuItem title]];
@@ -192,7 +237,7 @@
imageAndTextViewFrame.origin.x = x;
x += CGRectGetWidth(imageAndTextViewFrame);
height = MAX(height, CGRectGetHeight(imageAndTextViewFrame));
height = MAX(height, CGRectGetHeight(imageAndTextViewFrame)); // FIXME: here, height = 0 -> MAX useless
var hasKeyEquivalent = !![_menuItem keyEquivalent],
hasSubmenu = [_menuItem hasSubmenu];
@@ -202,14 +247,14 @@
if (hasKeyEquivalent)
{
[_keyEquivalentView setFont:[_menuItem font] || _font];
[_keyEquivalentView setFont:myFont];
[_keyEquivalentView setVerticalAlignment:CPCenterVerticalTextAlignment];
[_keyEquivalentView setImage:[_menuItem image]];
[_keyEquivalentView setText:[_menuItem keyEquivalentStringRepresentation]];
[_keyEquivalentView setTextColor:[self textColor]];
[_keyEquivalentView setTextShadowColor:[self textShadowColor]];
[_keyEquivalentView setTextShadowOffset:CGSizeMake(0, 1)];
[_keyEquivalentView setFrameOrigin:CGPointMake(x, [self valueForThemeAttribute:@"vertical-margin"])];
[_keyEquivalentView setFrameOrigin:CGPointMake(x, verticalMargin)];
[_keyEquivalentView sizeToFit];
var keyEquivalentViewFrame = [_keyEquivalentView frame];
@@ -226,6 +271,14 @@
if (hasSubmenu)
{
if (_hasSubmenuIndicatorImage)
{
var submenuIndicatorImage = [self valueForThemeAttribute:@"submenu-indicator-image" inState:CPControlSizeThemeStates[correspondingControlSize]];
[_submenuIndicatorView setImage:submenuIndicatorImage];
[_submenuIndicatorView setFrameSize:[submenuIndicatorImage size]];
}
[_submenuIndicatorView setHidden:NO];
var submenuViewFrame = [_submenuIndicatorView frame];
@@ -238,9 +291,9 @@
else
[_submenuIndicatorView setHidden:YES];
height += 2.0 * [self valueForThemeAttribute:@"vertical-margin"];
height += 2.0 * verticalMargin;
imageAndTextViewFrame.origin.y = FLOOR((height - CGRectGetHeight(imageAndTextViewFrame)) / 2.0);
imageAndTextViewFrame.origin.y = FLOOR((height - CGRectGetHeight(imageAndTextViewFrame)) / 2.0) + verticalOffset;
[_imageAndTextView setFrame:imageAndTextViewFrame];
if (hasStateColumn)
@@ -248,7 +301,7 @@
if (hasKeyEquivalent)
{
keyEquivalentViewFrame.origin.y = FLOOR((height - CGRectGetHeight(keyEquivalentViewFrame)) / 2.0);
keyEquivalentViewFrame.origin.y = FLOOR((height - CGRectGetHeight(keyEquivalentViewFrame)) / 2.0) + verticalOffset;
[_keyEquivalentView setFrame:keyEquivalentViewFrame];
}
@@ -273,6 +326,8 @@
_highlighted = shouldHighlight;
var correspondingControlSize = [[self font] controlSizeCorrespondingToFontSize];
[_imageAndTextView setTextColor:[self textColor]];
[_keyEquivalentView setTextColor:[self textColor]];
[_imageAndTextView setTextShadowColor:[self textShadowColor]];
@@ -282,13 +337,21 @@
{
[self setBackgroundColor:[self valueForThemeAttribute:@"menu-item-selection-color"]];
[_imageAndTextView setImage:[_menuItem alternateImage] || [_menuItem image]];
[_submenuIndicatorView setColor:[self textColor]];
if (_hasSubmenuIndicatorImage)
[_submenuIndicatorView setImage:[self valueForThemeAttribute:@"submenu-indicator-highlighted-image" inState:CPControlSizeThemeStates[correspondingControlSize]]];
else
[_submenuIndicatorView setColor:[self textColor]];
}
else
{
[self setBackgroundColor:nil];
[_imageAndTextView setImage:[_menuItem image]];
[_submenuIndicatorView setColor:[self valueForThemeAttribute:@"submenu-indicator-color"]];
if (_hasSubmenuIndicatorImage)
[_submenuIndicatorView setImage:[self valueForThemeAttribute:@"submenu-indicator-image" inState:CPControlSizeThemeStates[correspondingControlSize]]];
else
[_submenuIndicatorView setColor:[self valueForThemeAttribute:@"submenu-indicator-color"]];
}
if ([[_menuItem menu] showsStateColumn])
@@ -298,15 +361,15 @@
switch ([_menuItem state])
{
case CPOnState:
[_stateView setImage:[self valueForThemeAttribute:@"menu-item-default-on-state-highlighted-image"]];
[_stateView setImage:[_menuItem onStateImage] || [self valueForThemeAttribute:@"menu-item-default-on-state-highlighted-image" inState:CPControlSizeThemeStates[correspondingControlSize]]];
break;
case CPOffState:
[_stateView setImage:[self valueForThemeAttribute:@"menu-item-default-off-state-highlighted-image"]];
[_stateView setImage:[_menuItem offStateImage] || [self valueForThemeAttribute:@"menu-item-default-off-state-highlighted-image" inState:CPControlSizeThemeStates[correspondingControlSize]]];
break;
case CPMixedState:
[_stateView setImage:[self valueForThemeAttribute:@"menu-item-default-mixed-state-highlighted-image"]];
[_stateView setImage:[_menuItem mixedImage] || [self valueForThemeAttribute:@"menu-item-default-mixed-state-highlighted-image" inState:CPControlSizeThemeStates[correspondingControlSize]]];
break;
default:
@@ -318,15 +381,15 @@
switch ([_menuItem state])
{
case CPOnState:
[_stateView setImage:[self valueForThemeAttribute:@"menu-item-default-on-state-image"]];
[_stateView setImage:[_menuItem onStateImage] || [self valueForThemeAttribute:@"menu-item-default-on-state-image" inState:CPControlSizeThemeStates[correspondingControlSize]]];
break;
case CPOffState:
[_stateView setImage:[self valueForThemeAttribute:@"menu-item-default-off-state-image"]];
[_stateView setImage:[_menuItem offStateImage] || [self valueForThemeAttribute:@"menu-item-default-off-state-image" inState:CPControlSizeThemeStates[correspondingControlSize]]];
break;
case CPMixedState:
[_stateView setImage:[self valueForThemeAttribute:@"menu-item-default-mixed-state-image"]];
[_stateView setImage:[_menuItem mixedImage] || [self valueForThemeAttribute:@"menu-item-default-mixed-state-image" inState:CPControlSizeThemeStates[correspondingControlSize]]];
break;
default:
@@ -343,6 +406,22 @@
@end
#pragma mark -
@implementation _CPMenuItemStandardView (CSSTheming)
#pragma mark Override
- (void)_setThemeIncludingDescendants:(CPTheme)aTheme
{
[self setTheme:aTheme];
[[self subviews] makeObjectsPerformSelector:@selector(_setThemeIncludingDescendants:) withObject:aTheme];
}
@end
#pragma mark -
@implementation _CPMenuItemSubmenuIndicatorView : CPView
{
CPColor _color;
+27 -2
View File
@@ -26,6 +26,7 @@
@import "_CPMenuItemStandardView.j"
@import "_CPMenuItemMenuBarView.j"
@class CPMenuItem
@global CPApp
/*
@@ -53,7 +54,7 @@
return "menu-item-view";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{};
}
@@ -112,7 +113,6 @@
_view = menuItemView;
}
}
else if ([_menuItem menu] == [CPApp mainMenu])
{
if (![_view isKindOfClass:[_CPMenuItemMenuBarView class]])
@@ -252,6 +252,31 @@
@end
#pragma mark -
@implementation _CPMenuItemView (CSSTheming)
#pragma mark Override
- (void)_setThemeIncludingDescendants:(CPTheme)aTheme
{
[self setTheme:aTheme];
[_view _setThemeIncludingDescendants:aTheme];
// Items must also perform this (without this, only the selected item does)
[_imageAndTextView _setThemeIncludingDescendants:aTheme];
[_submenuView _setThemeIncludingDescendants:aTheme];
[[_menuItem view] _setThemeIncludingDescendants:aTheme];
if ([_view respondsToSelector:@selector(update)])
[_view update];
}
@end
#pragma mark -
@implementation _CPMenuItemArrowView : CPView
{
CPColor _color;
+152 -23
View File
@@ -27,6 +27,9 @@
@import "CPController.j"
@import "CPKeyValueBinding.j"
@class _CPManagedProxy
@class CPPredicate;
/*!
@class
@@ -47,11 +50,14 @@
BOOL _isEditable;
BOOL _automaticallyPreparesContent;
BOOL _usesLazyFetching @accessors(getter=usesLazyFetching, setter=setUsesLazyFetching:);
BOOL _isUsingManagedProxy;
_CPManagedProxy _managedProxy;
CPCountedSet _observedKeys;
}
+ (id)initialize
+ (void)initialize
{
if (self !== [CPObjectController class])
return;
@@ -179,6 +185,52 @@
return _automaticallyPreparesContent;
}
/*!
Sets the entity name the controller handles.
@param CPString newEntityName - The new entity name.
*/
- (void)setEntityName:(CPString)newEntityName
{
if (!_managedProxy)
{
_managedProxy = [[_CPManagedProxy alloc] init];
_isUsingManagedProxy = YES;
}
[_managedProxy setEntityName:newEntityName];
}
/*!
Returns the entity name.
@return CPString - The name of the entity.
*/
- (CPString)entityName
{
return [_managedProxy entityName];
}
/*!
Sets the predicate used to fetch content.
@param CPPredicate newPredicate - The fetch predicate.
*/
- (void)setFetchPredicate:(CPPredicate)newPredicate
{
[_managedProxy setFetchPredicate:newPredicate];
}
/*!
Returns the fetch predicate.
@return CPPredicate - The predicate used to fetch content.
*/
- (CPPredicate)fetchPredicate
{
return [_managedProxy fetchPredicate];
}
/*!
Overridden by a subclass that require control over the creation of new objects.
*/
@@ -189,6 +241,7 @@
/*!
Sets the object class when creating new objects.
@param Class - the class of new objects that will be created.
*/
- (void)setObjectClass:(Class)aClass
@@ -331,13 +384,35 @@
*/
- (void)_selectionDidChange
{
if (_selection === undefined || _selection === nil)
if (_selection == nil)
_selection = [[CPControllerSelectionProxy alloc] initWithController:self];
[_selection controllerDidChange];
[self didChangeValueForKey:@"selection"];
}
/*!
@ignore
These two private methods map CPTextField notifications to the CPEditorRegistration protocol
This should be generalized in the future:
The CPEditorRegistrationProtocol can be implemented in all controls that support editing, not just CPTextField.
In CPArrayController there are other cases than selection change when we need to review all editor pending changes. They should be covered, including the selection change, by the wider concept described by the methods commitEditing: (forces to end editing) and discardEditing: (pending changes are lost).
*/
- (void)_objectDidBeginEditing:(CPNotification)notification
{
[self objectDidBeginEditing:[notification object]];
}
/*!
@ignore
*/
- (void) _objectDidEndEditing:(CPNotification)notification
{
[self objectDidEndEditing:[notification object]];
}
/*!
@return id - Returns the keys which are being observed.
*/
@@ -363,7 +438,10 @@
var CPObjectControllerContentKey = @"CPObjectControllerContentKey",
CPObjectControllerObjectClassNameKey = @"CPObjectControllerObjectClassNameKey",
CPObjectControllerIsEditableKey = @"CPObjectControllerIsEditableKey",
CPObjectControllerAutomaticallyPreparesContentKey = @"CPObjectControllerAutomaticallyPreparesContentKey";
CPObjectControllerAutomaticallyPreparesContentKey = @"CPObjectControllerAutomaticallyPreparesContentKey",
CPObjectControllerUsesLazyFetchingKey = @"CPObjectControllerUsesLazyFetchingKey",
CPObjectControllerIsUsingManagedProxyKey = @"CPObjectControllerIsUsingManagedProxyKey",
CPObjectControllerManagedProxyKey = @"CPObjectControllerManagedProxyKey";
@implementation CPObjectController (CPCoding)
@@ -374,12 +452,18 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
if (self)
{
var objectClassName = [aCoder decodeObjectForKey:CPObjectControllerObjectClassNameKey],
objectClass = CPClassFromString(objectClassName);
objectClass = CPClassFromString(objectClassName),
content = [aCoder decodeObjectForKey:CPObjectControllerContentKey];
[self setObjectClass:objectClass || [CPMutableDictionary class]];
[self setEditable:[aCoder decodeBoolForKey:CPObjectControllerIsEditableKey]];
[self setAutomaticallyPreparesContent:[aCoder decodeBoolForKey:CPObjectControllerAutomaticallyPreparesContentKey]];
[self setContent:[aCoder decodeObjectForKey:CPObjectControllerContentKey]];
[self setUsesLazyFetching:[aCoder decodeBoolForKey:CPObjectControllerUsesLazyFetchingKey]];
_isUsingManagedProxy = [aCoder decodeBoolForKey:CPObjectControllerIsUsingManagedProxyKey];
_managedProxy = [aCoder decodeObjectForKey:CPObjectControllerManagedProxyKey];
if (content != nil)
[self setContent:content];
_observedKeys = [[CPCountedSet alloc] init];
}
@@ -398,6 +482,11 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
[aCoder encodeBool:[self isEditable] forKey:CPObjectControllerIsEditableKey];
[aCoder encodeBool:[self automaticallyPreparesContent] forKey:CPObjectControllerAutomaticallyPreparesContentKey];
[aCoder encodeBool:[self usesLazyFetching] forKey:CPObjectControllerUsesLazyFetchingKey];
[aCoder encodeBool:_isUsingManagedProxy forKey:CPObjectControllerIsUsingManagedProxyKey];
if (_managedProxy)
[aCoder encodeObject:_managedProxy forKey:CPObjectControllerManagedProxyKey];
}
- (void)awakeFromCib
@@ -459,13 +548,13 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
- (BOOL)isEqual:(id)anObject
{
if ([anObject class] === [self class])
{
if (anObject._observer === _observer && [anObject._keyPath isEqual:_keyPath] && [anObject._object isEqual:_object])
return YES;
}
if (self === anObject)
return YES;
return NO;
if (!anObject || [anObject class] !== [self class] || anObject._observer !== _observer || anObject._keyPath !== _keyPath || anObject._object !== _object)
return NO;
return YES;
}
- (void)observeValueForKeyPath:(CPString)aKeyPath ofObject:(id)anObject change:(CPDictionary)change context:(id)context
@@ -572,7 +661,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
}
}
- (void)insertObject:(id)anObject atIndex:(unsigned)anIndex
- (void)insertObject:(id)anObject atIndex:(CPUInteger)anIndex
{
for (var i = 0, count = [_observationProxies count]; i < count; i++)
{
@@ -592,7 +681,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
[super insertObject:anObject atIndex:anIndex];
}
- (void)removeObjectAtIndex:(unsigned)anIndex
- (void)removeObjectAtIndex:(CPUInteger)anIndex
{
var currentObject = [self objectAtIndex:anIndex];
@@ -614,7 +703,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
[super removeObjectAtIndex:anIndex];
}
- (_CPObservableArray)objectsAtIndexes:(CPIndexSet)theIndexes
- (CPArray)objectsAtIndexes:(CPIndexSet)theIndexes
{
return [_CPObservableArray arrayWithArray:[super objectsAtIndexes:theIndexes]];
}
@@ -629,7 +718,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
[self removeObjectAtIndex:[self count]];
}
- (void)replaceObjectAtIndex:(unsigned)anIndex withObject:(id)anObject
- (void)replaceObjectAtIndex:(CPUInteger)anIndex withObject:(id)anObject
{
var currentObject = [self objectAtIndex:anIndex];
@@ -703,7 +792,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
}
}
if (value === nil || value.isa && [value isEqual:[CPNull null]])
if (value == nil || value.isa && [value isEqual:[CPNull null]])
value = CPNullMarker;
return value;
@@ -749,7 +838,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
- (void)setValue:(id)theValue forKey:(CPString)theKeyPath
{
[self setValue:theKeyPath forKeyPath:theKeyPath];
[self setValue:theValue forKeyPath:theKeyPath];
}
- (unsigned)count
@@ -808,15 +897,55 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
- (void)removeObserver:(id)anObject forKeyPath:(CPString)aKeyPath
{
var proxy = [[_CPObservationProxy alloc] initWithKeyPath:aKeyPath observer:anObject object:self],
index = [_observationProxies indexOfObject:proxy];
[_observationProxies enumerateObjectsUsingBlock:function(aProxy, idx, stop)
{
if (aProxy._object === self && aProxy._keyPath == aKeyPath && aProxy._observer === anObject)
{
var observedObjects = _observedObjectsByKeyPath[aKeyPath];
var observedObjects = _observedObjectsByKeyPath[aKeyPath];
[observedObjects removeObserver:[_observationProxies objectAtIndex:index] forKeyPath:aKeyPath];
[observedObjects removeObserver:aProxy forKeyPath:aKeyPath];
[_observationProxies removeObjectAtIndex:idx];
[_observationProxies removeObjectAtIndex:index];
_observedObjectsByKeyPath[aKeyPath] = nil;
_observedObjectsByKeyPath[aKeyPath] = nil;
stop(YES);
}
}];
}
@end
@implementation _CPManagedProxy : CPObject
{
CPString _entityName @accessors(getter=entityName, setter=setEntityName:);
CPPredicate _fetchPredicate @accessors(getter=fetchPredicate, setter=setFetchPredicate:);
}
@end
var CPManagedProxyEntityNameKey = @"CPManagedProxyEntityNameKey",
CPManagedProxyFetchPredicateKey = @"CPManagedProxyFetchPredicateKey";
@implementation _CPManagedProxy (CPCoding)
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
[self setEntityName:[aCoder decodeObjectForKey:CPManagedProxyEntityNameKey]];
[self setFetchPredicate:[aCoder decodeObjectForKey:CPManagedProxyFetchPredicateKey]];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:[self entityName] forKey:CPManagedProxyEntityNameKey];
[aCoder encodeObject:[self fetchPredicate] forKey:CPManagedProxyFetchPredicateKey];
}
@end
+544 -360
View File
File diff suppressed because it is too large Load Diff
+23 -2
View File
@@ -22,10 +22,13 @@
@import "CPWindow.j"
@global CPApp
CPOKButton = 1;
CPCancelButton = 0;
CPDocModalWindowMask = 1 << 6;
/*!
@ingroup appkit
@class CPPanel
@@ -51,8 +54,6 @@ CPCancelButton = 0;
@global
@class CPWindow
*/
CPDocModalWindowMask = 1 << 6;
@implementation CPPanel : CPWindow
{
BOOL _becomesKeyOnlyIfNeeded;
@@ -119,4 +120,24 @@ CPDocModalWindowMask = 1 << 6;
return YES;
}
#pragma mark -
#pragma mark Overrides
/*!
@ignore
*/
- (void)cancelOperation:(id)sender
{
if ([[CPApp currentEvent] _couldBeKeyEquivalent] && [self performKeyEquivalent:[CPApp currentEvent]])
return;
[[self firstResponder] tryToPerform:@selector(cancel:) with:self];
}
- (void)cancel:(id)sender
{
[self performClose:sender];
}
@end
+16 -71
View File
@@ -26,6 +26,9 @@
@import <Foundation/CPDictionary.j>
@import <Foundation/CPPropertyListSerialization.j>
@class CPWebScriptObject
@typedef DataTransfer
CPGeneralPboard = @"CPGeneralPboard";
CPFontPboard = @"CPFontPboard";
@@ -41,6 +44,9 @@ CPStringPboardType = @"CPStringPboardType";
CPURLPboardType = @"CPURLPboardType";
CPImagesPboardType = @"CPImagesPboardType";
CPVideosPboardType = @"CPVideosPboardType";
CPRTFPboardType = @"CPRTFPboardType";
_CPSmartPboardType = @"_CPSmartPboardType";
_CPASPboardType = @"_CPASPboardType";
UTF8PboardType = @"public.utf8-plain-text";
@@ -48,8 +54,7 @@ UTF8PboardType = @"public.utf8-plain-text";
CPImagePboardType = @"CPImagePboardType";
var CPPasteboards = nil,
supportsNativePasteboard = NO;
var CPPasteboards = nil;
/*!
@ingroup appkit
@@ -65,8 +70,6 @@ var CPPasteboards = nil,
unsigned _changeCount;
CPString _stateUID;
WebScriptObject _nativePasteboard;
}
/*
@@ -80,9 +83,6 @@ var CPPasteboards = nil,
[self setVersion:1.0];
CPPasteboards = @{};
if (typeof window.cpPasteboardWithName !== "undefined")
supportsNativePasteboard = YES;
}
/*!
@@ -125,12 +125,6 @@ var CPPasteboards = nil,
_provided = @{};
_changeCount = 0;
if (supportsNativePasteboard)
{
_nativePasteboard = window.cpPasteboardWithName(aName);
[self _synchronizePasteboard];
}
}
return self;
@@ -160,15 +154,6 @@ var CPPasteboards = nil,
[_owners setObject:anOwner forKey:type];
}
if (_nativePasteboard)
{
var nativeTypes = [types copy];
if ([types containsObject:CPStringPboardType])
nativeTypes.push(UTF8PboardType);
_nativePasteboard.addTypes_(nativeTypes);
}
return ++_changeCount;
}
@@ -179,32 +164,19 @@ var CPPasteboards = nil,
@return the pasteboard's change count
*/
- (unsigned)declareTypes:(CPArray)types owner:(id)anOwner
{
[self _declareTypes:types owner:anOwner updateNativePasteboard:YES];
}
/*! @ignore */
- (unsigned)_declareTypes:(CPArray)types owner:(id)anOwner updateNativePasteboard:(BOOL)shouldUpdate
{
[_types setArray:types];
_owners = @{};
_provided = @{};
var count = _types.length;
while (count--)
[_owners setObject:anOwner forKey:_types[count]];
if (_nativePasteboard && shouldUpdate)
if (anOwner)
{
var nativeTypes = [types copy];
if ([types containsObject:CPStringPboardType])
nativeTypes.push(UTF8PboardType);
_nativePasteboard.declareTypes_(nativeTypes);
_changeCount = _nativePasteboard.changeCount();
var count = _types.length;
while (count--)
[_owners setObject:anOwner forKey:_types[count]];
}
return ++_changeCount;
}
@@ -243,6 +215,10 @@ var CPPasteboards = nil,
*/
- (void)setString:(CPString)aString forType:(CPString)aType
{
// Putting a non-string on the string pasteboard can lead to strange crashes.
if (aString && aString.isa && ![aString isKindOfClass:CPString])
[CPException raise:CPInvalidArgumentException reason:"CPPasteboard setString:forType: must be called with a string."];
[self setPropertyList:aString forType:aType];
}
@@ -263,7 +239,6 @@ var CPPasteboards = nil,
*/
- (CPArray)types
{
[self _synchronizePasteboard];
return _types;
}
@@ -302,36 +277,6 @@ var CPPasteboards = nil,
return nil;
}
- (void)_synchronizePasteboard
{
if (_nativePasteboard && _nativePasteboard.changeCount() > _changeCount)
{
var nativeTypes = [_nativePasteboard.types() copy];
if ([nativeTypes containsObject:UTF8PboardType])
nativeTypes.push(CPStringPboardType);
[self _declareTypes:nativeTypes owner:self updateNativePasteboard:NO];
_changeCount = _nativePasteboard.changeCount();
}
}
/*! @ignore
method provided for integration with native pasteboard
*/
- (void)pasteboard:(CPPasteboard)aPasteboard provideDataForType:(CPString)aType
{
if (aType === CPStringPboardType)
{
var string = _nativePasteboard.stringForType_(UTF8PboardType);
[self setString:string forType:CPStringPboardType];
[self setString:string forType:UTF8PboardType];
}
else
[self setString:_nativePasteboard.stringForType_(aType) forType:aType];
}
/*!
Returns the property list for the specified data type
@param aType the requested data type
+67 -52
View File
@@ -26,8 +26,6 @@
@import "CPMenu.j"
@import "CPMenuItem.j"
var VISIBLE_MARGIN = 7.0;
CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
/*!
@@ -47,6 +45,13 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
return "popup-button";
}
+ (CPDictionary)themeAttributes
{
return @{
@"menu-offset": CGSizeMake(0, 0)
};
}
+ (CPSet)keyPathsForValuesAffectingSelectedIndex
{
return [CPSet setWithObject:@"objectValue"];
@@ -279,7 +284,7 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
Selects the item at the specified index
@param anIndex the index of the item to select
*/
- (void)setObjectValue:(int)anIndex
- (void)setObjectValue:(id)anIndex
{
var indexOfSelectedItem = [self objectValue];
@@ -344,7 +349,7 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
Returns the item at the specified index or \c nil if the item does not exist.
@param anIndex the index of the item to obtain
*/
- (CPMenuItem)itemAtIndex:(unsigned)anIndex
- (CPMenuItem)itemAtIndex:(CPUInteger)anIndex
{
return [[self menu] itemAtIndex:anIndex];
}
@@ -353,7 +358,7 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
Returns the title of the item at the specified index or \c nil if no item exists.
@param anIndex the index of the item
*/
- (CPString)itemTitleAtIndex:(unsigned)anIndex
- (CPString)itemTitleAtIndex:(CPUInteger)anIndex
{
return [[[self menu] itemAtIndex:anIndex] title];
}
@@ -363,15 +368,10 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
*/
- (CPArray)itemTitles
{
var titles = [],
items = [self itemArray],
index = 0,
count = [items count];
for (; index < count; ++index)
titles.push([items[index] title]);
return titles;
return [[self itemArray] arrayByApplyingBlock:function(item)
{
return [item title];
}];
}
/*!
@@ -498,9 +498,17 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
if (index < 0)
{
[self addItemWithTitle:aTitle];
index = [self numberOfItems] - 1;
// this ist to match cocoa where setting an empty string does not add it but simply clears the title
// and sets objectValue to -1
if (aTitle === '')
[self selectItemAtIndex:-1];
else
{
[self addItemWithTitle:aTitle];
index = [self numberOfItems] - 1;
}
}
[self selectItemAtIndex:index];
@@ -684,14 +692,16 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
if ([self pullsDown])
{
var positionedItem = nil,
location = CGPointMake(0.0, CGRectGetMaxY(bounds) - 1);
menuOffset = [self currentValueForThemeAttribute:@"menu-offset"],
location = CGPointMake(menuOffset.width, CGRectGetMaxY(bounds) + menuOffset.height);
}
else
{
var contentRect = [self contentRectForBounds:bounds],
positionedItem = [self selectedItem],
standardLeftMargin = [_CPMenuWindow _standardLeftMargin] + [_CPMenuItemStandardView _standardLeftMargin],
location = CGPointMake(CGRectGetMinX(contentRect) - standardLeftMargin, 0.0);
menuOffset = [self currentValueForThemeAttribute:@"menu-offset"],
location = CGPointMake(CGRectGetMinX(contentRect) - standardLeftMargin + menuOffset.width, menuOffset.height);
minimumWidth += standardLeftMargin;
@@ -773,13 +783,6 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
[[self selectedItem] setState:CPOffState];
}
- (void)_reverseSetBinding
{
[_CPPopUpButtonSelectionBinder reverseSetValueForObject:self];
[super _reverseSetBinding];
}
@end
@implementation CPPopUpButton (BindingSupport)
@@ -802,6 +805,20 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
return [super _binderClassForBinding:aBinding];
}
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return (aBinding == CPSelectedIndexBinding ||
aBinding == CPSelectedTagBinding ||
aBinding == CPSelectedValueBinding);
}
- (void)_reverseSetBinding
{
[_CPPopUpButtonSelectionBinder _reverseSetValueFromExclusiveBinderForObject:self];
[super _reverseSetBinding];
}
@end
@implementation _CPPopUpButtonContentBinder : CPBinder
@@ -838,7 +855,7 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
[self _setContentValuesIfNeeded:contentArray];
}
- (void)valueForBinding:(CPString)aBinding
- (id)valueForBinding:(CPString)aBinding
{
return [self _content];
}
@@ -847,7 +864,17 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
{
var count = [aValue count],
options = [_info objectForKey:CPOptionsKey],
offset = [self _getInsertNullOffset];
offset = [self _getInsertNullOffset],
selectedBindingInfo = [_source infoForBinding:CPSelectedObjectBinding],
selectedObject = nil;
if (selectedBindingInfo)
{
var destination = [selectedBindingInfo objectForKey:CPObservedObjectKey],
keyPath = [selectedBindingInfo objectForKey:CPObservedKeyPathKey];
selectedObject = [destination valueForKeyPath:keyPath];
}
if (count + offset != [_source numberOfItems])
{
@@ -858,9 +885,19 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
for (var i = 0; i < count; i++)
{
var item = [[CPMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:nil];
[self _setValue:[aValue objectAtIndex:i] forItem:item withOptions:options];
var item = [[CPMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:nil],
itemValue = [aValue objectAtIndex:i];
[self _setValue:itemValue forItem:item withOptions:options];
[_source addItem:item];
// Select this item if it is the one selected by the selected object binding
// This is needed if the selected object binding is set before the items
// from the content binding
if (itemValue === selectedObject)
{
[_source setSelectedIndex:[_source numberOfItems] - 1];
}
}
}
else
@@ -910,7 +947,7 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
{
}
- (void)setValue:(id)aValue forBinding:(CPString)aBinding
- (void)setValue:(CPArray)aValue forBinding:(CPString)aBinding
{
[super _setContent:aValue];
}
@@ -931,30 +968,8 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
@end
var binderForObject = {};
@implementation _CPPopUpButtonSelectionBinder : CPBinder
{
CPString _selectionBinding @accessors;
}
- (id)initWithBinding:(CPString)aBinding name:(CPString)aName to:(id)aDestination keyPath:(CPString)aKeyPath options:(CPDictionary)options from:(id)aSource
{
self = [super initWithBinding:aBinding name:aName to:aDestination keyPath:aKeyPath options:options from:aSource];
if (self)
{
binderForObject[[aSource UID]] = self;
_selectionBinding = aName;
}
return self;
}
+ (void)reverseSetValueForObject:(id)aSource
{
var binder = binderForObject[[aSource UID]];
[binder reverseSetValueFor:[binder _selectionBinding]];
}
- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding
+70 -32
View File
@@ -28,8 +28,19 @@
@import "CPImageView.j"
@import "CPResponder.j"
@import "CPView.j"
@import "CPViewController.j"
@import "_CPPopoverWindow.j"
@protocol CPPopoverDelegate <CPObject>
@optional
- (BOOL)popoverShouldClose:(CPPopover)aPopover;
- (void)popoverWillClose:(CPPopover)aPopover;
- (void)popoverDidClose:(CPPopover)aPopover;
- (void)popoverWillShow:(CPPopover)aPopover;
- (void)popoverDidShow:(CPPopover)aPopover;
@end
CPPopoverBehaviorApplicationDefined = 0;
CPPopoverBehaviorTransient = 1;
@@ -60,15 +71,16 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
*/
@implementation CPPopover : CPResponder
{
@outlet CPViewController _contentViewController @accessors(property=contentViewController);
@outlet id _delegate @accessors(getter=delegate);
@outlet CPViewController _contentViewController @accessors(property=contentViewController);
@outlet id <CPPopoverDelegate> _delegate @accessors(getter=delegate);
BOOL _animates @accessors(getter=animates);
int _appearance @accessors(property=appearance);
int _behavior @accessors(getter=behavior);
BOOL _animates @accessors(getter=animates);
int _appearance @accessors(property=appearance);
int _behavior @accessors(getter=behavior);
_CPPopoverWindow _popoverWindow;
int _implementedDelegateMethods;
_CPPopoverWindow _popoverWindow;
CPView _positioningView;
int _implementedDelegateMethods;
}
@@ -127,9 +139,6 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
*/
- (CGSize)contentSize
{
if (![_popoverWindow isVisible])
return CGRectMakeZero();
return [[_contentViewController view] frameSize];
}
@@ -140,7 +149,10 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
*/
- (void)setContentSize:(CGSize)aSize
{
[[_contentViewController view] setFrameSize:aSize];
if (!_popoverWindow)
[[_contentViewController view] setFrameSize:aSize];
else
[_popoverWindow updateFrameWithSize:aSize];
}
/*!
@@ -181,10 +193,10 @@ Set the behavior of the CPPopover. It can be:
return;
_behavior = aBehavior;
[_popoverWindow setStyleMask:[self styleMaskForBehavior]];
[_popoverWindow setStyleMask:[self _styleMaskForBehavior]];
}
- (void)setDelegate:(id)aDelegate
- (void)setDelegate:(id <CPPopoverDelegate>)aDelegate
{
if (_delegate === aDelegate)
return;
@@ -226,17 +238,14 @@ Set the behavior of the CPPopover. It can be:
if (!_contentViewController)
[CPException raise:CPInternalInconsistencyException reason:@"contentViewController must not be nil"];
// If the popover is currently closing, do nothing. That is what Cocoa does.
if ([_popoverWindow isClosing])
// If the popover is currently closing or opening, do nothing. That is what Cocoa does.
if ([_popoverWindow isClosing] || [_popoverWindow isOpening])
return;
if (_implementedDelegateMethods & CPPopoverDelegate_popover_willShow_)
[_delegate popoverWillShow:self];
_positioningView = positioningView;
if (!_popoverWindow)
{
_popoverWindow = [[_CPPopoverWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:[self styleMaskForBehavior]];
}
_popoverWindow = [[_CPPopoverWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:[self _styleMaskForBehavior]];
[_popoverWindow setPlatformWindow:[[positioningView window] platformWindow]];
[_popoverWindow setAppearance:_appearance];
@@ -245,15 +254,22 @@ Set the behavior of the CPPopover. It can be:
[_popoverWindow setMovableByWindowBackground:NO];
[_popoverWindow setFrame:[_popoverWindow frameRectForContentRect:[[_contentViewController view] frame]]];
[_popoverWindow setContentView:[_contentViewController view]];
if (![self isShown])
[self _popoverWillShow];
[_popoverWindow positionRelativeToRect:positioningRect ofView:positioningView preferredEdge:preferredEdge];
if (!_animates && _implementedDelegateMethods & CPPopoverDelegate_popover_didShow_)
[_delegate popoverDidShow:self];
if (![self isShown])
[self _popoverWindowDidShow];
}
- (unsigned)styleMaskForBehavior
- (unsigned)_styleMaskForBehavior
{
return (_behavior == CPPopoverBehaviorTransient) ? CPClosableOnBlurWindowMask : 0;
if (_behavior == CPPopoverBehaviorApplicationDefined)
return 0;
return CPClosableOnBlurWindowMask
}
/*!
@@ -272,9 +288,9 @@ Set the behavior of the CPPopover. It can be:
if ([_popoverWindow isClosing] || ![self isShown])
return;
if (_implementedDelegateMethods & CPPopoverDelegate_popover_willClose_)
[_delegate popoverWillClose:self];
[self _popoverWillClose];
_positioningView = nil;
[_popoverWindow close];
// popoverDidClose will be sent from popoverWindowDidClose, since
@@ -295,9 +311,8 @@ Set the behavior of the CPPopover. It can be:
if ([_popoverWindow isClosing])
return;
if (_implementedDelegateMethods & CPPopoverDelegate_popover_shouldClose_)
if (![_delegate popoverShouldClose:self])
return;
if (![self _popoverShouldClose])
return;
[self _close];
}
@@ -307,7 +322,7 @@ Set the behavior of the CPPopover. It can be:
#pragma mark Delegates
/*! @ignore */
- (BOOL)popoverWindowShouldClose:(_CPPopoverWindow)aPopoverWindow
- (BOOL)_popoverWindowShouldClose
{
[self performClose:self];
@@ -318,19 +333,42 @@ Set the behavior of the CPPopover. It can be:
}
/*! @ignore */
- (void)popoverWindowDidClose:(_CPPopoverWindow)aPopoverWindow
- (void)_popoverWindowDidClose
{
if (_implementedDelegateMethods & CPPopoverDelegate_popover_didClose_)
[_delegate popoverDidClose:self];
}
/*! @ignore */
- (void)popoverWindowDidShow:(_CPPopoverWindow)aPopoverWindow
- (void)_popoverWindowDidShow
{
if (_implementedDelegateMethods & CPPopoverDelegate_popover_didShow_)
[_delegate popoverDidShow:self];
}
/*! @ignore */
- (BOOL)_popoverShouldClose
{
if (_implementedDelegateMethods & CPPopoverDelegate_popover_shouldClose_)
return [_delegate popoverShouldClose:self];
return YES;
}
/*! @ignore */
- (void)_popoverWillClose
{
if (_implementedDelegateMethods & CPPopoverDelegate_popover_willClose_)
[_delegate popoverWillClose:self];
}
/*! @ignore */
- (void)_popoverWillShow
{
if (_implementedDelegateMethods & CPPopoverDelegate_popover_willShow_)
[_delegate popoverWillShow:self];
}
@end
@implementation CPPopover (Deprecated)
+56
View File
@@ -26,6 +26,7 @@
@import "CPWindow_Constants.j"
@typedef CPProgressIndicatorStyle
/*
@global
@group CPProgressIndicatorStyle
@@ -85,6 +86,9 @@ var CPProgressIndicatorSpinningStyleColors = [];
@"spinning-mini-gif": [CPNull null],
@"spinning-small-gif": [CPNull null],
@"spinning-regular-gif": [CPNull null],
@"circular-border-color": [CPNull null],
@"circular-border-size": 1,
@"circular-color": [CPNull null]
};
}
@@ -367,6 +371,7 @@ var CPProgressIndicatorSpinningStyleColors = [];
- (void)drawBar
{
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
- (CPView)createEphemeralSubviewNamed:(CPString)aName
@@ -412,6 +417,9 @@ var CPProgressIndicatorSpinningStyleColors = [];
{
if (_style == CPProgressIndicatorSpinningStyle)
{
if (!_indeterminate)
return;
// This will cause the bar view to go away due to having a nil rect when _style == CPProgressIndicatorSpinningStyle.
[self layoutEphemeralSubviewNamed:"bar-view"
positioned:CPWindowBelow
@@ -437,6 +445,54 @@ var CPProgressIndicatorSpinningStyleColors = [];
[self setBackgroundColor:nil];
}
- (void)drawRect:(CGRect)aRect
{
if (_style == CPProgressIndicatorSpinningStyle && !_indeterminate)
{
var context = [[CPGraphicsContext currentContext] graphicsPort],
rect = CGRectMakeCopy(aRect),
borderSize = [self currentValueForThemeAttribute:@"circular-border-size"];
rect.origin.x += borderSize;
rect.origin.y += borderSize;
rect.size.width = rect.size.width - borderSize * 2;
rect.size.height = rect.size.height - borderSize * 2;
if ([self doubleValue] > [self minValue] && [self doubleValue] < [self maxValue])
{
var midX = CGRectGetMidX(rect),
midY = CGRectGetMidY(rect),
endAngle = Math.PI * 2 * (([self doubleValue] - [self minValue]) / ([self maxValue] - [self minValue])) - Math.PI / 2,
radius = MIN(rect.size.width / 2, rect.size.height / 2);
CGContextBeginPath(context);
CGContextSetLineWidth(context, borderSize);
CGContextSetFillColor(context, [self currentValueForThemeAttribute:@"circular-color"]);
CGContextMoveToPoint(context, midX, midY);
CGContextAddArc(context, midX, midY, radius, 3 * Math.PI / 2, endAngle, YES);
CGContextAddLineToPoint(context, midX, midY);
CGContextClosePath(context);
CGContextFillPath(context);
CGContextStrokePath(context);
}
else if ([self doubleValue] == [self maxValue])
{
CGContextBeginPath(context);
CGContextSetFillColor(context, [self currentValueForThemeAttribute:@"circular-color"]);
CGContextAddEllipseInRect(context, rect);
CGContextClosePath(context);
CGContextFillPath(context);
}
CGContextBeginPath(context);
CGContextSetStrokeColor(context , [self currentValueForThemeAttribute:@"circular-border-color"]);
CGContextSetLineWidth(context, borderSize);
CGContextAddEllipseInRect(context, rect);
CGContextClosePath(context);
CGContextStrokePath(context);
}
}
@end
+123 -40
View File
@@ -25,8 +25,11 @@
@import "CPButton.j"
@class CPRadioGroup
@global CPApp
CPRadioImageOffset = 4.0;
/*!
@ingroup appkit
@@ -64,10 +67,19 @@
[[button1 radioGroup] selectedRadio] returns the currently selected
option.
UPDATE 09/2020 : Implementation of modern Cocoa behavior :
As in Cocoa, radio buttons grouping is now automatic.
To be associated in a common group (and so being mutually exclusive),
radio buttons must combine 2 criteria :
- same superview (enclosing view)
- same action
TODO: This first implementation uses "as is" CPRadioGroup. This could
be simplified (no more need for radio group action, for example)
*/
CPRadioImageOffset = 4.0;
@implementation CPRadio : CPButton
{
CPRadioGroup _radioGroup;
@@ -152,7 +164,7 @@ CPRadioImageOffset = 4.0;
[_radioGroup _setSelectedRadio:self];
}
- (void)sendAction:(SEL)anAction to:(id)anObject
- (BOOL)sendAction:(SEL)anAction to:(id)anObject
{
[super sendAction:anAction to:anObject];
@@ -160,6 +172,71 @@ CPRadioImageOffset = 4.0;
[CPApp sendAction:[_radioGroup action] to:[_radioGroup target] from:_radioGroup];
}
- (void)viewDidMoveToSuperview
{
[self _setRadioGroup];
[super viewDidMoveToSuperview];
}
- (void)setAction:(SEL)anAction
{
if (anAction === _action)
return;
[super setAction:anAction];
[self _setRadioGroup];
}
#pragma mark Private methods
- (void)_setRadioGroup
{
// Implementation of modern Cocoa behavior : automatic radio group
// If no action is set or no superview, no grouping can be done.
if (![self action] || ![self superview])
{
// If this radio is in a group (size > 1), remove it.
if ([[self radioGroup] size] > 1)
{
[self setRadioGroup:[CPRadioGroup new]];
if ([self state] === CPOnState)
[_radioGroup _setSelectedRadio:self];
}
return;
}
// Search in superview subviews for other radio buttons having the same action.
// Take the one with the radio group having the greatest number of members.
var radioGroup;
for (var i = 0, superviewSubviews = [[self superview] subviews], count = [superviewSubviews count], aSubview, myAction = [self action], radioGroupSize = -1; (i < count); i++)
{
aSubview = superviewSubviews[i];
if ([aSubview isKindOfClass:CPRadio] && (aSubview !== self) && ([aSubview action] === myAction) && ([[aSubview radioGroup] size] > radioGroupSize))
{
radioGroup = [aSubview radioGroup];
radioGroupSize = [radioGroup size];
}
}
if (radioGroup)
[self setRadioGroup:radioGroup];
else
// No other radio buttons to group with found.
// It may be because this radio button was in a radio group and its action was changed.
// If this is the case, we must reisolate it in a new radio group.
if ([_radioGroup size] > 1)
[self setRadioGroup:[CPRadioGroup new]];
if ([self state] === CPOnState)
[_radioGroup _setSelectedRadio:self];
}
@end
var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
@@ -183,21 +260,37 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
[aCoder encodeObject:_radioGroup forKey:CPRadioRadioGroupKey];
}
- (CPImage)image
#pragma mark -
#pragma mark Override methods from CPButton
- (CPThemeState)_contentVisualState
{
return [self currentValueForThemeAttribute:@"image"];
// Note : Behavior differs from CPButton as title doesn't follow the highlightsBy content flag
var visualState = [self themeState] || CPThemeStateNormal, // Needed during theme compilation
currentState = [self state];
if ((currentState !== CPOffState) && (_showsStateBy & CPContentsCellMask))
visualState = visualState.and((currentState === CPOnState) ? CPThemeStateSelected : CPButtonStateMixed);
return visualState;
}
- (CPImage)alternateImage
- (CPThemeState)_imageVisualState
{
return [self currentValueForThemeAttribute:@"image"];
}
// Note : Behavior differs from CPButton as we don't force "not selected" theme state
// when button is highglighted and selected
- (BOOL)startTrackingAt:(CGPoint)aPoint
{
var startedTracking = [super startTrackingAt:aPoint];
[self highlight:YES];
return startedTracking;
var visualState = [self themeState] || CPThemeStateNormal, // Needed during theme compilation
currentState = [self state];
if (_isHighlighted && (_highlightsBy & CPContentsCellMask))
visualState = visualState.and(CPThemeStateHighlighted);
if ((currentState !== CPOffState) && (_showsStateBy & CPContentsCellMask))
visualState = visualState.and((currentState === CPOnState) ? CPThemeStateSelected : CPButtonStateMixed);
return visualState;
}
@end
@@ -267,9 +360,9 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
- (BOOL)selectRadioWithTag:(int)tag
{
var index = [_radios indexOfObjectPassingTest:function(radio)
{
return [radio tag] === tag;
}];
{
return [radio tag] === tag;
}];
if (index !== CPNotFound)
{
@@ -304,6 +397,11 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
return _radios;
}
- (int)size
{
return [_radios count];
}
- (void)setEnabled:(BOOL)enabled
{
[_radios makeObjectsPerformSelector:@selector(setEnabled:) withObject:enabled];
@@ -356,7 +454,7 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
[_selectedRadio setState:CPOffState];
_selectedRadio = aRadio;
[_CPRadioGroupSelectionBinder reverseSetValueForObject:self];
[_CPRadioGroupSelectionBinder _reverseSetValueFromExclusiveBinderForObject:self];
}
@end
@@ -407,32 +505,17 @@ var CPRadioGroupRadiosKey = @"CPRadioGroupRadiosKey",
return [super _binderClassForBinding:aBinding];
}
@end
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return (aBinding == CPSelectedIndexBinding ||
aBinding == CPSelectedTagBinding ||
aBinding == CPSelectedValueBinding);
}
var binderForObject = {};
@end
@implementation _CPRadioGroupSelectionBinder : CPBinder
{
CPString _selectionBinding @accessors;
}
- (id)initWithBinding:(CPString)aBinding name:(CPString)aName to:(id)aDestination keyPath:(CPString)aKeyPath options:(CPDictionary)options from:(id)aSource
{
self = [super initWithBinding:aBinding name:aName to:aDestination keyPath:aKeyPath options:options from:aSource];
if (self)
{
binderForObject[[aSource UID]] = self;
_selectionBinding = aName;
}
return self;
}
+ (void)reverseSetValueForObject:(id)aSource
{
var binder = binderForObject[[aSource UID]];
[binder reverseSetValueFor:[binder _selectionBinding]];
}
- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding
+16 -2
View File
@@ -24,8 +24,10 @@
@import <Foundation/CPObjJRuntime.j>
@import "CPEvent.j"
@import "CPCursor.j"
@class CPKeyBinding
@class CPMenu
CPDeleteKeyCode = 8;
CPTabKeyCode = 9;
@@ -199,6 +201,18 @@ CPDeleteForwardKeyCode = 46;
[_nextResponder performSelector:_cmd withObject:anEvent];
}
/*!
Notifies the receiver that the mouse entered the receiver's area and that it can adapt the cursor.
@param anEvent contains information about the exit
*/
- (void)cursorUpdate:(CPEvent)anEvent
{
if (_nextResponder)
[_nextResponder performSelector:_cmd withObject:anEvent];
else
[[CPCursor arrowCursor] set];
}
/*!
Notifies the receiver that the mouse scroll wheel has moved.
@param anEvent information about the scroll
@@ -356,7 +370,7 @@ CPDeleteForwardKeyCode = 46;
var CPResponderNextResponderKey = @"CPResponderNextResponderKey",
CPResponderMenuKey = @"CPResponderMenuKey";
@implementation CPResponder (CPCoding)
@implementation CPResponder (CPCoding) <CPCoding>
/*!
Initializes the responder with data from a coder.
@@ -383,7 +397,7 @@ var CPResponderNextResponderKey = @"CPResponderNextResponderKey",
- (void)encodeWithCoder:(CPCoder)aCoder
{
// This will come out nil on the other side with decodeObjectForKey:
if (_nextResponder !== nil)
if (_nextResponder != nil)
[aCoder encodeConditionalObject:_nextResponder forKey:CPResponderNextResponderKey];
[aCoder encodeObject:_menu forKey:CPResponderMenuKey];
+5 -5
View File
@@ -484,7 +484,7 @@
#pragma mark RuleEditor delegate methods
- (int)_queryNumberOfChildrenOfItem:(id)rowItem withRowType:(int)type
- (int)_queryNumberOfChildrenOfItem:(id)rowItem withRowType:(CPRuleEditorRowType)type
{
if (rowItem == nil)
{
@@ -494,7 +494,7 @@
return [[rowItem children] count];
}
- (id)_queryChild:(int)childIndex ofItem:(id)rowItem withRowType:(int)type
- (id)_queryChild:(int)childIndex ofItem:(id)rowItem withRowType:(CPRuleEditorRowType)type
{
if (rowItem == nil)
{
@@ -505,7 +505,7 @@
return [[rowItem children] objectAtIndex:childIndex];
}
- (id)_queryValueForItem:(id)rowItem inRow:(int)rowIndex
- (id)_queryValueForItem:(id)rowItem inRow:(CPInteger)rowIndex
{
return [rowItem displayValue];
}
@@ -516,7 +516,7 @@ var CPPredicateTemplatesKey = @"CPPredicateTemplates";
@implementation CPPredicateEditor (CPCoding)
- (id)initWithCoder:(id)aCoder
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
@@ -531,7 +531,7 @@ var CPPredicateTemplatesKey = @"CPPredicateTemplates";
return self;
}
- (void)encodeWithCoder:(id)aCoder
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
[aCoder encodeObject:_allTemplates forKey:CPPredicateTemplatesKey];
@@ -27,8 +27,7 @@
@import "CPMenuItem.j"
@import "CPTextField.j"
// NOTE: CPDatePicker is not implemented yet
@class CPDatePicker
@import "CPDatePicker.j"
CPUndefinedAttributeType = 0;
@@ -472,9 +471,11 @@ CPTransformableAttributeType = 1800;
var value;
if (attributeType >= CPInteger16AttributeType && attributeType <= CPFloatAttributeType)
value = [aView intValue];
value = [aView floatValue];
else if (attributeType == CPBooleanAttributeType)
value = [aView state];
else if (attributeType == CPDateAttributeType)
value = [aView dateValue];
else
value = [aView stringValue];
@@ -488,7 +489,36 @@ CPTransformableAttributeType = 1800;
- (id)copy
{
return [CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:self]];
var views = [CPArray array],
copy = [[[self class] alloc] init];
[copy _setTemplateType:_templateType];
[copy _setOptions:_predicateOptions];
[copy _setModifier:_predicateModifier];
[copy _setLeftAttributeType:_leftAttributeType];
[copy _setRightAttributeType:_rightAttributeType];
[copy setLeftIsWildcard:_leftIsWildcard];
[copy setRightIsWildcard:_rightIsWildcard];
[_views enumerateObjectsUsingBlock:function(aView, idx, stop)
{
var vcopy;
if ([aView implementsSelector:@selector(copy)])
{
vcopy = [aView copy];
}
else
{
vcopy = [CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:aView]];
}
[views addObject:vcopy];
}];
[copy setTemplateViews:views];
return copy;
}
+ (id)_operatorsForAttributeType:(CPAttributeType)attributeType
@@ -680,7 +710,10 @@ CPTransformableAttributeType = 1800;
view = [[CPCheckBox alloc] initWithFrame:CGRectMake(0, 0, 50, 26)];
}
else if (attributeType == CPDateAttributeType)
view = [[CPDatePicker alloc] initWithFrame:CGRectMake(0, 0, 150, 26)];
{
view = [[CPDatePicker alloc] initWithFrame:CGRectMake(0, 0, 180, 26)];
[view setDatePickerElements:CPYearMonthDayDatePickerElementFlag];
}
else
return nil;
@@ -702,12 +735,12 @@ CPTransformableAttributeType = 1800;
return textField;
}
- (void)_setOptions:(unsigned int)options
- (void)_setOptions:(unsigned)options
{
_predicateOptions = options;
}
- (void)_setModifier:(unsigned int)modifier
- (void)_setModifier:(unsigned)modifier
{
_predicateModifier = modifier;
}
@@ -797,5 +830,31 @@ var CPPredicateTemplateTypeKey = @"CPPredicateTemplateType",
[coder encodeObject:_views forKey:CPPredicateTemplateViewsKey];
}
@end
// Copy support for built-in types
@implementation CPDatePicker (CPCopying)
- (id)copy
{
var ret = [[[self class] alloc] initWithFrame:[self frame]];
[ret setTextFont:[self textFont]];
[ret setMinDate:[self minDate]];
[ret setMaxDate:[self maxDate]];
[ret setTimeInterval:[self timeInterval]];
[ret setDatePickerMode:[self datePickerMode]];
[ret setDatePickerElements:[self datePickerElements]];
[ret setDatePickerStyle:[self datePickerStyle]];
[ret setLocale:[self locale]];
[ret setDateValue:[self dateValue]];
[ret setBackgroundColor:[self backgroundColor]];
[ret setDrawsBackground:[self drawsBackground]];
[ret setBordered:[self isBordered]];
[ret _init];
return ret;
}
@end
/*! @endcond */
+159 -90
View File
@@ -41,6 +41,21 @@
@global CPCaseInsensitivePredicateOption
@global CPOrPredicateType
@protocol CPRuleEditorDelegate <CPObject>
@required
- (id)ruleEditor:(CPRuleEditor)editor child:(CPInteger)index forCriterion:(id)criterion withRowType:(CPRuleEditorRowType)rowType;
- (id)ruleEditor:(CPRuleEditor)editor displayValueForCriterion:(id)criterion inRow:(CPInteger)row;
- (CPInteger)ruleEditor:(CPRuleEditor)editor numberOfChildrenForCriterion:(id)criterion withRowType:(CPRuleEditorRowType)rowType;
@optional
- (CPDictionary)ruleEditor:(CPRuleEditor)editor predicatePartsForCriterion:(id)criterion withDisplayValue:(id)value inRow:(CPInteger)row;
- (void)ruleEditorRowsDidChange:(CPNotification)notification;
@end
var CPRuleEditorDelegate_ruleEditor_predicatePartsForCriterion_withDisplayValue_inRow_ = 1 << 1;
var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
itemsContext = "items",
valuesContext = "values",
@@ -69,50 +84,51 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
@implementation CPRuleEditor : CPControl
{
BOOL _suppressKeyDownHandling;
BOOL _allowsEmptyCompoundRows;
BOOL _disallowEmpty;
BOOL _delegateWantsValidation;
BOOL _editable;
BOOL _sendAction;
BOOL _suppressKeyDownHandling;
BOOL _allowsEmptyCompoundRows;
BOOL _disallowEmpty;
BOOL _delegateWantsValidation;
BOOL _editable;
BOOL _sendAction;
Class _rowClass;
Class _rowClass;
CPIndexSet _draggingRows;
CPInteger _subviewIndexOfDropLine;
CPView _dropLineView;
CPIndexSet _draggingRows;
CPInteger _subviewIndexOfDropLine;
CPView _dropLineView;
CPMutableArray _rowCache;
CPMutableArray _slices;
CPMutableArray _rowCache;
CPMutableArray _slices;
CPPredicate _predicate;
CPPredicate _predicate;
CPString _itemsKeyPath;
CPString _subrowsArrayKeyPath;
CPString _typeKeyPath;
CPString _valuesKeyPath;
CPString _boundArrayKeyPath @accessors(property=boundArrayKeyPath);
CPString _itemsKeyPath;
CPString _subrowsArrayKeyPath;
CPString _typeKeyPath;
CPString _valuesKeyPath;
CPString _boundArrayKeyPath @accessors(property=boundArrayKeyPath);
CPView _slicesHolder;
CPViewAnimation _currentAnimation;
CPView _slicesHolder;
CPViewAnimation _currentAnimation;
CPInteger _lastRow;
CPInteger _nestingMode;
CPInteger _lastRow;
CPInteger _nestingMode;
float _alignmentGridWidth;
float _sliceHeight;
float _alignmentGridWidth;
float _sliceHeight;
id _ruleDataSource;
id _ruleDelegate;
id _boundArrayOwner;
id _ruleDataSource;
id <CPRuleEditorDelegate> _ruleDelegate;
id _boundArrayOwner;
unsigned _implementedDelegateMethods;
CPString _stringsFilename;
CPString _stringsFilename;
BOOL _isKeyDown;
BOOL _nestingModeDidChange;
BOOL _isKeyDown;
BOOL _nestingModeDidChange;
_CPRuleEditorLocalizer _standardLocalizer @accessors(property=standardLocalizer);
CPDictionary _itemsAndValuesToAddForRowType;
_CPRuleEditorLocalizer _standardLocalizer @accessors(property=standardLocalizer);
CPDictionary _itemsAndValuesToAddForRowType;
}
/*! @cond */
@@ -122,7 +138,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
return @"rule-editor";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"alternating-row-colors": [CPNull null],
@@ -130,20 +146,22 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
@"slice-top-border-color": [CPNull null],
@"slice-bottom-border-color": [CPNull null],
@"slice-last-bottom-border-color": [CPNull null],
@"font": [CPNull null],
@"font": [CPFont systemFontOfSize:12],
@"font-color": [CPNull null],
@"add-image": [CPNull null],
@"remove-image": [CPNull null],
@"vertical-alignment": [CPNull null]
};
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self !== nil)
if (self)
{
_slices = [[CPMutableArray alloc] init];
_sliceHeight = 26.;
_sliceHeight = 26.0;
_nestingMode = CPRuleEditorNestingModeSimple; // 10.5 default is CPRuleEditorNestingModeCompound
_editable = YES;
_allowsEmptyCompoundRows = NO;
@@ -213,19 +231,24 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
@discussion CPRuleEditor requires a delegate that implements the required delegate methods to function.
@see delegate
*/
- (void)setDelegate:(id)aDelegate
- (void)setDelegate:(id <CPRuleEditorDelegate>)aDelegate
{
if (_ruleDelegate === aDelegate)
return;
var nc = [CPNotificationCenter defaultCenter];
if (_ruleDelegate)
[nc removeObserver:_ruleDelegate name:nil object:self];
_ruleDelegate = aDelegate;
_implementedDelegateMethods = 0;
if ([_ruleDelegate respondsToSelector:@selector(ruleEditorRowsDidChange:)])
[nc addObserver:_ruleDelegate selector:@selector(ruleEditorRowsDidChange:) name:CPRuleEditorRowsDidChangeNotification object:nil];
if ([_ruleDelegate respondsToSelector:@selector(ruleEditor:predicatePartsForCriterion:withDisplayValue:inRow:)])
_implementedDelegateMethods |= CPRuleEditorDelegate_ruleEditor_predicatePartsForCriterion_withDisplayValue_inRow_;
}
/*!
@brief Returns a Boolean value that indicates whether the receiver is editable.
@@ -396,7 +419,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
*/
- (void)setFormattingStringsFilename:(CPString)stringsFilename
{
if (_standardLocalizer === nil)
if (_standardLocalizer == nil)
_standardLocalizer = [_CPRuleEditorLocalizer new];
if (_stringsFilename !== stringsFilename)
@@ -404,14 +427,14 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
// Convert an empty string to nil
_stringsFilename = stringsFilename || nil;
if (stringsFilename !== nil)
if (stringsFilename != nil)
{
if (![stringsFilename hasSuffix:@".strings"])
stringsFilename = stringsFilename + @".strings";
var path = [[CPBundle mainBundle] pathForResource:stringsFilename];
if (path !== nil)
if (path != nil)
[_standardLocalizer loadContentOfURL:[CPURL URLWithString:path]];
}
}
@@ -442,7 +465,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
*/
- (void)setCriteria:(CPArray)criteria andDisplayValues:(CPArray)values forRowAtIndex:(int)rowIndex
{
if (criteria === nil || values === nil)
if (criteria == nil || values == nil)
[CPException raise:CPInvalidArgumentException reason:_cmd + @". criteria and values parameters must not be nil."];
if (rowIndex < 0 || rowIndex >= [self numberOfRows])
@@ -461,7 +484,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
@param row The index of a row in the receiver.
@return The currently chosen items for row @a row.
*/
- (id)criteriaForRow:(int)row
- (id)criteriaForRow:(CPInteger)row
{
var rowcache = [self _rowCacheForIndex:row];
if (rowcache)
@@ -480,7 +503,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
@return The chosen values (strings, views, or menu items) for row row.
@discussion The values returned are the same as those returned from the delegate method -#ruleEditor:displayValueForCriterion:inRow:
*/
- (CPMutableArray)displayValuesForRow:(int)row
- (CPMutableArray)displayValuesForRow:(CPInteger)row
{
var rowcache = [self _rowCacheForIndex:row];
if (rowcache)
@@ -503,7 +526,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
@param rowIndex The index of a row in the receiver.
@return The index of the parent of the row at @a rowIndex. If the row at @a rowIndex is a root row, returns @c -1.
*/
- (int)parentRowForRow:(int)rowIndex
- (int)parentRowForRow:(CPInteger)rowIndex
{
if (rowIndex < 0 || rowIndex >= [self numberOfRows])
[CPException raise:CPRangeException reason:_cmd + @" row " + rowIndex + " is out of range"];
@@ -544,7 +567,7 @@ TODO: implement
@return The type of the row at @a rowIndex.
@warning Raises a @c CPRangeException if rowIndex is less than @c 0 or greater than or equal to the number of rows.
*/
- (CPRuleEditorRowType)rowTypeForRow:(int)rowIndex
- (CPRuleEditorRowType)rowTypeForRow:(CPInteger)rowIndex
{
if (rowIndex < 0 || rowIndex > [self numberOfRows])
[CPException raise:CPRangeException reason:_cmd + @"row " + rowIndex + " is out of range"];
@@ -565,7 +588,7 @@ TODO: implement
@return The immediate subrows of the row at @a rowIndex.
@discussion Rows are numbered starting at @c 0.
*/
- (CPIndexSet)subrowIndexesForRow:(int)rowIndex
- (CPIndexSet)subrowIndexesForRow:(CPInteger)rowIndex
{
var object;
@@ -691,7 +714,7 @@ TODO: implement
@note Currently, @a shouldAnimate has no effect, rows are always animated when calling this method.
@see addRow:
*/
- (void)insertRowAtIndex:(int)rowIndex withType:(unsigned int)rowType asSubrowOfRow:(int)parentRow animate:(BOOL)shouldAnimate
- (void)insertRowAtIndex:(int)rowIndex withType:(unsigned int)rowType asSubrowOfRow:(CPInteger)parentRow animate:(BOOL)shouldAnimate
{
/*
TODO: raise exceptions if parentRow is greater than or equal to rowIndex, or if rowIndex would fall amongst the children of some other parent, or if the nesting mode forbids this configuration.
@@ -810,7 +833,7 @@ TODO: implement
var item = [items objectAtIndex:i],
//var displayValue = [self _queryValueForItem:item inRow:aRow]; Ask the delegate or get cached value ?.
displayValue = [[self displayValuesForRow:aRow] objectAtIndex:i],
predpart = [_ruleDelegate ruleEditor:self predicatePartsForCriterion:item withDisplayValue:displayValue inRow:aRow];
predpart = [self _sendDelegateRuleEditorPredicatePartsForCriterion:item withDisplayValue:displayValue inRow:aRow];
if (predpart)
[predicateParts addEntriesFromDictionary:predpart];
@@ -829,7 +852,7 @@ TODO: implement
while (current_index !== CPNotFound)
{
var subpredicate = [self predicateForRow:current_index];
if (subpredicate !== nil)
if (subpredicate != nil)
[subpredicates addObject:subpredicate];
current_index = [subrowsIndexes indexGreaterThanIndex:current_index];
@@ -865,33 +888,33 @@ TODO: implement
modifier = [predicateParts objectForKey:CPRuleEditorPredicateComparisonModifier],
selector = CPSelectorFromString([predicateParts objectForKey:CPRuleEditorPredicateCustomSelector]);
if (lhs === nil)
if (lhs == nil)
{
CPLogConsole(@"missing left expression in predicate parts dictionary");
return NULL;
}
if (rhs === nil)
if (rhs == nil)
{
CPLogConsole(@"missing right expression in predicate parts dictionary");
return NULL;
}
if (selector === nil && operator === nil)
if (selector == nil && operator == nil)
{
CPLogConsole(@"missing operator and selector in predicate parts dictionary");
return NULL;
}
if (modifier === nil)
if (modifier == nil)
CPLogConsole(@"missing modifier in predicate parts dictionary. Setting default: CPDirectPredicateModifier");
if (options === nil)
if (options == nil)
CPLogConsole(@"missing options in predicate parts dictionary. Setting default: CPCaseInsensitivePredicateOption");
try
{
if (selector !== nil)
if (selector != nil)
predicate = [CPComparisonPredicate predicateWithLeftExpression:lhs
rightExpression:rhs
customSelector:selector
@@ -1144,7 +1167,7 @@ TODO: implement
- (BOOL)_wantsRowAnimations
{
return (_currentAnimation !== nil);
return (_currentAnimation != nil);
}
- (void)_updateButtonVisibilities
@@ -1313,7 +1336,7 @@ TODO: implement
return [_boundArrayOwner mutableArrayValueForKey:_boundArrayKeyPath];
}
- (BOOL)_nextUnusedItems:(CPArray)items andValues:(CPArray)values forRow:(int)rowIndex forRowType:(unsigned int)type
- (BOOL)_nextUnusedItems:(CPArray)items andValues:(CPArray)values forRow:(CPInteger)rowIndex forRowType:(unsigned int)type
{
var parentItem = [items lastObject], // if empty items array, this is NULL aka the root item;
childrenCount = [self _queryNumberOfChildrenOfItem:parentItem withRowType:type],
@@ -1375,7 +1398,7 @@ TODO: implement
return YES;
}
- (CPMutableArray)_getItemsAndValuesToAddForRow:(int)rowIndex ofType:(CPRuleEditorRowType)type
- (CPMutableArray)_getItemsAndValuesToAddForRow:(CPInteger)rowIndex ofType:(CPRuleEditorRowType)type
{
//var cachedItemsAndValues = _itemsAndValuesToAddForRowType[type];
//if (cachedItemsAndValues)
@@ -1418,7 +1441,7 @@ TODO: implement
[self insertRowAtIndex:insertIndex withType:type asSubrowOfRow:parentRowIndex animate:YES];
}
- (id)_insertNewRowAtIndex:(int)insertIndex ofType:(CPRuleEditorRowType)rowtype withParentRow:(int)parentRowIndex
- (id)_insertNewRowAtIndex:(int)insertIndex ofType:(CPRuleEditorRowType)rowtype withParentRow:(CPInteger)parentRowIndex
{
var row = [[[self rowClass] alloc] init],
itemsandvalues = [self _getItemsAndValuesToAddForRow:insertIndex ofType:rowtype],
@@ -1520,7 +1543,7 @@ TODO: implement
}
}
- (void)_changedItem:(id)fromItem toItem:(id)toItem inRow:(int)aRow atCriteriaIndex:(int)fromItemIndex
- (void)_changedItem:(id)fromItem toItem:(id)toItem inRow:(CPInteger)aRow atCriteriaIndex:(int)fromItemIndex
{
var criteria = [self criteriaForRow:aRow],
displayValues = [self displayValuesForRow:aRow],
@@ -1684,7 +1707,7 @@ TODO: implement
[super bind:aBinding toObject:observableController withKeyPath:aKeyPath options:options];
}
- (void)unbind:(id)object
- (void)unbind:(CPString)object
{
_rowClass = [_CPRuleEditorRowObject class];
[super unbind:object];
@@ -1716,8 +1739,7 @@ TODO: implement
{
if (_delegateWantsValidation)
{
var selector = @selector(ruleEditor:predicatePartsForCriterion:withDisplayValue:inRow:);
if (![_ruleDelegate respondsToSelector:selector])
if (![self _delegateRespondsToRuleEditorPredicatePartsForCriterionWithDisplayValueInRow])
return;
_delegateWantsValidation = NO;
@@ -1731,7 +1753,7 @@ TODO: implement
{
var subpredicate = [self predicateForRow:current_index];
if (subpredicate !== nil)
if (subpredicate != nil)
[subpredicates addObject:subpredicate];
current_index = [subindexes indexGreaterThanIndex:current_index];
@@ -1773,7 +1795,7 @@ TODO: implement
startRect = [aslice frame],
startIndex = [aslice rowIndex] - 1;
if ([aslice superview] === nil)
if ([aslice superview] == nil)
{
startRect = CGRectMake(0, startIndex * _sliceHeight, CGRectGetWidth(startRect), _sliceHeight);
[aslice _reconfigureSubviews];
@@ -1865,14 +1887,34 @@ TODO: implement
return [self valueForThemeAttribute:@"font"];
}
- (CPImage)_addImage
- (CPColor)_fontColor
{
return [self valueForThemeAttribute:@"add-image"];
return [self valueForThemeAttribute:@"font-color"];
}
- (CPImage)_removeImage
- (CPImage)_imageAdd
{
return [self valueForThemeAttribute:@"remove-image"];
return [self valueForThemeAttribute:@"add-image" inState:CPThemeStateNormal];
}
- (CPImage)_imageAddHighlighted
{
return [self valueForThemeAttribute:@"add-image" inState:CPThemeStateHighlighted];
}
- (CPImage)_imageRemove
{
return [self valueForThemeAttribute:@"remove-image" inState:CPThemeStateNormal];
}
- (CPImage)_imageRemoveHighlighted
{
return [self valueForThemeAttribute:@"remove-image" inState:CPThemeStateHighlighted];
}
- (CPVerticalTextAlignment)_verticalAlignment
{
return [self valueForThemeAttribute:@"vertical-alignment"];
}
- (CPString)_toolTipForAddCompoundRowButton
@@ -2005,7 +2047,7 @@ TODO: implement
return [_ruleDelegate ruleEditor:self child:childIndex forCriterion:item withRowType:type];
}
- (id)_queryValueForItem:(id)item inRow:(int)row
- (id)_queryValueForItem:(id)item inRow:(CPInteger)row
{
return [_ruleDelegate ruleEditor:self displayValueForCriterion:item inRow:row];
}
@@ -2026,12 +2068,12 @@ TODO: implement
_alignmentGridWidth = width;
}
- (BOOL)_validateItem:(id)item value:(id)value inRow:(int)row
- (BOOL)_validateItem:(id)item value:(id)value inRow:(CPInteger)row
{
return [self _queryCanSelectItem:item displayValue:value inRow:row];
}
- (BOOL)_queryCanSelectItem:(id)item displayValue:(id)value inRow:(int)row
- (BOOL)_queryCanSelectItem:(id)item displayValue:(id)value inRow:(CPInteger)row
{
return YES;
}
@@ -2079,7 +2121,7 @@ TODO: implement
return;
var point = [self convertPoint:[event locationInWindow] fromView:nil],
view = [_slices objectAtIndex:FLOOR(point.y / _sliceHeight)];
view = [_slices objectAtIndex:FLOOR(MAX(0, point.y) / _sliceHeight)];
if ([self _dragShouldBeginFromMouseDown:view])
[self _performDragForSlice:view withEvent:event];
@@ -2087,7 +2129,7 @@ TODO: implement
- (BOOL)_dragShouldBeginFromMouseDown:(CPView)view
{
return (([self nestingMode] === CPRuleEditorNestingModeList || [view rowIndex] !== 0) && _editable && [view isKindOfClass:[_CPRuleEditorViewSliceRow class]] && _draggingRows === nil);
return (([self nestingMode] === CPRuleEditorNestingModeList || [view rowIndex] !== 0) && _editable && [view isKindOfClass:[_CPRuleEditorViewSliceRow class]] && _draggingRows == nil);
}
- (BOOL)_performDragForSlice:(id)slice withEvent:(CPEvent)event
@@ -2128,7 +2170,7 @@ TODO: implement
return YES;
}
- (CPDragOperation)draggingEntered:(id < CPDraggingInfo >)sender
- (CPDragOperation)draggingEntered:(id /*< CPDraggingInfo >*/)sender
{
if ([sender draggingSource] === self)
{
@@ -2158,14 +2200,14 @@ TODO: implement
_subviewIndexOfDropLine = CPNotFound;
}
- (CPDragOperation)draggingUpdated:(id <CPDraggingInfo>)sender
- (CPDragOperation)draggingUpdated:(id /*<CPDraggingInfo>*/)sender
{
var point = [self convertPoint:[sender draggingLocation] fromView:nil],
y = point.y + _sliceHeight / 2,
indexOfDropLine = FLOOR(y / _sliceHeight),
numberOfRows = [self numberOfRows];
if (indexOfDropLine < 0 || indexOfDropLine > numberOfRows || (indexOfDropLine >= [_draggingRows firstIndex] && indexOfDropLine <= [_draggingRows lastIndex] + 1))
if (indexOfDropLine <= 0 || indexOfDropLine > numberOfRows || (indexOfDropLine >= [_draggingRows firstIndex] && indexOfDropLine <= [_draggingRows lastIndex] + 1))
{
if (_subviewIndexOfDropLine !== CPNotFound && indexOfDropLine !== _subviewIndexOfDropLine)
[self _clearDropLine];
@@ -2195,12 +2237,12 @@ TODO: implement
return CPDragOperationMove;
}
- (BOOL)prepareForDragOperation:(id < CPDraggingInfo >)sender
- (BOOL)prepareForDragOperation:(id /*< CPDraggingInfo >*/)sender
{
return (_subviewIndexOfDropLine !== CPNotFound);
}
- (BOOL)performDragOperation:(id < CPDraggingInfo >)info
- (BOOL)performDragOperation:(id /*< CPDraggingInfo >*/)info
{
var aboveInsertIndexCount = 0,
object,
@@ -2262,7 +2304,7 @@ TODO: implement
{
}
- (void)_setWindow:(id)window
- (void)_setWindow:(CPWindow)window
{
[super _setWindow:window];
}
@@ -2279,7 +2321,7 @@ TODO: implement
- (void)_postRowCountChangedNotificationOfType:(CPString)notificationName indexes:indexes
{
var userInfo = indexes === nil ? @{} : @{ "indexes": indexes };
var userInfo = indexes == nil ? @{} : @{ "indexes": indexes };
[[CPNotificationCenter defaultCenter] postNotificationName:notificationName object:self userInfo:userInfo];
}
@@ -2325,7 +2367,7 @@ TODO: implement
return YES;
}
- (void)_getAllAvailableItems:(id)items values:(id)values asChildrenOfItem:(id)parentItem inRow:(int)aRow
- (void)_getAllAvailableItems:(id)items values:(id)values asChildrenOfItem:(id)parentItem inRow:(CPInteger)aRow
{
var type,
indexofCriterion,
@@ -2344,7 +2386,7 @@ TODO: implement
var criteria = [self criteriaForRow:aRow];
indexofCriterion = [criteria indexOfObject:criterion];
if (parentItem !== nil
if (parentItem != nil
&& indexofCriterion !== CPNotFound
&& indexofCriterion < [criteria count] - 1)
{
@@ -2377,6 +2419,33 @@ TODO: implement
@end
@implementation CPRuleEditor (CPRuleEditorDelegate)
/*!
@ignore
Check if the delegate responds to ruleEditor:predicatePartsForCriterion:withDisplayValue:inRow:
*/
- (BOOL)_delegateRespondsToRuleEditorPredicatePartsForCriterionWithDisplayValueInRow
{
return _implementedDelegateMethods & CPRuleEditorDelegate_ruleEditor_predicatePartsForCriterion_withDisplayValue_inRow_;
}
/*!
@ignore
Call delegate ruleEditor:predicatePartsForCriterion:withDisplayValue:inRow:
*/
- (CPDictionary)_sendDelegateRuleEditorPredicatePartsForCriterion:(id)criterion withDisplayValue:(id)value inRow:(CPInteger)row
{
if (!(_implementedDelegateMethods & CPRuleEditorDelegate_ruleEditor_predicatePartsForCriterion_withDisplayValue_inRow_))
return @{};
return [_ruleDelegate ruleEditor:self predicatePartsForCriterion:criterion withDisplayValue:value inRow:row];
}
@end
var CPRuleEditorAlignmentGridWidthKey = @"CPRuleEditorAlignmentGridWidth",
CPRuleEditorSliceHeightKey = @"CPRuleEditorSliceHeight",
CPRuleEditorStringsFilenameKey = @"CPRuleEditorStringsFilename",
@@ -2400,7 +2469,7 @@ var CPRuleEditorAlignmentGridWidthKey = @"CPRuleEditorAlignmentGridWidth",
- (id)initWithCoder:(CPCoder)coder
{
self = [super initWithCoder:coder];
if (self !== nil)
if (self)
{
[self setFormattingStringsFilename:[coder decodeObjectForKey:CPRuleEditorStringsFilenameKey]];
_alignmentGridWidth = [coder decodeFloatForKey:CPRuleEditorAlignmentGridWidthKey];
@@ -2426,7 +2495,7 @@ var CPRuleEditorAlignmentGridWidthKey = @"CPRuleEditorAlignmentGridWidth",
return self;
}
- (void)encodeWithCoder:(id)coder
- (void)encodeWithCoder:(CPCoder)coder
{
[super encodeWithCoder:coder];
@@ -2481,10 +2550,10 @@ var CriteriaKey = @"criteria",
return "<" + [self className] + ">\nsubrows = " + [subrows description] + "\ncriteria = " + [criteria description] + "\ndisplayValues = " + [displayValues description];
}
- (id)initWithCoder:(id)coder
- (id)initWithCoder:(CPCoder)coder
{
self = [super init];
if (self !== nil)
if (self)
{
subrows = [coder decodeObjectForKey:SubrowsKey];
criteria = [coder decodeObjectForKey:CriteriaKey];
@@ -2495,7 +2564,7 @@ var CriteriaKey = @"criteria",
return self;
}
- (void)encodeWithCoder:(id)coder
- (void)encodeWithCoder:(CPCoder)coder
{
[coder encodeObject:subrows forKey:SubrowsKey];
[coder encodeObject:criteria forKey:CriteriaKey];
@@ -2534,7 +2603,7 @@ var CPBoundArrayKey = @"CPBoundArray";
return self;
}
- (id)initWithCoder:(id)coder
- (id)initWithCoder:(CPCoder)coder
{
if (self = [super init])
boundArray = [coder decodeObjectForKey:CPBoundArrayKey];
@@ -2542,7 +2611,7 @@ var CPBoundArrayKey = @"CPBoundArray";
return self;
}
- (void)encodeWithCoder:(id)coder
- (void)encodeWithCoder:(CPCoder)coder
{
[coder encodeObject:boundArray forKey:CPBoundArrayKey];
}
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
CPRuleEditorPredicateLeftExpression = "CPRuleEditorPredicateLeftExpression";
CPRuleEditorPredicateRightExpression = "CPRuleEditorPredicateRightExpression";
CPRuleEditorPredicateComparisonModifier = "CPRuleEditorPredicateComparisonModifier";
@@ -36,5 +37,6 @@ CPRuleEditorNestingModeList = 1; // Allows a single list, with no nes
CPRuleEditorNestingModeCompound = 2; // Unlimited nesting and compound rows; this is the default
CPRuleEditorNestingModeSimple = 3; // One compound row at the top with subrows beneath it, and no further nesting allowed
@typedef CPRuleEditorRowType
CPRuleEditorRowTypeSimple = 0;
CPRuleEditorRowTypeCompound = 1;
@@ -131,7 +131,7 @@
{
var title = [self title];
if (title !== nil)
if (title != nil)
return title;
return [self templateView];
@@ -20,6 +20,8 @@
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
@class CPPredicateEditorRowTemplate
@implementation _CPPredicateEditorTree : CPObject
{
CPPredicateEditorRowTemplate template @accessors;
+4 -4
View File
@@ -40,7 +40,7 @@ var LocalizerStringsRegex = new RegExp("\"(.+)\"\\s*=\\s*\"(.+)\"\\s*;\\s*(//.+)
- (void)reloadIfNeeded
{
if (connection !== nil) // Connection waiting
if (connection != nil) // Connection waiting
{
connection = nil;
@@ -51,7 +51,7 @@ var LocalizerStringsRegex = new RegExp("\"(.+)\"\\s*=\\s*\"(.+)\"\\s*;\\s*(//.+)
- (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)rawString
{
if (connection !== nil && rawString !== nil)
if (connection != nil && rawString != nil)
[self loadContent:rawString];
connection = nil;
@@ -83,11 +83,11 @@ var LocalizerStringsRegex = new RegExp("\"(.+)\"\\s*=\\s*\"(.+)\"\\s*;\\s*(//.+)
{
[self reloadIfNeeded];
if (_dictionary !== nil && aString !== nil)
if (_dictionary != nil && aString != nil)
{
var localized = [_dictionary objectForKey:aString];
if (localized !== nil)
if (localized != nil)
return localized;
}
@@ -1,203 +0,0 @@
/*
* Created by cacaodev@gmail.com.
* Copyright (c) 2011 Pear, Inc. All rights reserved.
*
* 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 "CPBezierPath.j"
@import "CPPopUpButton.j"
@class _CPRuleEditorViewSlice
var GRADIENT_START_COLOR = "#fcfcfc",
GRADIENT_END_COLOR = "#dfdfdf",
BORDER_COLOR = "#BDBDBD";
var GRADIENT_NORMAL,
GRADIENT_HIGHLIGHTED,
GRADIENT_PROPERTY;
if (CPBrowserIsEngine(CPWebKitBrowserEngine))
{
GRADIENT_NORMAL = "-webkit-gradient(linear, left top, left bottom, from(" + GRADIENT_START_COLOR + "), to(" + GRADIENT_END_COLOR + "))",
GRADIENT_HIGHLIGHTED = "-webkit-gradient(linear, left top, left bottom, from(" + GRADIENT_END_COLOR + "), to(" + GRADIENT_START_COLOR + "))";
GRADIENT_PROPERTY = "background";
}
else if (CPBrowserIsEngine(CPGeckoBrowserEngine))
{
GRADIENT_NORMAL = "-moz-linear-gradient(top, " + GRADIENT_START_COLOR + ", " + GRADIENT_END_COLOR + ")",
GRADIENT_HIGHLIGHTED = "-moz-linear-gradient(top, " + GRADIENT_END_COLOR + ", " + GRADIENT_START_COLOR + ")";
GRADIENT_PROPERTY = "background";
}
else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
{
GRADIENT_NORMAL = "progid:DXImageTransform.Microsoft.gradient(startColorstr='" + GRADIENT_START_COLOR + "', endColorstr='" + GRADIENT_END_COLOR + "')";
GRADIENT_HIGHLIGHTED = "progid:DXImageTransform.Microsoft.gradient(startColorstr='" + GRADIENT_END_COLOR + "', endColorstr='" + GRADIENT_START_COLOR + "')";
GRADIENT_PROPERTY = "filter";
}else
{
GRADIENT_NORMAL = GRADIENT_START_COLOR;
GRADIENT_HIGHLIGHTED = GRADIENT_END_COLOR;
GRADIENT_PROPERTY = "background";
}
@implementation _CPRuleEditorPopUpButton : CPPopUpButton
{
CPInteger radius;
}
- (void)_sharedInit
{
[self setBordered:NO];
#if PLATFORM(DOM)
var style = _DOMElement.style;
style.border = "1px solid " + BORDER_COLOR;
style[GRADIENT_PROPERTY] = GRADIENT_NORMAL;
#endif
}
- (id)initWithFrame:(CGRect)aFrame
{
if (self = [super initWithFrame:aFrame])
[self _sharedInit];
return self;
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
[self _sharedInit];
return self;
}
- (id)hitTest:(CGPoint)point
{
if (!CGRectContainsPoint([self frame], point) || ![self sliceIsEditable])
return nil;
return self;
}
- (BOOL)sliceIsEditable
{
var superview = [self superview];
return ![superview isKindOfClass:[_CPRuleEditorViewSlice]] || [superview isEditable];
}
- (BOOL)trackMouse:(CPEvent)theEvent
{
if (![self sliceIsEditable])
return NO;
return [super trackMouse:theEvent];
}
- (CGRect)contentRectForBounds:(CGRect)bounds
{
var contentRect = [super contentRectForBounds:bounds];
contentRect.origin.x += radius;
contentRect.size.width -= 2 * radius;
return contentRect;
}
- (void)layoutSubviews
{
#if PLATFORM(DOM)
radius = FLOOR(CGRectGetHeight([self bounds]) / 2);
var style = _DOMElement.style,
radiusCSS = radius + "px";
style.borderRadius = radiusCSS;
#endif
[super layoutSubviews];
}
- (void)drawRect:(CGRect)aRect
{
var context = [[CPGraphicsContext currentContext] graphicsPort],
bounds = [self bounds],
arrow_width = FLOOR(CGRectGetHeight(bounds) / 3.5);
CGContextTranslateCTM(context, CGRectGetWidth(bounds) - radius - arrow_width, CGRectGetHeight(bounds) / 2);
var arrowsPath = [CPBezierPath bezierPath];
[arrowsPath moveToPoint:CGPointMake(0, 1)];
[arrowsPath lineToPoint:CGPointMake(arrow_width, 1)];
[arrowsPath lineToPoint:CGPointMake(arrow_width / 2, arrow_width + 1)];
[arrowsPath closePath];
CGContextSetFillColor(context, [CPColor colorWithWhite:101 / 255 alpha:1]);
[arrowsPath fill];
CGContextScaleCTM(context, 1 , -1);
[arrowsPath fill];
}
@end
@implementation _CPRuleEditorButton : CPButton
{
CPInteger radius;
}
- (void)_sharedInit
{
[self setBordered:NO];
#if PLATFORM(DOM)
var style = _DOMElement.style;
style.border = "1px solid " + BORDER_COLOR;
style[GRADIENT_PROPERTY] = GRADIENT_NORMAL;
#endif
}
- (id)initWithFrame:(CGRect)aFrame
{
if (self = [super initWithFrame:aFrame])
[self _sharedInit];
return self;
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
[self _sharedInit];
return self;
}
- (void)layoutSubviews
{
#if PLATFORM(DOM)
radius = FLOOR(CGRectGetHeight([self bounds]) / 2);
var style = _DOMElement.style,
radiusCSS = radius + "px";
style.borderRadius = radiusCSS;
style[GRADIENT_PROPERTY] = ([self isHighlighted]) ? GRADIENT_HIGHLIGHTED : GRADIENT_NORMAL;
#endif
[super layoutSubviews];
}
@end
+5 -4
View File
@@ -19,6 +19,8 @@
@import "CPView.j"
@class CPRuleEditor
@implementation _CPRuleEditorViewSlice : CPView
{
CPRuleEditor _ruleEditor;
@@ -27,7 +29,6 @@
CGRect _animationTargetRect @accessors(property=_animationTargetRect);
BOOL _selected @accessors(getter=_isSelected, setter=_setSelected:);
BOOL _lastSelected @accessors(getter=_isLastSelected, setter=_setLastSelected:);
CPColor _backgroundColor @accessors(property=backgroundColor);
BOOL _editable @accessors(getter=isEditable, setter=setEditable:);
}
@@ -61,9 +62,9 @@
- (void)drawRect:(CGRect)rect
{
var context = [[CPGraphicsContext currentContext] graphicsPort],
bounds = [self bounds],
maxX = CGRectGetWidth(bounds),
maxY = CGRectGetHeight(bounds);
bounds = [self bounds],
maxX = CGRectGetWidth(bounds),
maxY = CGRectGetHeight(bounds);
// Draw background
if ([self _isSelected])
+99 -89
View File
@@ -19,24 +19,27 @@
@import "CPRuleEditor_Constants.j"
@import "_CPRuleEditorViewSlice.j"
@import "_CPRuleEditorPopUpButton.j"
@import "CPButton.j"
@import "CPDatePicker.j"
@import "CPPopUpButton.j"
@global CPApp
var CONTROL_HEIGHT = 16.,
BUTTON_HEIGHT = 16.;
@global CPMiniControlSize
@global CPSmallControlSize
@implementation _CPRuleEditorViewSliceRow : _CPRuleEditorViewSlice
{
CPMutableArray _ruleOptionViews;
CPMutableArray _ruleOptionFrames;
CPMutableArray _correspondingRuleItems;
CPMutableArray _ruleOptionInitialViewFrames;
CPButton _addButton;
CPButton _subtractButton;
CPButton _addButton;
CPButton _subtractButton;
CPMutableArray _correspondingRuleItems;
CPMutableArray _ruleOptionFrames;
CPMutableArray _ruleOptionInitialViewFrames;
CPMutableArray _ruleOptionViews;
CPRuleEditorRowType _rowType @accessors;
CPRuleEditorRowType _plusButtonRowType;
CPRuleEditorRowType _rowType @accessors;
CPRuleEditorRowType _plusButtonRowType;
}
- (id)initWithFrame:(CGRect)frame ruleEditorView:(id)editor
@@ -49,34 +52,33 @@ var CONTROL_HEIGHT = 16.,
- (void)_initShared
{
_correspondingRuleItems = [[CPMutableArray alloc] init];
_ruleOptionFrames = [[CPMutableArray alloc] init];
_ruleOptionInitialViewFrames = [[CPMutableArray alloc] init];
_ruleOptionViews = [[CPMutableArray alloc] init];
_editable = [_ruleEditor isEditable];
_correspondingRuleItems = [[CPMutableArray alloc] init];
_ruleOptionFrames = [[CPMutableArray alloc] init];
_ruleOptionInitialViewFrames = [[CPMutableArray alloc] init];
_ruleOptionViews = [[CPMutableArray alloc] init];
_editable = [_ruleEditor isEditable];
_addButton = [self _createAddRowButton];
_subtractButton = [self _createDeleteRowButton];
_addButton = [self _createAddRowButton];
_subtractButton = [self _createDeleteRowButton];
[_addButton setToolTip:[_ruleEditor _toolTipForAddSimpleRowButton]];
[_subtractButton setToolTip:[_ruleEditor _toolTipForDeleteRowButton]];
[_addButton setHidden:!_editable];
[_subtractButton setHidden:!_editable];
[self addSubview:_addButton];
[self addSubview:_subtractButton];
[self setAutoresizingMask:CPViewWidthSizable];
var center = [CPNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(_textDidChange:) name:CPControlTextDidChangeNotification object:nil];
}
- (CPButton)_createRowButton
{
var button = [[_CPRuleEditorButton alloc] initWithFrame:CGRectMakeZero()];
[button setFont:[CPFont boldFontWithName:@"Apple Symbol" size:12.0]];
[button setTextColor:[CPColor colorWithWhite:150 / 255 alpha:1]];
var button = [[CPButton alloc] initWithFrame:CGRectMakeZero()];
[button setFont:[_ruleEditor font]];
[button setTextColor:[_ruleEditor _fontColor]];
[button setAlignment:CPCenterTextAlignment];
[button setAutoresizingMask:CPViewMinXMargin];
[button setButtonType:CPMomentaryChangeButton];
[button setBordered:NO];
[button setHidden:!_editable];
[button setImagePosition:CPImageOnly];
return button;
@@ -86,7 +88,10 @@ var CONTROL_HEIGHT = 16.,
{
var button = [self _createRowButton];
[button setImage:[_ruleEditor _addImage]];
[button setToolTip:[_ruleEditor _toolTipForAddSimpleRowButton]];
[button setValue:[_ruleEditor _imageAdd] forThemeAttribute:@"image" inState:CPThemeStateNormal];
[button setValue:[_ruleEditor _imageAddHighlighted] forThemeAttribute:@"image" inState:CPThemeStateHighlighted];
[button setAction:@selector(_addOption:)];
[button setTarget:self];
@@ -97,7 +102,10 @@ var CONTROL_HEIGHT = 16.,
{
var button = [self _createRowButton];
[button setImage:[_ruleEditor _removeImage]];
[button setToolTip:[_ruleEditor _toolTipForDeleteRowButton]];
[button setValue:[_ruleEditor _imageRemove] forThemeAttribute:@"image" inState:CPThemeStateNormal];
[button setValue:[_ruleEditor _imageRemoveHighlighted] forThemeAttribute:@"image" inState:CPThemeStateHighlighted];
[button setAction:@selector(_deleteOption:)];
[button setTarget:self];
@@ -107,20 +115,17 @@ var CONTROL_HEIGHT = 16.,
- (CPMenuItem)_createMenuItemWithTitle:(CPString )title
{
title = [[_ruleEditor standardLocalizer] localizedStringForString:title];
var mItem = [[CPMenuItem alloc] initWithTitle:title action:nil keyEquivalent:@""];
return mItem;
return [[CPMenuItem alloc] initWithTitle:title action:nil keyEquivalent:@""];
}
- (CPPopUpButton)_createPopUpButtonWithItems:(CPArray)itemsArray selectedItemIndex:(int)index
{
var title = [[itemsArray objectAtIndex:index] title],
font = [_ruleEditor font],
width = [title sizeWithFont:font].width + 20,
rect = CGRectMake(0, 0, (width - width % 40) + 80, CONTROL_HEIGHT),
var title = [[itemsArray objectAtIndex:index] title],
font = [_ruleEditor font],
width = [title sizeWithFont:font].width + 35, // 35 for right arrows + margins
rect = CGRectMake(0, 0, width, [_ruleEditor rowHeight]),
popup = [[CPPopUpButton alloc] initWithFrame:rect];
popup = [[_CPRuleEditorPopUpButton alloc] initWithFrame:rect];
[popup setTextColor:[CPColor colorWithWhite:101 / 255 alpha:1]];
[popup setValue:font forThemeAttribute:@"font"];
var count = [itemsArray count];
@@ -137,17 +142,17 @@ var CONTROL_HEIGHT = 16.,
return [CPMenuItem separatorItem];
}
- (_CPRuleEditorTextField)_createStaticTextFieldWithStringValue:(CPString)text
- (CPTextField)_createStaticTextFieldWithStringValue:(CPString)text
{
var textField = [[_CPRuleEditorTextField alloc] initWithFrame:CGRectMakeZero()],
ruleEditorFont = [_ruleEditor font],
font = [CPFont fontWithName:[ruleEditorFont familyName] size:[ruleEditorFont size] + 2],
localizedText = [[_ruleEditor standardLocalizer] localizedStringForString:text],
size = [localizedText sizeWithFont:font];
[textField setFrameSize:CGSizeMake(size.width + 4, CONTROL_HEIGHT + 2)];
var textField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()],
ruleEditorFont = [_ruleEditor font],
font = [CPFont fontWithName:[ruleEditorFont familyName] size:[ruleEditorFont size] + 2],
localizedText = [[_ruleEditor standardLocalizer] localizedStringForString:text],
size = [localizedText sizeWithFont:font];
[textField setFrameSize:CGSizeMake(size.width + 4, [_ruleEditor rowHeight])];
[textField setValue:font forThemeAttribute:@"font"];
[textField setValue:[_ruleEditor _verticalAlignment] forThemeAttribute:@"vertical-alignment"];
[textField setStringValue:localizedText];
return textField;
@@ -159,6 +164,7 @@ var CONTROL_HEIGHT = 16.,
[self setNeedsDisplay:YES];
var type = _plusButtonRowType;
if ([_ruleEditor nestingMode] == CPRuleEditorNestingModeCompound && ([[CPApp currentEvent] modifierFlags] & CPAlternateKeyMask))
type = CPRuleEditorRowTypeCompound;
@@ -170,12 +176,12 @@ var CONTROL_HEIGHT = 16.,
[_ruleEditor _deleteSlice:self];
}
- (void)_ruleOptionPopupChangedAction:(CPMenuItem )sender
- (void)_ruleOptionPopupChangedAction:(CPMenuItem)sender
{
var layoutdict = [sender representedObject],
newItem = [layoutdict objectForKey:@"item"],
var layoutdict = [sender representedObject],
newItem = [layoutdict objectForKey:@"item"],
indexInCriteria = [layoutdict objectForKey:@"indexInCriteria"],
oldItem = [_correspondingRuleItems objectAtIndex:indexInCriteria];
oldItem = [_correspondingRuleItems objectAtIndex:indexInCriteria];
if (![newItem isEqual:oldItem])
{
@@ -203,8 +209,7 @@ var CONTROL_HEIGHT = 16.,
- (void)_reconfigureSubviews
{
var ruleItems,
criteria,
var criteria,
repObject,
menuItem,
ruleView,
@@ -307,8 +312,16 @@ var CONTROL_HEIGHT = 16.,
if (ruleView != nil)
{
[ruleView setControlSize:CPSmallControlSize];
var minSize = [ruleView currentValueForThemeAttribute:@"min-size"],
frame = [ruleView frame];
// Force controls to their minimum size
frame.size.height = minSize.height;
[ruleView setFrame:frame];
[_ruleOptionViews addObject:ruleView];
var frame = [ruleView frame];
[_ruleOptionInitialViewFrames addObject:frame];
[_ruleOptionFrames addObject:frame];
@@ -331,8 +344,6 @@ var CONTROL_HEIGHT = 16.,
var aView = [_ruleOptionViews objectAtIndex:firstResponderIndex];
[[self window] makeFirstResponder:aView]; // This is not working. bug in CPPopUpButton firstResponder ?
}
//[self setNeedsDisplay:YES];
}
- (void)_updateEnabledStateForSubviews
@@ -350,14 +361,16 @@ var CONTROL_HEIGHT = 16.,
var optionViewOriginX,
leftHorizontalPadding,
leftButtonMinX,
rowHeight = [_ruleEditor rowHeight],
count = [_ruleOptionViews count],
sliceFrame = [self frame],
rowHeight = [_ruleEditor rowHeight],
count = [_ruleOptionViews count],
sliceFrame = [self frame],
image = [_ruleEditor _imageAdd],
imageSize = image ? [image size] : CGSizeMake(0,0),
buttonFrame = CGRectMake(CGRectGetWidth(sliceFrame) - BUTTON_HEIGHT - [self _rowButtonsRightHorizontalPadding], ([_ruleEditor rowHeight] - BUTTON_HEIGHT) / 2 - 2, BUTTON_HEIGHT, BUTTON_HEIGHT);
buttonFrame = CGRectMake(CGRectGetWidth(sliceFrame) - imageSize.width - [self _rowButtonsRightHorizontalPadding], ([_ruleEditor rowHeight] - imageSize.height) / 2 - 1, imageSize.width, imageSize.height);
[_addButton setFrame:buttonFrame];
buttonFrame.origin.x -= BUTTON_HEIGHT + [self _rowButtonsInterviewHorizontalPadding];
buttonFrame.origin.x -= imageSize.width + [self _rowButtonsInterviewHorizontalPadding];
[_subtractButton setFrame:buttonFrame];
if (widthChanged)
@@ -372,7 +385,8 @@ var CONTROL_HEIGHT = 16.,
var ruleOptionView = _ruleOptionViews[i],
optionFrame = _ruleOptionFrames[i];
optionFrame.origin.y = (rowHeight - CGRectGetHeight(optionFrame)) / 2 - 2;
// Use a pixel correction to align controls
optionFrame.origin.y = (rowHeight - CGRectGetHeight(optionFrame)) / 2;
if (widthChanged)
{
@@ -481,6 +495,26 @@ var CONTROL_HEIGHT = 16.,
[self layoutSubviews];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_textDidChange:) name:CPControlTextDidChangeNotification object:nil];
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPControlTextDidChangeNotification object:nil];
}
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
@@ -488,8 +522,9 @@ var CONTROL_HEIGHT = 16.,
- (BOOL)_isRulePopup:(CPView)view
{
if ([view isKindOfClass:[_CPRuleEditorPopUpButton class]])
if ([view isKindOfClass:[CPPopUpButton class]])
return YES;
return NO;
}
@@ -506,28 +541,3 @@ var CONTROL_HEIGHT = 16.,
}
@end
@implementation _CPRuleEditorTextField : CPTextField
{
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
[self setDrawsBackground:NO];
}
return self;
}
- (id)hitTest:(CGPoint)point
{
if (!CGRectContainsPoint([self frame], point))
return nil;
return [self superview];
}
@end
+5
View File
@@ -35,6 +35,11 @@
CPArray _allowedFileTypes @accessors(property=allowedFileTypes);
}
+ (CPURL)proposedFileURLWithDocumentName:(CPString)aDocumentName
{
return [CPURL URLWithString:aDocumentName];
}
+ (id)savePanel
{
return [[CPSavePanel alloc] init];
+215 -78
View File
@@ -30,52 +30,64 @@
@import "CPScroller.j"
@import "CPView.j"
@class CPTableView
#define SHOULD_SHOW_CORNER_VIEW() (_scrollerStyle === CPScrollerStyleLegacy && _verticalScroller && ![_verticalScroller isHidden])
@protocol CPScrollViewDelegate <CPObject>
@optional
- (void)scrollViewWillScroll:(CPScrollView)aScrollView;
- (void)scrollViewDidScroll:(CPScrollView)aScrollView;
@end
/*! @ignore */
var _isSystemUsingOverlayScrollers = function()
var _isBrowserUsingOverlayScrollers = function()
{
#if PLATFORM(DOM)
var inner = document.createElement('p'),
outer = document.createElement('div');
/*
Even if the system supports overlay (Lion) scrollers,
the browser (e.g. FireFox *cough*) may not.
inner.style.width = "100%";
inner.style.height = "200px";
To determine if the browser is using overlay scrollbars,
we put a <p> element inside a shorter <div> and set its
overflow to scroll. If the browser is using visible scrollers,
the outer div's clientWidth will less than the offsetWidth, because
clientWidth does not include scrollbars, whereas offsetWidth does.
So if clientWidth === offsetWidth, the scrollers must be overlay.
Even IE gets this right.
*/
var outer = document.createElement('div'),
inner = document.createElement('p');
// position it absolute so it doesn't affect existing DOM elements
outer.style.position = "absolute";
outer.style.top = "0px";
outer.style.left = "0px";
outer.style.visibility = "hidden";
outer.style.width = "200px";
outer.style.height = "150px";
outer.style.overflow = "hidden";
outer.appendChild (inner);
outer.style.overflow = "scroll";
document.body.appendChild (outer);
var w1 = inner.offsetWidth;
outer.style.overflow = 'scroll';
var w2 = inner.offsetWidth;
if (w1 == w2)
w2 = outer.clientWidth;
inner.style.width = "100%";
inner.style.height = "200px";
outer.appendChild(inner);
document.body.removeChild (outer);
document.body.appendChild(outer);
return (w1 - w2 == 0);
var usingOverlayScrollers = outer.clientWidth === outer.offsetWidth;
document.body.removeChild(outer);
return usingOverlayScrollers;
#else
return NO;
#endif
};
/*!
@ingroup appkit
@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.
*/
var TIMER_INTERVAL = 0.2,
CPScrollViewDelegate_scrollViewWillScroll_ = 1 << 0,
CPScrollViewDelegate_scrollViewDidScroll_ = 1 << 1,
@@ -85,38 +97,45 @@ var TIMER_INTERVAL = 0.2,
var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
CPScrollerStyleGlobalChangeNotification = @"CPScrollerStyleGlobalChangeNotification";
/*!
@ingroup appkit
@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.
*/
@implementation CPScrollView : CPView
{
CPClipView _contentView;
CPClipView _headerClipView;
CPView _cornerView;
CPView _bottomCornerView;
CPClipView _contentView;
CPClipView _headerClipView;
CPView _cornerView;
CPView _bottomCornerView;
id _delegate;
CPTimer _scrollTimer;
id <CPScrollViewDelegate> _delegate;
CPTimer _scrollTimer;
BOOL _hasVerticalScroller;
BOOL _hasHorizontalScroller;
BOOL _autohidesScrollers;
BOOL _hasVerticalScroller;
BOOL _hasHorizontalScroller;
BOOL _autohidesScrollers;
CPScroller _verticalScroller;
CPScroller _horizontalScroller;
CPScroller _verticalScroller;
CPScroller _horizontalScroller;
CPInteger _recursionCount;
CPInteger _implementedDelegateMethods;
CPInteger _recursionCount;
CPInteger _implementedDelegateMethods;
float _verticalLineScroll;
float _verticalPageScroll;
float _horizontalLineScroll;
float _horizontalPageScroll;
float _verticalLineScroll;
float _verticalPageScroll;
float _horizontalLineScroll;
float _horizontalPageScroll;
CPBorderType _borderType;
CPBorderType _borderType;
CPTimer _timerScrollersHide;
CPTimer _timerScrollersHide;
int _scrollerStyle;
int _scrollerKnobStyle;
int _scrollerStyle;
int _scrollerKnobStyle;
}
@@ -130,8 +149,8 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
var globalValue = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPScrollersGlobalStyle"];
if (globalValue == nil || globalValue == -1)
CPScrollerStyleGlobal = _isSystemUsingOverlayScrollers() ? CPScrollerStyleOverlay : CPScrollerStyleLegacy
if (globalValue == nil || globalValue === -1)
CPScrollerStyleGlobal = _isBrowserUsingOverlayScrollers() ? CPScrollerStyleOverlay : CPScrollerStyleLegacy
else
CPScrollerStyleGlobal = globalValue;
}
@@ -149,33 +168,65 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
};
}
/*! Deprecated
*/
+ (CGSize)contentSizeForFrameSize:(CGSize)frameSize hasHorizontalScroller:(BOOL)hFlag hasVerticalScroller:(BOOL)vFlag borderType:(CPBorderType)borderType
{
var bounds = [self _insetBounds:CGRectMake(0.0, 0.0, frameSize.width, frameSize.height) borderType:borderType],
scrollerWidth = [CPScroller scrollerWidth];
return [self contentSizeForFrameSize:frameSize
horizontalScrollerClass:hFlag ? [CPScroller class] : nil
verticalScrollerClass:vFlag ? [CPScroller class] : nil
borderType:borderType
controlSize:CPRegularControlSize
scrollerStyle:CPScrollerStyleGlobal];
}
if (hFlag)
bounds.size.height -= scrollerWidth;
+ (CGSize)contentSizeForFrameSize:(CGSize)frameSize
horizontalScrollerClass:(Class)horizontalScrollerClass
verticalScrollerClass:(Class)verticalScrollerClass
borderType:(CPBorderType)borderType
controlSize:(CPControlSize)controlSize
scrollerStyle:(CPScrollerStyle)scrollerStyle
{
var bounds = [self _insetBounds:CGRectMake(0.0, 0.0, frameSize.width, frameSize.height) borderType:borderType];
if (vFlag)
bounds.size.width -= scrollerWidth;
if (horizontalScrollerClass)
bounds.size.height -= [horizontalScrollerClass scrollerWidthInStyle:scrollerStyle];
if (verticalScrollerClass)
bounds.size.width -= [verticalScrollerClass scrollerWidthForControlSize:scrollerStyle];
return bounds.size;
}
/*! Deprecated
*/
+ (CGSize)frameSizeForContentSize:(CGSize)contentSize hasHorizontalScroller:(BOOL)hFlag hasVerticalScroller:(BOOL)vFlag borderType:(CPBorderType)borderType
{
return [self frameSizeForContentSize:contentSize
horizontalScrollerClass:hFlag ? [CPScroller class] : nil
verticalScrollerClass:vFlag ? [CPScroller class] : nil
borderType:borderType
controlSize:CPRegularControlSize
scrollerStyle:CPScrollerStyleGlobal];
}
+ (CGSize)frameSizeForContentSize:(CGSize)contentSize
horizontalScrollerClass:(Class)horizontalScrollerClass
verticalScrollerClass:(Class)verticalScrollerClass
borderType:(CPBorderType)borderType
controlSize:(CPControlSize)controlSize
scrollerStyle:(CPScrollerStyle)scrollerStyle
{
var bounds = [self _insetBounds:CGRectMake(0.0, 0.0, contentSize.width, contentSize.height) borderType:borderType],
widthInset = contentSize.width - bounds.size.width,
heightInset = contentSize.height - bounds.size.height,
frameSize = CGSizeMake(contentSize.width + widthInset, contentSize.height + heightInset),
scrollerWidth = [CPScroller scrollerWidth];
frameSize = CGSizeMake(contentSize.width + widthInset, contentSize.height + heightInset);
if (hFlag)
frameSize.height += scrollerWidth;
frameSize.height += [horizontalScrollerClass scrollerWidthInStyle:scrollerStyle];
if (vFlag)
frameSize.width += scrollerWidth;
frameSize.width += [verticalScrollerClass scrollerWidthForControlSize:scrollerStyle];
return frameSize;
}
@@ -203,7 +254,7 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
/*!
Get the system wide scroller style.
*/
+ (int)globalScrollerStyle
+ (CPScrollerStyle)globalScrollerStyle
{
return CPScrollerStyleGlobal;
}
@@ -213,7 +264,7 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
@param aStyle the scroller style to set all scroller views to use (CPScrollerStyleLegacy or CPScrollerStyleOverlay)
*/
+ (void)setGlobalScrollerStyle:(int)aStyle
+ (void)setGlobalScrollerStyle:(CPScrollerStyle)aStyle
{
CPScrollerStyleGlobal = aStyle;
[[CPNotificationCenter defaultCenter] postNotificationName:CPScrollerStyleGlobalChangeNotification object:nil];
@@ -254,11 +305,6 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
_delegate = nil;
_scrollTimer = nil;
_implementedDelegateMethods = 0;
[[CPNotificationCenter defaultCenter] addObserver:self
selector:@selector(_didReceiveDefaultStyleChange:)
name:CPScrollerStyleGlobalChangeNotification
object:nil];
}
return self;
@@ -291,7 +337,7 @@ Notifies the delegate when the scroll view has finished scrolling.
@endcode
*/
- (void)setDelegate:(id)aDelegate
- (void)setDelegate:(id <CPScrollViewDelegate>)aDelegate
{
if (aDelegate === _delegate)
return;
@@ -299,7 +345,7 @@ Notifies the delegate when the scroll view has finished scrolling.
_delegate = aDelegate;
_implementedDelegateMethods = 0;
if (_delegate === nil)
if (_delegate == nil)
return;
if ([_delegate respondsToSelector:@selector(scrollViewWillScroll:)])
@@ -309,7 +355,7 @@ Notifies the delegate when the scroll view has finished scrolling.
_implementedDelegateMethods |= CPScrollViewDelegate_scrollViewDidScroll_;
}
- (int)scrollerStyle
- (CPScrollerStyle)scrollerStyle
{
return _scrollerStyle;
}
@@ -320,7 +366,7 @@ Notifies the delegate when the scroll view has finished scrolling.
- CPScrollerStyleLegacy: Standard scrollers like Windows or Mac OS X prior to 10.7
- CPScrollerStyleOverlay: scrollers like those in Mac OS X 10.7+
*/
- (void)setScrollerStyle:(int)aStyle
- (void)setScrollerStyle:(CPScrollerStyle)aStyle
{
if (_scrollerStyle === aStyle)
return;
@@ -517,8 +563,8 @@ Notifies the delegate when the scroll view has finished scrolling.
{
var bounds = [self _insetBounds];
[self setHorizontalScroller:[[CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, MAX(CGRectGetWidth(bounds), [CPScroller scrollerWidthInStyle:_scrollerStyle] + 1), [CPScroller scrollerWidthInStyle:_scrollerStyle])]];
[[self horizontalScroller] setFrameSize:CGSizeMake(CGRectGetWidth(bounds), [CPScroller scrollerWidthInStyle:_scrollerStyle])];
[self setHorizontalScroller:[[CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, MAX(CGRectGetWidth(bounds), [_horizontalScroller scrollerWidth] + 1), [_horizontalScroller scrollerWidth])]];
[[self horizontalScroller] setFrameSize:CGSizeMake(CGRectGetWidth(bounds), [_horizontalScroller scrollerWidth])];
}
[self reflectScrolledClipView:_contentView];
@@ -582,8 +628,8 @@ Notifies the delegate when the scroll view has finished scrolling.
{
var bounds = [self _insetBounds];
[self setVerticalScroller:[[CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, [CPScroller scrollerWidthInStyle:_scrollerStyle], MAX(CGRectGetHeight(bounds), [CPScroller scrollerWidthInStyle:_scrollerStyle] + 1))]];
[[self verticalScroller] setFrameSize:CGSizeMake([CPScroller scrollerWidthInStyle:_scrollerStyle], CGRectGetHeight(bounds))];
[self setVerticalScroller:[[CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, [_verticalScroller scrollerWidth], MAX(CGRectGetHeight(bounds), [_verticalScroller scrollerWidth] + 1))]];
[[self verticalScroller] setFrameSize:CGSizeMake([_verticalScroller scrollerWidth], CGRectGetHeight(bounds))];
}
[self reflectScrolledClipView:_contentView];
@@ -899,8 +945,8 @@ Notifies the delegate when the scroll view has finished scrolling.
bottomCornerFrame.origin.x = CGRectGetMinX(verticalFrame);
bottomCornerFrame.origin.y = CGRectGetMaxY(verticalFrame);
bottomCornerFrame.size.width = [CPScroller scrollerWidthInStyle:_scrollerStyle];
bottomCornerFrame.size.height = [CPScroller scrollerWidthInStyle:_scrollerStyle];
bottomCornerFrame.size.width = [_verticalScroller scrollerWidth];
bottomCornerFrame.size.height = [_horizontalScroller scrollerWidth];
return bottomCornerFrame;
}
@@ -1112,8 +1158,8 @@ Notifies the delegate when the scroll view has finished scrolling.
contentFrame.size.height -= headerClipViewHeight;
var difference = CGSizeMake(CGRectGetWidth(documentFrame) - CGRectGetWidth(contentFrame), CGRectGetHeight(documentFrame) - CGRectGetHeight(contentFrame)),
verticalScrollerWidth = [CPScroller scrollerWidthInStyle:[_verticalScroller style]],
horizontalScrollerHeight = [CPScroller scrollerWidthInStyle:[_horizontalScroller style]],
verticalScrollerWidth = [_verticalScroller scrollerWidth],
horizontalScrollerHeight = [_horizontalScroller scrollerWidth],
hasVerticalScroll = difference.height > 0.0,
hasHorizontalScroll = difference.width > 0.0,
shouldShowVerticalScroller = _hasVerticalScroller && (!_autohidesScrollers || hasVerticalScroll),
@@ -1241,7 +1287,7 @@ Notifies the delegate when the scroll view has finished scrolling.
}
if (_timerScrollersHide)
[_timerScrollersHide invalidate]
[_timerScrollersHide invalidate];
_timerScrollersHide = [CPTimer scheduledTimerWithTimeInterval:CPScrollViewFadeOutTime target:self selector:@selector(_hideScrollers:) userInfo:nil repeats:NO];
}
@@ -1252,10 +1298,45 @@ Notifies the delegate when the scroll view has finished scrolling.
[self reflectScrolledClipView:_contentView];
}
- (CGRect)documentVisibleRect
{
return [_contentView documentVisibleRect];
}
#pragma mark -
#pragma mark Overrides
- (void)_removeObservers
{
if (!_isObserving)
return;
[[CPNotificationCenter defaultCenter] removeObserver:self
name:CPScrollerStyleGlobalChangeNotification
object:nil];
[super _removeObservers];
}
- (void)_addObservers
{
if (_isObserving)
return;
//Make sure to have the last global style for the scroller
[self _didReceiveDefaultStyleChange:nil];
[[CPNotificationCenter defaultCenter] addObserver:self
selector:@selector(_didReceiveDefaultStyleChange:)
name:CPScrollerStyleGlobalChangeNotification
object:nil];
[super _addObservers];
}
- (void)drawRect:(CGRect)aRect
{
[super drawRect:aRect];
@@ -1389,7 +1470,16 @@ Notifies the delegate when the scroll view has finished scrolling.
if (![_horizontalScroller isHidden] || ![_verticalScroller isHidden])
_timerScrollersHide = [CPTimer scheduledTimerWithTimeInterval:CPScrollViewFadeOutTime target:self selector:@selector(_hideScrollers:) userInfo:nil repeats:NO];
[self _respondToScrollWheelEventWithDeltaX:[anEvent deltaX] deltaY:[anEvent deltaY]];
var deltaX = [anEvent scrollingDeltaX],
deltaY = [anEvent scrollingDeltaY];
if (![anEvent hasPreciseScrollingDeltas])
{
deltaX *= (_horizontalLineScroll || 1.0);
deltaY *= (_verticalLineScroll || 1.0);
}
[self _respondToScrollWheelEventWithDeltaX:deltaX deltaY:deltaY];
}
- (void)scrollPageUp:(id)sender
@@ -1454,6 +1544,51 @@ Notifies the delegate when the scroll view has finished scrolling.
@end
#pragma mark -
@implementation CPScrollView (FirstResponder)
// Those 4 next methods are needed to (un)set CPThemeStateFirstResponder based on content view
- (void)viewWillMoveToWindow:(CPWindow)aWindow
{
[super viewWillMoveToWindow:aWindow];
[self _stopObservingFirstResponderForWindow:[self window]];
if (aWindow)
[self _startObservingFirstResponderForWindow:aWindow];
}
- (void)_startObservingFirstResponderForWindow:(CPWindow)aWindow
{
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_firstResponderDidChange:) name:_CPWindowDidChangeFirstResponderNotification object:aWindow];
}
- (void)_stopObservingFirstResponderForWindow:(CPWindow)aWindow
{
[[CPNotificationCenter defaultCenter] removeObserver:self name:_CPWindowDidChangeFirstResponderNotification object:aWindow];
}
- (void)_firstResponderDidChange:(CPNotification)aNotification
{
var responder = [[self window] firstResponder],
// FIXME: We add focus ring only on table views right now. When focus ring management will be added, this must be adapted.
shouldAddFocusRing = [responder isKindOfClass:[CPTableView class]],
found;
while (!(found = (responder === self)) && responder)
responder = [responder superview];
if (found && shouldAddFocusRing)
[self setThemeState:CPThemeStateFirstResponder];
else
[self unsetThemeState:CPThemeStateFirstResponder];
}
@end
#pragma mark -
var CPScrollViewContentViewKey = @"CPScrollViewContentView",
CPScrollViewHeaderClipViewKey = @"CPScrollViewHeaderClipViewKey",
@@ -1526,6 +1661,8 @@ var CPScrollViewContentViewKey = @"CPScrollViewContentView",
*/
- (void)awakeFromCib
{
[super awakeFromCib];
[self _updateScrollerStyle];
[self _updateCornerAndHeaderView];
}
+36 -53
View File
@@ -33,6 +33,7 @@
@global CPApp
// CPScroller Constants
@typedef CPScrollerPart
CPScrollerNoPart = 0;
CPScrollerDecrementPage = 1;
CPScrollerKnob = 2;
@@ -44,15 +45,11 @@ CPScrollerKnobSlot = 6;
CPScrollerIncrementArrow = 0;
CPScrollerDecrementArrow = 1;
@typedef CPUsableScrollerParts
CPNoScrollerParts = 0;
CPOnlyScrollerArrows = 1;
CPAllScrollerParts = 2;
/*!
@ingroup appkit
@class CPScroller
*/
var PARTS_ARRANGEMENT = [CPScrollerKnobSlot, CPScrollerDecrementLine, CPScrollerIncrementLine, CPScrollerKnob],
NAMES_FOR_PARTS = {},
PARTS_FOR_NAMES = {};
@@ -65,6 +62,7 @@ NAMES_FOR_PARTS[CPScrollerKnobSlot] = @"knob-slot";
NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
@typedef CPScrollerStyle
CPScrollerStyleLegacy = 0;
CPScrollerStyleOverlay = 1;
@@ -76,9 +74,13 @@ CPThemeStateScrollViewLegacy = CPThemeState("scroller-style-legacy");
CPThemeStateScrollerKnobLight = CPThemeState("scroller-knob-light");
CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
/*!
@ingroup appkit
@class CPScroller
*/
@implementation CPScroller : CPControl
{
CPControlSize _controlSize;
CPUsableScrollerParts _usableParts;
CPArray _partRects;
@@ -108,7 +110,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
return "scroller";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"scroller-width": 7.0,
@@ -133,7 +135,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
/*!
Returns the CPScroller's width for a CPRegularControlSize.
*/
+ (float)scrollerWidthInStyle:(int)aStyle
+ (float)scrollerWidthInStyle:(CPScrollerStyle)aStyle
{
if (!_CACHED_THEME_SCROLLER)
_CACHED_THEME_SCROLLER = [[self alloc] init];
@@ -172,7 +174,6 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
{
if (self = [super initWithFrame:aFrame])
{
_controlSize = CPRegularControlSize;
_partRects = [];
[self setFloatValue:0.0];
@@ -182,6 +183,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
_allowFadingOut = YES;
_isMouseOver = NO;
_style = CPScrollerStyleOverlay;
var paramAnimFadeOut = @{
CPViewAnimationTargetKey: self,
CPViewAnimationEffectKey: CPViewAnimationFadeOutEffect,
@@ -207,7 +209,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
/*!
Returns the scroller's style
*/
- (void)style
- (int)style
{
return _style;
}
@@ -216,7 +218,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
Set the scroller's control size
@param aStyle the scroller style: CPScrollerStyleLegacy or CPScrollerStyleOverlay
*/
- (void)setStyle:(id)aStyle
- (void)setStyle:(CPScrollerStyle)aStyle
{
if (_style != nil && _style === aStyle)
return;
@@ -225,6 +227,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
if (_style === CPScrollerStyleLegacy)
{
_allowFadingOut = NO;
[self fadeIn];
[self setThemeState:CPThemeStateScrollViewLegacy];
}
@@ -242,29 +245,6 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
[super setObjectValue:MIN(1.0, MAX(0.0, +aValue))];
}
/*!
Returns the scroller's control size
*/
- (CPControlSize)controlSize
{
return _controlSize;
}
/*!
Sets the scroller's size.
@param aControlSize the scroller's size
*/
- (void)setControlSize:(CPControlSize)aControlSize
{
if (_controlSize == aControlSize)
return;
_controlSize = aControlSize;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
/*!
Return's the knob's proportion
*/
@@ -280,7 +260,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
- (void)setKnobProportion:(float)aProportion
{
if (!_IS_NUMERIC(aProportion))
[CPException raise:CPInvalidArgumentException reason:"aProportion must be numeric"];
[CPException raise:CPInvalidArgumentException reason:"aProportion must be numeric, was: "+aProportion];
_knobProportion = MIN(1.0, MAX(0.0001, aProportion));
@@ -338,7 +318,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
// The ordering of these tests is important. We check the knob and
// page rects first since they may overlap with the arrows.
if (![self hasThemeState:CPThemeStateSelected])
if (![self hasThemeState:CPThemeStateSelected] && ![self hasThemeState:CPThemeStateScrollViewLegacy])
return CPScrollerNoPart;
if (CGRectContainsPoint([self rectForPart:CPScrollerKnob], aPoint))
@@ -402,9 +382,10 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
effectiveIncrementLineHeight = incrementLineSize.height + trackInset.bottom,
slotSize = height - effectiveDecrementLineHeight - effectiveIncrementLineHeight,
minimumKnobLength = [self currentValueForThemeAttribute:"minimum-knob-length"],
knobVerticalInset = knobInset.top + knobInset.bottom,
knobWidth = width - knobInset.left - knobInset.right,
knobHeight = MAX(minimumKnobLength, (slotSize * _knobProportion)),
knobLocation = effectiveDecrementLineHeight + (slotSize - knobHeight) * [self floatValue];
knobHeight = MAX(minimumKnobLength, ((slotSize - knobVerticalInset) * _knobProportion)),
knobLocation = effectiveDecrementLineHeight + (slotSize - knobHeight - knobVerticalInset) * [self floatValue] + knobInset.top;
_partRects[CPScrollerDecrementPage] = CGRectMake(0.0, effectiveDecrementLineHeight, width, knobLocation - effectiveDecrementLineHeight);
_partRects[CPScrollerKnob] = CGRectMake(knobInset.left, knobLocation, knobWidth, knobHeight);
@@ -431,9 +412,10 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
effectiveIncrementLineWidth = incrementLineSize.width + trackInset.right,
slotSize = width - effectiveDecrementLineWidth - effectiveIncrementLineWidth,
minimumKnobLength = [self currentValueForThemeAttribute:"minimum-knob-length"],
knobWidth = MAX(minimumKnobLength, (slotSize * _knobProportion)),
knobHorizontalInset = knobInset.left + knobInset.right,
knobWidth = MAX(minimumKnobLength, ((slotSize - knobHorizontalInset) * _knobProportion)),
knobHeight = height - knobInset.top - knobInset.bottom,
knobLocation = effectiveDecrementLineWidth + (slotSize - knobWidth) * [self floatValue];
knobLocation = effectiveDecrementLineWidth + (slotSize - knobWidth - knobHorizontalInset) * [self floatValue] + knobInset.left;
_partRects[CPScrollerDecrementPage] = CGRectMake(effectiveDecrementLineWidth, 0.0, knobLocation - effectiveDecrementLineWidth, height);
_partRects[CPScrollerKnob] = CGRectMake(knobLocation, knobInset.top, knobWidth, knobHeight);
@@ -482,9 +464,6 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
*/
- (void)fadeOut
{
if ([self hasThemeState:CPThemeStateScrollViewLegacy])
return;
[_animationScroller startAnimation];
}
@@ -732,7 +711,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
var themeState = _themeState;
if (NAMES_FOR_PARTS[_hitPart] + "-color" !== anAttributeName)
themeState &= ~CPThemeStateHighlighted;
themeState = themeState.without(CPThemeStateHighlighted);
return [self valueForThemeAttribute:anAttributeName inState:themeState];
}
@@ -781,15 +760,25 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
if ([self isHidden] || ![self isEnabled] || !_isMouseOver)
return;
_allowFadingOut = YES;
_allowFadingOut = (_style !== CPScrollerStyleLegacy);
_isMouseOver = NO;
if (_timerFadeOut)
[_timerFadeOut invalidate];
_timerFadeOut = [CPTimer scheduledTimerWithTimeInterval:1.2 target:self selector:@selector(_performFadeOut:) userInfo:nil repeats:NO];
if ([self hasThemeState:CPThemeStateScrollViewLegacy])
[self unsetThemeState:CPThemeStateSelected];
else
_timerFadeOut = [CPTimer scheduledTimerWithTimeInterval:1.2 target:self selector:@selector(_performFadeOut:) userInfo:nil repeats:NO];
}
- (float)scrollerWidth
{
if (_style == CPScrollerStyleLegacy)
return [self valueForThemeAttribute:@"scroller-width" inState:CPThemeStateScrollViewLegacy];
return [self currentValueForThemeAttribute:@"scroller-width"];
}
#pragma mark -
#pragma mark Delegates
@@ -801,8 +790,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
@end
var CPScrollerControlSizeKey = @"CPScrollerControlSize",
CPScrollerIsVerticalKey = @"CPScrollerIsVerticalKey",
var CPScrollerIsVerticalKey = @"CPScrollerIsVerticalKey",
CPScrollerKnobProportionKey = @"CPScrollerKnobProportion",
CPScrollerStyleKey = @"CPScrollerStyleKey";
@@ -812,10 +800,6 @@ var CPScrollerControlSizeKey = @"CPScrollerControlSize",
{
if (self = [super initWithCoder:aCoder])
{
_controlSize = CPRegularControlSize;
if ([aCoder containsValueForKey:CPScrollerControlSizeKey])
_controlSize = [aCoder decodeIntForKey:CPScrollerControlSizeKey];
_knobProportion = 1.0;
if ([aCoder containsValueForKey:CPScrollerKnobProportionKey])
@@ -850,7 +834,6 @@ var CPScrollerControlSizeKey = @"CPScrollerControlSize",
{
[super encodeWithCoder:aCoder];
[aCoder encodeInt:_controlSize forKey:CPScrollerControlSizeKey];
[aCoder encodeInt:_isVertical forKey:CPScrollerIsVerticalKey];
[aCoder encodeFloat:_knobProportion forKey:CPScrollerKnobProportionKey];
[aCoder encodeInt:_style forKey:CPScrollerStyleKey];
+393 -69
View File
@@ -24,8 +24,12 @@
@import "CPMenu.j"
@import "CPMenuItem.j"
@import "CPTextField.j"
@import "CPAnimationContext.j"
@import "CPViewAnimator.j"
@import "CPArrayController.j"
@class CPUserDefaults
@class CALayer
@global CPApp
@@ -36,8 +40,6 @@ CPSearchFieldNoRecentsMenuItemTag = 1003;
var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotification";
var RECENT_SEARCH_PREFIX = @" ";
/*!
@ingroup appkit
@class CPSearchField
@@ -60,6 +62,9 @@ var RECENT_SEARCH_PREFIX = @" ";
BOOL _sendsSearchStringImmediately;
BOOL _canResignFirstResponder;
CPTimer _partialStringTimer;
CPView _contentView;
BOOL _isBecomingFirstResponder;
}
+ (CPString)defaultThemeClass
@@ -73,10 +78,24 @@ var RECENT_SEARCH_PREFIX = @" ";
@"image-search": [CPNull null],
@"image-find": [CPNull null],
@"image-cancel": [CPNull null],
@"image-cancel-pressed": [CPNull null]
@"image-cancel-pressed": [CPNull null],
@"image-search-inset" : CGInsetMake(0, 0, 0, 5),
@"image-cancel-inset" : CGInsetMake(0, 5, 0, 0),
@"search-button-rect-function": [CPNull null],
@"layout-function": [CPNull null],
@"search-right-margin": 2,
@"search-menu-offset": CGPointMake(10, -4)
};
}
+ (Class)_binderClassForBinding:(CPString)aBinding
{
if (aBinding === CPPredicateBinding)
return [_CPSearchFieldPredicateBinder class];
return [super _binderClassForBinding:aBinding];
}
- (id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame])
@@ -87,10 +106,6 @@ var RECENT_SEARCH_PREFIX = @" ";
_recentsAutosaveName = nil;
[self _init];
#if PLATFORM(DOM)
_cancelButton._DOMElement.style.cursor = "default";
_searchButton._DOMElement.style.cursor = "default";
#endif
}
return self;
@@ -117,18 +132,31 @@ var RECENT_SEARCH_PREFIX = @" ";
[self resetSearchButton];
_canResignFirstResponder = YES;
_isBecomingFirstResponder = NO;
}
- (void)viewWillMoveToSuperview:(CPView)aView
#pragma mark -
#pragma mark Override observers
- (void)_removeObservers
{
[super viewWillMoveToSuperview:aView];
if (!_isObserving)
return;
[super _removeObservers];
// First we remove any observer that may have been in place to avoid memory leakage.
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPControlTextDidChangeNotification object:self];
}
// Register the observe here if we need to.
if (aView)
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_searchFieldTextDidChange:) name:CPControlTextDidChangeNotification object:self];
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_searchFieldTextDidChange:) name:CPControlTextDidChangeNotification object:self];
}
// Managing Buttons
@@ -165,7 +193,7 @@ var RECENT_SEARCH_PREFIX = @" ";
- (void)resetSearchButton
{
var button = [self searchButton],
searchButtonImage = (_searchMenuTemplate === nil) ? [self valueForThemeAttribute:@"image-search"] : [self valueForThemeAttribute:@"image-find"];
searchButtonImage = (_searchMenuTemplate == nil) ? [self currentValueForThemeAttribute:@"image-search"] : [self currentValueForThemeAttribute:@"image-find"];
[button setBordered:NO];
[button setImageScaling:CPImageScaleAxesIndependently];
@@ -212,8 +240,8 @@ var RECENT_SEARCH_PREFIX = @" ";
var button = [self cancelButton];
[button setBordered:NO];
[button setImageScaling:CPImageScaleAxesIndependently];
[button setImage:[self valueForThemeAttribute:@"image-cancel"]];
[button setAlternateImage:[self valueForThemeAttribute:@"image-cancel-pressed"]];
[button setImage:[self currentValueForThemeAttribute:@"image-cancel"]];
[button setAlternateImage:[self currentValueForThemeAttribute:@"image-cancel-pressed"]];
[button setAutoresizingMask:CPViewMinXMargin];
[button setTarget:self];
[button setAction:@selector(cancelOperation:)];
@@ -234,8 +262,9 @@ var RECENT_SEARCH_PREFIX = @" ";
if (_searchButton)
{
var searchBounds = [self searchButtonRectForBounds:bounds];
leftOffset = CGRectGetMaxX(searchBounds) + 2;
var searchBounds = [self searchButtonRectForBounds:bounds],
rightMargin = [self _potentialCurrentValueForThemeAttribute:@"search-right-margin"];
leftOffset = CGRectGetMaxX(searchBounds) + rightMargin;
}
if (_cancelButton)
@@ -254,9 +283,18 @@ var RECENT_SEARCH_PREFIX = @" ";
*/
- (CGRect)searchButtonRectForBounds:(CGRect)rect
{
var size = [[self valueForThemeAttribute:@"image-search"] size] || CGSizeMakeZero();
var themedRectFunction = [self _potentialCurrentValueForThemeAttribute:@"search-button-rect-function"];
return CGRectMake(5, (CGRectGetHeight(rect) - size.height) / 2, size.width, size.height);
if (themedRectFunction)
// There's a theme defined positioning function, just use it
return objj_eval("("+themedRectFunction+")")(self, rect);
else
{
var size = [[self _potentialCurrentValueForThemeAttribute:@"image-search"] size] || CGSizeMakeZero(),
inset = [self _potentialCurrentValueForThemeAttribute:@"image-search-inset"];
return CGRectMake(inset.left - inset.right, inset.top - inset.bottom + (CGRectGetHeight(rect) - size.height) / 2, size.width, size.height);
}
}
/*!
@@ -266,9 +304,10 @@ var RECENT_SEARCH_PREFIX = @" ";
*/
- (CGRect)cancelButtonRectForBounds:(CGRect)rect
{
var size = [[self valueForThemeAttribute:@"image-cancel"] size] || CGSizeMakeZero();
var size = [[self _potentialCurrentValueForThemeAttribute:@"image-cancel"] size] || CGSizeMakeZero(),
inset = [self _potentialCurrentValueForThemeAttribute:@"image-cancel-inset"];
return CGRectMake(CGRectGetWidth(rect) - size.width - 5, (CGRectGetHeight(rect) - size.width) / 2, size.height, size.height);
return CGRectMake(CGRectGetWidth(rect) - size.width + inset.left - inset.right, inset.top - inset.bottom + (CGRectGetHeight(rect) - size.width) / 2, size.height, size.height);
}
// Managing Menu Templates
@@ -372,10 +411,9 @@ var RECENT_SEARCH_PREFIX = @" ";
*/
- (void)setRecentSearches:(CPArray)searches
{
var max = MIN([self maximumRecents], [searches count]),
searches = [searches subarrayWithRange:CPMakeRange(0, max)];
var max = MIN([self maximumRecents], [searches count]);
_recentSearches = searches;
_recentSearches = [searches subarrayWithRange:CPMakeRange(0, max)];
[self _autosaveRecentSearchList];
}
@@ -458,8 +496,9 @@ var RECENT_SEARCH_PREFIX = @" ";
[self sendAction:[self action] to:[self target]];
}
- (void)sendAction:(SEL)anAction to:(id)anObject
- (BOOL)sendAction:(SEL)anAction to:(id)anObject
{
[self selectAll:nil];
[super sendAction:anAction to:anObject];
[_partialStringTimer invalidate];
@@ -470,7 +509,7 @@ var RECENT_SEARCH_PREFIX = @" ";
- (void)_addStringToRecentSearches:(CPString)string
{
if (string === nil || string === @"" || [_recentSearches containsObject:string])
if (string == nil || string === @"" || [_recentSearches containsObject:string])
return;
var searches = [CPMutableArray arrayWithArray:_recentSearches];
@@ -517,19 +556,16 @@ var RECENT_SEARCH_PREFIX = @" ";
}
/*!
Provides the common case items for a recent searches menu. If there are not recent searches,
displays a single disabled item:
No Recent Searches
Provides the common case items for a recent searches menu.
If there are 1 more recent searches, it displays:
Recent Searches
recent search 1
recent search 2
etc.
Clear
---------------------
Clear Recent Searches
Recent Searches
recent search 1
recent search 2
etc.
If you wish to add items before or after the template, you can. If you put items
before, a separator will automatically be placed before the default template item.
@@ -554,6 +590,15 @@ var RECENT_SEARCH_PREFIX = @" ";
var template = [[CPMenu alloc] init],
item;
item = [[CPMenuItem alloc] initWithTitle:@"Clear"
action:@selector(_searchFieldClearRecents:)
keyEquivalent:@""];
[item setTag:CPSearchFieldClearRecentsMenuItemTag];
[item setTarget:self];
[template addItem:item];
[self _addSeparatorToMenu:template];
item = [[CPMenuItem alloc] initWithTitle:@"Recent Searches"
action:nil
keyEquivalent:@""];
@@ -568,32 +613,20 @@ var RECENT_SEARCH_PREFIX = @" ";
[item setTarget:self];
[template addItem:item];
item = [[CPMenuItem alloc] initWithTitle:@"Clear Recent Searches"
action:@selector(_searchFieldClearRecents:)
keyEquivalent:@""];
[item setTag:CPSearchFieldClearRecentsMenuItemTag];
[item setTarget:self];
[template addItem:item];
item = [[CPMenuItem alloc] initWithTitle:@"No Recent Searches"
action:nil
keyEquivalent:@""];
[item setTag:CPSearchFieldNoRecentsMenuItemTag];
[item setEnabled:NO];
[template addItem:item];
return template;
}
- (void)_updateSearchMenu
{
if (_searchMenuTemplate === nil)
if (_searchMenuTemplate == nil)
return;
var menu = [[CPMenu alloc] init],
countOfRecents = [_recentSearches count],
numberOfItems = [_searchMenuTemplate numberOfItems];
[menu setAutoenablesItems:NO];
for (var i = 0; i < numberOfItems; i++)
{
var item = [[_searchMenuTemplate itemAtIndex:i] copy];
@@ -603,9 +636,6 @@ var RECENT_SEARCH_PREFIX = @" ";
case CPSearchFieldRecentsTitleMenuItemTag:
if (countOfRecents === 0)
continue;
if ([menu numberOfItems] > 0)
[self _addSeparatorToMenu:menu];
break;
case CPSearchFieldRecentsMenuItemTag:
@@ -614,8 +644,7 @@ var RECENT_SEARCH_PREFIX = @" ";
for (var recentIndex = 0; recentIndex < countOfRecents; ++recentIndex)
{
// RECENT_SEARCH_PREFIX is a hack until CPMenuItem -setIndentationLevel works
var recentItem = [[CPMenuItem alloc] initWithTitle:RECENT_SEARCH_PREFIX + [_recentSearches objectAtIndex:recentIndex]
var recentItem = [[CPMenuItem alloc] initWithTitle:[_recentSearches objectAtIndex:recentIndex]
action:itemAction
keyEquivalent:[item keyEquivalent]];
[item setTarget:self];
@@ -629,9 +658,6 @@ var RECENT_SEARCH_PREFIX = @" ";
if (countOfRecents === 0)
continue;
if ([menu numberOfItems] > 0)
[self _addSeparatorToMenu:menu];
[item setAction:@selector(_searchFieldClearRecents:)];
[item setTarget:self];
break;
@@ -639,9 +665,6 @@ var RECENT_SEARCH_PREFIX = @" ";
case CPSearchFieldNoRecentsMenuItemTag:
if (countOfRecents !== 0)
continue;
if ([menu numberOfItems] > 0)
[self _addSeparatorToMenu:menu];
break;
}
@@ -658,6 +681,7 @@ var RECENT_SEARCH_PREFIX = @" ";
{
var separator = [CPMenuItem separatorItem];
[separator setEnabled:NO];
[separator setTag:CPSearchFieldRecentsTitleMenuItemTag];
[aMenu addItem:separator];
}
@@ -679,7 +703,8 @@ var RECENT_SEARCH_PREFIX = @" ";
return;
var aFrame = [[self superview] convertRect:[self frame] toView:nil],
location = CGPointMake(aFrame.origin.x + 10, aFrame.origin.y + aFrame.size.height - 4);
offset = [self currentValueForThemeAttribute:@"search-menu-offset"],
location = CGPointMake(aFrame.origin.x + offset.x, aFrame.origin.y + aFrame.size.height + offset.y);
var anEvent = [CPEvent mouseEventWithType:CPRightMouseDown location:location modifierFlags:0 timestamp:[[CPApp currentEvent] timestamp] windowNumber:[[self window] windowNumber] context:nil eventNumber:1 clickCount:1 pressure:0];
@@ -695,15 +720,19 @@ var RECENT_SEARCH_PREFIX = @" ";
- (void)cancelOperation:(id)sender
{
[self setObjectValue:@""];
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
// If something was entered, the search field must deactivate itself (else, do nothing)
if ([[self stringValue] length] > 0)
{
[self setObjectValue:@""];
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
[self _updateCancelButtonVisibility];
[[self window] makeFirstResponder:[self window]];
}
}
- (void)_searchFieldSearch:(id)sender
{
var searchString = [[sender title] substringFromIndex:[RECENT_SEARCH_PREFIX length]];
var searchString = [sender title];
if ([sender tag] != CPSearchFieldRecentsMenuItemTag)
[self _addStringToRecentSearches:searchString];
@@ -748,17 +777,266 @@ var RECENT_SEARCH_PREFIX = @" ";
- (void)_loadRecentSearchList
{
var name = [self recentsAutosaveName];
if (name === nil)
if (name == nil)
return;
var list = [[CPUserDefaults standardUserDefaults] objectForKey:name];
if (list !== nil)
if (list != nil)
_recentSearches = list;
}
@end
#pragma mark -
@implementation CPSearchField (ThemingAdditions)
// Overwrite CPTextField method to permit themed layout functions
- (void)layoutSubviews
{
if (!_contentView)
{
// Search for the CPImageAndTextView subview of mine
for (var i = 0, subviews = [self subviews], nb = [subviews count]; (!_contentView && (i < nb)); i++)
if ([subviews[i] isKindOfClass:_CPImageAndTextView])
_contentView = subviews[i];
}
var bezelColor = [self currentValueForThemeAttribute:@"bezel-color"];
if ([bezelColor isCSSBased])
{
// CSS Styling
// We don't need bezelView as we apply CSS styling directly on the search view itself
[self _setBackgroundColor:bezelColor];
if (!_contentView)
_contentView = [self layoutEphemeralSubviewNamed:@"content-view"
positioned:CPWindowAbove
relativeToEphemeralSubviewNamed:nil];
}
else
{
var bezelView = [self layoutEphemeralSubviewNamed:@"bezel-view"
positioned:CPWindowBelow
relativeToEphemeralSubviewNamed:@"content-view"];
[bezelView setBackgroundColor:bezelColor];
if (!_contentView)
_contentView = [self layoutEphemeralSubviewNamed:@"content-view"
positioned:CPWindowAbove
relativeToEphemeralSubviewNamed:@"bezel-view"];
}
if (_contentView)
{
[_contentView setHidden:(_stringValue && _stringValue.length > 0) && [self hasThemeState:CPThemeStateEditing]];
[_contentView setText:[self hasThemeState:CPTextFieldStatePlaceholder] ? [self placeholderString] : _stringValue];
[_contentView setTextColor:[self currentValueForThemeAttribute:@"text-color"]];
[_contentView setFont:[self font]]; //[self currentValueForThemeAttribute:@"font"]];
[_contentView setAlignment:[self currentValueForThemeAttribute:@"alignment"]];
[_contentView setVerticalAlignment:[self currentValueForThemeAttribute:@"vertical-alignment"]];
[_contentView setLineBreakMode:[self currentValueForThemeAttribute:@"line-break-mode"]];
[_contentView setTextShadowColor:[self currentValueForThemeAttribute:@"text-shadow-color"]];
[_contentView setTextShadowOffset:[self currentValueForThemeAttribute:@"text-shadow-offset"]];
}
if (_isEditing)
[self _setCSSStyleForInputElement];
[self updateSearchButton];
[self updateTrackingAreas];
}
// As CPTextField redefines setBackgroundColor, we have to bypass it
- (void)_setBackgroundColor:(CPColor)aColor
{
var grannyMethod = class_getInstanceMethod([[self superclass] superclass], @selector(setBackgroundColor:)),
grannyImplementation = method_getImplementation(grannyMethod);
grannyImplementation(self, @selector(setBackgroundColor:), aColor);
}
- (void)_layoutSubviews
{
var themedLayoutFunction = [self currentValueForThemeAttribute:@"layout-function"];
if (themedLayoutFunction)
// There's a theme defined layout function, just use it
objj_eval("("+themedLayoutFunction+")")(self);
else
// Call directly the completion handler
[self themedLayoutFunctionCompletionHandler];
}
- (void)updateSearchButton
{
[_searchButton setImage:(_searchMenuTemplate ? [self currentValueForThemeAttribute:@"image-find"] : [self currentValueForThemeAttribute:@"image-search"])];
[self updateTrackingAreas];
}
- (void)themedLayoutFunctionCompletionHandler
{
if (_isBecomingFirstResponder)
{
_isBecomingFirstResponder = NO;
// Call the real _becomeFirstKeyResponder to finish setting the input element
[super _becomeFirstKeyResponder];
// For some (unknown yet) reason, input field doesn't focus and text field visual state is not updated
var element = [self _inputElement];
element.focus();
[self layoutSubviews];
[CALayer runLoopUpdateLayers]; // Thank you @daboe01 for suggesting adding this
}
else
[self layoutSubviews];
}
// We override CPTextField method in order to delay the display of the input element until the end of the animation
- (BOOL)_becomeFirstKeyResponder
{
// As we have to return a result, we check if response could be NO
if (![self _isWithinUsablePlatformRect] || ![self isEditable])
return NO;
// We are now sure that response will be YES
_isBecomingFirstResponder = YES;
// We have to do this now in order to avoid running conditions messing things among multiple textfields
_stringValue = [self stringValue];
var element = [self _inputElement];
element.value = _stringValue;
[self _layoutSubviews];
return YES;
}
- (void)textDidEndEditing:(CPNotification)note
{
if ([note object] != self)
return;
[self _layoutSubviews];
[super textDidEndEditing:note];
}
- (void)_windowDidResignKey:(CPNotification)aNotification
{
// When the window resigns key, if the search field is empty, it must cancel first responder
if ([[self stringValue] length] == 0)
[[self window] makeFirstResponder:[self window]];
[super _windowDidResignKey:aNotification];
[self _layoutSubviews];
}
- (void)setPlaceholderString:(CPString)aStringValue
{
[super setPlaceholderString:aStringValue];
[self _layoutContent];
}
- (void)_layoutContent
{
[_searchButton setFrame:[self searchButtonRectForBounds:[self bounds]]];
[_contentView setFrame:[self contentRectForBounds:[self bounds]]];
[_cancelButton setFrame:[self cancelButtonRectForBounds:[self bounds]]];
[self updateTrackingAreas];
}
- (void)setFrameSize:(CGSize)aSize
{
[super setFrameSize:aSize];
[self _layoutContent];
}
- (id)_potentialCurrentValueForThemeAttribute:(CPString)aName
{
if (_isBecomingFirstResponder)
return [self valueForThemeAttribute:aName inState:[self themeState].and(CPThemeStateEditing)];
else
return [self currentValueForThemeAttribute:aName];
}
- (void)unbind:(CPString)aBinding
{
[super unbind:aBinding];
// our CPPredicateBinding binder adds a binding to the value.
// this private binding has to be also removed
if (aBinding === CPPredicateBinding)
[[[self class] _binderClassForBinding:aBinding] unbind:CPValueBinding forObject:self];
}
@end
#pragma mark -
@implementation CPSearchField (CPTrackingArea)
{
CPTrackingArea _searchButtonTrackingArea;
CPTrackingArea _cancelButtonTrackingArea;
}
- (void)updateTrackingAreas
{
if (_searchButtonTrackingArea)
{
[self removeTrackingArea:_searchButtonTrackingArea];
_searchButtonTrackingArea = nil;
}
if (_cancelButtonTrackingArea)
{
[self removeTrackingArea:_cancelButtonTrackingArea];
_cancelButtonTrackingArea = nil;
}
if (_searchButton)
{
_searchButtonTrackingArea = [[CPTrackingArea alloc] initWithRect:[_searchButton frame]
options:CPTrackingCursorUpdate | CPTrackingActiveInKeyWindow
owner:self
userInfo:@{ @"isButton": YES }];
[self addTrackingArea:_searchButtonTrackingArea];
}
if (_cancelButton && ![_cancelButton isHidden])
{
_cancelButtonTrackingArea = [[CPTrackingArea alloc] initWithRect:[_cancelButton frame]
options:CPTrackingCursorUpdate | CPTrackingActiveInKeyWindow
owner:self
userInfo:@{ @"isButton": YES }];
[self addTrackingArea:_cancelButtonTrackingArea];
}
[super updateTrackingAreas];
}
- (void)cursorUpdate:(CPEvent)anEvent
{
if ([[[anEvent trackingArea] userInfo] objectForKey:@"isButton"])
[[CPCursor arrowCursor] set];
else
[super cursorUpdate:anEvent];
}
@end
#pragma mark -
var CPRecentsAutosaveNameKey = @"CPRecentsAutosaveNameKey",
CPSendsWholeSearchStringKey = @"CPSendsWholeSearchStringKey",
CPSendsSearchStringImmediatelyKey = @"CPSendsSearchStringImmediatelyKey",
@@ -811,3 +1089,49 @@ var CPRecentsAutosaveNameKey = @"CPRecentsAutosaveNameKey",
}
@end
@implementation _CPSearchFieldPredicateBinder : CPBinder
{
CPArrayController _controller;
CPString _predicateFormat;
}
- (void)setValue:(id)aValue forBinding:(CPString)aBinding
{
if (aBinding === CPPredicateBinding)
{
var options = [_info objectForKey:CPOptionsKey];
_controller = [_info objectForKey:CPObservedObjectKey];
_predicateFormat = [options objectForKey:"CPPredicateFormat"];
[_source bind:CPValueBinding toObject:self withKeyPath:"searchFieldValue" options:nil];
}
}
- (void)setSearchFieldValue:(CPString)aValue
{
var destination = [_info objectForKey:CPObservedObjectKey],
keyPath = [_info objectForKey:CPObservedKeyPathKey];
[self suppressSpecificNotificationFromObject:destination keyPath:keyPath];
if (aValue)
{
var values = @[],
formatString = _predicateFormat.replace(/\$value/g, function(x) {[values addObject:aValue]; return "%@";});
[_controller setFilterPredicate:[CPPredicate predicateWithFormat:formatString argumentArray:values]];
}
else
[_controller setFilterPredicate:nil];
[self unsuppressSpecificNotificationFromObject:destination keyPath:keyPath];
}
- (CPString)searchFieldValue
{
return [_source stringValue];
}
@end
+357 -248
View File
@@ -25,9 +25,11 @@
@import "CPControl.j"
@import "CPWindow_Constants.j"
@import "_CPImageAndTextView.j"
@import "CPMenu.j"
@global CPApp
@typedef CPSegmentSwitchTracking
CPSegmentSwitchTrackingSelectOne = 0;
CPSegmentSwitchTrackingSelectAny = 1;
CPSegmentSwitchTrackingMomentary = 2;
@@ -40,7 +42,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
@implementation CPSegmentedControl : CPControl
{
CPArray _segments;
CPArray _segments @accessors(getter=segments);
CPArray _themeStates;
int _selectedSegment;
@@ -56,7 +58,7 @@ CPSegmentSwitchTrackingMomentary = 2;
return "segmented-control";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"alignment": CPCenterTextAlignment,
@@ -70,23 +72,9 @@ CPSegmentSwitchTrackingMomentary = 2;
@"center-segment-bezel-color": [CPNull null],
@"divider-bezel-color": [CPNull null],
@"divider-thickness": 1.0,
@"default-height": 24.0,
};
}
+ (Class)_binderClassForBinding:(CPString)aBinding
{
if ([self _isSelectionBinding:aBinding])
return [_CPSegmentedControlBinder class];
return [super _binderClassForBinding:aBinding];
}
+ (BOOL)_isSelectionBinding:(CPString)aBinding
{
return (aBinding === CPSelectedIndexBinding || aBinding === CPSelectedLabelBinding || aBinding === CPSelectedTagBinding);
}
- (id)initWithFrame:(CGRect)aRect
{
_segments = [];
@@ -99,22 +87,21 @@ CPSegmentSwitchTrackingMomentary = 2;
_selectedSegment = -1;
_trackingMode = CPSegmentSwitchTrackingSelectOne;
_trackingHighlighted = NO;
_trackingSegment = -1;
}
return self;
}
- (void)bind:(CPString)aBinding toObject:(id)anObject withKeyPath:(CPString)aKeyPath options:(CPDictionary)options
/*!
Sets the control's size.
@param aControlSize the control's size
*/
- (void)setControlSize:(CPControlSize)aControlSize
{
if ([[self class] _isSelectionBinding:aBinding] && _trackingMode !== CPSegmentSwitchTrackingSelectOne)
CPLog.warn("Binding " + aBinding + " needs CPSegmentSwitchTrackingSelectOne tracking mode");
else
[super bind:aBinding toObject:anObject withKeyPath:aKeyPath options:options];
}
- (void)_reverseSetBinding
{
[_CPSegmentedControlBinder reverseSetValueForObject:self];
[super setControlSize:aControlSize];
[self _sizeToControlSize];
}
/*!
@@ -122,7 +109,54 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (int)selectedTag
{
return [_segments[_selectedSegment] tag];
return [[_segments objectAtIndex:_selectedSegment] tag];
}
/*! @ignore */
- (void)setSegments:(CPArray)segments
{
[self removeSegmentsAtIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [self segmentCount])]];
[self insertSegments:segments atIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [segments count])]];
}
/*! @ignore */
- (void)insertSegments:(CPArray)segments atIndexes:(CPIndexSet)indices
{
if ([segments count] == 0)
return;
var newStates = @[],
count = [indices count];
while (count--)
[newStates addObject:CPThemeStateNormal];
[_segments insertObjects:segments atIndexes:indices];
[_themeStates insertObjects:newStates atIndexes:indices];
if (_selectedSegment >= [indices firstIndex])
_selectedSegment += [indices count];
}
/*! @ignore */
- (void)removeSegmentsAtIndexes:(CPIndexSet)indices
{
if ([indices count] == 0)
return;
[indices enumerateIndexesUsingBlock:function(idx, stop)
{
[[_segments objectAtIndex:idx] setSelected:NO];
}];
if ([indices containsIndex:_selectedSegment])
_selectedSegment = -1;
else if ([indices lastIndex] < _selectedSegment)
_selectedSegment -= [indices count];
[_segments removeObjectsAtIndexes:indices];
[_themeStates removeObjectsAtIndexes:indices];
}
// Specifying the number of segments
@@ -132,41 +166,32 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (void)setSegmentCount:(unsigned)aCount
{
if (_segments.length == aCount)
var prevCount = [_segments count];
if (aCount == prevCount)
return;
var height = CGRectGetHeight([self bounds]),
dividersBefore = MAX(0, _segments.length - 1),
dividersAfter = MAX(0, aCount - 1);
if (_segments.length < aCount)
if (aCount > prevCount)
{
for (var index = _segments.length; index < aCount; ++index)
{
_segments[index] = [[_CPSegmentItem alloc] init];
_themeStates[index] = CPThemeStateNormal;
}
}
else if (aCount < _segments.length)
{
_segments.length = aCount;
_themeStates.length = aCount;
}
var count = aCount - prevCount,
segments = @[];
if (_selectedSegment >= _segments.length)
while (count--)
[segments addObject:[[_CPSegmentItem alloc] init]];
[self insertSegments:segments atIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(prevCount, aCount - prevCount)]];
}
else
[self removeSegmentsAtIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(aCount, prevCount - aCount)]];
[self _updateSelectionIfNeeded];
[self tileWithChangedSegment:MAX(MIN(prevCount, aCount) - 1, 0)];
}
- (void)_updateSelectionIfNeeded
{
if (_selectedSegment >= [self segmentCount])
_selectedSegment = -1;
var thickness = [self currentValueForThemeAttribute:@"divider-thickness"],
frame = [self frame],
widthOfAllSegments = 0,
dividerExtraSpace = ([_segments count] - 1) * thickness;
for (var i = 0; i < [_segments count]; i++)
widthOfAllSegments += [_segments[i] width];
[self setFrameSize:CGSizeMake(widthOfAllSegments + dividerExtraSpace, frame.size.height)];
[self tileWithChangedSegment:0];
}
/*!
@@ -174,7 +199,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (unsigned)segmentCount
{
return _segments.length;
return [_segments count];
}
// Specifying Selected Segment
@@ -186,7 +211,20 @@ CPSegmentSwitchTrackingMomentary = 2;
- (void)setSelectedSegment:(unsigned)aSegment
{
// setSelected:forSegment throws the exception for us (if necessary)
[self setSelected:YES forSegment:aSegment];
if (_selectedSegment == aSegment)
return;
if (aSegment == -1)
{
var count = [self segmentCount];
while (count--)
[self setSelected:NO forSegment:count];
_selectedSegment = -1;
}
else
[self setSelected:YES forSegment:aSegment];
}
/*!
@@ -204,8 +242,8 @@ CPSegmentSwitchTrackingMomentary = 2;
{
var index = 0;
for (; index < _segments.length; ++index)
if (_segments[index].tag == aTag)
for (; index < [_segments count]; ++index)
if ([[_segments objectAtIndex:index] tag] == aTag)
{
[self setSelectedSegment:index];
@@ -219,8 +257,8 @@ CPSegmentSwitchTrackingMomentary = 2;
{
var index = 0;
for (; index < _segments.length; ++index)
if (_segments[index].label == aLabel)
for (; index < [_segments count]; ++index)
if ([[_segments objectAtIndex:index] label] == aLabel)
{
[self setSelectedSegment:index];
@@ -231,7 +269,7 @@ CPSegmentSwitchTrackingMomentary = 2;
}
// Specifying Tracking Mode
/*! @ignore */
- (BOOL)isTracking
{
@@ -249,7 +287,7 @@ CPSegmentSwitchTrackingMomentary = 2;
var index = 0,
selected = NO;
for (; index < _segments.length; ++index)
for (; index < [self segmentCount]; ++index)
if ([_segments[index] selected])
if (selected)
[self setSelected:NO forSegment:index];
@@ -261,7 +299,7 @@ CPSegmentSwitchTrackingMomentary = 2;
{
var index = 0;
for (; index < _segments.length; ++index)
for (; index < [self segmentCount]; ++index)
if ([_segments[index] selected])
[self setSelected:NO forSegment:index];
}
@@ -284,8 +322,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (void)setWidth:(float)aWidth forSegment:(unsigned)aSegment
{
[_segments[aSegment] setWidth:aWidth];
[[_segments objectAtIndex:aSegment] setWidth:aWidth];
[self tileWithChangedSegment:aSegment];
}
@@ -296,7 +333,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (float)widthForSegment:(unsigned)aSegment
{
return [_segments[aSegment] width];
return [[_segments objectAtIndex:aSegment] width];
}
/*!
@@ -307,7 +344,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (void)setImage:(CPImage)anImage forSegment:(unsigned)aSegment
{
[_segments[aSegment] setImage:anImage];
[[_segments objectAtIndex:aSegment] setImage:anImage];
[self tileWithChangedSegment:aSegment];
}
@@ -319,7 +356,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (CPImage)imageForSegment:(unsigned)aSegment
{
return [_segments[aSegment] image];
return [[_segments objectAtIndex:aSegment] image];
}
/*!
@@ -330,7 +367,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (void)setLabel:(CPString)aLabel forSegment:(unsigned)aSegment
{
[_segments[aSegment] setLabel:aLabel];
[[_segments objectAtIndex:aSegment] setLabel:aLabel];
[self tileWithChangedSegment:aSegment];
}
@@ -342,7 +379,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (CPString)labelForSegment:(unsigned)aSegment
{
return [_segments[aSegment] label];
return [[_segments objectAtIndex:aSegment] label];
}
/*!
@@ -353,7 +390,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (void)setMenu:(CPMenu)aMenu forSegment:(unsigned)aSegment
{
[_segments[aSegment] setMenu:aMenu];
[[_segments objectAtIndex:aSegment] setMenu:aMenu];
}
/*!
@@ -363,7 +400,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (CPMenu)menuForSegment:(unsigned)aSegment
{
return [_segments[aSegment] menu];
return [[_segments objectAtIndex:aSegment] menu];
}
/*!
@@ -375,7 +412,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (void)setSelected:(BOOL)isSelected forSegment:(unsigned)aSegment
{
var segment = _segments[aSegment];
var segment = [_segments objectAtIndex:aSegment];
// If we're already in this state, bail.
if ([segment selected] == isSelected)
@@ -392,7 +429,7 @@ CPSegmentSwitchTrackingMomentary = 2;
_selectedSegment = aSegment;
if (_trackingMode == CPSegmentSwitchTrackingSelectOne && oldSelectedSegment != aSegment && oldSelectedSegment != -1)
if (_trackingMode == CPSegmentSwitchTrackingSelectOne && oldSelectedSegment != aSegment && oldSelectedSegment != -1 && oldSelectedSegment < _segments.length)
{
[_segments[oldSelectedSegment] setSelected:NO];
_themeStates[oldSelectedSegment] = CPThemeStateNormal;
@@ -415,7 +452,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (BOOL)isSelectedForSegment:(unsigned)aSegment
{
return [_segments[aSegment] selected];
return [[_segments objectAtIndex:aSegment] selected];
}
/*!
@@ -426,15 +463,17 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (void)setEnabled:(BOOL)shouldBeEnabled forSegment:(unsigned)aSegment
{
if ([_segments[aSegment] enabled] === shouldBeEnabled)
var segment = [_segments objectAtIndex:aSegment];
if ([segment enabled] === shouldBeEnabled)
return;
[_segments[aSegment] setEnabled:shouldBeEnabled];
[segment setEnabled:shouldBeEnabled];
if (shouldBeEnabled)
_themeStates[aSegment] &= ~CPThemeStateDisabled;
_themeStates[aSegment] = _themeStates[aSegment].without(CPThemeStateDisabled);
else
_themeStates[aSegment] |= CPThemeStateDisabled;
_themeStates[aSegment] = _themeStates[aSegment].and(CPThemeStateDisabled);
[self setNeedsLayout];
[self setNeedsDisplay:YES];
@@ -447,7 +486,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (BOOL)isEnabledForSegment:(unsigned)aSegment
{
return [_segments[aSegment] enabled];
return [[_segments objectAtIndex:aSegment] enabled];
}
/*!
@@ -457,7 +496,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (void)setTag:(int)aTag forSegment:(unsigned)aSegment
{
[_segments[aSegment] setTag:aTag];
[[_segments objectAtIndex:aSegment] setTag:aTag];
}
/*!
@@ -466,7 +505,7 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (int)tagForSegment:(unsigned)aSegment
{
return [_segments[aSegment] tag];
return [[_segments objectAtIndex:aSegment] tag];
}
// Drawings
@@ -477,10 +516,13 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (void)drawSegmentBezel:(int)aSegment highlight:(BOOL)shouldHighlight
{
if (shouldHighlight)
_themeStates[aSegment] |= CPThemeStateHighlighted;
else
_themeStates[aSegment] &= ~CPThemeStateHighlighted;
if (aSegment < _themeStates.length)
{
if (shouldHighlight)
_themeStates[aSegment] = _themeStates[aSegment].and(CPThemeStateHighlighted);
else
_themeStates[aSegment] = _themeStates[aSegment].without(CPThemeStateHighlighted);
}
[self setNeedsLayout];
[self setNeedsDisplay:YES];
@@ -488,14 +530,12 @@ CPSegmentSwitchTrackingMomentary = 2;
- (float)_leftOffsetForSegment:(unsigned)segment
{
var bezelInset = [self currentValueForThemeAttribute:@"bezel-inset"];
if (segment == 0)
return bezelInset.left;
return [self currentValueForThemeAttribute:@"bezel-inset"].left;
var thickness = [self currentValueForThemeAttribute:@"divider-thickness"];
return [self _leftOffsetForSegment:segment - 1] + [self widthForSegment:segment - 1] + thickness;
return [self _leftOffsetForSegment:segment - 1] + CGRectGetWidth([self frameForSegment:segment - 1]) + thickness;
}
- (unsigned)_indexOfLastSegment
@@ -510,7 +550,7 @@ CPSegmentSwitchTrackingMomentary = 2;
- (CGRect)rectForEphemeralSubviewNamed:(CPString)aName
{
var height = [self currentValueForThemeAttribute:@"default-height"],
var height = [self currentValueForThemeAttribute:@"min-size"].height,
contentInset = [self currentValueForThemeAttribute:@"content-inset"],
bezelInset = [self currentValueForThemeAttribute:@"bezel-inset"],
bounds = [self bounds];
@@ -529,7 +569,7 @@ CPSegmentSwitchTrackingMomentary = 2;
else if (aName.indexOf("segment-bezel") === 0)
{
var segment = parseInt(aName.substring("segment-bezel-".length), 10),
frame = CGRectCreateCopy([_segments[segment] frame]);
frame = CGRectCreateCopy([self frameForSegment:segment]);
if (segment === 0)
{
@@ -537,7 +577,7 @@ CPSegmentSwitchTrackingMomentary = 2;
frame.size.width -= contentInset.left;
}
if (segment === _segments.length - 1)
if (segment === [self segmentCount] - 1)
frame.size.width = CGRectGetWidth([self bounds]) - contentInset.right - frame.origin.x;
return frame;
@@ -545,7 +585,7 @@ CPSegmentSwitchTrackingMomentary = 2;
else if (aName.indexOf("divider-bezel") === 0)
{
var segment = parseInt(aName.substring("divider-bezel-".length), 10),
width = [self widthForSegment:segment],
width = CGRectGetWidth([self frameForSegment:segment]),
left = [self _leftOffsetForSegment:segment],
thickness = [self currentValueForThemeAttribute:@"divider-thickness"];
@@ -564,19 +604,32 @@ CPSegmentSwitchTrackingMomentary = 2;
- (CPView)createEphemeralSubviewNamed:(CPString)aName
{
if ([aName hasPrefix:@"segment-content"])
return [[_CPImageAndTextView alloc] initWithFrame:CGRectMakeZero()];
{
var view = [[_CPImageAndTextView alloc] initWithFrame:CGRectMakeZero()];
[view _setUsesSingleLineMode:YES];
return view;
}
return [[CPView alloc] initWithFrame:CGRectMakeZero()];
}
- (void)layoutSubviews
{
if (_segments.length <= 0)
if ([self segmentCount] <= 0)
return;
var themeState = _themeStates[0];
var themeState = _themeStates[0],
isDisabled = [self hasThemeState:CPThemeStateDisabled],
isControlSizeSmall = [self hasThemeState:CPThemeStateControlSizeSmall],
isControlSizeMini = [self hasThemeState:CPThemeStateControlSizeMini];
themeState |= _themeState & CPThemeStateDisabled;
themeState = isDisabled ? themeState.and(CPThemeStateDisabled) : themeState;
if (isControlSizeSmall)
themeState = themeState.and(CPThemeStateControlSizeSmall);
else if (isControlSizeMini)
themeState = themeState.and(CPThemeStateControlSizeMini);
var leftCapColor = [self valueForThemeAttribute:@"left-segment-bezel-color"
inState:themeState],
@@ -589,7 +642,12 @@ CPSegmentSwitchTrackingMomentary = 2;
var themeState = _themeStates[_themeStates.length - 1];
themeState |= _themeState & CPThemeStateDisabled;
themeState = isDisabled ? themeState.and(CPThemeStateDisabled) : themeState;
if (isControlSizeSmall)
themeState = themeState.and(CPThemeStateControlSizeSmall);
else if (isControlSizeMini)
themeState = themeState.and(CPThemeStateControlSizeMini);
var rightCapColor = [self valueForThemeAttribute:@"right-segment-bezel-color"
inState:themeState],
@@ -604,7 +662,12 @@ CPSegmentSwitchTrackingMomentary = 2;
{
var themeState = _themeStates[i];
themeState |= _themeState & CPThemeStateDisabled;
themeState = isDisabled ? themeState.and(CPThemeStateDisabled) : themeState;
if (isControlSizeSmall)
themeState = themeState.and(CPThemeStateControlSizeSmall);
else if (isControlSizeMini)
themeState = themeState.and(CPThemeStateControlSizeMini);
var bezelColor = [self valueForThemeAttribute:@"center-segment-bezel-color"
inState:themeState],
@@ -615,7 +678,6 @@ CPSegmentSwitchTrackingMomentary = 2;
[bezelView setBackgroundColor:bezelColor];
// layout image/title views
var segment = _segments[i],
contentView = [self layoutEphemeralSubviewNamed:@"segment-content-" + i
@@ -642,11 +704,15 @@ CPSegmentSwitchTrackingMomentary = 2;
if (i == count - 1)
continue;
var borderState = _themeStates[i] | _themeStates[i + 1];
borderState = (borderState & CPThemeStateSelected & ~CPThemeStateHighlighted) ? CPThemeStateSelected : CPThemeStateNormal;
var borderState = _themeStates[i].and(_themeStates[i + 1]);
borderState |= _themeState & CPThemeStateDisabled;
borderState = isDisabled ? borderState.and(CPThemeStateDisabled) : borderState;
if (isControlSizeSmall)
borderState = borderState.and(CPThemeStateControlSizeSmall);
else if (isControlSizeMini)
borderState = borderState.and(CPThemeStateControlSizeMini);
var borderColor = [self valueForThemeAttribute:@"divider-bezel-color"
inState:borderState],
@@ -669,61 +735,33 @@ CPSegmentSwitchTrackingMomentary = 2;
{
}
- (void)tileWithChangedSegment:(unsigned)aSegment
/*! @ignore */
- (void)tile
{
if (aSegment >= _segments.length)
[self tileWithChangedSegment:0];
}
/*! @ignore */
- (void)tileWithChangedSegment:(CPInteger)aSegment
{
var segmentCount = [self segmentCount];
// Corner case: when segmentCount == 0 and aSegment == 0, we do not return here because we still need to set the new frameSize bellow.
if (aSegment < 0 || (segmentCount > 0 && aSegment >= segmentCount))
return;
var segment = _segments[aSegment],
segmentWidth = [segment width],
themeState = _themeStates[aSegment] | (_themeState & CPThemeStateDisabled),
contentInset = [self valueForThemeAttribute:@"content-inset" inState:themeState],
font = [self font];
var width = 0;
if (!segmentWidth)
if (segmentCount > 0)
{
if ([segment image] && [segment label])
segmentWidth = [[segment label] sizeWithFont:font].width + [[segment image] size].width + contentInset.left + contentInset.right;
else if (segment.image)
segmentWidth = [[segment image] size].width + contentInset.left + contentInset.right;
else if (segment.label)
segmentWidth = [[segment label] sizeWithFont:font].width + contentInset.left + contentInset.right;
else
segmentWidth = 0.0;
// Invalidate frames for segments on the right. They will be lazily computed by -frameForSegment:.
for (var i = aSegment; i < segmentCount; i++)
[_segments[i] setFrame:CGRectMakeZero()];
width = CGRectGetMaxX([self frameForSegment:(segmentCount - 1)]);
}
var delta = segmentWidth - CGRectGetWidth([segment frame]);
if (!delta)
{
[self setNeedsLayout];
[self setNeedsDisplay:YES];
return;
}
// Update control size
var frame = [self frame];
[self setFrameSize:CGSizeMake(CGRectGetWidth(frame) + delta, CGRectGetHeight(frame))];
// Update segment width
[segment setWidth:segmentWidth];
[segment setFrame:[self frameForSegment:aSegment]];
// Update following segments widths
var index = aSegment + 1;
for (; index < _segments.length; ++index)
{
[_segments[index] frame].origin.x += delta;
[self drawSegmentBezel:index highlight:NO];
[self drawSegment:index highlight:NO];
}
[self drawSegmentBezel:aSegment highlight:NO];
[self drawSegment:aSegment highlight:NO];
[self setFrameSize:CGSizeMake(width, CGRectGetHeight([self frame]))];
[self setNeedsLayout];
[self setNeedsDisplay:YES];
@@ -735,29 +773,58 @@ CPSegmentSwitchTrackingMomentary = 2;
*/
- (CGRect)frameForSegment:(unsigned)aSegment
{
return [self bezelFrameForSegment:aSegment];
var segment = [_segments objectAtIndex:aSegment],
frame = [segment frame];
if (CGRectEqualToRect(frame, CGRectMakeZero()))
{
frame = [self bezelFrameForSegment:aSegment];
[segment setFrame:frame];
}
return frame;
}
- (CGRect)bezelFrameForSegment:(unsigned)aSegment
{
var height = [self currentValueForThemeAttribute:@"default-height"],
bezelInset = [self currentValueForThemeAttribute:@"bezel-inset"],
var left = [self _leftOffsetForSegment:aSegment],
top = [self currentValueForThemeAttribute:@"bezel-inset"].top,
width = [self widthForSegment:aSegment],
left = [self _leftOffsetForSegment:aSegment];
height = [self currentValueForThemeAttribute:@"min-size"].height;
return CGRectMake(left, bezelInset.top, width, height);
if (width == 0)
{
var themeState = _themeState.hasThemeState(CPThemeStateDisabled) ? _themeStates[aSegment].and(CPThemeStateDisabled) : _themeStates[aSegment],
contentInset = [self valueForThemeAttribute:@"content-inset" inState:themeState],
contentInsetWidth = contentInset.left + contentInset.right,
segment = _segments[aSegment],
label = [segment label],
image = [segment image];
// add 1 pixel to account for possible fractional pixels at right edge
width = (label ? [label sizeWithFont:[self font]].width + 1 : 4.0) + (image ? [image size].width : 0) + contentInsetWidth;
}
return CGRectMake(left, top, width, height);
}
- (CGRect)contentFrameForSegment:(unsigned)aSegment
{
var height = [self currentValueForThemeAttribute:@"default-height"],
var height = [self currentValueForThemeAttribute:@"min-size"].height,
contentInset = [self currentValueForThemeAttribute:@"content-inset"],
width = [self widthForSegment:aSegment],
width = CGRectGetWidth([self frameForSegment:aSegment]),
left = [self _leftOffsetForSegment:aSegment];
return CGRectMake(left + contentInset.left, contentInset.top, width - contentInset.left - contentInset.right, height - contentInset.top - contentInset.bottom);
}
- (CGSize)_minimumFrameSize
{
// The current width is always the minimum width.
return CGSizeMake(CGRectGetWidth([self frame]), [self currentValueForThemeAttribute:@"min-size"].height);
}
/*!
Returns the segment that is hit by the specified point.
@param aPoint the point to test for a segment hit
@@ -766,19 +833,19 @@ CPSegmentSwitchTrackingMomentary = 2;
- (unsigned)testSegment:(CGPoint)aPoint
{
var location = [self convertPoint:aPoint fromView:nil],
count = _segments.length;
count = [self segmentCount];
while (count--)
if (CGRectContainsPoint([_segments[count] frame], aPoint))
if (CGRectContainsPoint([self frameForSegment:count], aPoint))
return count;
if (_segments.length)
if ([self segmentCount])
{
var adjustedLastFrame = CGRectCreateCopy([_segments[_segments.length - 1] frame]);
var adjustedLastFrame = CGRectCreateCopy([self frameForSegment:(_segments.length - 1)]);
adjustedLastFrame.size.width = CGRectGetWidth([self bounds]) - adjustedLastFrame.origin.x;
if (CGRectContainsPoint(adjustedLastFrame, aPoint))
return _segments.length - 1;
return [self segmentCount] - 1;
}
return -1;
@@ -806,64 +873,68 @@ CPSegmentSwitchTrackingMomentary = 2;
var type = [anEvent type],
location = [self convertPoint:[anEvent locationInWindow] fromView:nil];
if (type == CPLeftMouseUp)
switch (type)
{
if (_trackingSegment == -1)
case CPLeftMouseUp:
if (_trackingSegment === CPNotFound)
return;
if (_trackingSegment === [self testSegment:location])
{
if (_trackingMode == CPSegmentSwitchTrackingSelectAny)
{
[self setSelected:![self isSelectedForSegment:_trackingSegment] forSegment:_trackingSegment];
// With ANY, _selectedSegment means last pressed.
_selectedSegment = _trackingSegment;
}
else
[self setSelected:YES forSegment:_trackingSegment];
[self sendAction:[self action] to:[self target]];
if (_trackingMode == CPSegmentSwitchTrackingMomentary)
{
[self setSelected:NO forSegment:_trackingSegment];
_selectedSegment = CPNotFound;
}
}
[self drawSegmentBezel:_trackingSegment highlight:NO];
_trackingSegment = CPNotFound;
return;
if (_trackingSegment === [self testSegment:location])
{
if (_trackingMode == CPSegmentSwitchTrackingSelectAny)
case CPLeftMouseDown:
var trackingSegment = [self testSegment:location];
if (trackingSegment > CPNotFound && [self isEnabledForSegment:trackingSegment])
{
[self setSelected:![self isSelectedForSegment:_trackingSegment] forSegment:_trackingSegment];
// With ANY, _selectedSegment means last pressed.
_selectedSegment = _trackingSegment;
_trackingHighlighted = YES;
_trackingSegment = trackingSegment;
[self drawSegmentBezel:_trackingSegment highlight:YES];
}
else
[self setSelected:YES forSegment:_trackingSegment];
[self sendAction:[self action] to:[self target]];
break;
if (_trackingMode == CPSegmentSwitchTrackingMomentary)
case CPLeftMouseDragged:
if (_trackingSegment === CPNotFound)
return;
var highlighted = [self testSegment:location] === _trackingSegment;
if (highlighted != _trackingHighlighted)
{
[self setSelected:NO forSegment:_trackingSegment];
_trackingHighlighted = highlighted;
_selectedSegment = -1;
[self drawSegmentBezel:_trackingSegment highlight:_trackingHighlighted];
}
}
[self drawSegmentBezel:_trackingSegment highlight:NO];
_trackingSegment = -1;
return;
}
if (type == CPLeftMouseDown)
{
var trackingSegment = [self testSegment:location];
if (trackingSegment > -1 && [self isEnabledForSegment:trackingSegment])
{
_trackingHighlighted = YES;
_trackingSegment = trackingSegment;
[self drawSegmentBezel:_trackingSegment highlight:YES];
}
}
else if (type == CPLeftMouseDragged)
{
if (_trackingSegment == -1)
return;
var highlighted = [self testSegment:location] === _trackingSegment;
if (highlighted != _trackingHighlighted)
{
_trackingHighlighted = highlighted;
[self drawSegmentBezel:_trackingSegment highlight:_trackingHighlighted];
}
break;
}
[CPApp setTarget:self selector:@selector(trackSegment:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES];
@@ -873,7 +944,7 @@ CPSegmentSwitchTrackingMomentary = 2;
{
[super setFont:aFont];
[self tileWithChangedSegment:0];
[self tile];
}
@end
@@ -905,28 +976,49 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
if ([aCoder containsValueForKey:CPSegmentedControlSelectedKey])
_selectedSegment = [aCoder decodeIntForKey:CPSegmentedControlSelectedKey];
else
_selectedSegment = -1;
_selectedSegment = CPNotFound;
if ([aCoder containsValueForKey:CPSegmentedControlTrackingModeKey])
_trackingMode = [aCoder decodeIntForKey:CPSegmentedControlTrackingModeKey];
else
_trackingMode = CPSegmentSwitchTrackingSelectOne;
// HACK
for (var i = 0; i < _segments.length; i++)
{
// Here we update the themeStates array for each segments to know if there are selected or not
for (var i = 0; i < [self segmentCount]; i++)
_themeStates[i] = [_segments[i] selected] ? CPThemeStateSelected : CPThemeStateNormal;
[self tileWithChangedSegment:i];
[self tile];
var thickness = [self currentValueForThemeAttribute:@"divider-thickness"],
dividerExtraSpace = ([_segments count] - 1) * thickness,
difference = MAX(originalWidth - [self frame].size.width - dividerExtraSpace, 0.0),
remainingWidth = FLOOR(difference / [self segmentCount]),
widthOfAllSegments = 0;
// We do this in a second loop because it relies on all the themeStates being set first
for (var i = 0; i < [self segmentCount]; i++)
{
var frame = [_segments[i] frame];
frame.size.width += remainingWidth;
widthOfAllSegments += CGRectGetWidth(frame);
}
var difference = MAX(originalWidth - [self frame].size.width, 0.0),
remainingWidth = FLOOR(difference / _segments.length);
// Here we handle the leftovers pixel, and we will add one pixel to each segment cell till we have the same size as the originalSize.
// This is needed to have a perfect/same alignment between our application and xCode.
var leftOversPixel = originalWidth - (widthOfAllSegments + dividerExtraSpace);
for (var i = 0; i < _segments.length; i++)
[self setWidth:[_segments[i] width] + remainingWidth forSegment:i];
// Make sure we don't make an out of range
if (leftOversPixel < [self segmentCount] - 1)
{
for (var i = 0; i < leftOversPixel; i++)
{
[_segments[i] frame].size.width += 1;
}
}
[self tileWithChangedSegment:0];
[self setFrameSize:CGSizeMake(originalWidth, CGRectGetHeight([self frame]))];
[self tile];
}
return self;
@@ -944,31 +1036,48 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
@end
var CPSegmentedControlBindersMap = {},
CPSegmentedControlNoSelectionPlaceholder = "CPSegmentedControlNoSelectionPlaceholder";
@implementation CPSegmentedControl (BindingSupport)
+ (Class)_binderClassForBinding:(CPString)aBinding
{
if ([self _isSelectionBinding:aBinding])
return [_CPSegmentedControlBinder class];
return [super _binderClassForBinding:aBinding];
}
+ (BOOL)_isSelectionBinding:(CPString)aBinding
{
return (aBinding === CPSelectedIndexBinding || aBinding === CPSelectedLabelBinding || aBinding === CPSelectedTagBinding);
}
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return [self _isSelectionBinding:aBinding];
}
- (void)bind:(CPString)aBinding toObject:(id)anObject withKeyPath:(CPString)aKeyPath options:(CPDictionary)options
{
if ([[self class] _isSelectionBinding:aBinding] && _trackingMode !== CPSegmentSwitchTrackingSelectOne)
{
CPLog.warn("Binding " + aBinding + " needs CPSegmentSwitchTrackingSelectOne tracking mode");
return;
}
[super bind:aBinding toObject:anObject withKeyPath:aKeyPath options:options];
}
- (void)_reverseSetBinding
{
[_CPSegmentedControlBinder _reverseSetValueFromExclusiveBinderForObject:self];
}
@end
var CPSegmentedControlNoSelectionPlaceholder = "CPSegmentedControlNoSelectionPlaceholder";
@implementation _CPSegmentedControlBinder : CPBinder
{
CPString _selectionBinding @accessors(readonly, getter=selectionBinding);
}
+ (void)reverseSetValueForObject:(id)aSource
{
var binder = CPSegmentedControlBindersMap[[aSource UID]];
[binder reverseSetValueFor:[binder selectionBinding]];
}
- (id)initWithBinding:(CPString)aBinding name:(CPString)aName to:(id)aDestination keyPath:(CPString)aKeyPath options:(CPDictionary)options from:(id)aSource
{
self = [super initWithBinding:aBinding name:aName to:aDestination keyPath:aKeyPath options:options from:aSource];
if (self)
{
CPSegmentedControlBindersMap[[aSource UID]] = self;
_selectionBinding = aName;
}
return self;
}
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options
+5 -2
View File
@@ -22,6 +22,9 @@
@import <Foundation/CPObject.j>
@import "CGGeometry.j"
@import "CPColor.j"
@import "CPGraphicsContext.j"
/*!
@deprecated
@@ -31,9 +34,9 @@
*/
@implementation CPShadow : CPObject
{
CGSize _offset @accessors(property=shadowOffset);
CGSize _offset @accessors(property=shadowOffset);
float _blurRadius @accessors(property=shadowBlurRadius);
CPColor _color @accessors(property=shadowColor);
CPColor _color @accessors(property=shadowColor);
}
/*!
+2 -2
View File
@@ -26,7 +26,7 @@
@import "CPImage.j"
@import "CPView.j"
@typedef CPShadowWeight
CPLightShadow = 0;
CPHeavyShadow = 1;
@@ -47,7 +47,7 @@ CPThemeStateShadowViewHeavy = CPThemeState("shadowview-style-heavy");
return "shadow-view";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"bezel-color": [CPNull null],
+803 -151
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -55,7 +55,6 @@
CPTextField _hexLabel;
CPTextField _hexValue;
CPTextField _hexValue;
CPTextField _redValue;
CPTextField _greenValue;
CPTextField _blueValue;
+51 -2
View File
@@ -23,6 +23,19 @@
@import <Foundation/CPObject.j>
@import <Foundation/CPRunLoop.j>
@typedef HTMLAudioElement
@protocol CPSoundDelegate <CPObject>
@optional
- (void)sound:(CPSound)aSound didFinishPlaying:(BOOL)finishedLoading;
@end
@global document
var CPSoundDelegate_sound_didFinishPlaying_ = 1 << 1;
CPSoundLoadStateEmpty = 0;
CPSoundLoadStateLoading = 1;
CPSoundLoadStateCanBePlayed = 2;
@@ -50,6 +63,7 @@ CPSoundPlayBackStatePause = 2;
HTMLAudioElement _audioTag;
int _loadStatus;
int _playBackStatus;
unsigned _implementedDelegateMethods;
}
#pragma mark -
@@ -133,6 +147,25 @@ CPSoundPlayBackStatePause = 2;
}
#pragma mark -
#pragma mark Delegate methods
/*!
Sets the sound's delegate.
@param aDelegate the new delegate
*/
- (void)setDelegate:(id)aDelegate
{
if (_delegate === aDelegate)
return;
_delegate = aDelegate;
_implementedDelegateMethods = 0;
if ([_delegate respondsToSelector:@selector(sound:didFinishPlaying:)])
_implementedDelegateMethods |= CPSoundDelegate_sound_didFinishPlaying_;
}
#pragma mark -
#pragma mark Events listener
@@ -207,8 +240,7 @@ CPSoundPlayBackStatePause = 2;
_audioTag.currentTime = 0.0;
_playBackStatus = CPSoundPlayBackStateStop;
if (_delegate && [_delegate respondsToSelector:@selector(sound:didFinishPlaying:)])
[_delegate sound:self didFinishPlaying:YES];
[self _sendDelegateSoundDidFinishPlaying:YES];
return YES;
}
@@ -316,3 +348,20 @@ CPSoundPlayBackStatePause = 2;
}
@end
@implementation CPSound (CPSoundDelegate)
/*!
@ignore
Call delegate sound:didFinishPlaying:
*/
- (void)_sendDelegateSoundDidFinishPlaying:(BOOL)finishedPlaying
{
if (!(_implementedDelegateMethods & CPSoundDelegate_sound_didFinishPlaying_))
return;
[_delegate sound:self didFinishPlaying:finishedPlaying];
}
@end
+1235 -620
View File
File diff suppressed because it is too large Load Diff
+31 -23
View File
@@ -25,7 +25,6 @@
@import "CPTextField.j"
/*!
CPStepper is an implementation of Cocoa NSStepper.
@@ -53,9 +52,9 @@
@param maxValue the maximal acceptable value of the stepper
@return Initialized CPStepper
*/
+ (CPStepper)stepperWithInitialValue:(float)aValue minValue:(float)aMinValue maxValue:(float)aMaxValue
+ (id)stepperWithInitialValue:(float)aValue minValue:(float)aMinValue maxValue:(float)aMaxValue
{
var stepper = [[CPStepper alloc] initWithFrame:CGRectMakeZero()];
var stepper = [[self alloc] initWithFrame:CGRectMakeZero()];
[stepper setDoubleValue:aValue];
[stepper setMinValue:aMinValue];
@@ -75,14 +74,14 @@
@return Initialized CPStepper
*/
+ (CPStepper)stepper
+ (id)stepper
{
return [CPStepper stepperWithInitialValue:0.0 minValue:0.0 maxValue:59.0];
}
+ (Class)_binderClassForBinding:(CPString)aBinding
{
if (aBinding == CPValueBinding || aBinding == CPMinValueBinding || aBinding == CPMaxValueBinding)
if (aBinding === CPValueBinding || aBinding === CPMinValueBinding || aBinding === CPMaxValueBinding)
return [_CPStepperValueBinder class];
return [super _binderClassForBinding:aBinding];
@@ -90,7 +89,7 @@
- (CPString)_replacementKeyPathForBinding:(CPString)aBinding
{
if (aBinding == CPValueBinding)
if (aBinding === CPValueBinding)
return @"doubleValue";
return [super _replacementKeyPathForBinding:aBinding];
@@ -138,9 +137,16 @@
[self setContinuous:_autorepeat];
[self addSubview:_buttonDown];
[self _sizeToFit];
[self setNeedsLayout];
}
- (void)setControlSize:(CPControlSize)aControlSize
{
[super setControlSize:aControlSize];
[self _sizeToFit];
}
#pragma mark -
#pragma mark Superclass overrides
@@ -159,8 +165,8 @@
- (void)setFrame:(CGRect)aFrame
{
var upSize = [self valueForThemeAttribute:@"up-button-size"],
downSize = [self valueForThemeAttribute:@"down-button-size"],
var upSize = [self currentValueForThemeAttribute:@"up-button-size"],
downSize = [self currentValueForThemeAttribute:@"down-button-size"],
minSize = CGSizeMake(upSize.width, upSize.height + downSize.height),
frame = CGRectMakeCopy(aFrame);
@@ -172,21 +178,22 @@
/*! @ignore */
- (void)layoutSubviews
{
var aFrame = [self frame],
upSize = [self valueForThemeAttribute:@"up-button-size"],
downSize = [self valueForThemeAttribute:@"down-button-size"],
upFrame = CGRectMake(aFrame.size.width - upSize.width, 0, upSize.width, upSize.height),
downFrame = CGRectMake(aFrame.size.width - downSize.width, upSize.height, downSize.width, downSize.height);
var controlSizeThemeState = [self _controlSizeThemeState],
aFrame = [self frame],
upSize = [self valueForThemeAttribute:@"up-button-size" inState:controlSizeThemeState],
downSize = [self valueForThemeAttribute:@"down-button-size" inState:controlSizeThemeState],
upFrame = CGRectMake(0, 0, upSize.width, upSize.height),
downFrame = CGRectMake(0, upSize.height, downSize.width, downSize.height);
[_buttonUp setFrame:upFrame];
[_buttonDown setFrame:downFrame];
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:CPThemeStateBordered] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:CPThemeStateBordered | CPThemeStateDisabled] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateDisabled];
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:CPThemeStateBordered | CPThemeStateHighlighted] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateHighlighted];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:CPThemeStateBordered] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:CPThemeStateBordered | CPThemeStateDisabled] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateDisabled];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:CPThemeStateBordered | CPThemeStateHighlighted] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateHighlighted];
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inStates:[controlSizeThemeState, CPThemeStateBordered]] forThemeAttribute:@"bezel-color" inStates:[CPThemeStateBordered, CPButtonStateBezelStyleRoundRect]];
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inStates:[controlSizeThemeState, CPThemeStateBordered, CPThemeStateDisabled]] forThemeAttribute:@"bezel-color" inStates:[CPThemeStateBordered, CPThemeStateDisabled, CPButtonStateBezelStyleRoundRect]];
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inStates:[controlSizeThemeState, CPThemeStateBordered, CPThemeStateHighlighted]] forThemeAttribute:@"bezel-color" inStates:[CPThemeStateBordered, CPThemeStateHighlighted, CPButtonStateBezelStyleRoundRect]];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inStates:[controlSizeThemeState, CPThemeStateBordered]] forThemeAttribute:@"bezel-color" inStates:[CPThemeStateBordered, CPButtonStateBezelStyleRoundRect]];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inStates:[controlSizeThemeState, CPThemeStateBordered, CPThemeStateDisabled]] forThemeAttribute:@"bezel-color" inStates:[CPThemeStateBordered, CPThemeStateDisabled, CPButtonStateBezelStyleRoundRect]];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inStates:[controlSizeThemeState, CPThemeStateBordered, CPThemeStateHighlighted]] forThemeAttribute:@"bezel-color" inStates:[CPThemeStateBordered, CPThemeStateHighlighted, CPButtonStateBezelStyleRoundRect]];
}
- (void)_sizeToFit
@@ -213,7 +220,7 @@
Set the current value of the stepper.
@param aValue a float containing the value
*/
- (void)setDoubleValue:(float)aValue
- (void)setDoubleValue:(double)aValue
{
if (aValue > _maxValue)
[super setDoubleValue:_valueWraps ? _minValue : _maxValue];
@@ -232,7 +239,7 @@
if (![self isEnabled])
return;
if (aSender == _buttonUp)
if (aSender === _buttonUp)
[self setDoubleValue:([self doubleValue] + _increment)];
else
[self setDoubleValue:([self doubleValue] - _increment)];
@@ -267,7 +274,7 @@
return @"stepper";
}
+ (id)themeAttributes
+ (CPDictionary)themeAttributes
{
return @{
@"bezel-color-up-button": [CPNull null],
@@ -285,7 +292,7 @@
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options forBinding:(CPString)aBinding
{
var placeholder = (aBinding == CPMaxValueBinding) ? [_source maxValue] : [_source minValue];
var placeholder = (aBinding === CPMaxValueBinding) ? [_source maxValue] : [_source minValue];
[super _updatePlaceholdersWithOptions:options];
@@ -316,6 +323,7 @@ var CPStepperMinValue = @"CPStepperMinValue",
_autorepeat = [aCoder decodeBoolForKey:CPStepperAutorepeat];
[self _init];
[self setEnabled:[self isEnabled]];
}
return self;
+59 -9
View File
@@ -24,11 +24,15 @@
@import "CGGeometry.j"
@import "CPPlatformString.j"
@import "CPFont.j"
@import "CPCompatibility.j"
var CPStringSizeWithFontInWidthCache = {};
var CPStringSizeWithFontInWidthCache = [],
CPStringSizeWithFontHeightCache = [],
CPStringSizeMeasuringContext;
CPStringSizeCachingEnabled = YES;
CPCanvasStringSizingIsFunctional = NO;
@implementation CPString (CPStringDrawing)
@@ -53,20 +57,66 @@ CPStringSizeCachingEnabled = YES;
return [self sizeWithFont:aFont inWidth:NULL];
}
+ (void) initialize
{
if ([self class] != [CPString class])
return;
#if PLATFORM(DOM)
if (CPFeatureIsCompatible(CPHTMLCanvasFeature))
{
if (!CPStringSizeMeasuringContext)
CPStringSizeMeasuringContext = CGBitmapGraphicsContextCreate();
// This is to make sure that Canvas based string sizing is functional before we use it.
// Currently, Chrome has issues with certain strings, FF had issues in the past.
// Unfortunately, this test does fit in CPCompatibility.j where things are not sufficiently initialized.
var testingFont = [CPFont systemFontOfSize:12];
var testingText = 'A A A A A A A A';
CPStringSizeMeasuringContext.font = [testingFont cssString];
CPCanvasStringSizingIsFunctional = ROUND(CPStringSizeMeasuringContext.measureText(testingText).width) == ROUND([CPPlatformString sizeOfString:testingText withFont:testingFont forWidth:NULL].width);
}
#endif
}
- (CGSize)sizeWithFont:(CPFont)aFont inWidth:(float)aWidth
{
if (!CPStringSizeCachingEnabled)
return [CPPlatformString sizeOfString:self withFont:aFont forWidth:aWidth];
var size;
var cacheKey = self + [aFont cssString] + aWidth,
size = CPStringSizeWithFontInWidthCache[cacheKey];
#if PLATFORM(DOM)
var sizeCacheForFont = CPStringSizeWithFontInWidthCache[self];
if (size === undefined)
{
if (sizeCacheForFont === undefined)
sizeCacheForFont = CPStringSizeWithFontInWidthCache[self] = [];
var cssString = [aFont cssString],
cacheKey = cssString + '_' + (aWidth ? aWidth : '0');
size = sizeCacheForFont[cacheKey];
if (size !== undefined && sizeCacheForFont.hasOwnProperty(cacheKey))
return CGSizeMakeCopy(size);
if (!CPCanvasStringSizingIsFunctional || aWidth)
size = [CPPlatformString sizeOfString:self withFont:aFont forWidth:aWidth];
CPStringSizeWithFontInWidthCache[cacheKey] = size;
else
{
if (CPPlatformHasBug(CPTextSizingAlwaysNeedsSetFontBug) || CPStringSizeMeasuringContext.font !== cssString)
CPStringSizeMeasuringContext.font = cssString;
var fontHeight = CPStringSizeWithFontHeightCache[cssString];
if (fontHeight === undefined)
fontHeight = CPStringSizeWithFontHeightCache[cssString] = [aFont defaultLineHeightForFont];
size = CGSizeMake(CPStringSizeMeasuringContext.measureText(self).width, fontHeight);
}
sizeCacheForFont[cacheKey] = size;
#else
size = CGSizeMake(0, 0);
#endif
return CGSizeMakeCopy(size);
}
+610 -110
View File
@@ -25,6 +25,7 @@
@import "CPTabViewItem.j"
@import "CPView.j"
@typedef CPTabViewType
CPTopTabsBezelBorder = 0;
//CPLeftTabsBezelBorder = 1;
CPBottomTabsBezelBorder = 2;
@@ -33,10 +34,25 @@ CPNoTabsBezelBorder = 4; //Displays no tabs and has a bezeled border.
CPNoTabsLineBorder = 5; //Has no tabs and displays a line border.
CPNoTabsNoBorder = 6; //Displays no tabs and no border.
var CPTabViewDidSelectTabViewItemSelector = 1,
CPTabViewShouldSelectTabViewItemSelector = 2,
CPTabViewWillSelectTabViewItemSelector = 4,
CPTabViewDidChangeNumberOfTabViewItemsSelector = 8;
@class _CPTabViewBox
@class _CPSegmentedControl
var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
CPTabViewShouldSelectTabViewItemSelector = 1 << 2,
CPTabViewWillSelectTabViewItemSelector = 1 << 3,
CPTabViewDidChangeNumberOfTabViewItemsSelector = 1 << 4;
@protocol CPTabViewDelegate <CPObject>
@optional
- (BOOL)tabView:(CPTabView)tabView shouldSelectTabViewItem:(CPTabViewItem)tabViewItem;
- (void)tabView:(CPTabView)tabView didSelectTabViewItem:(CPTabViewItem)tabViewItem;
- (void)tabView:(CPTabView)tabView willSelectTabViewItem:(CPTabViewItem)tabViewItem;
- (void)tabViewDidChangeNumberOfTabViewItems:(CPTabView)tabView;
@end
/*!
@ingroup appkit
@@ -48,27 +64,41 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
*/
@implementation CPTabView : CPView
{
CPArray _items;
CPArray _items;
CPSegmentedControl _tabs;
CPBox _box;
_CPSegmentedControl _tabs;
_CPTabViewBox _box;
CPView _placeholderView @accessors;
CPNumber _selectedIndex;
CPTabViewItem _selectedTabViewItem;
CPTabViewType _type;
CPFont _font;
CPTabViewType _type;
CPFont _font;
id _delegate;
unsigned _delegateSelectors;
id <CPTabViewDelegate> _delegate;
unsigned _delegateSelectors;
}
+ (CPString)defaultThemeClass
{
return @"tab-view";
}
+ (CPDictionary)themeAttributes
{
return @{
@"nib2cib-adjustment-frame": [CPNull null],
@"should-center-on-border": NO,
@"box-content-inset": CGInsetMakeZero()
};
}
- (id)initWithFrame:(CGRect)aFrame
{
if (self = [super initWithFrame:aFrame])
{
_items = [CPArray array];
[self _init];
_selectedTabViewItem = nil;
[self setTabViewType:CPTopTabsBezelBorder];
}
@@ -77,19 +107,30 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
- (void)_init
{
_selectedIndex = CPNotFound;
_tabs = [[CPSegmentedControl alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
_tabs = [[_CPSegmentedControl alloc] initWithFrame:CGRectMakeZero()];
[_tabs setTabView:self];
[_tabs setHitTests:NO];
[_tabs setSegments:[CPArray array]];
[_tabs setAction:@selector(_reflectSelectedTab:)];
[_tabs setTarget:self];
var height = [_tabs valueForThemeAttribute:@"default-height"];
var height = [_tabs valueForThemeAttribute:@"min-size"].height;
[_tabs setFrameSize:CGSizeMake(0, height)];
_box = [[CPBox alloc] initWithFrame:[self bounds]];
[self setBackgroundColor:[CPColor colorWithCalibratedWhite:0.95 alpha:1.0]];
_box = [[_CPTabViewBox alloc] initWithFrame:[self bounds]];
[_box setTabView:self];
[_box setContentInset:[self currentValueForThemeAttribute:@"box-content-inset"]];
[_box setContentViewMargins:CGSizeMakeZero()];
[self addSubview:_box];
[self addSubview:_tabs];
_placeholderView = nil;
}
- (CPArray)items
{
return [_tabs segments];
}
// Adding and Removing Tabs
@@ -99,7 +140,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
*/
- (void)addTabViewItem:(CPTabViewItem)aTabViewItem
{
[self insertTabViewItem:aTabViewItem atIndex:[_items count]];
[self insertTabViewItem:aTabViewItem atIndex:[self numberOfTabViewItems]];
}
/*!
@@ -107,17 +148,26 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
@param aTabViewItem the item to insert
@param anIndex the index for the item
*/
- (void)insertTabViewItem:(CPTabViewItem)aTabViewItem atIndex:(unsigned)anIndex
- (void)insertTabViewItem:(CPTabViewItem)aTabViewItem atIndex:(CPUInteger)anIndex
{
[_items insertObject:aTabViewItem atIndex:anIndex];
[self _insertTabViewItems:[aTabViewItem] atIndexes:[CPIndexSet indexSetWithIndex:anIndex] canUpdateSelectedTab:YES];
}
[self _updateItems];
[self _repositionTabs];
- (void)_insertTabViewItems:(CPArray)tabViewItems atIndexes:(CPIndexSet)indexes canUpdateSelectedTab:(BOOL)canUpdateSelectedTab
{
var prevItemsCount = [self numberOfTabViewItems];
[aTabViewItem _setTabView:self];
[_tabs insertSegments:tabViewItems atIndexes:indexes];
[tabViewItems makeObjectsPerformSelector:@selector(_setTabView:) withObject:self];
if (_delegateSelectors & CPTabViewDidChangeNumberOfTabViewItemsSelector)
[_delegate tabViewDidChangeNumberOfTabViewItems:self];
[self tileWithChangedItem:[tabViewItems firstObject]];
[self _reverseSetContent];
[self _sendDelegateTabViewDidChangeNumberOfTabViewItems];
// Do not allow empty selection if selection bindings are not enabled.
if (prevItemsCount == 0 && [self numberOfTabViewItems] > 0 && ![self _isSelectionBinded] && canUpdateSelectedTab)
[self _selectTabViewItemAtIndex:0];
}
/*!
@@ -126,23 +176,39 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
*/
- (void)removeTabViewItem:(CPTabViewItem)aTabViewItem
{
var count = [_items count];
for (var i = 0; i < count; i++)
{
if ([_items objectAtIndex:i] === aTabViewItem)
{
[_items removeObjectAtIndex:i];
break;
}
}
var idx = [[self items] indexOfObjectIdenticalTo:aTabViewItem];
[self _updateItems];
[self _repositionTabs];
if (idx == CPNotFound)
return;
[_tabs removeSegmentsAtIndexes:[CPIndexSet indexSetWithIndex:idx]];
[aTabViewItem _setTabView:nil];
if (_delegateSelectors & CPTabViewDidChangeNumberOfTabViewItemsSelector)
[_delegate tabViewDidChangeNumberOfTabViewItems:self];
[self tileWithChangedItem:nil];
[self _didRemoveTabViewItem:aTabViewItem atIndex:idx];
[self _reverseSetContent];
[self _sendDelegateTabViewDidChangeNumberOfTabViewItems];
}
- (void)_didRemoveTabViewItem:(CPTabViewItem)aTabViewItem atIndex:(CPInteger)idx
{
// If the selection is managed by bindings, let the binder do that.
if ([self _isSelectionBinded])
return;
if (_selectedTabViewItem == aTabViewItem)
{
var didSelect = NO;
if (idx > 0)
didSelect = [self selectTabViewItemAtIndex:idx - 1];
else if ([self numberOfTabViewItems] > 0)
didSelect = [self selectTabViewItemAtIndex:0];
if (didSelect == NO)
_selectedTabViewItem == nil;
}
}
// Accessing Tabs
@@ -153,7 +219,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
*/
- (int)indexOfTabViewItem:(CPTabViewItem)aTabViewItem
{
return [_items indexOfObjectIdenticalTo:aTabViewItem];
return [[self items] indexOfObjectIdenticalTo:aTabViewItem];
}
/*!
@@ -163,11 +229,10 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
*/
- (int)indexOfTabViewItemWithIdentifier:(CPString)anIdentifier
{
for (var index = [_items count]; index >= 0; index--)
if ([[_items[index] identifier] isEqual:anIdentifier])
return index;
return CPNotFound;
return [[self items] indexOfObjectPassingTest:function(item, idx, stop)
{
return [[item identifier] isEqual:anIdentifier];
}];
}
/*!
@@ -176,16 +241,16 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
*/
- (unsigned)numberOfTabViewItems
{
return [_items count];
return [[self items] count];
}
/*!
Returns the CPTabViewItem at the specified index.
@return a tab view item, or nil
*/
- (CPTabViewItem)tabViewItemAtIndex:(unsigned)anIndex
- (CPTabViewItem)tabViewItemAtIndex:(CPUInteger)anIndex
{
return [_items objectAtIndex:anIndex];
return [[self items] objectAtIndex:anIndex];
}
/*!
@@ -194,7 +259,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
*/
- (CPArray)tabViewItems
{
return [_items copy]; // Copy?
return [[self items] copy]; // Copy?
}
// Selecting a Tab
@@ -204,7 +269,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
*/
- (void)selectFirstTabViewItem:(id)aSender
{
if ([_items count] === 0)
if ([self numberOfTabViewItems] === 0)
return; // throw?
[self selectTabViewItemAtIndex:0];
@@ -216,10 +281,10 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
*/
- (void)selectLastTabViewItem:(id)aSender
{
if ([_items count] === 0)
if ([self numberOfTabViewItems] === 0)
return; // throw?
[self selectTabViewItemAtIndex:[_items count] - 1];
[self selectTabViewItemAtIndex:[self numberOfTabViewItems] - 1];
}
/*!
@@ -228,12 +293,12 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
*/
- (void)selectNextTabViewItem:(id)aSender
{
if (_selectedIndex === CPNotFound)
if (_selectedTabViewItem == nil)
return;
var nextIndex = _selectedIndex + 1;
var nextIndex = [self indexOfTabViewItem:_selectedTabViewItem] + 1;
if (nextIndex === [_items count])
if (nextIndex === [self numberOfTabViewItems])
// does nothing. According to spec at (http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Reference/ApplicationKit/Classes/NSTabView_Class/Reference/Reference.html#//apple_ref/occ/instm/NSTabView/selectNextTabViewItem:)
return;
@@ -246,10 +311,10 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
*/
- (void)selectPreviousTabViewItem:(id)aSender
{
if (_selectedIndex === CPNotFound)
if (_selectedTabViewItem == nil)
return;
var previousIndex = _selectedIndex - 1;
var previousIndex = [self indexOfTabViewItem:_selectedTabViewItem] - 1;
if (previousIndex < 0)
return; // does nothing. See above.
@@ -270,38 +335,72 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
Selects the item at the specified index.
@param anIndex the index of the item to display.
*/
- (BOOL)selectTabViewItemAtIndex:(unsigned)anIndex
- (BOOL)selectTabViewItemAtIndex:(CPUInteger)anIndex
{
if (anIndex === _selectedIndex)
return;
var aTabViewItem = [self tabViewItemAtIndex:anIndex];
if ((_delegateSelectors & CPTabViewShouldSelectTabViewItemSelector) && ![_delegate tabView:self shouldSelectTabViewItem:aTabViewItem])
if (![self _selectTabViewItemAtIndex:anIndex])
return NO;
if (_delegateSelectors & CPTabViewWillSelectTabViewItemSelector)
[_delegate tabView:self willSelectTabViewItem:aTabViewItem];
[_tabs selectSegmentWithTag:anIndex];
[self _setSelectedIndex:anIndex];
if (_delegateSelectors & CPTabViewDidSelectTabViewItemSelector)
[_delegate tabView:self didSelectTabViewItem:aTabViewItem];
[self _reverseSetSelectedIndex];
return YES;
}
// Like selectTabViewItemAtIndex: but without bindings interaction
- (BOOL)_selectTabViewItemAtIndex:(CPUInteger)anIndex
{
var aTabViewItem = [self tabViewItemAtIndex:anIndex];
if (aTabViewItem == _selectedTabViewItem)
return NO;
if (![self _sendDelegateShouldSelectTabViewItem:aTabViewItem])
return NO;
[self _sendDelegateWillSelectTabViewItem:aTabViewItem];
[_tabs setSelectedSegment:anIndex];
_selectedTabViewItem = aTabViewItem;
[self _loadTabViewItem:aTabViewItem];
[self _sendDelegateDidSelectTabViewItem:aTabViewItem];
return YES;
}
- (void)_loadTabViewItem:(CPTabViewItem)aTabViewItem
{
var controller = [aTabViewItem viewController];
if (controller != nil && ![controller isViewLoaded])
{
[controller loadViewWithCompletionHandler:function(view, error)
{
if (error != nil)
{
CPLog.warn("Could not load the view for item " + aTabViewItem + ". " + error);
}
else if (view != nil)
{
[aTabViewItem setView:view];
if ([self selectedTabViewItem] == aTabViewItem)
[self _displayItemView:view];
}
}];
}
else
{
[self _displayItemView:[aTabViewItem view]];
}
}
/*!
Returns the current item being displayed.
@return the tab view item currenly being displayed by the receiver
*/
- (CPTabViewItem)selectedTabViewItem
{
if (_selectedIndex != CPNotFound)
return [_items objectAtIndex:_selectedIndex];
return nil;
return _selectedTabViewItem;
}
// Modifying the font
@@ -362,6 +461,14 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
[self setNeedsLayout];
}
- (void)tileWithChangedItem:(CPTabViewItem)aTabViewItem
{
var segment = aTabViewItem ? [self indexOfTabViewItem:aTabViewItem] : 0;
[_tabs tileWithChangedSegment:segment];
[self setNeedsLayout];
}
- (void)layoutSubviews
{
// Even if CPTabView's autoresizesSubviews is NO, _tabs and _box has to be laid out.
@@ -374,10 +481,10 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
{
var aFrame = [self frame],
segmentedHeight = CGRectGetHeight([_tabs frame]),
origin = _type === CPTopTabsBezelBorder ? segmentedHeight / 2 : 0;
borderWidth = [self currentValueForThemeAttribute:@"should-center-on-border"] ? [_box borderWidth] : 0,
origin = _type === CPTopTabsBezelBorder ? (segmentedHeight - borderWidth) / 2 : 0;
[_box setFrame:CGRectMake(0, origin, CGRectGetWidth(aFrame),
CGRectGetHeight(aFrame) - segmentedHeight / 2)];
[_box setFrame:CGRectMake(0, origin, CGRectGetWidth(aFrame), CGRectGetHeight(aFrame) - (segmentedHeight - borderWidth) / 2)];
[self _repositionTabs];
}
@@ -405,7 +512,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
Sets the delegate for this tab view.
@param aDelegate the tab view's delegate
*/
- (void)setDelegate:(id)aDelegate
- (void)setDelegate:(id <CPTabViewDelegate>)aDelegate
{
if (_delegate == aDelegate)
return;
@@ -439,10 +546,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
- (void)mouseDown:(CPEvent)anEvent
{
var segmentIndex = [_tabs testSegment:[_tabs convertPoint:[anEvent locationInWindow] fromView:nil]];
if (segmentIndex != CPNotFound && [self selectTabViewItemAtIndex:segmentIndex])
[_tabs trackSegment:anEvent];
[_tabs trackSegment:anEvent];
}
- (void)_repositionTabs
@@ -456,30 +560,248 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
[_tabs setCenter:CGPointMake(horizontalCenterOfSelf, verticalCenterOfTabs)];
}
- (void)_setSelectedIndex:(CPNumber)index
- (void)_displayItemView:(CPView)aView
{
_selectedIndex = index;
[self _setContentViewFromItem:[_items objectAtIndex:_selectedIndex]];
[_box setContentView:aView];
}
- (void)_setContentViewFromItem:(CPTabViewItem)anItem
- (void)_reflectSelectedTab:(id)aSender
{
[_box setContentView:[anItem view]];
[self selectTabViewItemAtIndex:[_tabs selectedSegment]];
}
- (void)_updateItems
{
var count = [_items count];
[_tabs setSegmentCount:count];
// DELEGATE METHODS
for (var i = 0; i < count; i++)
- (BOOL)_sendDelegateShouldSelectTabViewItem:(CPTabViewItem)aTabViewItem
{
if (_delegateSelectors & CPTabViewShouldSelectTabViewItemSelector)
return [_delegate tabView:self shouldSelectTabViewItem:aTabViewItem];
return YES;
}
- (void)_sendDelegateWillSelectTabViewItem:(CPTabViewItem)aTabViewItem
{
if (_delegateSelectors & CPTabViewWillSelectTabViewItemSelector)
[_delegate tabView:self willSelectTabViewItem:aTabViewItem];
}
- (void)_sendDelegateDidSelectTabViewItem:(CPTabViewItem)aTabViewItem
{
if (_delegateSelectors & CPTabViewDidSelectTabViewItemSelector)
[_delegate tabView:self didSelectTabViewItem:aTabViewItem];
}
- (void)_sendDelegateTabViewDidChangeNumberOfTabViewItems
{
if (_delegateSelectors & CPTabViewDidChangeNumberOfTabViewItemsSelector)
[_delegate tabViewDidChangeNumberOfTabViewItems:self];
}
@end
@implementation CPTabView (BindingSupport)
+ (Class)_binderClassForBinding:(CPString)aBinding
{
if (aBinding == CPContentBinding)
return [_CPTabViewContentBinder class];
else if (aBinding == CPSelectionIndexesBinding || aBinding == CPSelectedIndexBinding)
return [_CPTabViewSelectionBinder class];
return [super _binderClassForBinding:aBinding];
}
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return (aBinding == CPSelectionIndexesBinding || aBinding == CPSelectedIndexBinding);
}
- (void)_reverseSetContent
{
var theBinder = [self binderForBinding:CPContentBinding];
[theBinder reverseSetValueFor:@"items"];
}
- (void)_reverseSetSelectedIndex
{
var theBinder = [self binderForBinding:CPSelectionIndexesBinding];
if (theBinder != nil)
[theBinder reverseSetValueFor:@"selectionIndexes"];
else
{
[_tabs setLabel:[[_items objectAtIndex:i] label] forSegment:i];
[_tabs setTag:i forSegment:i];
theBinder = [self binderForBinding:CPSelectedIndexBinding];
[theBinder reverseSetValueFor:@"selectedIndex"];
}
}
- (CPBinder)binderForBinding:(CPString)aBinding
{
var cls = [[self class] _binderClassForBinding:aBinding];
return [cls getBinding:aBinding forObject:self];
}
- (BOOL)_isSelectionBinded
{
return [self binderForBinding:CPSelectionIndexesBinding] || [self binderForBinding:CPSelectedIndexBinding];
}
- (void)setItems:(CPArray)tabViewItems
{
if ([tabViewItems isEqualToArray:[_tabs segments]])
return;
[[self items] makeObjectsPerformSelector:@selector(_setTabView:) withObject:nil];
[_tabs setSegments:tabViewItems];
[tabViewItems makeObjectsPerformSelector:@selector(_setTabView:) withObject:self];
[self tileWithChangedItem:nil];
// Update the selection because setSegments: did remove all previous segments AND the selection.
[_tabs setSelectedSegment:[self indexOfTabViewItem:_selectedTabViewItem]];
// should we send delegate methods in bindings mode ?
//[self _delegateTabViewDidChangeNumberOfTabViewItems:self];
}
- (void)_deselectAll
{
[_tabs setSelectedSegment:-1];
_selectedTabViewItem = nil;
}
- (void)_displayPlaceholder:(CPString)aPlaceholder
{
if (_placeholderView == nil)
{
_placeholderView = [[CPView alloc] initWithFrame:CGRectMakeZero()];
var textField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[textField setTag:1000];
[textField setTextColor:[CPColor whiteColor]];
[textField setFont:[CPFont boldFontWithName:@"Geneva" size:18 italic:YES]];
[_placeholderView addSubview:textField];
}
if (_selectedIndex === CPNotFound)
[self selectFirstTabViewItem:self];
var textField = [_placeholderView viewWithTag:1000];
[textField setStringValue:aPlaceholder];
[textField sizeToFit];
var boxBounds = [_box bounds],
textFieldBounds = [textField bounds],
origin = CGPointMake(CGRectGetWidth(boxBounds)/2 - CGRectGetWidth(textFieldBounds)/2, CGRectGetHeight(boxBounds)/2 - CGRectGetHeight(textFieldBounds));
[textField setFrameOrigin:origin];
[self _displayItemView:_placeholderView];
}
#pragma mark -
#pragma mark Override
/*!
Enabled controls accept first mouse by default.
*/
- (BOOL)acceptsFirstMouse:(CPEvent)anEvent
{
return YES;
}
@end
var _CPTabViewContentBinderNull = @"NO CONTENT";
@implementation _CPTabViewContentBinder : CPBinder
{
}
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options
{
[super _updatePlaceholdersWithOptions:options];
[self _setPlaceholder:_CPTabViewContentBinderNull forMarker:CPNullMarker isDefault:YES];
}
- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding
{
[_source setItems:@[]];
[_source _setPlaceholderView:aValue];
}
- (void)setValue:(id)aValue forBinding:(CPString)aBinding
{
[_source setItems:aValue];
}
- (id)valueForBinding:(CPString)aBinding
{
return [_source items];
}
@end
var _CPTabViewSelectionBinderMultipleValues = @"Multiple Selection",
_CPTabViewSelectionBinderNoSelection = @"No Selection";
@implementation _CPTabViewSelectionBinder : CPBinder
{
}
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options
{
[super _updatePlaceholdersWithOptions:options];
[self _setPlaceholder:_CPTabViewSelectionBinderMultipleValues forMarker:CPMultipleValuesMarker isDefault:YES];
[self _setPlaceholder:_CPTabViewSelectionBinderNoSelection forMarker:CPNoSelectionMarker isDefault:YES];
}
- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding
{
if (aMarker == CPNoSelectionMarker || aMarker == CPNullMarker)
[_source _deselectAll];
[_source _displayPlaceholder:aValue];
}
- (void)setValue:(id)aValue forBinding:(CPString)aBinding
{
if (aBinding == CPSelectionIndexesBinding)
{
if (aValue == nil || [aValue count] == 0)
{
[_source _deselectAll];
[_source _displayPlaceholder:_CPTabViewSelectionBinderNoSelection];
}
else if ([aValue count] > 1)
[_source _displayPlaceholder:_CPTabViewSelectionBinderMultipleValues];
else if ([aValue firstIndex] < [_source numberOfTabViewItems])
[_source _selectTabViewItemAtIndex:[aValue firstIndex]];
}
else if (aBinding == CPSelectedIndexBinding)
{
if (aValue == CPNotFound)
{
[_source _deselectAll];
[_source _displayPlaceholder:_CPTabViewSelectionBinderNoSelection];
}
else if (aValue < [_source numberOfTabViewItems])
[_source _selectTabViewItemAtIndex:aValue];
}
}
- (id)valueForBinding:(CPString)aBinding
{
if (aBinding == CPSelectionIndexesBinding)
{
var result = [CPIndexSet indexSet],
idx = [_source indexOfTabViewItem:[_source selectedTabViewItem]];
if (idx !== CPNotFound)
[result addIndex:idx];
return result;
}
else if (aBinding == CPSelectedIndexBinding)
return [_source indexOfTabViewItem:[_source selectedTabViewItem]];
}
@end
@@ -501,12 +823,13 @@ var CPTabViewItemsKey = "CPTabViewItemsKey",
_font = [aCoder decodeObjectForKey:CPTabViewFontKey];
[_tabs setFont:_font];
_items = [aCoder decodeObjectForKey:CPTabViewItemsKey];
[_items makeObjectsPerformSelector:@selector(_setTabView:) withObject:self];
var items = [aCoder decodeObjectForKey:CPTabViewItemsKey] || [CPArray array];
[self _insertTabViewItems:items atIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [items count])] canUpdateSelectedTab:NO];
[self setDelegate:[aCoder decodeObjectForKey:CPTabViewDelegateKey]];
self.selectOnAwake = [aCoder decodeObjectForKey:CPTabViewSelectedItemKey];
_selectedTabViewItem = [aCoder decodeObjectForKey:CPTabViewSelectedItemKey];
_type = [aCoder decodeIntForKey:CPTabViewTypeKey];
}
@@ -515,14 +838,23 @@ var CPTabViewItemsKey = "CPTabViewItemsKey",
- (void)awakeFromCib
{
[super awakeFromCib];
// This cannot be run in initWithCoder because it might call selectTabViewItem:, which is
// not safe to call before the views of the tab views items are fully decoded.
[self _updateItems];
if (self.selectOnAwake)
if (_selectedTabViewItem)
{
[self selectTabViewItem:self.selectOnAwake];
delete self.selectOnAwake;
var idx = [self indexOfTabViewItem:_selectedTabViewItem];
if (idx !== CPNotFound)
{
// Temporarily set the selected item to not selected.
// It allows the initial selection to be made correctly.
_selectedTabViewItem = nil;
[self selectTabViewItemAtIndex:idx];
}
}
var type = _type;
@@ -544,9 +876,7 @@ var CPTabViewItemsKey = "CPTabViewItemsKey",
[aCoder encodeObject:_items forKey:CPTabViewItemsKey];
var selected = [self selectedTabViewItem];
if (selected)
[aCoder encodeObject:selected forKey:CPTabViewSelectedItemKey];
[aCoder encodeConditionalObject:_selectedTabViewItem forKey:CPTabViewSelectedItemKey];
[aCoder encodeInt:_type forKey:CPTabViewTypeKey];
[aCoder encodeObject:_font forKey:CPTabViewFontKey];
@@ -555,3 +885,173 @@ var CPTabViewItemsKey = "CPTabViewItemsKey",
}
@end
#pragma mark -
@implementation CPTabView (CSSTheming)
#pragma mark Override
- (void)_setThemeIncludingDescendants:(CPTheme)aTheme
{
[self setTheme:aTheme];
[[self subviews] makeObjectsPerformSelector:@selector(_setThemeIncludingDescendants:) withObject:aTheme];
// Items must also perform this (without this, only the selected item does)
for (var i = 0, allItems = [self items], count = allItems.length; i < count; i++)
if (allItems[i] != _selectedTabViewItem)
[[allItems[i] view] _setThemeIncludingDescendants:aTheme];
}
@end
#pragma mark -
@implementation _CPTabViewBox : CPBox
{
CPTabView _tabView @accessors(property=tabView);
CGInset _contentInset @accessors(property=contentInset);
}
#pragma mark -
#pragma mark Override
- (id)initWithFrame:(CGRect)aFrame
{
if (self = [super initWithFrame:aFrame])
{
[self setBoxType:CPBoxPrimary];
}
return self;
}
- (CPView)hitTest:(CGPoint)aPoint
{
// Here we check if we have clicked on the segmentedControl of the tabView or not
// If YES, the CPBox should not handle the click
var segmentIndex = [_tabView._tabs testSegment:[_tabView._tabs convertPoint:aPoint fromView:[self superview]]];
if (segmentIndex != CPNotFound)
return nil;
return [super hitTest:aPoint];
}
// Some CPBox overrides because CPTabView use of CPBox differs from legacy CPBox regarding layout.
- (void)setContentView:(CPView)aView
{
if (aView === _contentView)
return;
if (_contentInset)
[aView setFrame:CGRectInsetByInset([self bounds], _contentInset)];
[aView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
// A nil contentView is allowed (tested in Cocoa 2013-02-22).
if (!aView)
[_contentView removeFromSuperview];
else if (_contentView)
[_boxView replaceSubview:_contentView with:aView];
else
[_boxView addSubview:aView];
_contentView = aView;
[self refreshDisplay];
}
- (void)sizeToFit
{
var offset = [self _titleHeightOffset],
size = [self frameSize];
[_boxView setFrame:CGRectMake(0, offset[1], size.width, size.height - offset[0])];
if (!_contentView)
return;
var boxSize = [_boxView frameSize];
if (_contentInset)
[_contentView setFrame:CGRectMake(_contentInset.left, _contentInset.top, boxSize.width - _contentInset.left - _contentInset.right, boxSize.height - _contentInset.top - _contentInset.bottom)];
}
@end
# pragma mark -
// This subclass of CPSegmentedControl implements specific behaviour needed by CPTabView, which
// differs in some ways from normal CPSegmentedControl habits :
//
// - all items are enabled
// - when you select a tab (mouse down, holding) and drag upon another tab, the second one reacts
// (showing a pushed state) and can then be selected by releasing the mouse over it.
// - a delegate has the opportunity to accept or not the selection of an item
@implementation _CPSegmentedControl : CPSegmentedControl
{
CPTabView _tabView @accessors(property=tabView);
}
- (void)trackSegment:(CPEvent)anEvent
{
var type = [anEvent type],
location = [self convertPoint:[anEvent locationInWindow] fromView:nil],
currentSegment = [self testSegment:location];
switch (type)
{
case CPLeftMouseUp:
if (_trackingSegment === CPNotFound)
return;
if ((_trackingSegment !== _selectedSegment) &&
[_tabView _sendDelegateShouldSelectTabViewItem:[_tabView tabViewItemAtIndex:_trackingSegment]])
{
[self setSelected:YES forSegment:_trackingSegment];
_selectedSegment = _trackingSegment;
[self sendAction:[self action] to:[self target]];
}
[self drawSegmentBezel:_trackingSegment highlight:NO];
_trackingSegment = CPNotFound;
return;
case CPLeftMouseDown:
if (currentSegment > CPNotFound)
{
_trackingSegment = currentSegment;
[self drawSegmentBezel:_trackingSegment highlight:YES];
}
break;
case CPLeftMouseDragged:
if (_trackingSegment !== currentSegment)
{
if (_trackingSegment > CPNotFound)
[self drawSegmentBezel:_trackingSegment highlight:NO];
_trackingSegment = currentSegment;
if (_trackingSegment > CPNotFound)
[self drawSegmentBezel:_trackingSegment highlight:YES];
}
break;
}
[CPApp setTarget:self selector:@selector(trackSegment:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES];
}
@end
+103 -10
View File
@@ -23,7 +23,8 @@
@import <Foundation/CPObject.j>
@import "CPView.j"
@class CPTabView
@class CPViewController
/*
The tab is currently selected.
@@ -53,14 +54,34 @@ CPPressedTab = 2;
*/
@implementation CPTabViewItem : CPObject
{
id _identifier;
CPString _label;
id _identifier;
CPString _label;
CPInteger _tag @accessors(property=tag);
CPView _view;
CPView _auxiliaryView;
CPView _view;
CPView _auxiliaryView;
CPTabView _tabView;
unsigned _tabState; // Looks like it is not yet implemented
CPTabView _tabView;
unsigned _tabState; // Looks like it is not yet implemented
CPImage _image @accessors(property=image);
CPViewController _viewController @accessors(getter=viewController);
BOOL _enabled @accessors(property=enabled);
BOOL _selected @accessors(property=selected);
CGRect _tabRect @accessors(property=frame);
float _width @accessors(property=width);
}
/*
*/
+ (CPTabViewItem)tabViewItemWithViewController:(CPViewController)aViewController
{
var item = [[CPTabViewItem alloc] init];
[item setViewController:aViewController];
return item;
}
- (id)init
@@ -68,6 +89,19 @@ CPPressedTab = 2;
return [self initWithIdentifier:@""];
}
- (void)_init
{
_tag = 0;
_viewController = nil;
_image = nil;
_tabState = 0;
_tabView = nil;
_enabled = YES;
_selected = NO;
_tabRect = CGRectMakeZero();
_width = 0;
}
/*!
Initializes the tab view item with the specified identifier.
@return the initialized CPTabViewItem
@@ -76,8 +110,12 @@ CPPressedTab = 2;
{
self = [super init];
if (self)
_identifier = anIdentifier;
[self _init];
_identifier = anIdentifier;
_label = nil;
_view = nil;
//_auxiliaryView = nil;
return self;
}
@@ -89,7 +127,11 @@ CPPressedTab = 2;
*/
- (void)setLabel:(CPString)aLabel
{
if ([aLabel isEqualToString:_label])
return;
_label = aLabel;
[_tabView tileWithChangedItem:self];
}
/*!
@@ -100,6 +142,28 @@ CPPressedTab = 2;
return _label;
}
// Working With Images
/*!
Sets the CPTabViewItem's image.
@param anImage the image for the item
*/
- (void)setImage:(CPImage)anImage
{
if ([anImage isEqual:_image])
return;
_image = anImage;
[_tabView tileWithChangedItem:self];
}
/*!
Returns the CPTabViewItem's image
*/
- (CPImage)image
{
return _image;
}
// Checking the Tab Display State
/*!
Returns the tab's current state.
@@ -139,7 +203,7 @@ CPPressedTab = 2;
_view = aView;
if ([_tabView selectedTabViewItem] == self)
[_tabView _setContentViewFromItem:self];
[_tabView _displayItemView:_view];
}
/*!
@@ -147,6 +211,9 @@ CPPressedTab = 2;
*/
- (CPView)view
{
if (!_view && _viewController)
return [_viewController view]; // The view controller loads here.
return _view;
}
@@ -185,10 +252,32 @@ CPPressedTab = 2;
_tabView = aView;
}
/*!
Sets the specified view controller for the tab view item.
@param aViewController an instance of CPViewController.
*/
- (void)setViewController:(CPViewController)aViewController
{
_viewController = aViewController;
var identifier = [aViewController cibName],
title = [_viewController title];
if (identifier)
_identifier = identifier;
if (title)
[self setLabel:title];
if ([_tabView selectedTabViewItem] == self)
[_tabView _loadTabViewItem:self];
}
@end
var CPTabViewItemIdentifierKey = "CPTabViewItemIdentifierKey",
CPTabViewItemLabelKey = "CPTabViewItemLabelKey",
CPTabViewItemImageKey = "CPTabViewItemImageKey",
CPTabViewItemViewKey = "CPTabViewItemViewKey",
CPTabViewItemAuxViewKey = "CPTabViewItemAuxViewKey";
@@ -201,8 +290,11 @@ var CPTabViewItemIdentifierKey = "CPTabViewItemIdentifierKey",
if (self)
{
[self _init];
_identifier = [aCoder decodeObjectForKey:CPTabViewItemIdentifierKey];
_label = [aCoder decodeObjectForKey:CPTabViewItemLabelKey];
_image = [aCoder decodeObjectForKey:CPTabViewItemImageKey];
_view = [aCoder decodeObjectForKey:CPTabViewItemViewKey];
_auxiliaryView = [aCoder decodeObjectForKey:CPTabViewItemAuxViewKey];
@@ -215,6 +307,7 @@ var CPTabViewItemIdentifierKey = "CPTabViewItemIdentifierKey",
{
[aCoder encodeObject:_identifier forKey:CPTabViewItemIdentifierKey];
[aCoder encodeObject:_label forKey:CPTabViewItemLabelKey];
[aCoder encodeObject:_image forKey:CPTabViewItemImageKey];
[aCoder encodeObject:_view forKey:CPTabViewItemViewKey];
[aCoder encodeObject:_auxiliaryView forKey:CPTabViewItemAuxViewKey];
+83 -32
View File
@@ -28,9 +28,8 @@
@import "CPTextField.j"
@global CPTableViewColumnDidResizeNotification
@class _CPTableColumnHeaderView
@class CPTableView
CPTableColumnNoResizing = 0;
CPTableColumnAutoresizingMask = 1 << 0;
@@ -181,11 +180,11 @@ CPTableColumnUserResizingMask = 1 << 1;
columns = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(index, [tableView._exposedColumns lastIndex] - index + 1)];
// FIXME: Would be faster with some sort of -setNeedsDisplayInColumns: that updates a dirtyTableColumnForDisplay cache; then marked columns would relayout their data views at display time.
[tableView _layoutDataViewsInRows:rows columns:columns];
[tableView _layoutViewsForRowIndexes:rows columnIndexes:columns];
[tableView tile];
if (!_disableResizingPosting)
[self _postDidResizeNotificationWithOldWidth:oldWidth];
[[self tableView] _didResizeTableColumn:self oldWidth:oldWidth];
}
}
@@ -288,7 +287,7 @@ CPTableColumnUserResizingMask = 1 << 1;
if (width < [self minWidth])
[self setMinWidth:width];
else if (width > [self maxWidth])
[self setMaxWidth:width]
[self setMaxWidth:width];
if (_width !== width)
[self setWidth:width];
@@ -394,8 +393,8 @@ CPTableColumnUserResizingMask = 1 << 1;
*/
- (void)setDataView:(CPView)aView
{
if (_dataView)
_dataViewData = nil;
if (_dataView === aView)
return;
[aView setThemeState:CPThemeStateTableDataView];
@@ -416,7 +415,7 @@ CPTableColumnUserResizingMask = 1 << 1;
to be invoked with row equal to -1 in cases where no actual row is involved but the table
view needs to get some generic cell info.
*/
- (id)dataViewForRow:(int)aRowIndex
- (id)dataViewForRow:(CPInteger)aRowIndex
{
return [self dataView];
}
@@ -500,7 +499,7 @@ CPTableColumnUserResizingMask = 1 << 1;
*/
- (void)setHidden:(BOOL)shouldBeHidden
{
shouldBeHidden = !!shouldBeHidden
shouldBeHidden = !!shouldBeHidden;
if (_isHidden === shouldBeHidden)
return;
@@ -541,14 +540,9 @@ CPTableColumnUserResizingMask = 1 << 1;
/*!
@ignore
*/
- (void)_postDidResizeNotificationWithOldWidth:(float)oldWidth
- (CPString)description
{
[[self tableView] _didResizeTableColumn:self];
[[CPNotificationCenter defaultCenter]
postNotificationName:CPTableViewColumnDidResizeNotification
object:[self tableView]
userInfo:@{ @"CPTableColumn": self, @"CPOldWidth": oldWidth }];
return [CPString stringWithFormat:"<%@ 0x%@ identifier=%@>", [self className], [CPString stringWithHash:[self UID]], [self identifier]];
}
@end
@@ -560,11 +554,22 @@ CPTableColumnUserResizingMask = 1 << 1;
- (void)setValueFor:(CPString)aBinding
{
var tableView = [_source tableView],
column = [[tableView tableColumns] indexOfObjectIdenticalTo:_source],
rowIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [tableView numberOfRows])],
columnIndexes = [CPIndexSet indexSetWithIndex:column];
newNumberOfRows = [tableView _numberOfRows];
[tableView reloadDataForRowIndexes:rowIndexes columnIndexes:columnIndexes];
if ([tableView numberOfRows] == newNumberOfRows)
{
var rowIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, newNumberOfRows)],
column = [[tableView tableColumns] indexOfObjectIdenticalTo:_source],
columnIndexes = [CPIndexSet indexSetWithIndex:column];
// Reloads objectValues only, not the views.
// FIXME: reload data for all rows or just rows intersecting exposed rows ?
[tableView _reloadDataForRowIndexes:rowIndexes columnIndexes:columnIndexes];
}
else
{
[tableView reloadData];
}
}
- (CPSortDescriptor)_defaultSortDescriptorPrototype
@@ -588,14 +593,14 @@ CPTableColumnUserResizingMask = 1 << 1;
{
var options = [_info objectForKey:CPOptionsKey],
optionValue = [options objectForKey:CPCreatesSortDescriptorBindingOption];
return optionValue === nil ? YES : [optionValue boolValue];
return optionValue == nil ? YES : [optionValue boolValue];
}
@end
@implementation CPTableColumn (Bindings)
+ (id)_binderClassForBinding:(CPString)aBinding
+ (Class)_binderClassForBinding:(CPString)aBinding
{
if (aBinding == CPValueBinding)
return [CPTableColumnValueBinder class];
@@ -604,7 +609,7 @@ CPTableColumnUserResizingMask = 1 << 1;
}
/*!
Binds the receiver to an object.
Binds the receiver to an object. Note that unlike Cocoa, this works only *after* the receiver has been added to a \c CPTableView.
@param CPString aBinding - The binding you wish to make. Typically CPValueBinding.
@param id anObject - The object to bind the receiver to.
@@ -634,6 +639,53 @@ CPTableColumnUserResizingMask = 1 << 1;
}
}
/*!
@ignore
This method will return the object at a row in the first found CPArray in the key path
that is divided in a first and second part.
The first part is never a combined key path. The second part can be a combined key path.
If this optimization is not done we will create an array with the valueForKeyPath value on each row and then pick
the wanted value for the row and throw away all the other rows. It is much more effective to first
pick the row and then do the valueForKeyPath on the rest of the key path.
When the second part is depleated it will stop the search for a CPArray and return the
current object for the first part. The second part will then be nil.
The secondPartRef will always be updated with the rest of the key path that can be applied
to the returned object.
It will stop the search if the object is nil
*/
- (CPValueCoding)_firstObjectInArrayUsingKeyPathFirstPart:(CPString)firstPart secondPart:(CPStringRef)secondPartRef sourceObject:(CPValueCoding)source forRow:(unsigned)aRow
{
var firstValue = [source valueForKeyPath:firstPart];
if (firstValue == nil)
return firstValue;
if ([firstValue isKindOfClass:CPArray])
return [firstValue objectAtIndex:aRow];
var secondPart = @deref(secondPartRef);
if (secondPart == nil)
return firstValue;
var dotIndex = secondPart.indexOf(".");
if (dotIndex === CPNotFound)
{
firstPart = secondPart;
@deref(secondPartRef) = nil;
}
else
{
firstPart = secondPart.substring(0, dotIndex);
@deref(secondPartRef) = secondPart.substring(dotIndex + 1);
}
return [self _firstObjectInArrayUsingKeyPathFirstPart:firstPart secondPart:secondPartRef sourceObject:firstValue forRow:aRow];
}
/*!
@ignore
*/
@@ -650,7 +702,7 @@ CPTableColumnUserResizingMask = 1 << 1;
bindingInfo = binding._info,
destination = [bindingInfo objectForKey:CPObservedObjectKey],
keyPath = [bindingInfo objectForKey:CPObservedKeyPathKey],
dotIndex = keyPath.lastIndexOf("."),
dotIndex = keyPath.indexOf("."),
value;
if (dotIndex === CPNotFound)
@@ -665,17 +717,16 @@ CPTableColumnUserResizingMask = 1 << 1;
The optimization is to get the array and access the value directly. This
turns the operation into a single access regardless of how long the model
array is.
array is or how long the key path is.
*/
var firstPart = keyPath.substring(0, dotIndex),
secondPart = keyPath.substring(dotIndex + 1),
firstValue = [destination valueForKeyPath:firstPart];
secondPart = keyPath.substring(dotIndex + 1);
if ([firstValue isKindOfClass:CPArray])
value = [[firstValue objectAtIndex:aRow] valueForKeyPath:secondPart];
else
value = [[firstValue valueForKeyPath:secondPart] objectAtIndex:aRow];
value = [self _firstObjectInArrayUsingKeyPathFirstPart:firstPart secondPart:@ref(secondPart) sourceObject:destination forRow:aRow];
if (secondPart != nil)
value = [value valueForKeyPath:secondPart];
}
value = [binding transformValue:value withOptions:[bindingInfo objectForKey:CPOptionsKey]];
@@ -828,7 +879,7 @@ var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey",
/*!
@ignore
*/
- (id)dataCellForRow:(int)row
- (id)dataCellForRow:(CPInteger)row
{
[CPException raise:CPUnsupportedMethodException
reason:@"dataCellForRow: is not supported. Use -dataViewForRow:row instead."];
+419 -367
View File
File diff suppressed because it is too large Load Diff

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