mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-09 12:17:13 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f56855010f | ||
|
|
b80713c1e5 | ||
|
|
93a1eea08b | ||
|
|
7393607a52 | ||
|
|
53784f0e10 | ||
|
|
900448528a | ||
|
|
e04e3d9ba5 | ||
|
|
5eaede0622 | ||
|
|
2c06bf566f | ||
|
|
4784a1a102 | ||
|
|
e3cb2cd6db | ||
|
|
dfe14a0f97 | ||
|
|
aa6fce3297 | ||
|
|
06da3164fc | ||
|
|
9cacb134c7 | ||
|
|
17e5d32621 | ||
|
|
f5b305317f | ||
|
|
9677609340 | ||
|
|
ab8e47fd01 | ||
|
|
a2181c88d7 | ||
|
|
1a9ff9ffb7 | ||
|
|
cc4b0e2540 | ||
|
|
87e0a6fe34 | ||
|
|
45d9f10a89 | ||
|
|
93937e8b1b | ||
|
|
bdc2b7cd67 | ||
|
|
b6ba250f82 | ||
|
|
4a5a25bb65 | ||
|
|
bc1889c7d4 | ||
|
|
5471c38905 | ||
|
|
9866dd49bb | ||
|
|
a6969bc756 | ||
|
|
23dff002a4 | ||
|
|
03b875697e | ||
|
|
d717e07d5c | ||
|
|
c39f03823a | ||
|
|
f3a04f23f8 | ||
|
|
0089785713 | ||
|
|
3a140b07fe | ||
|
|
74039c799a | ||
|
|
b3e2ed1071 | ||
|
|
1f8e75388d | ||
|
|
ee0c6fdf2d | ||
|
|
54b7d24081 | ||
|
|
bf76c7d2c7 | ||
|
|
bad82ee587 | ||
|
|
16beb1a86c | ||
|
|
690b79f113 | ||
|
|
4d13785119 | ||
|
|
4f29b77d65 | ||
|
|
be08bed01e | ||
|
|
e107e2d804 | ||
|
|
10351c3d4a | ||
|
|
67b4798caa | ||
|
|
301e940236 | ||
|
|
5bdac195fc | ||
|
|
8134b6dff7 | ||
|
|
7083f7b268 | ||
|
|
72d2b22088 | ||
|
|
acf410776d | ||
|
|
82f82190a1 | ||
|
|
f85ac1ea10 | ||
|
|
b6a245c852 | ||
|
|
874792fa6e | ||
|
|
378f7bbda1 | ||
|
|
ca13595e37 | ||
|
|
22a43bcfc5 | ||
|
|
4c54e6cd31 | ||
|
|
9ffa4decd4 | ||
|
|
389ad61251 | ||
|
|
d8dd2e8636 | ||
|
|
8d1429d063 | ||
|
|
d1b5c08272 | ||
|
|
6ef3cf776f | ||
|
|
0a6f2e569a | ||
|
|
ae409d05c1 | ||
|
|
6b732da749 | ||
|
|
45741365f4 | ||
|
|
2c86863258 | ||
|
|
8994806789 | ||
|
|
e51f0df1a6 | ||
|
|
a8a0c64a2a | ||
|
|
5449561fe2 | ||
|
|
073fae648e | ||
|
|
6121caf75d | ||
|
|
253d6669eb | ||
|
|
533a1d46eb | ||
|
|
c0b4fbfeb1 | ||
|
|
f6d96bbf17 | ||
|
|
52658b636a | ||
|
|
c32994af66 | ||
|
|
a1ac821678 | ||
|
|
548ed836a0 | ||
|
|
78a0ebab6e | ||
|
|
fad987641b | ||
|
|
3aa053e7a8 | ||
|
|
7aebf371e9 | ||
|
|
ac8ce3eec3 | ||
|
|
567ec55875 | ||
|
|
59569dcb34 | ||
|
|
3b09a5bde6 | ||
|
|
01f7f9b601 | ||
|
|
907ff374e6 | ||
|
|
a786418e19 | ||
|
|
6448f7ea12 | ||
|
|
ce2803f354 | ||
|
|
7e3d22b10e | ||
|
|
84dab55993 | ||
|
|
60a143eb7c | ||
|
|
aa961ff518 | ||
|
|
bbdc7e1fe1 | ||
|
|
b62721d79a | ||
|
|
450db2678a | ||
|
|
02a5434e4f | ||
|
|
51b10e2bc4 | ||
|
|
8cb3d7771c | ||
|
|
4ef40ff151 | ||
|
|
d7e5c2ccac | ||
|
|
f414fae60a | ||
|
|
a6c57b7128 | ||
|
|
cbf1d35f24 | ||
|
|
ecf36f12cb | ||
|
|
fa79df4309 | ||
|
|
c97839905c | ||
|
|
d34149b236 | ||
|
|
d9d3e5d613 | ||
|
|
a745af8ead | ||
|
|
6e0d2f97cc | ||
|
|
e288ea3690 | ||
|
|
87c1727ea0 | ||
|
|
1a9a42ff54 | ||
|
|
5592056351 | ||
|
|
98bfd87446 | ||
|
|
3f63be7290 | ||
|
|
b23d0cb8eb | ||
|
|
0da009d1b9 | ||
|
|
b1fade86fe | ||
|
|
04bad947e3 | ||
|
|
f2cdb08e76 | ||
|
|
da3b0b5e21 | ||
|
|
a240d312d0 | ||
|
|
bd48e2055e | ||
|
|
42c212df64 | ||
|
|
59e811328f | ||
|
|
317c1a1475 | ||
|
|
a93e67662b | ||
|
|
14379b1be9 | ||
|
|
2e8767509e | ||
|
|
429dfd7467 | ||
|
|
71a7b54edd | ||
|
|
ad05fbe97b | ||
|
|
0fed962b37 | ||
|
|
ee36796180 | ||
|
|
cff2fd8ed9 | ||
|
|
344cbd0660 | ||
|
|
e6e676c91e | ||
|
|
5fd2f49266 | ||
|
|
10fb3e6d31 | ||
|
|
535315485a | ||
|
|
88146a5389 | ||
|
|
c8789c5450 | ||
|
|
766035f4b7 | ||
|
|
a90b504dc7 | ||
|
|
26b2280fc2 | ||
|
|
15bbca8d77 | ||
|
|
319bcdaba9 | ||
|
|
89445f94a2 | ||
|
|
beb4aef424 | ||
|
|
ef680c080d | ||
|
|
c187f5de1d | ||
|
|
d40a151e05 | ||
|
|
e67c141921 | ||
|
|
de2ffd3aad | ||
|
|
4c8fd58471 | ||
|
|
873a102872 | ||
|
|
6dc11de431 | ||
|
|
672f25ce27 | ||
|
|
9731c4b394 | ||
|
|
b2c5955e7d | ||
|
|
bc0380e1cb | ||
|
|
1223cfc965 | ||
|
|
2f63a5fd10 | ||
|
|
b827310c75 | ||
|
|
361a4203da | ||
|
|
8de928d905 | ||
|
|
5a3d6e30cb | ||
|
|
227eda9d92 | ||
|
|
9fe0df74b3 | ||
|
|
381c1880c2 | ||
|
|
5439e5d473 | ||
|
|
50bac0a470 | ||
|
|
cfff603508 | ||
|
|
894a60ad45 | ||
|
|
acbe5885f1 | ||
|
|
a981b8b04d | ||
|
|
d75c0ac452 | ||
|
|
da061aac1d | ||
|
|
77433a3a1c | ||
|
|
4aaa32833a | ||
|
|
2a0cebb851 | ||
|
|
1b23bb8a67 | ||
|
|
5dc66c5b4e | ||
|
|
49b1800027 | ||
|
|
1cad83aba8 | ||
|
|
e1f5238063 | ||
|
|
5897d76c04 | ||
|
|
a0fc7723fc | ||
|
|
ec4a1d1724 | ||
|
|
6139216146 | ||
|
|
861c504c41 | ||
|
|
c9df6e4d25 | ||
|
|
c9d3ccdf0d | ||
|
|
2c275b279b | ||
|
|
44f6e0fded | ||
|
|
e5278fd17e | ||
|
|
1bd3c93717 | ||
|
|
afc6691f07 | ||
|
|
8c41c7b8ac | ||
|
|
5445d42eba | ||
|
|
d88f2ef7c0 | ||
|
|
14b5a67bf5 | ||
|
|
8e04b172ce | ||
|
|
5fff34be91 | ||
|
|
210133d9e2 | ||
|
|
524b1df4c9 | ||
|
|
9115949169 | ||
|
|
0b3aa6aac2 | ||
|
|
e03e0c6fc4 | ||
|
|
613a2722be | ||
|
|
e9b9d9702e | ||
|
|
750c123d1e | ||
|
|
5e0fc1cbb5 | ||
|
|
015f027cf2 | ||
|
|
c3d9dead19 | ||
|
|
b296f17d2b | ||
|
|
22fdc971c7 | ||
|
|
291be04dc3 | ||
|
|
5c7215c455 | ||
|
|
2a83dcb64a | ||
|
|
979118a86f | ||
|
|
4fbd50e81f | ||
|
|
3b1c1c0886 | ||
|
|
dbc8bfc7f3 | ||
|
|
10bb6723f3 | ||
|
|
c58a5b520e | ||
|
|
7b6cb51f4d | ||
|
|
c704880e13 | ||
|
|
41c422ed03 | ||
|
|
c94ed00f41 | ||
|
|
1d93cf2b1a | ||
|
|
420f3a538d | ||
|
|
453e8dbd2e | ||
|
|
c6549867bd | ||
|
|
3aecb3ea98 | ||
|
|
2819546716 | ||
|
|
7e0f03a6fc | ||
|
|
6e36fc0b20 | ||
|
|
e856605a09 | ||
|
|
d7315773e1 | ||
|
|
a27aaf8bd0 | ||
|
|
c0b875de5d | ||
|
|
141eb7b98e | ||
|
|
6099311cbd | ||
|
|
dcb06fbc4f | ||
|
|
8258c8ef0b | ||
|
|
9312c96154 | ||
|
|
c27b48d27a | ||
|
|
f3039fb77c | ||
|
|
abe159eceb | ||
|
|
ffb6b3e6fe | ||
|
|
7f25de0fad | ||
|
|
d6c5d8b4f2 | ||
|
|
78e1ea43c8 | ||
|
|
9d24c855e2 | ||
|
|
872af9ce2a | ||
|
|
18b2a668c5 | ||
|
|
72be296713 | ||
|
|
b620991770 | ||
|
|
732fc2d1e1 | ||
|
|
79a9ae31d3 | ||
|
|
e0e16eeca5 | ||
|
|
a784435c2b | ||
|
|
57987b6f67 | ||
|
|
480917eeab | ||
|
|
013e7bdf7e | ||
|
|
c4032ecd1d | ||
|
|
2ea11eb5ab | ||
|
|
7fad67484c | ||
|
|
f34cbbdf29 | ||
|
|
1c0cc2acef | ||
|
|
14a4b04d9b | ||
|
|
8aee2a511f | ||
|
|
65cb048b1b | ||
|
|
cf10b826d7 | ||
|
|
b7ac5272d0 | ||
|
|
dc893f7ca3 | ||
|
|
206b1d4a05 | ||
|
|
0bd83b6635 | ||
|
|
4dcfe992de | ||
|
|
ef9d6662cb | ||
|
|
0e5f3b1697 | ||
|
|
7fbea7913a | ||
|
|
4b81001330 | ||
|
|
043029cf41 | ||
|
|
81988f1ec7 | ||
|
|
9ecc739e8d | ||
|
|
3d5f4eec18 | ||
|
|
c7e89d3018 | ||
|
|
63e3f6c3fc | ||
|
|
d39a583127 | ||
|
|
f568427dc2 | ||
|
|
6e486bb30b | ||
|
|
5e297dd293 | ||
|
|
63cbb04acc | ||
|
|
6f55c7bbba | ||
|
|
ea4adf1039 | ||
|
|
3ff7818d58 | ||
|
|
3e4ebe8e47 | ||
|
|
b77a374f48 | ||
|
|
43936f640c | ||
|
|
6671d371e9 | ||
|
|
4fd99d2c52 | ||
|
|
6563e730a0 | ||
|
|
b39c3e8d4b | ||
|
|
9f092a3c2e | ||
|
|
5b820b270c | ||
|
|
da2c89daf3 | ||
|
|
ea425ae4c4 | ||
|
|
37a6e8fde5 | ||
|
|
0274d9fee7 | ||
|
|
f223644640 | ||
|
|
0aa4607d8e | ||
|
|
37b68bb166 | ||
|
|
ae4eef5d16 | ||
|
|
fdba5f55c5 | ||
|
|
bfeaabc038 | ||
|
|
a32b2d5f73 | ||
|
|
9f4db09bec | ||
|
|
58fe3d3d27 | ||
|
|
28303a7893 | ||
|
|
031e5e7ca3 | ||
|
|
c70079ae71 | ||
|
|
8ac2b94400 | ||
|
|
b1f2fb44a8 | ||
|
|
cd4c3cffe0 | ||
|
|
98c01b88e2 | ||
|
|
4970a2742d | ||
|
|
10d18e35ed | ||
|
|
12960f8160 | ||
|
|
622d738b44 | ||
|
|
4e5c0aed67 | ||
|
|
96d3ad2c47 | ||
|
|
c519784ecc | ||
|
|
d0d7033f63 | ||
|
|
9aaa565657 | ||
|
|
50e98d1335 | ||
|
|
837df80b64 | ||
|
|
f7a27cf905 | ||
|
|
da35d6b6ed | ||
|
|
fca30325e4 | ||
|
|
8f48d01c33 | ||
|
|
89d345dfdc | ||
|
|
1bbf87e2cb | ||
|
|
ec9c658565 | ||
|
|
8db24fcaf6 | ||
|
|
bce326de9d | ||
|
|
676ddc4601 | ||
|
|
19cceb4dd9 | ||
|
|
f31ac7cf21 | ||
|
|
802c644d94 | ||
|
|
749909b23c | ||
|
|
df594ae48e | ||
|
|
980e2f2c91 | ||
|
|
ea47767bb8 | ||
|
|
0b83c20648 | ||
|
|
0f9cadf8d3 | ||
|
|
c82e5750f0 | ||
|
|
2ff5eb39eb | ||
|
|
e216f0a355 | ||
|
|
0e86264837 | ||
|
|
57d0750f3c | ||
|
|
3be864e50f | ||
|
|
d583403195 | ||
|
|
946362f0d1 | ||
|
|
7ee4003840 | ||
|
|
f2bebcb2e6 | ||
|
|
e413f3a9fd | ||
|
|
0c4d33dccc | ||
|
|
4af8fcc008 | ||
|
|
6800472725 | ||
|
|
e6b9b9cfbd | ||
|
|
9dfaf293f2 | ||
|
|
fffcc85486 | ||
|
|
b349b23b81 | ||
|
|
886a4a422f | ||
|
|
d8dd3d0660 | ||
|
|
f19901c214 | ||
|
|
e198fbdc40 | ||
|
|
3dd97c0b49 | ||
|
|
b93aa732d2 | ||
|
|
16d8780812 | ||
|
|
febd1260cd | ||
|
|
45162a3fcb | ||
|
|
b598e80c58 | ||
|
|
41648b8605 | ||
|
|
6b285cd7f0 | ||
|
|
a5e9d65852 | ||
|
|
94195237d9 | ||
|
|
b8f63166cd | ||
|
|
fc91326a5f | ||
|
|
0fc2ed7081 | ||
|
|
8433d4a1d1 | ||
|
|
2615577173 | ||
|
|
5aa315e190 | ||
|
|
d180a25f2e | ||
|
|
8d61a5fbe1 | ||
|
|
b2cd64b956 | ||
|
|
53488c0adb | ||
|
|
ca9b8a78b2 | ||
|
|
c05b900fe6 | ||
|
|
907450a63d | ||
|
|
6b1e308dab | ||
|
|
e28df7d7d7 | ||
|
|
84d3a820f2 | ||
|
|
dda325b51b | ||
|
|
f0e29069a9 | ||
|
|
4730c23a97 | ||
|
|
593d098cc1 | ||
|
|
2e15f351a9 | ||
|
|
14a195592a | ||
|
|
7c81471a3a | ||
|
|
42ea1a5972 | ||
|
|
1da107c404 | ||
|
|
b2ada8a76f | ||
|
|
5ac90c163a | ||
|
|
53e7d14e1f | ||
|
|
186e2e6130 | ||
|
|
fefa603b45 | ||
|
|
99cf8e6387 | ||
|
|
53b4fe4fdc | ||
|
|
6773df15b9 | ||
|
|
bc64d147a8 | ||
|
|
569f93549e | ||
|
|
2045d1eaeb | ||
|
|
a2595093f8 | ||
|
|
9a9c9b8481 | ||
|
|
99ec1af301 | ||
|
|
f3fe384df1 | ||
|
|
c7f3dd5b0f | ||
|
|
547be633b6 | ||
|
|
a88002861b | ||
|
|
395022d652 | ||
|
|
dd24de5daf | ||
|
|
3c02cf5358 | ||
|
|
bf0f0ab509 | ||
|
|
3d0639b6dc | ||
|
|
ed50f3b654 | ||
|
|
25d186bf5c | ||
|
|
e02107102c | ||
|
|
1376466939 | ||
|
|
f2c05c4841 | ||
|
|
17136d23f9 | ||
|
|
812f69f4a7 | ||
|
|
7f286129de | ||
|
|
b92459ba38 | ||
|
|
51e9737114 | ||
|
|
66051b066f | ||
|
|
a3cb43bad8 | ||
|
|
ba4f0f7e4d | ||
|
|
ada5887deb | ||
|
|
af148b5008 | ||
|
|
205b645de8 | ||
|
|
f1f0703619 | ||
|
|
dc23fe49af | ||
|
|
44de0334b7 | ||
|
|
de96e0c22c | ||
|
|
2f5593390e | ||
|
|
0ef1239283 | ||
|
|
258dd7ba38 | ||
|
|
3e38560620 | ||
|
|
1826a14afe | ||
|
|
e46fc1dc77 | ||
|
|
debb43c1ca | ||
|
|
da8bf0abe1 | ||
|
|
92b7583f9f | ||
|
|
8950c4f0e3 | ||
|
|
9442f6b7d7 | ||
|
|
c14e08633d | ||
|
|
dfbf07b10c | ||
|
|
b2b29c928f | ||
|
|
c56448a29c | ||
|
|
42a00edbd8 | ||
|
|
18bb6daf10 | ||
|
|
799cb189c9 | ||
|
|
1112e658d4 | ||
|
|
23cdee2f22 | ||
|
|
13688507dc | ||
|
|
568d0faef6 | ||
|
|
41035a5b10 | ||
|
|
4cb0a87c68 | ||
|
|
cab5683cd9 | ||
|
|
4d20007a9b | ||
|
|
56eb096903 | ||
|
|
c077863e7a | ||
|
|
49e5cb64ad | ||
|
|
7e99e3ca20 | ||
|
|
0b4d156b5b | ||
|
|
76ba6a4e64 | ||
|
|
46bab97b49 | ||
|
|
2a32934f86 | ||
|
|
bda5594f0c | ||
|
|
134688ef5c | ||
|
|
e3fd7a295c | ||
|
|
c2d07b7b06 | ||
|
|
d9f31e8543 | ||
|
|
38f523b3c2 | ||
|
|
69a353d969 | ||
|
|
945e70c0ff | ||
|
|
277e9bee7b | ||
|
|
95614d567c | ||
|
|
6a488af1ca | ||
|
|
a0f9cb5183 | ||
|
|
1a74b4c692 | ||
|
|
746311c6cf | ||
|
|
876aaa483e | ||
|
|
570c31f248 | ||
|
|
b3695ed710 | ||
|
|
e9dddaad20 | ||
|
|
2b254a6f16 | ||
|
|
e9022d045c | ||
|
|
c70ea739ec | ||
|
|
85da0164ba | ||
|
|
89b262103f | ||
|
|
2c5744be57 | ||
|
|
cfcf8bc567 | ||
|
|
d1acff5b44 | ||
|
|
2add37983d | ||
|
|
ce00fdaae8 | ||
|
|
2fe29d4a26 | ||
|
|
fc582d8125 | ||
|
|
c41307dc37 | ||
|
|
27280f6da1 | ||
|
|
ce7fec170a | ||
|
|
98ef6fd902 | ||
|
|
1c4d9b1d8f | ||
|
|
b8b988c10b | ||
|
|
0eb87f85b4 | ||
|
|
a0136e2144 | ||
|
|
d12770c65d | ||
|
|
b0186bf4f2 | ||
|
|
9e15700f93 | ||
|
|
6b2494ede4 | ||
|
|
266965f506 | ||
|
|
1226f5120c | ||
|
|
f4ac0630b8 | ||
|
|
b3cb22caef | ||
|
|
b1d96dfdee | ||
|
|
25732f2f52 | ||
|
|
5ecdaafadf | ||
|
|
223bbc86e1 | ||
|
|
0867e718d1 | ||
|
|
c814b5daed | ||
|
|
0e8ee2f7d5 | ||
|
|
4b22d67f42 | ||
|
|
edf0a61653 | ||
|
|
e50ede815c | ||
|
|
6d2888e1c6 | ||
|
|
b6461ba4fb | ||
|
|
25708554fd | ||
|
|
74f204e6fa | ||
|
|
263ec36d80 | ||
|
|
bb6b738fc7 | ||
|
|
fb1c2732ac | ||
|
|
1fb42fc119 | ||
|
|
23f9170b90 | ||
|
|
7be2005fae | ||
|
|
afadec517b | ||
|
|
da5a12c938 | ||
|
|
a9aa15d63f | ||
|
|
e6d2d840e9 | ||
|
|
4963127c31 | ||
|
|
62c7ac891f | ||
|
|
e4b594f716 | ||
|
|
0835f18721 | ||
|
|
8231cbc55c | ||
|
|
b63cde48c6 | ||
|
|
30150178db | ||
|
|
61eebfcf46 | ||
|
|
40154ed86e | ||
|
|
23605ff2b0 | ||
|
|
964eb00ce1 | ||
|
|
930c1e874c | ||
|
|
1d96b09129 | ||
|
|
9c6ce6d200 | ||
|
|
a1aad41a6b | ||
|
|
38cb3cb1a2 | ||
|
|
751e1d27a6 | ||
|
|
36d4bd32b5 | ||
|
|
d835cf0c00 | ||
|
|
6ce85bae7e | ||
|
|
7d1df21b0e | ||
|
|
bbb87b4970 | ||
|
|
14d9bb795d | ||
|
|
2eb1d1bfb9 | ||
|
|
bae78b5055 | ||
|
|
c0705448cd | ||
|
|
e0a8fa3fde | ||
|
|
64f4b0fc13 | ||
|
|
c28a05e968 | ||
|
|
170d6ac2e7 | ||
|
|
64cc36a1ac | ||
|
|
af61bcb93f | ||
|
|
1f24e89c1b | ||
|
|
b12aee53d3 | ||
|
|
feb8ea0316 | ||
|
|
db51d5ca54 | ||
|
|
01e9f9181d | ||
|
|
3a9db70426 | ||
|
|
c7e850b95f | ||
|
|
89b3fb003c | ||
|
|
6abb8234fb | ||
|
|
4395663cc9 | ||
|
|
aeb982c616 | ||
|
|
3fd26e681b | ||
|
|
8bcf446187 | ||
|
|
42d51dc808 | ||
|
|
b05aa3dd32 | ||
|
|
98a539657c | ||
|
|
85f7125f22 | ||
|
|
2f8dd8c088 | ||
|
|
86d595b086 | ||
|
|
2f563fb870 | ||
|
|
c78a18dc3e | ||
|
|
0fa636dd79 | ||
|
|
7fc9fa70c1 | ||
|
|
9109cf3b54 | ||
|
|
50076efe1e | ||
|
|
097785fb93 | ||
|
|
7e07deeb23 | ||
|
|
e8c0c680ca | ||
|
|
d9ee7b23c2 | ||
|
|
03339e3c5d | ||
|
|
c58c5554f9 | ||
|
|
16ae7b7e74 | ||
|
|
6d3fec88ec | ||
|
|
4b74e7da31 | ||
|
|
fa70ffc918 | ||
|
|
fd177f4b9a | ||
|
|
08c666a53f | ||
|
|
668567d6e2 | ||
|
|
09f92407ec | ||
|
|
9dc12c0142 | ||
|
|
2fd821ca00 | ||
|
|
03195b66bc | ||
|
|
a3d906165a | ||
|
|
4c1ce50dd2 | ||
|
|
b638242e6f | ||
|
|
2349aacc3e | ||
|
|
1be7bbe0dc | ||
|
|
ea332d5492 | ||
|
|
aedede7381 | ||
|
|
d4cd46c331 | ||
|
|
62450c3bb1 | ||
|
|
bafba81f56 | ||
|
|
651b445c75 | ||
|
|
5adc3c6a99 | ||
|
|
4914ff8205 | ||
|
|
783205c731 | ||
|
|
00ab2d1f3a | ||
|
|
98dcbdd87a | ||
|
|
4a936a6eef | ||
|
|
ef7ee1b699 | ||
|
|
4e70c1fb10 | ||
|
|
21d4fa5176 | ||
|
|
f16b2e8243 | ||
|
|
4e550a22b0 | ||
|
|
c2404d3c67 | ||
|
|
f1a5467d04 | ||
|
|
512486f2e8 | ||
|
|
f1d95fa883 | ||
|
|
31cf9b8527 | ||
|
|
e0e8e8c6cc | ||
|
|
6653690d0c | ||
|
|
e63f59d33e | ||
|
|
3702c18df5 | ||
|
|
dfe215f34c | ||
|
|
621a559585 | ||
|
|
61317eff71 | ||
|
|
b314a951da | ||
|
|
1a1c105c71 | ||
|
|
3f8ee35ddb | ||
|
|
d2ea74ea14 | ||
|
|
8e1fb771e0 | ||
|
|
bbe5c82700 | ||
|
|
95e3ff3349 | ||
|
|
00c3b2083b | ||
|
|
8549858951 | ||
|
|
4730c3f4b5 | ||
|
|
19ba66fd9d | ||
|
|
589c26192d | ||
|
|
8471aeea1b | ||
|
|
58c39c14a5 | ||
|
|
2cfe45950b | ||
|
|
688671db6a | ||
|
|
1d2e50dfa2 | ||
|
|
7a70036c8f | ||
|
|
ab88a3b236 | ||
|
|
266e14063e | ||
|
|
3af0296779 | ||
|
|
5ff05503a4 | ||
|
|
13e6782cf1 | ||
|
|
24052e6369 | ||
|
|
9b17ce5524 | ||
|
|
e4c2d62eb0 | ||
|
|
27fa37a7e1 | ||
|
|
987da2b812 | ||
|
|
d1611bae12 | ||
|
|
96a3c4b9dd | ||
|
|
8ef40dced5 | ||
|
|
4a6ddb901f | ||
|
|
a5094e0acc | ||
|
|
966d9fe0d2 | ||
|
|
fffcca592d | ||
|
|
341584c032 | ||
|
|
a1e178d0d7 | ||
|
|
c59687b6e2 | ||
|
|
c2bd9f26a7 | ||
|
|
6d78b9b6df | ||
|
|
0669ce06f2 | ||
|
|
767d9378e3 | ||
|
|
c2d62b7a13 | ||
|
|
10e33298a9 | ||
|
|
ecc88112d5 | ||
|
|
b190063264 | ||
|
|
0c9c0c0239 | ||
|
|
ae333ecb77 | ||
|
|
72a85d11df | ||
|
|
f33ba954f5 | ||
|
|
f642330306 | ||
|
|
ae1a39322e | ||
|
|
29502d10eb | ||
|
|
37550b9fb0 | ||
|
|
efd2ed1960 | ||
|
|
150e44dcd5 | ||
|
|
3a164c8080 | ||
|
|
fb9223c6c3 | ||
|
|
511ce4b07d | ||
|
|
aea3fb5f07 | ||
|
|
5932a07eb2 | ||
|
|
2b07c4b662 | ||
|
|
bc689b91dc | ||
|
|
c6a42781e7 | ||
|
|
c92aedf433 | ||
|
|
7857f92f19 | ||
|
|
9361e5d401 | ||
|
|
6c6f69d4e5 | ||
|
|
e836226174 | ||
|
|
ad1862a253 | ||
|
|
4af137894a | ||
|
|
55aca1fde9 | ||
|
|
53e1e936d9 | ||
|
|
ff1448fb54 | ||
|
|
95fb19f311 | ||
|
|
46d869a62f | ||
|
|
03140dbf64 | ||
|
|
052c96e05a | ||
|
|
9a88f9c324 | ||
|
|
747ea627c9 | ||
|
|
89c0ab405a | ||
|
|
04c2b98ae4 | ||
|
|
24b36cdd95 | ||
|
|
3e83bd2363 | ||
|
|
5c91a08eaf | ||
|
|
edfba15d6f | ||
|
|
48e786e8b5 | ||
|
|
1282f1ac0e | ||
|
|
ee2fb61fdd | ||
|
|
68a113e7ee | ||
|
|
3cf3b76446 | ||
|
|
d7d561d3a9 | ||
|
|
73eeda3c09 | ||
|
|
3d514b5010 | ||
|
|
93fc8d29cc | ||
|
|
145bf65542 | ||
|
|
f21555bb6c | ||
|
|
be072a283f | ||
|
|
9e8d51c94d | ||
|
|
b3051a5bd0 | ||
|
|
a523cfc381 | ||
|
|
6544aff88e | ||
|
|
7c1fdbc720 | ||
|
|
bd84804e32 | ||
|
|
1f2a257bab | ||
|
|
b0684929e2 | ||
|
|
22dc587a8f | ||
|
|
622fcf740e | ||
|
|
77b59c8a18 | ||
|
|
462a18930b | ||
|
|
fb07def5fa | ||
|
|
a03ee6726e | ||
|
|
1ef49ef290 | ||
|
|
76d52e07d4 | ||
|
|
044b0bb0d2 | ||
|
|
472b59ef80 | ||
|
|
6b559ce283 | ||
|
|
c17b806fd5 | ||
|
|
1dcea8fe4c | ||
|
|
d72a52b9ce | ||
|
|
61e01b08e5 | ||
|
|
37756a5853 | ||
|
|
b66690e304 | ||
|
|
ccc6007bab | ||
|
|
3179d56879 | ||
|
|
b631032857 | ||
|
|
49574d1c54 | ||
|
|
b7d7368ce6 | ||
|
|
e221156c11 | ||
|
|
8e346acdce | ||
|
|
7c36fa3f56 | ||
|
|
642e254522 | ||
|
|
72aa1b8416 | ||
|
|
edb1ef7f98 | ||
|
|
92beaba1d6 | ||
|
|
3b61b1c85d | ||
|
|
a529e752b3 | ||
|
|
d9791673df | ||
|
|
a49a20e2c2 | ||
|
|
8570476cff | ||
|
|
d0923efa1a | ||
|
|
eab8fe2d64 | ||
|
|
c9e8b2970b | ||
|
|
1440c156b2 | ||
|
|
ddfa4445ae | ||
|
|
1f501e6429 | ||
|
|
7969f118de | ||
|
|
706166dc5c | ||
|
|
4a8667e0f3 | ||
|
|
094fbcc67c | ||
|
|
d34c47c167 | ||
|
|
7226330514 | ||
|
|
852b2bd5d9 | ||
|
|
3d8ecfad47 | ||
|
|
9e6f1e0dc3 | ||
|
|
4deb7a3f51 | ||
|
|
5b0b030435 | ||
|
|
4edec2df2e | ||
|
|
e0596bdf75 | ||
|
|
6430463b5d | ||
|
|
d9e27e549f | ||
|
|
9f14dac5d2 | ||
|
|
d70199ca58 | ||
|
|
6b1cdbd19c | ||
|
|
5b99757a0d | ||
|
|
6c49116c68 | ||
|
|
68f0cf27df | ||
|
|
89757e35e6 | ||
|
|
24bf09b70c | ||
|
|
0ed2709124 | ||
|
|
a835202db1 | ||
|
|
830fbbab26 | ||
|
|
119e11cfe2 | ||
|
|
511e18b44f | ||
|
|
2f00d93b22 | ||
|
|
973fa1b978 | ||
|
|
79f40d24ae | ||
|
|
fdff92e5c8 | ||
|
|
653dd07162 | ||
|
|
b7968ca4a7 | ||
|
|
2a0a6449e5 | ||
|
|
b7c04d7d16 | ||
|
|
ab4c87e69f | ||
|
|
8257632706 | ||
|
|
3f8821b43b | ||
|
|
f6b8bc0c45 | ||
|
|
0618fa9bb2 | ||
|
|
2e5a483dce | ||
|
|
e608e0dbf3 | ||
|
|
a88e316a94 | ||
|
|
51ffa256ca | ||
|
|
52bd654850 | ||
|
|
0518d479d3 | ||
|
|
a893f3f5c1 | ||
|
|
9c2f37b43f | ||
|
|
0289ba17f1 | ||
|
|
5db94e1e52 | ||
|
|
a4bc08c29e | ||
|
|
b638d8e904 | ||
|
|
251ce7fdad | ||
|
|
a2337a2969 | ||
|
|
0c803e26ca | ||
|
|
ab25fadb1e | ||
|
|
e697f4eca7 | ||
|
|
80158a8982 | ||
|
|
55bcfacf3b | ||
|
|
52b7a82b4d | ||
|
|
471e605871 | ||
|
|
5c635f17a7 | ||
|
|
c27d604780 | ||
|
|
ddaf575719 | ||
|
|
0757f2ea80 | ||
|
|
3f8dfb6516 | ||
|
|
45ee25adc2 | ||
|
|
fcfb3d4083 | ||
|
|
357f8bd684 | ||
|
|
173cd8b4ad | ||
|
|
d2ca5994c8 | ||
|
|
fe04d177af | ||
|
|
2a6b18bc1b | ||
|
|
152cd272f6 | ||
|
|
abbdc139e8 | ||
|
|
7226019b6a | ||
|
|
78ea29bd48 | ||
|
|
5c90d1f769 | ||
|
|
2ecea40fdc | ||
|
|
8d9c11b6f2 | ||
|
|
afd23e3457 | ||
|
|
ddeaad74d0 | ||
|
|
a82472f509 | ||
|
|
4a43e376ed | ||
|
|
9ab82e1e5e | ||
|
|
4b28d0c38b | ||
|
|
1924cd1822 | ||
|
|
730b2dd874 | ||
|
|
1c2b383838 | ||
|
|
0b99f83d6f | ||
|
|
dc5b3f48e8 | ||
|
|
d17671c99e | ||
|
|
b69259e83b | ||
|
|
f2c80dc815 | ||
|
|
cbc281b173 | ||
|
|
472f859bd8 | ||
|
|
e71f650650 | ||
|
|
e64c9d9cd4 | ||
|
|
87a1c6621c | ||
|
|
09f49c4afa | ||
|
|
eba1b2f999 | ||
|
|
8e026279ac | ||
|
|
3605e99914 | ||
|
|
5e9d479cef | ||
|
|
fb20463449 | ||
|
|
f5db73342f | ||
|
|
9b2dc23197 | ||
|
|
067052e1a8 | ||
|
|
441e5fbc05 | ||
|
|
0a2aae3bc2 | ||
|
|
a76c798500 | ||
|
|
c238ebeef4 | ||
|
|
206eddbdbd | ||
|
|
45549cdbcf | ||
|
|
e043b6a8c5 | ||
|
|
677076b89d | ||
|
|
77c9b99f74 | ||
|
|
c8cdda0c18 | ||
|
|
41cd73703e | ||
|
|
607e84c052 | ||
|
|
8416390631 | ||
|
|
6094d25cfb | ||
|
|
c80504efae | ||
|
|
2589033523 | ||
|
|
f74fed5ee0 | ||
|
|
01e295084c | ||
|
|
9f923941a8 | ||
|
|
3aba03eb28 | ||
|
|
1107195ab6 | ||
|
|
b67384cdd1 | ||
|
|
59603b550e | ||
|
|
c52f714149 | ||
|
|
35420732d1 | ||
|
|
7f48b84292 | ||
|
|
5110c5706f | ||
|
|
633511acda | ||
|
|
75d0a69c02 | ||
|
|
e6fe9396f8 | ||
|
|
5c4107835b | ||
|
|
57cc90f89f | ||
|
|
7e08e48a8a | ||
|
|
87719f1161 | ||
|
|
99d7c8d824 | ||
|
|
1caf4f99cf | ||
|
|
78b3887e4a | ||
|
|
bb064aacd5 | ||
|
|
d9e8321d9e | ||
|
|
5f6df95e30 | ||
|
|
ef779c346e | ||
|
|
c1543d4a2f | ||
|
|
9145e27009 | ||
|
|
299f1a9102 | ||
|
|
6eab438778 | ||
|
|
2a623fbb8c | ||
|
|
7bde091f1b | ||
|
|
412baf7872 | ||
|
|
010057d9e1 | ||
|
|
6c7d8df565 | ||
|
|
92598da06f | ||
|
|
601d6f7c6c | ||
|
|
e13cebaa3a | ||
|
|
5724868c5a | ||
|
|
03972f0aec | ||
|
|
6143ec4180 | ||
|
|
c30464ee77 | ||
|
|
1e1e6456cd | ||
|
|
6c46bb4756 | ||
|
|
5ac6b1d1f1 | ||
|
|
9c95c9c6e9 | ||
|
|
4b052e74f1 | ||
|
|
bd6b8e4b7f | ||
|
|
26e8432bb0 | ||
|
|
05f9fd22fe | ||
|
|
8f5bde2797 | ||
|
|
77fe16faec | ||
|
|
38dd776049 | ||
|
|
7e3c4074e4 | ||
|
|
89c8f8e80f | ||
|
|
7397e681f4 | ||
|
|
e7d5afe90e | ||
|
|
2d9d354a05 | ||
|
|
60a686d75c | ||
|
|
89b70843c7 | ||
|
|
9f9044b164 | ||
|
|
617987f4a5 | ||
|
|
5bb338d6ec | ||
|
|
8003d91c4a | ||
|
|
a4ef18ddab | ||
|
|
82e55b4761 | ||
|
|
3a51c386ca | ||
|
|
9868519cc0 | ||
|
|
038c007915 | ||
|
|
ba6350e24d | ||
|
|
1c866931f3 | ||
|
|
b7aff28b5e | ||
|
|
f0897ffdf8 | ||
|
|
f5937a6fad | ||
|
|
7dc77ed609 | ||
|
|
d1bfe62a65 | ||
|
|
f7c8f24bff | ||
|
|
055d63eeb5 | ||
|
|
ef7f92ed15 | ||
|
|
8daa53dd3e | ||
|
|
109003ae12 | ||
|
|
36f1abdbe6 | ||
|
|
50519776e0 | ||
|
|
9e289574ff | ||
|
|
2d96b06d4c | ||
|
|
0c706cfed2 | ||
|
|
3f9e1c6c47 | ||
|
|
58c08cebd7 | ||
|
|
fed0703ecf | ||
|
|
aaed1a934e | ||
|
|
11639af26e | ||
|
|
623ad2b1dc | ||
|
|
ac68fec6b1 | ||
|
|
dad49354aa | ||
|
|
ce4fa3c027 | ||
|
|
02d1a12bf5 | ||
|
|
78cbc3871e | ||
|
|
f9bb882ceb | ||
|
|
87fc6bde1d | ||
|
|
f666367b5d | ||
|
|
81c02f24c6 | ||
|
|
1d01ed92d8 | ||
|
|
1a7ced34a7 | ||
|
|
47ab94b5bc | ||
|
|
bea0778acc | ||
|
|
eeba5087b1 | ||
|
|
7bd8bf02f6 | ||
|
|
378f87a634 | ||
|
|
76dd5383ab | ||
|
|
129ca185e4 | ||
|
|
1f4ef42625 | ||
|
|
eb55e4def6 | ||
|
|
acda834ad9 | ||
|
|
aba3e30d9c | ||
|
|
c9e55ff1dc | ||
|
|
013c5e9e58 | ||
|
|
5e7f3dc24a | ||
|
|
2ffa174900 | ||
|
|
26cbe17218 | ||
|
|
fc8f1dca4e | ||
|
|
6b20a4f8f7 | ||
|
|
091025a304 | ||
|
|
1180789c0c | ||
|
|
ac056d4a06 | ||
|
|
7c196e098a | ||
|
|
c612b13529 | ||
|
|
5f4c79f6c4 | ||
|
|
302cbf641e | ||
|
|
4bc2e9ad44 | ||
|
|
6853c4c212 | ||
|
|
800e15cfd0 | ||
|
|
873f184117 | ||
|
|
3bae5cd5cb | ||
|
|
19300332e8 | ||
|
|
89d88c9644 | ||
|
|
472014b1b1 | ||
|
|
c094420428 | ||
|
|
e948064063 | ||
|
|
bdd3b7d2a5 | ||
|
|
404c37b54c | ||
|
|
ac686a17fa | ||
|
|
bfc5068b5e | ||
|
|
649bee2330 | ||
|
|
593587ea60 | ||
|
|
0ab81a7b32 | ||
|
|
8bf937357c | ||
|
|
1e8b1fda81 | ||
|
|
cba9212150 | ||
|
|
a0a6c42227 | ||
|
|
c245d9de80 | ||
|
|
ca5cd8e09b | ||
|
|
34ac4cd23b | ||
|
|
8598fe8ad9 | ||
|
|
3699a31f28 | ||
|
|
06498672ab | ||
|
|
cd3b92af7a | ||
|
|
e15cc29e2f | ||
|
|
dabeb066de | ||
|
|
c59e7cc456 | ||
|
|
3c16bfef58 | ||
|
|
ec24977d4e | ||
|
|
10b4f57a0e | ||
|
|
75cd5a75e1 | ||
|
|
fb2d0ed170 | ||
|
|
d4e139eaf5 | ||
|
|
49ef1276f6 | ||
|
|
828788b643 | ||
|
|
0ca8d7a258 | ||
|
|
75de49d151 | ||
|
|
d39e1c0c6e | ||
|
|
8e7f201ca8 | ||
|
|
85b2a9b0a0 | ||
|
|
d4e40faecc | ||
|
|
0be913ab18 | ||
|
|
bab30f3b61 | ||
|
|
abb599c556 | ||
|
|
2b6c6e9ab3 | ||
|
|
0db0d744da | ||
|
|
6b9f2d29fc | ||
|
|
2c141a5255 | ||
|
|
4f69a32700 | ||
|
|
3d4c08ad20 | ||
|
|
594d415976 | ||
|
|
ae50fde4e1 | ||
|
|
401461f1f0 | ||
|
|
676c6e106d | ||
|
|
d0a066ccd3 | ||
|
|
340e286277 | ||
|
|
9211d41984 | ||
|
|
686aa457d6 | ||
|
|
1b1431f0d0 | ||
|
|
cbcb46597d | ||
|
|
6644c85978 | ||
|
|
dd781fd86b | ||
|
|
97209846ad | ||
|
|
9744aa79b3 | ||
|
|
801648fcfe | ||
|
|
181fb9edb6 | ||
|
|
9ddbdfb80a | ||
|
|
1cab88181d | ||
|
|
803cc6e402 | ||
|
|
2e0b9f5ea5 | ||
|
|
fe60311072 | ||
|
|
de4a1d1e93 | ||
|
|
de36a2f4d1 | ||
|
|
57f6f3b318 | ||
|
|
8a3eb0d83b | ||
|
|
dd68b37a2a | ||
|
|
96793b39ba | ||
|
|
aa4f91b3b0 | ||
|
|
9ad44e6dc2 | ||
|
|
988b3d27b8 | ||
|
|
043cc13bb3 | ||
|
|
c0ee5f6563 | ||
|
|
f02d0ab1dd | ||
|
|
ff6d17990f | ||
|
|
9be52f639d | ||
|
|
586c419c46 | ||
|
|
73f02cc1bf | ||
|
|
eb27d24923 | ||
|
|
eeb056d509 | ||
|
|
3615912ce0 | ||
|
|
4518dfc0ca | ||
|
|
d5a7e8938d | ||
|
|
3d15844f7c | ||
|
|
62ed21b316 | ||
|
|
a178d43b01 | ||
|
|
ef2152beea | ||
|
|
e6475c1a9e | ||
|
|
091debd2a7 | ||
|
|
e7eff3e585 | ||
|
|
86a90e39d2 | ||
|
|
2887fbb251 | ||
|
|
fa6177b56d | ||
|
|
78524cdde7 | ||
|
|
6077d3f4c3 | ||
|
|
fd3acc456d | ||
|
|
257fe6dd3f | ||
|
|
cbb7cc93e9 | ||
|
|
8b608c5cce | ||
|
|
163fb14d0e | ||
|
|
e4f87bd805 | ||
|
|
864c7d96f1 | ||
|
|
e35e87fb05 | ||
|
|
3246bdbc8b | ||
|
|
710bb5fe1c | ||
|
|
53a52da709 | ||
|
|
4afbfc6e57 | ||
|
|
f7aa9efe13 | ||
|
|
1fce0ee551 | ||
|
|
ee695f9000 | ||
|
|
8f99ebb577 | ||
|
|
5bfafaf241 | ||
|
|
64e1a2ce4b | ||
|
|
27883c5beb | ||
|
|
2772725fe3 | ||
|
|
3f58a64827 | ||
|
|
cb37c7d218 | ||
|
|
88c1846e1a | ||
|
|
be3d559d8a | ||
|
|
45d951071f | ||
|
|
2ac60684fa | ||
|
|
af71742110 | ||
|
|
1adf27427a | ||
|
|
082f78eefa | ||
|
|
a8a9ec0023 | ||
|
|
df4f945bc6 | ||
|
|
ad756a5b86 | ||
|
|
2ca99ba669 | ||
|
|
6443575114 | ||
|
|
52a51d81f1 | ||
|
|
7d20b06e52 | ||
|
|
ad9d8a7200 | ||
|
|
44da699343 | ||
|
|
0a542f9be9 | ||
|
|
8f1601ca55 | ||
|
|
ff0ce164da | ||
|
|
3650c38aa9 | ||
|
|
61d97338e2 | ||
|
|
e27bb4de50 | ||
|
|
4462d8bf22 | ||
|
|
f23a8ac928 | ||
|
|
9e1750ee13 | ||
|
|
5cd284cb36 | ||
|
|
5ea58430fe | ||
|
|
acfbda0d91 | ||
|
|
437e5a62f1 | ||
|
|
bbb5aea77d | ||
|
|
b5d04f84e7 | ||
|
|
93b12eb14f | ||
|
|
0aa67c4cf2 | ||
|
|
1c1affac5c | ||
|
|
0919797edc | ||
|
|
94ac8fd837 | ||
|
|
ecc82b5b51 | ||
|
|
add021fd67 | ||
|
|
2daf309d7d | ||
|
|
20be4a40ea | ||
|
|
7de91da87a | ||
|
|
b8b48b533b | ||
|
|
535f981739 | ||
|
|
0404ac0395 | ||
|
|
f961625f03 | ||
|
|
7909bae065 | ||
|
|
7e6e117b17 | ||
|
|
314e64d7b1 | ||
|
|
8c72e77e0d | ||
|
|
77eb6b358f | ||
|
|
25f86e2542 | ||
|
|
8bc0461463 | ||
|
|
c9dd1ea71d | ||
|
|
85d3529bc3 | ||
|
|
3aac8bb072 | ||
|
|
e9a7e21aca | ||
|
|
fc0e4da33c | ||
|
|
ef3c1315dd | ||
|
|
5c12890faf | ||
|
|
c4fd5e0999 | ||
|
|
d3c56d635d | ||
|
|
c53cb49034 | ||
|
|
d38463c5d9 | ||
|
|
bc4b424f0e | ||
|
|
6bd4f3b7b4 | ||
|
|
d91d83f115 | ||
|
|
584b6ab219 | ||
|
|
04b155dbfb | ||
|
|
ddc5488db7 | ||
|
|
5c6906d5fd | ||
|
|
56fee5d286 | ||
|
|
c4dcab04b6 | ||
|
|
8dd9a96769 | ||
|
|
6864015af6 | ||
|
|
ebaa60e929 | ||
|
|
ac9962c624 | ||
|
|
ccd1773643 | ||
|
|
ac970ff768 | ||
|
|
53ff45425d | ||
|
|
de435c741f | ||
|
|
1dc9a44aec | ||
|
|
0206379315 | ||
|
|
c39adbbbc5 | ||
|
|
061a15d4f7 | ||
|
|
7c2518f027 | ||
|
|
a07459454b | ||
|
|
752f9d2694 | ||
|
|
0a180f9e20 | ||
|
|
6fff2e1c2f | ||
|
|
4266900d2e | ||
|
|
a2a1d84bc0 | ||
|
|
7648c562f1 | ||
|
|
403fd30926 | ||
|
|
17ccddf541 | ||
|
|
c24366fcec | ||
|
|
9a258a6265 | ||
|
|
4542ccbdc2 | ||
|
|
41d8ad2b86 | ||
|
|
a3a2ee118e | ||
|
|
f285efc277 | ||
|
|
fbaf87ec6c | ||
|
|
a005a468a7 | ||
|
|
c8d01549ba | ||
|
|
23af4505dd | ||
|
|
53cb6a5b3e | ||
|
|
765384ace1 | ||
|
|
d39e3e2f69 | ||
|
|
d75124066e | ||
|
|
f4400876da | ||
|
|
c222c5127f | ||
|
|
90d04956e6 | ||
|
|
5d3b918339 | ||
|
|
eba0091764 | ||
|
|
7999cbbea3 | ||
|
|
cee7987b35 | ||
|
|
d475c08024 | ||
|
|
d78f83ae49 | ||
|
|
df694f01e7 | ||
|
|
f5d9cbb11b | ||
|
|
d802588abe | ||
|
|
927d6d2fc6 | ||
|
|
bab7595078 | ||
|
|
1ea9a6c57f | ||
|
|
f479d415d8 | ||
|
|
f41e7be726 | ||
|
|
c1fe28124f | ||
|
|
01a1e506e4 | ||
|
|
e61aebb55d | ||
|
|
bae5bafc62 | ||
|
|
be6cb266de | ||
|
|
6f72edc2d9 | ||
|
|
29f66bdfed | ||
|
|
c1c6f5682c | ||
|
|
a8a74a0246 | ||
|
|
f9b867c3eb | ||
|
|
6c07f9a048 | ||
|
|
573e0acafa | ||
|
|
530c664967 | ||
|
|
12c29c8387 | ||
|
|
6c7f61d90f | ||
|
|
eb6d8d0bb3 | ||
|
|
ef462973c7 | ||
|
|
aa7e49cfde | ||
|
|
186048676a | ||
|
|
0f40721cff | ||
|
|
3799dd92fd | ||
|
|
9ea1a2b1de | ||
|
|
d8b27d122e | ||
|
|
15c3a6eae4 | ||
|
|
4fcc90d53e | ||
|
|
2619a50976 | ||
|
|
de116c95d4 | ||
|
|
47594c9b07 | ||
|
|
1b9098b564 | ||
|
|
b0306eac87 | ||
|
|
125e813d25 | ||
|
|
8e0d4a70f2 | ||
|
|
0556fc68b0 | ||
|
|
e9e2313159 | ||
|
|
dbb2f03a43 | ||
|
|
ed0dc2d887 | ||
|
|
0a93f2d0b0 | ||
|
|
fd581cd65c | ||
|
|
36702bc971 | ||
|
|
0fc3eb38f1 | ||
|
|
73c8e945e9 | ||
|
|
b8420303ba | ||
|
|
532bfcf937 | ||
|
|
f6d892023e | ||
|
|
7f2977f4af | ||
|
|
e246a2753b | ||
|
|
6d06a26c31 | ||
|
|
7cda21b60f | ||
|
|
1db740039b | ||
|
|
df462774aa | ||
|
|
f55fa789c4 | ||
|
|
488541f26e | ||
|
|
b404b1cf50 | ||
|
|
69370aa806 | ||
|
|
b3ddd85b09 | ||
|
|
033221fd01 | ||
|
|
1201fa38a8 | ||
|
|
32059c376e | ||
|
|
511d393c78 | ||
|
|
237601cf29 | ||
|
|
928f14872e | ||
|
|
c6a9adf96c | ||
|
|
cdd00e0bd4 | ||
|
|
2503d13402 | ||
|
|
2d97970d24 | ||
|
|
d8945e53ba | ||
|
|
f18012d07b | ||
|
|
104f8603b9 | ||
|
|
19bb083030 | ||
|
|
ae575a19a0 | ||
|
|
5f94d0a5c2 | ||
|
|
f2fe1a7c17 | ||
|
|
618e6a1604 | ||
|
|
cef294513a | ||
|
|
8550abadef | ||
|
|
25c8b2d631 | ||
|
|
e7b690205e | ||
|
|
2403f8833a | ||
|
|
9f25743b4d | ||
|
|
f1c76f65cf | ||
|
|
7b39533410 | ||
|
|
1fe9c39dd5 | ||
|
|
2b7be2e3f1 | ||
|
|
1ee9a3f279 | ||
|
|
679acfb239 | ||
|
|
3c7ab4b49b | ||
|
|
3f062e1c0a | ||
|
|
0a497d8c3f | ||
|
|
462351f485 | ||
|
|
c4cbb631a9 | ||
|
|
76f2d15b1b | ||
|
|
5d63865ae5 | ||
|
|
ad7c88fb45 | ||
|
|
1af3877758 | ||
|
|
146ce3b12b | ||
|
|
bf67721ac4 | ||
|
|
436f736a8e | ||
|
|
1446e90dd9 | ||
|
|
54716c03d1 | ||
|
|
fad5e97e0a | ||
|
|
8cf79590c5 | ||
|
|
c6aafac6c8 | ||
|
|
94a5995197 | ||
|
|
74081dc981 | ||
|
|
7a593b13a7 | ||
|
|
25dc38b2b1 | ||
|
|
403b12f7b7 | ||
|
|
cd223be88a | ||
|
|
a6a3fca1e7 | ||
|
|
63815eb5c2 | ||
|
|
4444264830 | ||
|
|
255f91f7ca | ||
|
|
700207d29b | ||
|
|
72d96e9a3b | ||
|
|
a55b6de1b4 | ||
|
|
9faac05666 | ||
|
|
7bf408aba0 | ||
|
|
70ee391b33 | ||
|
|
f5eb1158db | ||
|
|
81916d0f45 | ||
|
|
76d77cc244 | ||
|
|
03dccbe613 | ||
|
|
1ccec65619 | ||
|
|
b78e9062a1 | ||
|
|
dc87354702 | ||
|
|
033e8583db | ||
|
|
d46b51fa9a | ||
|
|
dd1dfdcfeb | ||
|
|
c0233c803d | ||
|
|
1fa8c88f6b | ||
|
|
195b109a36 | ||
|
|
994ac3fc8e | ||
|
|
a8ec5cf5e9 | ||
|
|
b4263aa3ec | ||
|
|
6456809a72 | ||
|
|
024c0a3186 | ||
|
|
560b1d48bc | ||
|
|
bb2d860807 | ||
|
|
6f1c0fa4a8 | ||
|
|
35808e7bde | ||
|
|
1b4eeb35b3 | ||
|
|
cee032bbc9 | ||
|
|
9547b70743 | ||
|
|
5df8939d84 | ||
|
|
0b9c689273 | ||
|
|
ac193cd97a | ||
|
|
7355a60f16 | ||
|
|
fb6f6325b5 | ||
|
|
0f767d9dfc | ||
|
|
d1addcab91 | ||
|
|
7a02cd794b | ||
|
|
258cd9209f | ||
|
|
700f6022d9 | ||
|
|
a0f6b815e8 | ||
|
|
54477b8b8f | ||
|
|
6183f8d4e9 | ||
|
|
d98e247665 | ||
|
|
d0cd976246 | ||
|
|
15f6f6a90a | ||
|
|
f18074bf49 | ||
|
|
3f64b74453 | ||
|
|
1c86256f83 | ||
|
|
98105ad4dc | ||
|
|
6bf2d6c1ab | ||
|
|
cebd51aac1 | ||
|
|
42b8b3aa75 | ||
|
|
c0eaf79d25 | ||
|
|
fb2fe3eb63 | ||
|
|
184d63f7eb | ||
|
|
14ebd58c96 | ||
|
|
3edddb8e91 | ||
|
|
d2340dff1a | ||
|
|
d30c6aec7d | ||
|
|
4854b3e08f | ||
|
|
facc748090 | ||
|
|
5c71612e34 | ||
|
|
f00a5fbaf4 | ||
|
|
34769da9cc | ||
|
|
458e6ed531 | ||
|
|
05814e9351 | ||
|
|
b6c0b1b396 | ||
|
|
1a299d85b6 | ||
|
|
1816274ebe | ||
|
|
b02e4c5308 | ||
|
|
12ed42e163 | ||
|
|
6c9c135062 | ||
|
|
6aea0160df | ||
|
|
30edd9e8dd | ||
|
|
7734402e8e | ||
|
|
ace1332ca5 | ||
|
|
baa313e8f8 | ||
|
|
3d9aa24f3c | ||
|
|
c287d457d6 | ||
|
|
7537b27a58 | ||
|
|
1f560c92fc | ||
|
|
74cd11c763 | ||
|
|
ee7d89331b | ||
|
|
5b51077823 | ||
|
|
d2f94d1945 | ||
|
|
0170a099bb | ||
|
|
2b893d0ea1 | ||
|
|
a08da57cbb | ||
|
|
a313fe5a86 | ||
|
|
544de699f6 | ||
|
|
d9d35b7f50 | ||
|
|
7dbec00f0e | ||
|
|
51b9b40c7e | ||
|
|
b2383a084a | ||
|
|
61848c5e24 | ||
|
|
60b2f7d243 | ||
|
|
d2a5e126ae | ||
|
|
9d7d8ddde9 | ||
|
|
249ebeb4aa | ||
|
|
378c14d790 | ||
|
|
30c1093c2f | ||
|
|
b966c8cb0b | ||
|
|
38cddf029b | ||
|
|
6652a27781 | ||
|
|
08b067cfc5 | ||
|
|
4959b84b4c | ||
|
|
d42562fdcb | ||
|
|
1e0aacd811 | ||
|
|
329469fe84 | ||
|
|
93b0c5a7e5 | ||
|
|
9e456fd315 | ||
|
|
8203c71b03 | ||
|
|
80d1e9a9a7 | ||
|
|
3c27e57b19 | ||
|
|
b46b2f048d | ||
|
|
8d403f579c | ||
|
|
12b274ab43 | ||
|
|
986cccb800 | ||
|
|
5da8728d6c | ||
|
|
66c9a1e90a | ||
|
|
a1925e1d0b | ||
|
|
da0910b1e5 | ||
|
|
8dbbe34dfc | ||
|
|
947d552509 | ||
|
|
037bc4ea2b | ||
|
|
cfbef141d8 | ||
|
|
410ad0dc09 | ||
|
|
3d9b42f0c2 | ||
|
|
eeea21c882 | ||
|
|
d94e5480c9 | ||
|
|
a5c8e87e6d | ||
|
|
08f74201b6 | ||
|
|
3a25c683b6 | ||
|
|
fb43f8bf1a | ||
|
|
bf082600c3 | ||
|
|
7596c66703 | ||
|
|
e1bcf6c47e | ||
|
|
ef1d6c78ac | ||
|
|
f36406af08 | ||
|
|
4b7d215d9d | ||
|
|
e09f12dc0b | ||
|
|
efa7406741 | ||
|
|
5a2181c064 | ||
|
|
dda81b12da | ||
|
|
c4bf67d133 | ||
|
|
f355c8679d | ||
|
|
095864de39 | ||
|
|
0eb196e852 | ||
|
|
62e5d8d841 | ||
|
|
2f82fb842d | ||
|
|
f9fa6abbad | ||
|
|
4b55a69150 | ||
|
|
42e12fae24 | ||
|
|
2f55d5130a | ||
|
|
cd4b47b397 | ||
|
|
126cba1e94 | ||
|
|
e4e894fa54 | ||
|
|
65f701d459 | ||
|
|
c2b7cc7964 | ||
|
|
969d1dff2a | ||
|
|
e0fab808b9 | ||
|
|
77031d7082 | ||
|
|
5a0f7ea706 | ||
|
|
9d041c4b62 | ||
|
|
ec4d29c327 | ||
|
|
5f8d8988e3 | ||
|
|
a31912f710 | ||
|
|
e0d42962e7 | ||
|
|
47688bf016 | ||
|
|
39a695959d | ||
|
|
71d45a67b7 | ||
|
|
8dc1369ba3 | ||
|
|
1206654d98 | ||
|
|
1492763d0c | ||
|
|
285fafc464 | ||
|
|
b15cc59b95 | ||
|
|
55cfe31dfe | ||
|
|
dafa6e0310 | ||
|
|
4befe17cab | ||
|
|
2217b560cb | ||
|
|
39d01a1da8 | ||
|
|
4e14ad7821 | ||
|
|
aee5a2cbe4 | ||
|
|
de2d5aec1a | ||
|
|
bea03de562 | ||
|
|
0aeccbb02c | ||
|
|
4e11152e76 | ||
|
|
5059028e8a | ||
|
|
070e6cf848 | ||
|
|
4187fe7261 | ||
|
|
bdec147874 | ||
|
|
189fc76dad | ||
|
|
c0a68005d4 | ||
|
|
8187e4cdc2 | ||
|
|
cc98fd4167 | ||
|
|
422e014eff | ||
|
|
dd4e044608 | ||
|
|
13fad1ca47 | ||
|
|
70aaa29016 | ||
|
|
7dcec9afcf | ||
|
|
608642fc25 | ||
|
|
dd62c08b09 | ||
|
|
315fc21eca | ||
|
|
8cfd3aeda9 | ||
|
|
6061323c36 | ||
|
|
17da8b04bf | ||
|
|
3a948406d5 | ||
|
|
91c52f8ec8 | ||
|
|
6076bbb554 | ||
|
|
f70d3359c4 | ||
|
|
2dbfbe36c3 | ||
|
|
a25bd03566 | ||
|
|
109da1c2cc | ||
|
|
9a48e25bb1 | ||
|
|
a3ade200a9 | ||
|
|
eb1901f03d | ||
|
|
f8c7cdfc28 | ||
|
|
ea58d84b55 | ||
|
|
1360caaa81 | ||
|
|
315a7b9e6a | ||
|
|
79311d107b | ||
|
|
77435fcbd7 | ||
|
|
4395c07648 | ||
|
|
f9cc77382a | ||
|
|
e4fce08eff | ||
|
|
47196cbc55 | ||
|
|
c0bf301434 | ||
|
|
f6671f8561 | ||
|
|
26aab2961b | ||
|
|
c233abe3a4 | ||
|
|
beb3646bef | ||
|
|
eb8330a420 | ||
|
|
7f3c2176f8 | ||
|
|
1d0fdd68f4 | ||
|
|
b26c78828e | ||
|
|
85648c7f11 | ||
|
|
8588f446aa | ||
|
|
d723c5c1c7 | ||
|
|
7897f2489c | ||
|
|
86e2e0a2c3 | ||
|
|
e2349019a3 | ||
|
|
e485044cfb | ||
|
|
72d80e2857 | ||
|
|
79a4733698 | ||
|
|
c64e1daa99 | ||
|
|
d6b4933b05 | ||
|
|
bcf9cee0f8 | ||
|
|
a2960a7997 | ||
|
|
dac9874895 | ||
|
|
a4d374ecb6 | ||
|
|
3e56c8ed8b | ||
|
|
f4c11d14e7 | ||
|
|
dde805931d | ||
|
|
fedc721432 | ||
|
|
b09cb24804 | ||
|
|
80bfeb1a29 | ||
|
|
63ad51a637 | ||
|
|
5ee6232bfc | ||
|
|
b7d399faf7 | ||
|
|
28691bb8a0 | ||
|
|
fd61f35f78 | ||
|
|
0505b59781 | ||
|
|
a3601e5167 | ||
|
|
99f63ab64d | ||
|
|
bb2a9fe180 | ||
|
|
e9c7c7ee4c | ||
|
|
ff7d4f237a | ||
|
|
8bf9f8057e | ||
|
|
27b0f531d7 | ||
|
|
01e96d3086 | ||
|
|
95e7a7c8eb | ||
|
|
bbc2f4766e | ||
|
|
12dde5154f | ||
|
|
5bc3609ad7 | ||
|
|
5c1cdea3c6 | ||
|
|
3da5b3a278 | ||
|
|
9f6460ddae | ||
|
|
f1dcf85d7b | ||
|
|
7b78edf38f | ||
|
|
4a726a0c75 | ||
|
|
5afa7e9fc3 | ||
|
|
75c102f304 | ||
|
|
68f3c10055 | ||
|
|
e9aeda2a34 | ||
|
|
45c7a110b6 | ||
|
|
e438e6aedb | ||
|
|
8dd888bcbd | ||
|
|
5f12291ac4 | ||
|
|
e206d78a52 | ||
|
|
d94a82b0a7 | ||
|
|
3bee3d1701 | ||
|
|
631352e1ef | ||
|
|
f2d5dee49e | ||
|
|
2d578c7cd9 | ||
|
|
b07ff100d1 | ||
|
|
b0c10b2248 | ||
|
|
7b8249442d | ||
|
|
8221339318 | ||
|
|
b773af96b8 | ||
|
|
dbc7808c70 | ||
|
|
77c5000f16 | ||
|
|
56928b6ca0 | ||
|
|
8178dfe7bd | ||
|
|
0db6c667c6 | ||
|
|
2b0a642827 | ||
|
|
f71c0f8cb8 | ||
|
|
3782372f65 | ||
|
|
9e35e42030 | ||
|
|
7a8195e54c | ||
|
|
b50ee28693 | ||
|
|
e134f910aa | ||
|
|
17eb6e47eb | ||
|
|
82ce626d8a | ||
|
|
e063ff5e54 | ||
|
|
5aa98966bc | ||
|
|
fca2746a82 | ||
|
|
7faffc2de7 | ||
|
|
86a8a9dc85 | ||
|
|
c13a0c1c26 | ||
|
|
6ce3c070b8 | ||
|
|
e1cb11da22 | ||
|
|
c628ea34b7 | ||
|
|
33b7c726f6 | ||
|
|
6f3fd424e1 | ||
|
|
b048ce9c8e | ||
|
|
6a1040d659 | ||
|
|
fc05c28231 | ||
|
|
5d165bc6df | ||
|
|
c139b5eabb | ||
|
|
d6dd0e551d | ||
|
|
a84a7bb7c3 | ||
|
|
7195ae6e46 | ||
|
|
3c70b2f033 | ||
|
|
c46340a830 | ||
|
|
8d703b1459 | ||
|
|
f1145ef169 | ||
|
|
a28f9ceeba | ||
|
|
1927bb4798 | ||
|
|
d4c77f9786 | ||
|
|
021f8d0331 | ||
|
|
e7d25550ee | ||
|
|
8227276437 | ||
|
|
38ef76bcdc | ||
|
|
7faa0f60b4 | ||
|
|
faebbb2b8a | ||
|
|
bc9beb1e87 | ||
|
|
f161f723d7 | ||
|
|
6c94550de3 | ||
|
|
b39a45781a | ||
|
|
9273c9ee10 | ||
|
|
e6285914b0 | ||
|
|
7d2eb83a1b | ||
|
|
7e622f1153 | ||
|
|
9b30a634b1 | ||
|
|
e897d2ef81 | ||
|
|
f5b177dda8 | ||
|
|
5f51b5d565 | ||
|
|
8d7753fb40 | ||
|
|
4c6f5744d8 | ||
|
|
43eb2932ba | ||
|
|
59de0e7a4a | ||
|
|
7b204cf910 | ||
|
|
b587a19a0f | ||
|
|
e58420b031 | ||
|
|
24313d6709 | ||
|
|
7acb30b981 | ||
|
|
7454620aa2 | ||
|
|
abb0799817 | ||
|
|
aebd28dbef | ||
|
|
152db9fb8e | ||
|
|
980cd520cd | ||
|
|
373ec8b5a1 | ||
|
|
bacb78e9e8 | ||
|
|
333e112e37 | ||
|
|
818d5d782f | ||
|
|
8774090086 | ||
|
|
0ca65c6d61 | ||
|
|
c38daac646 | ||
|
|
c31f5b1d59 | ||
|
|
2320a56a63 | ||
|
|
07bd91b456 | ||
|
|
803f7c3a4b | ||
|
|
a1926982c6 | ||
|
|
b3306d50eb | ||
|
|
3e6e5f95ec | ||
|
|
df71fb42ac | ||
|
|
fe81a354a3 | ||
|
|
67ba2e49c3 | ||
|
|
8dec42f295 | ||
|
|
5942553370 | ||
|
|
ae5d31746e | ||
|
|
1c1976abbf | ||
|
|
b3465ddf89 | ||
|
|
f67fafdb8e | ||
|
|
ffcac677e0 | ||
|
|
a9d643aa55 | ||
|
|
fa3647e8e5 | ||
|
|
db839f6d6d | ||
|
|
3a85d5b89f | ||
|
|
1575c2bc10 | ||
|
|
57189183d6 | ||
|
|
01c5cf98df | ||
|
|
9ad2995168 | ||
|
|
51fc6518e1 | ||
|
|
530db4e904 | ||
|
|
cd92ebd69c | ||
|
|
5c58552d91 | ||
|
|
584aebf76b | ||
|
|
43a2480699 | ||
|
|
699503042f | ||
|
|
02e71c23de | ||
|
|
c24c3868bb | ||
|
|
5c60819668 | ||
|
|
480a125a20 | ||
|
|
598a6ebaed | ||
|
|
185ad5e747 | ||
|
|
42d7e4312b | ||
|
|
41a741724f | ||
|
|
087e811586 | ||
|
|
fa07bc143e | ||
|
|
e13f5ed730 | ||
|
|
48108cebc9 | ||
|
|
ecac17a00a | ||
|
|
3ba215887c | ||
|
|
edbc1baf32 | ||
|
|
500fa7f314 | ||
|
|
a10dfa4ab4 | ||
|
|
b208571ed7 | ||
|
|
c1ec27045c | ||
|
|
111b12161c | ||
|
|
d23d18933c | ||
|
|
f0e736962d | ||
|
|
b12d1491d4 | ||
|
|
6d1a094b15 | ||
|
|
88d14792a4 | ||
|
|
7780a98abe | ||
|
|
a1248db3e7 | ||
|
|
6fd2d12d3f | ||
|
|
9fab52c044 | ||
|
|
a32f55d64e | ||
|
|
96d2b001ea | ||
|
|
e38d6c9f9e | ||
|
|
be129d243b | ||
|
|
c85355986b | ||
|
|
310c0e8379 | ||
|
|
f0dbffe4f8 | ||
|
|
598a482538 | ||
|
|
a995f3ab52 | ||
|
|
ec5454de44 | ||
|
|
ec55bddbd4 | ||
|
|
808591df56 | ||
|
|
96ae3da1e0 | ||
|
|
4f13df69c7 | ||
|
|
6d305e4a84 | ||
|
|
d3dab982a1 | ||
|
|
2f6adbae3c | ||
|
|
ccdc1eed5a | ||
|
|
65dee154f7 | ||
|
|
662db009de | ||
|
|
d07d8f6857 | ||
|
|
0327f6b1ea | ||
|
|
16dea2ee09 | ||
|
|
5e3fe139fc | ||
|
|
55d41fca05 | ||
|
|
0b7bb29557 | ||
|
|
6b683bd02d | ||
|
|
8f1a498953 | ||
|
|
293ed9065d | ||
|
|
8908fb7ee0 | ||
|
|
2877178b34 | ||
|
|
d527139f48 | ||
|
|
b3d8180541 | ||
|
|
3411c340ab | ||
|
|
4482089712 | ||
|
|
c8ce2343d7 | ||
|
|
d547d04277 | ||
|
|
8f1191733b | ||
|
|
00bdbcf857 | ||
|
|
bf8070c42d | ||
|
|
346a0b84ae | ||
|
|
ad48381744 | ||
|
|
0f30d7744d | ||
|
|
095a978120 | ||
|
|
1b72646772 | ||
|
|
a7b129147f | ||
|
|
6496a6643f | ||
|
|
e172217427 | ||
|
|
8c67eee4c8 | ||
|
|
ca9039b8d5 | ||
|
|
e260632a45 | ||
|
|
678f4fca8a | ||
|
|
5d88d07edc | ||
|
|
08aa591c65 | ||
|
|
f2a8edb29f | ||
|
|
50d7e8dc3d | ||
|
|
8403e36d4d | ||
|
|
2dda326cc4 | ||
|
|
9002a8db04 | ||
|
|
5ec5198dda | ||
|
|
0326b7d7ac | ||
|
|
2f5e7f3b2d | ||
|
|
0e17658269 | ||
|
|
87edda5972 | ||
|
|
ab8c3c2b75 | ||
|
|
44cef002ed | ||
|
|
bc80fe693a | ||
|
|
1898b51dc2 | ||
|
|
a5dcf5958e | ||
|
|
9fba72cbab | ||
|
|
912fdeaf09 | ||
|
|
36c417458d | ||
|
|
f1591e593a | ||
|
|
117ac0f5d6 | ||
|
|
e72a42fd2d | ||
|
|
e6e2f4c22c | ||
|
|
07b6e2b9f1 | ||
|
|
5ab10f4024 | ||
|
|
0ac08456bc | ||
|
|
80a3549ef5 | ||
|
|
770d5eb257 | ||
|
|
b32499f6ec | ||
|
|
d9819d8b3d | ||
|
|
932b825818 | ||
|
|
a0cbc5822e | ||
|
|
2ab50c6b61 | ||
|
|
d7426f6d35 | ||
|
|
8f15266f0a | ||
|
|
936c7190c7 | ||
|
|
3452984b8e | ||
|
|
3e17890528 | ||
|
|
2a7c50d356 | ||
|
|
05bca368c2 | ||
|
|
89c78f6030 | ||
|
|
b59b0259ca | ||
|
|
e46e1b20de | ||
|
|
7089abcef2 | ||
|
|
e6148a97a3 | ||
|
|
9e40033a92 | ||
|
|
08d4e19851 | ||
|
|
dcc0768411 | ||
|
|
f14062c721 | ||
|
|
0508b70658 | ||
|
|
04f8545397 | ||
|
|
633f985360 | ||
|
|
a649a6ebac | ||
|
|
634a8b4532 | ||
|
|
f3709a41e3 | ||
|
|
2bfebfee3c | ||
|
|
76ab5fbf78 | ||
|
|
c0b0c74638 | ||
|
|
6c0b771758 | ||
|
|
2f983fc305 | ||
|
|
3cf0d60f5d | ||
|
|
751e76b453 | ||
|
|
c2f95f7953 | ||
|
|
924b994df2 | ||
|
|
b10de5e82c | ||
|
|
65ffce8db2 | ||
|
|
58aeb2e40f | ||
|
|
141d737ca5 | ||
|
|
d0fd53a2ca | ||
|
|
3e0a6ea2cf | ||
|
|
758ad3eb06 | ||
|
|
b132a66707 | ||
|
|
f241f12ddb | ||
|
|
e1daf9467c | ||
|
|
5457ddb44f | ||
|
|
6fee13b0a5 | ||
|
|
2b17e173f5 | ||
|
|
569d4a5d8b | ||
|
|
51a88a23ac | ||
|
|
f41504ca57 | ||
|
|
bacb7018cb | ||
|
|
671ed3c2fe | ||
|
|
372e994617 | ||
|
|
e4560df62f | ||
|
|
920daf7fde | ||
|
|
ad1a15faaa | ||
|
|
459cf2e380 | ||
|
|
8d058a53fd | ||
|
|
d864ae9fef | ||
|
|
f1eeb61264 | ||
|
|
1418dd8b29 | ||
|
|
0297980ca3 | ||
|
|
5e94aaa2cb | ||
|
|
b929a8fe2e | ||
|
|
8c2f0bacf1 | ||
|
|
0bc02de012 | ||
|
|
411a282063 | ||
|
|
6c4d55622b | ||
|
|
e214bf3581 | ||
|
|
78e29d2bbf | ||
|
|
a93c10b794 | ||
|
|
3240d6f11a | ||
|
|
d5f38fe2f2 | ||
|
|
d4b1680727 | ||
|
|
b04e5760fb | ||
|
|
42c629ca45 | ||
|
|
68f45beb20 | ||
|
|
ea95897bbd | ||
|
|
4d1dc0c949 | ||
|
|
9fc892f723 | ||
|
|
5541381afe | ||
|
|
ed12bae6aa | ||
|
|
1520c1ebab | ||
|
|
790190e5c3 | ||
|
|
24889f7dcd | ||
|
|
8397685430 | ||
|
|
fc411c5c1c | ||
|
|
3a91f43bbb | ||
|
|
5e1f1675b8 | ||
|
|
9946987f69 | ||
|
|
526181a76b | ||
|
|
ce8f8c05e1 | ||
|
|
3844b88f7e | ||
|
|
db3c232173 | ||
|
|
22b77af9d3 | ||
|
|
3e29732e46 | ||
|
|
54e1efd794 | ||
|
|
8809c1634f | ||
|
|
13e1be1f74 | ||
|
|
26a123f5a8 | ||
|
|
f062fda2f7 | ||
|
|
e45e31d223 | ||
|
|
101261ca63 | ||
|
|
4ba9a19b5c | ||
|
|
f8eab7d611 | ||
|
|
40a9f19352 | ||
|
|
4b81e0d8af | ||
|
|
ea37bf8b45 | ||
|
|
c30f8b09b0 | ||
|
|
686f931fb4 | ||
|
|
1fe1e6f265 | ||
|
|
860decdac5 | ||
|
|
d5b90c91f5 | ||
|
|
20d6e365a1 | ||
|
|
e5e50c2220 | ||
|
|
e8da7baee2 | ||
|
|
8ab9e6bac7 | ||
|
|
9129301c89 | ||
|
|
9545e0145f | ||
|
|
15d3e4023b | ||
|
|
205e4dedd1 | ||
|
|
324d796aca | ||
|
|
5b31e8e9d8 | ||
|
|
0afb62ee88 | ||
|
|
1b0d053ab9 | ||
|
|
5871c4f092 | ||
|
|
5d415e6679 | ||
|
|
3a7384ec26 | ||
|
|
1d3a8bcacd | ||
|
|
dd187aef08 | ||
|
|
78b2c4d094 | ||
|
|
32b7a314b1 | ||
|
|
c8d768c59a | ||
|
|
3ef1c9167f | ||
|
|
36cdcbc3c1 | ||
|
|
83876532d0 | ||
|
|
edc824d05e | ||
|
|
9a7869dd40 | ||
|
|
1aa247d4da | ||
|
|
5db9f28b33 | ||
|
|
8599ad4a3c | ||
|
|
448c2a27d4 | ||
|
|
f2f4fa1b98 | ||
|
|
6f43a189c0 | ||
|
|
dd4de9822f | ||
|
|
c9e83e0517 | ||
|
|
4ac63950ad | ||
|
|
7a0b2c958b | ||
|
|
3fcc37e086 | ||
|
|
55181cec8c | ||
|
|
41d259006e | ||
|
|
93e8ec7f06 | ||
|
|
ba1d1c3bac | ||
|
|
fbaff2b75b | ||
|
|
9774e8807b | ||
|
|
b30103c790 | ||
|
|
bb9408b5d0 | ||
|
|
42c3c7bc48 | ||
|
|
464040895c | ||
|
|
525747dc53 | ||
|
|
c61d992559 | ||
|
|
2f79b079fd | ||
|
|
655bc39d85 | ||
|
|
1eb12d4fa0 | ||
|
|
2ab9186259 | ||
|
|
ab61aef985 | ||
|
|
65b3e9f8c1 | ||
|
|
1f57aa1ea5 | ||
|
|
340d827377 | ||
|
|
5cd25e24e4 | ||
|
|
58afc92a26 | ||
|
|
acb9931fe6 | ||
|
|
d4b035ac1a | ||
|
|
403dd5c005 | ||
|
|
7e4e1ec68f | ||
|
|
547764e3c1 | ||
|
|
541a7974e0 | ||
|
|
6bf6f82cad | ||
|
|
7be2325a95 | ||
|
|
fa1f739458 | ||
|
|
20289ff81b | ||
|
|
6d67d30aee | ||
|
|
bd0bd2e087 | ||
|
|
3d79799450 | ||
|
|
c99f9205b7 | ||
|
|
26bb54472f | ||
|
|
73e13fee37 | ||
|
|
205c1ac3b6 | ||
|
|
d317744f05 | ||
|
|
47611b7615 | ||
|
|
6420a51dd0 | ||
|
|
7c17d5bac0 | ||
|
|
0efd7c93c5 | ||
|
|
806be9551c | ||
|
|
b4dd3a9889 | ||
|
|
6b4a1b6758 | ||
|
|
4510b69798 | ||
|
|
84a3ee209a | ||
|
|
d6b0fccbda | ||
|
|
d1e31da2e5 | ||
|
|
923d32ee6d | ||
|
|
4b0fe879cb | ||
|
|
b87aeffcd8 | ||
|
|
88aafec6e3 | ||
|
|
6fe9dae3d6 | ||
|
|
2cb6ddf3ca | ||
|
|
799622a932 | ||
|
|
4c1e22b0f6 | ||
|
|
2283652704 | ||
|
|
33fb2daabf | ||
|
|
c79f59ec05 | ||
|
|
845aaad891 | ||
|
|
3c0b061220 | ||
|
|
af7de73f5c | ||
|
|
1a8a9f0047 | ||
|
|
a3b4e8db44 | ||
|
|
f9e8875803 | ||
|
|
e4c11d9a88 | ||
|
|
6d1d8da101 | ||
|
|
77303e668f | ||
|
|
72725b91c7 | ||
|
|
46f50f55c2 | ||
|
|
5e880f6bfa | ||
|
|
058a73f8a0 | ||
|
|
1ad8d34ecb | ||
|
|
3f9f926c8e | ||
|
|
80cf88dcc1 | ||
|
|
dddc7f348f | ||
|
|
ce45f2e114 | ||
|
|
d22a7c0a63 | ||
|
|
59162155de | ||
|
|
0f347cd0b4 | ||
|
|
1f983db47c | ||
|
|
dc50793733 | ||
|
|
b98329f91c | ||
|
|
587d8fbfa9 | ||
|
|
26a2e9ef53 | ||
|
|
e5ca98a1d3 | ||
|
|
5bd5e9000e | ||
|
|
d566642c98 | ||
|
|
f81ddc60ec | ||
|
|
6e0b20c921 | ||
|
|
0c308b38c5 | ||
|
|
8e0fdf68e4 | ||
|
|
9c7a9b5674 | ||
|
|
0a49e31b30 | ||
|
|
9478206202 | ||
|
|
c86e6f5b88 | ||
|
|
87868acecd | ||
|
|
6d877754da | ||
|
|
dd5521a07c | ||
|
|
3a6a84917b | ||
|
|
cca142ce86 | ||
|
|
fa3567cb9f | ||
|
|
7d22230b13 | ||
|
|
9694c796e3 | ||
|
|
1b7f684ab2 | ||
|
|
fef8f4d29c | ||
|
|
0d7e945623 | ||
|
|
13ea8eae77 | ||
|
|
cdb2ef3ac7 | ||
|
|
f216e0198f | ||
|
|
c5c3698f43 | ||
|
|
299d3b9f60 | ||
|
|
eaaebeaebb | ||
|
|
2ef2d2b9c5 | ||
|
|
da6698b216 | ||
|
|
c9f391dfc1 | ||
|
|
0f62926623 | ||
|
|
a856b4027b | ||
|
|
e2f72ecffc | ||
|
|
d888bcd473 | ||
|
|
0bfd5fa9a3 | ||
|
|
9c05ccef69 | ||
|
|
c7eb2ffe5c | ||
|
|
5281b6df77 | ||
|
|
cd5bb6a309 | ||
|
|
94a44d7af4 | ||
|
|
662050b89f | ||
|
|
3f7f3140eb | ||
|
|
a419694f70 | ||
|
|
0a20f77b08 | ||
|
|
dc11d18161 | ||
|
|
cde83e9d7d | ||
|
|
1476fda014 | ||
|
|
7a875f2db4 | ||
|
|
b868f37da5 | ||
|
|
9bef5a62dd | ||
|
|
d1aff30c9e | ||
|
|
a356dafde0 | ||
|
|
09477384fe | ||
|
|
6b923542e8 | ||
|
|
9722cf718c | ||
|
|
702b973c87 | ||
|
|
472372c9ed | ||
|
|
d358f0d27b | ||
|
|
d66bbd95f0 | ||
|
|
aae498509b | ||
|
|
4987fb5f15 | ||
|
|
b1ed299286 | ||
|
|
679ac3e5b1 | ||
|
|
181ef788a3 | ||
|
|
d2caa0953f | ||
|
|
3f88e02587 | ||
|
|
245da9b422 | ||
|
|
8cc075aff3 | ||
|
|
128a243166 | ||
|
|
0e41365020 | ||
|
|
bd6d5ffbb9 | ||
|
|
de7951f4db | ||
|
|
bdbf1fbb43 | ||
|
|
a7b6010ce2 | ||
|
|
5bba109873 | ||
|
|
d69ae60bcb | ||
|
|
a0277aba2e | ||
|
|
caba631db9 | ||
|
|
5095620005 | ||
|
|
abcdc0875c | ||
|
|
a4e41a57d7 | ||
|
|
e8bb3864e3 | ||
|
|
3e03d52fce | ||
|
|
4f64d466fb | ||
|
|
3102c545ce | ||
|
|
3cd1066a8d | ||
|
|
6494b7ea89 | ||
|
|
f232b327c0 | ||
|
|
204ed1f257 | ||
|
|
2f5d13ac10 | ||
|
|
65a379c8da | ||
|
|
99df5fadbc | ||
|
|
c8e6dca263 | ||
|
|
9dec40eca7 | ||
|
|
92cdb27e23 | ||
|
|
4896043599 | ||
|
|
5f0ddeedd0 | ||
|
|
e679e760ee | ||
|
|
a439688b3c | ||
|
|
0d17757729 | ||
|
|
899bbc2dbc | ||
|
|
57b68880db | ||
|
|
06c59763bc | ||
|
|
71c1d16c06 | ||
|
|
64c1b72481 | ||
|
|
e5742e057d | ||
|
|
a9d6176fd2 | ||
|
|
1b0aa2a9b1 | ||
|
|
a49c230bb2 | ||
|
|
b65749cf70 | ||
|
|
0cf54a6a03 | ||
|
|
4d77277f2d | ||
|
|
8b81506ed3 | ||
|
|
24c6509a61 | ||
|
|
3c32c4160d | ||
|
|
1f912d86e1 | ||
|
|
9c93ab0b6d | ||
|
|
6646a20a5d | ||
|
|
92f471c476 | ||
|
|
4c7ce97650 | ||
|
|
4d1fc994c0 | ||
|
|
c4310c554e | ||
|
|
c603326e58 | ||
|
|
a93e04a44e | ||
|
|
db9e649f6e | ||
|
|
c26aca4686 | ||
|
|
f822268ae1 | ||
|
|
4ebcf40619 | ||
|
|
a884b94ac0 | ||
|
|
194e705982 | ||
|
|
c77ec3bf20 | ||
|
|
0a1857249b | ||
|
|
3be3a1f2e6 | ||
|
|
62f9488829 | ||
|
|
9bcaef192c | ||
|
|
bcb1630f20 | ||
|
|
5f7922d7fd | ||
|
|
66b1d297ba | ||
|
|
eb4780a952 | ||
|
|
34f724a4a4 | ||
|
|
c5b250236f | ||
|
|
e5b122ee61 | ||
|
|
3b20021981 | ||
|
|
a7d1f180a4 | ||
|
|
68374e7c62 | ||
|
|
ba26a97ddc | ||
|
|
2db7ce8da1 | ||
|
|
6958da1adb | ||
|
|
cf48cd0ae5 | ||
|
|
b1b3966d41 | ||
|
|
c171a37f24 | ||
|
|
c13f1991c9 | ||
|
|
da15cc4de7 | ||
|
|
44c686f494 | ||
|
|
03bd5ad426 | ||
|
|
914a3d71c2 | ||
|
|
5c2e0935c6 | ||
|
|
e1ec604655 | ||
|
|
0dad10d6ab | ||
|
|
136138daab | ||
|
|
6efe563a69 | ||
|
|
fd068443aa | ||
|
|
82d0f62d73 | ||
|
|
01ba6ddecd | ||
|
|
769b379a8b | ||
|
|
1b981e0695 | ||
|
|
9798b9fd50 | ||
|
|
10792c0bc6 | ||
|
|
1c61afd3ee | ||
|
|
737ef583ee | ||
|
|
7b4365bd8a | ||
|
|
041fce743e | ||
|
|
ad4904a0ec | ||
|
|
42a1bca64d | ||
|
|
492a5bbb38 | ||
|
|
c40ef22c20 | ||
|
|
783aac561a | ||
|
|
02245c150c | ||
|
|
54a93775e4 | ||
|
|
ca778aac70 | ||
|
|
007ca4c6b0 | ||
|
|
b3dfce7b5a | ||
|
|
c75f1685c5 | ||
|
|
db5b103ab3 | ||
|
|
1925b7b324 | ||
|
|
b2f1c9e832 | ||
|
|
cff4eebb74 | ||
|
|
a3aab5aeca | ||
|
|
63e5d8f7ea | ||
|
|
e4df7b10f6 | ||
|
|
f39a1e7d03 | ||
|
|
a473f6aa16 | ||
|
|
6907c24690 | ||
|
|
ef3d8a9277 | ||
|
|
1a183b7f17 | ||
|
|
88f7b30128 | ||
|
|
4b38389dc8 | ||
|
|
865a45044f | ||
|
|
7378d06bfd | ||
|
|
55e19de8a1 | ||
|
|
4d7cb06481 | ||
|
|
7179a2995d | ||
|
|
2b853df75b | ||
|
|
ae6bcc2987 | ||
|
|
ed61e5c7f7 | ||
|
|
3581ac5ebd | ||
|
|
1f369b47d7 | ||
|
|
bb9049bef4 | ||
|
|
94f15aba40 | ||
|
|
b16b8388ef | ||
|
|
b1e89e7904 | ||
|
|
f48e2f3b18 | ||
|
|
bd673a3f26 | ||
|
|
51ec699649 | ||
|
|
ed6be510fb | ||
|
|
55f05ba839 | ||
|
|
17c9382a21 | ||
|
|
43c0eda2be | ||
|
|
f2c5515317 | ||
|
|
c1441eb758 | ||
|
|
cf92fb921d | ||
|
|
559ca3e97b | ||
|
|
7c095175ab | ||
|
|
3b2635014c | ||
|
|
755040444a | ||
|
|
59afb012b6 | ||
|
|
7d9a52301c | ||
|
|
50a53181dc | ||
|
|
36f6fec99f | ||
|
|
83eeb488f9 | ||
|
|
5394a35e1a | ||
|
|
0cd68ff8f8 | ||
|
|
e9ae8063db | ||
|
|
1c4e23512b | ||
|
|
51bdfa44b1 | ||
|
|
98d0a397a3 | ||
|
|
1dc060123d | ||
|
|
14349cb583 | ||
|
|
eca959034c | ||
|
|
9844550d6c | ||
|
|
82fcf08d84 | ||
|
|
845a35a9b8 | ||
|
|
0e4751ebee | ||
|
|
56badd44f3 | ||
|
|
399b3fd198 | ||
|
|
43a7ca7fe8 | ||
|
|
b951624ed3 | ||
|
|
1b21f2d1c7 | ||
|
|
43ea0effa2 | ||
|
|
6df9b95dea | ||
|
|
630aa53d98 | ||
|
|
40c81b88d4 | ||
|
|
027a317291 | ||
|
|
81b538556d | ||
|
|
6aece1cf8c | ||
|
|
cd7b9d31c9 | ||
|
|
03a6e6fc6a | ||
|
|
1d1aae03f3 | ||
|
|
b47ad50d42 | ||
|
|
a924fd0e7e | ||
|
|
82ae908e6a | ||
|
|
8e497e2a48 | ||
|
|
cbb4565a48 | ||
|
|
471fbee090 | ||
|
|
d66de937d9 | ||
|
|
3ea230fd17 | ||
|
|
34bc571f80 | ||
|
|
db46804bfe | ||
|
|
2bd0faac2e | ||
|
|
a9a6e58d60 | ||
|
|
b40f980c62 | ||
|
|
12ac781ef8 | ||
|
|
8373ffbf10 | ||
|
|
0233dca884 | ||
|
|
c1a3162a54 | ||
|
|
fc2f5c3615 | ||
|
|
3a5ac9df10 | ||
|
|
63f634af00 | ||
|
|
9cb3eefdc4 | ||
|
|
1c9e9da10f | ||
|
|
71c0ba63ca | ||
|
|
c04d3b2ace | ||
|
|
e8497bb0cc | ||
|
|
3430349dd1 | ||
|
|
fa6a5f75af | ||
|
|
7b9eb4c87c | ||
|
|
808411bc0b | ||
|
|
c3ab510b57 | ||
|
|
cbc653be37 | ||
|
|
e9efe5bbb7 | ||
|
|
a7c234b272 | ||
|
|
bb64d0dd54 | ||
|
|
f82b478a77 | ||
|
|
2028642efe | ||
|
|
9af9bd0c4c | ||
|
|
662bf83a88 | ||
|
|
2d474ccbda | ||
|
|
cec746d632 | ||
|
|
8371ac5b0d | ||
|
|
f248788d14 | ||
|
|
bf202f25dd | ||
|
|
2d2472dbe9 | ||
|
|
3adfa3c2a8 | ||
|
|
bf05155c5e | ||
|
|
d50df6a6fc | ||
|
|
a2b38c8d05 | ||
|
|
d546da8b5f | ||
|
|
7c60ffa88d | ||
|
|
6b235ab083 | ||
|
|
7c4cdef66d | ||
|
|
c0a2da443a | ||
|
|
e53658759b | ||
|
|
6dc4c1c03a | ||
|
|
818c3b6092 | ||
|
|
6e5dee13e1 | ||
|
|
cae78622f6 | ||
|
|
c5db677663 | ||
|
|
c6942daf74 | ||
|
|
ea644a2293 | ||
|
|
01e69ce2b0 | ||
|
|
187a017c4d | ||
|
|
f9ce1d17c8 | ||
|
|
ef4cd6a4a7 | ||
|
|
80c8dcacb3 | ||
|
|
0ad2dea722 | ||
|
|
dec3c45f6c | ||
|
|
32a73ad4b9 | ||
|
|
452e03b894 | ||
|
|
01bdddaee4 | ||
|
|
f7c82b0920 | ||
|
|
820eeb7752 | ||
|
|
2e25ef6f81 | ||
|
|
5736d2c9cc | ||
|
|
056a1f6a33 | ||
|
|
f96e211cd6 | ||
|
|
0d473cbe18 | ||
|
|
95514b05ca | ||
|
|
dc622a9bd5 | ||
|
|
3ddd1d5f21 | ||
|
|
c528421a8e | ||
|
|
ea15f0690c | ||
|
|
8751ef7439 | ||
|
|
8c393e3144 | ||
|
|
a3ef2a43ac | ||
|
|
d2b3029f67 | ||
|
|
3e800ec7c8 | ||
|
|
47d963b585 | ||
|
|
397ae3407e | ||
|
|
3f9e2d5d39 | ||
|
|
31449552d1 | ||
|
|
5f2fee5a99 | ||
|
|
db63c91f99 | ||
|
|
9c87c36644 | ||
|
|
be9f5ad951 | ||
|
|
d065a0cbc4 | ||
|
|
02dfa638ca | ||
|
|
bd71e779c3 | ||
|
|
18d83b8c50 | ||
|
|
fc2e16dd4e | ||
|
|
e156badef6 | ||
|
|
ae6d379cce | ||
|
|
1a414ac69c | ||
|
|
f82099143f | ||
|
|
93743b11b2 | ||
|
|
a94696e037 | ||
|
|
0255e8980b | ||
|
|
eff9c69069 | ||
|
|
2dccd2f30b | ||
|
|
b775cbb3bf | ||
|
|
79ef6f2f75 | ||
|
|
451ac297d4 | ||
|
|
0fd8a4507c | ||
|
|
49c7e7ce2d | ||
|
|
1af7d01d96 | ||
|
|
66c6938df0 | ||
|
|
bb9fb04788 | ||
|
|
f5cf2b2b55 | ||
|
|
3e8afaeae4 | ||
|
|
43169ced69 | ||
|
|
708844857d | ||
|
|
abe2e544bb | ||
|
|
ce777348b3 | ||
|
|
c052325487 | ||
|
|
ce69410f49 | ||
|
|
5f0be0cc7f | ||
|
|
dca6347ea9 | ||
|
|
94c4db9072 | ||
|
|
7f63be2cd2 | ||
|
|
1236dea4c5 | ||
|
|
c5c46df613 | ||
|
|
a96269150a | ||
|
|
75e347e8e3 | ||
|
|
d641cc5057 | ||
|
|
cf64145ff3 | ||
|
|
195eca6b09 | ||
|
|
b0ef077e48 | ||
|
|
e40a698d1a | ||
|
|
69c34b1b27 | ||
|
|
4700c2583d | ||
|
|
6cf79a3c73 | ||
|
|
2c110f7796 | ||
|
|
aebea0b57f | ||
|
|
8684455ea5 | ||
|
|
7cbb103376 | ||
|
|
9cf8ec5dd7 | ||
|
|
f5187b1533 | ||
|
|
6230a65a79 | ||
|
|
f13c96839e | ||
|
|
776f68c9dd | ||
|
|
714ed89a4c | ||
|
|
0b2b29b7cf | ||
|
|
a41c0a0519 | ||
|
|
026e28114e | ||
|
|
0840719289 | ||
|
|
aad875e113 | ||
|
|
6b059d94ba | ||
|
|
39eeaea7e7 | ||
|
|
81a8e91180 | ||
|
|
4fc6f6f59b | ||
|
|
dd2f573f27 | ||
|
|
ff8ddc431b | ||
|
|
d703945aa3 | ||
|
|
f4aba5f9ea | ||
|
|
393113c3e3 | ||
|
|
f2db18820a | ||
|
|
e04d300e18 | ||
|
|
685f836f41 | ||
|
|
d4f5ad641a | ||
|
|
007d437ee8 | ||
|
|
00e380e8d8 | ||
|
|
56749d9494 | ||
|
|
cf10d37c90 | ||
|
|
f9de34e36d | ||
|
|
aa889be140 | ||
|
|
6da6838bde | ||
|
|
07a0be303f | ||
|
|
ddbe0af290 | ||
|
|
e71f0f44a4 | ||
|
|
39f3bc7100 | ||
|
|
211a145e58 | ||
|
|
d2339b915f | ||
|
|
24c2651745 | ||
|
|
36e95b93b4 | ||
|
|
e7a44e0b15 | ||
|
|
fbdb21ac72 | ||
|
|
c9522cf6ae | ||
|
|
7bf9d334ad | ||
|
|
422ff93dcd | ||
|
|
eee1ea7a09 | ||
|
|
b90e482add | ||
|
|
875b51720b | ||
|
|
5272d4f9e3 | ||
|
|
c980f4f6e3 | ||
|
|
89525330c4 | ||
|
|
806db24c0e | ||
|
|
ba7d6df5a4 | ||
|
|
112301e0e0 | ||
|
|
c07065e457 | ||
|
|
b9e1afae17 | ||
|
|
549b4a9ebf | ||
|
|
fa9a3fb7c4 | ||
|
|
ccb15f278a | ||
|
|
f0fb4b8842 | ||
|
|
dacaf293b2 | ||
|
|
627d0e4e6f | ||
|
|
f32b9e26e0 | ||
|
|
db2b1a0a35 | ||
|
|
f734a60c62 | ||
|
|
9aa815c1ed | ||
|
|
e0772500c9 | ||
|
|
78c5522966 | ||
|
|
718f79775e | ||
|
|
4261c1768a | ||
|
|
01603185c3 | ||
|
|
f1adf24f3b | ||
|
|
856765a775 | ||
|
|
075da34cdb | ||
|
|
5ce543002d | ||
|
|
700b1c50af | ||
|
|
9e1c363a0a | ||
|
|
bbe3065f19 | ||
|
|
1716a0ebca | ||
|
|
ed66339e94 | ||
|
|
441774e61c | ||
|
|
c6fd14afd2 | ||
|
|
27ed9ca7fd | ||
|
|
50fda906bd | ||
|
|
6c7c60037b | ||
|
|
91a429ea77 | ||
|
|
2dbe01e90a | ||
|
|
3d7dd41223 | ||
|
|
91495c8595 | ||
|
|
c3e997168a | ||
|
|
c3e6f4f7b6 | ||
|
|
e600ec95ed | ||
|
|
cbd5853389 | ||
|
|
4e3a086993 | ||
|
|
5f23dfb034 | ||
|
|
99f59490a3 | ||
|
|
da82887cc0 | ||
|
|
45a59f9aec | ||
|
|
57408d18ae | ||
|
|
3a97db804f | ||
|
|
4a44b35ea5 | ||
|
|
47aafe9042 | ||
|
|
53d94a1d3d | ||
|
|
5dd3c7c8e8 | ||
|
|
0c2a13f27f | ||
|
|
da0d3133df | ||
|
|
7abd9a3db9 | ||
|
|
98b9f57e0e | ||
|
|
e064ccd585 | ||
|
|
b5a63ed3fc | ||
|
|
147edddb90 | ||
|
|
4b8a91fb8c | ||
|
|
4fb677ed23 | ||
|
|
4f0bd7f461 | ||
|
|
01eecdb698 | ||
|
|
5ca41a6fff | ||
|
|
e4f71420fc | ||
|
|
d5456ed1db | ||
|
|
e3335c5843 | ||
|
|
067e6bf93d | ||
|
|
13dc31dc1f | ||
|
|
7f6bf21270 | ||
|
|
d647258856 | ||
|
|
1eb7ed5e9c | ||
|
|
e78f1b05a7 | ||
|
|
e45140b7ea | ||
|
|
41747a7a04 | ||
|
|
e448430d8a | ||
|
|
394b1a1602 | ||
|
|
85abd5a8c3 | ||
|
|
b9e0eb5b76 | ||
|
|
a8eae73b66 | ||
|
|
9edd8d6f66 | ||
|
|
0cfb53cea4 | ||
|
|
4d8f7c67d4 | ||
|
|
e53337bcdc | ||
|
|
e5d883f97e | ||
|
|
548a55792c | ||
|
|
43f0f2a0fd | ||
|
|
7b1c696810 | ||
|
|
8d69c3764d | ||
|
|
87acd9d7ee | ||
|
|
06391c9de6 | ||
|
|
b42b41216b | ||
|
|
0a1d215560 | ||
|
|
44b6136ce2 | ||
|
|
ba3c6023a8 | ||
|
|
be7f6ae7d1 | ||
|
|
984c7a67f5 | ||
|
|
a4bf6c1f7a | ||
|
|
690ae1a7b6 | ||
|
|
eae9a10a7d | ||
|
|
7c6765b969 | ||
|
|
a6c143a1c7 | ||
|
|
714da0ab3b | ||
|
|
377ec37257 | ||
|
|
b349f0a2fb |
@@ -0,0 +1,12 @@
|
||||
# EditorConfig reference: https://editorconfig.org
|
||||
# https://editorconfig.org/#file-format-details
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
@@ -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: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [24.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
|
||||
@@ -0,0 +1,180 @@
|
||||
name: Main branch - Build Testbook with fresh frameworks and manual tests & deploy to GitHub Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pages: write # required by deploy-pages
|
||||
id-token: write # required by deploy-pages
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout cappuccino (this repo)
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Checkout Cappuccino-Testbook into ./testbook
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
repository: ArgosOz/Cappuccino-Testbook
|
||||
path: testbook
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24.x
|
||||
|
||||
- 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
|
||||
|
||||
# Refresh Frameworks from dist → testbook/Frameworks
|
||||
- name: Refresh Frameworks
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ ! -d dist ]; then
|
||||
echo "❌ dist/ not found at repo root" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p testbook/Frameworks
|
||||
rm -rf testbook/Frameworks/*
|
||||
cp -a dist/cappuccino/Frameworks/{Foundation,AppKit} testbook/Frameworks/
|
||||
cp -a dist/objective-j/Frameworks/Objective-J testbook/Frameworks/
|
||||
echo "Frameworks populated:" && ls -la testbook/Frameworks || true
|
||||
|
||||
- name: Generate manifest of manual test directories
|
||||
if: ${{ hashFiles('Tests/Manual/**') != '' }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p artifacts
|
||||
OUT="testbook/Resources/recipes.txt"
|
||||
: > "$OUT"
|
||||
|
||||
if [ ! -d "Tests/Manual" ]; then
|
||||
echo "❌ Tests/Manual not found at repo root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Iterate over immediate subdirectories of Tests/Manual (null-safe for spaces)
|
||||
while IFS= read -r -d '' d; do
|
||||
name=$(basename "$d")
|
||||
ts=$(date +%s%3N) # milliseconds since epoch
|
||||
printf '%s|%s|\n' "$ts" "$name" >> "$OUT"
|
||||
# Optional tiny sleep to help keep timestamps distinct:
|
||||
sleep 0.01
|
||||
done < <(find "Tests/Manual" -mindepth 1 -maxdepth 1 -type d -print0 | sort -z)
|
||||
|
||||
echo "Wrote $OUT:"
|
||||
cat "$OUT"
|
||||
|
||||
# Replace subdirectories inside testbook/Resources with Tests/Manual subdirectories
|
||||
- name: Sync Resources from Tests/Manual
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ ! -d "Tests/Manual" ]; then
|
||||
echo "❌ Tests/Manual not found at repo root" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p testbook/Resources
|
||||
# Remove only immediate subdirectories (keep stray files if any)
|
||||
find testbook/Resources -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -r rm -rf
|
||||
# Copy each immediate subdirectory from Tests/Manual → testbook/Resources
|
||||
while IFS= read -r -d '' d; do
|
||||
cp -a "$d" testbook/Resources/
|
||||
done < <(find Tests/Manual -mindepth 1 -maxdepth 1 -type d -print0)
|
||||
echo "Resources now contains:" && ls -la testbook/Resources || true
|
||||
|
||||
# Ensure each test Index.html includes the include path line before OBJJ_MAIN_FILE
|
||||
- name: Inject OBJJ_INCLUDE_PATHS into Index.html files
|
||||
run: |
|
||||
set -euo pipefail
|
||||
found=0
|
||||
while IFS= read -r -d '' f; do
|
||||
found=1
|
||||
if grep -q 'OBJJ_INCLUDE_PATHS' "$f"; then
|
||||
echo "Already updated: $f"
|
||||
continue
|
||||
fi
|
||||
perl -0777 -i -pe 's/OBJJ_MAIN_FILE\s*=\s*"main\.j";/OBJJ_INCLUDE_PATHS = ["..\/..\/Frameworks"];\nOBJJ_MAIN_FILE = "main.j";/i' "$f"
|
||||
perl -0777 -i -pe 's/Frameworks\/Objective-J\/Objective-J.js/\.\.\/\.\.\/Frameworks\/Objective-J\/Objective-J.js/' "$f"
|
||||
echo "Updated: $f"
|
||||
done < <(find testbook/Resources -mindepth 2 -maxdepth 2 -type f -iname "index.html" -print0)
|
||||
|
||||
if [ "$found" -eq 0 ]; then
|
||||
echo "⚠️ No index.html files found under testbook/Resources/*/" >&2
|
||||
fi
|
||||
|
||||
# Optional: prune VCS/CI metadata from the served content
|
||||
- name: Clean testbook for Pages (optional)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
test -f testbook/index.html
|
||||
test -d testbook/Resources
|
||||
test -d testbook/Frameworks
|
||||
rm -rf testbook/.git testbook/.github || true
|
||||
find testbook -maxdepth 1 -type f -name ".git*" -delete || true
|
||||
|
||||
- name: Publish to gh-pages (preserve PR previews)
|
||||
uses: JamesIves/github-pages-deploy-action@v4
|
||||
with:
|
||||
branch: gh-pages
|
||||
folder: testbook
|
||||
clean-exclude: pr-preview/ # keep PR preview folders
|
||||
force: false # avoid force-push so previews survive
|
||||
|
||||
- name: Checkout gh-pages ./gh-pages
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
path: gh-pages
|
||||
ref: gh-pages
|
||||
|
||||
- name: Clean gh-pages for Pages
|
||||
run: |
|
||||
set -euo pipefail
|
||||
test -d gh-pages
|
||||
rm -rf gh-pages/.git gh-pages/.github || true
|
||||
find gh-pages -maxdepth 1 -type f -name ".git*" -delete || true
|
||||
find gh-pages -type f -name "*.xib" -delete || true
|
||||
find gh-pages -type f -name "*xcode*" -delete || true
|
||||
find gh-pages -name "Jakefile" -delete || true
|
||||
|
||||
- name: Upload Pages artifact (testbook/)
|
||||
uses: actions/upload-pages-artifact@v4
|
||||
with:
|
||||
path: gh-pages
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: true
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
|
||||
- name: Comment Pages URL on PR
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const url = `${{ toJSON(steps.deployment.outputs.page_url) }}`;
|
||||
const body = `📄 GitHub Pages preview for this PR:\n\n${url}`;
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body
|
||||
});
|
||||
+11
@@ -17,3 +17,14 @@ 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
|
||||
/dist/cappuccino/bin
|
||||
Tests/Manual/.Frameworks
|
||||
/Tests/Manual/index.html
|
||||
|
||||
+28
@@ -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
|
||||
|
||||
+10
-2
@@ -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"
|
||||
@@ -92,21 +93,28 @@
|
||||
@import "CPSlider.j"
|
||||
@import "CPSound.j"
|
||||
@import "CPSplitView.j"
|
||||
@import "CPStackView.j"
|
||||
@import "CPStepper.j"
|
||||
@import "CPTableColumn.j"
|
||||
@import "CPTableView.j"
|
||||
@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"
|
||||
@import "CPWorkspace.j"
|
||||
@import "CPFontPanel.j"
|
||||
@import "CPTreeController.j"
|
||||
|
||||
+10
-10
@@ -172,7 +172,7 @@ var bottomHeight = 71;
|
||||
BOOL _needsLayout;
|
||||
}
|
||||
|
||||
#pragma mark Creating Alerts
|
||||
// MARK: Creating Alerts
|
||||
|
||||
/*!
|
||||
Returns a CPAlert object with the provided info
|
||||
@@ -249,8 +249,8 @@ var bottomHeight = 71;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegate
|
||||
// MARK: -
|
||||
// MARK: Delegate
|
||||
|
||||
/*!
|
||||
Set the delegate of the receiver
|
||||
@@ -272,7 +272,7 @@ var bottomHeight = 71;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Accessors
|
||||
// MARK: Accessors
|
||||
|
||||
- (CPTheme)theme
|
||||
{
|
||||
@@ -402,7 +402,7 @@ var bottomHeight = 71;
|
||||
_needsLayout = YES;
|
||||
}
|
||||
|
||||
#pragma mark Accessing Buttons
|
||||
// MARK: Accessing Buttons
|
||||
|
||||
/*!
|
||||
Adds a button with a given title to the receiver.
|
||||
@@ -438,7 +438,7 @@ var bottomHeight = 71;
|
||||
[_buttons insertObject:button atIndex:0];
|
||||
}
|
||||
|
||||
#pragma mark Layout
|
||||
// MARK: Layout
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
@@ -664,7 +664,7 @@ var bottomHeight = 71;
|
||||
_needsLayout = NO;
|
||||
}
|
||||
|
||||
#pragma mark Displaying Alerts
|
||||
// MARK: Displaying Alerts
|
||||
|
||||
/*!
|
||||
Displays the \c CPAlert panel as a modal dialog. The user will not be
|
||||
@@ -742,7 +742,7 @@ var bottomHeight = 71;
|
||||
[self beginSheetModalForWindow:aWindow modalDelegate:nil didEndSelector:nil contextInfo:nil];
|
||||
}
|
||||
|
||||
#pragma mark Private
|
||||
// MARK: Private
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
@@ -821,12 +821,12 @@ var bottomHeight = 71;
|
||||
else if (_modalDelegate)
|
||||
{
|
||||
if (_didEndSelector)
|
||||
objj_msgSend(_modalDelegate, _didEndSelector, self, returnCode, contextInfo);
|
||||
_modalDelegate.isa.objj_msgSend3(_modalDelegate, _didEndSelector, self, returnCode, contextInfo);
|
||||
}
|
||||
else if (_delegate)
|
||||
{
|
||||
if (_didEndSelector)
|
||||
objj_msgSend(_delegate, _didEndSelector, self, returnCode);
|
||||
_delegate.isa.objj_msgSend2(_delegate, _didEndSelector, self, returnCode);
|
||||
else
|
||||
[self _sendDelegateAlertDidEndReturnCode:returnCode];
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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];
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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 + ">";
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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
|
||||
+56
-15
@@ -47,6 +47,8 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
@protocol CPApplicationDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (CPApplicationTerminateReply)applicationShouldTerminate:(CPApplication)sender;
|
||||
- (CPString)applicationShouldTerminateMessage:(CPApplication)sender;
|
||||
- (void)applicationDidBecomeActive:(CPNotification)aNotification;
|
||||
- (void)applicationDidChangeScreenParameters:(CPNotification)aNotification;
|
||||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification;
|
||||
@@ -58,6 +60,9 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
|
||||
@end
|
||||
|
||||
var CPApplicationDelegate_applicationShouldTerminate_ = 1 << 0,
|
||||
CPApplicationDelegate_applicationShouldTerminateMessage_ = 1 << 1;
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPApplication
|
||||
@@ -103,6 +108,8 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
|
||||
//
|
||||
id <CPApplicationDelegate> _delegate;
|
||||
CPInteger _implementedDelegateMethods;
|
||||
|
||||
BOOL _finishedLaunching;
|
||||
BOOL _isActive;
|
||||
|
||||
@@ -125,7 +132,7 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
+ (CPApplication)sharedApplication
|
||||
{
|
||||
if (!CPApp)
|
||||
CPApp = [[CPApplication alloc] init];
|
||||
CPApp = [[self alloc] init];
|
||||
|
||||
return CPApp;
|
||||
}
|
||||
@@ -165,6 +172,8 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
if (_delegate == aDelegate)
|
||||
return;
|
||||
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter],
|
||||
delegateNotifications =
|
||||
[
|
||||
@@ -205,6 +214,12 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
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_
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -426,12 +441,7 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
{
|
||||
// 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
|
||||
@@ -445,6 +455,9 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
|
||||
- (void)activateIgnoringOtherApps:(BOOL)shouldIgnoreOtherApps
|
||||
{
|
||||
if (_isActive)
|
||||
return;
|
||||
|
||||
[self _willBecomeActive];
|
||||
|
||||
[CPPlatform activateIgnoringOtherApps:shouldIgnoreOtherApps];
|
||||
@@ -455,6 +468,9 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
|
||||
- (void)deactivate
|
||||
{
|
||||
if (!_isActive)
|
||||
return;
|
||||
|
||||
[self _willResignActive];
|
||||
|
||||
[CPPlatform deactivate];
|
||||
@@ -463,7 +479,7 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
[self _didResignActive];
|
||||
}
|
||||
|
||||
- (void)isActive
|
||||
- (BOOL)isActive
|
||||
{
|
||||
return _isActive;
|
||||
}
|
||||
@@ -480,6 +496,15 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
- (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
|
||||
@@ -603,11 +628,6 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
|
||||
var theWindow = [anEvent window];
|
||||
|
||||
// Check if this is a candidate for key equivalent...
|
||||
if ([anEvent _couldBeKeyEquivalent] && [self _handleKeyEquivalent:anEvent])
|
||||
// The key equivalent was handled.
|
||||
return;
|
||||
|
||||
if ([anEvent type] == CPMouseMoved)
|
||||
{
|
||||
if (theWindow !== _lastMouseMoveWindow)
|
||||
@@ -644,6 +664,11 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
|
||||
_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];
|
||||
}
|
||||
@@ -959,7 +984,7 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
*/
|
||||
- (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));
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1195,6 +1220,22 @@ var CPMainCibFile = @"CPMainCibFile",
|
||||
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)
|
||||
@@ -1317,7 +1358,7 @@ var _CPAppBootstrapperActions = nil;
|
||||
{
|
||||
var action = _CPAppBootstrapperActions.shift();
|
||||
|
||||
if (objj_msgSend(self, action))
|
||||
if (self.isa.objj_msgSend0(self, action))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ CPApplicationWillResignActiveNotification = @"CPApplicationWillResignA
|
||||
CPApplicationDidResignActiveNotification = @"CPApplicationDidResignActiveNotification";
|
||||
CPApplicationDidChangeScreenParametersNotification = @"CPApplicationDidChangeScreenParametersNotification";
|
||||
|
||||
@typedef CPApplicationTerminateReply
|
||||
CPTerminateNow = YES;
|
||||
CPTerminateCancel = NO;
|
||||
CPTerminateLater = -1; // not currently supported
|
||||
|
||||
+25
-26
@@ -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.
|
||||
|
||||
+46
-2
@@ -231,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];
|
||||
}
|
||||
@@ -250,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];
|
||||
}
|
||||
@@ -378,3 +378,47 @@ var DefaultLineWidth = 1.0;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPBezierPath (AnimationAdditions)
|
||||
|
||||
- (CPString)SVGString
|
||||
{
|
||||
var pathString = "";
|
||||
var elements = _path.elements;
|
||||
var count = _path.count;
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var element = elements[i];
|
||||
|
||||
// Use the kCGPathElement* constants defined in CGPath.j
|
||||
switch (element.type)
|
||||
{
|
||||
case kCGPathElementMoveToPoint:
|
||||
pathString += "M " + element.x + " " + element.y + " ";
|
||||
break;
|
||||
|
||||
case kCGPathElementAddLineToPoint:
|
||||
pathString += "L " + element.x + " " + element.y + " ";
|
||||
break;
|
||||
|
||||
case kCGPathElementAddQuadCurveToPoint:
|
||||
pathString += "Q " + element.cpx + " " + element.cpy + " " + element.x + " " + element.y + " ";
|
||||
break;
|
||||
|
||||
case kCGPathElementAddCurveToPoint:
|
||||
pathString += "C " + element.cp1x + " " + element.cp1y + " " + element.cp2x + " " + element.cp2y + " " + element.x + " " + element.y + " ";
|
||||
break;
|
||||
|
||||
case kCGPathElementCloseSubpath:
|
||||
pathString += "Z ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pathString.trim();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+371
-58
@@ -22,13 +22,14 @@
|
||||
|
||||
@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
|
||||
@@ -58,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
|
||||
@@ -90,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
|
||||
};
|
||||
}
|
||||
|
||||
@@ -114,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;
|
||||
@@ -155,6 +178,8 @@ CPBelowBottom = 6;
|
||||
*/
|
||||
- (CPBorderType)borderType
|
||||
{
|
||||
CPLog.warn("CPBox borderType is deprecated.");
|
||||
|
||||
return _borderType;
|
||||
}
|
||||
|
||||
@@ -177,7 +202,8 @@ CPBelowBottom = 6;
|
||||
return;
|
||||
|
||||
_borderType = aBorderType;
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
[self refreshDisplay];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -217,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];
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// 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.
|
||||
// MARK: borderColor
|
||||
- (CPColor)borderColor
|
||||
{
|
||||
return [self valueForThemeAttribute:@"border-color"];
|
||||
@@ -231,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.
|
||||
// MARK: borderWidth
|
||||
- (float)borderWidth
|
||||
{
|
||||
return [self valueForThemeAttribute:@"border-width"];
|
||||
@@ -244,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.
|
||||
// MARK: cornerRadius
|
||||
- (float)cornerRadius
|
||||
{
|
||||
return [self valueForThemeAttribute:@"corner-radius"];
|
||||
@@ -257,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.
|
||||
// MARK: fillColor
|
||||
- (CPColor)fillColor
|
||||
{
|
||||
return [self valueForThemeAttribute:@"background-color"];
|
||||
@@ -270,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;
|
||||
|
||||
@@ -286,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
|
||||
@@ -320,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
|
||||
@@ -347,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.
|
||||
|
||||
@@ -365,25 +506,39 @@ CPBelowBottom = 6;
|
||||
return _titleView;
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the rectangle in which the receiver’s 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;
|
||||
|
||||
@@ -391,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];
|
||||
@@ -440,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;
|
||||
@@ -475,9 +645,6 @@ CPBelowBottom = 6;
|
||||
switch (_borderType)
|
||||
{
|
||||
case CPBezelBorder:
|
||||
[self _drawBezelBorderInRect:bounds];
|
||||
break;
|
||||
|
||||
case CPGrooveBorder:
|
||||
case CPLineBorder:
|
||||
[self _drawLineBorderInRect:bounds];
|
||||
@@ -594,11 +761,83 @@ CPBelowBottom = 6;
|
||||
|
||||
@end
|
||||
|
||||
// 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
|
||||
|
||||
// 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)
|
||||
|
||||
@@ -611,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;
|
||||
@@ -628,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
|
||||
|
||||
+14
-19
@@ -42,7 +42,6 @@
|
||||
- (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;
|
||||
- (CPImage)browser:(CPBrowser)browser imageValueForItem:(id)item;
|
||||
- (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;
|
||||
@@ -62,19 +61,18 @@ var CPBrowserDelegate_browser_acceptDrop_atRow_column_dropOperation_
|
||||
CPBrowserDelegate_browser_shouldSelectRowIndexes_inColumn_ = 1 << 4,
|
||||
CPBrowserDelegate_browser_writeRowsWithIndexes_inColumn_toPasteboard_ = 1 << 5,
|
||||
CPBrowserDelegate_browser_validateDrop_proposedRow_column_dropOperation_ = 1 << 6,
|
||||
CPBrowserDelegate_browser_imageValueForItem_ = 1 << 7,
|
||||
CPBrowserDelegate_browser_draggingImageForRowsWithIndexes_inColumn_withEvent_offset_ = 1 << 8,
|
||||
CPBrowserDelegate_browser_imageValueForItem_ = 1 << 9,
|
||||
CPBrowserDelegate_browser_selectionIndexesForProposedSelection_inColumn_ = 1 << 10,
|
||||
CPBrowserDelegate_browser_numberOfChildrenOfItem_ = 1 << 11,
|
||||
CPBrowserDelegate_browser_draggingViewForRowsWithIndexes_inColumn_withEvent_offset_ = 1 << 12,
|
||||
CPBrowserDelegate_browser_child_ofItem_ = 1 << 13,
|
||||
CPBrowserDelegate_browser_objectValueForItem_ = 1 << 14,
|
||||
CPBrowserDelegate_rootItemForBrowser_ = 1 << 15,
|
||||
CPBrowserDelegate_browser_didChangeLastColumn_toColumn_ = 1 << 16,
|
||||
CPBrowserDelegate_browser_didResizeColumn_ = 1 << 17,
|
||||
CPBrowserDelegate_browserSelectionIsChanging_ = 1 << 18,
|
||||
CPBrowserDelegate_browserSelectionDidChange_ = 1 << 19;
|
||||
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
|
||||
@@ -211,9 +209,6 @@ var CPBrowserDelegate_browser_acceptDrop_atRow_column_dropOperation_
|
||||
if ([_delegate respondsToSelector:@selector(browser:validateDrop:proposedRow:column:dropOperation:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_validateDrop_proposedRow_column_dropOperation_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:imageValueForItem:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_imageValueForItem_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:draggingImageForRowsWithIndexes:inColumn:withEvent:offset:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_draggingImageForRowsWithIndexes_inColumn_withEvent_offset_;
|
||||
|
||||
@@ -468,7 +463,7 @@ var CPBrowserDelegate_browser_acceptDrop_atRow_column_dropOperation_
|
||||
|
||||
- (id)itemAtRow:(CPInteger)row inColumn:(CPInteger)column
|
||||
{
|
||||
return [_tableDelegates[column] childAtIndex:row];
|
||||
return [_tableDelegates[column] childAtIndex:row] || nil;
|
||||
}
|
||||
|
||||
- (BOOL)isLeafItem:(id)item
|
||||
@@ -478,7 +473,7 @@ var CPBrowserDelegate_browser_acceptDrop_atRow_column_dropOperation_
|
||||
|
||||
- (id)parentForItemsInColumn:(CPInteger)column
|
||||
{
|
||||
return [_tableDelegates[column] _item];
|
||||
return [_tableDelegates[column] _item] || nil;
|
||||
}
|
||||
|
||||
- (CPSet)selectedItems
|
||||
|
||||
+252
-172
@@ -44,6 +44,7 @@ CPTexturedRoundedBezelStyle = 11; // Round Textured
|
||||
CPRoundRectBezelStyle = 12; // Round Rect
|
||||
CPRecessedBezelStyle = 13; // Recessed
|
||||
CPRoundedDisclosureBezelStyle = 14; // Disclosure
|
||||
CPInlineBezelStyle = 15; // Inline
|
||||
CPHUDBezelStyle = -1;
|
||||
|
||||
|
||||
@@ -72,14 +73,32 @@ CPPushInCellMask = CPPushInButtonMask;
|
||||
CPChangeGrayCellMask = CPGrayButtonMask;
|
||||
CPChangeBackgroundCellMask = CPBackgroundButtonMask;
|
||||
|
||||
CPButtonStateMixed = CPThemeState("mixed");
|
||||
CPButtonStateBezelStyleRounded = CPThemeState("rounded");
|
||||
CPButtonStateBezelStyleRoundRect = CPThemeState("roundRect");
|
||||
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: CPButtonStateBezelStyleRoundRect,
|
||||
CPRoundedBezelStyle: CPButtonStateBezelStyleRounded,
|
||||
CPShadowlessSquareBezelStyle: CPButtonStateBezelStyleShadowlessSquare,
|
||||
CPSmallSquareBezelStyle: CPButtonStateBezelStyleSmallSquare,
|
||||
CPTexturedRoundedBezelStyle: CPButtonStateBezelStyleTexturedRounded,
|
||||
CPRoundRectBezelStyle: CPButtonStateBezelStyleRoundRect,
|
||||
CPRecessedBezelStyle: CPButtonStateBezelStyleRecessed,
|
||||
CPInlineBezelStyle: CPButtonStateBezelStyleInline,
|
||||
CPRegularSquareBezelStyle: CPButtonStateBezelStyleRegularSquare,
|
||||
CPTexturedSquareBezelStyle: CPButtonStateBezelStyleTextured,
|
||||
CPDisclosureBezelStyle: CPButtonStateBezelStyleDisclosure,
|
||||
CPRoundedDisclosureBezelStyle: CPButtonStateBezelStyleRoundedDisclosure
|
||||
};
|
||||
|
||||
/// @cond IGNORE
|
||||
@@ -108,6 +127,7 @@ CPButtonImageOffset = 3.0;
|
||||
|
||||
// NS-style Display Properties
|
||||
CPBezelStyle _bezelStyle;
|
||||
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
|
||||
@@ -154,9 +174,17 @@ CPButtonImageOffset = 3.0;
|
||||
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];
|
||||
|
||||
@@ -198,8 +220,8 @@ CPButtonImageOffset = 3.0;
|
||||
[self setButtonType:CPMomentaryPushInButton];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Control Size
|
||||
// MARK: -
|
||||
// MARK: Control Size
|
||||
|
||||
- (void)setControlSize:(CPControlSize)aControlSize
|
||||
{
|
||||
@@ -210,7 +232,7 @@ CPButtonImageOffset = 3.0;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
// MARK: -
|
||||
|
||||
// Setting the state
|
||||
/*!
|
||||
@@ -258,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]];
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -378,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];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -392,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)];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -400,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
|
||||
@@ -423,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];
|
||||
}
|
||||
@@ -444,11 +457,8 @@ CPButtonImageOffset = 3.0;
|
||||
|
||||
_highlightsBy = aMask;
|
||||
|
||||
if ([self hasThemeState:CPThemeStateHighlighted])
|
||||
{
|
||||
[self setNeedsDisplay:YES];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
[self setNeedsDisplay:YES];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (CPInteger)highlightsBy
|
||||
@@ -533,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()
|
||||
{
|
||||
@@ -555,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];
|
||||
}
|
||||
|
||||
@@ -615,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);
|
||||
}
|
||||
@@ -642,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"],
|
||||
@@ -665,10 +652,10 @@ CPButtonImageOffset = 3.0;
|
||||
*/
|
||||
- (void)sizeToFit
|
||||
{
|
||||
[self setFrameSize:[self _minimumFrameSize]];
|
||||
|
||||
[self layoutSubviews];
|
||||
|
||||
[self setFrameSize:[self _minimumFrameSize]];
|
||||
|
||||
if ([self ephemeralSubviewNamed:@"content-view"])
|
||||
[self layoutSubviews];
|
||||
}
|
||||
@@ -698,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
|
||||
@@ -807,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)
|
||||
@@ -873,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
|
||||
{
|
||||
@@ -895,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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -919,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
|
||||
@@ -942,7 +1012,8 @@ var CPButtonImageKey = @"CPButtonImageKey",
|
||||
CPButtonPeriodicDelayKey = @"CPButtonPeriodicDelayKey",
|
||||
CPButtonPeriodicIntervalKey = @"CPButtonPeriodicIntervalKey",
|
||||
CPButtonHighlightsByKey = @"CPButtonHighlightsByKey",
|
||||
CPButtonShowsStateByKey = @"CPButtonShowsStateByKey";
|
||||
CPButtonShowsStateByKey = @"CPButtonShowsStateByKey",
|
||||
CPButtonBezelStyleKey = @"CPButtonBezelStyleKey";
|
||||
|
||||
@implementation CPButton (CPCoding)
|
||||
|
||||
@@ -991,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];
|
||||
}
|
||||
@@ -1025,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
|
||||
|
||||
+79
-21
@@ -36,6 +36,7 @@
|
||||
BOOL _hasResizeControl;
|
||||
BOOL _resizeControlIsLeftAligned;
|
||||
CPArray _buttons;
|
||||
CPArray _rightButtons;
|
||||
}
|
||||
|
||||
+ (id)plusButton
|
||||
@@ -70,7 +71,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];
|
||||
|
||||
@@ -104,6 +105,7 @@
|
||||
if (self)
|
||||
{
|
||||
_buttons = [];
|
||||
_rightButtons = [];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
@@ -112,6 +114,8 @@
|
||||
|
||||
- (void)awakeFromCib
|
||||
{
|
||||
[super awakeFromCib];
|
||||
|
||||
var view = [self superview],
|
||||
subview = self;
|
||||
|
||||
@@ -155,6 +159,30 @@
|
||||
return [CPArray arrayWithArray:_buttons];
|
||||
}
|
||||
|
||||
- (void)setRightButtons:(CPArray)buttons
|
||||
{
|
||||
for (var i = [_rightButtons count] - 1; i >= 0; i--)
|
||||
{
|
||||
[_rightButtons[i] removeFromSuperview];
|
||||
[_rightButtons[i] removeObserver:self forKeyPath:@"hidden"];
|
||||
}
|
||||
|
||||
_rightButtons = [CPArray arrayWithArray:buttons];
|
||||
|
||||
for (var i = [_rightButtons count] - 1; i >= 0; i--)
|
||||
{
|
||||
[_rightButtons[i] addObserver:self forKeyPath:@"hidden" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld context:nil];
|
||||
[_rightButtons[i] setBordered:YES];
|
||||
}
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (CPArray)rightButtons
|
||||
{
|
||||
return [CPArray arrayWithArray:_rightButtons];
|
||||
}
|
||||
|
||||
- (void)setHasResizeControl:(BOOL)shouldHaveResizeControl
|
||||
{
|
||||
if (_hasResizeControl === shouldHaveResizeControl)
|
||||
@@ -241,46 +269,73 @@
|
||||
}
|
||||
}
|
||||
|
||||
var currentButtonOffset = _resizeControlIsLeftAligned ? CGRectGetMaxX([self bounds]) + 1 : -1,
|
||||
bounds = [self bounds],
|
||||
var rightButtonsNotHidden = [CPArray arrayWithArray:_rightButtons],
|
||||
rightCount = [rightButtonsNotHidden count];
|
||||
|
||||
while (rightCount--)
|
||||
{
|
||||
var button = rightButtonsNotHidden[rightCount];
|
||||
|
||||
if ([button isHidden])
|
||||
{
|
||||
[button removeFromSuperview];
|
||||
[rightButtonsNotHidden removeObject:button];
|
||||
}
|
||||
}
|
||||
|
||||
var bounds = [self bounds],
|
||||
height = CGRectGetHeight(bounds) - 1,
|
||||
frameWidth = CGRectGetWidth(bounds),
|
||||
resizeRect = _hasResizeControl ? [self rectForEphemeralSubviewNamed:"resize-control-view"] : CGRectMakeZero(),
|
||||
resizeWidth = CGRectGetWidth(resizeRect),
|
||||
availableWidth = frameWidth - resizeWidth - 1;
|
||||
|
||||
for (var i = 0, count = [buttonsNotHidden count]; i < count; i++)
|
||||
var currentLeftOffset = _resizeControlIsLeftAligned ? resizeWidth - 1 : -1,
|
||||
currentRightOffset = _resizeControlIsLeftAligned ? CGRectGetMaxX(bounds) + 1 : CGRectGetMaxX(bounds) - resizeWidth + 1;
|
||||
|
||||
var setupButton = function(button, isRightAligned)
|
||||
{
|
||||
var button = buttonsNotHidden[i],
|
||||
width = CGRectGetWidth([button frame]);
|
||||
var width = CGRectGetWidth([button frame]);
|
||||
|
||||
if (availableWidth > width)
|
||||
availableWidth -= width;
|
||||
else
|
||||
break;
|
||||
return NO;
|
||||
|
||||
if (_resizeControlIsLeftAligned)
|
||||
if (isRightAligned)
|
||||
{
|
||||
[button setFrame:CGRectMake(currentButtonOffset - width, 1, width, height)];
|
||||
currentButtonOffset -= width - 1;
|
||||
[button setFrame:CGRectMake(currentRightOffset - width, 1, width, height)];
|
||||
currentRightOffset -= width - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
[button setFrame:CGRectMake(currentButtonOffset, 1, width, height)];
|
||||
currentButtonOffset += width - 1;
|
||||
{[button setFrame:CGRectMake(currentLeftOffset, 1, width, height)];
|
||||
currentLeftOffset += 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]];
|
||||
// FIXME shouldn't need this[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];
|
||||
|
||||
return YES;
|
||||
};
|
||||
|
||||
for (var i = 0, count = [buttonsNotHidden count]; i < count; i++)
|
||||
{
|
||||
if (!setupButton(buttonsNotHidden[i], _resizeControlIsLeftAligned))
|
||||
break;
|
||||
}
|
||||
|
||||
for (var i = 0, count = [rightButtonsNotHidden count]; i < count; i++)
|
||||
{
|
||||
if (!setupButton(rightButtonsNotHidden[i], YES))
|
||||
break;
|
||||
}
|
||||
|
||||
if (_hasResizeControl)
|
||||
@@ -312,7 +367,8 @@
|
||||
|
||||
var CPButtonBarHasResizeControlKey = @"CPButtonBarHasResizeControlKey",
|
||||
CPButtonBarResizeControlIsLeftAlignedKey = @"CPButtonBarResizeControlIsLeftAlignedKey",
|
||||
CPButtonBarButtonsKey = @"CPButtonBarButtonsKey";
|
||||
CPButtonBarButtonsKey = @"CPButtonBarButtonsKey",
|
||||
CPButtonBarRightButtonsKey = @"CPButtonBarRightButtonsKey";
|
||||
|
||||
@implementation CPButtonBar (CPCoding)
|
||||
|
||||
@@ -323,6 +379,7 @@ var CPButtonBarHasResizeControlKey = @"CPButtonBarHasResizeControlKey",
|
||||
[aCoder encodeBool:_hasResizeControl forKey:CPButtonBarHasResizeControlKey];
|
||||
[aCoder encodeBool:_resizeControlIsLeftAligned forKey:CPButtonBarResizeControlIsLeftAlignedKey];
|
||||
[aCoder encodeObject:_buttons forKey:CPButtonBarButtonsKey];
|
||||
[aCoder encodeObject:_rightButtons forKey:CPButtonBarRightButtonsKey];
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
@@ -330,6 +387,7 @@ var CPButtonBarHasResizeControlKey = @"CPButtonBarHasResizeControlKey",
|
||||
if (self = [super initWithCoder:aCoder])
|
||||
{
|
||||
_buttons = [aCoder decodeObjectForKey:CPButtonBarButtonsKey] || [];
|
||||
_rightButtons = [aCoder decodeObjectForKey:CPButtonBarRightButtonsKey] || [];
|
||||
_hasResizeControl = [aCoder decodeBoolForKey:CPButtonBarHasResizeControlKey];
|
||||
_resizeControlIsLeftAligned = [aCoder decodeBoolForKey:CPButtonBarResizeControlIsLeftAlignedKey];
|
||||
}
|
||||
|
||||
+49
-19
@@ -94,26 +94,9 @@ CPCheckBoxImageOffset = 4.0;
|
||||
[self takeStateFromKeyPath:aKeyPath ofObjects:objects];
|
||||
}
|
||||
|
||||
- (CPImage)image
|
||||
{
|
||||
return [self currentValueForThemeAttribute:@"image"];
|
||||
}
|
||||
|
||||
- (CPImage)alternateImage
|
||||
{
|
||||
return [self currentValueForThemeAttribute:@"image"];
|
||||
}
|
||||
|
||||
- (BOOL)startTrackingAt:(CGPoint)aPoint
|
||||
{
|
||||
var startedTracking = [super startTrackingAt:aPoint];
|
||||
[self highlight:YES];
|
||||
return startedTracking;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Override methods from CPButton
|
||||
// MARK: -
|
||||
// MARK: Override methods from CPButton
|
||||
|
||||
- (CGSize)_minimumFrameSize
|
||||
{
|
||||
@@ -135,6 +118,36 @@ CPCheckBoxImageOffset = 4.0;
|
||||
return size;
|
||||
}
|
||||
|
||||
- (CPThemeState)_contentVisualState
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
- (CPThemeState)_imageVisualState
|
||||
{
|
||||
// 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
|
||||
|
||||
@implementation _CPCheckBoxValueBinder : CPBinder
|
||||
@@ -163,3 +176,20 @@ CPCheckBoxImageOffset = 4.0;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// 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
|
||||
|
||||
+1
-1
@@ -195,7 +195,7 @@
|
||||
|
||||
- (CGRect)documentVisibleRect
|
||||
{
|
||||
return [self convertRect:[self bounds] fromView:_documentView];
|
||||
return [_documentView visibleRect];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+59
-34
@@ -31,6 +31,7 @@
|
||||
@import "CPDragServer_Constants.j"
|
||||
@import "CPPasteboard.j"
|
||||
@import "CPView.j"
|
||||
@import "CPKeyValueBinding.j"
|
||||
|
||||
@class _CPCollectionViewDropIndicator
|
||||
|
||||
@@ -55,11 +56,13 @@ var CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_
|
||||
- (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 dragginViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)event offset:(CGPoint)dragImageOffset;
|
||||
- (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
|
||||
@class CPCollectionView
|
||||
@@ -88,9 +91,6 @@ var CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_
|
||||
@param indices the indices to obtain drag types
|
||||
@return an array of drag types (CPString)
|
||||
*/
|
||||
|
||||
var HORIZONTAL_MARGIN = 2;
|
||||
|
||||
@implementation CPCollectionView : CPView
|
||||
{
|
||||
CPArray _content;
|
||||
@@ -133,7 +133,6 @@ var HORIZONTAL_MARGIN = 2;
|
||||
CGSize _storedFrameSize;
|
||||
|
||||
BOOL _uniformSubviewsResizing @accessors(property=uniformSubviewsResizing);
|
||||
BOOL _lockResizing;
|
||||
|
||||
CPInteger _currentDropIndex;
|
||||
CPDragOperation _currentDragOperation;
|
||||
@@ -141,6 +140,14 @@ var HORIZONTAL_MARGIN = 2;
|
||||
_CPCollectionViewDropIndicator _dropView;
|
||||
}
|
||||
|
||||
+ (Class)_binderClassForBinding:(CPString)aBinding
|
||||
{
|
||||
if (aBinding == CPContentBinding)
|
||||
return [_CPCollectionViewContentBinder class];
|
||||
|
||||
return [super _binderClassForBinding:aBinding];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
self = [super initWithFrame:aFrame];
|
||||
@@ -183,7 +190,7 @@ var HORIZONTAL_MARGIN = 2;
|
||||
|
||||
_needsMinMaxItemSizeUpdate = YES;
|
||||
_uniformSubviewsResizing = NO;
|
||||
_lockResizing = NO;
|
||||
_inLiveResize = NO;
|
||||
|
||||
_currentDropIndex = -1;
|
||||
_currentDragOperation = CPDragOperationNone;
|
||||
@@ -195,8 +202,8 @@ var HORIZONTAL_MARGIN = 2;
|
||||
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegate
|
||||
// MARK: -
|
||||
// MARK: Delegate
|
||||
|
||||
/*!
|
||||
Set the delegate of the receiver
|
||||
@@ -385,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];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -446,22 +446,15 @@ 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"];
|
||||
@@ -526,14 +519,14 @@ var HORIZONTAL_MARGIN = 2;
|
||||
|
||||
- (void)resizeWithOldSuperviewSize:(CGSize)oldBoundsSize
|
||||
{
|
||||
if (_lockResizing)
|
||||
if (_inLiveResize)
|
||||
return;
|
||||
|
||||
_lockResizing = YES;
|
||||
_inLiveResize = YES;
|
||||
|
||||
[self tile];
|
||||
|
||||
_lockResizing = NO;
|
||||
_inLiveResize = NO;
|
||||
}
|
||||
|
||||
- (void)tile
|
||||
@@ -607,9 +600,12 @@ var HORIZONTAL_MARGIN = 2;
|
||||
if (_maxNumberOfRows > 0)
|
||||
numberOfRows = MIN(numberOfRows, _maxNumberOfRows);
|
||||
|
||||
height = MAX(height, numberOfRows * (_minItemSize.height + _verticalMargin));
|
||||
// calculate the required height: (sum of item heights) + (sum of margins between items).
|
||||
var requiredHeight = (numberOfRows * _minItemSize.height) + (MAX(0, numberOfRows - 1) * _verticalMargin);
|
||||
height = MAX(height, requiredHeight);
|
||||
|
||||
var itemSizeHeight = FLOOR(height / numberOfRows) - _verticalMargin;
|
||||
// calculate individual item height based on the total available height.
|
||||
var itemSizeHeight = (numberOfRows > 0) ? FLOOR((height - (MAX(0, numberOfRows - 1) * _verticalMargin)) / numberOfRows) : 0;
|
||||
|
||||
if (maxItemSizeHeight > 0)
|
||||
itemSizeHeight = MIN(itemSizeHeight, maxItemSizeHeight);
|
||||
@@ -628,7 +624,7 @@ var HORIZONTAL_MARGIN = 2;
|
||||
_horizontalMargin = _uniformSubviewsResizing ? FLOOR((aFrameSize.width - numberOfColumns * anItemSize.width) / (numberOfColumns + 1)) : HORIZONTAL_MARGIN;
|
||||
|
||||
var x = _horizontalMargin,
|
||||
y = -anItemSize.height;
|
||||
y = -anItemSize.height;
|
||||
|
||||
[displayItems enumerateObjectsUsingBlock:function(item, idx, stop)
|
||||
{
|
||||
@@ -643,7 +639,11 @@ var HORIZONTAL_MARGIN = 2;
|
||||
if (idx % numberOfColumns == 0)
|
||||
{
|
||||
x = _horizontalMargin;
|
||||
y += _verticalMargin + anItemSize.height;
|
||||
// For the first row, don't add a margin. For all subsequent rows, add the margin.
|
||||
if (idx === 0)
|
||||
y += anItemSize.height;
|
||||
else
|
||||
y += _verticalMargin + anItemSize.height;
|
||||
}
|
||||
|
||||
[view setFrameOrigin:CGPointMake(x, y)];
|
||||
@@ -746,7 +746,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))
|
||||
@@ -973,6 +973,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)
|
||||
@@ -1587,3 +1601,14 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeK
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPCollectionViewContentBinder : CPBinder
|
||||
{
|
||||
}
|
||||
|
||||
- (void)setValue:(id)aValue forBinding:(CPString)aBinding
|
||||
{
|
||||
[_source setContent:aValue];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+303
-11
@@ -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
|
||||
|
||||
// MARK: -
|
||||
// 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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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];
|
||||
|
||||
@@ -821,9 +884,221 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image
|
||||
|
||||
@end
|
||||
|
||||
// MARK: -
|
||||
// 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
|
||||
|
||||
// MARK: -
|
||||
|
||||
/// @cond IGNORE
|
||||
var CPColorComponentsKey = @"CPColorComponentsKey",
|
||||
CPColorPatternImageKey = @"CPColorPatternImageKey";
|
||||
var CPColorComponentsKey = @"CPColorComponentsKey",
|
||||
CPColorPatternImageKey = @"CPColorPatternImageKey",
|
||||
CPColorCssDictionaryKey = @"CPColorCssDictionaryKey",
|
||||
CPColorCssBeforeDictionaryKey = @"CPColorCssBeforeDictionaryKey",
|
||||
CPColorCssAfterDictionaryKey = @"CPColorCssAfterDictionaryKey";
|
||||
/// @endcond
|
||||
|
||||
@implementation CPColor (CPCoding)
|
||||
@@ -835,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;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -848,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
|
||||
@@ -1186,7 +1477,8 @@ var patternColorsFromPattern = function(pattern, attributes, imageFactory)
|
||||
bottomHeight,
|
||||
centerWidthHeight,
|
||||
centerIsNil,
|
||||
numParts;
|
||||
numParts,
|
||||
isVertical;
|
||||
|
||||
// positions are mandatory
|
||||
if (pattern.indexOf("{position}") < 0)
|
||||
|
||||
+85
-39
@@ -51,6 +51,7 @@ CPColorPickerViewWidth = 265;
|
||||
CPColorPickerViewHeight = 370;
|
||||
|
||||
CPColorPanelColorDidChangeNotification = @"CPColorPanelColorDidChangeNotification";
|
||||
CPColorDragType = CPColorPboardType;
|
||||
|
||||
var PREVIEW_HEIGHT = 20.0,
|
||||
TOOLBAR_HEIGHT = 32.0,
|
||||
@@ -71,7 +72,6 @@ var SharedColorPanel = nil,
|
||||
*/
|
||||
@implementation CPColorPanel : CPPanel
|
||||
{
|
||||
_CPColorPanelToolbar _toolbar;
|
||||
_CPColorPanelSwatches _swatchView;
|
||||
_CPColorPanelPreview _previewView;
|
||||
|
||||
@@ -130,8 +130,6 @@ var SharedColorPanel = nil,
|
||||
|
||||
if (self)
|
||||
{
|
||||
//[[self contentView] setBackgroundColor:[CPColor colorWithWhite:0.95 alpha:1.0]];
|
||||
|
||||
[self setTitle:@"Color Panel"];
|
||||
[self setLevel:CPFloatingWindowLevel];
|
||||
|
||||
@@ -150,20 +148,37 @@ var SharedColorPanel = nil,
|
||||
*/
|
||||
- (void)setColor:(CPColor)aColor
|
||||
{
|
||||
if ([_color isEqual:aColor])
|
||||
return;
|
||||
|
||||
_color = aColor;
|
||||
[_previewView setBackgroundColor:_color];
|
||||
|
||||
[CPApp sendAction:@selector(changeColor:) to:nil from:self];
|
||||
// Check if the color change originated from user interaction inside the panel itself.
|
||||
// We only broadcast `changeColor:` if the user picked a color via the panel's UI.
|
||||
// If an external CPColorWell called `setColor:` programmatically, broadcasting it
|
||||
// back down the responder chain would incorrectly change the previous First Responder.
|
||||
var currentEvent = [CPApp currentEvent],
|
||||
isFromPanel = currentEvent && ([currentEvent window] === self);
|
||||
|
||||
if (_target && _action)
|
||||
[CPApp sendAction:_action to:_target from:self];
|
||||
if (isFromPanel)
|
||||
{
|
||||
// Push color via Responder Chain (targets First Responder, i.e., the active CPColorWell)
|
||||
[CPApp sendAction:@selector(changeColor:) to:nil from:self];
|
||||
|
||||
if (_target && _action)
|
||||
[CPApp sendAction:_action to:_target from:self];
|
||||
}
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPColorPanelColorDidChangeNotification
|
||||
object:self];
|
||||
|
||||
[_activePicker setColor:_color];
|
||||
[_opacitySlider setFloatValue:[_color alphaComponent]];
|
||||
if (_activePicker)
|
||||
[_activePicker setColor:_color];
|
||||
|
||||
if (_opacitySlider)
|
||||
[_opacitySlider setFloatValue:[_color alphaComponent]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -175,7 +190,7 @@ var SharedColorPanel = nil,
|
||||
{
|
||||
[self setColor:aColor];
|
||||
|
||||
if (bool)
|
||||
if (bool && _activePicker)
|
||||
[_activePicker setColor:_color];
|
||||
}
|
||||
|
||||
@@ -333,7 +348,7 @@ var SharedColorPanel = nil,
|
||||
buttonForLater = button;
|
||||
}
|
||||
|
||||
// FIXME: http://280north.lighthouseapp.com/projects/13294-cappuccino/tickets/25-implement-cpbox
|
||||
// Preview
|
||||
var previewBox = [[CPView alloc] initWithFrame:CGRectMake(76, TOOLBAR_HEIGHT + 10, CGRectGetWidth(bounds) - 86, PREVIEW_HEIGHT)];
|
||||
|
||||
_previewView = [[_CPColorPanelPreview alloc] initWithFrame:CGRectInset([previewBox bounds], 2.0, 2.0)];
|
||||
@@ -351,7 +366,7 @@ var SharedColorPanel = nil,
|
||||
[_previewLabel setTextColor:[CPColor blackColor]];
|
||||
[_previewLabel setAlignment:CPRightTextAlignment];
|
||||
|
||||
// FIXME: http://280north.lighthouseapp.com/projects/13294-cappuccino/tickets/25-implement-cpbox
|
||||
// Swatches
|
||||
var swatchBox = [[CPView alloc] initWithFrame:CGRectMake(76, TOOLBAR_HEIGHT + 10 + PREVIEW_HEIGHT + 5, CGRectGetWidth(bounds) - 86, SWATCH_HEIGHT + 2.0)];
|
||||
|
||||
[swatchBox setBackgroundColor:[CPColor colorWithWhite:0.8 alpha:1.0]];
|
||||
@@ -392,8 +407,6 @@ var SharedColorPanel = nil,
|
||||
[contentView addSubview:opacityLabel];
|
||||
[contentView addSubview:_opacitySlider];
|
||||
|
||||
_target = nil;
|
||||
_action = nil;
|
||||
_activePicker = nil;
|
||||
|
||||
[_previewView setBackgroundColor:_color];
|
||||
@@ -413,8 +426,6 @@ var SharedColorPanel = nil,
|
||||
@end
|
||||
|
||||
|
||||
CPColorDragType = "CPColorDragType";
|
||||
|
||||
var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
|
||||
/* @ignore */
|
||||
@@ -424,12 +435,14 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
CPColor _dragColor;
|
||||
CPColorPanel _colorPanel;
|
||||
CPCookie _swatchCookie;
|
||||
CGPoint _mouseDownPoint;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
self = [super initWithFrame:aFrame];
|
||||
|
||||
_mouseDownPoint = CGPointMake(0, 0);
|
||||
[self setBackgroundColor:[CPColor grayColor]];
|
||||
|
||||
[self registerForDraggedTypes:[CPArray arrayWithObjects:CPColorDragType]];
|
||||
@@ -443,7 +456,6 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
|
||||
for (var i = 0; i < 50; i++)
|
||||
{
|
||||
// FIXME: http://280north.lighthouseapp.com/projects/13294-cappuccino/tickets/25-implement-cpbox
|
||||
var view = [[CPView alloc] initWithFrame:CGRectMake(13 * i + 1, 1, 12, 12)],
|
||||
fillView = [[CPView alloc] initWithFrame:CGRectInset([view bounds], 1.0, 1.0)];
|
||||
|
||||
@@ -484,19 +496,17 @@ 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
|
||||
{
|
||||
var result = [];
|
||||
// FIXME: http://280north.lighthouseapp.com/projects/13294-cappuccino/tickets/25-implement-cpbox
|
||||
for (var i = 0; i < _swatches.length; i++)
|
||||
result.push([[[_swatches[i] subviews][0] backgroundColor] hexString]);
|
||||
|
||||
@@ -523,39 +533,44 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
|
||||
- (void)setColor:(CPColor)aColor atIndex:(int)index
|
||||
{
|
||||
// FIXME: http://280north.lighthouseapp.com/projects/13294-cappuccino/tickets/25-implement-cpbox
|
||||
[[_swatches[index] subviews][0] setBackgroundColor:aColor];
|
||||
[self saveColorList];
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
_mouseDownPoint = [anEvent locationInWindow];
|
||||
}
|
||||
|
||||
- (void)mouseUp:(CPEvent)anEvent
|
||||
{
|
||||
var point = [self convertPoint:[anEvent locationInWindow] fromView:nil],
|
||||
bounds = [self bounds];
|
||||
|
||||
if (!CGRectContainsPoint(bounds, point) || point.x > [self bounds].size.width - 1 || point.x < 1)
|
||||
return NO;
|
||||
return;
|
||||
|
||||
[_colorPanel setColor:[self colorAtIndex:FLOOR(point.x / 13)] updatePicker:YES];
|
||||
}
|
||||
|
||||
- (void)mouseDragged:(CPEvent)anEvent
|
||||
{
|
||||
var point = [self convertPoint:[anEvent locationInWindow] fromView:nil];
|
||||
var windowPoint = [anEvent locationInWindow];
|
||||
|
||||
// Prevent accidental drags from rapid clicking causing small micro-movements
|
||||
if (ABS(windowPoint.x - _mouseDownPoint.x) < 3 && ABS(windowPoint.y - _mouseDownPoint.y) < 3)
|
||||
return;
|
||||
|
||||
var point = [self convertPoint:windowPoint fromView:nil];
|
||||
|
||||
if (point.x > [self bounds].size.width - 1 || point.x < 1)
|
||||
return NO;
|
||||
|
||||
[[CPPasteboard pasteboardWithName:CPDragPboard] declareTypes:[CPArray arrayWithObject:CPColorDragType] owner:self];
|
||||
return;
|
||||
|
||||
var swatch = _swatches[FLOOR(point.x / 13)];
|
||||
|
||||
// FIXME: http://280north.lighthouseapp.com/projects/13294-cappuccino/tickets/25-implement-cpbox
|
||||
_dragColor = [[swatch subviews][0] backgroundColor];
|
||||
|
||||
var bounds = CGRectMakeCopy([swatch bounds]);
|
||||
|
||||
// FIXME: http://280north.lighthouseapp.com/projects/13294-cappuccino/tickets/25-implement-cpbox
|
||||
var dragView = [[CPView alloc] initWithFrame:bounds],
|
||||
dragFillView = [[CPView alloc] initWithFrame:CGRectInset(bounds, 1.0, 1.0)];
|
||||
|
||||
@@ -564,11 +579,15 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
|
||||
[dragView addSubview:dragFillView];
|
||||
|
||||
var pasteboard = [CPPasteboard pasteboardWithName:CPDragPboard];
|
||||
[pasteboard declareTypes:[CPArray arrayWithObject:CPColorDragType] owner:self];
|
||||
[pasteboard setData:[CPKeyedArchiver archivedDataWithRootObject:_dragColor] forType:CPColorDragType];
|
||||
|
||||
[self dragView:dragView
|
||||
at:CGPointMake(point.x - bounds.size.width / 2.0, point.y - bounds.size.height / 2.0)
|
||||
offset:CGPointMake(0.0, 0.0)
|
||||
event:anEvent
|
||||
pasteboard:nil
|
||||
pasteboard:pasteboard
|
||||
source:self
|
||||
slideBack:YES];
|
||||
}
|
||||
@@ -579,7 +598,7 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
[aPasteboard setData:[CPKeyedArchiver archivedDataWithRootObject:_dragColor] forType:aType];
|
||||
}
|
||||
|
||||
- (void)performDragOperation:(id /*<CPDraggingInfo>*/)aSender
|
||||
- (BOOL)performDragOperation:(id /*<CPDraggingInfo>*/)aSender
|
||||
{
|
||||
var location = [self convertPoint:[aSender draggingLocation] fromView:nil],
|
||||
pasteboard = [aSender draggingPasteboard],
|
||||
@@ -589,6 +608,13 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
return NO;
|
||||
|
||||
[self setColor:[CPKeyedUnarchiver unarchiveObjectWithData:[pasteboard dataForType:CPColorDragType]] atIndex:FLOOR(location.x / 13)];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (unsigned)draggingSourceOperationMaskForLocal:(BOOL)isLocal
|
||||
{
|
||||
return CPDragOperationCopy;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -597,11 +623,13 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
@implementation _CPColorPanelPreview : CPView
|
||||
{
|
||||
CPColorPanel _colorPanel;
|
||||
CGPoint _mouseDownPoint;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
self = [super initWithFrame:aFrame];
|
||||
_mouseDownPoint = CGPointMake(0, 0);
|
||||
|
||||
[self registerForDraggedTypes:[CPArray arrayWithObjects:CPColorDragType]];
|
||||
|
||||
@@ -618,7 +646,7 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
return _colorPanel;
|
||||
}
|
||||
|
||||
- (void)performDragOperation:(id /*<CPDraggingInfo>*/)aSender
|
||||
- (BOOL)performDragOperation:(id /*<CPDraggingInfo>*/)aSender
|
||||
{
|
||||
var pasteboard = [aSender draggingPasteboard];
|
||||
|
||||
@@ -627,6 +655,8 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
|
||||
var color = [CPKeyedUnarchiver unarchiveObjectWithData:[pasteboard dataForType:CPColorDragType]];
|
||||
[_colorPanel setColor:color updatePicker:YES];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isOpaque
|
||||
@@ -634,15 +664,22 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
_mouseDownPoint = [anEvent locationInWindow];
|
||||
}
|
||||
|
||||
- (void)mouseDragged:(CPEvent)anEvent
|
||||
{
|
||||
var point = [self convertPoint:[anEvent locationInWindow] fromView:nil];
|
||||
var windowPoint = [anEvent locationInWindow];
|
||||
|
||||
if (ABS(windowPoint.x - _mouseDownPoint.x) < 3 && ABS(windowPoint.y - _mouseDownPoint.y) < 3)
|
||||
return;
|
||||
|
||||
[[CPPasteboard pasteboardWithName:CPDragPboard] declareTypes:[CPColorDragType] owner:self];
|
||||
var point = [self convertPoint:windowPoint fromView:nil];
|
||||
|
||||
var bounds = CGRectMake(0, 0, 15, 15);
|
||||
|
||||
// FIXME: http://280north.lighthouseapp.com/projects/13294-cappuccino/tickets/25-implement-cpbox
|
||||
var dragView = [[CPView alloc] initWithFrame:bounds],
|
||||
dragFillView = [[CPView alloc] initWithFrame:CGRectInset(bounds, 1.0, 1.0)];
|
||||
|
||||
@@ -651,11 +688,15 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
|
||||
[dragView addSubview:dragFillView];
|
||||
|
||||
var pasteboard = [CPPasteboard pasteboardWithName:CPDragPboard];
|
||||
[pasteboard declareTypes:[CPArray arrayWithObject:CPColorDragType] owner:self];
|
||||
[pasteboard setData:[CPKeyedArchiver archivedDataWithRootObject:[self backgroundColor]] forType:CPColorDragType];
|
||||
|
||||
[self dragView:dragView
|
||||
at:CGPointMake(point.x - bounds.size.width / 2.0, point.y - bounds.size.height / 2.0)
|
||||
offset:CGPointMake(0.0, 0.0)
|
||||
event:anEvent
|
||||
pasteboard:nil
|
||||
pasteboard:pasteboard
|
||||
source:self
|
||||
slideBack:YES];
|
||||
}
|
||||
@@ -666,6 +707,11 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
[aPasteboard setData:[CPKeyedArchiver archivedDataWithRootObject:[self backgroundColor]] forType:aType];
|
||||
}
|
||||
|
||||
- (unsigned)draggingSourceOperationMaskForLocal:(BOOL)isLocal
|
||||
{
|
||||
return CPDragOperationCopy;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@import "CPColorPicker.j"
|
||||
|
||||
@@ -125,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];
|
||||
@@ -246,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);
|
||||
|
||||
+200
-134
@@ -25,7 +25,7 @@
|
||||
@import "CPView.j"
|
||||
@import "CPColor.j"
|
||||
@import "CPColorPanel.j"
|
||||
|
||||
@import "CPPasteboard.j"
|
||||
|
||||
var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiveNotification";
|
||||
|
||||
@@ -39,10 +39,10 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
|
||||
*/
|
||||
@implementation CPColorWell : CPControl
|
||||
{
|
||||
BOOL _active;
|
||||
BOOL _bordered;
|
||||
|
||||
CPColor _color;
|
||||
BOOL _isChangingColorFromPanel; // Guard flag to prevent recursion
|
||||
CGPoint _mouseDownPoint;
|
||||
}
|
||||
|
||||
+ (Class)_binderClassForBinding:(CPString)aBinding
|
||||
@@ -77,52 +77,54 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
|
||||
[theBinding reverseSetValueFor:@"color"];
|
||||
}
|
||||
|
||||
- (BOOL)isFirstResponder
|
||||
{
|
||||
return [[self window] firstResponder] === self;
|
||||
}
|
||||
|
||||
- (BOOL)acceptsFirstResponder
|
||||
{
|
||||
return [self isEnabled];
|
||||
}
|
||||
|
||||
- (void)activate:(BOOL)shouldBeExclusive
|
||||
{
|
||||
[[self window] makeFirstResponder:self];
|
||||
[[CPColorPanel sharedColorPanel] orderFront:self];
|
||||
}
|
||||
|
||||
- (BOOL)isActive
|
||||
{
|
||||
return [self isFirstResponder] && [self isEnabled];
|
||||
}
|
||||
|
||||
/*!
|
||||
Deactivates the color well.
|
||||
*/
|
||||
- (void)deactivate
|
||||
{
|
||||
if ([self isFirstResponder])
|
||||
[[self window] makeFirstResponder:nil];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
self = [super initWithFrame:aFrame];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_active = NO;
|
||||
_color = [CPColor whiteColor];
|
||||
_mouseDownPoint = CGPointMakeZero();
|
||||
[self setBordered:YES];
|
||||
|
||||
[self registerForDraggedTypes:[CPArray arrayWithObject:CPColorPboardType]];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_registerNotifications
|
||||
{
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
[defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(colorWellDidBecomeExclusive:)
|
||||
name:_CPColorWellDidBecomeExclusiveNotification
|
||||
object:nil];
|
||||
|
||||
[defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(colorPanelWillClose:)
|
||||
name:CPWindowWillCloseNotification
|
||||
object:[CPColorPanel sharedColorPanel]];
|
||||
}
|
||||
|
||||
- (void)_removeNotifications
|
||||
{
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
[defaultCenter
|
||||
removeObserver:self
|
||||
name:_CPColorWellDidBecomeExclusiveNotification
|
||||
object:nil];
|
||||
|
||||
[defaultCenter
|
||||
removeObserver:self
|
||||
name:CPWindowWillCloseNotification
|
||||
object:[CPColorPanel sharedColorPanel]];
|
||||
|
||||
}
|
||||
// MARK: -
|
||||
// MARK: Draw
|
||||
|
||||
/*!
|
||||
Sets whether the color well is bordered.
|
||||
@@ -143,7 +145,8 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
|
||||
return [self hasThemeState:CPThemeStateBordered];
|
||||
}
|
||||
|
||||
// Managing Color From Color Wells
|
||||
// MARK: -
|
||||
// MARK: Managing Color
|
||||
|
||||
/*!
|
||||
Returns the color well's current color.
|
||||
@@ -158,12 +161,17 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
|
||||
*/
|
||||
- (void)setColor:(CPColor)aColor
|
||||
{
|
||||
if (_color == aColor)
|
||||
if ([_color isEqual:aColor])
|
||||
return;
|
||||
|
||||
_color = aColor;
|
||||
|
||||
[self setNeedsLayout];
|
||||
|
||||
// Only push back to the panel if we initiated the change (not if the panel pushed it to us)
|
||||
// AND if we are the current focus.
|
||||
if (!_isChangingColorFromPanel && [self isFirstResponder])
|
||||
[[CPColorPanel sharedColorPanel] setColor:_color];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -175,94 +183,175 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
|
||||
[self setColor:[aSender color]];
|
||||
}
|
||||
|
||||
// Activating and Deactivating Color Wells
|
||||
/*!
|
||||
Standard action method sent by CPColorPanel via the Responder Chain.
|
||||
*/
|
||||
- (void)changeColor:(id)aSender
|
||||
{
|
||||
if ([aSender isKindOfClass:[CPColorPanel class]])
|
||||
{
|
||||
_isChangingColorFromPanel = YES;
|
||||
[self setColor:[aSender color]];
|
||||
_isChangingColorFromPanel = NO;
|
||||
|
||||
// Forward the action to our target (e.g. controller)
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// MARK: Activating and Deactivating
|
||||
|
||||
/*!
|
||||
Activates the color well, displays the color panel, and makes the panel's current color the same as its own.
|
||||
If exclusive is \c YES, deactivates any other CPColorWells. \c NO, keeps them active.
|
||||
@param shouldBeExclusive whether other color wells should be deactivated.
|
||||
*/
|
||||
- (void)activate:(BOOL)shouldBeExclusive
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
if (shouldBeExclusive)
|
||||
// FIXME: make this queue!
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:_CPColorWellDidBecomeExclusiveNotification
|
||||
object:self];
|
||||
[self setThemeState:CPThemeStateFirstResponder];
|
||||
|
||||
var panel = [CPColorPanel sharedColorPanel];
|
||||
|
||||
// EXPLICITLY set ourselves as the target.
|
||||
// This ensures that when the user clicks the panel (making Panel key),
|
||||
// the panel still knows to send messages back to us.
|
||||
[panel setTarget:self];
|
||||
[panel setAction:@selector(changeColor:)];
|
||||
|
||||
// Sync panel to our current color
|
||||
[panel setColor:_color];
|
||||
|
||||
|
||||
if ([self isActive])
|
||||
return;
|
||||
|
||||
_active = YES;
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(colorPanelDidChangeColor:)
|
||||
name:CPColorPanelColorDidChangeNotification
|
||||
object:[CPColorPanel sharedColorPanel]];
|
||||
}
|
||||
|
||||
/*!
|
||||
Deactivates the color well.
|
||||
*/
|
||||
- (void)deactivate
|
||||
{
|
||||
if (![self isActive])
|
||||
return;
|
||||
|
||||
_active = NO;
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
removeObserver:self
|
||||
name:CPColorPanelColorDidChangeNotification
|
||||
object:[CPColorPanel sharedColorPanel]];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c YES if the color well is active.
|
||||
*/
|
||||
- (BOOL)isActive
|
||||
{
|
||||
return _active;
|
||||
}
|
||||
|
||||
- (void)colorPanelDidChangeColor:(CPNotification)aNotification
|
||||
{
|
||||
[self takeColorFrom:[aNotification object]];
|
||||
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
}
|
||||
|
||||
- (void)colorWellDidBecomeExclusive:(CPNotification)aNotification
|
||||
{
|
||||
if (self != [aNotification object])
|
||||
[self deactivate];
|
||||
}
|
||||
|
||||
- (void)colorPanelWillClose:(CPNotification)aNotification
|
||||
{
|
||||
[self deactivate];
|
||||
}
|
||||
|
||||
- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
|
||||
{
|
||||
[self highlight:NO];
|
||||
|
||||
if (!mouseIsUp || !CGRectContainsPoint([self bounds], aPoint) || ![self isEnabled])
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:_CPColorWellDidBecomeExclusiveNotification object:self];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)resignFirstResponder
|
||||
{
|
||||
[self unsetThemeState:CPThemeStateFirstResponder];
|
||||
|
||||
var panel = [CPColorPanel sharedColorPanel];
|
||||
|
||||
// Clean up if we were the target
|
||||
if ([panel target] == self)
|
||||
[panel setTarget:nil];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// MARK: Event Handling
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
if (![self isEnabled])
|
||||
return;
|
||||
|
||||
_mouseDownPoint = [anEvent locationInWindow];
|
||||
[self activate:YES];
|
||||
|
||||
var colorPanel = [CPColorPanel sharedColorPanel];
|
||||
|
||||
[colorPanel setColor:_color];
|
||||
[colorPanel orderFront:self];
|
||||
}
|
||||
|
||||
- (void)mouseDragged:(CPEvent)anEvent
|
||||
{
|
||||
if (![self isEnabled])
|
||||
return;
|
||||
|
||||
var windowPoint = [anEvent locationInWindow];
|
||||
|
||||
// Prevent accidental drags from rapid clicking causing small micro-movements
|
||||
if (ABS(windowPoint.x - _mouseDownPoint.x) < 3 && ABS(windowPoint.y - _mouseDownPoint.y) < 3)
|
||||
return;
|
||||
|
||||
var bounds = CGRectMake(0, 0, 15, 15);
|
||||
var dragView = [[CPView alloc] initWithFrame:bounds],
|
||||
dragFillView = [[CPView alloc] initWithFrame:CGRectInset(bounds, 1.0, 1.0)];
|
||||
|
||||
[dragView setBackgroundColor:[CPColor blackColor]];
|
||||
[dragFillView setBackgroundColor:_color];
|
||||
|
||||
[dragView addSubview:dragFillView];
|
||||
|
||||
var pasteboard = [CPPasteboard pasteboardWithName:CPDragPboard];
|
||||
[pasteboard declareTypes:[CPArray arrayWithObject:CPColorPboardType] owner:self];
|
||||
[pasteboard setData:[CPKeyedArchiver archivedDataWithRootObject:_color] forType:CPColorPboardType];
|
||||
|
||||
var point = [self convertPoint:windowPoint fromView:nil];
|
||||
|
||||
[self dragView:dragView
|
||||
at:CGPointMake(point.x - bounds.size.width / 2.0, point.y - bounds.size.height / 2.0)
|
||||
offset:CGPointMake(0.0, 0.0)
|
||||
event:anEvent
|
||||
pasteboard:pasteboard
|
||||
source:self
|
||||
slideBack:YES];
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// MARK: Drag and Drop
|
||||
|
||||
- (void)draggingEntered:(id)sender
|
||||
{
|
||||
var pasteboard = [sender draggingPasteboard];
|
||||
|
||||
if ([[pasteboard types] containsObject:CPColorPboardType])
|
||||
{
|
||||
[self setThemeState:CPThemeStateHighlighted];
|
||||
return CPDragOperationCopy;
|
||||
}
|
||||
|
||||
return CPDragOperationNone;
|
||||
}
|
||||
|
||||
- (void)draggingExited:(id)sender
|
||||
{
|
||||
[self unsetThemeState:CPThemeStateHighlighted];
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id)sender
|
||||
{
|
||||
var pasteboard = [sender draggingPasteboard];
|
||||
|
||||
if ([[pasteboard types] containsObject:CPColorPboardType])
|
||||
{
|
||||
var data = [pasteboard dataForType:CPColorPboardType],
|
||||
newColor = [CPKeyedUnarchiver unarchiveObjectWithData:data];
|
||||
|
||||
if (newColor && [newColor isKindOfClass:[CPColor class]])
|
||||
{
|
||||
[self setColor:newColor];
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
|
||||
// Activate nicely after drop
|
||||
[self activate:YES];
|
||||
[self unsetThemeState:CPThemeStateHighlighted];
|
||||
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)pasteboard:(CPPasteboard)aPasteboard provideDataForType:(CPString)aType
|
||||
{
|
||||
if (aType == CPColorPboardType)
|
||||
[aPasteboard setData:[CPKeyedArchiver archivedDataWithRootObject:_color] forType:aType];
|
||||
}
|
||||
|
||||
- (unsigned)draggingSourceOperationMaskForLocal:(BOOL)isLocal
|
||||
{
|
||||
return CPDragOperationCopy;
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// MARK: Layout
|
||||
|
||||
- (CGRect)contentRectForBounds:(CGRect)bounds
|
||||
{
|
||||
var contentInset = [self currentValueForThemeAttribute:@"content-inset"];
|
||||
|
||||
return CGRectInsetByInset(bounds, contentInset);
|
||||
}
|
||||
|
||||
@@ -316,7 +405,6 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
|
||||
positioned:CPWindowAbove
|
||||
relativeToEphemeralSubviewNamed:@"bezel-view"];
|
||||
|
||||
|
||||
[contentView setBackgroundColor:_color];
|
||||
|
||||
var contentBorderView = [self layoutEphemeralSubviewNamed:@"content-border-view"
|
||||
@@ -326,28 +414,6 @@ 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
|
||||
@@ -396,9 +462,9 @@ var CPColorWellColorKey = "CPColorWellColorKey",
|
||||
|
||||
if (self)
|
||||
{
|
||||
_active = NO;
|
||||
_color = [aCoder decodeObjectForKey:CPColorWellColorKey];
|
||||
[self setBordered:[aCoder decodeBoolForKey:CPColorWellBorderedKey]];
|
||||
[self registerForDraggedTypes:[CPArray arrayWithObject:CPColorPboardType]];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
+27
-19
@@ -74,7 +74,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
BOOL _usesDataSource;
|
||||
CGSize _intercellSpacing;
|
||||
CPArray _items;
|
||||
id<CPComboBoxDataSource> _dataSource;
|
||||
id <CPComboBoxDataSource> _dataSource;
|
||||
CPInteger _implementedDelegateComboBoxMethods;
|
||||
CPString _selectedStringValue;
|
||||
float _itemHeight;
|
||||
@@ -133,7 +133,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
[self setThemeState:CPComboBoxStateButtonBordered];
|
||||
}
|
||||
|
||||
#pragma mark Setting Display Attributes
|
||||
// MARK: Setting Display Attributes
|
||||
|
||||
- (BOOL)hasVerticalScroller
|
||||
{
|
||||
@@ -214,7 +214,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
_numberOfVisibleItems = MAX(visibleItems, 1);
|
||||
}
|
||||
|
||||
#pragma mark Setting a Delegate
|
||||
// MARK: Setting a Delegate
|
||||
|
||||
- (id <CPComboBoxDelegate>)delegate
|
||||
{
|
||||
@@ -254,7 +254,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
[super setDelegate:aDelegate];
|
||||
}
|
||||
|
||||
#pragma mark Setting a Data Source
|
||||
// MARK: Setting a Data Source
|
||||
|
||||
- (id <CPComboBoxDataSource>)dataSource
|
||||
{
|
||||
@@ -305,7 +305,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
[self reloadData];
|
||||
}
|
||||
|
||||
#pragma mark Working with an Internal List
|
||||
// MARK: Working with an Internal List
|
||||
|
||||
- (void)addItemsWithObjectValues:(CPArray)objects
|
||||
{
|
||||
@@ -378,7 +378,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
return _items.length;
|
||||
}
|
||||
|
||||
#pragma mark Manipulating the Displayed List
|
||||
// MARK: Manipulating the Displayed List
|
||||
|
||||
/*!
|
||||
Returns the delegate to be used when creating the pop up list.
|
||||
@@ -564,7 +564,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
|
||||
var selectedStringValue = [_listDelegate selectedStringValue];
|
||||
|
||||
if (selectedStringValue === nil)
|
||||
if (selectedStringValue == nil)
|
||||
return NO;
|
||||
else
|
||||
_selectedStringValue = selectedStringValue;
|
||||
@@ -594,7 +594,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
}
|
||||
|
||||
#pragma mark Manipulating the Selection
|
||||
// MARK: Manipulating the Selection
|
||||
|
||||
- (void)deselectItemAtIndex:(int)index
|
||||
{
|
||||
@@ -646,7 +646,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
[self selectItemAtIndex:index];
|
||||
}
|
||||
|
||||
#pragma mark Completing the Text Field
|
||||
// MARK: Completing the Text Field
|
||||
|
||||
- (BOOL)completes
|
||||
{
|
||||
@@ -693,7 +693,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
_forceSelection = !!flag;
|
||||
}
|
||||
|
||||
#pragma mark CPTextField Delegate Methods and Overrides
|
||||
// MARK: CPTextField Delegate Methods and Overrides
|
||||
|
||||
/*! @ignore */
|
||||
- (BOOL)sendAction:(SEL)anAction to:(id)anObject
|
||||
@@ -843,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;
|
||||
@@ -883,7 +893,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
[_listDelegate setAlignment:alignment];
|
||||
}
|
||||
|
||||
#pragma mark Pop Up Button Layout
|
||||
// MARK: Pop Up Button Layout
|
||||
|
||||
- (CGRect)popupButtonRectForBounds:(CGRect)bounds
|
||||
{
|
||||
@@ -928,7 +938,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
relativeToEphemeralSubviewNamed:@"content-view"];
|
||||
}
|
||||
|
||||
#pragma mark Internal Helpers
|
||||
// MARK: Internal Helpers
|
||||
|
||||
/*! @ignore */
|
||||
- (void)_dataSourceWarningForMethod:(SEL)cmd condition:(CPString)flag
|
||||
@@ -1006,8 +1016,8 @@ var CPComboBoxTextSubview = @"text",
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Observers method
|
||||
// MARK: -
|
||||
// MARK: Observers method
|
||||
|
||||
- (void)_addObservers
|
||||
{
|
||||
@@ -1132,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];
|
||||
|
||||
+86
-16
@@ -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;
|
||||
@@ -80,18 +82,28 @@ 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;
|
||||
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,
|
||||
@@ -110,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;
|
||||
@@ -136,10 +148,32 @@ else if (typeof window !== "undefined" && window.attachEvent) // Must follow Ope
|
||||
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;
|
||||
@@ -179,7 +213,10 @@ else if (USER_AGENT.indexOf("AppleWebKit/") != -1)
|
||||
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)
|
||||
@@ -189,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));
|
||||
@@ -208,6 +246,9 @@ 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;
|
||||
|
||||
@@ -286,7 +327,7 @@ function CPPlatformHasBug(aBug)
|
||||
|
||||
function CPBrowserIsEngine(anEngine)
|
||||
{
|
||||
return PLATFORM_ENGINE === anEngine;
|
||||
return PLATFORM_ENGINE & anEngine;
|
||||
}
|
||||
|
||||
function CPBrowserIsOperatingSystem(anOperatingSystem)
|
||||
@@ -322,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
|
||||
@@ -369,6 +418,18 @@ function CPBrowserStyleProperty(aProperty)
|
||||
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(' '),
|
||||
@@ -438,3 +499,12 @@ function CPBrowserCSSProperty(aProperty)
|
||||
|
||||
return browserProperty.toLowerCase();
|
||||
}
|
||||
|
||||
function CPBrowserBackingStorePixelRatio(context)
|
||||
{
|
||||
return context.webkitBackingStorePixelRatio ||
|
||||
context.mozBackingStorePixelRatio ||
|
||||
context.msBackingStorePixelRatio ||
|
||||
context.oBackingStorePixelRatio ||
|
||||
context.backingStorePixelRatio || 1;
|
||||
}
|
||||
|
||||
+105
-29
@@ -23,10 +23,12 @@
|
||||
@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
|
||||
|
||||
@@ -42,18 +44,14 @@
|
||||
|
||||
@end
|
||||
|
||||
@typedef CPTextAlignment
|
||||
CPLeftTextAlignment = 0;
|
||||
CPRightTextAlignment = 1;
|
||||
CPCenterTextAlignment = 2;
|
||||
CPJustifiedTextAlignment = 3;
|
||||
CPNaturalTextAlignment = 4;
|
||||
|
||||
@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;
|
||||
@@ -126,6 +124,8 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
CGPoint _previousTrackingLocation;
|
||||
|
||||
CPControlSize _controlSize;
|
||||
|
||||
CPWritingDirection _baseWritingDirection @accessors(property=baseWritingDirection);
|
||||
}
|
||||
|
||||
+ (CPDictionary)themeAttributes
|
||||
@@ -135,14 +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),
|
||||
@"nib2cib-adjustment-frame": CGRectMakeZero()
|
||||
@"max-size": CGSizeMake(-1.0, -1.0)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -173,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
|
||||
{
|
||||
@@ -200,14 +199,16 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
{
|
||||
_sendActionOn = CPLeftMouseUpMask;
|
||||
_trackingMouseDownFlags = 0;
|
||||
|
||||
[self setControlSize:CPThemeStateControlSizeRegular];
|
||||
[self updateTrackingAreas];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Control Size
|
||||
// MARK: -
|
||||
// MARK: Control Size
|
||||
|
||||
/*!
|
||||
Returns the control's control size
|
||||
@@ -240,7 +241,7 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
*/
|
||||
- (ThemeState)_controlSizeThemeState
|
||||
{
|
||||
switch(_controlSize)
|
||||
switch (_controlSize)
|
||||
{
|
||||
case CPSmallControlSize:
|
||||
return CPThemeStateControlSizeSmall;
|
||||
@@ -285,7 +286,7 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
// MARK: -
|
||||
|
||||
/*!
|
||||
Sets the receiver's target action.
|
||||
@@ -625,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);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -642,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;
|
||||
@@ -808,7 +809,7 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
CPBottomVerticalTextAlignment
|
||||
</pre>
|
||||
*/
|
||||
- (void)setVerticalAlignment:(CPTextVerticalAlignment)alignment
|
||||
- (void)setVerticalAlignment:(CPVerticalTextAlignment)alignment
|
||||
{
|
||||
[self setValue:alignment forThemeAttribute:@"vertical-alignment"];
|
||||
}
|
||||
@@ -853,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];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -911,7 +917,7 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
*/
|
||||
- (CPFont)font
|
||||
{
|
||||
return [self valueForThemeAttribute:@"font"];
|
||||
return [self currentValueForThemeAttribute:@"font"] || [CPFont systemFontForControlSize:_controlSize];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1016,6 +1022,69 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
return [self hasThemeState:CPThemeStateHighlighted];
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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
|
||||
|
||||
@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",
|
||||
@@ -1027,6 +1096,7 @@ var CPControlActionKey = @"CPControlActionKey",
|
||||
CPControlSendsActionOnEndEditingKey = @"CPControlSendsActionOnEndEditingKey",
|
||||
CPControlTargetKey = @"CPControlTargetKey",
|
||||
CPControlValueKey = @"CPControlValueKey",
|
||||
CPControlBaseWrittingDirectionKey = @"CPControlBaseWrittingDirectionKey";
|
||||
|
||||
__Deprecated__CPImageViewImageKey = @"CPImageViewImageKey";
|
||||
|
||||
@@ -1055,6 +1125,9 @@ var CPControlActionKey = @"CPControlActionKey",
|
||||
[self setFormatter:[aCoder decodeObjectForKey:CPControlFormatterKey]];
|
||||
|
||||
[self setControlSize:[aCoder decodeIntForKey:CPControlControlSizeKey]];
|
||||
|
||||
[self setBaseWritingDirection:[aCoder decodeIntForKey:CPControlBaseWrittingDirectionKey]];
|
||||
[self updateTrackingAreas];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -1074,21 +1147,24 @@ var CPControlActionKey = @"CPControlActionKey",
|
||||
|
||||
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
|
||||
|
||||
@@ -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
+115
-44
@@ -23,6 +23,7 @@ Cursor support by browser:
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
@import "CPImage.j"
|
||||
@import "CPCompatibility.j"
|
||||
|
||||
@global CPApp
|
||||
|
||||
@@ -31,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);
|
||||
@@ -123,6 +130,9 @@ var currentCursor = nil,
|
||||
|
||||
- (void)set
|
||||
{
|
||||
if (currentCursor === self)
|
||||
return;
|
||||
|
||||
currentCursor = self;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
@@ -154,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];
|
||||
|
||||
@@ -162,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
|
||||
|
||||
+215
-116
@@ -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
|
||||
@@ -59,31 +59,31 @@ 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);
|
||||
CPInteger _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);
|
||||
|
||||
BOOL _invokedByUserEvent;
|
||||
_CPDatePickerTextField _datePickerTextfield;
|
||||
_CPDatePickerCalendar _datePickerCalendar;
|
||||
unsigned _implementedCDatePickerDelegateMethods;
|
||||
BOOL _isTextual;
|
||||
id _datePickerComponent;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Theme methods
|
||||
// MARK: -
|
||||
// MARK: Theme methods
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
@@ -144,12 +144,38 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
@"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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Binding methods
|
||||
// MARK: -
|
||||
// MARK: Binding methods
|
||||
|
||||
+ (Class)_binderClassForBinding:(CPString)theBinding
|
||||
{
|
||||
@@ -174,8 +200,8 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Init methods
|
||||
// MARK: -
|
||||
// MARK: Init methods
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
@@ -206,34 +232,61 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
if (!_locale)
|
||||
_locale = [CPLocale currentLocale];
|
||||
|
||||
_datePickerTextfield = [[_CPDatePickerTextField alloc] initWithFrame:[self bounds] withDatePicker:self];
|
||||
[_datePickerTextfield setDateValue:_dateValue];
|
||||
_datePickerComponent = nil;
|
||||
|
||||
_datePickerCalendar = [[_CPDatePickerCalendar alloc] initWithFrame:[self bounds] withDatePicker:self];
|
||||
[_datePickerCalendar setDateValue:_dateValue];
|
||||
|
||||
// We might have been unarchived in a disabled state.
|
||||
[_datePickerTextfield setEnabled:[self isEnabled]];
|
||||
[self _createComponents];
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)_createComponents
|
||||
{
|
||||
_isTextual = (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle) || (_datePickerStyle == CPTextFieldDatePickerStyle);
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Control Size
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// MARK: Control Size
|
||||
|
||||
- (void)setControlSize:(CPControlSize)aControlSize
|
||||
{
|
||||
[super setControlSize:aControlSize];
|
||||
|
||||
if ([self datePickerStyle] == CPTextFieldAndStepperDatePickerStyle || [self datePickerStyle] == CPTextFieldDatePickerStyle)
|
||||
[_datePickerComponent setControlSize:aControlSize];
|
||||
|
||||
if (_isTextual)
|
||||
[self _sizeToControlSize];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegate methods
|
||||
// MARK: -
|
||||
// MARK: Delegate methods
|
||||
|
||||
/*! Set the delegate of the datePicker
|
||||
@param aDelegate delegate of the datePicker
|
||||
@@ -249,42 +302,19 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Layout method
|
||||
// MARK: -
|
||||
// MARK: Layout method
|
||||
|
||||
/*! Layout the subviews
|
||||
*/
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
{
|
||||
if (![_datePickerTextfield superview])
|
||||
[self addSubview:_datePickerTextfield];
|
||||
|
||||
if ([_datePickerCalendar superview])
|
||||
[_datePickerCalendar removeFromSuperview];
|
||||
|
||||
[_datePickerTextfield setControlSize:[self controlSize]];
|
||||
[_datePickerTextfield setNeedsLayout];
|
||||
[_datePickerTextfield setNeedsDisplay:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (![_datePickerCalendar superview])
|
||||
[self addSubview:_datePickerCalendar];
|
||||
|
||||
if ([_datePickerTextfield superview])
|
||||
[_datePickerTextfield removeFromSuperview];
|
||||
|
||||
[_datePickerCalendar setNeedsLayout];
|
||||
[_datePickerCalendar setNeedsDisplay:YES];
|
||||
}
|
||||
[_datePickerComponent setNeedsLayout];
|
||||
[_datePickerComponent setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Setter
|
||||
// MARK: -
|
||||
// MARK: Setter
|
||||
|
||||
/*! Return the objectValue of the datePicker. The objectValue should take the timeZoneEffect
|
||||
*/
|
||||
@@ -323,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));
|
||||
|
||||
@@ -333,10 +371,7 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
|
||||
if ([aDateValue isEqualToDate:_dateValue] && aTimeInterval == _timeInterval)
|
||||
{
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
[_datePickerTextfield setDateValue:_dateValue];
|
||||
else
|
||||
[_datePickerCalendar setDateValue:_dateValue];
|
||||
[_datePickerComponent setDateValue:_dateValue];
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -344,8 +379,8 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
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];
|
||||
}
|
||||
@@ -364,10 +399,7 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
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
|
||||
@@ -375,6 +407,9 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
*/
|
||||
- (void)setMinDate:(CPDate)aMinDate
|
||||
{
|
||||
if (_minDate === aMinDate)
|
||||
return;
|
||||
|
||||
[self willChangeValueForKey:@"minDate"];
|
||||
_minDate = aMinDate;
|
||||
[self didChangeValueForKey:@"minDate"];
|
||||
@@ -387,6 +422,9 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
*/
|
||||
- (void)setMaxDate:(CPDate)aMaxDate
|
||||
{
|
||||
if (_maxDate === aMaxDate)
|
||||
return;
|
||||
|
||||
[self willChangeValueForKey:@"maxDate"];
|
||||
_maxDate = aMaxDate;
|
||||
[self didChangeValueForKey:@"maxDate"];
|
||||
@@ -399,10 +437,32 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
*/
|
||||
- (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];
|
||||
}
|
||||
@@ -412,8 +472,14 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
*/
|
||||
- (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];
|
||||
}
|
||||
@@ -423,6 +489,9 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
*/
|
||||
- (void)setDatePickerMode:(CPInteger)aDatePickerMode
|
||||
{
|
||||
if (_datePickerMode === aDatePickerMode)
|
||||
return;
|
||||
|
||||
_datePickerMode = aDatePickerMode;
|
||||
|
||||
if (_datePickerMode == CPSingleDateMode)
|
||||
@@ -448,6 +517,9 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
*/
|
||||
- (void)setLocale:(CPLocale)aLocale
|
||||
{
|
||||
if (_locale === aLocale)
|
||||
return;
|
||||
|
||||
_locale = aLocale;
|
||||
|
||||
if (_formatter)
|
||||
@@ -458,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];
|
||||
}
|
||||
@@ -469,6 +543,9 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
*/
|
||||
- (void)setBezeled:(BOOL)shouldBeBezeled
|
||||
{
|
||||
if (_isBezeled === shouldBeBezeled)
|
||||
return;
|
||||
|
||||
_isBezeled = shouldBeBezeled;
|
||||
|
||||
if (shouldBeBezeled)
|
||||
@@ -483,6 +560,9 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
*/
|
||||
- (void)setBordered:(BOOL)shouldBeBordered
|
||||
{
|
||||
if (_isBordered === shouldBeBordered)
|
||||
return;
|
||||
|
||||
_isBordered = shouldBeBordered;
|
||||
|
||||
if (shouldBeBordered)
|
||||
@@ -498,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.
|
||||
@@ -507,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
|
||||
@@ -525,6 +623,9 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
*/
|
||||
- (void)setDrawsBackground:(BOOL)aBoolean
|
||||
{
|
||||
if (_drawsBackground === aBoolean)
|
||||
return;
|
||||
|
||||
[self willChangeValueForKey:@"drawsBackground"];
|
||||
_drawsBackground = aBoolean;
|
||||
[self didChangeValueForKey:@"drawsBackground"];
|
||||
@@ -537,32 +638,32 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
*/
|
||||
- (void)setTimeZone:(CPTimeZone)aTimeZone
|
||||
{
|
||||
if (_timeZone === aTimeZone)
|
||||
return;
|
||||
|
||||
[self willChangeValueForKey:@"timeZone"];
|
||||
_timeZone = aTimeZone;
|
||||
[self didChangeValueForKey:@"timeZone"];
|
||||
|
||||
[self setNeedsLayout];
|
||||
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
[_datePickerTextfield setDateValue:_dateValue];
|
||||
else
|
||||
[_datePickerCalendar setDateValue:_dateValue];
|
||||
[_datePickerComponent setDateValue:_dateValue];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark First responder methods
|
||||
// MARK: -
|
||||
// MARK: First responder methods
|
||||
|
||||
/*! Return YES if style is set to CPTextFieldAndStepperDatePickerStyle or CPTextFieldDatePickerStyle
|
||||
*/
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
if (_isTextual)
|
||||
{
|
||||
if (![super becomeFirstResponder])
|
||||
return NO;
|
||||
|
||||
[_datePickerTextfield _selectTextFieldWithFlags:[[CPApp currentEvent] modifierFlags]];
|
||||
[_datePickerComponent _selectTextFieldWithFlags:[[CPApp currentEvent] modifierFlags]];
|
||||
|
||||
return YES;
|
||||
}
|
||||
@@ -581,15 +682,15 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
*/
|
||||
- (BOOL)resignFirstResponder
|
||||
{
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
[_datePickerTextfield resignFirstResponder];
|
||||
if (_isTextual)
|
||||
[_datePickerComponent resignFirstResponder];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark getter
|
||||
// MARK: -
|
||||
// MARK: getter
|
||||
|
||||
/*!
|
||||
Returns \c YES if the textfield is bezeled.
|
||||
@@ -622,24 +723,16 @@ 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
|
||||
// MARK: -
|
||||
// MARK: Key event
|
||||
|
||||
/*! Key down event
|
||||
@param anEvent
|
||||
*/
|
||||
- (void)keyDown:(CPEvent)anEvent
|
||||
{
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
[_datePickerTextfield keyDown:anEvent];
|
||||
if (_isTextual)
|
||||
[_datePickerComponent keyDown:anEvent];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -665,20 +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];
|
||||
[self setDatePickerStyle:[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
|
||||
@@ -686,7 +781,10 @@ var CPDatePickerModeKey = @"CPDatePickerModeKey",
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
// FIXME Do we need to encode _datePickerTextfield and _datePickerCalendar? As subviews they'll be encoded, but when we decode we recreate them anyhow.
|
||||
// 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];
|
||||
@@ -694,8 +792,8 @@ var CPDatePickerModeKey = @"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];
|
||||
@@ -706,6 +804,7 @@ var CPDatePickerModeKey = @"CPDatePickerModeKey",
|
||||
|
||||
@end
|
||||
|
||||
// FIXME: add support for CPEditorRegistrationProtocol as implemented for CPTextField
|
||||
@implementation _CPDatePickerValueBinder : CPBinder
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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
@@ -20,13 +20,18 @@
|
||||
* 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
|
||||
@@ -34,28 +39,48 @@
|
||||
|
||||
var RADIANS = Math.PI / 180;
|
||||
|
||||
@typedef _CPDatePickerClockHand
|
||||
_CPDatePickerClockHours = 1;
|
||||
_CPDatePickerClockMinutes = 2;
|
||||
_CPDatePickerClockSeconds = 3;
|
||||
|
||||
@implementation _CPDatePickerClock : CPView
|
||||
@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
|
||||
// MARK: -
|
||||
// MARK: Init methods
|
||||
|
||||
- (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()];
|
||||
|
||||
@@ -73,7 +98,7 @@ var RADIANS = Math.PI / 180;
|
||||
|
||||
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
|
||||
@@ -97,106 +122,132 @@ var RADIANS = Math.PI / 180;
|
||||
[_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
|
||||
|
||||
- (void)layoutSubviews
|
||||
- (void)_initHands
|
||||
{
|
||||
if ([_datePicker datePickerStyle] == CPTextFieldAndStepperDatePickerStyle || [_datePicker datePickerStyle] == CPTextFieldDatePickerStyle)
|
||||
return;
|
||||
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"];
|
||||
|
||||
[super layoutSubviews];
|
||||
// If hand images are true CPImage, we have to duplicate them to avoid
|
||||
// the multiple delegates bug when multiple clocks are displayed
|
||||
|
||||
var bounds = [self bounds],
|
||||
dateValue = [[_datePicker dateValue] copy];
|
||||
if ([middleHandImage isKindOfClass:[CPImage class]])
|
||||
middleHandImage = [middleHandImage duplicate];
|
||||
|
||||
[dateValue _dateWithTimeZone:[_datePicker timeZone]];
|
||||
if ([hourHandImage isKindOfClass:[CPImage class]])
|
||||
hourHandImage = [hourHandImage duplicate];
|
||||
|
||||
[self setBackgroundColor:[_datePicker currentValueForThemeAttribute:@"bezel-color-clock"]];
|
||||
[_middleHandLayer setImage:[_datePicker currentValueForThemeAttribute:@"middle-hand-image"]];
|
||||
[_hourHandLayer setImage:[_datePicker currentValueForThemeAttribute:@"hour-hand-image"]];
|
||||
[_minuteHandLayer setImage:[_datePicker currentValueForThemeAttribute:@"minute-hand-image"]];
|
||||
[_secondHandLayer setImage:[_datePicker currentValueForThemeAttribute:@"second-hand-image"]];
|
||||
if ([minuteHandImage isKindOfClass:[CPImage class]])
|
||||
minuteHandImage = [minuteHandImage duplicate];
|
||||
|
||||
if ([_datePicker _isEnglishFormat])
|
||||
{
|
||||
if (dateValue.getHours() > 11)
|
||||
[_PMAMTextField setStringValue:@"PM"]
|
||||
else
|
||||
[_PMAMTextField setStringValue:@"AM"];
|
||||
if ([secondHandImage isKindOfClass:[CPImage class]])
|
||||
secondHandImage = [secondHandImage 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];
|
||||
}
|
||||
[_middleHandLayer setImage:middleHandImage];
|
||||
[_hourHandLayer setImage:hourHandImage];
|
||||
[_minuteHandLayer setImage:minuteHandImage];
|
||||
[_secondHandLayer setImage:secondHandImage];
|
||||
|
||||
[_hourHandLayer setRotationRadians:[self _hourPositionRadianForDate:dateValue]];
|
||||
[_minuteHandLayer setRotationRadians:[self _minutePositionRadianForDate:dateValue]];
|
||||
[_secondHandLayer setRotationRadians:[self _secondPositionRadianForDate:dateValue]];
|
||||
[_hourHandLayer setNeedsDisplay];
|
||||
[_middleHandLayer setNeedsDisplay];
|
||||
[_secondHandLayer setNeedsDisplay];
|
||||
[_minuteHandLayer setNeedsDisplay];
|
||||
|
||||
[_PMAMTextField setEnabled:_isEnabled];
|
||||
[_hourHandLayer setEnabled:_isEnabled];
|
||||
[_middleHandLayer setEnabled:_isEnabled];
|
||||
[_secondHandLayer setEnabled:_isEnabled];
|
||||
[_minuteHandLayer setEnabled:_isEnabled];
|
||||
|
||||
// Check if we have to display the hand second
|
||||
if (([_datePicker datePickerElements] & CPHourMinuteSecondDatePickerElementFlag) == CPHourMinuteSecondDatePickerElementFlag)
|
||||
[_secondHandLayer setHidden:NO];
|
||||
else
|
||||
[_secondHandLayer setHidden:YES];
|
||||
[_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 Accessors
|
||||
|
||||
- (float)_hourPositionRadianForDate:(CPDate)aDate
|
||||
- (void)setDatePickerElements:(CPInteger)aDatePickerElements
|
||||
{
|
||||
var hours = aDate.getHours() + aDate.getMinutes() / 60;
|
||||
_datePickerElements = aDatePickerElements;
|
||||
|
||||
return (360 * hours / 12) * RADIANS;
|
||||
// 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
|
||||
}
|
||||
|
||||
- (float)_secondPositionRadianForDate:(CPDate)aDate
|
||||
// MARK: Layout methods
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
return (360 * aDate.getSeconds() / 60) * RADIANS;
|
||||
// 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];
|
||||
}
|
||||
|
||||
- (float)_minutePositionRadianForDate:(CPDate)aDate
|
||||
- (void)_updateHands
|
||||
{
|
||||
var minutes = aDate.getMinutes() + aDate.getSeconds() / 60;
|
||||
var bounds = [self bounds];
|
||||
|
||||
return (360 * minutes / 60) * RADIANS;
|
||||
[_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];
|
||||
}
|
||||
|
||||
// MARK: Accessors
|
||||
|
||||
- (void)setEnabled:(BOOL)shouldEnable
|
||||
{
|
||||
shouldEnable = !!shouldEnable;
|
||||
@@ -205,36 +256,191 @@ var RADIANS = Math.PI / 180;
|
||||
return;
|
||||
|
||||
_isEnabled = shouldEnable;
|
||||
[self setNeedsLayout];
|
||||
|
||||
// FIXME: This is a workaround for an apparent bug in CALayer.
|
||||
// Without pumping the event loop, the sublayers of _rootLayer
|
||||
// (the hands) are not redrawn until an event occurs.
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
[self _initHands];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation HandLayer : CALayer
|
||||
{
|
||||
BOOL _isEnabled @accessors(setter=setEnabled:, getter=isEnabled);
|
||||
|
||||
CPImage _image;
|
||||
CALayer _imageLayer;
|
||||
float _rotationRadians;
|
||||
CPImage _image;
|
||||
HandImageLayer _imageLayer;
|
||||
float _rotationRadians;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Init methods
|
||||
// MARK: Init methods
|
||||
|
||||
- (id)initWithSize:(CGSize)aSize
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_isEnabled = YES;
|
||||
_imageLayer = [CALayer layer];
|
||||
_imageLayer = [HandImageLayer layer];
|
||||
_rotationRadians = 0;
|
||||
|
||||
[_imageLayer setDelegate:self];
|
||||
@@ -247,8 +453,7 @@ var RADIANS = Math.PI / 180;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Setter Getter methods
|
||||
// MARK: Setter Getter methods
|
||||
|
||||
/*!
|
||||
Set the bounds of the layer. The imageLayer will be at the center of this bounds.
|
||||
@@ -285,18 +490,6 @@ var RADIANS = Math.PI / 180;
|
||||
1.0, 1.0)];
|
||||
}
|
||||
|
||||
- (void)setEnabled:(BOOL)shouldEnable
|
||||
{
|
||||
shouldEnable = !!shouldEnable;
|
||||
|
||||
if (_isEnabled === shouldEnable)
|
||||
return;
|
||||
|
||||
_isEnabled = shouldEnable;
|
||||
[self setNeedsDisplay];
|
||||
[_imageLayer setNeedsDisplay];
|
||||
}
|
||||
|
||||
- (void)imageDidLoad:(CPImage)anImage
|
||||
{
|
||||
[_imageLayer setNeedsDisplay];
|
||||
@@ -310,4 +503,109 @@ var RADIANS = Math.PI / 180;
|
||||
CGContextDrawImage(aContext, [aLayer bounds], _image);
|
||||
}
|
||||
|
||||
- (BOOL)handIsHitAtPoint:(CGPoint)aPoint
|
||||
{
|
||||
return (!_isHidden && [_imageLayer hitTest:aPoint] === _imageLayer);
|
||||
}
|
||||
|
||||
- (void)setNeedsDisplay
|
||||
{
|
||||
[super setNeedsDisplay];
|
||||
[_imageLayer setNeedsDisplay];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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];
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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];
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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,604 @@
|
||||
/* _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";
|
||||
|
||||
// Removed hardcoded KeyCodes (CPZeroKeyCode, etc) as they are unreliable across browsers/layouts.
|
||||
|
||||
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],
|
||||
characters = [anEvent characters];
|
||||
|
||||
// Check if the event is a deletion
|
||||
var isDelete = (keyCode === CPDeleteKeyCode || keyCode === CPDeleteForwardKeyCode);
|
||||
|
||||
// Check if the event is a numeric input.
|
||||
// By testing the character string against a regex, we support num-pads and
|
||||
// international keyboards correctly, rather than relying on keyCode ranges.
|
||||
var isNumeric = (characters && [characters length] > 0 && /^[0-9]$/.test(characters));
|
||||
|
||||
// If it is neither a delete command nor a digit, we ignore it.
|
||||
if (!isDelete && !isNumeric)
|
||||
return;
|
||||
|
||||
var newValue = [self stringValue].replace(/\s/g, ''),
|
||||
length = [newValue length];
|
||||
|
||||
if (isDelete)
|
||||
{
|
||||
[_timerEdition invalidate];
|
||||
_timerEdition = nil;
|
||||
|
||||
// Ensure we don't substring if length is 0
|
||||
if (length > 0)
|
||||
newValue = [newValue substringToIndex:(length - 1)];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Since isNumeric is true, characters is a valid digit string
|
||||
var eventKeyValue = characters;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// Safety check for NaN before comparison
|
||||
var numericValue = parseInt(newValue);
|
||||
if (isNaN(numericValue))
|
||||
numericValue = 0;
|
||||
|
||||
if (numericValue > [self _maxNumberWithMaxDate] || ([_datePicker _isAmericanFormat] && _dateType == CPHourDateType && numericValue > 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;
|
||||
}
|
||||
|
||||
// if we enter a day that is too high for the current month
|
||||
// we need to increase the month by one
|
||||
// if we do not do this, the user input would be silently reset
|
||||
// very poor user experience
|
||||
|
||||
if (parseInt(anObjectValue, 10) > [dateValue _daysInMonth])
|
||||
{
|
||||
[_datePickerElementView._textFieldMonth setIntValue:(dateValue.getMonth() + 2)];
|
||||
[super setObjectValue:objectValue];
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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"]];
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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];
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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];
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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;
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// 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]];
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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
@@ -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]];
|
||||
|
||||
|
||||
+26
-14
@@ -515,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
|
||||
{
|
||||
@@ -540,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];
|
||||
}
|
||||
}
|
||||
@@ -553,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
|
||||
{
|
||||
@@ -569,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];
|
||||
}
|
||||
}
|
||||
@@ -580,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
|
||||
{
|
||||
@@ -597,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];
|
||||
}
|
||||
}
|
||||
@@ -858,21 +864,27 @@ 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
|
||||
{
|
||||
if (aDocument === self && shouldClose)
|
||||
var theDelegate = context.delegate;
|
||||
|
||||
// Only close the document explicitly if there is NO delegate to handle the action.
|
||||
// If a delegate exists (e.g., the CPWindow), it is responsible for performing the close
|
||||
// upon receiving the callback below. Calling [self close] here would cause a double-close.
|
||||
if (aDocument === self && shouldClose && theDelegate == nil)
|
||||
[self close];
|
||||
|
||||
objj_msgSend(context.delegate, context.selector, aDocument, shouldClose, context.context);
|
||||
if (theDelegate)
|
||||
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];
|
||||
|
||||
@@ -901,8 +913,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;
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -297,7 +297,7 @@ var CPSharedDocumentController = nil;
|
||||
var iter = [_documents objectEnumerator],
|
||||
obj;
|
||||
|
||||
while ((obj = [iter nextObject]) !== nil)
|
||||
while ((obj = [iter nextObject]) != nil)
|
||||
{
|
||||
if ([obj isDocumentEdited])
|
||||
return YES;
|
||||
@@ -402,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
|
||||
|
||||
+56
-2
@@ -26,6 +26,7 @@
|
||||
@import "CPPasteboard.j"
|
||||
@import "CPView.j"
|
||||
@import "CPWindow_Constants.j"
|
||||
@import "CPViewAnimation.j"
|
||||
|
||||
@class CPWindow // This file is imported by CPWindow.j
|
||||
@class _CPDOMDataTransferPasteboard
|
||||
@@ -132,6 +133,10 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
||||
unsigned _dragOperation;
|
||||
|
||||
CPTimer _draggingUpdateTimer;
|
||||
|
||||
// Animation State
|
||||
CGPoint _pendingEndLocation;
|
||||
CPDragOperation _pendingEndOperation;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -261,10 +266,19 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
||||
{
|
||||
var contentView = [scrollView contentView],
|
||||
bounds = [contentView bounds],
|
||||
insetBounds = CGRectInset(bounds, 30, 30),
|
||||
eventLocation = [contentView convertPoint:_draggingLocation fromView:nil],
|
||||
deltaX = 0,
|
||||
deltaY = 0;
|
||||
deltaY = 0,
|
||||
insetSize = 30;
|
||||
|
||||
if ([contentView respondsToSelector:@selector(documentView)] &&
|
||||
[[contentView documentView] respondsToSelector:@selector(rowHeight)])
|
||||
{
|
||||
// Adjust inset bounds based on CPTableView row height
|
||||
insetSize = MAX(insetSize, [[contentView documentView] rowHeight]);
|
||||
}
|
||||
|
||||
var insetBounds = CGRectInset(bounds, insetSize, insetSize);
|
||||
|
||||
if (!CGRectContainsPoint(insetBounds, eventLocation))
|
||||
{
|
||||
@@ -316,6 +330,46 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
||||
[_draggingUpdateTimer invalidate];
|
||||
_draggingUpdateTimer = nil;
|
||||
|
||||
// Check if we should slide back (drag failed + slideBack requested)
|
||||
if (![CPPlatform supportsDragAndDrop] && _shouldSlideBack && anOperation === CPDragOperationNone)
|
||||
{
|
||||
// Store state to finalize drag after animation completes
|
||||
_pendingEndLocation = aLocation;
|
||||
_pendingEndOperation = anOperation;
|
||||
|
||||
var currentFrame = [_draggedWindow frame],
|
||||
targetFrame = CGRectMake(_startDragLocation.x, _startDragLocation.y, currentFrame.size.width, currentFrame.size.height);
|
||||
|
||||
// We use CPViewAnimation. Even though _draggedWindow is a CPWindow,
|
||||
// CPViewAnimation supports targets that respond to setFrame: (like NSViewAnimation does for NSWindow).
|
||||
var animation = [[CPViewAnimation alloc] initWithViewAnimations:[
|
||||
[CPDictionary dictionaryWithObjects:[_draggedWindow, currentFrame, targetFrame]
|
||||
forKeys:[CPViewAnimationTargetKey, CPViewAnimationStartFrameKey, CPViewAnimationEndFrameKey]]
|
||||
]];
|
||||
|
||||
[animation setAnimationCurve:CPAnimationEaseOut];
|
||||
[animation setDuration:0.25];
|
||||
[animation setDelegate:self];
|
||||
[animation startAnimation];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
[self _performFinalCleanupWithLocation:aLocation operation:anOperation];
|
||||
}
|
||||
|
||||
- (void)animationDidEnd:(CPAnimation)anAnimation
|
||||
{
|
||||
[self _performFinalCleanupWithLocation:_pendingEndLocation operation:_pendingEndOperation];
|
||||
}
|
||||
|
||||
- (void)animationDidStop:(CPAnimation)anAnimation
|
||||
{
|
||||
[self _performFinalCleanupWithLocation:_pendingEndLocation operation:_pendingEndOperation];
|
||||
}
|
||||
|
||||
- (void)_performFinalCleanupWithLocation:(CGPoint)aLocation operation:(CPDragOperation)anOperation
|
||||
{
|
||||
[_draggedView removeFromSuperview];
|
||||
|
||||
if (![CPPlatform supportsDragAndDrop])
|
||||
|
||||
+99
-6
@@ -28,13 +28,16 @@
|
||||
|
||||
@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
|
||||
@@ -63,10 +66,11 @@ var _CPEventPeriodicEventPeriod = 0,
|
||||
CPWindow _window;
|
||||
Number _windowNumber;
|
||||
CPString _characters;
|
||||
CPString _charactersIgnoringModifiers
|
||||
CPString _charactersIgnoringModifiers;
|
||||
BOOL _isARepeat;
|
||||
unsigned _keyCode;
|
||||
DOMEvent _DOMEvent;
|
||||
BOOL _isActionKey;
|
||||
int _data1;
|
||||
int _data2;
|
||||
short _subtype;
|
||||
@@ -82,6 +86,8 @@ var _CPEventPeriodicEventPeriod = 0,
|
||||
BOOL _suppressCappuccinoCut;
|
||||
BOOL _suppressCappuccinoPaste;
|
||||
#endif
|
||||
|
||||
CPTrackingArea _trackingArea;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -105,17 +111,28 @@ var _CPEventPeriodicEventPeriod = 0,
|
||||
@param unmodCharacters the string of keys pressed without the presence of any modifiers other than Shift
|
||||
@param repeatKey \c YES if this is caused by the system repeat as opposed to the user pressing the key again
|
||||
@param code a number associated with the keyboard key of this event
|
||||
@param isAnActionKey a BOOL indicating whether this key is an action key (e.g. a function key)
|
||||
@throws CPInternalInconsistencyException if \c anEventType is not a CPKeyDown,
|
||||
CPKeyUp or CPFlagsChanged
|
||||
@return the keyboard event
|
||||
*/
|
||||
+ (CPEvent)keyEventWithType:(CPEventType)anEventType location:(CGPoint)aPoint modifierFlags:(unsigned int)modifierFlags
|
||||
timestamp:(CPTimeInterval)aTimestamp windowNumber:(int)aWindowNumber context:(CPGraphicsContext)aGraphicsContext
|
||||
characters:(CPString)characters charactersIgnoringModifiers:(CPString)unmodCharacters isARepeat:(BOOL)repeatKey keyCode:(unsigned short)code
|
||||
characters:(CPString)characters charactersIgnoringModifiers:(CPString)unmodCharacters isARepeat:(BOOL)repeatKey keyCode:(unsigned short)code isActionKey:(BOOL)isAnActionKey
|
||||
{
|
||||
return [[self alloc] _initKeyEventWithType:anEventType location:aPoint modifierFlags:modifierFlags
|
||||
timestamp:aTimestamp windowNumber:aWindowNumber context:aGraphicsContext
|
||||
characters:characters charactersIgnoringModifiers:unmodCharacters isARepeat:repeatKey keyCode:code];
|
||||
characters:characters charactersIgnoringModifiers:unmodCharacters isARepeat:repeatKey keyCode:code isActionKey:isAnActionKey];
|
||||
}
|
||||
|
||||
// for backwards compatibility only
|
||||
+ (CPEvent)keyEventWithType:(CPEventType)anEventType location:(CGPoint)aPoint modifierFlags:(unsigned int)modifierFlags
|
||||
timestamp:(CPTimeInterval)aTimestamp windowNumber:(int)aWindowNumber context:(CPGraphicsContext)aGraphicsContext
|
||||
characters:(CPString)characters charactersIgnoringModifiers:(CPString)unmodCharacters isARepeat:(BOOL)repeatKey keyCode:(unsigned short)code
|
||||
{
|
||||
return [[self alloc] _initKeyEventWithType:anEventType location:aPoint modifierFlags:modifierFlags
|
||||
timestamp:aTimestamp windowNumber:aWindowNumber context:aGraphicsContext
|
||||
characters:characters charactersIgnoringModifiers:unmodCharacters isARepeat:repeatKey keyCode:code isActionKey:NO];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -141,6 +158,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.
|
||||
|
||||
@@ -201,10 +239,32 @@ 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
|
||||
characters:(CPString)characters charactersIgnoringModifiers:(CPString)unmodCharacters isARepeat:(BOOL)isARepeat keyCode:(unsigned short)code
|
||||
characters:(CPString)characters charactersIgnoringModifiers:(CPString)unmodCharacters isARepeat:(BOOL)isARepeat keyCode:(unsigned short)code isActionKey:(BOOL)isAnActionKey
|
||||
{
|
||||
if (self = [self _initWithType:anEventType])
|
||||
{
|
||||
@@ -216,6 +276,7 @@ var _CPEventPeriodicEventPeriod = 0,
|
||||
_charactersIgnoringModifiers = unmodCharacters;
|
||||
_isARepeat = isARepeat;
|
||||
_keyCode = code;
|
||||
_isActionKey = isAnActionKey;
|
||||
_windowNumber = aWindowNumber;
|
||||
}
|
||||
|
||||
@@ -236,6 +297,7 @@ var _CPEventPeriodicEventPeriod = 0,
|
||||
_subtype = aSubtype;
|
||||
_data1 = aData1;
|
||||
_data2 = aData2;
|
||||
_windowNumber = aWindowNumber;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -289,6 +351,14 @@ var _CPEventPeriodicEventPeriod = 0,
|
||||
return _type;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the subtype of the event.
|
||||
*/
|
||||
- (CPEventType)subtype
|
||||
{
|
||||
return _subtype;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the event's associated window.
|
||||
*/
|
||||
@@ -514,6 +584,21 @@ var _CPEventPeriodicEventPeriod = 0,
|
||||
return !firstResponderIsText;
|
||||
}
|
||||
|
||||
- (BOOL)_isActionOrCommandEvent
|
||||
{
|
||||
// This method is now platform-agnostic. It checks for abstract properties
|
||||
// of the event, including the _isActionKey flag that was set at creation time.
|
||||
return (
|
||||
// Is it a command shortcut?
|
||||
(_modifierFlags & (CPCommandKeyMask | CPControlKeyMask)) ||
|
||||
|
||||
// Is it a key that doesn't produce a character?
|
||||
([_characters length] === 0) ||
|
||||
|
||||
// Was it identified as an action key by the platform-specific layer?
|
||||
_isActionKey
|
||||
);
|
||||
}
|
||||
/*!
|
||||
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
|
||||
@@ -551,7 +636,7 @@ var _CPEventPeriodicEventPeriod = 0,
|
||||
*/
|
||||
+ (void)stopPeriodicEvents
|
||||
{
|
||||
if (_CPEventPeriodicEventTimer === nil)
|
||||
if (_CPEventPeriodicEventTimer == nil)
|
||||
return;
|
||||
|
||||
window.clearTimeout(_CPEventPeriodicEventTimer);
|
||||
@@ -582,6 +667,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()
|
||||
|
||||
@@ -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
|
||||
@@ -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:(CPEvent)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
|
||||
+170
-12
@@ -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;
|
||||
}
|
||||
|
||||
@@ -176,14 +256,13 @@ following:
|
||||
|
||||
+ (CPFont)systemFontForControlSize:(CPControlSize)aSize
|
||||
{
|
||||
// TODO These sizes should be themable or made less arbitrary in some other way.
|
||||
switch (aSize)
|
||||
{
|
||||
case CPSmallControlSize:
|
||||
return [self systemFontOfSize:_CPFontSystemFontSize - 1];
|
||||
return [self systemFontOfSize:_CPFontSystemFontSizeSmall];
|
||||
|
||||
case CPMiniControlSize:
|
||||
return [self systemFontOfSize:_CPFontSystemFontSize - 2];
|
||||
return [self systemFontOfSize:_CPFontSystemFontSizeMini];
|
||||
|
||||
case CPRegularControlSize:
|
||||
default:
|
||||
@@ -314,6 +393,10 @@ following:
|
||||
_isItalic = isItalic;
|
||||
_isSystem = isSystem;
|
||||
|
||||
_theme = [CPTheme defaultTheme];
|
||||
_themeState = CPThemeStateNormal;
|
||||
[self _loadThemeAttributes];
|
||||
|
||||
if (isSystem)
|
||||
{
|
||||
_name = aName;
|
||||
@@ -381,6 +464,22 @@ following:
|
||||
return _CPRealFontSize(_size);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the font size. Cocoa/AppKit compatibility alias for -size.
|
||||
*/
|
||||
- (float)pointSize
|
||||
{
|
||||
return [self size];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the font name. Cocoa/AppKit compatibility alias for -familyName.
|
||||
*/
|
||||
- (CPString)fontName
|
||||
{
|
||||
return [self familyName];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the font as a CSS string
|
||||
*/
|
||||
@@ -431,8 +530,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 +606,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 +624,8 @@ var CPFontNameKey = @"CPFontNameKey",
|
||||
[aCoder encodeBool:_isBold forKey:CPFontIsBoldKey];
|
||||
[aCoder encodeBool:_isItalic forKey:CPFontIsItalicKey];
|
||||
[aCoder encodeBool:_isSystem forKey:CPFontIsSystemKey];
|
||||
|
||||
[self _encodeThemeObjectsWithCoder:aCoder];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+218
-32
@@ -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)
|
||||
@@ -208,8 +208,13 @@ var CPSharedFontManager = nil,
|
||||
|
||||
- (@action)addFontTrait:(id)sender
|
||||
{
|
||||
var tag = [sender tag];
|
||||
_activeChange = tag === nil ? @{} : @{ @"addTraits": tag };
|
||||
var tag = sender;
|
||||
|
||||
if ([sender respondsToSelector:@selector(tag)])
|
||||
tag = [sender tag];
|
||||
|
||||
_activeChange = tag == nil ? @{} : @{ @"addTraits": tag };
|
||||
_fontAction = CPAddTraitFontAction;
|
||||
|
||||
[self sendAction];
|
||||
}
|
||||
@@ -219,6 +224,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
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
|
||||
+460
-7
@@ -26,10 +26,15 @@
|
||||
@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"
|
||||
@import "CPGraphicsContext.j"
|
||||
|
||||
@class CPColor
|
||||
@global document
|
||||
|
||||
@protocol CPImageDelegate <CPObject>
|
||||
|
||||
@@ -85,9 +90,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")
|
||||
@@ -161,7 +164,7 @@ function CPAppKitImage(aFilename, aSize)
|
||||
- (id)initByReferencingFile:(CPString)aFilename size:(CGSize)aSize
|
||||
{
|
||||
// Quietly return nil like in Cocoa, rather than crashing later.
|
||||
if (aFilename === undefined || aFilename === nil)
|
||||
if (aFilename == nil)
|
||||
return nil;
|
||||
|
||||
self = [super init];
|
||||
@@ -246,7 +249,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);
|
||||
@@ -275,7 +278,7 @@ function CPAppKitImage(aFilename, aSize)
|
||||
*/
|
||||
- (CGSize)size
|
||||
{
|
||||
return _size;
|
||||
return CGSizeMakeCopy(_size);
|
||||
}
|
||||
|
||||
+ (id)imageNamed:(CPString)aName
|
||||
@@ -446,6 +449,11 @@ function CPAppKitImage(aFilename, aSize)
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)isMaterialIconImage
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (CPString)description
|
||||
{
|
||||
var filename = [self filename],
|
||||
@@ -509,6 +517,229 @@ function CPAppKitImage(aFilename, aSize)
|
||||
|
||||
@end
|
||||
|
||||
// MARK: -
|
||||
// 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";
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation CPImage (CPCoding)
|
||||
|
||||
/*!
|
||||
@@ -518,7 +749,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"]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -529,10 +763,218 @@ 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
|
||||
|
||||
// MARK: -
|
||||
// MARK: Drawing
|
||||
|
||||
@implementation CPImage (Drawing)
|
||||
|
||||
- (void)drawAtPoint:(CGPoint)point fromRect:(CPRect)fromRect operation:(CGBlendMode)op fraction:(float)delta
|
||||
{
|
||||
if (_loadStatus !== CPImageLoadStatusCompleted)
|
||||
return;
|
||||
|
||||
var context = [CPGraphicsContext currentContext].graphicsPort;
|
||||
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
CGContextSaveGState(context);
|
||||
|
||||
CGContextSetBlendMode(context, op);
|
||||
CGContextSetAlpha(context, delta);
|
||||
|
||||
context.drawImage(
|
||||
_image,
|
||||
fromRect.origin.x,
|
||||
fromRect.origin.y,
|
||||
fromRect.size.width,
|
||||
fromRect.size.height,
|
||||
point.x,
|
||||
point.y,
|
||||
fromRect.size.width,
|
||||
fromRect.size.height
|
||||
);
|
||||
|
||||
CGContextRestoreGState(context);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation CPThreePartImage : CPObject
|
||||
{
|
||||
CPArray _imageSlices;
|
||||
@@ -673,3 +1115,14 @@ var CPNinePartImageImageSlicesKey = @"CPNinePartImageImageSlicesKey";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation CPImage (Duplication)
|
||||
|
||||
- (CPImage)duplicate
|
||||
{
|
||||
return [CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:self]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+47
-6
@@ -29,6 +29,8 @@
|
||||
@global CPImagesPboardType
|
||||
@global appkit_tag_dom_elements
|
||||
|
||||
@global document
|
||||
|
||||
@typedef CPImageAlignment
|
||||
CPImageAlignCenter = 0;
|
||||
CPImageAlignTop = 1;
|
||||
@@ -98,10 +100,32 @@ var CPImageViewEmptyPlaceholderImage = nil;
|
||||
- (void)_createDOMImageElement
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (_DOMImageElement)
|
||||
return;
|
||||
var image = [self objectValue],
|
||||
isCSSBasedImage = [image isCSSBased],
|
||||
isIMGImageElement = _DOMImageElement && (_DOMImageElement.nodeName == "IMG");
|
||||
|
||||
_DOMImageElement = document.createElement("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";
|
||||
@@ -150,10 +174,15 @@ var CPImageViewEmptyPlaceholderImage = nil;
|
||||
var newImage = [self objectValue];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
if (!_DOMImageElement)
|
||||
[self _createDOMImageElement];
|
||||
[self _createDOMImageElement];
|
||||
|
||||
_DOMImageElement.src = newImage ? [newImage filename] : [CPImageViewEmptyPlaceholderImage filename];
|
||||
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];
|
||||
@@ -417,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)
|
||||
|
||||
@@ -30,6 +30,7 @@ CPStandardKeyBindings = {
|
||||
@"@.": @"cancelOperation:",
|
||||
|
||||
@"@a": @"selectAll:",
|
||||
@"@~$v": @"pasteAsPlainText:",
|
||||
@"^a": @"moveToBeginningOfParagraph:",
|
||||
@"^$a": @"moveToBeginningOfParagraphAndModifySelection:",
|
||||
@"^b": @"moveBackward:",
|
||||
|
||||
@@ -182,7 +182,7 @@ var CPBindingOperationAnd = 0,
|
||||
allBindings = [bindingsForObject allKeys],
|
||||
count = [allBindings count];
|
||||
|
||||
while(count--)
|
||||
while (count--)
|
||||
{
|
||||
if ([[anObject class] isBindingExclusive:allBindings[count]])
|
||||
return NO;
|
||||
@@ -208,7 +208,11 @@ var CPBindingOperationAnd = 0,
|
||||
options = [_info objectForKey:CPOptionsKey],
|
||||
newValue = [destination valueForKeyPath:keyPath];
|
||||
|
||||
if (CPIsControllerMarker(newValue))
|
||||
// give nil values the chance to be transformed to true via CPNegateBoolean (issue #1986)
|
||||
if ((newValue == nil || CPIsControllerMarker(newValue)) && [options objectForKey:CPValueTransformerNameBindingOption] === CPNegateBooleanTransformerName)
|
||||
[self setValue:[self transformValue:NO withOptions:options] forBinding:theBinding];
|
||||
|
||||
else if (CPIsControllerMarker(newValue))
|
||||
{
|
||||
[self raiseIfNotApplicable:newValue forKeyPath:keyPath options:options];
|
||||
|
||||
@@ -293,7 +297,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;
|
||||
|
||||
@@ -653,7 +657,7 @@ var CPBindingOperationAnd = 0,
|
||||
keyPath = [info objectForKey:CPObservedKeyPathKey],
|
||||
value = [object valueForKeyPath:keyPath];
|
||||
|
||||
if (value === nil || value === undefined)
|
||||
if (value == nil)
|
||||
{
|
||||
[_source setEnabled:NO];
|
||||
return;
|
||||
@@ -796,7 +800,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]);
|
||||
@@ -857,7 +861,7 @@ var CPBindingOperationAnd = 0,
|
||||
- (id)initWithName:(CPString)aName
|
||||
{
|
||||
if (self = [super init])
|
||||
_name = aName
|
||||
_name = aName;
|
||||
|
||||
return self;
|
||||
}
|
||||
@@ -918,6 +922,7 @@ CPTextColorBinding = @"textColor";
|
||||
CPTitleBinding = @"title";
|
||||
CPToolTipBinding = @"toolTip";
|
||||
CPValueBinding = @"value";
|
||||
CPAttributedStringBinding = @"attributedString";
|
||||
CPValueURLBinding = @"valueURL";
|
||||
CPValuePathBinding = @"valuePath";
|
||||
CPDataBinding = @"data";
|
||||
|
||||
@@ -22,15 +22,10 @@
|
||||
|
||||
@import "CPControl.j"
|
||||
@import "CPWindow_Constants.j"
|
||||
@import "CPSlider.j"
|
||||
|
||||
@global CPApp
|
||||
|
||||
@typedef CPTickMarkPosition
|
||||
CPTickMarkBelow = 0;
|
||||
CPTickMarkAbove = 1;
|
||||
CPTickMarkLeft = CPTickMarkAbove;
|
||||
CPTickMarkRight = CPTickMarkBelow;
|
||||
|
||||
@typedef CPLevelIndicatorStyle
|
||||
CPRelevancyLevelIndicatorStyle = 0;
|
||||
CPContinuousCapacityLevelIndicatorStyle = 1;
|
||||
@@ -292,7 +287,7 @@ CPRatingLevelIndicatorStyle = 3;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)setWarningValue:(double)warningValue;
|
||||
- (void)setWarningValue:(double)warningValue
|
||||
{
|
||||
if (_warningValue === warningValue)
|
||||
return;
|
||||
@@ -301,7 +296,7 @@ CPRatingLevelIndicatorStyle = 3;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)setCriticalValue:(double)criticalValue;
|
||||
- (void)setCriticalValue:(double)criticalValue
|
||||
{
|
||||
if (_criticalValue === criticalValue)
|
||||
return;
|
||||
|
||||
+97
-4
@@ -27,6 +27,7 @@
|
||||
|
||||
@import "CPKeyValueBinding.j"
|
||||
@import "CPMenuItem.j"
|
||||
@import "CALayer.j"
|
||||
|
||||
@global CPApp
|
||||
|
||||
@@ -164,7 +165,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];
|
||||
@@ -268,7 +269,8 @@ var _CPMenuBarVisible = NO,
|
||||
if (self)
|
||||
{
|
||||
_title = aTitle;
|
||||
_items = [];
|
||||
// Use CPMutableArray instead of raw JS array for consistency with removeAllItems
|
||||
_items = [CPMutableArray array];
|
||||
|
||||
_autoenablesItems = YES;
|
||||
_showsStateColumn = YES;
|
||||
@@ -373,6 +375,10 @@ var _CPMenuBarVisible = NO,
|
||||
[self willChangeValueForKey:@"items"];
|
||||
_items = [CPMutableArray array];
|
||||
[self didChangeValueForKey:@"items"];
|
||||
|
||||
// Ensure the main menu updates if cleared
|
||||
if (self === [CPApp mainMenu] && _CPMenuBarSharedWindow)
|
||||
[_CPMenuBarSharedWindow setMenu:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -389,6 +395,9 @@ var _CPMenuBarVisible = NO,
|
||||
if ([aMenuItem menu] !== self || !_items)
|
||||
return;
|
||||
|
||||
if (_menuWindow)
|
||||
[[_menuWindow _menuView] tile];
|
||||
|
||||
[aMenuItem setValue:[aMenuItem valueForKey:@"changeCount"] + 1 forKey:@"changeCount"];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
@@ -1016,6 +1025,10 @@ var _CPMenuBarVisible = NO,
|
||||
// an additional mouse move after all this, but not in other browsers.
|
||||
// This will be fixed correctly with the coming run loop changes.
|
||||
[_CPDisplayServer run];
|
||||
|
||||
// If layers are updated within the menu callback, the re-draw & re-layout doesn't occur until a mouse move.
|
||||
// We force the update here.
|
||||
[CALayer runLoopUpdateLayers];
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
@@ -1057,7 +1070,23 @@ var _CPMenuBarVisible = NO,
|
||||
if ([anEvent _triggersKeyEquivalent:[item keyEquivalent] withModifierMask:[item keyEquivalentModifierMask]])
|
||||
{
|
||||
if ([item isEnabled])
|
||||
{
|
||||
// Flash the top-level item if this is the Main Menu
|
||||
if (self === [CPApp mainMenu])
|
||||
[self _flashItemAtIndex:index];
|
||||
|
||||
anEvent._isKeyEquivalent = YES; // prevent the menu keystroke from beeing inserted into textview
|
||||
[self performActionForItemAtIndex:index];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
// we are done with this event in cappuccino space. do not let the browser do something weird additionally (e.g. command-o).
|
||||
// but we must not stop copy/paste events as these can only be handled by the browser at this time even if they are in our menu
|
||||
// (until we move to CPTextView as the fieleditor)
|
||||
|
||||
if (characters != "c" && characters != "x" && characters != "v")
|
||||
_CPDOMEventStop(anEvent._DOMEvent);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
//beep?
|
||||
@@ -1067,7 +1096,13 @@ var _CPMenuBarVisible = NO,
|
||||
}
|
||||
|
||||
if ([[item submenu] performKeyEquivalent:anEvent])
|
||||
{
|
||||
// Flash the top-level item if a submenu handled the event
|
||||
if (self === [CPApp mainMenu])
|
||||
[self _flashItemAtIndex:index];
|
||||
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
@@ -1131,7 +1166,7 @@ var _CPMenuBarVisible = NO,
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_menuWithName:(CPString)aName
|
||||
- (CPMenu)_menuWithName:(CPString)aName
|
||||
{
|
||||
if (aName === _name)
|
||||
return self;
|
||||
@@ -1147,6 +1182,25 @@ var _CPMenuBarVisible = NO,
|
||||
return nil;
|
||||
}
|
||||
|
||||
//
|
||||
/*
|
||||
@ignore
|
||||
*/
|
||||
- (void)_flashItemAtIndex:(int)anIndex
|
||||
{
|
||||
// If we are using a native bridge (like a desktop wrapper), let the OS handle the visual feedback.
|
||||
if ([CPPlatform supportsNativeMainMenu])
|
||||
return;
|
||||
|
||||
[self _highlightItemAtIndex:anIndex];
|
||||
[self performSelector:@selector(_stopFlashingItem) withObject:nil afterDelay:0.2];
|
||||
}
|
||||
|
||||
- (void)_stopFlashingItem
|
||||
{
|
||||
[self _highlightItemAtIndex:CPNotFound];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -1218,6 +1272,11 @@ var _CPMenuBarVisible = NO,
|
||||
postNotificationName:CPMenuDidAddItemNotification
|
||||
object:self
|
||||
userInfo:@{ @"CPMenuItemIndex": anIndex }];
|
||||
|
||||
// FIX #1222: If this is the main menu, force the shared menu bar window to refresh its layout.
|
||||
// This ensures new items are positioned correctly (e.g. not pushed to the far right by previous layout states).
|
||||
if (self === [CPApp mainMenu] && _CPMenuBarSharedWindow)
|
||||
[_CPMenuBarSharedWindow setMenu:self];
|
||||
}
|
||||
|
||||
- (void)removeObjectFromItemsAtIndex:(CPUInteger)anIndex
|
||||
@@ -1233,6 +1292,10 @@ var _CPMenuBarVisible = NO,
|
||||
postNotificationName:CPMenuDidRemoveItemNotification
|
||||
object:self
|
||||
userInfo:@{ @"CPMenuItemIndex": anIndex }];
|
||||
|
||||
// FIX #1222: Ensure the shared menu bar updates layout when items are removed.
|
||||
if (self === [CPApp mainMenu] && _CPMenuBarSharedWindow)
|
||||
[_CPMenuBarSharedWindow setMenu:self];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1293,6 +1356,36 @@ var CPMenuTitleKey = @"CPMenuTitleKey",
|
||||
|
||||
@end
|
||||
|
||||
// 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
|
||||
|
||||
@import "_CPMenuBarWindow.j"
|
||||
@import "_CPMenuWindow.j"
|
||||
|
||||
|
||||
@@ -25,14 +25,16 @@
|
||||
|
||||
@class _CPMenuView
|
||||
@class CPMenu
|
||||
@class CPMenuItem
|
||||
|
||||
@global CPMenuDidAddItemNotification
|
||||
@global CPMenuDidChangeItemNotification
|
||||
@global CPMenuDidRemoveItemNotification
|
||||
|
||||
@global document
|
||||
|
||||
@implementation _CPMenuBarWindow : CPPanel
|
||||
{
|
||||
CPMenu _menu;
|
||||
CPView _highlightView;
|
||||
CPArray _menuItemViews;
|
||||
|
||||
@@ -130,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
|
||||
@@ -278,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];
|
||||
@@ -351,17 +365,46 @@
|
||||
|
||||
- (CPFont)font
|
||||
{
|
||||
[CPFont systemFontOfSize:[CPFont systemFontSize]];
|
||||
return [CPFont systemFontOfSize:[CPFont systemFontSize]];
|
||||
}
|
||||
|
||||
- (void)tile
|
||||
{
|
||||
var bounds = [[self contentView] bounds],
|
||||
height = CGRectGetHeight(bounds),
|
||||
x = [[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-window-left-margin" forClass:_CPMenuView];
|
||||
|
||||
// 1. Layout the Icon (if present)
|
||||
if (_iconImageView && ![_iconImageView isHidden])
|
||||
{
|
||||
var iconFrame = [_iconImageView frame];
|
||||
|
||||
iconFrame.origin.x = x;
|
||||
// Vertically center
|
||||
iconFrame.origin.y = (height - CGRectGetHeight(iconFrame)) / 2.0;
|
||||
|
||||
[_iconImageView setFrame:iconFrame];
|
||||
|
||||
x = CGRectGetMaxX(iconFrame) + 6.0; // Spacing between icon and title
|
||||
}
|
||||
|
||||
// 2. Layout the Title (if present)
|
||||
if (_titleField && [_titleField stringValue] && [[_titleField stringValue] length] > 0)
|
||||
{
|
||||
var titleFrame = [_titleField frame];
|
||||
|
||||
titleFrame.origin.x = x;
|
||||
titleFrame.origin.y = (height - CGRectGetHeight(titleFrame)) / 2.0;
|
||||
|
||||
[_titleField setFrame:titleFrame];
|
||||
|
||||
x = CGRectGetMaxX(titleFrame) + 12.0; // Spacing between title and menu items
|
||||
}
|
||||
|
||||
// 3. Layout the Menu Items
|
||||
var items = [_menu itemArray],
|
||||
index = 0,
|
||||
count = items.length,
|
||||
|
||||
x = [[CPTheme defaultTheme] valueForAttributeWithName:@"menu-bar-window-left-margin" forClass:_CPMenuView],
|
||||
y = 0.0,
|
||||
count = items ? items.length : 0,
|
||||
isLeftAligned = YES;
|
||||
|
||||
for (; index < count; ++index)
|
||||
@@ -376,11 +419,18 @@
|
||||
continue;
|
||||
}
|
||||
|
||||
if ([item isHidden])
|
||||
// Fix for #1742: If a main menu item does not have a submenu, it should not appear in the menu bar.
|
||||
if ([item isHidden] || ![item submenu])
|
||||
{
|
||||
[[item _menuItemView] setHidden:YES];
|
||||
continue;
|
||||
}
|
||||
|
||||
var menuItemView = [item _menuItemView],
|
||||
frame = [menuItemView frame];
|
||||
var menuItemView = [item _menuItemView];
|
||||
|
||||
[menuItemView setHidden:NO];
|
||||
|
||||
var frame = [menuItemView frame];
|
||||
|
||||
if (isLeftAligned)
|
||||
{
|
||||
@@ -395,21 +445,6 @@
|
||||
x = CGRectGetMinX([menuItemView frame]);
|
||||
}
|
||||
}
|
||||
|
||||
var bounds = [[self contentView] bounds],
|
||||
titleFrame = [_titleField frame];
|
||||
|
||||
if ([_iconImageView isHidden])
|
||||
[_titleField setFrameOrigin:CGPointMake((CGRectGetWidth(bounds) - CGRectGetWidth(titleFrame)) / 2.0, (CGRectGetHeight(bounds) - CGRectGetHeight(titleFrame)) / 2.0)];
|
||||
else
|
||||
{
|
||||
var iconFrame = [_iconImageView frame],
|
||||
iconWidth = CGRectGetWidth(iconFrame),
|
||||
totalWidth = iconWidth + CGRectGetWidth(titleFrame);
|
||||
|
||||
[_iconImageView setFrameOrigin:CGPointMake((CGRectGetWidth(bounds) - totalWidth) / 2.0, (CGRectGetHeight(bounds) - CGRectGetHeight(iconFrame)) / 2.0)];
|
||||
[_titleField setFrameOrigin:CGPointMake((CGRectGetWidth(bounds) - totalWidth) / 2.0 + iconWidth, (CGRectGetHeight(bounds) - CGRectGetHeight(titleFrame)) / 2.0)];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setFrame:(CGRect)aRect display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate
|
||||
@@ -450,13 +485,18 @@
|
||||
{
|
||||
var item = items[index];
|
||||
|
||||
if ([item isHidden] || [item isSeparatorItem])
|
||||
if ([item isHidden] || [item isSeparatorItem] || ![item submenu])
|
||||
continue;
|
||||
|
||||
if (CGRectContainsPoint([self rectForItemAtIndex:index], aPoint))
|
||||
return index;
|
||||
}
|
||||
|
||||
// If the mouse is within the menu bar bounds but not over an item
|
||||
// (e.g. dragging far left or right), force the menu to unhighlight.
|
||||
if (CGRectContainsPoint([[self contentView] bounds], aPoint))
|
||||
[_menu _highlightItemAtIndex:CPNotFound];
|
||||
|
||||
return CPNotFound;
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -553,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);
|
||||
|
||||
@@ -580,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
|
||||
@@ -587,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;
|
||||
@@ -725,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
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
@import "_CPMenuManager.j"
|
||||
|
||||
@class _CPMenuView
|
||||
@class CPMenuItem
|
||||
|
||||
var _CPMenuWindowPool = [],
|
||||
_CPMenuWindowPoolCapacity = 5,
|
||||
@@ -233,6 +234,19 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
|
||||
// FIXME: This gets called far too often.
|
||||
_unconstrainedFrame = CGRectMakeCopy(aFrame);
|
||||
|
||||
// If we are a submenu and we are being displayed off the right of the screen,
|
||||
// we should try and display on the left of our supermenu.
|
||||
var supermenu = [[self menu] supermenu];
|
||||
if (supermenu && (CGRectGetMaxX(_unconstrainedFrame) > CGRectGetMaxX(_constraintRect)))
|
||||
{
|
||||
var supermenuWindow = supermenu._menuWindow;
|
||||
if (supermenuWindow)
|
||||
{
|
||||
var supermenuFrame = [supermenuWindow frame];
|
||||
_unconstrainedFrame.origin.x = CGRectGetMinX(supermenuFrame) - CGRectGetWidth(_unconstrainedFrame);
|
||||
}
|
||||
}
|
||||
|
||||
var constrainedFrame = CGRectIntersection(_unconstrainedFrame, _constraintRect),
|
||||
marginInset = [_menuView valueForThemeAttribute:@"menu-window-margin-inset"],
|
||||
scrollIndicatorHeight = [_menuView valueForThemeAttribute:@"menu-window-scroll-indicator-height"];
|
||||
@@ -419,6 +433,21 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
|
||||
|
||||
@end
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation _CPMenuWindow (CSSTheming)
|
||||
|
||||
- (void)_setThemeIncludingDescendants:(CPTheme)aTheme
|
||||
{
|
||||
[[self contentView] _setThemeIncludingDescendants:aTheme];
|
||||
[_menuView _setThemeIncludingDescendants:aTheme];
|
||||
[_menuView tile];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// MARK: -
|
||||
|
||||
/*
|
||||
@ignore
|
||||
*/
|
||||
@@ -449,6 +478,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,
|
||||
@@ -466,6 +496,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
|
||||
};
|
||||
}
|
||||
|
||||
@@ -552,6 +585,7 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
|
||||
|
||||
[view setFrameOrigin:CGPointMake(0.0, y)];
|
||||
|
||||
[view _setThemeIncludingDescendants:[CPTheme defaultTheme]];
|
||||
[self addSubview:view];
|
||||
|
||||
var size = [view minSize],
|
||||
@@ -582,3 +616,18 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// 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
|
||||
|
||||
@@ -505,7 +505,7 @@ CPOffState
|
||||
if (_submenu)
|
||||
{
|
||||
[_submenu setSupermenu:_menu];
|
||||
[_submenu setTitle:[self title]]
|
||||
[_submenu setTitle:[self title]];
|
||||
|
||||
[self setTarget:_menu];
|
||||
[self setAction:@selector(submenuAction:)];
|
||||
@@ -826,7 +826,7 @@ CPControlKeyMask
|
||||
return [[self menu] highlightedItem] == self;
|
||||
}
|
||||
|
||||
#pragma mark CPObject Overrides
|
||||
// MARK: CPObject Overrides
|
||||
|
||||
/*!
|
||||
Returns a copy of the item. The copy does not belong If the item has a submenu, it is NOT copied.
|
||||
@@ -843,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];
|
||||
@@ -867,7 +867,7 @@ CPControlKeyMask
|
||||
return [self copy];
|
||||
}
|
||||
|
||||
#pragma mark Internal
|
||||
// MARK: Internal
|
||||
|
||||
/*
|
||||
@ignore
|
||||
@@ -897,6 +897,20 @@ CPControlKeyMask
|
||||
|
||||
@end
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation CPMenuItem (CSSTheming)
|
||||
|
||||
- (void)_setThemeIncludingDescendants:(CPTheme)aTheme
|
||||
{
|
||||
[_view _setThemeIncludingDescendants:aTheme];
|
||||
[_menuItemView _setThemeIncludingDescendants:aTheme];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// MARK: -
|
||||
|
||||
var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
|
||||
|
||||
CPMenuItemTitleKey = @"CPMenuItemTitleKey",
|
||||
@@ -911,6 +925,9 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
|
||||
|
||||
CPMenuItemImageKey = @"CPMenuItemImageKey",
|
||||
CPMenuItemAlternateImageKey = @"CPMenuItemAlternateImageKey",
|
||||
CPMenuItemOnStateImageKey = @"CPMenuItemOnStateImageKey",
|
||||
CPMenuItemOffStateImageKey = @"CPMenuItemOffStateImageKey",
|
||||
CPMenuItemMixedStateImageKey = @"CPMenuItemMixedStateImageKey",
|
||||
|
||||
CPMenuItemSubmenuKey = @"CPMenuItemSubmenuKey",
|
||||
CPMenuItemMenuKey = @"CPMenuItemMenuKey",
|
||||
@@ -955,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];
|
||||
@@ -1003,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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
_CPImageAndTextView _imageAndTextView;
|
||||
_CPImageAndTextView _keyEquivalentView;
|
||||
CPView _submenuIndicatorView;
|
||||
|
||||
BOOL _hasSubmenuIndicatorImage;
|
||||
}
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
@@ -55,6 +57,7 @@
|
||||
@"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],
|
||||
@@ -62,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]
|
||||
};
|
||||
}
|
||||
|
||||
@@ -90,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];
|
||||
|
||||
@@ -108,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];
|
||||
@@ -124,7 +148,7 @@
|
||||
- (CPColor)textColor
|
||||
{
|
||||
if (![_menuItem isEnabled])
|
||||
return [CPColor lightGrayColor];
|
||||
return [self valueForThemeAttribute:@"menu-item-disabled-text-color"];
|
||||
|
||||
if (_highlighted)
|
||||
return [CPColor whiteColor];
|
||||
@@ -148,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)
|
||||
{
|
||||
@@ -162,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]];
|
||||
@@ -195,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];
|
||||
@@ -205,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];
|
||||
@@ -229,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];
|
||||
@@ -241,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)
|
||||
@@ -251,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];
|
||||
}
|
||||
|
||||
@@ -276,6 +326,8 @@
|
||||
|
||||
_highlighted = shouldHighlight;
|
||||
|
||||
var correspondingControlSize = [[self font] controlSizeCorrespondingToFontSize];
|
||||
|
||||
[_imageAndTextView setTextColor:[self textColor]];
|
||||
[_keyEquivalentView setTextColor:[self textColor]];
|
||||
[_imageAndTextView setTextShadowColor:[self textShadowColor]];
|
||||
@@ -285,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])
|
||||
@@ -301,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:
|
||||
@@ -321,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:
|
||||
@@ -346,6 +406,22 @@
|
||||
|
||||
@end
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation _CPMenuItemStandardView (CSSTheming)
|
||||
|
||||
// MARK: Override
|
||||
|
||||
- (void)_setThemeIncludingDescendants:(CPTheme)aTheme
|
||||
{
|
||||
[self setTheme:aTheme];
|
||||
[[self subviews] makeObjectsPerformSelector:@selector(_setThemeIncludingDescendants:) withObject:aTheme];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation _CPMenuItemSubmenuIndicatorView : CPView
|
||||
{
|
||||
CPColor _color;
|
||||
|
||||
@@ -252,6 +252,31 @@
|
||||
|
||||
@end
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation _CPMenuItemView (CSSTheming)
|
||||
|
||||
// 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
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation _CPMenuItemArrowView : CPView
|
||||
{
|
||||
CPColor _color;
|
||||
|
||||
+132
-7
@@ -27,6 +27,9 @@
|
||||
@import "CPController.j"
|
||||
@import "CPKeyValueBinding.j"
|
||||
|
||||
@class _CPManagedProxy
|
||||
@class CPPredicate;
|
||||
|
||||
/*!
|
||||
@class
|
||||
|
||||
@@ -47,6 +50,9 @@
|
||||
|
||||
BOOL _isEditable;
|
||||
BOOL _automaticallyPreparesContent;
|
||||
BOOL _usesLazyFetching @accessors(getter=usesLazyFetching, setter=setUsesLazyFetching:);
|
||||
BOOL _isUsingManagedProxy;
|
||||
_CPManagedProxy _managedProxy;
|
||||
|
||||
CPCountedSet _observedKeys;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
@@ -719,7 +808,8 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
var value = [self _controllerMarkerForValues:values];
|
||||
[_cachedValues setObject:value forKey:theKeyPath];
|
||||
|
||||
return value;
|
||||
// Apple's implementation returns nil instead of CPNullMarker
|
||||
return value === CPNullMarker ? nil : value;
|
||||
}
|
||||
else
|
||||
return values;
|
||||
@@ -749,7 +839,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
|
||||
- (void)setValue:(id)theValue forKey:(CPString)theKeyPath
|
||||
{
|
||||
[self setValue:theKeyPath forKeyPath:theKeyPath];
|
||||
[self setValue:theValue forKeyPath:theKeyPath];
|
||||
}
|
||||
|
||||
- (unsigned)count
|
||||
@@ -825,3 +915,38 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
}
|
||||
|
||||
@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
|
||||
|
||||
+504
-183
@@ -23,6 +23,7 @@
|
||||
@import "CPButton.j"
|
||||
@import "CPTableColumn.j"
|
||||
@import "CPTableView.j"
|
||||
@import "CPTreeNode.j"
|
||||
|
||||
@global CPApp
|
||||
|
||||
@@ -127,16 +128,112 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
@protocol CPOutlineViewDataSource <CPObject>
|
||||
|
||||
@optional
|
||||
/*!
|
||||
@abstract Invoked when a drag operation concludes over the outline view.
|
||||
@discussion The data source should incorporate the data from the dragging pasteboard and update its data model.
|
||||
@param anOutlineView The outline view that is the destination of the drop.
|
||||
@param info An object that contains information about the dragging session.
|
||||
@param anItem The item that is the proposed parent for the dropped data. If anItem is nil, the data is to be dropped at the root level.
|
||||
@param anIndex The index at which to drop the data among the item's children. If you want to drop on anItem, this will be CPOutlineViewDropOnItemIndex (-1).
|
||||
@return YES if the drop was successful; otherwise, NO.
|
||||
*/
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView acceptDrop:(id /*<CPDraggingInfo>*/)info item:(id)anItem childIndex:(CPInteger)anIndex;
|
||||
|
||||
/*!
|
||||
@abstract Asks the data source whether to defer displaying the children of a given item.
|
||||
@discussion This method is useful for implementing lazy loading of outline view data. Returning NO prevents the outline view from querying for children of anItem, even if it is expandable.
|
||||
@param anOutlineView The outline view that sent the message.
|
||||
@param anItem The item being considered for expansion.
|
||||
@return YES to allow the outline view to query for children of anItem; otherwise, NO. The default is YES.
|
||||
*/
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView shouldDeferDisplayingChildrenOfItem:(id)anItem;
|
||||
|
||||
/*!
|
||||
@abstract Invoked when a drag should begin.
|
||||
@discussion The data source should write the representation of the specified items to the pasteboard.
|
||||
@param anOutlineView The outline view that is the source of the drag.
|
||||
@param items An array of items to be dragged.
|
||||
@param pboard The pasteboard to which the data for the dragged items should be written.
|
||||
@return YES if the drag should begin; NO to prevent the drag.
|
||||
*/
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView writeItems:(CPArray)items toPasteboard:(CPPasteboard)pboard;
|
||||
|
||||
/*!
|
||||
@abstract Used for promised-file dragging.
|
||||
@discussion When a promised-file drag is dropped, this method is invoked to ask the data source to create the files at the specified destination and return their names.
|
||||
@param anOutlineView The outline view that was the source of the drag.
|
||||
@param dropDestination The URL of the directory where the files should be created.
|
||||
@param items The items that were dragged, representing the promised files.
|
||||
@return An array of strings containing the names of the files that were created.
|
||||
*/
|
||||
- (CPArray)outlineView:(CPOutlineView)anOutlineView namesOfPromisedFilesDroppedAtDestination:(CPURL)dropDestination forDraggedItems:(CPArray)items;
|
||||
|
||||
/*!
|
||||
@abstract Invoked to determine if a drop is allowed at a specified location.
|
||||
@discussion This method is called repeatedly while the user drags over the outline view. It should return the drag operation that should be performed.
|
||||
@param anOutlineView The outline view that is the destination of the drag.
|
||||
@param info An object that contains information about the dragging session.
|
||||
@param anItem The item that is the proposed parent for the dropped data.
|
||||
@param anIndex The index at which to drop the data among the item's children. If you want to drop on anItem, this will be CPOutlineViewDropOnItemIndex (-1).
|
||||
@return A CPDragOperation value that indicates the type of operation to perform.
|
||||
*/
|
||||
- (CPDragOperation)outlineView:(CPOutlineView)anOutlineView validateDrop:(id /*<CPDraggingInfo>*/)info proposedItem:(id)anItem proposedChildIndex:(CPInteger)anIndex;
|
||||
|
||||
/*!
|
||||
@abstract Invoked to determine if a drop is allowed at a specified row.
|
||||
@discussion This is a legacy method from CPTableView. It is recommended to implement outlineView:validateDrop:proposedItem:proposedChildIndex: instead for more precise control in an outline view.
|
||||
@param anOutlineView The outline view that is the destination of the drag.
|
||||
@param info An object that contains information about the dragging session.
|
||||
@param theRow The proposed row for the drop.
|
||||
@param theOperation The proposed drop operation (CPTableViewDropOn or CPTableViewDropAbove).
|
||||
@return A CPDragOperation value that indicates the type of operation to perform.
|
||||
*/
|
||||
- (CPDragOperation)outlineView:(CPOutlineView)anOutlineView validateDrop:(id /*<CPDraggingInfo>*/)info proposedRow:(int)theRow proposedDropOperation:(CPTableViewDropOperation)theOperation;
|
||||
|
||||
/*!
|
||||
@abstract Used for state preservation.
|
||||
@discussion This method is called to convert a persistent, serializable object back into a model item.
|
||||
@param anOutlineView The outline view requesting the item.
|
||||
@param anObject The persistent object used to identify the model item.
|
||||
@return The model item corresponding to anObject, or nil if it cannot be found.
|
||||
*/
|
||||
- (id)outlineView:(CPOutlineView)anOutlineView itemForPersistentObject:(id)anObject;
|
||||
|
||||
/*!
|
||||
@abstract Returns the data object to be displayed for a given item and column.
|
||||
@discussion This method is called by the outline view to get the value for each cell. It is required for cell-based outline views.
|
||||
@param anOutlineView The outline view that sent the message.
|
||||
@param aTableColumn The column for which the value is requested.
|
||||
@param anItem The item for the row being displayed.
|
||||
@return The data object (e.g., a CPString) for the specified item and column.
|
||||
*/
|
||||
- (id)outlineView:(CPOutlineView)anOutlineView objectValueforTableColumn:(CPTableColumn)aTableColumn byItem:(id)anItem;
|
||||
|
||||
/*!
|
||||
@abstract Used for state preservation.
|
||||
@discussion This method is called to convert a model item into a persistent, serializable object (e.g., a string identifier) that can be saved.
|
||||
@param anOutlineView The outline view requesting the persistent object.
|
||||
@param anItem The item to be converted.
|
||||
@return A serializable object that persistently identifies anItem.
|
||||
*/
|
||||
- (id)outlineView:(CPOutlineView)anOutlineView persistentObjectForItem:(id)anItem;
|
||||
|
||||
/*!
|
||||
@abstract Sets the data object for a given item and column.
|
||||
@discussion This method is called when the user edits a cell's value. The data source should update its model with the new value.
|
||||
@param anOutlineView The outline view that sent the message.
|
||||
@param anObject The new value.
|
||||
@param aTableColumn The column that was edited.
|
||||
@param anItem The item whose value was edited.
|
||||
*/
|
||||
- (void)outlineView:(CPOutlineView)anOutlineView setObjectValue:(id)anObject forTableColumn:(CPTableColumn)aTableColumn byItem:(id)anItem;
|
||||
|
||||
/*!
|
||||
@abstract Notifies the data source that the sort descriptors have changed.
|
||||
@discussion This method is called after the user clicks a column header to change the sort order. The data source should re-sort its data based on the outline view's new 'sortDescriptors' property and then call `reloadData`.
|
||||
@param anOutlineView The outline view that sent the message.
|
||||
@param oldDescriptors The previous sort descriptors.
|
||||
*/
|
||||
- (void)outlineView:(CPOutlineView)anOutlineView sortDescriptorsDidChange:(CPArray)oldDescriptors;
|
||||
|
||||
@end
|
||||
@@ -215,14 +312,30 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
[self setIndentationPerLevel:16.0];
|
||||
[self setIndentationMarkerFollowsDataView:YES];
|
||||
|
||||
[super setDataSource:[[_CPOutlineViewTableViewDataSource alloc] initWithOutlineView:self]];
|
||||
[super setDelegate:[[_CPOutlineViewTableViewDelegate alloc] initWithOutlineView:self]];
|
||||
[super setDataSource:self];
|
||||
[super setDelegate:self];
|
||||
|
||||
[self setDisclosureControlPrototype:[[CPDisclosureButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 10.0, 10.0)]];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_initSubclass
|
||||
{
|
||||
_BlockDeselectView = function(view, row, column)
|
||||
{
|
||||
[view unsetThemeState:CPThemeStateSelectedDataView];
|
||||
[_disclosureControlsForRows[row] unsetThemeState:CPThemeStateSelected];
|
||||
};
|
||||
|
||||
_BlockSelectView = function(view, row, column)
|
||||
{
|
||||
[view setThemeState:CPThemeStateSelectedDataView];
|
||||
[_disclosureControlsForRows[row] setThemeState:CPThemeStateSelected];
|
||||
};
|
||||
}
|
||||
|
||||
/*!
|
||||
In addition to standard delegation, the outline view also supports data
|
||||
source delegation. This method sets the data source object. Just like the
|
||||
@@ -661,6 +774,11 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
[self reloadItem:anItem reloadChildren:NO];
|
||||
}
|
||||
|
||||
- (int)_numberOfRows
|
||||
{
|
||||
return _itemsForRows ? _itemsForRows.length : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Reloads the data for a given item and optionally the children.
|
||||
|
||||
@@ -669,9 +787,12 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
*/
|
||||
- (void)reloadItem:(id)anItem reloadChildren:(BOOL)shouldReloadChildren
|
||||
{
|
||||
|
||||
_pendingItemToClean = [];
|
||||
_itemAddedDuringLastLoading = [];
|
||||
|
||||
var previousRowCount = _itemsForRows.length;
|
||||
|
||||
if (!!shouldReloadChildren || !anItem)
|
||||
[self _loadItemInfoForItem:anItem intermediate:NO];
|
||||
else
|
||||
@@ -679,7 +800,12 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
|
||||
[self _cleanPendingItem];
|
||||
|
||||
[super reloadData];
|
||||
// Safely update the table size and force a synchronous layout recalculation
|
||||
// BEFORE the views are reloaded, avoiding the clipping issue.
|
||||
if (_itemsForRows.length !== previousRowCount)
|
||||
[self noteNumberOfRowsChanged];
|
||||
|
||||
[super _reloadDataViews];
|
||||
}
|
||||
|
||||
- (void)_reloadItem:(id)anItem
|
||||
@@ -725,9 +851,20 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
|
||||
for (var i = [previousItems count] - 1; i >= 0; i--)
|
||||
{
|
||||
var item = previousItems[i];
|
||||
var item = previousItems[i],
|
||||
found = NO;
|
||||
|
||||
if (![children containsObject:item])
|
||||
// Use strict identity (===) instead of containsObject: (which triggers isEqual:)
|
||||
for (var j = 0, count = children.length; j < count; j++)
|
||||
{
|
||||
if (children[j] === item)
|
||||
{
|
||||
found = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
[self _addPendingItem:item];
|
||||
}
|
||||
}
|
||||
@@ -741,7 +878,8 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
|
||||
var children = itemInfo.children;
|
||||
|
||||
for (var i = [children count]; i >= 0; i--)
|
||||
// Fixed out-of-bounds index (was previously [children count])
|
||||
for (var i = children.length - 1; i >= 0; i--)
|
||||
{
|
||||
var child = children[i];
|
||||
[self _addPendingItem:child];
|
||||
@@ -752,7 +890,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
|
||||
- (void)_cleanPendingItem
|
||||
{
|
||||
for (var i = [_pendingItemToClean count]; i >= 0; i--)
|
||||
for (var i = [_pendingItemToClean count] - 1; i >= 0; i--)
|
||||
{
|
||||
var item = _pendingItemToClean[i];
|
||||
|
||||
@@ -796,7 +934,8 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
var weight = itemInfo.weight,
|
||||
descendants = anItem ? [anItem] : [];
|
||||
|
||||
[_itemAddedDuringLastLoading addObject:anItem];
|
||||
if (anItem)
|
||||
[_itemAddedDuringLastLoading addObject:anItem];
|
||||
|
||||
if (itemInfo.isExpanded && [self _sendDataSourceShouldDeferDisplayingChildrenOfItem:anItem])
|
||||
{
|
||||
@@ -973,7 +1112,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
var parent = itemInfo.parent;
|
||||
|
||||
// Check if the parent is the root item because we never return the actual root item
|
||||
if (itemInfo[[parent UID]] === _rootItemInfo)
|
||||
if (parent && _itemInfosForItems[[parent UID]] === _rootItemInfo)
|
||||
parent = nil;
|
||||
|
||||
return parent;
|
||||
@@ -1308,7 +1447,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
/*!
|
||||
Reloads all the data of the outlineview.
|
||||
*/
|
||||
- (void)reloadData
|
||||
- (void)_reloadDataViews
|
||||
{
|
||||
[self reloadItem:nil reloadChildren:YES];
|
||||
}
|
||||
@@ -1340,6 +1479,25 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
else
|
||||
[super removeTableColumn:aTableColumn];
|
||||
}
|
||||
|
||||
- (void)_addDraggedDataView:(CPView)aDataView toView:(CPView)aSuperview forColumn:(CPInteger)column row:(CPInteger)row offset:(CGPoint)offset
|
||||
{
|
||||
var control;
|
||||
|
||||
[super _addDraggedDataView:aDataView toView:aSuperview forColumn:column row:row offset:offset];
|
||||
|
||||
if (_tableColumns[column] === _outlineTableColumn && (control = _disclosureControlsForRows[row]))
|
||||
{
|
||||
var controlFrame = [self frameOfOutlineDisclosureControlAtRow:row];
|
||||
|
||||
controlFrame.origin.x -= offset.x;
|
||||
controlFrame.origin.y -= offset.y;
|
||||
|
||||
[control setFrame:controlFrame];
|
||||
[aSuperview addSubview:control];
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
We override this because we need a special behavior for the outline
|
||||
@@ -1355,65 +1513,19 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
return [super frameOfDataViewAtColumn:aColumn row:aRow];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
We need to offset the dataview and add the disclosure triangle.
|
||||
*/
|
||||
- (CPView)_dragViewForColumn:(CPInteger)theColumnIndex event:(CPEvent)theDragEvent offset:(CGPoint)theDragViewOffset
|
||||
- (void)_applyToolTipToDataView:(CPView)aDataView forTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow
|
||||
{
|
||||
var dragView = [[_CPColumnDragView alloc] initWithLineColor:[self gridColor]],
|
||||
tableColumn = [[self tableColumns] objectAtIndex:theColumnIndex],
|
||||
defaultRowHeight = [self valueForThemeAttribute:@"default-row-height"],
|
||||
bounds = CGRectMake(0.0, 0.0, [tableColumn width], CGRectGetHeight([self exposedRect]) + defaultRowHeight),
|
||||
columnRect = [self rectOfColumn:theColumnIndex],
|
||||
headerView = [tableColumn headerView],
|
||||
row = [_exposedRows firstIndex];
|
||||
|
||||
while (row !== CPNotFound)
|
||||
if (_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_toolTipForView_rect_tableColumn_item_mouseLocation_)
|
||||
{
|
||||
var dataView = [self _newDataViewForRow:row tableColumn:tableColumn],
|
||||
dataViewFrame = [self frameOfDataViewAtColumn:theColumnIndex row:row];
|
||||
var item = [self itemAtRow:aRow],
|
||||
tooltip = [self _sendDelegateToolTipForView:aDataView rect:[aDataView frame] tableColumn:aTableColumn item:item mouseLocation:CGPointMakeZero()];
|
||||
|
||||
// Only one column is ever dragged so we just place the view at
|
||||
dataViewFrame.origin.x = 0.0;
|
||||
|
||||
// Offset by table header height - scroll position
|
||||
dataViewFrame.origin.y = (CGRectGetMinY(dataViewFrame) - CGRectGetMinY([self exposedRect])) + defaultRowHeight;
|
||||
[dataView setFrame:dataViewFrame];
|
||||
|
||||
[dataView setObjectValue:[self _objectValueForTableColumn:tableColumn row:row]];
|
||||
|
||||
|
||||
if (tableColumn === _outlineTableColumn)
|
||||
{
|
||||
// first inset the dragview
|
||||
var indentationWidth = ([self levelForRow:row] + 1) * [self indentationPerLevel];
|
||||
|
||||
dataViewFrame.origin.x += indentationWidth;
|
||||
dataViewFrame.size.width -= indentationWidth;
|
||||
|
||||
[dataView setFrame:dataViewFrame];
|
||||
}
|
||||
|
||||
[dragView addSubview:dataView];
|
||||
|
||||
row = [_exposedRows indexGreaterThanIndex:row];
|
||||
[aDataView setToolTip:tooltip];
|
||||
}
|
||||
else
|
||||
{
|
||||
[super _applyToolTipToDataView:aDataView forTableColumn:aTableColumn row:aRow];
|
||||
}
|
||||
|
||||
// Add the column header view
|
||||
var headerFrame = [headerView frame];
|
||||
headerFrame.origin = CGPointMakeZero();
|
||||
|
||||
var columnHeaderView = [[_CPTableColumnHeaderView alloc] initWithFrame:headerFrame];
|
||||
[columnHeaderView setStringValue:[headerView stringValue]];
|
||||
[columnHeaderView setThemeState:[headerView themeState]];
|
||||
[dragView addSubview:columnHeaderView];
|
||||
|
||||
[dragView setBackgroundColor:[CPColor whiteColor]];
|
||||
[dragView setAlphaValue:0.7];
|
||||
[dragView setFrame:bounds];
|
||||
|
||||
return dragView;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1443,7 +1555,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
if (_dropItem)
|
||||
{
|
||||
[_dropOperationFeedbackView blink];
|
||||
[CPTimer scheduledTimerWithTimeInterval:.3 callback:objj_msgSend(self, "expandItem:", _dropItem) repeats:NO];
|
||||
[CPTimer scheduledTimerWithTimeInterval:.3 callback:[self expandItem:_dropItem] repeats:NO];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1464,7 +1576,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
_shouldRetargetChildIndex = YES;
|
||||
|
||||
// set CPTableView's _retargetedDropRow based on retargetedItem and retargetedChildIndex
|
||||
var retargetedItemInfo = (_retargetedItem !== nil) ? _itemInfosForItems[[_retargetedItem UID]] : _rootItemInfo;
|
||||
var retargetedItemInfo = (_retargetedItem != nil) ? _itemInfosForItems[[_retargetedItem UID]] : _rootItemInfo;
|
||||
|
||||
if (_retargedChildIndex === [retargetedItemInfo.children count])
|
||||
{
|
||||
@@ -1539,43 +1651,22 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
@ignore
|
||||
We need to move the disclosure control too.
|
||||
*/
|
||||
- (void)_layoutDataViewsInRows:(CPIndexSet)rows columns:(CPIndexSet)columns
|
||||
- (void)_layoutViewsForRowIndexes:(CPIndexSet)rowIndexes columnIndexes:(CPIndexSet)columnIndexes
|
||||
{
|
||||
var rowArray = [],
|
||||
columnArray = [];
|
||||
|
||||
[rows getIndexes:rowArray maxCount:-1 inIndexRange:nil];
|
||||
[columns getIndexes:columnArray maxCount:-1 inIndexRange:nil];
|
||||
|
||||
var columnIndex = 0,
|
||||
columnsCount = columnArray.length;
|
||||
|
||||
for (; columnIndex < columnsCount; ++columnIndex)
|
||||
[self _enumerateViewsInRows:rowIndexes columns:columnIndexes usingBlock:function(view, row, column, stop)
|
||||
{
|
||||
var column = columnArray[columnIndex],
|
||||
tableColumn = _tableColumns[column],
|
||||
tableColumnUID = [tableColumn UID],
|
||||
dataViewsForTableColumn = _dataViewsForTableColumns[tableColumnUID],
|
||||
rowIndex = 0,
|
||||
rowsCount = rowArray.length;
|
||||
var control;
|
||||
|
||||
for (; rowIndex < rowsCount; ++rowIndex)
|
||||
[view setFrame:[self frameOfDataViewAtColumn:column row:row]];
|
||||
|
||||
if (_tableColumns[column] === _outlineTableColumn && (control = _disclosureControlsForRows[row]))
|
||||
{
|
||||
var row = rowArray[rowIndex],
|
||||
dataView = dataViewsForTableColumn[row],
|
||||
dataViewFrame = [self frameOfDataViewAtColumn:column row:row];
|
||||
|
||||
[dataView setFrame:dataViewFrame];
|
||||
|
||||
if (tableColumn === _outlineTableColumn)
|
||||
{
|
||||
var control = _disclosureControlsForRows[row],
|
||||
frame = [self frameOfOutlineDisclosureControlAtRow:row];
|
||||
|
||||
[control setFrame:frame];
|
||||
}
|
||||
var frame = [self frameOfOutlineDisclosureControlAtRow:row];
|
||||
[control setFrame:frame];
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1587,7 +1678,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
|
||||
var outlineColumn = [[self tableColumns] indexOfObjectIdenticalTo:[self outlineTableColumn]];
|
||||
|
||||
if (![columns containsIndex:outlineColumn] || [self outlineTableColumn] === _draggedColumn)
|
||||
if (![columns containsIndex:outlineColumn] || outlineColumn === _draggedColumnIndex)
|
||||
return;
|
||||
|
||||
var rowArray = [];
|
||||
@@ -1890,6 +1981,14 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
return _implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_;
|
||||
}
|
||||
|
||||
- (id)_hitTest:(CPView)aView
|
||||
{
|
||||
if ([aView isKindOfClass:[CPDisclosureButton class]])
|
||||
return aView;
|
||||
|
||||
return [super _hitTest:aView];
|
||||
}
|
||||
|
||||
- (BOOL)_delegateRespondsToShouldExpandItem
|
||||
{
|
||||
return _implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldExpandItem_;
|
||||
@@ -1918,43 +2017,28 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
return _implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldSelectItem_;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPOutlineViewTableViewDataSource : CPObject
|
||||
{
|
||||
CPObject _outlineView;
|
||||
}
|
||||
|
||||
- (id)initWithOutlineView:(CPOutlineView)anOutlineView
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
_outlineView = anOutlineView;
|
||||
|
||||
return self;
|
||||
}
|
||||
/*** CPTableViewDataSource methods ***/
|
||||
|
||||
- (CPInteger)numberOfRowsInTableView:(CPTableView)anOutlineView
|
||||
{
|
||||
return _outlineView._itemsForRows.length;
|
||||
return _itemsForRows.length;
|
||||
}
|
||||
|
||||
- (id)tableView:(CPTableView)aTableView objectValueForTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow
|
||||
{
|
||||
return [_outlineView._outlineViewDataSource outlineView:_outlineView objectValueForTableColumn:aTableColumn byItem:_outlineView._itemsForRows[aRow]];
|
||||
return [_outlineViewDataSource outlineView:self objectValueForTableColumn:aTableColumn byItem:_itemsForRows[aRow]];
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView setObjectValue:(id)aValue forTableColumn:(CPTableColumn)aColumn row:(CPInteger)aRow
|
||||
{
|
||||
if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_))
|
||||
if (!(_implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_))
|
||||
return;
|
||||
[_outlineView._outlineViewDataSource outlineView:_outlineView setObjectValue:aValue forTableColumn:aColumn byItem:_outlineView._itemsForRows[aRow]];
|
||||
[_outlineViewDataSource outlineView:self setObjectValue:aValue forTableColumn:aColumn byItem:_itemsForRows[aRow]];
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableColumn writeRowsWithIndexes:(CPIndexSet)theIndexes toPasteboard:(CPPasteboard)thePasteboard
|
||||
{
|
||||
if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_writeItems_toPasteboard_))
|
||||
if (!(_implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_writeItems_toPasteboard_))
|
||||
return NO;
|
||||
|
||||
var items = [],
|
||||
@@ -1962,27 +2046,27 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
|
||||
while (index !== CPNotFound)
|
||||
{
|
||||
[items addObject:[_outlineView itemAtRow:index]]
|
||||
[items addObject:[self itemAtRow:index]];
|
||||
index = [theIndexes indexGreaterThanIndex:index];
|
||||
}
|
||||
|
||||
return [_outlineView._outlineViewDataSource outlineView:_outlineView writeItems:items toPasteboard:thePasteboard];
|
||||
return [_outlineViewDataSource outlineView:self writeItems:items toPasteboard:thePasteboard];
|
||||
}
|
||||
|
||||
- (int)_childIndexForDropOperation:(CPTableViewDropOperation)theDropOperation row:(CPInteger)theRow offset:(CGPoint)theOffset
|
||||
{
|
||||
if (_outlineView._shouldRetargetChildIndex)
|
||||
return _outlineView._retargedChildIndex;
|
||||
if (_shouldRetargetChildIndex)
|
||||
return _retargedChildIndex;
|
||||
|
||||
var childIndex = CPNotFound;
|
||||
|
||||
if (theDropOperation === CPTableViewDropAbove)
|
||||
{
|
||||
var parentItem = [_outlineView _parentItemForUpperRow:theRow - 1 andLowerRow:theRow atMouseOffset:theOffset],
|
||||
itemInfo = (parentItem !== nil) ? _outlineView._itemInfosForItems[[parentItem UID]] : _outlineView._rootItemInfo,
|
||||
var parentItem = [self _parentItemForUpperRow:theRow - 1 andLowerRow:theRow atMouseOffset:theOffset],
|
||||
itemInfo = (parentItem != nil) ? _itemInfosForItems[[parentItem UID]] : _rootItemInfo,
|
||||
children = itemInfo.children;
|
||||
|
||||
childIndex = [children indexOfObject:[_outlineView itemAtRow:theRow]];
|
||||
childIndex = [children indexOfObject:[self itemAtRow:theRow]];
|
||||
|
||||
if (childIndex === CPNotFound)
|
||||
childIndex = children.length;
|
||||
@@ -1993,155 +2077,151 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
return childIndex;
|
||||
}
|
||||
|
||||
- (void)_parentItemForDropOperation:(CPTableViewDropOperation)theDropOperation row:(CPInteger)theRow offset:(CGPoint)theOffset
|
||||
- (id)_parentItemForDropOperation:(CPTableViewDropOperation)theDropOperation row:(CPInteger)theRow offset:(CGPoint)theOffset
|
||||
{
|
||||
if (theDropOperation === CPTableViewDropAbove)
|
||||
return [_outlineView _parentItemForUpperRow:theRow - 1 andLowerRow:theRow atMouseOffset:theOffset]
|
||||
return [self _parentItemForUpperRow:theRow - 1 andLowerRow:theRow atMouseOffset:theOffset];
|
||||
|
||||
return [_outlineView itemAtRow:theRow];
|
||||
return [self itemAtRow:theRow];
|
||||
}
|
||||
|
||||
- (CPDragOperation)tableView:(CPTableView)aTableView validateDrop:(id /*< CPDraggingInfo >*/)theInfo
|
||||
proposedRow:(CPInteger)theRow proposedDropOperation:(CPTableViewDropOperation)theOperation
|
||||
{
|
||||
if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_validateDrop_proposedItem_proposedChildIndex_))
|
||||
if (!(_implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_validateDrop_proposedItem_proposedChildIndex_))
|
||||
return CPDragOperationNone;
|
||||
|
||||
// Make sure the retargeted item and index are reset
|
||||
_outlineView._retargetedItem = nil;
|
||||
_outlineView._shouldRetargetItem = NO;
|
||||
_retargetedItem = nil;
|
||||
_shouldRetargetItem = NO;
|
||||
|
||||
_outlineView._retargedChildIndex = nil;
|
||||
_outlineView._shouldRetargetChildIndex = NO;
|
||||
_retargedChildIndex = nil;
|
||||
_shouldRetargetChildIndex = NO;
|
||||
|
||||
var location = [_outlineView convertPoint:[theInfo draggingLocation] fromView:nil],
|
||||
var location = [self convertPoint:[theInfo draggingLocation] fromView:nil],
|
||||
parentItem = [self _parentItemForDropOperation:theOperation row:theRow offset:location],
|
||||
childIndex = [self _childIndexForDropOperation:theOperation row:theRow offset:location];
|
||||
|
||||
return [_outlineView._outlineViewDataSource outlineView:_outlineView validateDrop:theInfo proposedItem:parentItem proposedChildIndex:childIndex];
|
||||
return [_outlineViewDataSource outlineView:self validateDrop:theInfo proposedItem:parentItem proposedChildIndex:childIndex];
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView acceptDrop:(id /*<CPDraggingInfo>*/)theInfo row:(CPInteger)theRow dropOperation:(CPTableViewDropOperation)theOperation
|
||||
{
|
||||
if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_acceptDrop_item_childIndex_))
|
||||
if (!(_implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_acceptDrop_item_childIndex_))
|
||||
return NO;
|
||||
|
||||
var location = [_outlineView convertPoint:[theInfo draggingLocation] fromView:nil],
|
||||
var location = [self convertPoint:[theInfo draggingLocation] fromView:nil],
|
||||
parentItem = [self _parentItemForDropOperation:theOperation row:theRow offset:location],
|
||||
childIndex = [self _childIndexForDropOperation:theOperation row:theRow offset:location];
|
||||
|
||||
_outlineView._retargetedItem = nil;
|
||||
_outlineView._shouldRetargetItem = NO;
|
||||
_retargetedItem = nil;
|
||||
_shouldRetargetItem = NO;
|
||||
|
||||
_outlineView._retargedChildIndex = nil;
|
||||
_outlineView._shouldRetargetChildIndex = NO;
|
||||
_retargedChildIndex = nil;
|
||||
_shouldRetargetChildIndex = NO;
|
||||
|
||||
return [_outlineView._outlineViewDataSource outlineView:_outlineView acceptDrop:theInfo item:parentItem childIndex:childIndex];
|
||||
return [_outlineViewDataSource outlineView:self acceptDrop:theInfo item:parentItem childIndex:childIndex];
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView sortDescriptorsDidChange:(CPArray)oldSortDescriptors
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDataSourceMethods &
|
||||
if ((_implementedOutlineViewDataSourceMethods &
|
||||
CPOutlineViewDataSource_outlineView_sortDescriptorsDidChange_))
|
||||
{
|
||||
[[_outlineView dataSource] outlineView:_outlineView sortDescriptorsDidChange:oldSortDescriptors];
|
||||
[[self dataSource] outlineView:self sortDescriptorsDidChange:oldSortDescriptors];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
/*** CPTableViewDelegate methods ***/
|
||||
|
||||
@implementation _CPOutlineViewTableViewDelegate : CPObject
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (CPString)_sendDelegateToolTipForView:(id)aView rect:(CGRect)aRect tableColumn:(CPTableColumn)aTableColumn item:(id)anItem mouseLocation:(CGPoint)aPoint
|
||||
{
|
||||
CPOutlineView _outlineView;
|
||||
}
|
||||
if (!(_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_toolTipForView_rect_tableColumn_item_mouseLocation_))
|
||||
return nil;
|
||||
|
||||
- (id)initWithOutlineView:(CPOutlineView)anOutlineView
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
_outlineView = anOutlineView;
|
||||
|
||||
return self;
|
||||
return [_outlineViewDelegate outlineView:self toolTipForView:aView rect:aRect tableColumn:aTableColumn item:anItem mouseLocation:aPoint];
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)theTableView shouldSelectRow:(CPInteger)theRow
|
||||
{
|
||||
return SHOULD_SELECT_ITEM(_outlineView, [_outlineView itemAtRow:theRow]);
|
||||
return SHOULD_SELECT_ITEM(self, [self itemAtRow:theRow]);
|
||||
}
|
||||
|
||||
- (BOOL)selectionShouldChangeInTableView:(CPTableView)theTableView
|
||||
{
|
||||
return SELECTION_SHOULD_CHANGE(_outlineView);
|
||||
return SELECTION_SHOULD_CHANGE(self);
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView shouldEditTableColumn:(CPTableColumn)aColumn row:(CPInteger)aRow
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldEditTableColumn_item_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView shouldEditTableColumn:aColumn item:[_outlineView itemAtRow:aRow]];
|
||||
if ((_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldEditTableColumn_item_))
|
||||
return [_outlineViewDelegate outlineView:self shouldEditTableColumn:aColumn item:[self itemAtRow:aRow]];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (float)tableView:(CPTableView)theTableView heightOfRow:(CPInteger)theRow
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_heightOfRowByItem_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView heightOfRowByItem:[_outlineView itemAtRow:theRow]];
|
||||
if ((_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_heightOfRowByItem_))
|
||||
return [_outlineViewDelegate outlineView:self heightOfRowByItem:[self itemAtRow:theRow]];
|
||||
|
||||
return [theTableView rowHeight];
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView willDisplayView:(id)aView forTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRowIndex
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_))
|
||||
if ((_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_))
|
||||
{
|
||||
var item = [_outlineView itemAtRow:aRowIndex];
|
||||
[_outlineView._outlineViewDelegate outlineView:_outlineView willDisplayView:aView forTableColumn:aTableColumn item:item];
|
||||
var item = [self itemAtRow:aRowIndex];
|
||||
[_outlineViewDelegate outlineView:self willDisplayView:aView forTableColumn:aTableColumn item:item];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView willRemoveView:(id)aView forTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRowIndex
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_willRemoveView_forTableColumn_item_))
|
||||
if ((_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_willRemoveView_forTableColumn_item_))
|
||||
{
|
||||
var item = [_outlineView itemAtRow:aRowIndex];
|
||||
[_outlineView._outlineViewDelegate outlineView:_outlineView willRemoveView:aView forTableColumn:aTableColumn item:item];
|
||||
var item = [self itemAtRow:aRowIndex];
|
||||
[_outlineViewDelegate outlineView:self willRemoveView:aView forTableColumn:aTableColumn item:item];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView isGroupRow:(CPInteger)aRow
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_isGroupItem_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView isGroupItem:[_outlineView itemAtRow:aRow]];
|
||||
if ((_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_isGroupItem_))
|
||||
return [_outlineViewDelegate outlineView:self isGroupItem:[self itemAtRow:aRow]];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (CPMenu)tableView:(CPTableView)aTableView menuForTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_menuForTableColumn_item_))
|
||||
if ((_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_menuForTableColumn_item_))
|
||||
{
|
||||
var item = [_outlineView itemAtRow:aRow];
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView menuForTableColumn:aTableColumn item:item]
|
||||
var item = [self itemAtRow:aRow];
|
||||
return [_outlineViewDelegate outlineView:self menuForTableColumn:aTableColumn item:item]
|
||||
}
|
||||
|
||||
// We reimplement CPView menuForEvent: because we can't call it directly. CPTableView implements menuForEvent:
|
||||
// to call this delegate method.
|
||||
return [_outlineView menu] || [[_outlineView class] defaultMenu];
|
||||
return [self menu] || [[self class] defaultMenu];
|
||||
}
|
||||
|
||||
- (CPIndexSet)tableView:(CPTableView)aTableView selectionIndexesForProposedSelection:(CPIndexSet)anIndexSet
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_selectionIndexesForProposedSelection_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView selectionIndexesForProposedSelection:anIndexSet];
|
||||
if ((_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_selectionIndexesForProposedSelection_))
|
||||
return [_outlineViewDelegate outlineView:self selectionIndexesForProposedSelection:anIndexSet];
|
||||
|
||||
return anIndexSet;
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView shouldSelectTableColumn:(CPTableColumn)aTableColumn
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldSelectTableColumn_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView shouldSelectTableColumn:aTableColumn];
|
||||
if ((_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldSelectTableColumn_))
|
||||
return [_outlineViewDelegate outlineView:self shouldSelectTableColumn:aTableColumn];
|
||||
|
||||
return YES;
|
||||
}
|
||||
@@ -2247,8 +2327,8 @@ var CPOutlineViewIndentationPerLevelKey = @"CPOutlineViewIndentationPerLevelKey"
|
||||
_outlineViewDataSource = [aCoder decodeObjectForKey:CPOutlineViewDataSourceKey];
|
||||
_outlineViewDelegate = [aCoder decodeObjectForKey:CPOutlineViewDelegateKey];
|
||||
|
||||
[super setDataSource:[[_CPOutlineViewTableViewDataSource alloc] initWithOutlineView:self]];
|
||||
[super setDelegate:[[_CPOutlineViewTableViewDelegate alloc] initWithOutlineView:self]];
|
||||
[super setDataSource:self];
|
||||
[super setDelegate:self];
|
||||
|
||||
[self _updateIsViewBased];
|
||||
}
|
||||
@@ -2287,3 +2367,244 @@ var colorForDisclosureTriangle = function(isSelected, isHighlighted)
|
||||
? [CPColor colorWithCalibratedWhite:0.4 alpha: 1.0]
|
||||
: [CPColor colorWithCalibratedWhite:0.5 alpha: 1.0]);
|
||||
};
|
||||
|
||||
@implementation CPOutlineView (CPBindings)
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self !== [CPOutlineView class])
|
||||
return;
|
||||
|
||||
[self exposeBinding:@"content"];
|
||||
[self exposeBinding:@"selectionIndexPaths"];
|
||||
[self exposeBinding:@"sortDescriptors"];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the currently selected index paths.
|
||||
This allows the outline view to be KVC-compliant for `selectionIndexPaths`.
|
||||
*/
|
||||
- (CPArray)selectionIndexPaths
|
||||
{
|
||||
var indexes = [self selectedRowIndexes],
|
||||
paths = [CPMutableArray array],
|
||||
index = [indexes firstIndex];
|
||||
|
||||
while (index !== CPNotFound)
|
||||
{
|
||||
var item = [self itemAtRow:index];
|
||||
|
||||
// Check if the item is a CPTreeNode proxy (which it will be when bound to CPTreeController)
|
||||
if ([item respondsToSelector:@selector(indexPath)])
|
||||
[paths addObject:[item indexPath]];
|
||||
|
||||
index = [indexes indexGreaterThanIndex:index];
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPOutlineView (CPBinder)
|
||||
|
||||
- (id)content { return nil; }
|
||||
- (void)setContent:(id)aContent { }
|
||||
- (void)setSelectionIndexPaths:(CPArray)paths { }
|
||||
|
||||
+ (Class)_binderClassForBinding:(CPString)aBinding
|
||||
{
|
||||
if (aBinding === @"content")
|
||||
return [_CPOutlineViewContentBinder class];
|
||||
|
||||
if (aBinding === @"selectionIndexPaths")
|
||||
return [_CPOutlineViewSelectionIndexPathsBinder class];
|
||||
|
||||
return [super _binderClassForBinding:aBinding];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
// --- Content Binder ---
|
||||
|
||||
/*!
|
||||
_CPOutlineViewContentBinder acts as the CPOutlineViewDataSource when the outline view
|
||||
is bound to a CPTreeController's arrangedObjects.
|
||||
*/
|
||||
@implementation _CPOutlineViewContentBinder : CPBinder
|
||||
{
|
||||
CPTreeNode _rootNode;
|
||||
}
|
||||
|
||||
- (void)setValueFor:(CPString)aBinding
|
||||
{
|
||||
var destination = [_info objectForKey:CPObservedObjectKey],
|
||||
keyPath = [_info objectForKey:CPObservedKeyPathKey],
|
||||
value = [destination valueForKeyPath:keyPath];
|
||||
|
||||
if (!value || ![value isKindOfClass:[CPTreeNode class]])
|
||||
_rootNode = [[CPTreeNode alloc] initWithRepresentedObject:nil];
|
||||
else
|
||||
_rootNode = value;
|
||||
|
||||
if ([_source dataSource] !== self)
|
||||
[_source setDataSource:self];
|
||||
else
|
||||
[_source reloadData];
|
||||
}
|
||||
|
||||
- (CPTreeNode)rootNode
|
||||
{
|
||||
return _rootNode;
|
||||
}
|
||||
|
||||
// -- CPOutlineViewDataSource implementation --
|
||||
|
||||
- (id)outlineView:(CPOutlineView)outlineView child:(CPInteger)index ofItem:(id)item
|
||||
{
|
||||
var node = item || _rootNode;
|
||||
return [[node childNodes] objectAtIndex:index];
|
||||
}
|
||||
|
||||
- (BOOL)outlineView:(CPOutlineView)outlineView isItemExpandable:(id)item
|
||||
{
|
||||
var node = item || _rootNode;
|
||||
return ![node isLeaf];
|
||||
}
|
||||
|
||||
- (int)outlineView:(CPOutlineView)outlineView numberOfChildrenOfItem:(id)item
|
||||
{
|
||||
var node = item || _rootNode;
|
||||
return [[node childNodes] count];
|
||||
}
|
||||
|
||||
- (id)outlineView:(CPOutlineView)outlineView objectValueForTableColumn:(CPTableColumn)tableColumn byItem:(id)item
|
||||
{
|
||||
var rep = [item respondsToSelector:@selector(representedObject)] ? [item representedObject] : item;
|
||||
|
||||
// Dynamically fetch the value using the column's identifier (e.g., "name")
|
||||
if (rep && [tableColumn identifier] && [tableColumn identifier] !== @"")
|
||||
return [rep valueForKey:[tableColumn identifier]];
|
||||
|
||||
return rep;
|
||||
}
|
||||
|
||||
- (void)outlineView:(CPOutlineView)outlineView setObjectValue:(id)value forTableColumn:(CPTableColumn)tableColumn byItem:(id)item
|
||||
{
|
||||
var rep = [item respondsToSelector:@selector(representedObject)] ?[item representedObject] : item;
|
||||
|
||||
// Push the inline edit back to the model using the column's identifier
|
||||
if (rep && [tableColumn identifier] && [tableColumn identifier] !== @"")
|
||||
[rep setValue:value forKey:[tableColumn identifier]];
|
||||
}
|
||||
|
||||
- (id)content
|
||||
{
|
||||
// CPTableView internals probe the binder for its flat content to draw rows.
|
||||
if (_source && _source._itemsForRows)
|
||||
return _source._itemsForRows;
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// --- Selection Index Paths Binder ---
|
||||
|
||||
/*!
|
||||
_CPOutlineViewSelectionIndexPathsBinder listens for selection changes on the CPOutlineView
|
||||
and translates the selected rows into CPIndexPaths to push to the CPTreeController.
|
||||
It also intercepts changes from the CPTreeController and auto-expands the tree to highlight them.
|
||||
*/
|
||||
@implementation _CPOutlineViewSelectionIndexPathsBinder : CPBinder
|
||||
{
|
||||
BOOL _isSyncingFromModel;
|
||||
}
|
||||
|
||||
- (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];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(outlineViewSelectionDidChange:)
|
||||
name:CPOutlineViewSelectionDidChangeNotification
|
||||
object:aSource];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (void)unbind:(CPString)aBinding forObject:(id)anObject
|
||||
{
|
||||
if (aBinding === "selectionIndexPaths")
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
removeObserver:self
|
||||
name:CPOutlineViewSelectionDidChangeNotification
|
||||
object:anObject];
|
||||
|
||||
[super unbind:aBinding forObject:anObject];
|
||||
}
|
||||
|
||||
- (void)setValueFor:(CPString)aBinding
|
||||
{
|
||||
// 1. SUPPRESS KVO AT THE VERY TOP to avoid circular updates when expanding parents
|
||||
_isSyncingFromModel = YES;
|
||||
|
||||
var destination = [_info objectForKey:CPObservedObjectKey],
|
||||
keyPath = [_info objectForKey:CPObservedKeyPathKey],
|
||||
indexPaths = [destination valueForKeyPath:keyPath] || [],
|
||||
indexes = [CPMutableIndexSet indexSet];
|
||||
|
||||
// 2. Fetch the root node directly from the CPTreeController (destination)
|
||||
var rootNode = [destination respondsToSelector:@selector(arrangedObjects)] ? [destination arrangedObjects] : nil;
|
||||
|
||||
if (rootNode)
|
||||
{
|
||||
for (var i = 0, count = [indexPaths count]; i < count; i++)
|
||||
{
|
||||
var item = [rootNode descendantNodeAtIndexPath:[indexPaths objectAtIndex:i]];
|
||||
|
||||
if (item)
|
||||
{
|
||||
var parentsToExpand = [CPMutableArray array],
|
||||
parent = [item parentNode];
|
||||
|
||||
while (parent && parent !== rootNode)
|
||||
{
|
||||
[parentsToExpand insertObject:parent atIndex:0];
|
||||
parent = [parent parentNode];
|
||||
}
|
||||
|
||||
for (var j = 0; j < [parentsToExpand count]; j++)
|
||||
[_source expandItem:parentsToExpand[j]];
|
||||
|
||||
var row = [_source rowForItem:item];
|
||||
|
||||
if (row !== CPNotFound && row >= 0)
|
||||
[indexes addIndex:row];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust the CPOutlineView selection
|
||||
[_source selectRowIndexes:indexes byExtendingSelection:NO];
|
||||
|
||||
// 3. Re-enable KVO after adjustments are done
|
||||
_isSyncingFromModel = NO;
|
||||
}
|
||||
|
||||
- (void)outlineViewSelectionDidChange:(CPNotification)note
|
||||
{
|
||||
// We only want to push the change back if we aren't currently syncing down from the model
|
||||
if (_isSyncingFromModel)
|
||||
return;
|
||||
|
||||
// In CPBinder, reverseSetValueFor: takes the name of the property on _source
|
||||
// it should fetch the updated value from. Since CPOutlineView has the selectionIndexPaths method:
|
||||
[self reverseSetValueFor:@"selectionIndexPaths"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+5
-4
@@ -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;
|
||||
@@ -120,8 +121,8 @@ CPDocModalWindowMask = 1 << 6;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Overrides
|
||||
// MARK: -
|
||||
// MARK: Overrides
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
|
||||
+4
-69
@@ -44,6 +44,9 @@ CPStringPboardType = @"CPStringPboardType";
|
||||
CPURLPboardType = @"CPURLPboardType";
|
||||
CPImagesPboardType = @"CPImagesPboardType";
|
||||
CPVideosPboardType = @"CPVideosPboardType";
|
||||
CPRTFPboardType = @"CPRTFPboardType";
|
||||
_CPSmartPboardType = @"_CPSmartPboardType";
|
||||
_CPASPboardType = @"_CPASPboardType";
|
||||
|
||||
UTF8PboardType = @"public.utf8-plain-text";
|
||||
|
||||
@@ -51,8 +54,7 @@ UTF8PboardType = @"public.utf8-plain-text";
|
||||
CPImagePboardType = @"CPImagePboardType";
|
||||
|
||||
|
||||
var CPPasteboards = nil,
|
||||
supportsNativePasteboard = NO;
|
||||
var CPPasteboards = nil;
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@@ -68,8 +70,6 @@ var CPPasteboards = nil,
|
||||
|
||||
unsigned _changeCount;
|
||||
CPString _stateUID;
|
||||
|
||||
CPWebScriptObject _nativePasteboard;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -83,9 +83,6 @@ var CPPasteboards = nil,
|
||||
[self setVersion:1.0];
|
||||
|
||||
CPPasteboards = @{};
|
||||
|
||||
if (typeof window.cpPasteboardWithName !== "undefined")
|
||||
supportsNativePasteboard = YES;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -128,12 +125,6 @@ var CPPasteboards = nil,
|
||||
_provided = @{};
|
||||
|
||||
_changeCount = 0;
|
||||
|
||||
if (supportsNativePasteboard)
|
||||
{
|
||||
_nativePasteboard = window.cpPasteboardWithName(aName);
|
||||
[self _synchronizePasteboard];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -163,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;
|
||||
}
|
||||
|
||||
@@ -182,12 +164,6 @@ 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];
|
||||
|
||||
@@ -201,16 +177,6 @@ var CPPasteboards = nil,
|
||||
[_owners setObject:anOwner forKey:_types[count]];
|
||||
}
|
||||
|
||||
if (_nativePasteboard && shouldUpdate)
|
||||
{
|
||||
var nativeTypes = [types copy];
|
||||
if ([types containsObject:CPStringPboardType])
|
||||
nativeTypes.push(UTF8PboardType);
|
||||
|
||||
_nativePasteboard.declareTypes_(nativeTypes);
|
||||
_changeCount = _nativePasteboard.changeCount();
|
||||
}
|
||||
|
||||
return ++_changeCount;
|
||||
}
|
||||
|
||||
@@ -273,7 +239,6 @@ var CPPasteboards = nil,
|
||||
*/
|
||||
- (CPArray)types
|
||||
{
|
||||
[self _synchronizePasteboard];
|
||||
return _types;
|
||||
}
|
||||
|
||||
@@ -312,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
|
||||
|
||||
+48
-16
@@ -45,6 +45,13 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
||||
return "popup-button";
|
||||
}
|
||||
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"menu-offset": CGSizeMake(0, 0)
|
||||
};
|
||||
}
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingSelectedIndex
|
||||
{
|
||||
return [CPSet setWithObject:@"objectValue"];
|
||||
@@ -361,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];
|
||||
}];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -496,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];
|
||||
@@ -682,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;
|
||||
|
||||
@@ -852,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])
|
||||
{
|
||||
@@ -863,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
|
||||
|
||||
+10
-10
@@ -84,8 +84,8 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Initialization
|
||||
// MARK: -
|
||||
// MARK: Initialization
|
||||
|
||||
/*!
|
||||
Initialize the CPPopover witn default values
|
||||
@@ -105,8 +105,8 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Getters / Setters
|
||||
// MARK: -
|
||||
// MARK: Getters / Setters
|
||||
|
||||
/*!
|
||||
Returns the current rect of the popover
|
||||
@@ -220,8 +220,8 @@ Set the behavior of the CPPopover. It can be:
|
||||
_implementedDelegateMethods |= CPPopoverDelegate_popover_didClose_;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Positioning
|
||||
// MARK: -
|
||||
// MARK: Positioning
|
||||
|
||||
/*!
|
||||
Show the popover
|
||||
@@ -298,8 +298,8 @@ Set the behavior of the CPPopover. It can be:
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Action
|
||||
// MARK: -
|
||||
// MARK: Action
|
||||
|
||||
/*!
|
||||
Close the popover
|
||||
@@ -318,8 +318,8 @@ Set the behavior of the CPPopover. It can be:
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegates
|
||||
// MARK: -
|
||||
// MARK: Delegates
|
||||
|
||||
/*! @ignore */
|
||||
- (BOOL)_popoverWindowShouldClose
|
||||
|
||||
@@ -86,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]
|
||||
};
|
||||
}
|
||||
|
||||
@@ -368,6 +371,7 @@ var CPProgressIndicatorSpinningStyleColors = [];
|
||||
- (void)drawBar
|
||||
{
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (CPView)createEphemeralSubviewNamed:(CPString)aName
|
||||
@@ -413,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
|
||||
@@ -438,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
|
||||
|
||||
|
||||
|
||||
+113
-17
@@ -29,6 +29,7 @@
|
||||
|
||||
@global CPApp
|
||||
|
||||
CPRadioImageOffset = 4.0;
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@@ -66,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;
|
||||
@@ -162,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];
|
||||
}
|
||||
|
||||
// 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";
|
||||
@@ -185,21 +260,37 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
|
||||
[aCoder encodeObject:_radioGroup forKey:CPRadioRadioGroupKey];
|
||||
}
|
||||
|
||||
- (CPImage)image
|
||||
// MARK: -
|
||||
// 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
|
||||
@@ -269,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)
|
||||
{
|
||||
@@ -306,6 +397,11 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
|
||||
return _radios;
|
||||
}
|
||||
|
||||
- (int)size
|
||||
{
|
||||
return [_radios count];
|
||||
}
|
||||
|
||||
- (void)setEnabled:(BOOL)enabled
|
||||
{
|
||||
[_radios makeObjectsPerformSelector:@selector(setEnabled:) withObject:enabled];
|
||||
@@ -316,7 +412,7 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
|
||||
[_radios makeObjectsPerformSelector:@selector(setHidden:) withObject:hidden];
|
||||
}
|
||||
|
||||
#pragma mark Private
|
||||
// MARK: Private
|
||||
|
||||
- (void)_addRadio:(CPRadio)aRadio
|
||||
{
|
||||
|
||||
+14
-1
@@ -24,6 +24,7 @@
|
||||
@import <Foundation/CPObjJRuntime.j>
|
||||
|
||||
@import "CPEvent.j"
|
||||
@import "CPCursor.j"
|
||||
|
||||
@class CPKeyBinding
|
||||
@class CPMenu
|
||||
@@ -200,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
|
||||
@@ -384,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];
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
SEL _predicateAction @accessors(property=action);
|
||||
}
|
||||
|
||||
#pragma mark public methods
|
||||
// MARK: public methods
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPPredicateEditor
|
||||
@@ -251,7 +251,7 @@
|
||||
return tree;
|
||||
}
|
||||
|
||||
#pragma mark Set the Predicate
|
||||
// MARK: Set the Predicate
|
||||
|
||||
- (void)setObjectValue:(id)objectValue
|
||||
{
|
||||
@@ -269,6 +269,8 @@
|
||||
_currentAnimation = nil;
|
||||
_sendAction = NO;
|
||||
|
||||
var rows = [];
|
||||
|
||||
if (predicate != nil)
|
||||
{
|
||||
if ((_nestingMode == CPRuleEditorNestingModeSimple || _nestingMode == CPRuleEditorNestingModeCompound)
|
||||
@@ -276,10 +278,13 @@
|
||||
predicate = [[CPCompoundPredicate alloc] initWithType:[self _compoundPredicateTypeForRootRows] subpredicates:[CPArray arrayWithObject:predicate]];
|
||||
|
||||
var row = [self _rowObjectFromPredicate:predicate];
|
||||
|
||||
if (row != nil)
|
||||
[_boundArrayOwner setValue:[CPArray arrayWithObject:row] forKey:_boundArrayKeyPath];
|
||||
[rows addObject:row];
|
||||
}
|
||||
|
||||
[_boundArrayOwner setValue:rows forKey:_boundArrayKeyPath];
|
||||
|
||||
[self setAnimation:animation];
|
||||
}
|
||||
|
||||
@@ -369,7 +374,7 @@
|
||||
return row;
|
||||
}
|
||||
|
||||
#pragma mark Get the predicate
|
||||
// MARK: Get the predicate
|
||||
|
||||
- (void)_updatePredicate
|
||||
{
|
||||
@@ -447,7 +452,7 @@
|
||||
return CPAndPredicateType;
|
||||
}
|
||||
|
||||
#pragma mark Control delegate
|
||||
// MARK: Control delegate
|
||||
|
||||
- (void)_sendRuleAction
|
||||
{
|
||||
@@ -482,7 +487,7 @@
|
||||
}
|
||||
*/
|
||||
|
||||
#pragma mark RuleEditor delegate methods
|
||||
// MARK: RuleEditor delegate methods
|
||||
|
||||
- (int)_queryNumberOfChildrenOfItem:(id)rowItem withRowType:(CPRuleEditorRowType)type
|
||||
{
|
||||
|
||||
@@ -471,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];
|
||||
|
||||
@@ -487,9 +489,9 @@ CPTransformableAttributeType = 1800;
|
||||
|
||||
- (id)copy
|
||||
{
|
||||
var views = [CPArray array];
|
||||
var views = [CPArray array],
|
||||
copy = [[[self class] alloc] init];
|
||||
|
||||
var copy = [[[self class] alloc] init];
|
||||
[copy _setTemplateType:_templateType];
|
||||
[copy _setOptions:_predicateOptions];
|
||||
[copy _setModifier:_predicateModifier];
|
||||
|
||||
@@ -80,6 +80,35 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
@n An ordered to-many relation containing the display values for the row.
|
||||
@n@n @c @@"criteria"
|
||||
@n An ordered to-many relation containing the criteria for the row.
|
||||
@n@n
|
||||
Localization & Positional Reordering
|
||||
@n
|
||||
CPRuleEditor supports complete localization of menu items and grammatical positional reordering (sentence structure layout adjustment) via strings resource files (.strings) or custom programmatic CPDictionary tables.
|
||||
@n@n
|
||||
Since sentence structures vary significantly across languages, the editor can dynamically reposition views (such as popups, static labels, and text fields) from left to right to form grammatically correct sentences.
|
||||
@n@n
|
||||
Formatting Keys (English representation):
|
||||
@n @c %[%]@@
|
||||
@n Represents a popup button displaying its selected value (e.g. @c %[firstName]@@).
|
||||
@n @c %@@
|
||||
@n Represents an editable text input field.
|
||||
@n Static text represents a literal label placed directly inside the formatting key.
|
||||
@n@n
|
||||
Example English format key:
|
||||
@n @c "%[firstName]@ %[is equal to]@ %@"
|
||||
@n@n
|
||||
Translation Patterns (Target language):
|
||||
@n Positional specifiers such as @c %1$@@, @c %2$@@, @c %3$@@ dictate the visual order of views from left to right.
|
||||
@n Bracketed values inside positional specifiers (e.g. @c %1$[Nombre]@@) define the localized title for popup selection items.
|
||||
@n Literal text outside the specifiers (such as @c "y" or @c "und") is automatically instantiated as static text labels positioned between controls.
|
||||
@n@n
|
||||
Example translations:
|
||||
@n@n
|
||||
Spanish (Reorders to: [1: Name] y [3: Value] [2: are equal]):
|
||||
@n @c "%[firstName]@ %[is equal to]@ %@" = "%1$[Nombre]@ y %3$@ %2$[son iguales]@";
|
||||
@n@n
|
||||
German (Reorders to: [1: First Name] und [3: Value] [2: are equal]):
|
||||
@n @c "%[firstName]@ %[is equal to]@ %@" = "%1$[Vorname]@ und %3$@ %2$[sind gleich]@";
|
||||
*/
|
||||
|
||||
@implementation CPRuleEditor : CPControl
|
||||
@@ -127,7 +156,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
BOOL _isKeyDown;
|
||||
BOOL _nestingModeDidChange;
|
||||
|
||||
_CPRuleEditorLocalizer _standardLocalizer @accessors(property=standardLocalizer);
|
||||
_CPRuleEditorLocalizer _standardLocalizer;
|
||||
CPDictionary _itemsAndValuesToAddForRowType;
|
||||
}
|
||||
|
||||
@@ -146,7 +175,7 @@ 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],
|
||||
@@ -157,7 +186,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self !== nil)
|
||||
if (self)
|
||||
{
|
||||
_slices = [[CPMutableArray alloc] init];
|
||||
|
||||
@@ -207,8 +236,34 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
|
||||
[self registerForDraggedTypes:[CPArray arrayWithObjects:CPRuleEditorItemPBoardType,nil]];
|
||||
[_boundArrayOwner addObserver:self forKeyPath:_boundArrayKeyPath options:CPKeyValueObservingOptionOld | CPKeyValueObservingOptionNew context:boundArrayContext];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(_ruleEditorLocalizerDidLoad:)
|
||||
name:@"_CPRuleEditorLocalizerDidLoadNotification"
|
||||
object:nil];
|
||||
}
|
||||
|
||||
|
||||
- (void)_ruleEditorLocalizerDidLoad:(CPNotification)aNotification
|
||||
{
|
||||
if ([aNotification object] === [self standardLocalizer])
|
||||
{
|
||||
// Defer execution to the next run loop cycle so that any active slice
|
||||
// insertions have fully completed and are present in the `_slices` array.
|
||||
[[CPRunLoop mainRunLoop] performBlock:function() {
|
||||
var count = [_slices count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var slice = [_slices objectAtIndex:i];
|
||||
[slice _reconfigureSubviews];
|
||||
[slice _updateButtonVisibilities]; // Force updates on row button tooltips
|
||||
}
|
||||
|
||||
[self _updatePredicate];
|
||||
[self _sendRuleAction];
|
||||
} argument:nil order:0 modes:[CPDefaultRunLoopMode]];
|
||||
}
|
||||
}
|
||||
/*! @endcond */
|
||||
|
||||
/*!
|
||||
@@ -384,7 +439,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
*/
|
||||
- (CPDictionary)formattingDictionary
|
||||
{
|
||||
return [_standardLocalizer dictionary];
|
||||
return [[self standardLocalizer] dictionary];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -396,6 +451,9 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
*/
|
||||
- (void)setFormattingDictionary:(CPDictionary)dictionary
|
||||
{
|
||||
if (_standardLocalizer == nil)
|
||||
_standardLocalizer = [_CPRuleEditorLocalizer new];
|
||||
|
||||
[_standardLocalizer setDictionary:dictionary];
|
||||
_stringsFilename = nil;
|
||||
}
|
||||
@@ -419,7 +477,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
*/
|
||||
- (void)setFormattingStringsFilename:(CPString)stringsFilename
|
||||
{
|
||||
if (_standardLocalizer === nil)
|
||||
if (_standardLocalizer == nil)
|
||||
_standardLocalizer = [_CPRuleEditorLocalizer new];
|
||||
|
||||
if (_stringsFilename !== stringsFilename)
|
||||
@@ -427,19 +485,32 @@ 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]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (_CPRuleEditorLocalizer)standardLocalizer
|
||||
{
|
||||
if (_standardLocalizer == nil)
|
||||
_standardLocalizer = [_CPRuleEditorLocalizer new];
|
||||
|
||||
return _standardLocalizer;
|
||||
}
|
||||
|
||||
- (void)setStandardLocalizer:(_CPRuleEditorLocalizer)aLocalizer
|
||||
{
|
||||
_standardLocalizer = aLocalizer;
|
||||
}
|
||||
|
||||
/*!
|
||||
@name Providing Data
|
||||
*/
|
||||
@@ -465,7 +536,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])
|
||||
@@ -538,7 +609,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
if ([self rowTypeForRow:current_index] === CPRuleEditorRowTypeCompound)
|
||||
{
|
||||
var candidate = [[self _rowCacheForIndex:current_index] rowObject],
|
||||
subObjects = [[self _subrowObjectsOfObject:candidate] _representedObject];
|
||||
subObjects = [self _subrowObjectsOfObject:candidate]; // Standard direct array query
|
||||
|
||||
if ([subObjects indexOfObjectIdenticalTo:targetObject] !== CPNotFound)
|
||||
return current_index;
|
||||
@@ -605,7 +676,7 @@ TODO: implement
|
||||
for (var i = rowIndex + 1; i < count; i++)
|
||||
{
|
||||
var candidate = [[self _rowCacheForIndex:i] rowObject],
|
||||
indexInSubrows = [[subobjects _representedObject] indexOfObjectIdenticalTo:candidate];
|
||||
indexInSubrows = [subobjects indexOfObjectIdenticalTo:candidate]; // Standard direct array query
|
||||
|
||||
if (indexInSubrows !== CPNotFound)
|
||||
{
|
||||
@@ -774,7 +845,7 @@ TODO: implement
|
||||
while (current_index !== CPNotFound)
|
||||
{
|
||||
var rowObject = [[self _rowCacheForIndex:current_index] rowObject],
|
||||
relativeChildIndex = [[subrows _representedObject] indexOfObjectIdenticalTo:rowObject];
|
||||
relativeChildIndex = [subrows indexOfObjectIdenticalTo:rowObject]; // Standard direct array query
|
||||
|
||||
if (relativeChildIndex !== CPNotFound)
|
||||
[childsIndexes addIndex:relativeChildIndex];
|
||||
@@ -831,7 +902,6 @@ TODO: implement
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
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 = [self _sendDelegateRuleEditorPredicatePartsForCriterion:item withDisplayValue:displayValue inRow:aRow];
|
||||
|
||||
@@ -849,10 +919,11 @@ TODO: implement
|
||||
return nil;
|
||||
|
||||
var current_index = [subrowsIndexes firstIndex];
|
||||
|
||||
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];
|
||||
@@ -888,33 +959,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
|
||||
@@ -1167,7 +1238,7 @@ TODO: implement
|
||||
|
||||
- (BOOL)_wantsRowAnimations
|
||||
{
|
||||
return (_currentAnimation !== nil);
|
||||
return (_currentAnimation != nil);
|
||||
}
|
||||
|
||||
- (void)_updateButtonVisibilities
|
||||
@@ -1233,7 +1304,7 @@ TODO: implement
|
||||
return shouldHide;
|
||||
}
|
||||
|
||||
#pragma mark Rows management
|
||||
// MARK: Rows management
|
||||
|
||||
- (id)_rowCacheForIndex:(int)index
|
||||
{
|
||||
@@ -1278,23 +1349,28 @@ TODO: implement
|
||||
|
||||
while (current_index !== CPNotFound)
|
||||
{
|
||||
var parentIndex = [self parentRowForRow:current_index],
|
||||
subrowsIndexes = [self subrowIndexesForRow:parentIndex];
|
||||
|
||||
if ([subrowsIndexes count] === 1)
|
||||
var parentIndex = [self parentRowForRow:current_index];
|
||||
|
||||
// If the row has a valid parent in the editor (i.e. not a root row)
|
||||
if (parentIndex !== -1)
|
||||
{
|
||||
if (parentIndex !== -1)
|
||||
return [CPIndexSet indexSetWithIndex:0];
|
||||
var subrowsIndexes = [self subrowIndexesForRow:parentIndex];
|
||||
|
||||
var childlessGranPa = [self _childlessParentsIfSlicesWereDeletedAtIndexes:[CPIndexSet indexSetWithIndex:parentIndex]];
|
||||
[childlessParents addIndexes:childlessGranPa];
|
||||
// If deleting this row leaves the parent with no remaining child rows
|
||||
if ([subrowsIndexes count] === 1)
|
||||
{
|
||||
[childlessParents addIndex:parentIndex];
|
||||
|
||||
// Recursively check if deleting this parent row leaves the grandparent childless
|
||||
var childlessGranPa = [self _childlessParentsIfSlicesWereDeletedAtIndexes:[CPIndexSet indexSetWithIndex:parentIndex]];
|
||||
[childlessParents addIndexes:childlessGranPa];
|
||||
}
|
||||
}
|
||||
|
||||
current_index = [indexes indexGreaterThanIndex:current_index];
|
||||
}
|
||||
|
||||
return childlessParents;
|
||||
// (id)-[RuleEditor _includeSubslicesForSlicesAtIndexes:]
|
||||
}
|
||||
|
||||
- (CPIndexSet)_includeSubslicesForSlicesAtIndexes:(CPIndexSet)indexes
|
||||
@@ -1356,8 +1432,25 @@ TODO: implement
|
||||
|
||||
if ([self rowTypeForRow:row] === type && itemIndex < [aCriteria count])
|
||||
{
|
||||
var crit = [aCriteria objectAtIndex:itemIndex];
|
||||
[current_criterions addObject:crit];
|
||||
// Verify that this row's parent path matches the path currently being built
|
||||
var pathMatches = true;
|
||||
for (var p = 0; p < itemIndex; p++)
|
||||
{
|
||||
var criterionA = [aCriteria objectAtIndex:p],
|
||||
criterionB = [items objectAtIndex:p];
|
||||
|
||||
if (criterionA !== criterionB && (typeof criterionA.isEqual !== "function" || ![criterionA isEqual:criterionB]))
|
||||
{
|
||||
pathMatches = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pathMatches)
|
||||
{
|
||||
var crit = [aCriteria objectAtIndex:itemIndex];
|
||||
[current_criterions addObject:crit];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1473,7 +1566,7 @@ TODO: implement
|
||||
return row;
|
||||
}
|
||||
|
||||
#pragma mark Key value observing
|
||||
// MARK: Key value observing
|
||||
|
||||
- (void)_startObservingRowObjectsRecursively:(CPArray)rowObjects
|
||||
{
|
||||
@@ -1753,7 +1846,7 @@ TODO: implement
|
||||
{
|
||||
var subpredicate = [self predicateForRow:current_index];
|
||||
|
||||
if (subpredicate !== nil)
|
||||
if (subpredicate != nil)
|
||||
[subpredicates addObject:subpredicate];
|
||||
|
||||
current_index = [subindexes indexGreaterThanIndex:current_index];
|
||||
@@ -1774,7 +1867,12 @@ TODO: implement
|
||||
|
||||
- (_CPRuleEditorViewSliceRow)_createNewSliceWithFrame:(CGRect)frame ruleEditorView:(CPRuleEditor)editor
|
||||
{
|
||||
return [[_CPRuleEditorViewSliceRow alloc] initWithFrame:frame ruleEditorView:editor];
|
||||
var slice = [[_CPRuleEditorViewSliceRow alloc] initWithFrame:frame ruleEditorView:editor];
|
||||
|
||||
// Ensure the slice resizes with the editor
|
||||
[slice setAutoresizingMask:CPViewWidthSizable];
|
||||
|
||||
return slice;
|
||||
}
|
||||
|
||||
- (void)_reconfigureSubviewsAnimate:(BOOL)animate
|
||||
@@ -1795,7 +1893,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];
|
||||
@@ -1919,17 +2017,17 @@ TODO: implement
|
||||
|
||||
- (CPString)_toolTipForAddCompoundRowButton
|
||||
{
|
||||
return [_standardLocalizer localizedStringForString:@"Add compound row"];
|
||||
return [[self standardLocalizer] localizedStringForString:@"Add compound row"];
|
||||
}
|
||||
|
||||
- (CPString)_toolTipForAddSimpleRowButton
|
||||
{
|
||||
return [_standardLocalizer localizedStringForString:@"Add row"];
|
||||
return [[self standardLocalizer] localizedStringForString:@"Add row"];
|
||||
}
|
||||
|
||||
- (CPString)_toolTipForDeleteRowButton
|
||||
{
|
||||
return [_standardLocalizer localizedStringForString:@"Delete row"];
|
||||
return [[self standardLocalizer] localizedStringForString:@"Delete row"];
|
||||
}
|
||||
|
||||
- (void)_updateSliceIndentations
|
||||
@@ -2121,7 +2219,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];
|
||||
@@ -2129,7 +2227,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
|
||||
@@ -2244,33 +2342,41 @@ TODO: implement
|
||||
|
||||
- (BOOL)performDragOperation:(id /*< CPDraggingInfo >*/)info
|
||||
{
|
||||
var aboveInsertIndexCount = 0,
|
||||
object,
|
||||
removeIndex;
|
||||
var object;
|
||||
|
||||
var rowObjects = [_rowCache valueForKey:@"rowObject"],
|
||||
index = [_draggingRows lastIndex];
|
||||
|
||||
var parentRowIndex = [self parentRowForRow:index], // first index of draggingrows
|
||||
var firstDraggingIndex = [_draggingRows firstIndex],
|
||||
parentRowIndex = [self parentRowForRow:firstDraggingIndex],
|
||||
parentRowObject = (parentRowIndex === -1) ? _boundArrayOwner : [[self _rowCacheForIndex:parentRowIndex] rowObject],
|
||||
insertIndex = _subviewIndexOfDropLine;
|
||||
|
||||
while (index !== CPNotFound)
|
||||
{
|
||||
if (index >= insertIndex)
|
||||
// Identify if this row's parent is also inside the dragging set.
|
||||
// If it is, we skip it because it will move automatically with its parent.
|
||||
var parentOfCurrent = [self parentRowForRow:index];
|
||||
if (parentOfCurrent !== -1 && [_draggingRows containsIndex:parentOfCurrent])
|
||||
{
|
||||
removeIndex = index + aboveInsertIndexCount;
|
||||
aboveInsertIndexCount += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
removeIndex = index;
|
||||
insertIndex -= 1;
|
||||
index = [_draggingRows indexLessThanIndex:index];
|
||||
continue;
|
||||
}
|
||||
|
||||
object = [rowObjects objectAtIndex:removeIndex];
|
||||
[self removeRowAtIndex:removeIndex];
|
||||
[[self _subrowObjectsOfObject:parentRowObject] insertObject:object atIndex:insertIndex - parentRowIndex - 1];
|
||||
object = [rowObjects objectAtIndex:index];
|
||||
|
||||
// Find the current live index of the object inside the editor
|
||||
var cache = [self _searchCacheForRowObject:object];
|
||||
var liveIndex = [_rowCache indexOfObjectIdenticalTo:cache];
|
||||
|
||||
if (liveIndex !== CPNotFound)
|
||||
{
|
||||
if (liveIndex < insertIndex)
|
||||
insertIndex -= 1;
|
||||
|
||||
[self removeRowAtIndex:liveIndex];
|
||||
[[self _subrowObjectsOfObject:parentRowObject] insertObject:object atIndex:insertIndex - parentRowIndex - 1];
|
||||
}
|
||||
|
||||
index = [_draggingRows indexLessThanIndex:index];
|
||||
}
|
||||
@@ -2280,6 +2386,7 @@ TODO: implement
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (CPIndexSet)_draggingTypes
|
||||
{
|
||||
return [CPIndexSet indexSetWithIndex:CPDragOperationMove];
|
||||
@@ -2321,7 +2428,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];
|
||||
}
|
||||
|
||||
@@ -2386,7 +2493,7 @@ TODO: implement
|
||||
var criteria = [self criteriaForRow:aRow];
|
||||
indexofCriterion = [criteria indexOfObject:criterion];
|
||||
|
||||
if (parentItem !== nil
|
||||
if (parentItem != nil
|
||||
&& indexofCriterion !== CPNotFound
|
||||
&& indexofCriterion < [criteria count] - 1)
|
||||
{
|
||||
@@ -2469,7 +2576,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];
|
||||
@@ -2553,7 +2660,7 @@ var CriteriaKey = @"criteria",
|
||||
- (id)initWithCoder:(CPCoder)coder
|
||||
{
|
||||
self = [super init];
|
||||
if (self !== nil)
|
||||
if (self)
|
||||
{
|
||||
subrows = [coder decodeObjectForKey:SubrowsKey];
|
||||
criteria = [coder decodeObjectForKey:CriteriaKey];
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
{
|
||||
var title = [self title];
|
||||
|
||||
if (title !== nil)
|
||||
if (title != nil)
|
||||
return title;
|
||||
|
||||
return [self templateView];
|
||||
|
||||
@@ -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;
|
||||
@@ -77,21 +77,251 @@ var LocalizerStringsRegex = new RegExp("\"(.+)\"\\s*=\\s*\"(.+)\"\\s*;\\s*(//.+)
|
||||
}
|
||||
|
||||
_dictionary = [CPDictionary dictionaryWithDictionary:dict];
|
||||
|
||||
// Post notification to let the rule editor know the translation dictionary is ready
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:@"_CPRuleEditorLocalizerDidLoadNotification" object:self];
|
||||
}
|
||||
|
||||
- (CPString)localizedStringForString:(CPString)aString
|
||||
{
|
||||
[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;
|
||||
}
|
||||
|
||||
return aString;
|
||||
}
|
||||
|
||||
// MARK: - Formatting & Reordering Helpers
|
||||
|
||||
- (CPString)_englishRepresentationForView:(id)aView
|
||||
{
|
||||
if ([aView isKindOfClass:[CPPopUpButton class]])
|
||||
{
|
||||
var selectedItem = [aView selectedItem];
|
||||
if (selectedItem)
|
||||
{
|
||||
var originalTitle = selectedItem._originalTitle;
|
||||
|
||||
// Fallback: If not cached directly, inspect representedObject payload dictionary
|
||||
if (!originalTitle)
|
||||
{
|
||||
var rep = [selectedItem representedObject];
|
||||
if (rep && typeof rep === "object" && [rep respondsToSelector:@selector(objectForKey:)])
|
||||
{
|
||||
originalTitle = [rep objectForKey:@"value"];
|
||||
}
|
||||
else if (rep && typeof rep === "string")
|
||||
{
|
||||
originalTitle = rep;
|
||||
}
|
||||
}
|
||||
if (!originalTitle)
|
||||
{
|
||||
originalTitle = [selectedItem title];
|
||||
}
|
||||
return "%[" + originalTitle + "]@";
|
||||
}
|
||||
return "%[]@";
|
||||
}
|
||||
else if ([aView isKindOfClass:[CPTextField class]] && ![aView isEditable])
|
||||
{
|
||||
return aView._originalText || [aView stringValue];
|
||||
}
|
||||
else
|
||||
{
|
||||
return "%@";
|
||||
}
|
||||
}
|
||||
|
||||
- (CPString)formattingKeyForViews:(CPArray)views
|
||||
{
|
||||
var keyParts = [];
|
||||
var count = [views count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var view = [views objectAtIndex:i];
|
||||
[keyParts addObject:[self _englishRepresentationForView:view]];
|
||||
}
|
||||
return [keyParts componentsJoinedByString:@" "];
|
||||
}
|
||||
|
||||
- (void)localizeMenuItemsForViews:(CPArray)views
|
||||
{
|
||||
var count = [views count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var view = [views objectAtIndex:i];
|
||||
if ([view isKindOfClass:[CPPopUpButton class]])
|
||||
{
|
||||
var menuItems = [view itemArray];
|
||||
var menuItemsCount = [menuItems count];
|
||||
var selectedItem = [view selectedItem];
|
||||
|
||||
for (var j = 0; j < menuItemsCount; j++)
|
||||
{
|
||||
var item = [menuItems objectAtIndex:j];
|
||||
|
||||
if (!item._originalTitle)
|
||||
{
|
||||
var rep = [item representedObject];
|
||||
if (rep && typeof rep === "object" && [rep respondsToSelector:@selector(objectForKey:)])
|
||||
{
|
||||
item._originalTitle = [rep objectForKey:@"value"];
|
||||
}
|
||||
else
|
||||
{
|
||||
item._originalTitle = [item title];
|
||||
}
|
||||
}
|
||||
|
||||
// Temporarily select item to generate formatting key context
|
||||
[view selectItem:item];
|
||||
|
||||
var tempKey = [self formattingKeyForViews:views];
|
||||
var tempPattern = [self localizedStringForString:tempKey];
|
||||
|
||||
if (tempPattern !== tempKey)
|
||||
{
|
||||
var regex = /%(\d+)\$(?:\[([^\]]+)\])?@/g;
|
||||
var match;
|
||||
while ((match = regex.exec(tempPattern)) !== null)
|
||||
{
|
||||
var position = parseInt(match[1], 10) - 1;
|
||||
var translatedValue = match[2];
|
||||
|
||||
if (position === i && translatedValue)
|
||||
{
|
||||
[item setTitle:translatedValue];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[item setTitle:item._originalTitle];
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedItem)
|
||||
{
|
||||
[view selectItem:selectedItem];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (CPArray)localizeAndReorderViews:(CPArray)views
|
||||
{
|
||||
var key = [self formattingKeyForViews:views];
|
||||
var localizedPattern = [self localizedStringForString:key];
|
||||
|
||||
if (localizedPattern === key)
|
||||
{
|
||||
var count = [views count];
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var originalView = [views objectAtIndex:i];
|
||||
if ([originalView isKindOfClass:[CPPopUpButton class]])
|
||||
{
|
||||
var selectedItem = [originalView selectedItem];
|
||||
if (selectedItem && selectedItem._originalTitle)
|
||||
{
|
||||
[selectedItem setTitle:selectedItem._originalTitle];
|
||||
}
|
||||
}
|
||||
else if ([originalView respondsToSelector:@selector(setStringValue:)] && originalView._originalText)
|
||||
{
|
||||
[originalView setStringValue:originalView._originalText];
|
||||
|
||||
if ([originalView isKindOfClass:[CPTextField class]] && ![originalView isEditable])
|
||||
{
|
||||
var font = [originalView font] || [CPFont systemFontOfSize:[CPFont systemFontSize]],
|
||||
size = [originalView._originalText sizeWithFont:font];
|
||||
[originalView setFrameSize:CGSizeMake(size.width + 4, CGRectGetHeight([originalView frame]))];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return views;
|
||||
}
|
||||
|
||||
var newViews = [CPMutableArray array];
|
||||
var regex = /%(\d+)\$(?:\[([^\]]+)\])?@/g;
|
||||
var lastIndex = 0;
|
||||
var match;
|
||||
|
||||
while ((match = regex.exec(localizedPattern)) !== null)
|
||||
{
|
||||
var literalText = localizedPattern.substring(lastIndex, match.index);
|
||||
|
||||
// Only add a label if there are actual non-whitespace characters (like 'y')
|
||||
if (literalText.length > 0 && /\S/.test(literalText))
|
||||
{
|
||||
var label = [CPTextField labelWithTitle:literalText];
|
||||
[newViews addObject:label];
|
||||
}
|
||||
|
||||
var position = parseInt(match[1], 10) - 1;
|
||||
var translatedValue = match[2];
|
||||
|
||||
if (position >= 0 && position < [views count])
|
||||
{
|
||||
var originalView = [views objectAtIndex:position];
|
||||
|
||||
if (translatedValue !== undefined && translatedValue !== null)
|
||||
{
|
||||
if ([originalView isKindOfClass:[CPPopUpButton class]])
|
||||
{
|
||||
var selectedItem = [originalView selectedItem];
|
||||
if (selectedItem)
|
||||
{
|
||||
if (!selectedItem._originalTitle)
|
||||
{
|
||||
selectedItem._originalTitle = [selectedItem title];
|
||||
}
|
||||
[selectedItem setTitle:translatedValue];
|
||||
}
|
||||
}
|
||||
else if ([originalView respondsToSelector:@selector(setStringValue:)])
|
||||
{
|
||||
[originalView setStringValue:translatedValue];
|
||||
|
||||
// Recalculate frame size if it is a static CPTextField to avoid visual clipping
|
||||
if ([originalView isKindOfClass:[CPTextField class]] && ![originalView isEditable])
|
||||
{
|
||||
var font = [originalView font] || [CPFont systemFontOfSize:[CPFont systemFontSize]],
|
||||
size = [translatedValue sizeWithFont:font];
|
||||
[originalView setFrameSize:CGSizeMake(size.width + 4, CGRectGetHeight([originalView frame]))];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[newViews addObject:originalView];
|
||||
}
|
||||
|
||||
lastIndex = regex.lastIndex;
|
||||
}
|
||||
|
||||
if (lastIndex < localizedPattern.length)
|
||||
{
|
||||
var literalText = localizedPattern.substring(lastIndex);
|
||||
|
||||
// Only add a label if there are actual non-whitespace characters
|
||||
if (literalText.length > 0 && /\S/.test(literalText))
|
||||
{
|
||||
var label = [CPTextField labelWithTitle:literalText];
|
||||
[newViews addObject:label];
|
||||
}
|
||||
}
|
||||
|
||||
return newViews;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -29,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:);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,8 +114,32 @@
|
||||
|
||||
- (CPMenuItem)_createMenuItemWithTitle:(CPString )title
|
||||
{
|
||||
title = [[_ruleEditor standardLocalizer] localizedStringForString:title];
|
||||
return [[CPMenuItem alloc] initWithTitle:title action:nil keyEquivalent:@""];
|
||||
var originalTitle = title;
|
||||
var localizedTitle = [[_ruleEditor standardLocalizer] localizedStringForString:title];
|
||||
var item = [[CPMenuItem alloc] initWithTitle:localizedTitle action:nil keyEquivalent:@""];
|
||||
|
||||
// Cache the raw English title for pattern-matching
|
||||
item._originalTitle = originalTitle;
|
||||
return item;
|
||||
}
|
||||
|
||||
- (CPTextField)_createStaticTextFieldWithStringValue:(CPString)text
|
||||
{
|
||||
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];
|
||||
|
||||
// Cache the raw English text for pattern-matching
|
||||
textField._originalText = text;
|
||||
|
||||
return textField;
|
||||
}
|
||||
|
||||
- (CPPopUpButton)_createPopUpButtonWithItems:(CPArray)itemsArray selectedItemIndex:(int)index
|
||||
@@ -142,22 +166,6 @@
|
||||
return [CPMenuItem separatorItem];
|
||||
}
|
||||
|
||||
- (CPTextField)_createStaticTextFieldWithStringValue:(CPString)text
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
- (void)_addOption:(id)sender
|
||||
{
|
||||
if (_rowIndex == [_ruleEditor numberOfRows] - 1)
|
||||
@@ -209,8 +217,7 @@
|
||||
|
||||
- (void)_reconfigureSubviews
|
||||
{
|
||||
var ruleItems,
|
||||
criteria,
|
||||
var criteria,
|
||||
repObject,
|
||||
menuItem,
|
||||
ruleView,
|
||||
@@ -335,6 +342,28 @@
|
||||
|
||||
[_correspondingRuleItems setArray:ruleItems];
|
||||
|
||||
// Localize drop-down options in context and reorder/insert intermediate labels natively
|
||||
var localizer = [_ruleEditor standardLocalizer];
|
||||
if (localizer)
|
||||
{
|
||||
[localizer localizeMenuItemsForViews:_ruleOptionViews];
|
||||
_ruleOptionViews = [localizer localizeAndReorderViews:_ruleOptionViews];
|
||||
}
|
||||
|
||||
// Rebuild frame configurations to match the new localized layout order
|
||||
[_ruleOptionFrames removeAllObjects];
|
||||
[_ruleOptionInitialViewFrames removeAllObjects];
|
||||
|
||||
var newCount = [_ruleOptionViews count];
|
||||
for (var i = 0; i < newCount; i++)
|
||||
{
|
||||
var view = [_ruleOptionViews objectAtIndex:i],
|
||||
frame = [view frame];
|
||||
|
||||
[_ruleOptionFrames addObject:frame];
|
||||
[_ruleOptionInitialViewFrames addObject:frame];
|
||||
}
|
||||
|
||||
if (!_editable)
|
||||
[self _updateEnabledStateForSubviews];
|
||||
|
||||
@@ -366,11 +395,12 @@
|
||||
count = [_ruleOptionViews count],
|
||||
sliceFrame = [self frame],
|
||||
image = [_ruleEditor _imageAdd],
|
||||
imageSize = image ? [image size] : CGSizeMake(0,0),
|
||||
|
||||
buttonFrame = CGRectMake(CGRectGetWidth(sliceFrame) - [image size].width - [self _rowButtonsRightHorizontalPadding], ([_ruleEditor rowHeight] - [image size].height) / 2 - 1, [image size].width, [image size].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 -= [image size].width + [self _rowButtonsInterviewHorizontalPadding];
|
||||
buttonFrame.origin.x -= imageSize.width + [self _rowButtonsInterviewHorizontalPadding];
|
||||
[_subtractButton setFrame:buttonFrame];
|
||||
|
||||
if (widthChanged)
|
||||
@@ -410,6 +440,9 @@
|
||||
{
|
||||
[_addButton setHidden:[_ruleEditor _shouldHideAddButtonForSlice:self]];
|
||||
[_subtractButton setHidden:[_ruleEditor _shouldHideSubtractButtonForSlice:self]];
|
||||
|
||||
[_addButton setToolTip:[_ruleEditor _toolTipForAddSimpleRowButton]];
|
||||
[_subtractButton setToolTip:[_ruleEditor _toolTipForDeleteRowButton]];
|
||||
}
|
||||
|
||||
- (void)_configurePlusButtonByRowType:(CPRuleEditorRowType)type
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
CPArray _allowedFileTypes @accessors(property=allowedFileTypes);
|
||||
}
|
||||
|
||||
+ (CPURL)proposedFileURLWithDocumentName:(CPString)aDocumentName
|
||||
{
|
||||
return [CPURL URLWithString:aDocumentName];
|
||||
}
|
||||
|
||||
+ (id)savePanel
|
||||
{
|
||||
return [[CPSavePanel alloc] init];
|
||||
|
||||
+376
-77
@@ -29,10 +29,23 @@
|
||||
@import "CPClipView.j"
|
||||
@import "CPScroller.j"
|
||||
@import "CPView.j"
|
||||
@import "CPRulerView.j"
|
||||
|
||||
@class CPTableView
|
||||
@class CPRulerView
|
||||
|
||||
#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 _isBrowserUsingOverlayScrollers = function()
|
||||
{
|
||||
@@ -77,6 +90,19 @@ var _isBrowserUsingOverlayScrollers = function()
|
||||
#endif
|
||||
};
|
||||
|
||||
var TIMER_INTERVAL = 0.2,
|
||||
CPScrollViewDelegate_scrollViewWillScroll_ = 1 << 0,
|
||||
CPScrollViewDelegate_scrollViewDidScroll_ = 1 << 1,
|
||||
|
||||
CPScrollViewFadeOutTime = 1.3;
|
||||
|
||||
var CPScrollViewWillStartLiveScrollNotification = @"CPScrollViewWillStartLiveScrollNotification",
|
||||
CPScrollViewDidLiveScrollNotification = @"CPScrollViewDidLiveScrollNotification",
|
||||
CPScrollViewDidEndLiveScrollNotification = @"CPScrollViewDidEndLiveScrollNotification";
|
||||
|
||||
var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
CPScrollerStyleGlobalChangeNotification = @"CPScrollerStyleGlobalChangeNotification";
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPScrollView
|
||||
@@ -85,53 +111,50 @@ var _isBrowserUsingOverlayScrollers = function()
|
||||
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,
|
||||
|
||||
CPScrollViewFadeOutTime = 1.3;
|
||||
|
||||
var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
CPScrollerStyleGlobalChangeNotification = @"CPScrollerStyleGlobalChangeNotification";
|
||||
|
||||
|
||||
@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;
|
||||
|
||||
// Ruler Support
|
||||
BOOL _hasVerticalRuler;
|
||||
BOOL _hasHorizontalRuler;
|
||||
BOOL _rulersVisible;
|
||||
|
||||
CPRulerView _verticalRuler;
|
||||
CPRulerView _horizontalRuler;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Class methods
|
||||
// MARK: -
|
||||
// MARK: Class methods
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
@@ -140,7 +163,7 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
|
||||
var globalValue = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPScrollersGlobalStyle"];
|
||||
|
||||
if (globalValue === nil || globalValue === -1)
|
||||
if (globalValue == nil || globalValue === -1)
|
||||
CPScrollerStyleGlobal = _isBrowserUsingOverlayScrollers() ? CPScrollerStyleOverlay : CPScrollerStyleLegacy
|
||||
else
|
||||
CPScrollerStyleGlobal = globalValue;
|
||||
@@ -159,33 +182,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;
|
||||
}
|
||||
@@ -213,7 +268,7 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
/*!
|
||||
Get the system wide scroller style.
|
||||
*/
|
||||
+ (int)globalScrollerStyle
|
||||
+ (CPScrollerStyle)globalScrollerStyle
|
||||
{
|
||||
return CPScrollerStyleGlobal;
|
||||
}
|
||||
@@ -223,15 +278,15 @@ 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];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Initialization
|
||||
// MARK: -
|
||||
// MARK: Initialization
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
@@ -261,6 +316,10 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
_scrollerKnobStyle = CPScrollerKnobStyleDefault;
|
||||
[self setScrollerStyle:CPScrollerStyleGlobal];
|
||||
|
||||
_hasVerticalRuler = NO;
|
||||
_hasHorizontalRuler = NO;
|
||||
_rulersVisible = NO;
|
||||
|
||||
_delegate = nil;
|
||||
_scrollTimer = nil;
|
||||
_implementedDelegateMethods = 0;
|
||||
@@ -270,8 +329,8 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Getters / Setters
|
||||
// MARK: -
|
||||
// MARK: Getters / Setters
|
||||
|
||||
/*!
|
||||
The delegate of the scroll view
|
||||
@@ -296,7 +355,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;
|
||||
@@ -304,7 +363,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:)])
|
||||
@@ -314,7 +373,7 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
_implementedDelegateMethods |= CPScrollViewDelegate_scrollViewDidScroll_;
|
||||
}
|
||||
|
||||
- (int)scrollerStyle
|
||||
- (CPScrollerStyle)scrollerStyle
|
||||
{
|
||||
return _scrollerStyle;
|
||||
}
|
||||
@@ -325,7 +384,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;
|
||||
@@ -522,8 +581,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];
|
||||
@@ -587,8 +646,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];
|
||||
@@ -749,8 +808,105 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Privates
|
||||
// MARK: -
|
||||
// MARK: Rulers
|
||||
|
||||
- (BOOL)hasHorizontalRuler
|
||||
{
|
||||
return _hasHorizontalRuler;
|
||||
}
|
||||
|
||||
- (void)setHasHorizontalRuler:(BOOL)shouldHaveHorizontalRuler
|
||||
{
|
||||
if (_hasHorizontalRuler === shouldHaveHorizontalRuler)
|
||||
return;
|
||||
|
||||
_hasHorizontalRuler = shouldHaveHorizontalRuler;
|
||||
|
||||
if (_hasHorizontalRuler && !_horizontalRuler)
|
||||
{
|
||||
_horizontalRuler = [[CPRulerView alloc] initWithScrollView:self orientation:CPRulerOrientationHorizontal];
|
||||
}
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (BOOL)hasVerticalRuler
|
||||
{
|
||||
return _hasVerticalRuler;
|
||||
}
|
||||
|
||||
- (void)setHasVerticalRuler:(BOOL)shouldHaveVerticalRuler
|
||||
{
|
||||
if (_hasVerticalRuler === shouldHaveVerticalRuler)
|
||||
return;
|
||||
|
||||
_hasVerticalRuler = shouldHaveVerticalRuler;
|
||||
|
||||
if (_hasVerticalRuler && !_verticalRuler)
|
||||
{
|
||||
_verticalRuler = [[CPRulerView alloc] initWithScrollView:self orientation:CPRulerOrientationVertical];
|
||||
}
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (BOOL)rulersVisible
|
||||
{
|
||||
return _rulersVisible;
|
||||
}
|
||||
|
||||
- (void)setRulersVisible:(BOOL)areRulersVisible
|
||||
{
|
||||
if (_rulersVisible === areRulersVisible)
|
||||
return;
|
||||
|
||||
_rulersVisible = areRulersVisible;
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (CPRulerView)horizontalRulerView
|
||||
{
|
||||
return _horizontalRuler;
|
||||
}
|
||||
|
||||
- (void)setHorizontalRulerView:(CPRulerView)aRulerView
|
||||
{
|
||||
if (_horizontalRuler === aRulerView)
|
||||
return;
|
||||
|
||||
[_horizontalRuler removeFromSuperview];
|
||||
_horizontalRuler = aRulerView;
|
||||
|
||||
if (_horizontalRuler)
|
||||
[self addSubview:_horizontalRuler];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (CPRulerView)verticalRulerView
|
||||
{
|
||||
return _verticalRuler;
|
||||
}
|
||||
|
||||
- (void)setVerticalRulerView:(CPRulerView)aRulerView
|
||||
{
|
||||
if (_verticalRuler === aRulerView)
|
||||
return;
|
||||
|
||||
[_verticalRuler removeFromSuperview];
|
||||
_verticalRuler = aRulerView;
|
||||
|
||||
if (_verticalRuler)
|
||||
[self addSubview:_verticalRuler];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// MARK: Privates
|
||||
|
||||
/* @ignore */
|
||||
- (void)_updateScrollerStyle
|
||||
@@ -904,8 +1060,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;
|
||||
}
|
||||
@@ -946,6 +1102,8 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
[self _sendDelegateMessages];
|
||||
|
||||
[_contentView scrollToPoint:contentBounds.origin];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPScrollViewDidLiveScrollNotification object:self];
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
@@ -984,6 +1142,8 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
|
||||
[_contentView scrollToPoint:contentBounds.origin];
|
||||
[_headerClipView scrollToPoint:CGPointMake(contentBounds.origin.x, 0.0)];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPScrollViewDidLiveScrollNotification object:self];
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
@@ -994,6 +1154,7 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
|
||||
if (!_scrollTimer)
|
||||
{
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPScrollViewWillStartLiveScrollNotification object:self];
|
||||
[self _scrollViewWillScroll];
|
||||
_scrollTimer = [CPTimer scheduledTimerWithTimeInterval:TIMER_INTERVAL target:self selector:@selector(_scrollViewDidScroll) userInfo:nil repeats:YES];
|
||||
}
|
||||
@@ -1032,6 +1193,8 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
[_contentView scrollToPoint:constrainedOrigin];
|
||||
[_headerClipView scrollToPoint:CGPointMake(constrainedOrigin.x, 0.0)];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPScrollViewDidLiveScrollNotification object:self];
|
||||
|
||||
if (extraX || extraY)
|
||||
[enclosingScrollView _respondToScrollWheelEventWithDeltaX:extraX deltaY:extraY];
|
||||
}
|
||||
@@ -1051,6 +1214,8 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
|
||||
if (_implementedDelegateMethods & CPScrollViewDelegate_scrollViewDidScroll_)
|
||||
[_delegate scrollViewDidScroll:self];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPScrollViewDidEndLiveScrollNotification object:self];
|
||||
}
|
||||
|
||||
/*! @ignore*/
|
||||
@@ -1061,18 +1226,15 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Utilities
|
||||
// MARK: -
|
||||
// MARK: Utilities
|
||||
|
||||
/*!
|
||||
Lays out the scroll view's components.
|
||||
*/
|
||||
- (void)tile
|
||||
{
|
||||
// yuck.
|
||||
// RESIZE: tile->setHidden AND refl
|
||||
// Outside Change: refl->tile->setHidden AND refl
|
||||
// scroll: refl.
|
||||
[self reflectScrolledClipView:_contentView];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1116,9 +1278,44 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
contentFrame.origin.y += headerClipViewHeight;
|
||||
contentFrame.size.height -= headerClipViewHeight;
|
||||
|
||||
// Adjust content view based on horizontal / vertical ruler presence
|
||||
var showHorizontalRuler = _rulersVisible && _hasHorizontalRuler && _horizontalRuler,
|
||||
showVerticalRuler = _rulersVisible && _hasVerticalRuler && _verticalRuler;
|
||||
|
||||
var horizRulerThickness = showHorizontalRuler ? ([_horizontalRuler respondsToSelector:@selector(ruleThickness)] ? [_horizontalRuler ruleThickness] : 16.0) : 0.0,
|
||||
vertRulerThickness = showVerticalRuler ? ([_verticalRuler respondsToSelector:@selector(ruleThickness)] ? [_verticalRuler ruleThickness] : 24.0) : 0.0;
|
||||
|
||||
if (showHorizontalRuler)
|
||||
{
|
||||
if ([_horizontalRuler superview] !== self)
|
||||
[self addSubview:_horizontalRuler];
|
||||
[_horizontalRuler setHidden:NO];
|
||||
}
|
||||
else if (_horizontalRuler)
|
||||
{
|
||||
[_horizontalRuler setHidden:YES];
|
||||
}
|
||||
|
||||
if (showVerticalRuler)
|
||||
{
|
||||
if ([_verticalRuler superview] !== self)
|
||||
[self addSubview:_verticalRuler];
|
||||
[_verticalRuler setHidden:NO];
|
||||
}
|
||||
else if (_verticalRuler)
|
||||
{
|
||||
[_verticalRuler setHidden:YES];
|
||||
}
|
||||
|
||||
contentFrame.origin.y += horizRulerThickness;
|
||||
contentFrame.size.height -= horizRulerThickness;
|
||||
|
||||
contentFrame.origin.x += vertRulerThickness;
|
||||
contentFrame.size.width -= vertRulerThickness;
|
||||
|
||||
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),
|
||||
@@ -1208,6 +1405,7 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
[_contentView setFrame:contentFrame];
|
||||
[_headerClipView setFrame:[self _headerClipViewFrame]];
|
||||
[[_headerClipView documentView] setNeedsDisplay:YES];
|
||||
|
||||
if (SHOULD_SHOW_CORNER_VIEW())
|
||||
{
|
||||
[_cornerView setFrame:[self _cornerViewFrame]];
|
||||
@@ -1222,6 +1420,37 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
[[self bottomCornerView] setBackgroundColor:[self currentValueForThemeAttribute:@"bottom-corner-color"]];
|
||||
}
|
||||
|
||||
// Position and redraw rulers to track viewport updates
|
||||
if (showHorizontalRuler)
|
||||
{
|
||||
[_horizontalRuler setFrame:CGRectMake(
|
||||
CGRectGetMinX(contentFrame),
|
||||
CGRectGetMinY(contentFrame) - horizRulerThickness,
|
||||
CGRectGetWidth(contentFrame),
|
||||
horizRulerThickness
|
||||
)];
|
||||
|
||||
if ([_horizontalRuler respondsToSelector:@selector(updateRuler)])
|
||||
[_horizontalRuler updateRuler];
|
||||
else
|
||||
[_horizontalRuler setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
if (showVerticalRuler)
|
||||
{
|
||||
[_verticalRuler setFrame:CGRectMake(
|
||||
CGRectGetMinX(contentFrame) - vertRulerThickness,
|
||||
CGRectGetMinY(contentFrame),
|
||||
vertRulerThickness,
|
||||
CGRectGetHeight(contentFrame)
|
||||
)];
|
||||
|
||||
if ([_verticalRuler respondsToSelector:@selector(updateRuler)])
|
||||
[_verticalRuler updateRuler];
|
||||
else
|
||||
[_verticalRuler setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
--_recursionCount;
|
||||
}
|
||||
|
||||
@@ -1246,7 +1475,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];
|
||||
}
|
||||
@@ -1262,8 +1491,8 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
return [_contentView documentVisibleRect];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Overrides
|
||||
// MARK: -
|
||||
// MARK: Overrides
|
||||
|
||||
|
||||
- (void)_removeObservers
|
||||
@@ -1384,8 +1613,8 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
|
||||
y = maxY - 1.5;
|
||||
|
||||
CGContextMoveToPoint(context, maxX - 1.0, y);
|
||||
CGContextAddLineToPoint(context, minX + 2.0, y);
|
||||
CGContextMoveToPoint(maxX - 1.0, y);
|
||||
CGContextAddLineToPoint(minX + 2.0, y);
|
||||
|
||||
x = minX + 0.5;
|
||||
|
||||
@@ -1503,6 +1732,51 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
|
||||
@end
|
||||
|
||||
// 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
|
||||
|
||||
// MARK: -
|
||||
|
||||
var CPScrollViewContentViewKey = @"CPScrollViewContentView",
|
||||
CPScrollViewHeaderClipViewKey = @"CPScrollViewHeaderClipViewKey",
|
||||
@@ -1519,7 +1793,14 @@ var CPScrollViewContentViewKey = @"CPScrollViewContentView",
|
||||
CPScrollViewBottomCornerViewKey = @"CPScrollViewBottomCornerViewKey",
|
||||
CPScrollViewBorderTypeKey = @"CPScrollViewBorderTypeKey",
|
||||
CPScrollViewScrollerStyleKey = @"CPScrollViewScrollerStyleKey",
|
||||
CPScrollViewScrollerKnobStyleKey = @"CPScrollViewScrollerKnobStyleKey";
|
||||
CPScrollViewScrollerKnobStyleKey = @"CPScrollViewScrollerKnobStyleKey",
|
||||
|
||||
// Ruler Coding Keys
|
||||
CPScrollViewHasVRulerKey = @"CPScrollViewHasVRuler",
|
||||
CPScrollViewHasHRulerKey = @"CPScrollViewHasHRuler",
|
||||
CPScrollViewRulersVisibleKey = @"CPScrollViewRulersVisible",
|
||||
CPScrollViewVRulerKey = @"CPScrollViewVRuler",
|
||||
CPScrollViewHRulerKey = @"CPScrollViewHRuler";
|
||||
|
||||
@implementation CPScrollView (CPCoding)
|
||||
|
||||
@@ -1554,6 +1835,14 @@ var CPScrollViewContentViewKey = @"CPScrollViewContentView",
|
||||
_cornerView = [aCoder decodeObjectForKey:CPScrollViewCornerViewKey];
|
||||
_bottomCornerView = [aCoder decodeObjectForKey:CPScrollViewBottomCornerViewKey];
|
||||
|
||||
// Ruler decoding
|
||||
_hasVerticalRuler = [aCoder decodeBoolForKey:CPScrollViewHasVRulerKey];
|
||||
_hasHorizontalRuler = [aCoder decodeBoolForKey:CPScrollViewHasHRulerKey];
|
||||
_rulersVisible = [aCoder decodeBoolForKey:CPScrollViewRulersVisibleKey];
|
||||
|
||||
_verticalRuler = [aCoder decodeObjectForKey:CPScrollViewVRulerKey];
|
||||
_horizontalRuler = [aCoder decodeObjectForKey:CPScrollViewHRulerKey];
|
||||
|
||||
_delegate = nil;
|
||||
_scrollTimer = nil;
|
||||
_implementedDelegateMethods = 0;
|
||||
@@ -1575,6 +1864,8 @@ var CPScrollViewContentViewKey = @"CPScrollViewContentView",
|
||||
*/
|
||||
- (void)awakeFromCib
|
||||
{
|
||||
[super awakeFromCib];
|
||||
|
||||
[self _updateScrollerStyle];
|
||||
[self _updateCornerAndHeaderView];
|
||||
}
|
||||
@@ -1605,6 +1896,14 @@ var CPScrollViewContentViewKey = @"CPScrollViewContentView",
|
||||
|
||||
[aCoder encodeInt:_scrollerStyle forKey:CPScrollViewScrollerStyleKey];
|
||||
[aCoder encodeInt:_scrollerKnobStyle forKey:CPScrollViewScrollerKnobStyleKey];
|
||||
|
||||
// Ruler encoding
|
||||
[aCoder encodeBool:_hasVerticalRuler forKey:CPScrollViewHasVRulerKey];
|
||||
[aCoder encodeBool:_hasHorizontalRuler forKey:CPScrollViewHasHRulerKey];
|
||||
[aCoder encodeBool:_rulersVisible forKey:CPScrollViewRulersVisibleKey];
|
||||
|
||||
[aCoder encodeObject:_verticalRuler forKey:CPScrollViewVRulerKey];
|
||||
[aCoder encodeObject:_horizontalRuler forKey:CPScrollViewHRulerKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+48
-38
@@ -23,12 +23,11 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "../Foundation/Foundation.h"
|
||||
|
||||
@import "CPAnimation.j"
|
||||
@import "CPControl.j"
|
||||
@import "CPWindow_Constants.j"
|
||||
@import "CPViewAnimation.j"
|
||||
@import "CPWindow_Constants.j"
|
||||
|
||||
@global CPApp
|
||||
|
||||
@@ -50,11 +49,6 @@ CPNoScrollerParts = 0;
|
||||
CPOnlyScrollerArrows = 1;
|
||||
CPAllScrollerParts = 2;
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPScroller
|
||||
*/
|
||||
|
||||
var PARTS_ARRANGEMENT = [CPScrollerKnobSlot, CPScrollerDecrementLine, CPScrollerIncrementLine, CPScrollerKnob],
|
||||
NAMES_FOR_PARTS = {},
|
||||
PARTS_FOR_NAMES = {};
|
||||
@@ -67,6 +61,7 @@ NAMES_FOR_PARTS[CPScrollerKnobSlot] = @"knob-slot";
|
||||
NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
|
||||
|
||||
|
||||
@typedef CPScrollerStyle
|
||||
CPScrollerStyleLegacy = 0;
|
||||
CPScrollerStyleOverlay = 1;
|
||||
|
||||
@@ -78,6 +73,11 @@ CPThemeStateScrollViewLegacy = CPThemeState("scroller-style-legacy");
|
||||
CPThemeStateScrollerKnobLight = CPThemeState("scroller-knob-light");
|
||||
CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPScroller
|
||||
*/
|
||||
|
||||
@implementation CPScroller : CPControl
|
||||
{
|
||||
CPUsableScrollerParts _usableParts;
|
||||
@@ -101,8 +101,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Class methods
|
||||
// MARK: -
|
||||
// MARK: Class methods
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
@@ -134,7 +134,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];
|
||||
@@ -166,8 +166,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Initialization
|
||||
// MARK: -
|
||||
// MARK: Initialization
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
@@ -202,13 +202,13 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Getters / Setters
|
||||
// MARK: -
|
||||
// MARK: Getters / Setters
|
||||
|
||||
/*!
|
||||
Returns the scroller's style
|
||||
*/
|
||||
- (void)style
|
||||
- (int)style
|
||||
{
|
||||
return _style;
|
||||
}
|
||||
@@ -217,7 +217,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;
|
||||
@@ -226,6 +226,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
|
||||
if (_style === CPScrollerStyleLegacy)
|
||||
{
|
||||
_allowFadingOut = NO;
|
||||
[self fadeIn];
|
||||
[self setThemeState:CPThemeStateScrollViewLegacy];
|
||||
}
|
||||
@@ -257,8 +258,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
*/
|
||||
- (void)setKnobProportion:(float)aProportion
|
||||
{
|
||||
if (!_IS_NUMERIC(aProportion))
|
||||
[CPException raise:CPInvalidArgumentException reason:"aProportion must be numeric"];
|
||||
if (!CPIsNumeric(aProportion))
|
||||
[CPException raise:CPInvalidArgumentException reason:"aProportion must be numeric, was: "+aProportion];
|
||||
|
||||
_knobProportion = MIN(1.0, MAX(0.0001, aProportion));
|
||||
|
||||
@@ -267,8 +268,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Privates
|
||||
// MARK: -
|
||||
// MARK: Privates
|
||||
|
||||
/*! @ignore */
|
||||
- (void)_adjustScrollerSize
|
||||
@@ -293,8 +294,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Utilities
|
||||
// MARK: -
|
||||
// MARK: Utilities
|
||||
|
||||
- (CGRect)rectForPart:(CPScrollerPart)aPart
|
||||
{
|
||||
@@ -316,7 +317,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))
|
||||
@@ -380,9 +381,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);
|
||||
@@ -409,9 +411,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);
|
||||
@@ -460,15 +463,12 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
*/
|
||||
- (void)fadeOut
|
||||
{
|
||||
if ([self hasThemeState:CPThemeStateScrollViewLegacy])
|
||||
return;
|
||||
|
||||
[_animationScroller startAnimation];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Drawing
|
||||
// MARK: -
|
||||
// MARK: Drawing
|
||||
|
||||
/*!
|
||||
Draws the specified arrow and sets the highlight.
|
||||
@@ -702,8 +702,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Overrides
|
||||
// MARK: -
|
||||
// MARK: Overrides
|
||||
|
||||
- (id)currentValueForThemeAttribute:(CPString)anAttributeName
|
||||
{
|
||||
@@ -759,18 +759,28 @@ 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];
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegates
|
||||
return [self currentValueForThemeAttribute:@"scroller-width"];
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// MARK: Delegates
|
||||
|
||||
- (void)animationDidEnd:(CPAnimation)animation
|
||||
{
|
||||
|
||||
+376
-64
@@ -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,11 +132,12 @@ var RECENT_SEARCH_PREFIX = @" ";
|
||||
[self resetSearchButton];
|
||||
|
||||
_canResignFirstResponder = YES;
|
||||
_isBecomingFirstResponder = NO;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Override observers
|
||||
// MARK: -
|
||||
// MARK: Override observers
|
||||
|
||||
- (void)_removeObservers
|
||||
{
|
||||
@@ -177,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];
|
||||
@@ -224,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:)];
|
||||
@@ -246,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)
|
||||
@@ -266,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);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -278,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
|
||||
@@ -384,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];
|
||||
}
|
||||
|
||||
@@ -472,6 +498,7 @@ var RECENT_SEARCH_PREFIX = @" ";
|
||||
|
||||
- (BOOL)sendAction:(SEL)anAction to:(id)anObject
|
||||
{
|
||||
[self selectAll:nil];
|
||||
[super sendAction:anAction to:anObject];
|
||||
|
||||
[_partialStringTimer invalidate];
|
||||
@@ -482,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];
|
||||
@@ -529,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.
|
||||
@@ -566,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:@""];
|
||||
@@ -580,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];
|
||||
@@ -615,9 +636,6 @@ var RECENT_SEARCH_PREFIX = @" ";
|
||||
case CPSearchFieldRecentsTitleMenuItemTag:
|
||||
if (countOfRecents === 0)
|
||||
continue;
|
||||
|
||||
if ([menu numberOfItems] > 0)
|
||||
[self _addSeparatorToMenu:menu];
|
||||
break;
|
||||
|
||||
case CPSearchFieldRecentsMenuItemTag:
|
||||
@@ -626,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];
|
||||
@@ -641,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;
|
||||
@@ -651,9 +665,6 @@ var RECENT_SEARCH_PREFIX = @" ";
|
||||
case CPSearchFieldNoRecentsMenuItemTag:
|
||||
if (countOfRecents !== 0)
|
||||
continue;
|
||||
|
||||
if ([menu numberOfItems] > 0)
|
||||
[self _addSeparatorToMenu:menu];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -670,6 +681,7 @@ var RECENT_SEARCH_PREFIX = @" ";
|
||||
{
|
||||
var separator = [CPMenuItem separatorItem];
|
||||
[separator setEnabled:NO];
|
||||
[separator setTag:CPSearchFieldRecentsTitleMenuItemTag];
|
||||
[aMenu addItem:separator];
|
||||
}
|
||||
|
||||
@@ -691,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];
|
||||
|
||||
@@ -707,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];
|
||||
@@ -760,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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// MARK: -
|
||||
|
||||
var CPRecentsAutosaveNameKey = @"CPRecentsAutosaveNameKey",
|
||||
CPSendsWholeSearchStringKey = @"CPSendsWholeSearchStringKey",
|
||||
CPSendsSearchStringImmediatelyKey = @"CPSendsSearchStringImmediatelyKey",
|
||||
@@ -823,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
|
||||
|
||||
|
||||
+257
-192
@@ -42,7 +42,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
@implementation CPSegmentedControl : CPControl
|
||||
{
|
||||
CPArray _segments;
|
||||
CPArray _segments @accessors(getter=segments);
|
||||
CPArray _themeStates;
|
||||
|
||||
int _selectedSegment;
|
||||
@@ -87,6 +87,8 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
_selectedSegment = -1;
|
||||
|
||||
_trackingMode = CPSegmentSwitchTrackingSelectOne;
|
||||
_trackingHighlighted = NO;
|
||||
_trackingSegment = -1;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -107,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
|
||||
@@ -117,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];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -159,7 +199,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (unsigned)segmentCount
|
||||
{
|
||||
return _segments.length;
|
||||
return [_segments count];
|
||||
}
|
||||
|
||||
// Specifying Selected Segment
|
||||
@@ -171,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];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -189,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];
|
||||
|
||||
@@ -204,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];
|
||||
|
||||
@@ -216,7 +269,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
}
|
||||
|
||||
// Specifying Tracking Mode
|
||||
|
||||
/*! @ignore */
|
||||
- (BOOL)isTracking
|
||||
{
|
||||
|
||||
@@ -234,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];
|
||||
@@ -246,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];
|
||||
}
|
||||
@@ -269,7 +322,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (void)setWidth:(float)aWidth forSegment:(unsigned)aSegment
|
||||
{
|
||||
[_segments[aSegment] setWidth:aWidth];
|
||||
[[_segments objectAtIndex:aSegment] setWidth:aWidth];
|
||||
[self tileWithChangedSegment:aSegment];
|
||||
}
|
||||
|
||||
@@ -280,7 +333,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (float)widthForSegment:(unsigned)aSegment
|
||||
{
|
||||
return [_segments[aSegment] width];
|
||||
return [[_segments objectAtIndex:aSegment] width];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -291,7 +344,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (void)setImage:(CPImage)anImage forSegment:(unsigned)aSegment
|
||||
{
|
||||
[_segments[aSegment] setImage:anImage];
|
||||
[[_segments objectAtIndex:aSegment] setImage:anImage];
|
||||
|
||||
[self tileWithChangedSegment:aSegment];
|
||||
}
|
||||
@@ -303,7 +356,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (CPImage)imageForSegment:(unsigned)aSegment
|
||||
{
|
||||
return [_segments[aSegment] image];
|
||||
return [[_segments objectAtIndex:aSegment] image];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -314,7 +367,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (void)setLabel:(CPString)aLabel forSegment:(unsigned)aSegment
|
||||
{
|
||||
[_segments[aSegment] setLabel:aLabel];
|
||||
[[_segments objectAtIndex:aSegment] setLabel:aLabel];
|
||||
|
||||
[self tileWithChangedSegment:aSegment];
|
||||
}
|
||||
@@ -326,7 +379,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (CPString)labelForSegment:(unsigned)aSegment
|
||||
{
|
||||
return [_segments[aSegment] label];
|
||||
return [[_segments objectAtIndex:aSegment] label];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -337,7 +390,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (void)setMenu:(CPMenu)aMenu forSegment:(unsigned)aSegment
|
||||
{
|
||||
[_segments[aSegment] setMenu:aMenu];
|
||||
[[_segments objectAtIndex:aSegment] setMenu:aMenu];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -347,7 +400,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (CPMenu)menuForSegment:(unsigned)aSegment
|
||||
{
|
||||
return [_segments[aSegment] menu];
|
||||
return [[_segments objectAtIndex:aSegment] menu];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -359,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)
|
||||
@@ -376,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;
|
||||
@@ -399,7 +452,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (BOOL)isSelectedForSegment:(unsigned)aSegment
|
||||
{
|
||||
return [_segments[aSegment] selected];
|
||||
return [[_segments objectAtIndex:aSegment] selected];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -410,10 +463,12 @@ 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] = _themeStates[aSegment].without(CPThemeStateDisabled);
|
||||
@@ -431,7 +486,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (BOOL)isEnabledForSegment:(unsigned)aSegment
|
||||
{
|
||||
return [_segments[aSegment] enabled];
|
||||
return [[_segments objectAtIndex:aSegment] enabled];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -441,7 +496,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (void)setTag:(int)aTag forSegment:(unsigned)aSegment
|
||||
{
|
||||
[_segments[aSegment] setTag:aTag];
|
||||
[[_segments objectAtIndex:aSegment] setTag:aTag];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -450,7 +505,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (int)tagForSegment:(unsigned)aSegment
|
||||
{
|
||||
return [_segments[aSegment] tag];
|
||||
return [[_segments objectAtIndex:aSegment] tag];
|
||||
}
|
||||
|
||||
// Drawings
|
||||
@@ -461,7 +516,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (void)drawSegmentBezel:(int)aSegment highlight:(BOOL)shouldHighlight
|
||||
{
|
||||
if(aSegment < _themeStates.length)
|
||||
if (aSegment < _themeStates.length)
|
||||
{
|
||||
if (shouldHighlight)
|
||||
_themeStates[aSegment] = _themeStates[aSegment].and(CPThemeStateHighlighted);
|
||||
@@ -475,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
|
||||
@@ -508,15 +561,16 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
}
|
||||
else if (aName === "right-segment-bezel")
|
||||
{
|
||||
return CGRectMake(CGRectGetWidth([self bounds]) - contentInset.right,
|
||||
bezelInset.top,
|
||||
contentInset.right,
|
||||
height);
|
||||
// we have to FLOOR the coordinates to prevent a 1px glitch in Safari
|
||||
return CGRectMake(FLOOR(CGRectGetWidth([self bounds]) - contentInset.right),
|
||||
FLOOR(bezelInset.top),
|
||||
FLOOR(contentInset.right),
|
||||
FLOOR(height));
|
||||
}
|
||||
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)
|
||||
{
|
||||
@@ -524,7 +578,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;
|
||||
@@ -532,7 +586,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"];
|
||||
|
||||
@@ -551,14 +605,19 @@ 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],
|
||||
@@ -646,9 +705,8 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
if (i == count - 1)
|
||||
continue;
|
||||
|
||||
var borderState = _themeStates[i].and(_themeStates[i + 1]);
|
||||
|
||||
borderState = (borderState.hasThemeState(CPThemeStateSelected) && !borderState.hasThemeState(CPThemeStateHighlighted)) ? CPThemeStateSelected : CPThemeStateNormal;
|
||||
var borderState = _themeStates[i].and(_themeStates[i + 1]);
|
||||
|
||||
borderState = isDisabled ? borderState.and(CPThemeStateDisabled) : borderState;
|
||||
|
||||
@@ -678,60 +736,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 = _themeState.hasThemeState(CPThemeStateDisabled) ? _themeStates[aSegment].and(CPThemeStateDisabled) : _themeStates[aSegment],
|
||||
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];
|
||||
@@ -743,29 +774,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:@"min-size"].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:@"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
|
||||
@@ -774,19 +834,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;
|
||||
@@ -814,64 +874,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];
|
||||
@@ -881,7 +945,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
{
|
||||
[super setFont:aFont];
|
||||
|
||||
[self tileWithChangedSegment:0];
|
||||
[self tile];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -913,7 +977,7 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
|
||||
if ([aCoder containsValueForKey:CPSegmentedControlSelectedKey])
|
||||
_selectedSegment = [aCoder decodeIntForKey:CPSegmentedControlSelectedKey];
|
||||
else
|
||||
_selectedSegment = -1;
|
||||
_selectedSegment = CPNotFound;
|
||||
|
||||
if ([aCoder containsValueForKey:CPSegmentedControlTrackingModeKey])
|
||||
_trackingMode = [aCoder decodeIntForKey:CPSegmentedControlTrackingModeKey];
|
||||
@@ -921,23 +985,24 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
|
||||
_trackingMode = CPSegmentSwitchTrackingSelectOne;
|
||||
|
||||
// Here we update the themeStates array for each segments to know if there are selected or not
|
||||
for (var i = 0; i < _segments.length; i++)
|
||||
for (var i = 0; i < [self segmentCount]; i++)
|
||||
_themeStates[i] = [_segments[i] selected] ? CPThemeStateSelected : CPThemeStateNormal;
|
||||
|
||||
// We do this in a second loop because it relies on all the themeStates being set first
|
||||
for (var i = 0; i < _segments.length; i++)
|
||||
[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 / _segments.length),
|
||||
remainingWidth = FLOOR(difference / [self segmentCount]),
|
||||
widthOfAllSegments = 0;
|
||||
|
||||
for (var i = 0; i < _segments.length; i++)
|
||||
// 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++)
|
||||
{
|
||||
[self setWidth:[_segments[i] width] + remainingWidth forSegment:i];
|
||||
widthOfAllSegments += [_segments[i] width];
|
||||
var frame = [_segments[i] frame];
|
||||
frame.size.width += remainingWidth;
|
||||
|
||||
widthOfAllSegments += CGRectGetWidth(frame);
|
||||
}
|
||||
|
||||
// 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.
|
||||
@@ -945,16 +1010,16 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
|
||||
var leftOversPixel = originalWidth - (widthOfAllSegments + dividerExtraSpace);
|
||||
|
||||
// Make sure we don't make an out of range
|
||||
if (leftOversPixel < _segments.length - 1)
|
||||
if (leftOversPixel < [self segmentCount] - 1)
|
||||
{
|
||||
for (var i = 0; i < leftOversPixel; i++)
|
||||
{
|
||||
[self setWidth:[_segments[i] width] + 1 forSegment:i];
|
||||
[_segments[i] frame].size.width += 1;
|
||||
}
|
||||
}
|
||||
|
||||
[self setFrameSize:CGSizeMake(originalWidth, [self frame].size.height)];
|
||||
[self tileWithChangedSegment:0];
|
||||
[self setFrameSize:CGSizeMake(originalWidth, CGRectGetHeight([self frame]))];
|
||||
[self tile];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
+808
-150
File diff suppressed because it is too large
Load Diff
+12
-11
@@ -32,6 +32,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@global document
|
||||
|
||||
var CPSoundDelegate_sound_didFinishPlaying_ = 1 << 1;
|
||||
|
||||
@@ -65,8 +66,8 @@ CPSoundPlayBackStatePause = 2;
|
||||
unsigned _implementedDelegateMethods;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Initialization
|
||||
// MARK: -
|
||||
// MARK: Initialization
|
||||
|
||||
- (id)init
|
||||
{
|
||||
@@ -146,8 +147,8 @@ CPSoundPlayBackStatePause = 2;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegate methods
|
||||
// MARK: -
|
||||
// MARK: Delegate methods
|
||||
|
||||
/*!
|
||||
Sets the sound's delegate.
|
||||
@@ -165,8 +166,8 @@ CPSoundPlayBackStatePause = 2;
|
||||
_implementedDelegateMethods |= CPSoundDelegate_sound_didFinishPlaying_;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Events listener
|
||||
// MARK: -
|
||||
// MARK: Events listener
|
||||
|
||||
/*! @ignore
|
||||
*/
|
||||
@@ -198,8 +199,8 @@ CPSoundPlayBackStatePause = 2;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Media controls
|
||||
// MARK: -
|
||||
// MARK: Media controls
|
||||
|
||||
/*!
|
||||
Play the sound.
|
||||
@@ -323,8 +324,8 @@ CPSoundPlayBackStatePause = 2;
|
||||
_audioTag.volume = aVolume;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Accessors
|
||||
// MARK: -
|
||||
// MARK: Accessors
|
||||
|
||||
/*!
|
||||
Returns the duration in seconds of the sound.
|
||||
@@ -363,4 +364,4 @@ CPSoundPlayBackStatePause = 2;
|
||||
[_delegate sound:self didFinishPlaying:finishedPlaying];
|
||||
}
|
||||
|
||||
@end
|
||||
@end
|
||||
|
||||
+1038
-605
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,388 @@
|
||||
/*
|
||||
* CPSplitViewController.j
|
||||
*
|
||||
* Created by Daniel Boehringer on September 2, 2025.
|
||||
* Copyright (c) 2025 Daniel Boehringer. 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 "CPViewController.j"
|
||||
@import "CPSplitView.j"
|
||||
|
||||
var CPSplitViewControllerAutomaticDimension = -1.0;
|
||||
|
||||
/**
|
||||
* A container view controller that manages two or more child view
|
||||
* controllers in a split view interface.
|
||||
*
|
||||
* This class provides a controller-level abstraction for CPSplitView,
|
||||
* managing the addition, removal, and arrangement of view controllers
|
||||
* through CPSplitViewItem instances.
|
||||
*
|
||||
* This implementation was synthesized with the assistance of an LLM,
|
||||
* directed by the author.
|
||||
*/
|
||||
@implementation CPSplitViewController : CPViewController <CPSplitViewDelegate>
|
||||
{
|
||||
/** @private The underlying split view that arranges the child views. */
|
||||
CPSplitView _splitView;
|
||||
|
||||
/** @private An array of CPSplitViewItem objects managed by this controller. */
|
||||
CPMutableArray _splitViewItems;
|
||||
|
||||
/** @private The minimum thickness for sidebars to be displayed inline. */
|
||||
CPNumber _minimumThicknessForInlineSidebars;
|
||||
}
|
||||
|
||||
// MARK: - Initialization
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_splitViewItems = [CPMutableArray array];
|
||||
_minimumThicknessForInlineSidebars = 20.0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// MARK: - View Lifecycle
|
||||
|
||||
- (void)loadView
|
||||
{
|
||||
if (!_splitView)
|
||||
{
|
||||
_splitView = [[CPSplitView alloc] initWithFrame:CGRectMake(0,0,400,400)];
|
||||
[_splitView setDelegate:self];
|
||||
}
|
||||
[self setView:_splitView];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
for (var i = 0; i < [_splitViewItems count]; i++)
|
||||
{
|
||||
var viewController = [[_splitViewItems objectAtIndex:i] viewController];
|
||||
[[self splitView] addArrangedSubview:[viewController view]];
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Accessors
|
||||
|
||||
/**
|
||||
* Returns the CPSplitView instance managed by the controller.
|
||||
*
|
||||
* @returns {CPSplitView} The split view.
|
||||
*/
|
||||
- (CPSplitView)splitView
|
||||
{
|
||||
return _splitView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a custom split view for the controller.
|
||||
*
|
||||
* @param {CPSplitView} splitView The custom split view to use.
|
||||
*/
|
||||
- (void)setSplitView:(CPSplitView)splitView
|
||||
{
|
||||
if (_splitView !== splitView)
|
||||
{
|
||||
_splitView = splitView;
|
||||
[_splitView setDelegate:self];
|
||||
if ([self isViewLoaded])
|
||||
[self setView:_splitView];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of split view items.
|
||||
*
|
||||
* @returns {CPArray} The array of CPSplitViewItem objects.
|
||||
*/
|
||||
- (CPArray)splitViewItems
|
||||
{
|
||||
return _splitViewItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the array of split view items, replacing any existing items.
|
||||
*
|
||||
* @param {CPArray} splitViewItems An array of CPSplitViewItem objects.
|
||||
*/
|
||||
- (void)setSplitViewItems:(CPArray)splitViewItems
|
||||
{
|
||||
// Remove all existing items
|
||||
while ([_splitViewItems count] > 0)
|
||||
{
|
||||
[self removeSplitViewItem:[_splitViewItems lastObject]];
|
||||
}
|
||||
|
||||
// Add new items
|
||||
for (var i = 0; i < [splitViewItems count]; i++)
|
||||
{
|
||||
[self addSplitViewItem:[splitViewItems objectAtIndex:i]];
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Managing Split View Items
|
||||
|
||||
/**
|
||||
* Adds a split view item to the end of the split view.
|
||||
*
|
||||
* @param {CPSplitViewItem} splitViewItem The split view item to add.
|
||||
*/
|
||||
- (void)addSplitViewItem:(CPSplitViewItem)splitViewItem
|
||||
{
|
||||
[self insertSplitViewItem:splitViewItem atIndex:[_splitViewItems count]];
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a split view item at a specific index.
|
||||
*
|
||||
* @param {CPSplitViewItem} splitViewItem The split view item to insert.
|
||||
* @param {CPInteger} index The zero-based index at which to insert the item.
|
||||
*/
|
||||
- (void)insertSplitViewItem:(CPSplitViewItem)splitViewItem atIndex:(CPInteger)index
|
||||
{
|
||||
[splitViewItem _setSplitViewController:self];
|
||||
[_splitViewItems insertObject:splitViewItem atIndex:index];
|
||||
[self addChildViewController:[splitViewItem viewController]];
|
||||
|
||||
if ([self isViewLoaded])
|
||||
[[self splitView] insertArrangedSubview:[[splitViewItem viewController] view] atIndex:index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified split view item.
|
||||
*
|
||||
* @param {CPSplitViewItem} splitViewItem The split view item to remove.
|
||||
*/
|
||||
- (void)removeSplitViewItem:(CPSplitViewItem)splitViewItem
|
||||
{
|
||||
var viewController = [splitViewItem viewController];
|
||||
if ([self isViewLoaded])
|
||||
[[viewController view] removeFromSuperview];
|
||||
|
||||
[viewController removeFromParentViewController];
|
||||
[splitViewItem _setSplitViewController:nil];
|
||||
[_splitViewItems removeObject:splitViewItem];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the split view item associated with a given view controller.
|
||||
*
|
||||
* @param {CPViewController} viewController The view controller to find.
|
||||
* @returns {CPSplitViewItem | null} The corresponding split view item, or nil if not found.
|
||||
*/
|
||||
- (CPSplitViewItem)splitViewItemForViewController:(CPViewController)viewController
|
||||
{
|
||||
for (var i = 0; i < [_splitViewItems count]; i++)
|
||||
{
|
||||
var item = [_splitViewItems objectAtIndex:i];
|
||||
if ([item viewController] === viewController)
|
||||
return item;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
// MARK: - Managing Sidebars and Inspectors
|
||||
|
||||
/**
|
||||
* Toggles the collapsed state of the first split view item, typically a sidebar.
|
||||
*
|
||||
* @param {id} sender The object that initiated the action.
|
||||
*/
|
||||
- (void)toggleSidebar:(id)sender
|
||||
{
|
||||
if ([_splitViewItems count] > 0)
|
||||
{
|
||||
var sidebarItem = [_splitViewItems objectAtIndex:0];
|
||||
[sidebarItem setCollapsed:![sidebarItem isCollapsed]];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the collapsed state of the last split view item, typically an inspector.
|
||||
*
|
||||
* @param {id} sender The object that initiated the action.
|
||||
*/
|
||||
- (void)toggleInspector:(id)sender
|
||||
{
|
||||
if ([_splitViewItems count] > 1)
|
||||
{
|
||||
var inspectorItem = [_splitViewItems lastObject];
|
||||
[inspectorItem setCollapsed:![inspectorItem isCollapsed]];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum thickness for sidebars to be displayed inline.
|
||||
*
|
||||
* @returns {CPNumber} The minimum thickness.
|
||||
*/
|
||||
- (CPNumber)minimumThicknessForInlineSidebars
|
||||
{
|
||||
return _minimumThicknessForInlineSidebars;
|
||||
}
|
||||
|
||||
// MARK: - CPSplitViewDelegate Methods
|
||||
|
||||
// Note: A more complete implementation would forward these delegate methods
|
||||
// to a separate delegate property on the CPSplitViewController itself.
|
||||
// For now, these are stubbed to demonstrate where they would be handled.
|
||||
|
||||
- (BOOL)splitView:(CPSplitView)splitView canCollapseSubview:(CPView)subview
|
||||
{
|
||||
// Default behavior: allow all subviews to be collapsed.
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (CGFloat)splitView:(CPSplitView)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(CPInteger)dividerIndex
|
||||
{
|
||||
return proposedMinimumPosition;
|
||||
}
|
||||
|
||||
- (CGFloat)splitView:(CPSplitView)splitView constrainMaxCoordinate:(CGFloat)proposedMaximumPosition ofSubviewAt:(CPInteger)dividerIndex
|
||||
{
|
||||
return proposedMaximumPosition;
|
||||
}
|
||||
|
||||
- (CGRect)splitView:(CPSplitView)splitView effectiveRect:(CGRect)proposedEffectiveRect forDrawnRect:(CGRect)drawnRect ofDividerAtIndex:(CPInteger)dividerIndex
|
||||
{
|
||||
// Default behavior: return the proposed rectangle.
|
||||
// This can be overridden to provide a larger or custom hit area for the divider.
|
||||
return proposedEffectiveRect;
|
||||
}
|
||||
|
||||
- (void)splitViewDidResizeSubviews:(CPNotification)notification
|
||||
{
|
||||
// Can be used to respond to user-initiated resizing.
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* An object that manages a view controller within a CPSplitViewController.
|
||||
*
|
||||
* A CPSplitViewItem acts as a wrapper around a CPViewController,
|
||||
* maintaining properties like its collapsed state within the parent
|
||||
* split view controller.
|
||||
*/
|
||||
@implementation CPSplitViewItem : CPObject
|
||||
{
|
||||
/** @private The view controller managed by this item. */
|
||||
CPViewController _viewController;
|
||||
|
||||
/** @private A boolean indicating whether the item is collapsed. */
|
||||
BOOL _isCollapsed;
|
||||
|
||||
/** @private A weak reference to the owning split view controller. */
|
||||
CPSplitViewController _splitViewController;
|
||||
}
|
||||
|
||||
// MARK: - Class Methods
|
||||
|
||||
/**
|
||||
* Creates and returns a new split view item with the specified view controller.
|
||||
*
|
||||
* @param {CPViewController} viewController The view controller for the new item.
|
||||
* @returns {instancetype} A new CPSplitViewItem instance.
|
||||
*/
|
||||
+ (instancetype)splitViewItemWithViewController:(CPViewController)viewController
|
||||
{
|
||||
return [[self alloc] initWithViewController:viewController];
|
||||
}
|
||||
|
||||
// MARK: - Initialization
|
||||
|
||||
/**
|
||||
* Initializes a new split view item with the specified view controller.
|
||||
*
|
||||
* @param {CPViewController} viewController The view controller for the new item.
|
||||
* @returns {id} The initialized CPSplitViewItem instance.
|
||||
*/
|
||||
- (id)initWithViewController:(CPViewController)viewController
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_viewController = viewController;
|
||||
_isCollapsed = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// MARK: - Accessors
|
||||
|
||||
/**
|
||||
* Returns the view controller associated with the item.
|
||||
*
|
||||
* @returns {CPViewController} The associated view controller.
|
||||
*/
|
||||
- (CPViewController)viewController
|
||||
{
|
||||
return _viewController;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean value indicating whether the item is collapsed.
|
||||
*
|
||||
* @returns {BOOL} YES if the item is collapsed, otherwise NO.
|
||||
*/
|
||||
- (BOOL)isCollapsed
|
||||
{
|
||||
return _isCollapsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the collapsed state of the item.
|
||||
* When collapsed, the view controller's view is hidden.
|
||||
*
|
||||
* @param {BOOL} shouldCollapse YES to collapse the item, NO to expand it.
|
||||
*/
|
||||
- (void)setCollapsed:(BOOL)shouldCollapse
|
||||
{
|
||||
if (_isCollapsed === shouldCollapse)
|
||||
return;
|
||||
|
||||
_isCollapsed = shouldCollapse;
|
||||
[[_viewController view] setHidden:shouldCollapse];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the split view controller that owns this item.
|
||||
*
|
||||
* @returns {CPSplitViewController | null} The parent split view controller.
|
||||
*/
|
||||
- (CPSplitViewController)splitViewController
|
||||
{
|
||||
return _splitViewController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Sets the owning split view controller. This method is for internal use by
|
||||
* CPSplitViewController.
|
||||
*
|
||||
* @param {CPSplitViewController} splitViewController The parent controller.
|
||||
*/
|
||||
- (void)_setSplitViewController:(CPSplitViewController)splitViewController
|
||||
{
|
||||
_splitViewController = splitViewController;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,815 @@
|
||||
/*
|
||||
* CPStackView.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Daniel Boehringer.
|
||||
* Copyright 2025, 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* PLACEHOLDER IMPLEMENTATION — READ BEFORE USE OR MODIFICATION.
|
||||
*
|
||||
* This class lays out views by direct, procedural arithmetic. It has no
|
||||
* constraint solver. It cannot compress, expand, or negotiate space among
|
||||
* views the way NSStackView does; it only places views at their existing
|
||||
* frame size, in order, separated by fixed spacing.
|
||||
*
|
||||
* Known, accepted limitations:
|
||||
* - `distribution` is stored but has no effect on layout. Fill,
|
||||
* FillEqually, FillProportionally, and EqualSpacing are unimplemented.
|
||||
* - Center-gravity views are clamped against the Leading edge only; if
|
||||
* Leading + Center + Trailing content overflows the container, Center
|
||||
* views can overlap Trailing views instead of compressing.
|
||||
* - `visibilityPriority:forView:` only supports the two extreme values
|
||||
* (MustHold / NotVisible). Intermediate priorities are accepted but
|
||||
* have no defined effect.
|
||||
* - No guarantee is made of correctness beyond what a single manual
|
||||
* test (Tests/Manual/CPStackViewTest) exercises: orientation, the
|
||||
* three gravity areas, alignment switching, spacing, and hidden-view
|
||||
* detachment. Insertion, removal, custom spacing, and the CPCoding
|
||||
* archive path are implemented but not verified by that test.
|
||||
*
|
||||
* This exists to give AppKit a working CPStackView symbol now, not to be
|
||||
* a durable design. It is expected to be replaced by a constraint-solver
|
||||
* based implementation (Kiwi.js) when time permits. Do not build on its
|
||||
* internal layout algorithm as if it were a stable foundation.
|
||||
*/
|
||||
|
||||
@import "CPView.j"
|
||||
@import <Foundation/CPMapTable.j>
|
||||
|
||||
// MARK: -
|
||||
// MARK: Minimal local type definitions
|
||||
//
|
||||
// These types support this file only. They are not shared with the rest
|
||||
// of AppKit. A future constraint-solver based Auto Layout engine will
|
||||
// replace them. Numeric values match the equivalent Cocoa constants
|
||||
// (NSUserInterfaceLayoutOrientation, NSLayoutAttribute) so that a later,
|
||||
// solver-based CPLayoutAttribute can reuse these numbers without a
|
||||
// renumbering pass.
|
||||
|
||||
@typedef CPUserInterfaceLayoutOrientation
|
||||
CPUserInterfaceLayoutOrientationHorizontal = 0;
|
||||
CPUserInterfaceLayoutOrientationVertical = 1;
|
||||
|
||||
@typedef CPLayoutAttribute
|
||||
CPLayoutAttributeLeft = 1;
|
||||
CPLayoutAttributeRight = 2;
|
||||
CPLayoutAttributeTop = 3;
|
||||
CPLayoutAttributeBottom = 4;
|
||||
CPLayoutAttributeLeading = 5;
|
||||
CPLayoutAttributeTrailing = 6;
|
||||
CPLayoutAttributeWidth = 7;
|
||||
CPLayoutAttributeHeight = 8;
|
||||
CPLayoutAttributeCenterX = 9;
|
||||
CPLayoutAttributeCenterY = 10;
|
||||
|
||||
@typedef CPEdgeInsets
|
||||
|
||||
/*!
|
||||
Creates a CPEdgeInsets. Argument order matches Cocoa's NSEdgeInsetsMake
|
||||
(top, left, bottom, right). Storage reuses the existing CGInset struct,
|
||||
whose field order is (top, right, bottom, left).
|
||||
*/
|
||||
function CPEdgeInsetsMake(top, left, bottom, right)
|
||||
{
|
||||
return CGInsetMake(top, right, bottom, left);
|
||||
}
|
||||
|
||||
function CPEdgeInsetsEqualToEdgeInsets(lhsInsets, rhsInsets)
|
||||
{
|
||||
return CGInsetEqualToInset(lhsInsets, rhsInsets);
|
||||
}
|
||||
|
||||
// Gravity Areas
|
||||
@typedef CPStackViewGravity
|
||||
CPStackViewGravityTop = 1;
|
||||
CPStackViewGravityLeading = 1;
|
||||
CPStackViewGravityCenter = 2;
|
||||
CPStackViewGravityBottom = 3;
|
||||
CPStackViewGravityTrailing = 3;
|
||||
|
||||
// Distribution (Deprecated in modern macOS, but kept for compatibility/logic)
|
||||
@typedef CPStackViewDistribution
|
||||
CPStackViewDistributionGravityAreas = 0;
|
||||
CPStackViewDistributionFill = 1;
|
||||
CPStackViewDistributionFillEqually = 2;
|
||||
CPStackViewDistributionFillProportionally = 3;
|
||||
CPStackViewDistributionEqualSpacing = 4;
|
||||
CPStackViewDistributionEqualCentering = 5;
|
||||
|
||||
// Visibility Priority
|
||||
@typedef CPStackViewVisibilityPriority
|
||||
CPStackViewVisibilityPriorityMustHold = 1000.0;
|
||||
CPStackViewVisibilityPriorityNotVisible = 0.0;
|
||||
|
||||
var CPStackViewSpacingUseDefault = 3.40282347e+38; // FLT_MAX
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPStackView
|
||||
|
||||
CPStackView arranges an array of views horizontally or vertically and updates
|
||||
their placement and sizing when the window size changes.
|
||||
|
||||
Unlike a simple list, CPStackView supports "Gravity Areas" (Leading, Center, Trailing),
|
||||
allowing you to pin groups of views to specific sections of the layout.
|
||||
*/
|
||||
@implementation CPStackView : CPView
|
||||
{
|
||||
CPUserInterfaceLayoutOrientation _orientation;
|
||||
CPLayoutAttribute _alignment;
|
||||
CPStackViewDistribution _distribution;
|
||||
float _spacing;
|
||||
CPEdgeInsets _edgeInsets;
|
||||
|
||||
BOOL _detachesHiddenViews;
|
||||
|
||||
// View Storage by Gravity
|
||||
CPMutableArray _viewsLeading;
|
||||
CPMutableArray _viewsCenter;
|
||||
CPMutableArray _viewsTrailing;
|
||||
|
||||
// Internal cache of all arranged subviews to maintain order for hittesting/iterating
|
||||
CPMutableArray _arrangedSubviews;
|
||||
|
||||
// Custom Spacing storage
|
||||
CPMapTable _customSpacings;
|
||||
|
||||
// Visibility Priorities
|
||||
CPMapTable _visibilityPriorities;
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// MARK: Initialization
|
||||
|
||||
+ (CPStackView)stackViewWithViews:(CPArray)views
|
||||
{
|
||||
var stackView = [[CPStackView alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
for (var i = 0, count = [views count]; i < count; i++)
|
||||
[stackView addView:views[i] inGravity:CPStackViewGravityLeading];
|
||||
|
||||
return stackView;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
if (self = [super initWithFrame:aFrame])
|
||||
{
|
||||
_orientation = CPUserInterfaceLayoutOrientationHorizontal;
|
||||
_alignment = CPLayoutAttributeCenterY; // Default alignment
|
||||
_distribution = CPStackViewDistributionGravityAreas;
|
||||
_spacing = 8.0; // Default Cocoa spacing
|
||||
_edgeInsets = CPEdgeInsetsMake(0, 0, 0, 0);
|
||||
_detachesHiddenViews = YES;
|
||||
|
||||
_viewsLeading = [[CPMutableArray alloc] init];
|
||||
_viewsCenter = [[CPMutableArray alloc] init];
|
||||
_viewsTrailing = [[CPMutableArray alloc] init];
|
||||
_arrangedSubviews = [[CPMutableArray alloc] init];
|
||||
|
||||
_customSpacings = [[CPMapTable alloc] init];
|
||||
_visibilityPriorities = [[CPMapTable alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// MARK: Configuration
|
||||
|
||||
/*!
|
||||
The horizontal or vertical layout direction of the stack view.
|
||||
*/
|
||||
- (CPUserInterfaceLayoutOrientation)orientation
|
||||
{
|
||||
return _orientation;
|
||||
}
|
||||
|
||||
- (void)setOrientation:(CPUserInterfaceLayoutOrientation)anOrientation
|
||||
{
|
||||
if (_orientation === anOrientation)
|
||||
return;
|
||||
|
||||
_orientation = anOrientation;
|
||||
|
||||
// Reset default alignment based on new orientation if needed,
|
||||
// though usually developer sets alignment explicitly.
|
||||
// If switching to Vertical, CenterY makes less sense, usually CenterX.
|
||||
if (_orientation === CPUserInterfaceLayoutOrientationVertical)
|
||||
{
|
||||
if (_alignment === CPLayoutAttributeCenterY)
|
||||
_alignment = CPLayoutAttributeCenterX;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_alignment === CPLayoutAttributeCenterX)
|
||||
_alignment = CPLayoutAttributeCenterY;
|
||||
}
|
||||
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
The view alignment within the stack view.
|
||||
Common values:
|
||||
Horizontal: CPLayoutAttributeTop, CPLayoutAttributeBottom, CPLayoutAttributeCenterY, CPLayoutAttributeHeight (fill)
|
||||
Vertical: CPLayoutAttributeLeading, CPLayoutAttributeTrailing, CPLayoutAttributeCenterX, CPLayoutAttributeWidth (fill)
|
||||
*/
|
||||
- (CPLayoutAttribute)alignment
|
||||
{
|
||||
return _alignment;
|
||||
}
|
||||
|
||||
- (void)setAlignment:(CPLayoutAttribute)anAlignment
|
||||
{
|
||||
if (_alignment === anAlignment)
|
||||
return;
|
||||
|
||||
_alignment = anAlignment;
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
The distribution mode for the stack view.
|
||||
@note Not yet applied to layout. All views are laid out at their
|
||||
existing frame size regardless of this value, pending the
|
||||
constraint-solver based layout engine. The value is stored and
|
||||
returned so client code can read back what was set.
|
||||
*/
|
||||
- (CPStackViewDistribution)distribution
|
||||
{
|
||||
return _distribution;
|
||||
}
|
||||
|
||||
- (void)setDistribution:(CPStackViewDistribution)aDistribution
|
||||
{
|
||||
if (_distribution === aDistribution)
|
||||
return;
|
||||
|
||||
_distribution = aDistribution;
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
The minimum spacing, in points, between adjacent views in the stack view.
|
||||
*/
|
||||
- (float)spacing
|
||||
{
|
||||
return _spacing;
|
||||
}
|
||||
|
||||
- (void)setSpacing:(float)aSpacing
|
||||
{
|
||||
if (_spacing === aSpacing)
|
||||
return;
|
||||
|
||||
_spacing = aSpacing;
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
The geometric padding, in points, inside the stack view, surrounding its views.
|
||||
*/
|
||||
- (CPEdgeInsets)edgeInsets
|
||||
{
|
||||
return _edgeInsets;
|
||||
}
|
||||
|
||||
- (void)setEdgeInsets:(CPEdgeInsets)insets
|
||||
{
|
||||
if (CPEdgeInsetsEqualToEdgeInsets(_edgeInsets, insets))
|
||||
return;
|
||||
|
||||
_edgeInsets = insets;
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
A Boolean value that indicates whether the stack view removes hidden views from its view hierarchy.
|
||||
*/
|
||||
- (BOOL)detachesHiddenViews
|
||||
{
|
||||
return _detachesHiddenViews;
|
||||
}
|
||||
|
||||
- (void)setDetachesHiddenViews:(BOOL)shouldDetach
|
||||
{
|
||||
if (_detachesHiddenViews === shouldDetach)
|
||||
return;
|
||||
|
||||
_detachesHiddenViews = shouldDetach;
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// MARK: Managing Views in Gravity Areas
|
||||
|
||||
- (CPArray)_containerForGravity:(CPStackViewGravity)gravity
|
||||
{
|
||||
if (gravity === CPStackViewGravityCenter)
|
||||
return _viewsCenter;
|
||||
else if (gravity === CPStackViewGravityTrailing) // or Bottom
|
||||
return _viewsTrailing;
|
||||
|
||||
return _viewsLeading; // Leading or Top
|
||||
}
|
||||
|
||||
/*!
|
||||
Rebuilds _arrangedSubviews from the three gravity containers, in
|
||||
Leading, Center, Trailing order. Call after any change to a gravity
|
||||
container so _arrangedSubviews stays a correct, single source of truth
|
||||
for ordering, rather than an incrementally and separately maintained
|
||||
(and error-prone) copy.
|
||||
*/
|
||||
- (void)_rebuildArrangedSubviews
|
||||
{
|
||||
_arrangedSubviews = [[CPMutableArray alloc] init];
|
||||
[_arrangedSubviews addObjectsFromArray:_viewsLeading];
|
||||
[_arrangedSubviews addObjectsFromArray:_viewsCenter];
|
||||
[_arrangedSubviews addObjectsFromArray:_viewsTrailing];
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds a view to the end of the stack view gravity area.
|
||||
*/
|
||||
- (void)addView:(CPView)aView inGravity:(CPStackViewGravity)gravity
|
||||
{
|
||||
var container = [self _containerForGravity:gravity];
|
||||
|
||||
// Check if view is already in a container
|
||||
if ([_arrangedSubviews containsObject:aView])
|
||||
[self removeView:aView];
|
||||
|
||||
[container addObject:aView];
|
||||
[self _rebuildArrangedSubviews];
|
||||
|
||||
// Add as actual subview
|
||||
if ([aView superview] !== self)
|
||||
[self addSubview:aView];
|
||||
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds a view to a stack view gravity area at a specified index position.
|
||||
*/
|
||||
- (void)insertView:(CPView)aView atIndex:(CPInteger)index inGravity:(CPStackViewGravity)gravity
|
||||
{
|
||||
var container = [self _containerForGravity:gravity];
|
||||
|
||||
if ([_arrangedSubviews containsObject:aView])
|
||||
[self removeView:aView];
|
||||
|
||||
if (index >= [container count])
|
||||
[container addObject:aView];
|
||||
else
|
||||
[container insertObject:aView atIndex:index];
|
||||
|
||||
[self _rebuildArrangedSubviews];
|
||||
|
||||
if ([aView superview] !== self)
|
||||
[self addSubview:aView];
|
||||
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
Specifies an array of views for a specified gravity area in the stack view, replacing any previous views in that area.
|
||||
*/
|
||||
- (void)setViews:(CPArray)views inGravity:(CPStackViewGravity)gravity
|
||||
{
|
||||
var container = [self _containerForGravity:gravity];
|
||||
|
||||
// Remove old views from superview
|
||||
for (var i = 0; i < [container count]; i++)
|
||||
[container[i] removeFromSuperview];
|
||||
|
||||
[container removeAllObjects];
|
||||
|
||||
for (var i = 0; i < [views count]; i++)
|
||||
{
|
||||
var newView = views[i];
|
||||
[container addObject:newView];
|
||||
[self addSubview:newView];
|
||||
}
|
||||
|
||||
[self _rebuildArrangedSubviews];
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes a specified view from the stack view.
|
||||
*/
|
||||
- (void)removeView:(CPView)aView
|
||||
{
|
||||
if (![_arrangedSubviews containsObject:aView])
|
||||
return;
|
||||
|
||||
[_viewsLeading removeObject:aView];
|
||||
[_viewsCenter removeObject:aView];
|
||||
[_viewsTrailing removeObject:aView];
|
||||
[self _rebuildArrangedSubviews];
|
||||
|
||||
[aView removeFromSuperview];
|
||||
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the array of views in the specified gravity area in the stack view.
|
||||
*/
|
||||
- (CPArray)viewsInGravity:(CPStackViewGravity)gravity
|
||||
{
|
||||
return [[self _containerForGravity:gravity] copy];
|
||||
}
|
||||
|
||||
/*!
|
||||
The array of views arranged by the stack view.
|
||||
*/
|
||||
- (CPArray)arrangedSubviews
|
||||
{
|
||||
return [_arrangedSubviews copy];
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds the specified view to the end of the arranged subviews list.
|
||||
(Defaults to Leading gravity if not specified).
|
||||
*/
|
||||
- (void)addArrangedSubview:(CPView)view
|
||||
{
|
||||
[self addView:view inGravity:CPStackViewGravityLeading];
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes the provided view from the stack’s array of arranged subviews.
|
||||
*/
|
||||
- (void)removeArrangedSubview:(CPView)view
|
||||
{
|
||||
[self removeView:view];
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// MARK: Custom Spacing
|
||||
|
||||
- (float)customSpacingAfterView:(CPView)aView
|
||||
{
|
||||
var val = [_customSpacings objectForKey:aView];
|
||||
if (val)
|
||||
return [val floatValue];
|
||||
|
||||
return CPStackViewSpacingUseDefault;
|
||||
}
|
||||
|
||||
- (void)setCustomSpacing:(float)spacing afterView:(CPView)aView
|
||||
{
|
||||
if (spacing === CPStackViewSpacingUseDefault)
|
||||
[_customSpacings removeObjectForKey:aView];
|
||||
else
|
||||
[_customSpacings setObject:spacing forKey:aView];
|
||||
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
|
||||
- (float)_spacingAfterView:(CPView)aView
|
||||
{
|
||||
var custom = [self customSpacingAfterView:aView];
|
||||
if (custom !== CPStackViewSpacingUseDefault)
|
||||
return custom;
|
||||
return _spacing;
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// MARK: Visibility Priority
|
||||
|
||||
- (void)setVisibilityPriority:(float)priority forView:(CPView)aView
|
||||
{
|
||||
[_visibilityPriorities setObject:priority forKey:aView];
|
||||
|
||||
if (priority === CPStackViewVisibilityPriorityNotVisible)
|
||||
{
|
||||
[aView setHidden:YES];
|
||||
}
|
||||
else if (priority === CPStackViewVisibilityPriorityMustHold)
|
||||
{
|
||||
[aView setHidden:NO];
|
||||
}
|
||||
// Note: Intermediate priorities require complex constraint logic
|
||||
// or a multi-pass layout system to determine fitting, which is
|
||||
// simplified here to basic Hidden/Visible states.
|
||||
|
||||
[self setNeedsLayout:YES];
|
||||
}
|
||||
|
||||
- (float)visibilityPriorityForView:(CPView)aView
|
||||
{
|
||||
var val = [_visibilityPriorities objectForKey:aView];
|
||||
if (val)
|
||||
return [val floatValue];
|
||||
return CPStackViewVisibilityPriorityMustHold;
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// MARK: Layout
|
||||
|
||||
- (void)resizeSubviewsWithOldSize:(CGSize)oldSize
|
||||
{
|
||||
[self layoutSubviews];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
if (_orientation === CPUserInterfaceLayoutOrientationVertical)
|
||||
[self _layoutVertical];
|
||||
else
|
||||
[self _layoutHorizontal];
|
||||
}
|
||||
|
||||
- (void)_layoutHorizontal
|
||||
{
|
||||
var bounds = [self bounds],
|
||||
availWidth = CGRectGetWidth(bounds) - _edgeInsets.left - _edgeInsets.right,
|
||||
availHeight = CGRectGetHeight(bounds) - _edgeInsets.top - _edgeInsets.bottom,
|
||||
currentX = _edgeInsets.left;
|
||||
|
||||
// 1. Layout Leading Views
|
||||
currentX = [self _layoutViews:_viewsLeading startOffset:currentX availableOrthogonalSize:availHeight direction:1];
|
||||
|
||||
// 2. Layout Trailing Views
|
||||
// We layout backwards from the right
|
||||
var startRight = CGRectGetWidth(bounds) - _edgeInsets.right;
|
||||
[self _layoutViews:_viewsTrailing startOffset:startRight availableOrthogonalSize:availHeight direction:-1];
|
||||
|
||||
// 3. Layout Center Views
|
||||
if ([_viewsCenter count] > 0)
|
||||
{
|
||||
// Calculate total width of center stack
|
||||
var centerStackWidth = 0.0;
|
||||
for (var i = 0; i < [_viewsCenter count]; i++)
|
||||
{
|
||||
var view = _viewsCenter[i];
|
||||
if (_detachesHiddenViews && [view isHidden]) continue;
|
||||
|
||||
centerStackWidth += CGRectGetWidth([view frame]);
|
||||
if (i < [_viewsCenter count] - 1)
|
||||
centerStackWidth += [self _spacingAfterView:view];
|
||||
}
|
||||
|
||||
var centerStart = (CGRectGetWidth(bounds) / 2.0) - (centerStackWidth / 2.0);
|
||||
|
||||
// Clamp to prevent overlap with Leading (simplified collision logic)
|
||||
// ideally stack view compresses views, but here we just shift/clip
|
||||
if (centerStart < currentX)
|
||||
centerStart = currentX;
|
||||
|
||||
[self _layoutViews:_viewsCenter startOffset:centerStart availableOrthogonalSize:availHeight direction:1];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_layoutVertical
|
||||
{
|
||||
var bounds = [self bounds],
|
||||
availWidth = CGRectGetWidth(bounds) - _edgeInsets.left - _edgeInsets.right,
|
||||
availHeight = CGRectGetHeight(bounds) - _edgeInsets.top - _edgeInsets.bottom,
|
||||
currentY = _edgeInsets.top;
|
||||
|
||||
// 1. Layout Top (Leading) Views
|
||||
currentY = [self _layoutViews:_viewsLeading startOffset:currentY availableOrthogonalSize:availWidth direction:1];
|
||||
|
||||
// 2. Layout Bottom (Trailing) Views
|
||||
var startBottom = CGRectGetHeight(bounds) - _edgeInsets.bottom;
|
||||
[self _layoutViews:_viewsTrailing startOffset:startBottom availableOrthogonalSize:availWidth direction:-1];
|
||||
|
||||
// 3. Layout Center Views
|
||||
if ([_viewsCenter count] > 0)
|
||||
{
|
||||
var centerStackHeight = 0.0;
|
||||
for (var i = 0; i < [_viewsCenter count]; i++)
|
||||
{
|
||||
var view = _viewsCenter[i];
|
||||
if (_detachesHiddenViews && [view isHidden]) continue;
|
||||
|
||||
centerStackHeight += CGRectGetHeight([view frame]);
|
||||
if (i < [_viewsCenter count] - 1)
|
||||
centerStackHeight += [self _spacingAfterView:view];
|
||||
}
|
||||
|
||||
var centerStart = (CGRectGetHeight(bounds) / 2.0) - (centerStackHeight / 2.0);
|
||||
|
||||
if (centerStart < currentY)
|
||||
centerStart = currentY;
|
||||
|
||||
[self _layoutViews:_viewsCenter startOffset:centerStart availableOrthogonalSize:availWidth direction:1];
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to layout a specific array of views in one direction
|
||||
// Returns the ending offset
|
||||
- (float)_layoutViews:(CPArray)views startOffset:(float)offset availableOrthogonalSize:(float)orthoSize direction:(int)dir
|
||||
{
|
||||
var cursor = offset;
|
||||
var isVert = (_orientation === CPUserInterfaceLayoutOrientationVertical);
|
||||
|
||||
// If direction is -1 (Trailing/Bottom), we iterate backwards
|
||||
// However, the standard behavior for trailing gravity is that the *last* view added is at the *end*.
|
||||
// Leading: [A] [B] ->
|
||||
// Trailing: -> [C] [D] (where D is rightmost)
|
||||
// To support Trailing logic: We start at Right Edge, move left by Width(D), place D, move left by Spacing...
|
||||
|
||||
var count = [views count];
|
||||
if (count === 0) return cursor;
|
||||
|
||||
// If direction is negative (Trailing), we process list in reverse order to stack them from edge inwards
|
||||
var i = (dir === 1) ? 0 : count - 1;
|
||||
var limit = (dir === 1) ? count : -1;
|
||||
var step = (dir === 1) ? 1 : -1;
|
||||
|
||||
// Spacing is applied as a gap *before* placing an element (except the
|
||||
// first placed one), rather than trailing off the end after the last
|
||||
// element. This keeps the returned cursor at the true content edge,
|
||||
// with no phantom spacing past the final view.
|
||||
var hasPlacedAny = false;
|
||||
var pendingSpacing = 0;
|
||||
|
||||
for (; i !== limit; i += step)
|
||||
{
|
||||
var view = views[i];
|
||||
|
||||
if (_detachesHiddenViews && [view isHidden])
|
||||
continue;
|
||||
|
||||
if (hasPlacedAny)
|
||||
cursor += (dir === 1) ? pendingSpacing : -pendingSpacing;
|
||||
|
||||
var viewFrame = [view frame];
|
||||
var viewSizePrimary = isVert ? CGRectGetHeight(viewFrame) : CGRectGetWidth(viewFrame);
|
||||
|
||||
// Handle Alignment (Orthogonal Axis)
|
||||
var orthoPos = 0.0;
|
||||
var viewOrthoSize = isVert ? CGRectGetWidth(viewFrame) : CGRectGetHeight(viewFrame);
|
||||
|
||||
// Apply Stretch/Fill Alignment
|
||||
if (isVert)
|
||||
{
|
||||
// Vertical Stack, dealing with Width
|
||||
if (_alignment === CPLayoutAttributeWidth || _alignment === CPLayoutAttributeLeading || _alignment === CPLayoutAttributeTrailing)
|
||||
{
|
||||
// Note: CPLayoutAttributeLeading/Trailing in this context implies filling width usually,
|
||||
// or aligning to edges. Let's assume Width/Fill for Leading/Trailing/Left/Right
|
||||
// in this simplified implementation, or strictly left/right.
|
||||
|
||||
if (_alignment === CPLayoutAttributeWidth || _alignment === CPLayoutAttributeLeft || _alignment === CPLayoutAttributeLeading)
|
||||
{
|
||||
// Fill width if explicit, or just align left
|
||||
if (_alignment === CPLayoutAttributeWidth) viewOrthoSize = orthoSize;
|
||||
orthoPos = _edgeInsets.left;
|
||||
}
|
||||
else if (_alignment === CPLayoutAttributeRight || _alignment === CPLayoutAttributeTrailing)
|
||||
{
|
||||
orthoPos = _edgeInsets.left + (orthoSize - viewOrthoSize);
|
||||
}
|
||||
else // CenterX
|
||||
{
|
||||
orthoPos = _edgeInsets.left + (orthoSize - viewOrthoSize) / 2.0;
|
||||
}
|
||||
}
|
||||
else // Default CenterX
|
||||
{
|
||||
orthoPos = _edgeInsets.left + (orthoSize - viewOrthoSize) / 2.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Horizontal Stack, dealing with Height
|
||||
if (_alignment === CPLayoutAttributeHeight || _alignment === CPLayoutAttributeTop || _alignment === CPLayoutAttributeBottom)
|
||||
{
|
||||
if (_alignment === CPLayoutAttributeHeight)
|
||||
{
|
||||
viewOrthoSize = orthoSize;
|
||||
orthoPos = _edgeInsets.top;
|
||||
}
|
||||
else if (_alignment === CPLayoutAttributeTop)
|
||||
{
|
||||
orthoPos = _edgeInsets.top;
|
||||
}
|
||||
else if (_alignment === CPLayoutAttributeBottom)
|
||||
{
|
||||
orthoPos = _edgeInsets.top + (orthoSize - viewOrthoSize);
|
||||
}
|
||||
else // CenterY
|
||||
{
|
||||
orthoPos = _edgeInsets.top + (orthoSize - viewOrthoSize) / 2.0;
|
||||
}
|
||||
}
|
||||
else // Default CenterY
|
||||
{
|
||||
orthoPos = _edgeInsets.top + (orthoSize - viewOrthoSize) / 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate Position
|
||||
var originX = 0.0, originY = 0.0;
|
||||
var sizeW = 0.0, sizeH = 0.0;
|
||||
|
||||
if (isVert)
|
||||
{
|
||||
// Vertical
|
||||
sizeH = viewSizePrimary;
|
||||
sizeW = viewOrthoSize;
|
||||
originX = orthoPos;
|
||||
|
||||
if (dir === 1) {
|
||||
originY = cursor;
|
||||
cursor += sizeH;
|
||||
} else {
|
||||
cursor -= sizeH;
|
||||
originY = cursor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Horizontal
|
||||
sizeW = viewSizePrimary;
|
||||
sizeH = viewOrthoSize;
|
||||
originY = orthoPos;
|
||||
|
||||
if (dir === 1) {
|
||||
originX = cursor;
|
||||
cursor += sizeW;
|
||||
} else {
|
||||
cursor -= sizeW;
|
||||
originX = cursor;
|
||||
}
|
||||
}
|
||||
|
||||
[view setFrame:CGRectMake(originX, originY, sizeW, sizeH)];
|
||||
|
||||
pendingSpacing = [self _spacingAfterView:view];
|
||||
hasPlacedAny = true;
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// MARK: CPCoding
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super initWithCoder:aCoder];
|
||||
if (self)
|
||||
{
|
||||
_orientation = [aCoder decodeIntForKey:@"CPStackViewOrientation"];
|
||||
_alignment = [aCoder decodeIntForKey:@"CPStackViewAlignment"];
|
||||
_distribution = [aCoder decodeIntForKey:@"CPStackViewDistribution"];
|
||||
_spacing = [aCoder decodeFloatForKey:@"CPStackViewSpacing"];
|
||||
_edgeInsets = [aCoder decodeObjectForKey:@"CPStackViewEdgeInsets"]; // Assuming CPEdgeInsets supports obj coding or manual decode
|
||||
if (!_edgeInsets) _edgeInsets = CPEdgeInsetsMake(0,0,0,0);
|
||||
|
||||
_detachesHiddenViews = [aCoder decodeBoolForKey:@"CPStackViewDetachesHiddenViews"];
|
||||
|
||||
_viewsLeading = [aCoder decodeObjectForKey:@"CPStackViewViewsLeading"] || [];
|
||||
_viewsCenter = [aCoder decodeObjectForKey:@"CPStackViewViewsCenter"] || [];
|
||||
_viewsTrailing = [aCoder decodeObjectForKey:@"CPStackViewViewsTrailing"] || [];
|
||||
|
||||
// Rebuild arranged subviews cache
|
||||
[self _rebuildArrangedSubviews];
|
||||
|
||||
_customSpacings = [aCoder decodeObjectForKey:@"CPStackViewCustomSpacings"] || [[CPMapTable alloc] init];
|
||||
_visibilityPriorities = [[CPMapTable alloc] init]; // usually not persisted
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
[aCoder encodeInt:_orientation forKey:@"CPStackViewOrientation"];
|
||||
[aCoder encodeInt:_alignment forKey:@"CPStackViewAlignment"];
|
||||
[aCoder encodeInt:_distribution forKey:@"CPStackViewDistribution"];
|
||||
[aCoder encodeFloat:_spacing forKey:@"CPStackViewSpacing"];
|
||||
[aCoder encodeObject:_edgeInsets forKey:@"CPStackViewEdgeInsets"];
|
||||
[aCoder encodeBool:_detachesHiddenViews forKey:@"CPStackViewDetachesHiddenViews"];
|
||||
|
||||
[aCoder encodeObject:_viewsLeading forKey:@"CPStackViewViewsLeading"];
|
||||
[aCoder encodeObject:_viewsCenter forKey:@"CPStackViewViewsCenter"];
|
||||
[aCoder encodeObject:_viewsTrailing forKey:@"CPStackViewViewsTrailing"];
|
||||
|
||||
[aCoder encodeObject:_customSpacings forKey:@"CPStackViewCustomSpacings"];
|
||||
}
|
||||
|
||||
@end
|
||||
+15
-14
@@ -42,8 +42,8 @@
|
||||
CPButton _buttonUp;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Initialization
|
||||
// MARK: -
|
||||
// MARK: Initialization
|
||||
|
||||
/*!
|
||||
Initializes a CPStepper with given values.
|
||||
@@ -147,8 +147,8 @@
|
||||
[self _sizeToFit];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Superclass overrides
|
||||
// MARK: -
|
||||
// MARK: Superclass overrides
|
||||
|
||||
/*!
|
||||
Set if the CPStepper is enabled or not.
|
||||
@@ -188,12 +188,12 @@
|
||||
[_buttonUp setFrame:upFrame];
|
||||
[_buttonDown setFrame:downFrame];
|
||||
|
||||
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:[controlSizeThemeState, CPThemeStateBordered]] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
|
||||
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:[controlSizeThemeState, CPThemeStateBordered, CPThemeStateDisabled]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateDisabled]];
|
||||
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:[controlSizeThemeState, CPThemeStateBordered, CPThemeStateHighlighted]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateHighlighted]];
|
||||
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:[controlSizeThemeState, CPThemeStateBordered]] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
|
||||
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:[controlSizeThemeState, CPThemeStateBordered, CPThemeStateDisabled]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateDisabled]];
|
||||
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:[controlSizeThemeState, 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
|
||||
@@ -230,8 +230,8 @@
|
||||
[super setDoubleValue:aValue];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Actions
|
||||
// MARK: -
|
||||
// MARK: Actions
|
||||
|
||||
/*! @ignore */
|
||||
- (IBAction)_buttonDidClick:(id)aSender
|
||||
@@ -266,8 +266,8 @@
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Theming
|
||||
// MARK: -
|
||||
// MARK: Theming
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
@@ -323,6 +323,7 @@ var CPStepperMinValue = @"CPStepperMinValue",
|
||||
_autorepeat = [aCoder decodeBoolForKey:CPStepperAutorepeat];
|
||||
|
||||
[self _init];
|
||||
[self setEnabled:[self isEnabled]];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
@@ -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,62 @@ 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.
|
||||
// Unfortunately, as of today canvas sizing is not funtional any more. Neither in Chrome nor in FF
|
||||
|
||||
CPCanvasStringSizingIsFunctional = NO;
|
||||
}
|
||||
#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);
|
||||
}
|
||||
|
||||
|
||||
+583
-97
@@ -34,6 +34,9 @@ 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.
|
||||
|
||||
@class _CPTabViewBox
|
||||
@class _CPSegmentedControl
|
||||
|
||||
var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
|
||||
CPTabViewShouldSelectTabViewItemSelector = 1 << 2,
|
||||
CPTabViewWillSelectTabViewItemSelector = 1 << 3,
|
||||
@@ -63,10 +66,11 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
|
||||
{
|
||||
CPArray _items;
|
||||
|
||||
CPSegmentedControl _tabs;
|
||||
CPBox _box;
|
||||
_CPSegmentedControl _tabs;
|
||||
_CPTabViewBox _box;
|
||||
CPView _placeholderView @accessors;
|
||||
|
||||
CPNumber _selectedIndex;
|
||||
CPTabViewItem _selectedTabViewItem;
|
||||
|
||||
CPTabViewType _type;
|
||||
CPFont _font;
|
||||
@@ -75,13 +79,26 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
|
||||
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];
|
||||
}
|
||||
|
||||
@@ -90,19 +107,30 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 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:@"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
|
||||
@@ -112,7 +140,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
|
||||
*/
|
||||
- (void)addTabViewItem:(CPTabViewItem)aTabViewItem
|
||||
{
|
||||
[self insertTabViewItem:aTabViewItem atIndex:[_items count]];
|
||||
[self insertTabViewItem:aTabViewItem atIndex:[self numberOfTabViewItems]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -122,15 +150,24 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
|
||||
*/
|
||||
- (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];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -139,23 +176,39 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 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
|
||||
@@ -166,7 +219,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
|
||||
*/
|
||||
- (int)indexOfTabViewItem:(CPTabViewItem)aTabViewItem
|
||||
{
|
||||
return [_items indexOfObjectIdenticalTo:aTabViewItem];
|
||||
return [[self items] indexOfObjectIdenticalTo:aTabViewItem];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -176,11 +229,10 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 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];
|
||||
}];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -189,7 +241,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
|
||||
*/
|
||||
- (unsigned)numberOfTabViewItems
|
||||
{
|
||||
return [_items count];
|
||||
return [[self items] count];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -198,7 +250,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
|
||||
*/
|
||||
- (CPTabViewItem)tabViewItemAtIndex:(CPUInteger)anIndex
|
||||
{
|
||||
return [_items objectAtIndex:anIndex];
|
||||
return [[self items] objectAtIndex:anIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -207,7 +259,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
|
||||
*/
|
||||
- (CPArray)tabViewItems
|
||||
{
|
||||
return [_items copy]; // Copy?
|
||||
return [[self items] copy]; // Copy?
|
||||
}
|
||||
|
||||
// Selecting a Tab
|
||||
@@ -217,7 +269,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
|
||||
*/
|
||||
- (void)selectFirstTabViewItem:(id)aSender
|
||||
{
|
||||
if ([_items count] === 0)
|
||||
if ([self numberOfTabViewItems] === 0)
|
||||
return; // throw?
|
||||
|
||||
[self selectTabViewItemAtIndex:0];
|
||||
@@ -229,10 +281,10 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 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];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -241,12 +293,12 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 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;
|
||||
|
||||
@@ -259,10 +311,10 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 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.
|
||||
@@ -285,36 +337,70 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
|
||||
*/
|
||||
- (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
|
||||
@@ -375,6 +461,14 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 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.
|
||||
@@ -387,12 +481,11 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 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 _updateItems];
|
||||
[self _repositionTabs];
|
||||
}
|
||||
}
|
||||
@@ -453,10 +546,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 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
|
||||
@@ -470,30 +560,248 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 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];
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// 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
|
||||
@@ -515,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];
|
||||
}
|
||||
|
||||
@@ -529,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;
|
||||
@@ -558,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];
|
||||
@@ -569,3 +885,173 @@ var CPTabViewItemsKey = "CPTabViewItemsKey",
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation CPTabView (CSSTheming)
|
||||
|
||||
// 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
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation _CPTabViewBox : CPBox
|
||||
{
|
||||
CPTabView _tabView @accessors(property=tabView);
|
||||
CGInset _contentInset @accessors(property=contentInset);
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// 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
|
||||
|
||||
|
||||
+102
-10
@@ -24,6 +24,7 @@
|
||||
|
||||
@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,8 +127,11 @@ CPPressedTab = 2;
|
||||
*/
|
||||
- (void)setLabel:(CPString)aLabel
|
||||
{
|
||||
if ([aLabel isEqualToString:_label])
|
||||
return;
|
||||
|
||||
_label = aLabel;
|
||||
[_tabView setNeedsLayout];
|
||||
[_tabView tileWithChangedItem:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -101,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.
|
||||
@@ -140,7 +203,7 @@ CPPressedTab = 2;
|
||||
_view = aView;
|
||||
|
||||
if ([_tabView selectedTabViewItem] == self)
|
||||
[_tabView _setContentViewFromItem:self];
|
||||
[_tabView _displayItemView:_view];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -148,6 +211,9 @@ CPPressedTab = 2;
|
||||
*/
|
||||
- (CPView)view
|
||||
{
|
||||
if (!_view && _viewController)
|
||||
return [_viewController view]; // The view controller loads here.
|
||||
|
||||
return _view;
|
||||
}
|
||||
|
||||
@@ -186,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";
|
||||
|
||||
@@ -202,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];
|
||||
@@ -216,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];
|
||||
|
||||
+84
-19
@@ -180,7 +180,7 @@ 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)
|
||||
@@ -287,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];
|
||||
@@ -393,8 +393,8 @@ CPTableColumnUserResizingMask = 1 << 1;
|
||||
*/
|
||||
- (void)setDataView:(CPView)aView
|
||||
{
|
||||
if (_dataView)
|
||||
_dataViewData = nil;
|
||||
if (_dataView === aView)
|
||||
return;
|
||||
|
||||
[aView setThemeState:CPThemeStateTableDataView];
|
||||
|
||||
@@ -499,7 +499,7 @@ CPTableColumnUserResizingMask = 1 << 1;
|
||||
*/
|
||||
- (void)setHidden:(BOOL)shouldBeHidden
|
||||
{
|
||||
shouldBeHidden = !!shouldBeHidden
|
||||
shouldBeHidden = !!shouldBeHidden;
|
||||
|
||||
if (_isHidden === shouldBeHidden)
|
||||
return;
|
||||
@@ -537,6 +537,14 @@ CPTableColumnUserResizingMask = 1 << 1;
|
||||
return _headerToolTip;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (CPString)description
|
||||
{
|
||||
return [CPString stringWithFormat:"<%@ 0x%@ identifier=%@>", [self className], [CPString stringWithHash:[self UID]], [self identifier]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPTableColumnValueBinder : CPBinder
|
||||
@@ -546,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
|
||||
@@ -574,7 +593,7 @@ 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
|
||||
@@ -590,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.
|
||||
@@ -620,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
|
||||
*/
|
||||
@@ -636,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)
|
||||
@@ -651,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]];
|
||||
|
||||
+414
-365
File diff suppressed because it is too large
Load Diff
+910
-676
File diff suppressed because it is too large
Load Diff
+337
-1
@@ -5,6 +5,13 @@
|
||||
* Created by Alexander Ljungberg.
|
||||
* Copyright 2010, WireLoad, LLC.
|
||||
*
|
||||
* additions from
|
||||
*
|
||||
* Daniel Boehringer on 8/02/2014.
|
||||
* Copyright Daniel Boehringer on 8/02/2014.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -20,6 +27,30 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import <Foundation/Foundation.j>
|
||||
|
||||
@import "CPPasteboard.j"
|
||||
@import "CPView.j"
|
||||
|
||||
@global CPStringPboardType
|
||||
@global _CPSmartPboardType
|
||||
|
||||
@class CPAttributedString
|
||||
@class _CPRTFParser
|
||||
|
||||
@protocol CPTextDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (BOOL)textShouldBeginEditing:(CPText)aTextObject;
|
||||
- (BOOL)textShouldEndEditing:(CPText)aTextObject;
|
||||
- (void)textDidBeginEditing:(CPNotification)aNotification;
|
||||
- (void)textDidChange:(CPNotification)aNotification;
|
||||
- (void)textDidEndEditing:(CPNotification)aNotification;
|
||||
|
||||
@end
|
||||
|
||||
CPParagraphSeparatorCharacter = 0x2029;
|
||||
CPLineSeparatorCharacter = 0x2028;
|
||||
CPEnterCharacter = "\u0003";
|
||||
CPBackspaceCharacter = "\u0008";
|
||||
CPTabCharacter = "\u0009";
|
||||
@@ -29,6 +60,7 @@ CPCarriageReturnCharacter = "\u000d";
|
||||
CPBackTabCharacter = "\u0019";
|
||||
CPDeleteCharacter = "\u007f";
|
||||
|
||||
@typedef CPTextMovement
|
||||
CPIllegalTextMovement = 0;
|
||||
CPOtherTextMovement = 0;
|
||||
CPReturnTextMovement = 16;
|
||||
@@ -38,4 +70,308 @@ CPLeftTextMovement = 19;
|
||||
CPRightTextMovement = 20;
|
||||
CPUpTextMovement = 21;
|
||||
CPDownTextMovement = 22;
|
||||
CPCancelTextMovement = 23;
|
||||
CPCancelTextMovement = 23;
|
||||
|
||||
@typedef CPWritingDirection
|
||||
CPWritingDirectionNatural = -1;
|
||||
CPWritingDirectionLeftToRight = 0;
|
||||
CPWritingDirectionRightToLeft = 1;
|
||||
|
||||
@typedef CPTextAlignment
|
||||
CPLeftTextAlignment = 0;
|
||||
CPRightTextAlignment = 1;
|
||||
CPCenterTextAlignment = 2;
|
||||
CPJustifiedTextAlignment = 3;
|
||||
CPNaturalTextAlignment = 4;
|
||||
|
||||
@typedef CPUnderlineStyle
|
||||
CPUnderlineStyleNone = 0;
|
||||
CPUnderlineStyleSingle = 1;
|
||||
CPUnderlineStyleThick = 2;
|
||||
CPUnderlineStyleDouble = 3;
|
||||
CPUnderlineStylePatternSolid = 4;
|
||||
CPUnderlineStylePatternDot = 5;
|
||||
CPUnderlineStylePatternDash = 6;
|
||||
CPUnderlineStylePatternDashDot = 7;
|
||||
CPUnderlineStylePatternDashDotDot = 8;
|
||||
CPUnderlineStyleByWord = 9;
|
||||
|
||||
/*
|
||||
CPText notifications
|
||||
*/
|
||||
CPTextDidBeginEditingNotification = @"CPTextDidBeginEditingNotification";
|
||||
CPTextDidChangeNotification = @"CPTextDidChangeNotification";
|
||||
CPTextDidEndEditingNotification = @"CPTextDidEndEditingNotification";
|
||||
|
||||
/*
|
||||
CPTextView Notifications
|
||||
*/
|
||||
CPTextViewDidChangeSelectionNotification = @"CPTextViewDidChangeSelectionNotification";
|
||||
CPTextViewDidChangeTypingAttributesNotification = @"CPTextViewDidChangeTypingAttributesNotification";
|
||||
|
||||
/*
|
||||
FIXME: move these to CPAttributed string
|
||||
Make use of attributed keys in AppKit
|
||||
*/
|
||||
CPFontAttributeName = @"CPFontAttributeName";
|
||||
CPForegroundColorAttributeName = @"CPForegroundColorAttributeName";
|
||||
CPBackgroundColorAttributeName = @"CPBackgroundColorAttributeName";
|
||||
CPShadowAttributeName = @"CPShadowAttributeName";
|
||||
CPUnderlineStyleAttributeName = @"CPUnderlineStyleAttributeName";
|
||||
CPSuperscriptAttributeName = @"CPSuperscriptAttributeName";
|
||||
CPBaselineOffsetAttributeName = @"CPBaselineOffsetAttributeName";
|
||||
CPAttachmentAttributeName = @"CPAttachmentAttributeName";
|
||||
CPLigatureAttributeName = @"CPLigatureAttributeName";
|
||||
CPKernAttributeName = @"CPKernAttributeName";
|
||||
|
||||
@implementation CPText : CPView
|
||||
{
|
||||
BOOL _isEditable @accessors(getter=isEditable, setter=setEditable:);
|
||||
BOOL _isSelectable @accessors(getter=isSelectable, setter=setSelectable:);
|
||||
BOOL _isRichText @accessors(getter=isRichText, setter=setRichText:);
|
||||
}
|
||||
|
||||
- (void)setSelectable:(BOOL)flag
|
||||
{
|
||||
[self willChangeValueForKey:@"selectable"];
|
||||
_isSelectable = flag;
|
||||
[self didChangeValueForKey:@"selectable"];
|
||||
|
||||
if (!flag)
|
||||
[self setEditable:flag];
|
||||
}
|
||||
|
||||
- (void)setEditable:(BOOL)flag
|
||||
{
|
||||
[self willChangeValueForKey:@"editable"];
|
||||
_isEditable = flag;
|
||||
[self didChangeValueForKey:@"editable"];
|
||||
|
||||
if (flag)
|
||||
[self setSelectable:flag];
|
||||
}
|
||||
|
||||
- (void)changeFont:(id)sender
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (void)copy:(id)sender
|
||||
{
|
||||
var selectedRange = [self selectedRange];
|
||||
|
||||
if (selectedRange.length < 1)
|
||||
return;
|
||||
|
||||
var pasteboard = [CPPasteboard generalPasteboard];
|
||||
|
||||
// put plain representation on the pasteboad unconditionally
|
||||
[pasteboard declareTypes:[CPStringPboardType] owner:nil];
|
||||
[pasteboard setString:[[self stringValue] substringWithRange:selectedRange] forType:CPStringPboardType];
|
||||
}
|
||||
|
||||
- (id)_plainStringForPasting
|
||||
{
|
||||
return [[CPPasteboard generalPasteboard] stringForType:CPStringPboardType];
|
||||
}
|
||||
|
||||
- (id)_stringForPasting
|
||||
{
|
||||
var pasteboard = [CPPasteboard generalPasteboard],
|
||||
dataForPasting = [pasteboard stringForType:CPRTFPboardType],
|
||||
stringForPasting = [pasteboard stringForType:CPStringPboardType],
|
||||
attributedStringData = [pasteboard stringForType:_CPASPboardType];
|
||||
|
||||
if ([self isRichText] && attributedStringData)
|
||||
return [CPKeyedUnarchiver unarchiveObjectWithData:[CPData dataWithRawString:attributedStringData]];
|
||||
|
||||
if (dataForPasting || [stringForPasting hasPrefix:"{\\rtf1\\ansi"])
|
||||
stringForPasting = [[_CPRTFParser new] parseRTF:dataForPasting ? dataForPasting : stringForPasting];
|
||||
|
||||
if (![self isRichText] && [stringForPasting isKindOfClass:[CPAttributedString class]])
|
||||
stringForPasting = stringForPasting._string;
|
||||
|
||||
return stringForPasting;
|
||||
}
|
||||
|
||||
- (BOOL)_shouldUseSmartPasting
|
||||
{
|
||||
return parseInt([[CPPasteboard generalPasteboard] stringForType:_CPSmartPboardType], 10) > 0 || NO;
|
||||
}
|
||||
|
||||
- (void)paste:(id)sender
|
||||
{
|
||||
var stringForPasting = [self _stringForPasting];
|
||||
|
||||
if (stringForPasting)
|
||||
[self insertText:stringForPasting];
|
||||
}
|
||||
|
||||
- (void)copyFont:(id)sender
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (void)delete:(id)sender
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (CPFont)font:(CPFont)aFont
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)isHorizontallyResizable
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)isRulerVisible
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)isVerticallyResizable
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (CGSize)maxSize
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
|
||||
return CGSizeMake(0,0);
|
||||
}
|
||||
|
||||
- (CGSize)minSize
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
return CGSizeMake(0,0);
|
||||
}
|
||||
|
||||
- (void)pasteFont:(id)sender
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (void)replaceCharactersInRange:(CPRange)aRange withString:(CPString)aString
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (void)scrollRangeToVisible:(CPRange)aRange
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (void)selectedAll:(id)sender
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (CPRange)selectedRange
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
|
||||
return CPMakeRange(CPNotFound, 0);
|
||||
}
|
||||
|
||||
- (void)setFont:(CPFont)aFont
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (void)setFont:(CPFont)aFont range:(CPRange)aRange
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (void)setHorizontallyResizable:(BOOL)flag
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (void)setMaxSize:(CGSize)aSize
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (void)setMinSize:(CGSize)aSize
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (void)setString:(CPString)aString
|
||||
{
|
||||
[self replaceCharactersInRange:CPMakeRange(0, [[self string] length]) withString:aString];
|
||||
}
|
||||
|
||||
- (void)setUsesFontPanel:(BOOL)flag
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (void)setVerticallyResizable:(BOOL)flag
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (CPString)string
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)underline:(id)sender
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
- (BOOL)usesFontPanel
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPTextViewIsEditableKey = @"CPTextViewIsEditableKey",
|
||||
CPTextViewIsSelectableKey = @"CPTextViewIsSelectableKey",
|
||||
CPTextViewIsRichTextKey = @"CPTextViewIsRichTextKey";
|
||||
|
||||
@implementation CPText (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super initWithCoder:aCoder];
|
||||
|
||||
if (self)
|
||||
{
|
||||
[self setSelectable:[aCoder decodeBoolForKey:CPTextViewIsSelectableKey]];
|
||||
[self setEditable:[aCoder decodeBoolForKey:CPTextViewIsEditableKey]];
|
||||
[self setRichText:[aCoder decodeBoolForKey:CPTextViewIsRichTextKey]];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
[aCoder encodeBool:_isEditable forKey:CPTextViewIsEditableKey];
|
||||
[aCoder encodeBool:_isSelectable forKey:CPTextViewIsSelectableKey];
|
||||
[aCoder encodeBool:_isRichText forKey:CPTextViewIsRichTextKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+444
-93
@@ -28,11 +28,13 @@
|
||||
@import "_CPImageAndTextView.j"
|
||||
|
||||
@class CPPasteboard
|
||||
@class CPScrollView
|
||||
|
||||
@global CPApp
|
||||
@global CPStringPboardType
|
||||
@global CPCursor
|
||||
|
||||
@global document
|
||||
|
||||
@protocol CPTextFieldDelegate <CPControlTextEditingDelegate>
|
||||
|
||||
@@ -65,11 +67,15 @@ var CPTextFieldDOMCurrentElement = nil,
|
||||
CPTextFieldCachedSelectStartFunction = nil,
|
||||
CPTextFieldCachedDragFunction = nil,
|
||||
CPTextFieldBlurHandler = nil,
|
||||
CPTextFieldInputFunction = nil;
|
||||
CPTextFieldInputFunction = nil,
|
||||
CPTexFieldCurrentCSSSelectableField = nil,
|
||||
CPTextFieldLastValidationFailureEvent = nil,
|
||||
CPTextFieldLastValidationFailureString = nil,
|
||||
CPTextFieldLastValidationFailureField = nil,
|
||||
CPTextFieldLastValidationFailureResult = NO;
|
||||
|
||||
var CPSecureTextFieldCharacter = "\u2022";
|
||||
|
||||
|
||||
function CPTextFieldBlurFunction(anEvent, owner, domElement, inputElement, resigning, didBlurRef)
|
||||
{
|
||||
if (owner && domElement != inputElement.parentNode)
|
||||
@@ -77,20 +83,16 @@ function CPTextFieldBlurFunction(anEvent, owner, domElement, inputElement, resig
|
||||
|
||||
var ownerWindow = [owner window];
|
||||
|
||||
if (!resigning && [ownerWindow isKeyWindow])
|
||||
if (!resigning && [ownerWindow isKeyWindow] && [ownerWindow firstResponder] === owner)
|
||||
{
|
||||
/*
|
||||
Browsers blur text fields when a click occurs anywhere outside the text field. That is normal for browsers, but in Cocoa the key view retains focus unless the click target accepts first responder. So if we lost focus but were not told to resign and our window is still key, restore focus,
|
||||
but only if the text field is completely within the browser window. If we restore focus when it
|
||||
is off screen, the entire body scrolls out of our control.
|
||||
Previously we had code here which would force the input to regain focus if the input lost focus without the CPTextField having actually lost first responder status. This typically happened because the user clicked away from the input in the browser, without clicking on something that could become the first responder. In the browser, clicking outside of an input blurs it, but in Cocoa and Cappuccino it does not (unless you actually click something that will become the first responder).
|
||||
|
||||
That refocusing code has now been removed because we simply prevent the default action on clicks in the browser instead, which combined with the fix in 58d5d7d7, successfully prevents unintentional focus loss in (at least) Safari 9.1.1, Chrome 51 and Safari for iOS 9.3 when you click outside of a text field.
|
||||
|
||||
Now we can still lose focus unexpectedly: this is when the 'done' button is tapped on the virtual keyboard of a mobile device. In this case we actually do want to resign first responder status, because that is what the done button should do (and if we did not the keyboard would go away and then immediately come back which looks dumb and isn't what the user wanted).
|
||||
*/
|
||||
if ([owner _isWithinUsablePlatformRect])
|
||||
{
|
||||
window.setTimeout(function()
|
||||
{
|
||||
inputElement.focus();
|
||||
}, 0.0);
|
||||
}
|
||||
[ownerWindow makeFirstResponder:nil];
|
||||
}
|
||||
|
||||
CPTextFieldHandleBlur(anEvent, @ref(owner));
|
||||
@@ -173,7 +175,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
+ (CPTextField)textFieldWithStringValue:(CPString)aStringValue placeholder:(CPString)aPlaceholder width:(float)aWidth theme:(CPTheme)aTheme
|
||||
{
|
||||
var textField = [[self alloc] initWithFrame:CGRectMake(0.0, 0.0, aWidth, 29.0)];
|
||||
var minSize = aTheme ? [aTheme valueForAttributeWithName:@"min-size" forClass:CPTextField] : CGSizeMake(0,0),
|
||||
textField = [[self alloc] initWithFrame:CGRectMake(0.0, 0.0, aWidth, minSize.height)];
|
||||
|
||||
[textField setTheme:aTheme];
|
||||
[textField setStringValue:aStringValue];
|
||||
@@ -194,7 +197,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
+ (CPTextField)roundedTextFieldWithStringValue:(CPString)aStringValue placeholder:(CPString)aPlaceholder width:(float)aWidth theme:(CPTheme)aTheme
|
||||
{
|
||||
var textField = [[CPTextField alloc] initWithFrame:CGRectMake(0.0, 0.0, aWidth, 29.0)];
|
||||
var minSize = aTheme ? [aTheme valueForAttributeWithName:@"min-size" forClass:CPTextField] : CGSizeMake(0,0),
|
||||
textField = [[self alloc] initWithFrame:CGRectMake(0.0, 0.0, aWidth, minSize.height)];
|
||||
|
||||
[textField setTheme:aTheme];
|
||||
[textField setStringValue:aStringValue];
|
||||
@@ -235,12 +239,14 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
@"bezel-inset": CGInsetMakeZero(),
|
||||
@"content-inset": CGInsetMake(1.0, 0.0, 0.0, 0.0),
|
||||
@"bezel-color": [CPNull null],
|
||||
@"min-size": CGSizeMake(0, 29),
|
||||
@"background-inset": CGInsetMakeZero()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Control Size
|
||||
// MARK: -
|
||||
// MARK: Control Size
|
||||
|
||||
- (void)setControlSize:(CPControlSize)aControlSize
|
||||
{
|
||||
@@ -251,7 +257,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
// MARK: -
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
- (DOMElement)_inputElement
|
||||
@@ -330,12 +336,13 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
characters:nil
|
||||
charactersIgnoringModifiers:nil
|
||||
isARepeat:NO
|
||||
keyCode:nil];
|
||||
keyCode:nil
|
||||
isActionKey:NO];
|
||||
|
||||
[CPTextFieldInputOwner keyUp:cappEvent];
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
};
|
||||
|
||||
CPTextFieldDOMPasswordInputElement.oninput = CPTextFieldInputFunction;
|
||||
CPTextFieldDOMPasswordInputElement.onblur = CPTextFieldBlurHandler;
|
||||
@@ -369,14 +376,12 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
[self setPlaceholderString:@""];
|
||||
|
||||
_sendActionOn = CPKeyUpMask | CPKeyDownMask;
|
||||
|
||||
[self setValue:CPLeftTextAlignment forThemeAttribute:@"alignment"];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark Controlling Editability and Selectability
|
||||
// MARK: Controlling Editability and Selectability
|
||||
|
||||
/*!
|
||||
Sets whether or not the receiver text field can be edited. If NO, any
|
||||
@@ -397,7 +402,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
else
|
||||
[self unsetThemeState:CPThemeStateEditable];
|
||||
|
||||
// We only allow first responder status if the field is enable, and editable or selectable.
|
||||
// We only allow first responder status if the field is enabled, and editable or selectable.
|
||||
if (!(shouldBeEditable && ![self isSelectable]) && [[self window] firstResponder] === self)
|
||||
[[self window] makeFirstResponder:nil];
|
||||
|
||||
@@ -405,6 +410,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
[self setThemeState:CPThemeStateEditable];
|
||||
else
|
||||
[self unsetThemeState:CPThemeStateEditable];
|
||||
|
||||
[self updateTrackingAreas];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -426,6 +433,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
// We only allow first responder status if the field is enabled.
|
||||
if (!shouldBeEnabled && [[self window] firstResponder] === self)
|
||||
[[self window] makeFirstResponder:nil];
|
||||
|
||||
[self updateTrackingAreas];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -435,6 +444,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
- (void)setSelectable:(BOOL)aFlag
|
||||
{
|
||||
_isSelectable = aFlag;
|
||||
|
||||
[self updateTrackingAreas];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -555,9 +566,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
Sets the background color, which is shown for non-bezeled text fields with drawsBackground set to YES
|
||||
@param aColor The background color
|
||||
*/
|
||||
- (void)setTextFieldBackgroundColor:(CPColor)aColor
|
||||
- (void)setBackgroundColor:(CPColor)aColor
|
||||
{
|
||||
if (_textFieldBackgroundColor == aColor)
|
||||
if (_backgroundColor == aColor)
|
||||
return;
|
||||
|
||||
_textFieldBackgroundColor = aColor;
|
||||
@@ -569,7 +580,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
/*!
|
||||
Returns the background color.
|
||||
*/
|
||||
- (CPColor)textFieldBackgroundColor
|
||||
- (CPColor)backgroundColor
|
||||
{
|
||||
return _textFieldBackgroundColor;
|
||||
}
|
||||
@@ -643,6 +654,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
_stringValue = [self stringValue];
|
||||
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
[self _setCSSStyleForInputElement];
|
||||
@@ -664,30 +676,86 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
CPTextFieldInputOwner = self;
|
||||
|
||||
window.setTimeout(function()
|
||||
[[CPRunLoop mainRunLoop] performBlock:function()
|
||||
{
|
||||
/*
|
||||
setTimeout handlers are not guaranteed to fire in the order they were initiated. This can cause a race condition when several windows with text fields are opened quickly, resulting in several instances of this timeout function being fired, perhaps out of order. So we have to check that by the time this function is fired, CPTextFieldInputOwner has not been changed to another text field in the meantime.
|
||||
*/
|
||||
if (CPTextFieldInputOwner !== self)
|
||||
return;
|
||||
|
||||
// This will prevent to jump to the focused element
|
||||
var previousScrollingOrigin = [self _scrollToVisibleRectAndReturnPreviousOrigin];
|
||||
|
||||
element.focus();
|
||||
|
||||
[self _restorePreviousScrollingOrigin:previousScrollingOrigin];
|
||||
|
||||
// Select the text if the textfield became first responder through keyboard interaction
|
||||
if (!_willBecomeFirstResponderByClick)
|
||||
{
|
||||
[self _selectText:self immediately:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
var x = [self convertPointFromBase:[[CPApp currentEvent] locationInWindow]].x,
|
||||
contentInset = [self currentValueForThemeAttribute:@"content-inset"],
|
||||
text = [self stringValue],
|
||||
font = [self font];
|
||||
|
||||
switch ([self alignment]) {
|
||||
case CPCenterTextAlignment:
|
||||
|
||||
var contentWidth = [self bounds].size.width - contentInset.left - contentInset.right,
|
||||
textWidth = [text sizeWithFont:font].width;
|
||||
|
||||
x -= (contentWidth - textWidth) / 2 + contentInset.left;
|
||||
|
||||
break;
|
||||
|
||||
case CPRightTextAlignment:
|
||||
|
||||
var contentWidth = [self bounds].size.width - contentInset.left - contentInset.right,
|
||||
textWidth = [text sizeWithFont:font].width;
|
||||
|
||||
x -= (contentWidth - textWidth) + contentInset.left;
|
||||
|
||||
break;
|
||||
|
||||
default: // CPLeftTextAlignment, CPJustifiedTextAlignment, CPNaturalTextAlignment
|
||||
|
||||
x -= contentInset.left;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
var position = [CPPlatformString charPositionOfString:text withFont:font forPoint:CGPointMake(x, 0)];
|
||||
|
||||
[self setSelectedRange:CPMakeRange(position, 0)];
|
||||
}
|
||||
|
||||
_willBecomeFirstResponderByClick = NO;
|
||||
|
||||
[self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]];
|
||||
}, 0.0);
|
||||
} argument:nil order:0 modes:[CPDefaultRunLoopMode]];
|
||||
|
||||
#endif
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the selection css style for the DOM element of the textField
|
||||
@ignore
|
||||
*/
|
||||
- (void)_setEnableCSSSelection:(BOOL)shouldEnable
|
||||
{
|
||||
#if PLATFORM (DOM)
|
||||
if (CPTexFieldCurrentCSSSelectableField)
|
||||
CPTexFieldCurrentCSSSelectableField._DOMElement.style[CPBrowserStyleProperty(@"user-select")] = @"none";
|
||||
|
||||
CPTexFieldCurrentCSSSelectableField = self;
|
||||
_DOMElement.style[CPBrowserStyleProperty(@"user-select")] = shouldEnable ? @"text" : @"none";
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the css style for the input element of the textField
|
||||
@ignore
|
||||
@@ -697,7 +765,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
var element = [self _inputElement],
|
||||
font = [self currentValueForThemeAttribute:@"font"],
|
||||
font = [self font],
|
||||
lineHeight = [font defaultLineHeightForFont],
|
||||
contentRect = [self contentRectForBounds:[self bounds]],
|
||||
verticalAlign = [self currentValueForThemeAttribute:"vertical-alignment"],
|
||||
@@ -741,6 +809,10 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
element.style.textAlign = "right";
|
||||
break;
|
||||
|
||||
case CPNaturalTextAlignment:
|
||||
element.style.textAlign = "";
|
||||
break;
|
||||
|
||||
default:
|
||||
element.style.textAlign = "left";
|
||||
}
|
||||
@@ -750,7 +822,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
element.style.zIndex = 1000;
|
||||
element.style.top = topPoint;
|
||||
element.style.lineHeight = ROUND(lineHeight) + "px";
|
||||
element.style.height = isTextArea ? CGRectGetHeight(contentRect) + "px" : ROUND(lineHeight) + "px";;
|
||||
element.style.height = isTextArea ? CGRectGetHeight(contentRect) + "px" : ROUND(lineHeight) + "px";
|
||||
element.style.width = CGRectGetWidth(contentRect) + "px";
|
||||
element.style.left = left + "px";
|
||||
element.style.verticalAlign = "top";
|
||||
@@ -783,7 +855,13 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
// even if the value has not changed.
|
||||
if ([self _valueIsValid:newValue] === NO)
|
||||
{
|
||||
// This will prevent to jump to the focused element
|
||||
var previousScrollingOrigin = [self _scrollToVisibleRectAndReturnPreviousOrigin];
|
||||
|
||||
element.focus();
|
||||
|
||||
[self _restorePreviousScrollingOrigin:previousScrollingOrigin];
|
||||
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
@@ -792,9 +870,11 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
// When we are no longer the first responder we don't worry about the key status of our window anymore.
|
||||
[self _setObserveWindowKeyNotifications:NO];
|
||||
|
||||
[self _resignFirstKeyResponder];
|
||||
if ([[self window] isKeyWindow])
|
||||
[self _resignFirstKeyResponder];
|
||||
|
||||
_isEditing = NO;
|
||||
|
||||
if ([self isEditable])
|
||||
{
|
||||
[self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:@{"CPTextMovement": [self _currentTextMovement]}]];
|
||||
@@ -832,12 +912,18 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
if (!CPTextFieldInputDidBlur)
|
||||
CPTextFieldBlurHandler();
|
||||
|
||||
CPTextFieldInputDidBlur = NO;
|
||||
CPTextFieldInputResigning = NO;
|
||||
|
||||
if (element.parentNode == _DOMElement)
|
||||
element.parentNode.removeChild(element);
|
||||
|
||||
// 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.
|
||||
|
||||
CPTextFieldInputDidBlur = NO;
|
||||
CPTextFieldInputResigning = NO;
|
||||
|
||||
CPTextFieldInputIsActive = NO;
|
||||
|
||||
if (document.attachEvent)
|
||||
@@ -915,7 +1001,26 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
var acceptInvalidValue = NO;
|
||||
|
||||
if (_implementedDelegateMethods & CPTextFieldDelegate_control_didFailToFormatString_errorDescription_)
|
||||
acceptInvalidValue = [_delegate control:self didFailToFormatString:aValue errorDescription:error];
|
||||
{
|
||||
var currentEvent = [CPApp currentEvent];
|
||||
|
||||
if (currentEvent &&
|
||||
CPTextFieldLastValidationFailureField === self &&
|
||||
CPTextFieldLastValidationFailureString === aValue &&
|
||||
CPTextFieldLastValidationFailureEvent === currentEvent)
|
||||
{
|
||||
acceptInvalidValue = CPTextFieldLastValidationFailureResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
acceptInvalidValue = [_delegate control:self didFailToFormatString:aValue errorDescription:error];
|
||||
|
||||
CPTextFieldLastValidationFailureField = self;
|
||||
CPTextFieldLastValidationFailureString = aValue;
|
||||
CPTextFieldLastValidationFailureEvent = currentEvent;
|
||||
CPTextFieldLastValidationFailureResult = acceptInvalidValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (acceptInvalidValue === NO)
|
||||
return NO;
|
||||
@@ -954,14 +1059,11 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
- (void)mouseMoved:(CPEvent)anEvent
|
||||
{
|
||||
[super mouseMoved:anEvent];
|
||||
[self _updateCursorForEvent:anEvent];
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
if (![self isEnabled])
|
||||
return [[self nextResponder] mouseDown:anEvent];
|
||||
|
||||
// Don't track! (ever?)
|
||||
if ([self isEditable] && [self isEnabled])
|
||||
{
|
||||
@@ -970,6 +1072,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
}
|
||||
else if ([self isSelectable])
|
||||
{
|
||||
[self _setEnableCSSSelection:YES];
|
||||
if (document.attachEvent)
|
||||
{
|
||||
CPTextFieldCachedSelectStartFunction = [[self window] platformWindow]._DOMBodyElement.onselectstart;
|
||||
@@ -995,7 +1098,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
[[self window] platformWindow]._DOMBodyElement.ondrag = CPTextFieldCachedDragFunction;
|
||||
[[self window] platformWindow]._DOMBodyElement.onselectstart = CPTextFieldCachedSelectStartFunction;
|
||||
|
||||
CPTextFieldCachedSelectStartFunction = nil
|
||||
CPTextFieldCachedSelectStartFunction = nil;
|
||||
CPTextFieldCachedDragFunction = nil;
|
||||
}
|
||||
|
||||
@@ -1011,6 +1114,14 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)rightMouseDown:(CPEvent)anEvent
|
||||
{
|
||||
if ([self menuForEvent:anEvent] || [[self nextResponder] isKindOfClass:CPView])
|
||||
[super rightMouseDown:anEvent];
|
||||
else
|
||||
[[[anEvent window] platformWindow] _propagateContextMenuDOMEvent:YES];
|
||||
}
|
||||
|
||||
- (void)mouseDragged:(CPEvent)anEvent
|
||||
{
|
||||
if (![self isEnabled] || !([self isSelectable] || [self isEditable]))
|
||||
@@ -1039,9 +1150,16 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)keyDown:(CPEvent)anEvent
|
||||
{
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
// Has to be enabled, and it also has to be editable or selectable.
|
||||
if (![self isEnabled] || !([self isEditable] || [self isSelectable]))
|
||||
return;
|
||||
|
||||
if ([self isEditable] && !_isEditing)
|
||||
{
|
||||
_isEditing = YES;
|
||||
[self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
// CPTextField uses an HTML input element to take the input so we need to
|
||||
// propagate the dom event so the element is updated. This has to be done
|
||||
// before interpretKeyEvents: though so individual commands have a chance
|
||||
@@ -1161,7 +1279,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
- (void)textDidFocus:(CPNotification)note
|
||||
{
|
||||
// this looks to prevent false propagation of notifications for other objects
|
||||
if ([note object] != self)
|
||||
if ([note object] !== self)
|
||||
return;
|
||||
|
||||
if (_implementedDelegateMethods & CPTextFieldDelegate_controlTextDidFocus_)
|
||||
@@ -1190,7 +1308,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
return;
|
||||
|
||||
if (_implementedDelegateMethods & CPTextFieldDelegate_controlTextDidBeginEditing_)
|
||||
[_delegate controlTextDidBeginEditing:[[CPNotification alloc] initWithName:CPControlTextDidBeginEditingNotification object:self userInfo:@{"CPFieldEditor": [note object]}]]
|
||||
[_delegate controlTextDidBeginEditing:[[CPNotification alloc] initWithName:CPControlTextDidBeginEditingNotification object:self userInfo:@{"CPFieldEditor": [note object]}]];
|
||||
|
||||
[super textDidBeginEditing:note];
|
||||
}
|
||||
@@ -1207,27 +1325,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
[_delegate controlTextDidEndEditing:note];
|
||||
}
|
||||
|
||||
- (void)_updateCursorForEvent:(CPEvent)anEvent
|
||||
{
|
||||
var frame = CGRectMakeCopy([self frame]),
|
||||
contentInset = [self currentValueForThemeAttribute:@"content-inset"];
|
||||
|
||||
frame = [[self superview] convertRectToBase:CGRectInsetByInset(frame, contentInset)];
|
||||
|
||||
if ([self isEnabled] && ([self isSelectable] || [self isEditable]) && CGRectContainsPoint(frame, [anEvent locationInWindow]))
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
self._DOMElement.style.cursor = "text";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
self._DOMElement.style.cursor = "default";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the string in the text field.
|
||||
*/
|
||||
@@ -1299,7 +1396,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
// If there is a formatter, make sure the object value can be formatted successfully
|
||||
var formattedString = [self hasThemeState:CPThemeStateEditing] ? [formatter editingStringForObjectValue:aValue] : [formatter stringForObjectValue:aValue];
|
||||
|
||||
if (formattedString === nil)
|
||||
if (formattedString == nil)
|
||||
{
|
||||
var value = nil;
|
||||
|
||||
@@ -1309,7 +1406,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
value = undefined;
|
||||
|
||||
[super setObjectValue:value];
|
||||
_stringValue = (value === nil || value === undefined) ? @"" : String(value);
|
||||
_stringValue = (value == nil) ? @"" : String(value);
|
||||
}
|
||||
else
|
||||
_stringValue = formattedString;
|
||||
@@ -1396,7 +1493,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
lineBreakMode = [self lineBreakMode],
|
||||
text = (_stringValue || @" "),
|
||||
textSize = CGSizeMakeCopy(frameSize),
|
||||
font = [self currentValueForThemeAttribute:@"font"];
|
||||
font = [self font];
|
||||
|
||||
textSize.width -= contentInset.left + contentInset.right;
|
||||
textSize.height -= contentInset.top + contentInset.bottom;
|
||||
@@ -1463,9 +1560,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
if (immediately)
|
||||
element.select();
|
||||
else
|
||||
window.setTimeout(function() { element.select(); }, 0);
|
||||
[[CPRunLoop mainRunLoop] performBlock:function(){ element.select(); } argument:nil order:0 modes:[CPDefaultRunLoopMode]];
|
||||
}
|
||||
else if (wind !== nil && [wind makeFirstResponder:self])
|
||||
else if (wind != nil && [wind makeFirstResponder:self])
|
||||
[self _selectText:sender immediately:immediately];
|
||||
}
|
||||
else
|
||||
@@ -1475,7 +1572,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
#else
|
||||
// Even if we can't actually select the text we need to preserve the first
|
||||
// responder side effect.
|
||||
if (wind !== nil && [wind firstResponder] !== self)
|
||||
if (wind != nil && [wind firstResponder] !== self)
|
||||
[wind makeFirstResponder:self];
|
||||
#endif
|
||||
}
|
||||
@@ -1747,7 +1844,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
[self _didEdit];
|
||||
}
|
||||
|
||||
#pragma mark Setting the Delegate
|
||||
// MARK: Setting the Delegate
|
||||
|
||||
- (void)setDelegate:(id <CPTextFieldDelegate>)aDelegate
|
||||
{
|
||||
@@ -1758,7 +1855,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(control:didFailToFormatString:errorDescription:)])
|
||||
_implementedDelegateMethods |= CPTextFieldDelegate_control_didFailToFormatString_errorDescription_
|
||||
_implementedDelegateMethods |= CPTextFieldDelegate_control_didFailToFormatString_errorDescription_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(controlTextDidBeginEditing:)])
|
||||
_implementedDelegateMethods |= CPTextFieldDelegate_controlTextDidBeginEditing_;
|
||||
@@ -1800,6 +1897,12 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
if (aName === "bezel-view")
|
||||
return [self bezelRectForBounds:[self bounds]];
|
||||
|
||||
else if (aName === "background-view")
|
||||
{
|
||||
var backgroundInset = [self currentValueForThemeAttribute:@"background-inset"];
|
||||
|
||||
return CGRectInsetByInset([self bounds], backgroundInset);
|
||||
}
|
||||
else if (aName === "content-view")
|
||||
return [self contentRectForBounds:[self bounds]];
|
||||
|
||||
@@ -1816,6 +1919,14 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
return view;
|
||||
}
|
||||
else if (aName === "background-view")
|
||||
{
|
||||
var view = [[CPView alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
[view setHitTests:NO];
|
||||
|
||||
return view;
|
||||
}
|
||||
else
|
||||
{
|
||||
var view = [[_CPImageAndTextView alloc] initWithFrame:CGRectMakeZero()];
|
||||
@@ -1830,16 +1941,37 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
var bezelView = [self layoutEphemeralSubviewNamed:@"bezel-view"
|
||||
positioned:CPWindowBelow
|
||||
relativeToEphemeralSubviewNamed:@"content-view"];
|
||||
var bezelColor = [self currentValueForThemeAttribute:@"bezel-color"];
|
||||
|
||||
if ([bezelColor isCSSBased])
|
||||
{
|
||||
// CSS Styling
|
||||
// We don't need bezelView as we apply CSS styling directly on the text field view itself
|
||||
|
||||
if (bezelView)
|
||||
[bezelView setBackgroundColor:[self currentValueForThemeAttribute:@"bezel-color"]];
|
||||
// We need to call [super setBackgroundColor:] as we have redefined it here
|
||||
[super setBackgroundColor:bezelColor];
|
||||
|
||||
var contentView = [self layoutEphemeralSubviewNamed:@"content-view"
|
||||
positioned:CPWindowAbove
|
||||
relativeToEphemeralSubviewNamed:nil],
|
||||
backgroundView = [self layoutEphemeralSubviewNamed:@"background-view"
|
||||
positioned:CPWindowBelow
|
||||
relativeToEphemeralSubviewNamed:@"content-view"];
|
||||
|
||||
var contentView = [self layoutEphemeralSubviewNamed:@"content-view"
|
||||
positioned:CPWindowAbove
|
||||
relativeToEphemeralSubviewNamed:@"bezel-view"];
|
||||
[backgroundView setBackgroundColor:(_drawsBackground ? _textFieldBackgroundColor : [CPColor clearColor])];
|
||||
}
|
||||
else
|
||||
{
|
||||
var bezelView = [self layoutEphemeralSubviewNamed:@"bezel-view"
|
||||
positioned:CPWindowBelow
|
||||
relativeToEphemeralSubviewNamed:@"content-view"];
|
||||
|
||||
[bezelView setBackgroundColor:bezelColor];
|
||||
|
||||
var contentView = [self layoutEphemeralSubviewNamed:@"content-view"
|
||||
positioned:CPWindowAbove
|
||||
relativeToEphemeralSubviewNamed:@"bezel-view"];
|
||||
}
|
||||
|
||||
if (contentView)
|
||||
{
|
||||
@@ -1860,7 +1992,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
[contentView setText:string];
|
||||
|
||||
[contentView setTextColor:[self currentValueForThemeAttribute:@"text-color"]];
|
||||
[contentView setFont:[self currentValueForThemeAttribute:@"font"]];
|
||||
[contentView setFont:[self font]];
|
||||
[contentView setAlignment:[self currentValueForThemeAttribute:@"alignment"]];
|
||||
[contentView setVerticalAlignment:[self currentValueForThemeAttribute:@"vertical-alignment"]];
|
||||
[contentView setLineBreakMode:[self currentValueForThemeAttribute:@"line-break-mode"]];
|
||||
@@ -1872,6 +2004,43 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
[self _setCSSStyleForInputElement];
|
||||
}
|
||||
|
||||
// MARK: Overrides
|
||||
|
||||
/*!
|
||||
Sets the font of the receiver.
|
||||
|
||||
@param aFont - A CPFont object.
|
||||
*/
|
||||
- (void)setFont:(CPFont)aFont
|
||||
{
|
||||
if ([self currentValueForThemeAttribute:@"font"] === aFont)
|
||||
return;
|
||||
|
||||
// Apply the font to the default/normal state
|
||||
[self setValue:aFont forThemeAttribute:@"font"];
|
||||
|
||||
// Apply to standard editing and border states
|
||||
[self setValue:aFont forThemeAttribute:@"font" inState:CPThemeStateEditing];
|
||||
[self setValue:aFont forThemeAttribute:@"font" inState:CPThemeStateBezeled];
|
||||
[self setValue:aFont forThemeAttribute:@"font" inState:CPThemeStateBordered];
|
||||
[self setValue:aFont forThemeAttribute:@"font" inState:CPTextFieldStateRounded];
|
||||
|
||||
// Use CPThemeState() function to create composite states instead of array literals
|
||||
[self setValue:aFont forThemeAttribute:@"font" inState:CPThemeState(CPTextFieldStateRounded, CPThemeStateEditing)];
|
||||
|
||||
// Apply across all standard control size states
|
||||
[self setValue:aFont forThemeAttribute:@"font" inState:CPThemeStateControlSizeRegular];
|
||||
[self setValue:aFont forThemeAttribute:@"font" inState:CPThemeStateControlSizeSmall];
|
||||
[self setValue:aFont forThemeAttribute:@"font" inState:CPThemeStateControlSizeMini];
|
||||
|
||||
// Apply to table data view states (ensuring Interface Builder-style lists respect the font)
|
||||
[self setValue:aFont forThemeAttribute:@"font" inState:CPThemeStateTableDataView];
|
||||
[self setValue:aFont forThemeAttribute:@"font" inState:CPThemeState(CPThemeStateTableDataView, CPThemeStateSelectedDataView)];
|
||||
[self setValue:aFont forThemeAttribute:@"font" inState:CPThemeState(CPThemeStateTableDataView, CPThemeStateSelectedDataView, CPThemeStateFirstResponder, CPThemeStateKeyWindow)];
|
||||
|
||||
[self layoutSubviews];
|
||||
}
|
||||
|
||||
- (void)takeValueFromKeyPath:(CPString)aKeyPath ofObjects:(CPArray)objects
|
||||
{
|
||||
var count = objects.length,
|
||||
@@ -1888,7 +2057,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark Overrides
|
||||
// MARK: Overrides
|
||||
|
||||
/*!
|
||||
Sets the text color of the receiver.
|
||||
@@ -1900,8 +2069,28 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
// We don't want to change the text-color of the placeHolder of the textField
|
||||
var placeholderColor = [self valueForThemeAttribute:@"text-color" inState:CPTextFieldStatePlaceholder];
|
||||
|
||||
[super setTextColor:aColor];
|
||||
// If the text field is a cell based table data view, we need to fix the color for all possible states
|
||||
if ([self hasThemeState:CPThemeStateTableDataView])
|
||||
{
|
||||
[self setTextColor:aColor inThemeStates:[CPThemeStateTableDataView]];
|
||||
[self setTextColor:aColor inThemeStates:[CPThemeStateTableDataView, CPThemeStateSelectedDataView]];
|
||||
[self setTextColor:aColor inThemeStates:[CPThemeStateTableDataView, CPThemeStateSelectedDataView, CPThemeStateFirstResponder, CPThemeStateKeyWindow]];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([self hasThemeState:CPTextFieldStateRounded])
|
||||
{
|
||||
[self setTextColor:aColor inThemeStates:[CPTextFieldStateRounded]];
|
||||
[self setTextColor:aColor inThemeStates:[CPTextFieldStateRounded, CPThemeStateEditing]];
|
||||
}
|
||||
|
||||
[self setTextColor:aColor inThemeStates:[CPThemeStateNormal]];
|
||||
[self setTextColor:aColor inThemeStates:[CPThemeStateEditing]];
|
||||
}
|
||||
|
||||
[self setValue:placeholderColor forThemeAttribute:@"text-color" inState:CPTextFieldStatePlaceholder];
|
||||
|
||||
[self layoutSubviews];
|
||||
}
|
||||
|
||||
- (void)viewDidHide
|
||||
@@ -1937,7 +2126,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark Private
|
||||
// MARK: Private
|
||||
|
||||
- (BOOL)_isWithinUsablePlatformRect
|
||||
{
|
||||
@@ -1950,17 +2139,55 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
if (!wind)
|
||||
return NO;
|
||||
|
||||
var scrollView = [self enclosingScrollView],
|
||||
previousContentViewBoundsOrigin;
|
||||
|
||||
// Here we scroll to the textField, otherwise the textField could not be in the usable platformRect
|
||||
var previousScrollingOrigin = [self _scrollToVisibleRectAndReturnPreviousOrigin];
|
||||
|
||||
var frame = [self convertRectToBase:[self contentRectForBounds:[self bounds]]],
|
||||
usableRect = [[wind platformWindow] usableContentFrame];
|
||||
|
||||
frame.origin = [wind convertBaseToGlobal:frame.origin];
|
||||
|
||||
// Here we restore the previous scrolling posiition
|
||||
[self _restorePreviousScrollingOrigin:previousScrollingOrigin];
|
||||
|
||||
return (CGRectGetMinX(frame) >= CGRectGetMinX(usableRect) &&
|
||||
CGRectGetMaxX(frame) <= CGRectGetMaxX(usableRect) &&
|
||||
CGRectGetMinY(frame) >= CGRectGetMinY(usableRect) &&
|
||||
CGRectGetMaxY(frame) <= CGRectGetMaxY(usableRect));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (CGPoint)_scrollToVisibleRectAndReturnPreviousOrigin
|
||||
{
|
||||
var scrollView = [self enclosingScrollView],
|
||||
previousContentViewBoundsOrigin;
|
||||
|
||||
// Here we scroll to the textField, otherwise the textField could not be in the usable platformRect
|
||||
if ([scrollView isKindOfClass:[CPScrollView class]])
|
||||
{
|
||||
previousContentViewBoundsOrigin = CGPointMakeCopy([[scrollView contentView] boundsOrigin]);
|
||||
|
||||
if (![[self superview] scrollRectToVisible:[self frame]])
|
||||
previousContentViewBoundsOrigin = nil;
|
||||
}
|
||||
|
||||
return previousContentViewBoundsOrigin;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (void)_restorePreviousScrollingOrigin:(CGPoint)scrollingOrigin
|
||||
{
|
||||
if (scrollingOrigin)
|
||||
[[[self enclosingScrollView] contentView] setBoundsOrigin:scrollingOrigin];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var secureStringForString = function(aString)
|
||||
@@ -2005,8 +2232,7 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
|
||||
[self setSelectable:[aCoder decodeBoolForKey:CPTextFieldIsSelectableKey]];
|
||||
|
||||
[self setDrawsBackground:[aCoder decodeBoolForKey:CPTextFieldDrawsBackgroundKey]];
|
||||
|
||||
[self setTextFieldBackgroundColor:[aCoder decodeObjectForKey:CPTextFieldBackgroundColorKey]];
|
||||
[self setBackgroundColor:[aCoder decodeObjectForKey:CPTextFieldBackgroundColorKey]];
|
||||
|
||||
[self setLineBreakMode:[aCoder decodeIntForKey:CPTextFieldLineBreakModeKey]];
|
||||
[self setAlignment:[aCoder decodeIntForKey:CPTextFieldAlignmentKey]];
|
||||
@@ -2016,6 +2242,7 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
|
||||
[self _setUsesSingleLineMode:[aCoder decodeBoolForKey:CPTextFieldUsesSingleLineMode]];
|
||||
[self _setWraps:[aCoder decodeBoolForKey:CPTextFieldWraps]];
|
||||
[self _setScrolls:[aCoder decodeBoolForKey:CPTextFieldScrolls]];
|
||||
[self updateTrackingAreas];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -2050,6 +2277,56 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
|
||||
|
||||
@implementation _CPTextFieldValueBinder : CPBinder
|
||||
|
||||
+ (void)unbind:(CPString)aBinding forObject:(id)anObject
|
||||
{
|
||||
var theBinding = [self getBinding:aBinding forObject:anObject],
|
||||
notificationCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
if (theBinding)
|
||||
{
|
||||
[notificationCenter removeObserver:[theBinding._info objectForKey:CPObservedObjectKey]
|
||||
name:CPControlTextDidBeginEditingNotification
|
||||
object:anObject];
|
||||
|
||||
[notificationCenter removeObserver:[theBinding._info objectForKey:CPObservedObjectKey]
|
||||
name:CPControlTextDidEndEditingNotification
|
||||
object:anObject];
|
||||
|
||||
[super unbind:aBinding forObject:anObject];
|
||||
}
|
||||
}
|
||||
|
||||
- (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];
|
||||
|
||||
var notificationCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
// This gives us support for the CPEditorRegistration informal protocol
|
||||
if ([aDestination respondsToSelector:@selector(_objectDidBeginEditing:)])
|
||||
{
|
||||
[notificationCenter addObserver:aDestination
|
||||
selector:@selector(_objectDidBeginEditing:)
|
||||
name:CPControlTextDidBeginEditingNotification
|
||||
object:aSource];
|
||||
}
|
||||
|
||||
if ([aDestination respondsToSelector:@selector(_objectDidEndEditing:)])
|
||||
{
|
||||
[notificationCenter addObserver:aDestination
|
||||
selector:@selector(_objectDidEndEditing:)
|
||||
name:CPControlTextDidEndEditingNotification
|
||||
object:aSource];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options forBinding:(CPString)aBinding
|
||||
{
|
||||
[super _updatePlaceholdersWithOptions:options];
|
||||
@@ -2082,7 +2359,8 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
|
||||
newValue = [self valueForBinding:aBinding],
|
||||
value = [destination valueForKeyPath:keyPath];
|
||||
|
||||
if (CPIsControllerMarker(value) && newValue === nil) return;
|
||||
if (CPIsControllerMarker(value) && newValue == nil)
|
||||
return;
|
||||
|
||||
newValue = [self reverseTransformValue:newValue withOptions:options];
|
||||
|
||||
@@ -2110,3 +2388,76 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPTextField (CPTrackingArea)
|
||||
{
|
||||
CPTrackingArea _textFieldTrackingArea;
|
||||
}
|
||||
|
||||
- (void)updateTrackingAreas
|
||||
{
|
||||
if (_textFieldTrackingArea)
|
||||
{
|
||||
[self removeTrackingArea:_textFieldTrackingArea];
|
||||
_textFieldTrackingArea = nil;
|
||||
}
|
||||
|
||||
if ([self isEnabled] && (_isEditable || _isSelectable))
|
||||
{
|
||||
var myBounds = CGRectMakeCopy([self bounds]),
|
||||
contentInset = [self currentValueForThemeAttribute:@"content-inset"];
|
||||
|
||||
_textFieldTrackingArea = [[CPTrackingArea alloc] initWithRect:CGRectInsetByInset(myBounds, contentInset)
|
||||
options:CPTrackingCursorUpdate | CPTrackingActiveInKeyWindow
|
||||
owner:self
|
||||
userInfo:nil];
|
||||
|
||||
[self addTrackingArea:_textFieldTrackingArea];
|
||||
}
|
||||
|
||||
[super updateTrackingAreas];
|
||||
}
|
||||
|
||||
- (void)cursorUpdate:(CPEvent)anEvent
|
||||
{
|
||||
[[CPCursor IBeamCursor] set];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation CPTextField (TableDataView)
|
||||
|
||||
// We overide here _CPObject+Theme setValue:forThemeAttribute as CPTextField 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
|
||||
|
||||
// MARK: -
|
||||
|
||||
@implementation CPTextField (Deprecated)
|
||||
|
||||
- (void)setTextFieldBackgroundColor:(CPColor)aColor
|
||||
{
|
||||
CPLog.error("[CPTextField setTextFieldBackgroundColor:] is deprecated, use [CPTextField setBackgroundColor:] instead.");
|
||||
|
||||
[self setBackgroundColor:aColor];
|
||||
}
|
||||
|
||||
- (CPColor)textFieldBackgroundColor
|
||||
{
|
||||
CPLog.info("[CPTextField textFieldBackgroundColor] is deprecated, use [CPTextField backgroundColor] instead.");
|
||||
|
||||
return [self backgroundColor];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
/*
|
||||
* CPFontDescriptor.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Emmanuel Maillard on 07/03/10.
|
||||
* Copyright Emmanuel Maillard 2010.
|
||||
*
|
||||
* 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>
|
||||
/*
|
||||
Font descriptor dictionary keys
|
||||
*/
|
||||
|
||||
/*
|
||||
CPFontNameAttribute contains a CPString that specified the font name
|
||||
(may be an name list like: 'Marker Felt, Lucida Grande, Helvetica')
|
||||
*/
|
||||
CPFontNameAttribute = @"CPFontNameAttribute";
|
||||
/*
|
||||
CPFontSizeAttribute contains a CPString that specified the font size
|
||||
(as a float value)
|
||||
*/
|
||||
CPFontSizeAttribute = @"CPFontSizeAttribute";
|
||||
/*
|
||||
CPFontTraitsAttribute a CPDictionary that contains font traits keys
|
||||
(CPFontSymbolicTrait or CPFontWeightTrait)
|
||||
*/
|
||||
CPFontTraitsAttribute = @"CPFontTraitsAttribute";
|
||||
|
||||
// Font traits dictionary keys
|
||||
/*
|
||||
CPFontSymbolicTrait a CPNumber that contains CPFontFamilyClass and
|
||||
typeface information flags.
|
||||
*/
|
||||
CPFontSymbolicTrait = @"CPFontSymbolicTrait";
|
||||
|
||||
/*
|
||||
CPFontWeightTrait
|
||||
We use CPString with CSS string values for font weight
|
||||
(normal | bold | bolder | lighter | 100 | 200 | 300 | 400
|
||||
| 500 | 600 | 700 | 800 | 900)
|
||||
NOTE: Cocoa compatibility issue: NSFontWeightTrait are NSNumber for
|
||||
font weight (from -1.0 to 1.0, 0.0 for normal weight).
|
||||
*/
|
||||
CPFontWeightTrait = @"CPFontWeightTrait";
|
||||
|
||||
/*
|
||||
CPFontFamilyClass
|
||||
*/
|
||||
CPFontUnknownClass = 0 << 28;
|
||||
CPFontOldStyleSerifsClass = 1 << 28;
|
||||
CPFontTransitionalSerifsClass = 2 << 28;
|
||||
CPFontModernSerifsClass = 3 << 28;
|
||||
CPFontClarendonSerifsClass = 4 << 28;
|
||||
CPFontSlabSerifsClass = 5 << 28;
|
||||
CPFontFreeformSerifsClass = 7 << 28;
|
||||
CPFontSansSerifClass = 8 << 28;
|
||||
|
||||
CPFontSerifClass = (CPFontOldStyleSerifsClass | CPFontTransitionalSerifsClass |
|
||||
CPFontModernSerifsClass | CPFontClarendonSerifsClass |
|
||||
CPFontSlabSerifsClass | CPFontFreeformSerifsClass);
|
||||
|
||||
CPFontFamilyClassMask = 0xF0000000;
|
||||
|
||||
/*
|
||||
Typeface information
|
||||
*/
|
||||
CPFontItalicTrait = 1 << 0;
|
||||
CPFontBoldTrait = 1 << 1;
|
||||
CPFontExpandedTrait = 1 << 5; /* TODO: CCS 3 font-stretch */
|
||||
CPFontCondensedTrait = 1 << 6;
|
||||
CPFontSmallCapsTrait = 1 << 7;
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPFontDescriptor
|
||||
*/
|
||||
@implementation CPFontDescriptor : CPObject
|
||||
{
|
||||
CPDictionary _attributes;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a font descriptor with the specified attributes.
|
||||
|
||||
@param attributes a dictionary that describe the desired font descriptor
|
||||
@return the requested font descriptor
|
||||
*/
|
||||
+ (CPFontDescriptor)fontDescriptorWithFontAttributes:(CPDictionary)attributes
|
||||
{
|
||||
return [[CPFontDescriptor alloc] initWithFontAttributes:attributes];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a font descriptor with the specified name and size.
|
||||
|
||||
@param fontName the name of the font
|
||||
@param aSize the size of the font (in points)
|
||||
@return the requested font descriptor
|
||||
*/
|
||||
+ (CPFontDescriptor)fontDescriptorWithName:(CPString)fontName size:(float)size
|
||||
{
|
||||
return [[CPFontDescriptor alloc] initWithFontAttributes:[CPDictionary dictionaryWithObjects:[fontName, [CPString stringWithString:size + '']] forKeys:[CPFontNameAttribute,CPFontSizeAttribute]]];
|
||||
}
|
||||
|
||||
/*!
|
||||
Initialize a font descriptor with the specified attributes.
|
||||
|
||||
@param attributes a dictionary that describe the desired font descriptor
|
||||
@return the requested font descriptor
|
||||
*/
|
||||
- (id)initWithFontAttributes:(CPDictionary)attributes
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_attributes = [[CPMutableDictionary alloc] init];
|
||||
|
||||
if (attributes)
|
||||
[_attributes addEntriesFromDictionary:attributes];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a new font descriptor that is the same as the receiver but with the
|
||||
specified attributes taking precedence over the existing ones.
|
||||
|
||||
@param attributes a dictionary that describe the desired font descriptor
|
||||
@return the new font descriptor
|
||||
*/
|
||||
- (CPFontDescriptor)fontDescriptorByAddingAttributes:(CPDictionary)attributes
|
||||
{
|
||||
var attrib = [_attributes copy];
|
||||
|
||||
[attrib addEntriesFromDictionary:attributes];
|
||||
|
||||
return [[CPFontDescriptor alloc] initWithFontAttributes:attrib];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a new font descriptor that is the same as the receiver but with the specified size taking precedence over the existing ones.
|
||||
|
||||
@param aSize the new size
|
||||
@return the new font descriptor
|
||||
*/
|
||||
- (CPFontDescriptor)fontDescriptorWithSize:(float)aSize
|
||||
{
|
||||
var attrib = [_attributes copy];
|
||||
|
||||
[attrib setObject:[CPString stringWithString:aSize + ''] forKey:CPFontSizeAttribute];
|
||||
|
||||
return [[CPFontDescriptor alloc] initWithFontAttributes:attrib];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a new font descriptor that is the same as the receiver but with
|
||||
the specified symbolic traits taking precedence over the existing ones.
|
||||
|
||||
@param symbolicTraits the desired new symbolic traits
|
||||
@return the new font descriptor
|
||||
*/
|
||||
- (CPFontDescriptor)fontDescriptorWithSymbolicTraits:(CPFontSymbolicTraits)symbolicTraits
|
||||
{
|
||||
var attrib = [_attributes copy];
|
||||
|
||||
if ([attrib objectForKey:CPFontTraitsAttribute])
|
||||
[[attrib objectForKey:CPFontTraitsAttribute] setObject:[CPNumber numberWithUnsignedInt:symbolicTraits]
|
||||
forKey:CPFontSymbolicTrait];
|
||||
else
|
||||
[attrib setObject:[CPDictionary dictionaryWithObject:[CPNumber numberWithUnsignedInt:symbolicTraits]
|
||||
forKey:CPFontSymbolicTrait] forKey:CPFontTraitsAttribute];
|
||||
|
||||
return [[CPFontDescriptor alloc] initWithFontAttributes:attrib];
|
||||
}
|
||||
|
||||
- (id)objectForKey:(id)aKey
|
||||
{
|
||||
return [_attributes objectForKey:aKey];
|
||||
}
|
||||
|
||||
- (CPDictionary)fontAttributes
|
||||
{
|
||||
return _attributes;
|
||||
}
|
||||
|
||||
- (float)pointSize
|
||||
{
|
||||
var value = [_attributes objectForKey:CPFontSizeAttribute];
|
||||
|
||||
return value ? [value floatValue] : 0.0;
|
||||
}
|
||||
|
||||
- (CPFontSymbolicTraits)symbolicTraits
|
||||
{
|
||||
var traits = [_attributes objectForKey:CPFontTraitsAttribute];
|
||||
|
||||
return (traits && [traits objectForKey:CPFontSymbolicTrait]) ? [[traits objectForKey:CPFontSymbolicTrait] unsignedIntValue] : 0;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPFontDescriptorAttributesKey = @"CPFontDescriptorAttributesKey";
|
||||
|
||||
@implementation CPFontDescriptor (CPCoding)
|
||||
|
||||
/*!
|
||||
Initializes the font descriptor from a coder.
|
||||
|
||||
@param aCoder the coder from which to read the font descriptor data
|
||||
@return the initialized font
|
||||
*/
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
return [self initWithFontAttributes:[aCoder decodeObjectForKey:CPFontDescriptorAttributesKey]];
|
||||
}
|
||||
|
||||
/*!
|
||||
Writes the font descriptor to a coder.
|
||||
|
||||
@param aCoder the coder to which the data will be written
|
||||
*/
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[aCoder encodeObject:_attributes forKey:CPFontDescriptorAttributesKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var _wrapNameRegEx = new RegExp(/(\w+\s+\w+)(,*)/g);
|
||||
|
||||
/*
|
||||
Helper methods to CPFont for generating CSS font style
|
||||
*/
|
||||
@implementation CPFontDescriptor (CPFontCSSHelper)
|
||||
|
||||
- (CPString)fontStyleCSSString
|
||||
{
|
||||
return [self symbolicTraits] & CPFontItalicTrait ? @"italic" : @"normal";
|
||||
}
|
||||
|
||||
- (CPString)fontWeightCSSString
|
||||
{
|
||||
var traitsAttributes = [_attributes objectForKey:CPFontTraitsAttribute];
|
||||
|
||||
if (traitsAttributes)
|
||||
{
|
||||
/* give preference to CPFontWeightTrait */
|
||||
if ([traitsAttributes objectForKey:CPFontWeightTrait])
|
||||
return [traitsAttributes objectForKey:CPFontWeightTrait];
|
||||
/* else fallback to facetype symbolic traits */
|
||||
if ([self symbolicTraits] & CPFontBoldTrait)
|
||||
return @"bold";
|
||||
}
|
||||
|
||||
return @"normal";
|
||||
}
|
||||
|
||||
- (CPString)fontSizeCSSString
|
||||
{
|
||||
return [_attributes objectForKey:CPFontSizeAttribute] ? [[_attributes objectForKey:CPFontSizeAttribute] intValue] + "px" : @"";
|
||||
}
|
||||
|
||||
- (CPString)fontFamilyCSSString
|
||||
{
|
||||
var aName = @"";
|
||||
|
||||
if ([_attributes objectForKey:CPFontNameAttribute])
|
||||
aName += [_attributes objectForKey:CPFontNameAttribute].replace(_wrapNameRegEx, '"$1"$2');
|
||||
|
||||
var symbolicTraits = [self symbolicTraits];
|
||||
|
||||
if (symbolicTraits)
|
||||
{
|
||||
if ((symbolicTraits & CPFontFamilyClassMask) & CPFontSansSerifClass)
|
||||
aName += @", sans-serif";
|
||||
else if ((symbolicTraits & CPFontFamilyClassMask) & CPFontSerifClass)
|
||||
aName += @", serif";
|
||||
}
|
||||
|
||||
return aName;
|
||||
}
|
||||
|
||||
- (CPString)fontVariantCSSString
|
||||
{
|
||||
if ([self symbolicTraits] & CPFontSmallCapsTrait)
|
||||
return @"small-caps";
|
||||
|
||||
return @"normal";
|
||||
}
|
||||
|
||||
- (CPString)cssString
|
||||
{
|
||||
return [CPString stringWithString:[self fontStyleCSSString] + " "
|
||||
+ [self fontVariantCSSString] + " "
|
||||
+ [self fontWeightCSSString] + " "
|
||||
+ [self fontSizeCSSString] + " "
|
||||
+ [self fontFamilyCSSString]];
|
||||
}
|
||||
|
||||
@end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user