Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e7c3e952b | ||
|
|
e6411d7d90 | ||
|
|
9e7d0d3183 | ||
|
|
3ae4b1cf19 | ||
|
|
2841223c9d | ||
|
|
ba713b8b06 | ||
|
|
c53bff288a | ||
|
|
d85e8798c2 | ||
|
|
6dbb4eedb7 | ||
|
|
33b4b94426 | ||
|
|
3fc99095e2 | ||
|
|
8410198c37 | ||
|
|
d1b325052d | ||
|
|
4c4b42833a | ||
|
|
519a9300e2 | ||
|
|
91dda1f759 | ||
|
|
65e12269d1 | ||
|
|
9d2474b142 | ||
|
|
e804d44934 | ||
|
|
961628d8d3 | ||
|
|
7522751fd2 | ||
|
|
e3dc9fd96b | ||
|
|
c3ac076d13 | ||
|
|
1e02511022 | ||
|
|
071a772208 | ||
|
|
78711163c5 | ||
|
|
3f005ff476 | ||
|
|
ddd399631f | ||
|
|
c0ce830456 | ||
|
|
481555f11f | ||
|
|
20327d8fb6 | ||
|
|
a377e15368 | ||
|
|
52ca9628fd | ||
|
|
db1454c4fe | ||
|
|
6845bd4598 | ||
|
|
f02286e3f5 | ||
|
|
d473c251e6 | ||
|
|
64a401125d | ||
|
|
68ae1af13f | ||
|
|
f2165af48f | ||
|
|
62b1dbbc74 | ||
|
|
0881d86998 | ||
|
|
aff4883222 | ||
|
|
fbed77fc64 | ||
|
|
276e8b948d | ||
|
|
2edcfbda35 | ||
|
|
22cdd6e04d | ||
|
|
3518813145 | ||
|
|
a453412d5b | ||
|
|
55b438e8c1 | ||
|
|
ce749302a5 | ||
|
|
3356175f3e | ||
|
|
50ff20ba33 | ||
|
|
d3ba51104e | ||
|
|
981c184c20 | ||
|
|
e3a65a1847 | ||
|
|
64eb440ea3 | ||
|
|
994383f73a | ||
|
|
89bd5f5b93 | ||
|
|
ae25f489ad | ||
|
|
510eaabcfb | ||
|
|
875e177219 | ||
|
|
f8f62e1473 | ||
|
|
c1a70a3aa2 | ||
|
|
c514fd7a08 | ||
|
|
3cefc86fbf | ||
|
|
0c66606d1d | ||
|
|
05fc35a5b9 | ||
|
|
2425838ea6 | ||
|
|
20d117e129 | ||
|
|
8f08c33bcc | ||
|
|
d7f0bf6a24 | ||
|
|
5afe6fea3c | ||
|
|
9441739839 | ||
|
|
8727d96a06 | ||
|
|
b2ffe7e509 | ||
|
|
119c950b53 | ||
|
|
29a0de3636 | ||
|
|
aa3e3c7e71 | ||
|
|
eb00953c60 | ||
|
|
c4b255ae46 | ||
|
|
d3547dd892 | ||
|
|
7d1c7b2907 | ||
|
|
d0999fa5d5 | ||
|
|
c478afee0f | ||
|
|
ab196e75c1 | ||
|
|
50b5c21fcf | ||
|
|
47bc7e812d | ||
|
|
ad5f574fb7 | ||
|
|
9537a62ab1 | ||
|
|
dc7bd3355d | ||
|
|
d76d9bcfad | ||
|
|
440eed77cf | ||
|
|
b906fbea29 | ||
|
|
af148137d6 | ||
|
|
64357fde0d | ||
|
|
7512a45cda | ||
|
|
e034abef82 | ||
|
|
0b5db9c4bd | ||
|
|
3cd763aabb | ||
|
|
1a881fb501 | ||
|
|
2f68804279 | ||
|
|
60d15e2983 | ||
|
|
628488f7aa | ||
|
|
149308bc89 | ||
|
|
b4fa971007 | ||
|
|
b30f10ca46 | ||
|
|
da725f6ffc | ||
|
|
b0d62a8608 | ||
|
|
3da2d3718b | ||
|
|
4bd6aca0c0 | ||
|
|
e90c84ee81 | ||
|
|
45b8f83cdd | ||
|
|
c8e0aa9cb4 | ||
|
|
7a486db45f | ||
|
|
4634c6cf3b | ||
|
|
eb57d14673 | ||
|
|
cb939baca0 | ||
|
|
db8a277960 | ||
|
|
398d61097c | ||
|
|
4a43e4fda6 | ||
|
|
783159ee44 | ||
|
|
fa63551b42 | ||
|
|
18a0deb678 | ||
|
|
f7c46855b8 | ||
|
|
e67539c3b1 | ||
|
|
b8d06521b2 | ||
|
|
3225d980c5 | ||
|
|
9c3a579ff8 | ||
|
|
92b5b34d17 | ||
|
|
47e8696b9f | ||
|
|
7938384162 | ||
|
|
01aec1f78e | ||
|
|
67f35c7b74 | ||
|
|
d600df4585 | ||
|
|
f3a0710059 | ||
|
|
203e0d150b | ||
|
|
efd699a044 | ||
|
|
dbe0ca0adc | ||
|
|
5316cabf30 | ||
|
|
9a16921a32 | ||
|
|
f5edf2a4c2 | ||
|
|
cfdcfdbc99 | ||
|
|
ad99dca6ac | ||
|
|
fbcc81056b | ||
|
|
756877b94c | ||
|
|
68d30c8802 | ||
|
|
555b83a359 | ||
|
|
ff43be6d7b | ||
|
|
7defbce1dd | ||
|
|
ef5aead17d | ||
|
|
585b70a6a9 | ||
|
|
b24a78bdd5 | ||
|
|
f305621ade | ||
|
|
24198a7890 | ||
|
|
2d477b38bc | ||
|
|
48afc5639e | ||
|
|
7b932fbf4a | ||
|
|
39f3e7b292 | ||
|
|
49f3038737 | ||
|
|
f7a40a071b | ||
|
|
3a1ebcaf3f | ||
|
|
3da1c4381c | ||
|
|
9ff73e5e63 | ||
|
|
f3633c050b | ||
|
|
1ba828da18 | ||
|
|
109725d613 | ||
|
|
4bc8f01376 | ||
|
|
df20a6d6df | ||
|
|
e32963384e | ||
|
|
03a9865ccb | ||
|
|
7674b3aec6 | ||
|
|
9c9a5bcd51 | ||
|
|
8948f7f43c | ||
|
|
ef4e86a124 | ||
|
|
b9edc357f3 | ||
|
|
9353d0f95c | ||
|
|
7defdd2a00 | ||
|
|
621e79fe33 | ||
|
|
e759c5343b | ||
|
|
d879b25458 | ||
|
|
ccffde6966 | ||
|
|
1524f80418 | ||
|
|
bcbeb888f6 | ||
|
|
7730aeb652 | ||
|
|
272f938f2e | ||
|
|
5570a346c4 | ||
|
|
2b90652a16 | ||
|
|
a58dd4678c | ||
|
|
25f4574093 | ||
|
|
733b9b731d | ||
|
|
20637fc5e0 | ||
|
|
c33e2ee51f | ||
|
|
7ef59418dd | ||
|
|
0805e58a94 | ||
|
|
6ddeff2b21 | ||
|
|
7433c38d92 | ||
|
|
5f930ec840 | ||
|
|
0dd36b2275 | ||
|
|
629428739d | ||
|
|
7d7281480a | ||
|
|
666e2c0190 | ||
|
|
3968d35cac | ||
|
|
551677d6fd | ||
|
|
85b029fad0 | ||
|
|
841ed9ea89 | ||
|
|
74fd7eb793 | ||
|
|
26df9e861f | ||
|
|
338860d05b | ||
|
|
b7df6c1480 | ||
|
|
b2179f14ab | ||
|
|
99b43fed7f | ||
|
|
25dfcd38a7 | ||
|
|
a6d2c42402 | ||
|
|
fd8271396d | ||
|
|
19ca6a342e | ||
|
|
7819e174f1 | ||
|
|
7cd6d026a2 | ||
|
|
c48d306195 | ||
|
|
3a9845f784 | ||
|
|
94d3053232 | ||
|
|
b078169adf | ||
|
|
38c4dd408c | ||
|
|
8beb9dfed0 | ||
|
|
eef9549e96 | ||
|
|
82ac98ddc7 | ||
|
|
3d52ffcbdc | ||
|
|
3fad4635b0 | ||
|
|
b0b19328a8 | ||
|
|
9fd79488f8 | ||
|
|
cebe31857a | ||
|
|
1961829414 | ||
|
|
3e5bdec033 | ||
|
|
5789021a76 | ||
|
|
6bf0319c51 | ||
|
|
8f519caa77 | ||
|
|
a38be80a86 | ||
|
|
81b72fc571 | ||
|
|
91681d7846 | ||
|
|
d40619aca0 | ||
|
|
1328bc732f | ||
|
|
060f65b27e | ||
|
|
364669f527 | ||
|
|
f4042b9d4b | ||
|
|
c750b696d2 | ||
|
|
02cdee6c75 | ||
|
|
c4a824b5db | ||
|
|
7f31c0632d | ||
|
|
96ee92695c | ||
|
|
80b252a744 | ||
|
|
4f50f8b83f | ||
|
|
df895b9529 | ||
|
|
f9e9e51352 | ||
|
|
27e99344bd | ||
|
|
32572844fd | ||
|
|
a77e67e578 | ||
|
|
fb9cd1ef93 | ||
|
|
93722f6a7d | ||
|
|
76da7466ec | ||
|
|
6b3c95f09f | ||
|
|
81110ddba7 | ||
|
|
64fd9f615c | ||
|
|
213df88766 | ||
|
|
a26750d4f4 | ||
|
|
72edd7376e | ||
|
|
948e9ae139 | ||
|
|
ae357d1a2b | ||
|
|
59756ff1b3 | ||
|
|
2908e453e8 | ||
|
|
7b1ffc885f | ||
|
|
95364b1d31 | ||
|
|
f3257c0847 | ||
|
|
eb0fc35c8f | ||
|
|
3dccd93093 | ||
|
|
8929199082 | ||
|
|
20f6a57b3a | ||
|
|
db949728dd | ||
|
|
92d28e468e | ||
|
|
f95c3ca46a | ||
|
|
477b6bcdc5 | ||
|
|
3e40deba5f | ||
|
|
7d9bd25270 | ||
|
|
c201990cb0 | ||
|
|
289df53fb4 | ||
|
|
62788423a1 | ||
|
|
8617990206 | ||
|
|
2d8f2b328f | ||
|
|
833896e267 | ||
|
|
f12b4520f6 | ||
|
|
2564003c85 | ||
|
|
c36b8f2257 | ||
|
|
d413fbe0ed | ||
|
|
4237000fc9 | ||
|
|
5131aff352 | ||
|
|
f77f52802c | ||
|
|
d52ab34421 | ||
|
|
81e4c26b38 | ||
|
|
1eed1901e9 | ||
|
|
a8b1c7bce1 | ||
|
|
ac3d035ce7 | ||
|
|
c8575cac05 | ||
|
|
8d63c059c5 | ||
|
|
bc53288fca | ||
|
|
474d4281f1 | ||
|
|
73babcd7d6 | ||
|
|
5fe208d6a0 | ||
|
|
94ca0ed71b | ||
|
|
a323cfe08c | ||
|
|
29c3654928 | ||
|
|
27fefed0d8 | ||
|
|
235d974ce1 | ||
|
|
cb1d3168e3 | ||
|
|
64dc25dfb6 | ||
|
|
9a7484e57d | ||
|
|
b89ee3e4c1 | ||
|
|
ec5645d380 | ||
|
|
a0abf1e221 | ||
|
|
0e558d54e5 | ||
|
|
004cc5fe5a | ||
|
|
0b22b1d022 | ||
|
|
24ecf31bd3 | ||
|
|
c37c80771c | ||
|
|
a017c0c4a8 | ||
|
|
3a35ab449b | ||
|
|
da84964a33 | ||
|
|
65051855ee | ||
|
|
72c36789c6 | ||
|
|
bc07bd16bd | ||
|
|
bf691fa552 | ||
|
|
47ddfec1f9 | ||
|
|
fb8ba655e1 | ||
|
|
d64f56817d | ||
|
|
9363708e49 | ||
|
|
65a2e4d6b0 | ||
|
|
138d7bd9a2 | ||
|
|
97fe09fbdd | ||
|
|
487412fa22 | ||
|
|
ea47baa1fc | ||
|
|
90cd519916 | ||
|
|
669d18b218 | ||
|
|
fbcd2b3174 | ||
|
|
99a839456d | ||
|
|
0d9d60466d | ||
|
|
5a031efa7a | ||
|
|
1f64fce47c | ||
|
|
04529897dc | ||
|
|
7837e1ad81 | ||
|
|
c7c60b2b94 | ||
|
|
f9c2805379 | ||
|
|
035d772a4a | ||
|
|
f89c2e0ba9 | ||
|
|
94ce055bc2 | ||
|
|
9b3d4d4453 | ||
|
|
329e4dc3c3 | ||
|
|
d96e939eed | ||
|
|
c8437895dc | ||
|
|
95ba648dae | ||
|
|
9f847e5a24 | ||
|
|
a4eec5fef8 | ||
|
|
e51bf3f0c1 | ||
|
|
b907ea59f4 | ||
|
|
cebff75992 | ||
|
|
a3f9b65501 | ||
|
|
1f7afe7a49 | ||
|
|
ceecaa0184 | ||
|
|
78b4bbb06e | ||
|
|
0375e7a881 | ||
|
|
ebc831663b | ||
|
|
65ceb96e4f | ||
|
|
57ef2d2229 | ||
|
|
8759b175bd | ||
|
|
13f86b0cd4 | ||
|
|
c0fad49375 | ||
|
|
579cc98e4f | ||
|
|
4a98417ee8 | ||
|
|
4a5e90b5cb | ||
|
|
36a85e935b | ||
|
|
9034203a4f | ||
|
|
24e8f8aa43 | ||
|
|
632251b16c | ||
|
|
2406cbe7ed | ||
|
|
e6a0caa164 | ||
|
|
cd3e2fbbb8 | ||
|
|
47bd6e5ce3 | ||
|
|
f590c63e33 | ||
|
|
e8b74ece72 | ||
|
|
3d45699bc7 | ||
|
|
ae987f19dc | ||
|
|
09786cb8d2 | ||
|
|
17072f9ed4 | ||
|
|
82d3d1abc5 | ||
|
|
2cc40a7961 | ||
|
|
c523e706e9 | ||
|
|
cdca8047b9 | ||
|
|
09b8a3394e | ||
|
|
ed1a7a4bc9 | ||
|
|
0696fb405e | ||
|
|
265a410342 | ||
|
|
cbd0d6e6a2 | ||
|
|
25e0a59d5b | ||
|
|
ab34ee882e | ||
|
|
4f05657236 | ||
|
|
7720200679 | ||
|
|
117ec9970c | ||
|
|
766073f77a | ||
|
|
5f0a60f61c | ||
|
|
d608d34166 | ||
|
|
8bc1c7445d | ||
|
|
985b906c94 | ||
|
|
e8ac94f8da | ||
|
|
9465dd6941 | ||
|
|
28a00fff23 | ||
|
|
c418481981 | ||
|
|
2b87b9f3fc | ||
|
|
683eb993e8 | ||
|
|
e19d6a58c9 | ||
|
|
2dccee05bc | ||
|
|
ac2885afc6 | ||
|
|
972909902e | ||
|
|
b07f2ed186 | ||
|
|
ee6160e796 | ||
|
|
5940e6913d | ||
|
|
c85e33c034 | ||
|
|
21ef259e1f | ||
|
|
2b66683167 | ||
|
|
851a0e3d24 | ||
|
|
8b32f561ec | ||
|
|
1571b6daa2 | ||
|
|
2d69509d5e | ||
|
|
8edf05c000 | ||
|
|
0e6cef0268 | ||
|
|
60e4d8e080 | ||
|
|
6b58986ec3 | ||
|
|
e88ec01fca | ||
|
|
8284498722 | ||
|
|
e088280a5f | ||
|
|
7f78c323e9 | ||
|
|
77303c1aeb | ||
|
|
cc74f941c6 | ||
|
|
775c1c1c8b | ||
|
|
35a7456302 | ||
|
|
4006b35a5e | ||
|
|
b562280503 | ||
|
|
e3a075a6a6 | ||
|
|
8c534c6d33 | ||
|
|
82be6c243c | ||
|
|
5b8ee5dd1b | ||
|
|
050a132bd5 | ||
|
|
146bff6766 | ||
|
|
cd98bce331 | ||
|
|
a2d3723c7a | ||
|
|
ecb88a87ad | ||
|
|
3f2813932a | ||
|
|
c2223e3942 | ||
|
|
2dc0839d36 | ||
|
|
97ef1d1781 | ||
|
|
e64a9a7ab9 | ||
|
|
d4f3f83212 | ||
|
|
1488f3ed58 | ||
|
|
26945bde42 | ||
|
|
c911dd8aa6 | ||
|
|
1c81e0eee0 | ||
|
|
5366713790 | ||
|
|
e9940d060a | ||
|
|
605e905f3e | ||
|
|
11d30566bf | ||
|
|
0942f9fac3 | ||
|
|
7b303b6529 | ||
|
|
6a9040989d | ||
|
|
840e9c7671 | ||
|
|
1d9e2f8169 | ||
|
|
8c9f302b67 | ||
|
|
44f23cd8ac | ||
|
|
c88f781509 | ||
|
|
3dc578d585 | ||
|
|
238d8ff0be | ||
|
|
ca5dd0071c | ||
|
|
86fa759f9f | ||
|
|
0bcf8a6626 | ||
|
|
d735cd98e7 | ||
|
|
e25a550d3f | ||
|
|
8a2206656d | ||
|
|
ac68d670a2 | ||
|
|
e6539bbed5 | ||
|
|
9db0694677 | ||
|
|
a4d73330cc | ||
|
|
ea6a983e9b | ||
|
|
79cd8603a2 | ||
|
|
02cb054b71 | ||
|
|
007cfd589f | ||
|
|
90d24fd6bf | ||
|
|
4b7310d0cb | ||
|
|
59660032e1 | ||
|
|
d9c47ec763 | ||
|
|
a18ea750a6 | ||
|
|
c423411639 | ||
|
|
b5ad030e40 | ||
|
|
bfdbe2a34a | ||
|
|
ec5dcb47c9 | ||
|
|
436f1d1541 | ||
|
|
05873a030f | ||
|
|
78083eea48 | ||
|
|
7715da02e7 | ||
|
|
6798a5777a | ||
|
|
2f3ad961e7 | ||
|
|
dba047187f | ||
|
|
03e63f29dc | ||
|
|
b4cd9c4c45 | ||
|
|
b9b2649db9 | ||
|
|
df98483b06 | ||
|
|
37fbeaad02 | ||
|
|
794d8a754c | ||
|
|
b081debf88 | ||
|
|
36c6c9bfa6 | ||
|
|
bda5ea1c59 | ||
|
|
5ccf6eefc0 | ||
|
|
06261559fc | ||
|
|
477d2f9d82 | ||
|
|
0cb66ddc6e | ||
|
|
99df7f6acb | ||
|
|
0791fa0ad3 | ||
|
|
9811327672 | ||
|
|
60f2eaadf5 | ||
|
|
5478c640cc | ||
|
|
7fe3b115f1 | ||
|
|
3ee63b754c | ||
|
|
378b6c12f3 | ||
|
|
ee5817e480 | ||
|
|
a354b4acd5 | ||
|
|
8e87a4a941 | ||
|
|
42712166e9 | ||
|
|
2bc31de69d | ||
|
|
fcfeb29be5 | ||
|
|
a64a270e25 | ||
|
|
96eebc7d1d | ||
|
|
38fd675f51 | ||
|
|
35adaee1bb | ||
|
|
def314b5ad | ||
|
|
913a18eaaf | ||
|
|
d82b39de19 | ||
|
|
cde5d8709c | ||
|
|
ec210c49c5 | ||
|
|
07f320def9 | ||
|
|
f5fe15d6cb | ||
|
|
da146b0873 | ||
|
|
3b7a77ae0c | ||
|
|
9cb1e28ad1 | ||
|
|
9db7701691 | ||
|
|
27aca4c84a | ||
|
|
4e50244dca | ||
|
|
0c21724270 | ||
|
|
09306aa2cd | ||
|
|
1170673b92 | ||
|
|
712a991c86 | ||
|
|
e3cdcbc5ab | ||
|
|
62379b21c1 | ||
|
|
cfde67742c | ||
|
|
9b01561127 | ||
|
|
fb89450b90 | ||
|
|
5a8d491f10 | ||
|
|
7ffb44e394 | ||
|
|
34a5d9e61b | ||
|
|
e1d43e3651 | ||
|
|
c291ad83f1 | ||
|
|
c6a4eb28a8 | ||
|
|
dd4735026a | ||
|
|
dc0439227e | ||
|
|
00f470763f | ||
|
|
05b1cfca31 | ||
|
|
e40696a7af | ||
|
|
bc030c42d9 | ||
|
|
7ce72a31c5 | ||
|
|
cf8989938c | ||
|
|
e09b63183c | ||
|
|
76717c7177 | ||
|
|
6749fa57ad | ||
|
|
050b75a2df | ||
|
|
3f730c94ce | ||
|
|
22c931729b | ||
|
|
cb658826a3 | ||
|
|
3f8c311ea2 | ||
|
|
22aa4d359e | ||
|
|
c2880ec8e4 | ||
|
|
108822d4e1 | ||
|
|
f79a926b10 | ||
|
|
4eef234736 | ||
|
|
5abbdfc094 | ||
|
|
c44715bef4 | ||
|
|
b5f55100e9 | ||
|
|
4e0404fce6 | ||
|
|
f1874eca8a | ||
|
|
2e1d6f2412 | ||
|
|
0395287906 | ||
|
|
bda8a5fd6c | ||
|
|
ded413481c | ||
|
|
a5a6c07b08 | ||
|
|
204df99375 | ||
|
|
55dd67a0ad | ||
|
|
6040ee4ffc | ||
|
|
544ed99d98 | ||
|
|
7546640fba | ||
|
|
daf5b88834 | ||
|
|
c36f975bbf | ||
|
|
a5e34d9153 | ||
|
|
57a63440f9 | ||
|
|
e25a227e4d | ||
|
|
db7b340b32 | ||
|
|
7683755137 | ||
|
|
8de71663c2 | ||
|
|
211a7c7939 | ||
|
|
82ce66af16 | ||
|
|
df4bc13122 | ||
|
|
8f3661d5a4 | ||
|
|
bb31ac11ca | ||
|
|
4ef0065c66 | ||
|
|
476d168a46 | ||
|
|
093c6cdca3 | ||
|
|
345f5e14de | ||
|
|
5ddfef7eb7 | ||
|
|
81d784b5dc | ||
|
|
b0b9a7a294 | ||
|
|
e76ee3c96e | ||
|
|
24b495ca43 | ||
|
|
ff4fd1411e | ||
|
|
03eed5f4f9 | ||
|
|
1c89968b69 | ||
|
|
01ce469a0f | ||
|
|
c6347a3cf1 | ||
|
|
bf7e581445 | ||
|
|
0fe9253d3b | ||
|
|
6a9042fd9c | ||
|
|
9e62fdc0b8 | ||
|
|
a33b70f8bd | ||
|
|
bfc06ed81f | ||
|
|
c3c8ac7ff0 | ||
|
|
bfd0c00708 | ||
|
|
ef0c84072b | ||
|
|
066972ff75 | ||
|
|
608853d4fa | ||
|
|
1774305c2d | ||
|
|
3295966022 | ||
|
|
8f43f5a4a1 | ||
|
|
379f40c1be | ||
|
|
c2282af879 | ||
|
|
d057b1909f | ||
|
|
2ba4e99114 | ||
|
|
f61a6ba5ff | ||
|
|
34a6389a92 | ||
|
|
b675adbbb0 | ||
|
|
e46da0e2f2 | ||
|
|
44b257a749 | ||
|
|
fe2599eb35 | ||
|
|
d791a189bc | ||
|
|
bbc521a2f3 | ||
|
|
56f6da606c | ||
|
|
3e098b7479 | ||
|
|
7e2fe6d5be | ||
|
|
c4b2cf9394 | ||
|
|
9ac823833a | ||
|
|
60132c085c | ||
|
|
5e14e65eb0 | ||
|
|
64063fb77d | ||
|
|
aa309ef27c | ||
|
|
4c81c9e21e | ||
|
|
f4912eb23b | ||
|
|
7f85b8b33f | ||
|
|
85c68f78da | ||
|
|
af03085d5f | ||
|
|
b7d747ee17 | ||
|
|
b6f100888a | ||
|
|
3cfd392e3e | ||
|
|
7ed98a8655 | ||
|
|
d78eb4a4e5 | ||
|
|
a3d168b646 | ||
|
|
5018df511b | ||
|
|
09345a9d53 | ||
|
|
8b17cd3cde | ||
|
|
403fcd8fff | ||
|
|
409be4020b | ||
|
|
24801a220c | ||
|
|
19b9f4e1c1 | ||
|
|
48d584df58 | ||
|
|
dd999a29fd | ||
|
|
75fdfb5a0b | ||
|
|
6b4db4e9ae | ||
|
|
2571b24f22 | ||
|
|
855a9eea44 | ||
|
|
189e299592 | ||
|
|
6cbaa35849 | ||
|
|
cb1cfa4d94 | ||
|
|
5bbf893a37 | ||
|
|
3ddbfb5dea | ||
|
|
5352d062d5 | ||
|
|
e15cbfca33 | ||
|
|
51b58f911e | ||
|
|
7acfbb9eed | ||
|
|
4bf9853a25 | ||
|
|
58c6db0a8f | ||
|
|
aed52a7829 | ||
|
|
a1e24a3f95 | ||
|
|
11cff29916 | ||
|
|
f184b9bcc4 | ||
|
|
bab0024e0c | ||
|
|
deed92cff7 | ||
|
|
a9bc949679 | ||
|
|
1411410f4e | ||
|
|
648fbe1b10 | ||
|
|
7042f89620 | ||
|
|
e235fffb5e | ||
|
|
6aadd13450 | ||
|
|
349de098af | ||
|
|
5527e585f6 | ||
|
|
a6e9814dfc | ||
|
|
f01a7d3933 | ||
|
|
d2cd3b899f | ||
|
|
ac2c0d5d84 | ||
|
|
f0d0b512ca | ||
|
|
c859ffd0f7 | ||
|
|
4eb57f3cc5 | ||
|
|
6218bfaf9e | ||
|
|
4d5cdcaeae | ||
|
|
6ad62a6f2f | ||
|
|
37d4b151d7 | ||
|
|
37c1d804f6 | ||
|
|
d200df3e9c | ||
|
|
eb43e416ae | ||
|
|
e6244f71bd | ||
|
|
403277ed06 | ||
|
|
dbe8a59c3c | ||
|
|
a98de54db4 | ||
|
|
7edb7266f2 | ||
|
|
d14e077511 | ||
|
|
211c14e316 | ||
|
|
4fbc140551 | ||
|
|
ee8e65c80d | ||
|
|
1db2e0282a | ||
|
|
2351f73c76 | ||
|
|
20a38c3aac | ||
|
|
bca25d0f5f | ||
|
|
b26853e4d7 | ||
|
|
39049f82fc | ||
|
|
a30250f758 | ||
|
|
629737cda3 | ||
|
|
ec41411675 | ||
|
|
becdf2bfeb | ||
|
|
1e723945f8 | ||
|
|
dfb7599bb6 | ||
|
|
e1d3363ad9 | ||
|
|
c36c750c5d | ||
|
|
c7581c0847 | ||
|
|
936d65291f | ||
|
|
a64030ad93 | ||
|
|
01d60ad4e9 | ||
|
|
06b64c6a87 | ||
|
|
0eff4e2bc0 | ||
|
|
44d6139db2 | ||
|
|
506e3004b7 | ||
|
|
9ce4c7a468 | ||
|
|
2fc724e469 | ||
|
|
afb69a7f03 | ||
|
|
cd2dd9f12d | ||
|
|
29963f74d6 | ||
|
|
565a017ebd | ||
|
|
0b85847524 | ||
|
|
cfc46edfb8 | ||
|
|
f250373673 | ||
|
|
b0acc13da7 | ||
|
|
d705af8965 | ||
|
|
a401dfddff | ||
|
|
f579fd925e | ||
|
|
e6d86eaa9b | ||
|
|
348e45a5cd | ||
|
|
2120e9cf2a | ||
|
|
3002acc895 | ||
|
|
0b3c313280 | ||
|
|
982ab4b4fa | ||
|
|
a0ee2f384b | ||
|
|
56a739655f | ||
|
|
150ee44da0 | ||
|
|
78795e3167 | ||
|
|
b0dd3cd818 | ||
|
|
ef12ec54d7 | ||
|
|
495b774965 | ||
|
|
1381bb5c54 | ||
|
|
f1d4794dd1 | ||
|
|
d58473c270 | ||
|
|
7adf32f36e | ||
|
|
5c3beb4160 | ||
|
|
b82c307007 | ||
|
|
a7010e7598 | ||
|
|
f850cbf780 | ||
|
|
4581fe4f22 | ||
|
|
35df54ae99 | ||
|
|
f8a5f91687 | ||
|
|
4b71557584 | ||
|
|
feda903f2f | ||
|
|
150e264f0d | ||
|
|
b592f6ae92 | ||
|
|
37ba8fb57d | ||
|
|
72f80cdbed | ||
|
|
c070f20669 | ||
|
|
a4d5165a3d | ||
|
|
4fdddfb585 | ||
|
|
0575e96b60 | ||
|
|
d0a8749986 | ||
|
|
44fbf8afe2 | ||
|
|
1eb9202233 | ||
|
|
b7da92d225 | ||
|
|
e4f6d0db1f | ||
|
|
0a8bd9f687 | ||
|
|
f2608998f9 | ||
|
|
ffb08d32ce | ||
|
|
119e776ddc | ||
|
|
652930d5aa | ||
|
|
e3babe97e4 | ||
|
|
72d01865ae | ||
|
|
b9664681a3 | ||
|
|
fd5c545189 | ||
|
|
0639f4b00f | ||
|
|
ab49986238 | ||
|
|
a4fdc50d1d | ||
|
|
ed228b6183 | ||
|
|
e0e675531a | ||
|
|
44e0879224 | ||
|
|
1e6fa93ea2 | ||
|
|
2aaed6bffd | ||
|
|
2d367a8b47 | ||
|
|
52c18abc5e | ||
|
|
595c70ed56 | ||
|
|
9faec8decd | ||
|
|
90dc1f6cf8 | ||
|
|
ba01976151 | ||
|
|
4d7f5a8a09 | ||
|
|
2d01fa6f94 | ||
|
|
970f848b84 | ||
|
|
31feec0465 | ||
|
|
2466c14300 | ||
|
|
49927fcfb7 | ||
|
|
f612683dfb | ||
|
|
11e6ad2153 | ||
|
|
d041c69e0d | ||
|
|
b394052145 | ||
|
|
e94ddb4179 |
@@ -4,3 +4,4 @@ Build
|
||||
Demos
|
||||
./Aristo
|
||||
WebSite
|
||||
.push-package
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
[submodule "External/narwhal"]
|
||||
path = External/narwhal
|
||||
url = git://github.com/tlrobinson/narwhal.git
|
||||
[submodule "External/jack"]
|
||||
path = External/jack
|
||||
url = git://github.com/tlrobinson/jack.git
|
||||
[submodule "External/browserjs"]
|
||||
path = External/browserjs
|
||||
url = git://github.com/tlrobinson/browserjs.git
|
||||
[submodule "External/ojunit"]
|
||||
path = External/ojunit
|
||||
url = git://github.com/280north/ojunit.git
|
||||
@@ -43,6 +43,7 @@
|
||||
@import "CPCompatibility.j"
|
||||
@import "CPControl.j"
|
||||
@import "CPCookie.j"
|
||||
@import "CPCursor.j"
|
||||
@import "CPDocument.j"
|
||||
@import "CPDocumentController.j"
|
||||
@import "CPEvent.j"
|
||||
@@ -56,6 +57,7 @@
|
||||
@import "CPMenu.j"
|
||||
@import "CPMenuItem.j"
|
||||
@import "CPOpenPanel.j"
|
||||
@import "CPOutlineView.j"
|
||||
@import "CPPanel.j"
|
||||
@import "CPPasteboard.j"
|
||||
@import "CPPopUpButton.j"
|
||||
@@ -76,7 +78,9 @@
|
||||
@import "CPTextField.j"
|
||||
@import "CPToolbar.j"
|
||||
@import "CPToolbarItem.j"
|
||||
@import "CPTreeNode.j"
|
||||
@import "CPView.j"
|
||||
@import "CPViewAnimation.j"
|
||||
@import "CPViewController.j"
|
||||
@import "CPWebView.j"
|
||||
@import "CPWindow.j"
|
||||
|
||||
@@ -197,6 +197,20 @@
|
||||
return indexSet;
|
||||
}
|
||||
|
||||
- (void)setEnabled:(BOOL)isEnabled forItemAtIndex:(CPInteger)anIndex
|
||||
{
|
||||
var itemView = _itemViews[anIndex];
|
||||
if (!itemView)
|
||||
return;
|
||||
|
||||
if (!isEnabled)
|
||||
[self collapseItemAtIndex:anIndex];
|
||||
else
|
||||
[self expandItemAtIndex:anIndex];
|
||||
|
||||
[itemView setEnabled:isEnabled];
|
||||
}
|
||||
|
||||
- (void)_invalidateItemsStartingAtIndex:(CPInteger)anIndex
|
||||
{
|
||||
if (_dirtyItemIndex === CPNotFound)
|
||||
@@ -301,6 +315,12 @@
|
||||
[_headerView setStringValue:aLabel];
|
||||
}
|
||||
|
||||
- (void)setEnabled:(BOOL)isEnabled
|
||||
{
|
||||
if ([_headerView respondsToSelector:@selector(setEnabled:)])
|
||||
[_headerView setEnabled:isEnabled];
|
||||
}
|
||||
|
||||
- (void)setContentView:(CPView)aView
|
||||
{
|
||||
if (_contentView === aView)
|
||||
@@ -312,7 +332,7 @@
|
||||
|
||||
_contentView = aView;
|
||||
|
||||
[_contentView addObserver:self forKeyPath:@"frame" options:0 context:NULL];
|
||||
[_contentView addObserver:self forKeyPath:@"frame" options:CPKeyValueObservingOptionOld | CPKeyValueObservingOptionNew context:NULL];
|
||||
|
||||
[self addSubview:_contentView];
|
||||
|
||||
|
||||
@@ -148,8 +148,9 @@ var CPAlertWarningImage,
|
||||
var button = _buttons[i];
|
||||
|
||||
[button setFrameSize:CGSizeMake([button frame].size.width, (styleMask == CPHUDBackgroundWindowMask) ? 20.0 : 24.0)];
|
||||
[button setBezelStyle:(styleMask & CPHUDBackgroundWindowMask) ? CPHUDBezelStyle : CPRoundedBezelStyle];
|
||||
|
||||
[button setTheme:(_windowStyle === CPHUDBackgroundWindowMask) ? [CPTheme themeNamed:"Aristo-HUD"] : [CPTheme defaultTheme]];
|
||||
|
||||
[[_alertPanel contentView] addSubview:button];
|
||||
}
|
||||
|
||||
@@ -161,6 +162,7 @@ var CPAlertWarningImage,
|
||||
[_messageLabel setFont:[CPFont boldSystemFontOfSize:13.0]];
|
||||
[_messageLabel setLineBreakMode:CPLineBreakByWordWrapping];
|
||||
[_messageLabel setAlignment:CPJustifiedTextAlignment];
|
||||
[_messageLabel setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
|
||||
|
||||
_alertImageView = [[CPImageView alloc] initWithFrame:CGRectMake(15.0, 12.0, 32.0, 32.0)];
|
||||
}
|
||||
@@ -262,7 +264,9 @@ var CPAlertWarningImage,
|
||||
[button setTag:_buttonCount];
|
||||
[button setAction:@selector(_notifyDelegate:)];
|
||||
|
||||
[button setBezelStyle:(_windowStyle == CPHUDBackgroundWindowMask) ? CPHUDBezelStyle : CPRoundRectBezelStyle];
|
||||
[button setTheme:(_windowStyle === CPHUDBackgroundWindowMask) ? [CPTheme themeNamed:"Aristo-HUD"] : [CPTheme defaultTheme]];
|
||||
[button setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin];
|
||||
|
||||
[[_alertPanel contentView] addSubview:button];
|
||||
|
||||
if (_buttonCount == 0)
|
||||
|
||||
@@ -40,6 +40,10 @@ CPApp = nil;
|
||||
CPApplicationWillFinishLaunchingNotification = @"CPApplicationWillFinishLaunchingNotification";
|
||||
CPApplicationDidFinishLaunchingNotification = @"CPApplicationDidFinishLaunchingNotification";
|
||||
CPApplicationWillTerminateNotification = @"CPApplicationWillTerminateNotification";
|
||||
CPApplicationWillBecomeActiveNotification = @"CPApplicationWillBecomeActiveNotification";
|
||||
CPApplicationDidBecomeActiveNotification = @"CPApplicationDidBecomeActiveNotification";
|
||||
CPApplicationWillResignActiveNotification = @"CPApplicationWillResignActiveNotification";
|
||||
CPApplicationDidResignActiveNotification = @"CPApplicationDidResignActiveNotification";
|
||||
|
||||
CPTerminateNow = YES;
|
||||
CPTerminateCancel = NO;
|
||||
@@ -83,6 +87,8 @@ CPRunContinuesResponse = -1002;
|
||||
CPArray _windows;
|
||||
CPWindow _keyWindow;
|
||||
CPWindow _mainWindow;
|
||||
CPWindow _previousKeyWindow;
|
||||
CPWindow _previousMainWindow;
|
||||
|
||||
CPMenu _mainMenu;
|
||||
CPDocumentController _documentController;
|
||||
@@ -92,10 +98,15 @@ CPRunContinuesResponse = -1002;
|
||||
//
|
||||
id _delegate;
|
||||
BOOL _finishedLaunching;
|
||||
BOOL _isActive;
|
||||
|
||||
CPDictionary _namedArgs;
|
||||
CPArray _args;
|
||||
CPString _fullArgsString;
|
||||
|
||||
CPImage _applicationIconImage;
|
||||
|
||||
CPPanel _aboutPanel;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -215,6 +226,26 @@ CPRunContinuesResponse = -1002;
|
||||
removeObserver:_delegate
|
||||
name:CPApplicationDidFinishLaunchingNotification
|
||||
object:self];
|
||||
|
||||
[defaultCenter
|
||||
removeObserver:_delegate
|
||||
name:CPApplicationWillBecomeActiveNotification
|
||||
object:self];
|
||||
|
||||
[defaultCenter
|
||||
removeObserver:_delegate
|
||||
name:CPApplicationDidBecomeActiveNotification
|
||||
object:self];
|
||||
|
||||
[defaultCenter
|
||||
removeObserver:_delegate
|
||||
name:CPApplicationWillResignActiveNotification
|
||||
object:self];
|
||||
|
||||
[defaultCenter
|
||||
removeObserver:_delegate
|
||||
name:CPApplicationDidResignActiveNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
_delegate = aDelegate;
|
||||
@@ -232,6 +263,34 @@ CPRunContinuesResponse = -1002;
|
||||
selector:@selector(applicationDidFinishLaunching:)
|
||||
name:CPApplicationDidFinishLaunchingNotification
|
||||
object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(applicationWillBecomeActive:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(applicationWillBecomeActive:)
|
||||
name:CPApplicationWillBecomeActiveNotification
|
||||
object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(applicationDidBecomeActive:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(applicationDidBecomeActive:)
|
||||
name:CPApplicationDidBecomeActiveNotification
|
||||
object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(applicationWillResignActive:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(applicationWillResignActive:)
|
||||
name:CPApplicationWillResignActiveNotification
|
||||
object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(applicationDidResignActive:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(applicationDidResignActive:)
|
||||
name:CPApplicationDidResignActiveNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -250,6 +309,14 @@ CPRunContinuesResponse = -1002;
|
||||
*/
|
||||
- (void)finishLaunching
|
||||
{
|
||||
// At this point we clear the window.status to eliminate Safari's "Cancelled" error message
|
||||
// The message shouldn't be displayed, because only an XHR is cancelled, but it is a usability issue.
|
||||
// We do it here so that applications can change it in willFinish or didFinishLaunching
|
||||
window.status = " ";
|
||||
|
||||
// We also want to set the default cursor on the body, so that buttons and things don't have an iBeam
|
||||
[[CPCursor arrowCursor] set];
|
||||
|
||||
var bundle = [CPBundle mainBundle],
|
||||
types = [bundle objectForInfoDictionaryKey:@"CPBundleDocumentTypes"];
|
||||
|
||||
@@ -302,11 +369,88 @@ CPRunContinuesResponse = -1002;
|
||||
|
||||
- (void)terminate:(id)aSender
|
||||
{
|
||||
[[CPDocumentController sharedDocumentController] closeAllDocumentsWithDelegate:self
|
||||
didCloseAllSelector:@selector(_documentController:didCloseAll:context:)
|
||||
contextInfo:nil];
|
||||
if (![CPPlatform isBrowser])
|
||||
{
|
||||
[[CPDocumentController sharedDocumentController] closeAllDocumentsWithDelegate:self
|
||||
didCloseAllSelector:@selector(_documentController:didCloseAll:context:)
|
||||
contextInfo:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[[self keyWindow] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setApplicationIconImage:(CPImage)anImage
|
||||
{
|
||||
_applicationIconImage = anImage;
|
||||
}
|
||||
|
||||
- (CPImage)applicationIconImage
|
||||
{
|
||||
if (_applicationIconImage)
|
||||
return _applicationIconImage;
|
||||
|
||||
var imagePath = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPApplicationIcon"];
|
||||
if (imagePath)
|
||||
_applicationIconImage = [[CPImage alloc] initWithContentsOfFile:imagePath];
|
||||
|
||||
return _applicationIconImage;
|
||||
}
|
||||
|
||||
- (void)orderFrontStandardAboutPanel:(id)sender
|
||||
{
|
||||
[self orderFrontStandardAboutPanelWithOptions:nil];
|
||||
}
|
||||
|
||||
- (void)orderFrontStandardAboutPanelWithOptions:(CPDictionary)options
|
||||
{
|
||||
if (!_aboutPanel)
|
||||
{
|
||||
var mainInfo = [[CPBundle mainBundle] infoDictionary],
|
||||
applicationTitle = [options objectForKey:"ApplicationName"] || [mainInfo objectForKey:@"CPBundleName"],
|
||||
applicationIcon = [options objectForKey:@"ApplicationIcon"] || [self applicationIconImage],
|
||||
version = [options objectForKey:@"Version"] || [mainInfo objectForKey:@"CPBundleVersion"],
|
||||
applicationVersion = [options objectForKey:@"ApplicationVersion"] || [mainInfo objectForKey:@"CPBundleShortVersionString"],
|
||||
copyright = [options objectForKey:@"Copyright"] || [mainInfo objectForKey:@"CPHumanReadableCopyright"];
|
||||
|
||||
var aboutPanelController = [[CPWindowController alloc] initWithWindowCibName:@"AboutPanel"],
|
||||
aboutPanel = [aboutPanelController window],
|
||||
contentView = [aboutPanel contentView],
|
||||
imageView = [contentView viewWithTag:1],
|
||||
applicationLabel = [contentView viewWithTag:2],
|
||||
versionLabel = [contentView viewWithTag:3],
|
||||
copyrightLabel = [contentView viewWithTag:4],
|
||||
standardPath = [[CPBundle bundleForClass:[self class]] pathForResource:@"standardApplicationIcon.png"];
|
||||
|
||||
// FIXME move this into the CIB eventually
|
||||
[applicationLabel setFont:[CPFont boldSystemFontOfSize:14.0]];
|
||||
[applicationLabel setAlignment:CPCenterTextAlignment];
|
||||
[versionLabel setAlignment:CPCenterTextAlignment];
|
||||
[copyrightLabel setAlignment:CPCenterTextAlignment];
|
||||
|
||||
[imageView setImage:applicationIcon || [[CPImage alloc] initWithContentsOfFile:standardPath
|
||||
size:CGSizeMake(256, 256)]];
|
||||
|
||||
[applicationLabel setStringValue:applicationTitle || ""];
|
||||
|
||||
if (applicationVersion && version)
|
||||
[versionLabel setStringValue:@"Version " + applicationVersion + " (" + version + ")"];
|
||||
else if (applicationVersion || version)
|
||||
[versionLabel setStringValue:@"Version " + (applicationVersion || version)];
|
||||
else
|
||||
[versionLabel setStringValue:@""];
|
||||
|
||||
[copyrightLabel setStringValue:copyright || ""];
|
||||
[aboutPanel center];
|
||||
|
||||
_aboutPanel = aboutPanel;
|
||||
}
|
||||
|
||||
[_aboutPanel orderFront:self];
|
||||
}
|
||||
|
||||
|
||||
- (void)_documentController:(NSDocumentController *)docController didCloseAll:(BOOL)didCloseAll context:(Object)info
|
||||
{
|
||||
// callback method for terminate:
|
||||
@@ -330,7 +474,27 @@ CPRunContinuesResponse = -1002;
|
||||
|
||||
- (void)activateIgnoringOtherApps:(BOOL)shouldIgnoreOtherApps
|
||||
{
|
||||
[self _willBecomeActive];
|
||||
|
||||
[CPPlatform activateIgnoringOtherApps:shouldIgnoreOtherApps];
|
||||
_isActive = YES;
|
||||
|
||||
[self _willResignActive];
|
||||
}
|
||||
|
||||
- (void)deactivate
|
||||
{
|
||||
[self _willResignActive];
|
||||
|
||||
[CPPlatform deactivate];
|
||||
_isActive = NO;
|
||||
|
||||
[self _didResignActive];
|
||||
}
|
||||
|
||||
- (void)isActive
|
||||
{
|
||||
return _isActive;
|
||||
}
|
||||
|
||||
- (void)hideOtherApplications:(id)aSender
|
||||
@@ -462,13 +626,28 @@ CPRunContinuesResponse = -1002;
|
||||
{
|
||||
_currentEvent = anEvent;
|
||||
|
||||
var willPropagate = [[[anEvent window] platformWindow] _willPropagateCurrentDOMEvent];
|
||||
|
||||
// temporarily pretend we won't propagate the event. we'll restore the saved value later
|
||||
// we do this outside the if so that changes user code might make in _handleKeyEquiv. are preserved
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:NO];
|
||||
|
||||
// Check if this is a candidate for key equivalent...
|
||||
if ([anEvent _couldBeKeyEquivalent] && [self _handleKeyEquivalent:anEvent])
|
||||
{
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:NO];
|
||||
var characters = [anEvent characters],
|
||||
modifierFlags = [anEvent modifierFlags];
|
||||
|
||||
// Unconditionally propagate on these keys to solve browser copy paste bugs
|
||||
if ((characters == "c" || characters == "x" || characters == "v") && (modifierFlags & CPPlatformActionKeyMask))
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// if we make it this far, then restore the original willPropagate value
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:willPropagate];
|
||||
|
||||
if (_eventListeners.length)
|
||||
{
|
||||
if (_eventListeners[_eventListeners.length - 1]._mask & (1 << [anEvent type]))
|
||||
@@ -520,6 +699,14 @@ CPRunContinuesResponse = -1002;
|
||||
return _windows;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns an array of visible CPWindow objects, ordered by their front to back order on the screen.
|
||||
*/
|
||||
- (CPArray)orderedWindows
|
||||
{
|
||||
return CPWindowObjectList();
|
||||
}
|
||||
|
||||
- (void)hide:(id)aSender
|
||||
{
|
||||
[CPPlatform hide:self];
|
||||
@@ -559,16 +746,6 @@ CPRunContinuesResponse = -1002;
|
||||
[[CPColorPanel sharedColorPanel] orderFront:self];
|
||||
}
|
||||
|
||||
- (void)orderFrontStandardAboutPanel:(id)aSender
|
||||
{
|
||||
[self orderFrontStandardAboutPanelWithOptions:nil];
|
||||
}
|
||||
|
||||
- (void)orderFrontStandardAboutPanelWithOptions:(CPDictionary)aDictionary
|
||||
{
|
||||
// FIXME: Implement.
|
||||
}
|
||||
|
||||
// Posting Actions
|
||||
/*!
|
||||
Tries to perform the action with an argument. Performs
|
||||
@@ -607,7 +784,7 @@ CPRunContinuesResponse = -1002;
|
||||
- (BOOL)sendAction:(SEL)anAction to:(id)aTarget from:(id)aSender
|
||||
{
|
||||
var target = [self targetForAction:anAction to:aTarget from:aSender];
|
||||
|
||||
|
||||
if (!target)
|
||||
return NO;
|
||||
|
||||
@@ -769,6 +946,7 @@ CPRunContinuesResponse = -1002;
|
||||
return;
|
||||
}
|
||||
|
||||
[aWindow orderFront:self];
|
||||
[aWindow _attachSheet:aSheet modalDelegate:aModalDelegate didEndSelector:aDidEndSelector contextInfo:aContextInfo];
|
||||
}
|
||||
|
||||
@@ -795,10 +973,9 @@ CPRunContinuesResponse = -1002;
|
||||
[self endSheet:sheet returnCode:0];
|
||||
}
|
||||
|
||||
|
||||
- (CPArray)arguments
|
||||
{
|
||||
if(_fullArgsString != window.location.hash)
|
||||
if(_fullArgsString !== window.location.hash)
|
||||
[self _reloadArguments];
|
||||
|
||||
return _args;
|
||||
@@ -831,12 +1008,18 @@ CPRunContinuesResponse = -1002;
|
||||
- (void)_reloadArguments
|
||||
{
|
||||
_fullArgsString = window.location.hash;
|
||||
var args = _fullArgsString.replace("#", "").split("/").slice(0);
|
||||
|
||||
for(var i=0, count = args.length; i<count; i++)
|
||||
args[i] = decodeURIComponent(args[i]);
|
||||
|
||||
_args = args;
|
||||
if (_fullArgsString.length)
|
||||
{
|
||||
var args = _fullArgsString.substring(1).split("/");
|
||||
|
||||
for (var i = 0, count = args.length; i < count; i++)
|
||||
args[i] = decodeURIComponent(args[i]);
|
||||
|
||||
_args = args;
|
||||
}
|
||||
else
|
||||
_args = [];
|
||||
}
|
||||
|
||||
- (CPDictionary)namedArguments
|
||||
@@ -858,10 +1041,71 @@ CPRunContinuesResponse = -1002;
|
||||
return !![_documentController openDocumentWithContentsOfURL:aURL display:YES error:NULL];
|
||||
}
|
||||
|
||||
- (void)_willBecomeActive
|
||||
{
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationWillBecomeActiveNotification
|
||||
object:self
|
||||
userInfo:nil];
|
||||
}
|
||||
|
||||
- (void)_didBecomeActive
|
||||
{
|
||||
if (![self keyWindow] && _previousKeyWindow &&
|
||||
[[self windows] indexOfObjectIdenticalTo:_previousKeyWindow] !== CPNotFound)
|
||||
[_previousKeyWindow makeKeyWindow];
|
||||
|
||||
if (![self mainWindow] && _previousMainWindow &&
|
||||
[[self windows] indexOfObjectIdenticalTo:_previousMainWindow] !== CPNotFound)
|
||||
[_previousMainWindow makeMainWindow];
|
||||
|
||||
if ([self keyWindow])
|
||||
[[self keyWindow] orderFront:self];
|
||||
else if ([self mainWindow])
|
||||
[[self mainWindow] makeKeyAndOrderFront:self];
|
||||
else
|
||||
[[[self mainMenu] window] makeKeyWindow]; //FIXME this may not actually work
|
||||
|
||||
_previousKeyWindow = nil;
|
||||
_previousMainWindow = nil;
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationDidBecomeActiveNotification
|
||||
object:self
|
||||
userInfo:nil];
|
||||
}
|
||||
|
||||
- (void)_willResignActive
|
||||
{
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationWillResignActiveNotification
|
||||
object:self
|
||||
userInfo:nil];
|
||||
}
|
||||
|
||||
- (void)_didResignActive
|
||||
{
|
||||
if (self._activeMenu)
|
||||
[self._activeMenu cancelTracking];
|
||||
|
||||
if ([self keyWindow])
|
||||
{
|
||||
_previousKeyWindow = [self keyWindow];
|
||||
[_previousKeyWindow resignKeyWindow];
|
||||
}
|
||||
|
||||
if ([self mainWindow])
|
||||
{
|
||||
_previousMainWindow = [self mainWindow];
|
||||
[_previousMainWindow resignMainWindow];
|
||||
}
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationDidResignActiveNotification
|
||||
object:self
|
||||
userInfo:nil];
|
||||
}
|
||||
|
||||
+ (CPString)defaultThemeName
|
||||
{
|
||||
// FIXME: don't hardcode
|
||||
return ([[CPBundle mainBundle] objectForInfoDictionaryKey:"CPDefaultTheme"] || @"Aristo");
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -904,29 +1148,8 @@ function CPApplicationMain(args, namedArgs)
|
||||
|
||||
[principalClass sharedApplication];
|
||||
|
||||
//FIXME?
|
||||
if (!args)
|
||||
{
|
||||
var args = [CPApp arguments];
|
||||
|
||||
if([args containsObject:"debug"])
|
||||
CPLogRegister(CPLogPopup);
|
||||
}
|
||||
|
||||
if (!namedArgs)
|
||||
{
|
||||
var searchParams = window.location.search.substring(1).split("&");
|
||||
namedArgs = [CPDictionary dictionary];
|
||||
|
||||
for(var i=0; i<searchParams.length; i++)
|
||||
{
|
||||
var index = searchParams[i].indexOf('=');
|
||||
if(index == -1)
|
||||
[namedArgs setObject: "" forKey:searchParams[i]];
|
||||
else
|
||||
[namedArgs setObject: searchParams[i].substring(index+1) forKey: searchParams[i].substring(0, index)];
|
||||
}
|
||||
}
|
||||
if ([args containsObject:"debug"])
|
||||
CPLogRegister(CPLogPopup);
|
||||
|
||||
CPApp._args = args;
|
||||
CPApp._namedArgs = namedArgs;
|
||||
@@ -940,7 +1163,7 @@ var _CPAppBootstrapperActions = nil;
|
||||
{
|
||||
}
|
||||
|
||||
+ (void)actions
|
||||
+ (CPArray)actions
|
||||
{
|
||||
return [@selector(bootstrapPlatform), @selector(loadDefaultTheme), @selector(loadMainCibFile)];
|
||||
}
|
||||
@@ -968,16 +1191,16 @@ var _CPAppBootstrapperActions = nil;
|
||||
|
||||
+ (BOOL)loadDefaultTheme
|
||||
{
|
||||
var blend = [[CPThemeBlend alloc] initWithContentsOfURL:[[CPBundle bundleForClass:[CPApplication class]] pathForResource:@"Aristo.blend"]];
|
||||
var blend = [[CPThemeBlend alloc] initWithContentsOfURL:[[CPBundle bundleForClass:[CPApplication class]] pathForResource:[CPApplication defaultThemeName] + ".blend"]];
|
||||
|
||||
[blend loadWithDelegate:self];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (void)blendDidFinishLoading:(CPBundle)aBundle
|
||||
+ (void)blendDidFinishLoading:(CPThemeBlend)aThemeBlend
|
||||
{
|
||||
[CPTheme setDefaultTheme:[CPTheme themeNamed:@"Aristo"]];
|
||||
[CPTheme setDefaultTheme:[CPTheme themeNamed:[CPApplication defaultThemeName]]];
|
||||
|
||||
[self performActions];
|
||||
}
|
||||
@@ -1004,4 +1227,9 @@ var _CPAppBootstrapperActions = nil;
|
||||
[self performActions];
|
||||
}
|
||||
|
||||
+ (void)reset
|
||||
{
|
||||
_CPAppBootstrapperActions = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -24,32 +24,11 @@
|
||||
@import "CGGeometry.j"
|
||||
|
||||
@import "CPControl.j"
|
||||
@import "CPStringDrawing.j"
|
||||
|
||||
#include "CoreGraphics/CGGeometry.h"
|
||||
|
||||
|
||||
CPScaleProportionally = 0;
|
||||
CPScaleToFit = 1;
|
||||
CPScaleNone = 2;
|
||||
|
||||
|
||||
/* @group CPCellImagePosition */
|
||||
|
||||
CPNoImage = 0;
|
||||
CPImageOnly = 1;
|
||||
CPImageLeft = 2;
|
||||
CPImageRight = 3;
|
||||
CPImageBelow = 4;
|
||||
CPImageAbove = 5;
|
||||
CPImageOverlaps = 6;
|
||||
|
||||
|
||||
/* @group CPButtonState */
|
||||
|
||||
CPOnState = 1;
|
||||
CPOffState = 0;
|
||||
CPMixedState = -1;
|
||||
|
||||
/* @group CPBezelStyle */
|
||||
|
||||
CPRoundedBezelStyle = 1;
|
||||
@@ -145,7 +124,7 @@ CPButtonStateMixed = CPThemeState("mixed");
|
||||
|
||||
+ (id)themeAttributes
|
||||
{
|
||||
return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMakeZero(), nil]
|
||||
return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMakeZero(), [CPNull null]]
|
||||
forKeys:[@"bezel-inset", @"content-inset", @"bezel-color"]];
|
||||
}
|
||||
|
||||
@@ -192,8 +171,8 @@ CPButtonStateMixed = CPThemeState("mixed");
|
||||
|
||||
_allowsMixedState = aFlag;
|
||||
|
||||
if (!_allowsMixedState)
|
||||
[self unsetThemeState:CPButtonStateMixed];
|
||||
if (!_allowsMixedState && [self state] === CPMixedState)
|
||||
[self setState:CPOnState];
|
||||
}
|
||||
|
||||
- (void)setObjectValue:(id)anObjectValue
|
||||
@@ -460,7 +439,7 @@ CPButtonStateMixed = CPThemeState("mixed");
|
||||
return bounds;
|
||||
}
|
||||
|
||||
- (CGRect)bezelRectForBounds:(CFRect)bounds
|
||||
- (CGRect)bezelRectForBounds:(CGRect)bounds
|
||||
{
|
||||
if (![self isBordered])
|
||||
return _CGRectMakeZero();
|
||||
|
||||
@@ -8,6 +8,16 @@
|
||||
{
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
self = [super initWithFrame:aFrame];
|
||||
|
||||
if (self)
|
||||
[self setNeedsLayout];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (CPString)themeClass
|
||||
{
|
||||
return @"button-bar";
|
||||
@@ -15,7 +25,7 @@
|
||||
|
||||
+ (id)themeAttributes
|
||||
{
|
||||
return [CPDictionary dictionaryWithObjects:[nil]
|
||||
return [CPDictionary dictionaryWithObjects:[[CPNull null]]
|
||||
forKeys:[@"bezel-color"]];
|
||||
}
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@
|
||||
*/
|
||||
- (CPIndexSet)selectionIndexes
|
||||
{
|
||||
return _selectionIndexes;
|
||||
return [_selectionIndexes copy];
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
@@ -333,6 +333,8 @@
|
||||
while (count--)
|
||||
{
|
||||
[[_items[count] view] removeFromSuperview];
|
||||
[_items[count] setSelected:NO];
|
||||
|
||||
_cachedItems.push(_items[count]);
|
||||
}
|
||||
|
||||
@@ -351,7 +353,11 @@
|
||||
|
||||
[self addSubview:[_items[index] view]];
|
||||
}
|
||||
|
||||
|
||||
index = CPNotFound;
|
||||
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound)
|
||||
[_items[index] setSelected:YES];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
@@ -672,6 +678,103 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPCollectionView (KeyboardInteraction)
|
||||
|
||||
- (CGRect)rectForItemAtIndex:(int)index
|
||||
{
|
||||
// Don't re-compute anything just grab the current frame
|
||||
// This allows subclasses to override tile without messing this up.
|
||||
return [[_items[index] view] frame];
|
||||
}
|
||||
|
||||
- (CGRect)rectForItemsAtIndexes:(CPIndexSet)indexSet
|
||||
{
|
||||
var indexArray = [],
|
||||
rect = nil;
|
||||
|
||||
[indexSet getIndexes:indexArray maxCount:-1 inIndexRange:nil];
|
||||
|
||||
for (var i = 0, count = indexArray.length; i < count; ++i)
|
||||
{
|
||||
var index = indexArray[i];
|
||||
if (rect == nil)
|
||||
rect = [self rectForItemAtIndex:index];
|
||||
else
|
||||
rect = CGRectUnion(rect, [self rectForItemAtIndex:index]);
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (void)_scrollToSelection
|
||||
{
|
||||
var rect = [self rectForItemsAtIndexes:[self selectionIndexes]];
|
||||
if (rect)
|
||||
[self scrollRectToVisible:rect];
|
||||
}
|
||||
|
||||
- (void)moveLeft:(id)sender
|
||||
{
|
||||
var index = [[self selectionIndexes] firstIndex];
|
||||
if (index === CPNotFound)
|
||||
index = [[self items] count];
|
||||
|
||||
index = MAX(index - 1, 0);
|
||||
|
||||
[self setSelectionIndexes:[CPIndexSet indexSetWithIndex:index]];
|
||||
[self _scrollToSelection];
|
||||
}
|
||||
|
||||
- (void)moveRight:(id)sender
|
||||
{
|
||||
var index = MIN([[self selectionIndexes] firstIndex] + 1, [[self items] count]-1);
|
||||
|
||||
[self setSelectionIndexes:[CPIndexSet indexSetWithIndex:index]];
|
||||
[self _scrollToSelection];
|
||||
}
|
||||
|
||||
- (void)moveDown:(id)sender
|
||||
{
|
||||
var index = MIN([[self selectionIndexes] firstIndex] + [self numberOfColumns], [[self items] count]-1);
|
||||
|
||||
[self setSelectionIndexes:[CPIndexSet indexSetWithIndex:index]];
|
||||
[self _scrollToSelection];
|
||||
}
|
||||
|
||||
- (void)moveUp:(id)sender
|
||||
{
|
||||
var index = [[self selectionIndexes] firstIndex];
|
||||
if (index == CPNotFound)
|
||||
index = [[self items] count];
|
||||
|
||||
index = MAX(0, index - [self numberOfColumns]);
|
||||
|
||||
[self setSelectionIndexes:[CPIndexSet indexSetWithIndex:index]];
|
||||
[self _scrollToSelection];
|
||||
}
|
||||
|
||||
- (void)deleteBackwards:(id)sender
|
||||
{
|
||||
if ([[self delegate] respondsToSelector:@selector(collectionView:shouldDeleteItemsAtIndexes:)])
|
||||
{
|
||||
[[self delegate] collectionView:self shouldDeleteItemsAtIndexes:[self selectionIndexes]];
|
||||
|
||||
var index = [[self selectionIndexes] firstIndex];
|
||||
if (index > [[self content] count]-1)
|
||||
[self setSelectionIndexes:[CPIndexSet indexSetWithIndex:[[self content] count]-1]];
|
||||
|
||||
[self _scrollToSelection];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)keyDown:(CPEvent)anEvent
|
||||
{
|
||||
[self interpretKeyEvents:[anEvent]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey",
|
||||
CPCollectionViewMaxItemSizeKey = @"CPCollectionViewMaxItemSizeKey",
|
||||
CPCollectionViewVerticalMarginKey = @"CPCollectionViewVerticalMarginKey",
|
||||
|
||||
@@ -735,6 +735,9 @@ var CPColorComponentsKey = @"CPColorComponentsKey",
|
||||
|
||||
var hexCharacters = "0123456789ABCDEF";
|
||||
|
||||
// HACK: prevent these from becoming globals. workaround for obj-j "function foo(){}" behavior
|
||||
var hexToRGB, integerToBytes, rgbToHex, byteToHex;
|
||||
|
||||
/*!
|
||||
Used for the CPColor \c +colorWithHexString: implementation
|
||||
@ignore
|
||||
|
||||
@@ -140,7 +140,7 @@ CPColorPickerViewHeight = 370;
|
||||
Sets the color of the panel, and updates the picker. Also posts a \c CPColorPanelDidChangeNotification.
|
||||
*/
|
||||
- (void)setColor:(CPColor)aColor
|
||||
{
|
||||
{
|
||||
_color = aColor;
|
||||
[_previewView setBackgroundColor: _color];
|
||||
|
||||
@@ -518,9 +518,10 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
|
||||
- (void)mouseUp:(CPEvent)anEvent
|
||||
{
|
||||
var point = [self convertPoint:[anEvent locationInWindow] fromView:nil];
|
||||
var point = [self convertPoint:[anEvent locationInWindow] fromView:nil],
|
||||
bounds = [self bounds];
|
||||
|
||||
if(point.x > [self bounds].size.width - 1 || point.x < 1)
|
||||
if(!CGRectContainsPoint(bounds, point) || point.x > [self bounds].size.width - 1 || point.x < 1)
|
||||
return NO;
|
||||
|
||||
[_colorPanel setColor: [self colorAtIndex:FLOOR(point.x / 13)] updatePicker: YES];
|
||||
@@ -563,7 +564,7 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
- (void)pasteboard:(CPPasteboard)aPasteboard provideDataForType:(CPString)aType
|
||||
{
|
||||
if(aType == CPColorDragType)
|
||||
[aPasteboard setData:_dragColor forType:aType];
|
||||
[aPasteboard setData:[CPKeyedArchiver archivedDataWithRootObject:_dragColor] forType:aType];
|
||||
}
|
||||
|
||||
- (void)performDragOperation:(id <CPDraggingInfo>)aSender
|
||||
@@ -575,7 +576,7 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
if(![pasteboard availableTypeFromArray:[CPColorDragType]] || location.x > [self bounds].size.width - 1 || location.x < 1)
|
||||
return NO;
|
||||
|
||||
[self setColor:[pasteboard dataForType:CPColorDragType] atIndex: FLOOR(location.x / 13)];
|
||||
[self setColor:[CPKeyedUnarchiver unarchiveObjectWithData:[pasteboard dataForType:CPColorDragType]] atIndex: FLOOR(location.x / 13)];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -612,8 +613,8 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
if(![pasteboard availableTypeFromArray:[CPColorDragType]])
|
||||
return NO;
|
||||
|
||||
var color = [pasteboard dataForType:CPColorDragType];
|
||||
[_colorPanel setColor: color updatePicker: YES];
|
||||
var color = [CPKeyedUnarchiver unarchiveObjectWithData:[pasteboard dataForType:CPColorDragType]];
|
||||
[_colorPanel setColor:color updatePicker:YES];
|
||||
}
|
||||
|
||||
- (BOOL)isOpaque
|
||||
@@ -625,7 +626,7 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
{
|
||||
var point = [self convertPoint:[anEvent locationInWindow] fromView:nil];
|
||||
|
||||
[[CPPasteboard pasteboardWithName:CPDragPboard] declareTypes:[CPArray arrayWithObject:CPColorDragType] owner:self];
|
||||
[[CPPasteboard pasteboardWithName:CPDragPboard] declareTypes:[CPColorDragType] owner:self];
|
||||
|
||||
var bounds = CPRectMake(0, 0, 15, 15);
|
||||
|
||||
@@ -650,7 +651,7 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
- (void)pasteboard:(CPPasteboard)aPasteboard provideDataForType:(CPString)aType
|
||||
{
|
||||
if(aType == CPColorDragType)
|
||||
[aPasteboard setData:[self backgroundColor] forType:aType];
|
||||
[aPasteboard setData:[CPKeyedArchiver archivedDataWithRootObject:[self backgroundColor]] forType:aType];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
@import <Foundation/CPObject.j>
|
||||
@import "CPColorPanel.j"
|
||||
|
||||
#include "Platform/Platform.h"
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPColorPicker
|
||||
@@ -239,8 +241,10 @@
|
||||
_blackWheelImage.style.filter = "alpha(opacity=0)"
|
||||
_blackWheelImage.style.position = "absolute";
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement.appendChild(_wheelImage);
|
||||
_DOMElement.appendChild(_blackWheelImage);
|
||||
#endif
|
||||
|
||||
[self setWheelSize:aFrame.size];
|
||||
|
||||
|
||||
@@ -31,6 +31,11 @@ CPKHTMLBrowserEngine = 3;
|
||||
CPOperaBrowserEngine = 4;
|
||||
CPWebKitBrowserEngine = 5;
|
||||
|
||||
// Operating Systems
|
||||
CPMacOperatingSystem = 0;
|
||||
CPWindowsOperatingSystem = 1;
|
||||
CPOtherOperatingSystem = 2;
|
||||
|
||||
// Features
|
||||
CPCSSRGBAFeature = 1 << 5;
|
||||
|
||||
@@ -104,7 +109,10 @@ else if (USER_AGENT.indexOf("AppleWebKit/") != -1)
|
||||
// Features we can only be sure of with WebKit (no known independent tests)
|
||||
PLATFORM_FEATURES |= CPCSSRGBAFeature;
|
||||
PLATFORM_FEATURES |= CPHTMLContentEditableFeature;
|
||||
PLATFORM_FEATURES |= CPHTMLDragAndDropFeature;
|
||||
|
||||
if (USER_AGENT.indexOf("Chrome") === -1)
|
||||
PLATFORM_FEATURES |= CPHTMLDragAndDropFeature;
|
||||
|
||||
PLATFORM_FEATURES |= CPJavascriptClipboardEventsFeature;
|
||||
PLATFORM_FEATURES |= CPJavascriptClipboardAccessFeature;
|
||||
PLATFORM_FEATURES |= CPJavaScriptShadowFeature;
|
||||
@@ -183,25 +191,37 @@ function CPFeatureIsCompatible(aFeature)
|
||||
|
||||
function CPBrowserIsEngine(anEngine)
|
||||
{
|
||||
return PLATFORM_ENGINE == anEngine;
|
||||
return PLATFORM_ENGINE === anEngine;
|
||||
}
|
||||
|
||||
if (USER_AGENT.indexOf("Mac") != -1)
|
||||
function CPBrowserIsOperatingSystem(anOperatingSystem)
|
||||
{
|
||||
return OPERATING_SYSTEM === anOperatingSystem;
|
||||
}
|
||||
|
||||
OPERATING_SYSTEM = CPOtherOperatingSystem;
|
||||
|
||||
if (USER_AGENT.indexOf("Mac") !== -1)
|
||||
{
|
||||
OPERATING_SYSTEM = CPMacOperatingSystem;
|
||||
|
||||
CPPlatformActionKeyMask = CPCommandKeyMask;
|
||||
|
||||
CPUndoKeyEquivalent = @"Z";
|
||||
CPUndoKeyEquivalent = @"z";
|
||||
CPRedoKeyEquivalent = @"Z";
|
||||
|
||||
CPUndoKeyEquivalentModifierMask = CPCommandKeyMask;
|
||||
CPRedoKeyEquivalentModifierMask = CPCommandKeyMask | CPShiftKeyMask;
|
||||
CPRedoKeyEquivalentModifierMask = CPCommandKeyMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (USER_AGENT.indexOf("Windows") !== -1)
|
||||
OPERATING_SYSTEM = CPWindowsOperatingSystem;
|
||||
|
||||
CPPlatformActionKeyMask = CPControlKeyMask;
|
||||
|
||||
CPUndoKeyEquivalent = @"Z";
|
||||
CPRedoKeyEquivalent = @"Y";
|
||||
CPUndoKeyEquivalent = @"z";
|
||||
CPRedoKeyEquivalent = @"y";
|
||||
|
||||
CPUndoKeyEquivalentModifierMask = CPControlKeyMask;
|
||||
CPRedoKeyEquivalentModifierMask = CPControlKeyMask;
|
||||
|
||||
@@ -27,47 +27,42 @@
|
||||
#include "CoreGraphics/CGGeometry.h"
|
||||
#include "Platform/Platform.h"
|
||||
|
||||
/*
|
||||
@global
|
||||
@group CPTextAlignment
|
||||
*/
|
||||
CPLeftTextAlignment = 0;
|
||||
/*
|
||||
@global
|
||||
@group CPTextAlignment
|
||||
*/
|
||||
CPRightTextAlignment = 1;
|
||||
/*
|
||||
@global
|
||||
@group CPTextAlignment
|
||||
*/
|
||||
CPCenterTextAlignment = 2;
|
||||
/*
|
||||
@global
|
||||
@group CPTextAlignment
|
||||
*/
|
||||
CPJustifiedTextAlignment = 3;
|
||||
/*
|
||||
@global
|
||||
@group CPTextAlignment
|
||||
*/
|
||||
CPNaturalTextAlignment = 4;
|
||||
CPLeftTextAlignment = 0;
|
||||
CPRightTextAlignment = 1;
|
||||
CPCenterTextAlignment = 2;
|
||||
CPJustifiedTextAlignment = 3;
|
||||
CPNaturalTextAlignment = 4;
|
||||
|
||||
/*
|
||||
@global
|
||||
@group CPControlSize
|
||||
*/
|
||||
CPRegularControlSize = 0;
|
||||
/*
|
||||
@global
|
||||
@group CPControlSize
|
||||
*/
|
||||
CPSmallControlSize = 1;
|
||||
/*
|
||||
@global
|
||||
@group CPControlSize
|
||||
*/
|
||||
CPMiniControlSize = 2;
|
||||
CPRegularControlSize = 0;
|
||||
CPSmallControlSize = 1;
|
||||
CPMiniControlSize = 2;
|
||||
|
||||
CPLineBreakByWordWrapping = 0;
|
||||
CPLineBreakByCharWrapping = 1;
|
||||
CPLineBreakByClipping = 2;
|
||||
CPLineBreakByTruncatingHead = 3;
|
||||
CPLineBreakByTruncatingTail = 4;
|
||||
CPLineBreakByTruncatingMiddle = 5;
|
||||
|
||||
CPTopVerticalTextAlignment = 1,
|
||||
CPCenterVerticalTextAlignment = 2,
|
||||
CPBottomVerticalTextAlignment = 3;
|
||||
|
||||
CPScaleProportionally = 0;
|
||||
CPScaleToFit = 1;
|
||||
CPScaleNone = 2;
|
||||
|
||||
CPNoImage = 0;
|
||||
CPImageOnly = 1;
|
||||
CPImageLeft = 2;
|
||||
CPImageRight = 3;
|
||||
CPImageBelow = 4;
|
||||
CPImageAbove = 5;
|
||||
CPImageOverlaps = 6;
|
||||
|
||||
CPOnState = 1;
|
||||
CPOffState = 0;
|
||||
CPMixedState = -1;
|
||||
|
||||
CPControlNormalBackgroundColor = "CPControlNormalBackgroundColor";
|
||||
CPControlSelectedBackgroundColor = "CPControlSelectedBackgroundColor";
|
||||
@@ -112,7 +107,7 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
CPLineBreakByClipping,
|
||||
[CPColor blackColor],
|
||||
[CPFont systemFontOfSize:12.0],
|
||||
nil,
|
||||
[CPNull null],
|
||||
_CGSizeMakeZero(),
|
||||
CPImageLeft,
|
||||
CPScaleToFit,
|
||||
@@ -308,6 +303,12 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
[self highlight:YES];
|
||||
[self setState:[self nextState]];
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
|
||||
[CPTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(unhighlightButtonTimerDidFinish:) userInfo:nil repeats:NO];
|
||||
}
|
||||
|
||||
- (void)unhighlightButtonTimerDidFinish:(id)sender
|
||||
{
|
||||
[self highlight:NO];
|
||||
}
|
||||
|
||||
@@ -572,7 +573,9 @@ var CPControlValueKey = "CPControlValueKey",
|
||||
|
||||
CPControlTargetKey = "CPControlTargetKey",
|
||||
CPControlActionKey = "CPControlActionKey",
|
||||
CPControlSendActionOnKey = "CPControlSendActionOnKey";
|
||||
CPControlSendActionOnKey = "CPControlSendActionOnKey",
|
||||
|
||||
CPControlSendsActionOnEndEditingKey = "CPControlSendsActionOnEndEditingKey";
|
||||
|
||||
var __Deprecated__CPImageViewImageKey = @"CPImageViewImageKey";
|
||||
|
||||
@@ -595,6 +598,7 @@ var __Deprecated__CPImageViewImageKey = @"CPImageViewImageKey";
|
||||
[self setAction:[aCoder decodeObjectForKey:CPControlActionKey]];
|
||||
|
||||
[self sendActionOn:[aCoder decodeIntForKey:CPControlSendActionOnKey]];
|
||||
[self setSendsActionOnEndEditing:[aCoder decodeBoolForKey:CPControlSendsActionOnEndEditingKey]];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -608,6 +612,9 @@ var __Deprecated__CPImageViewImageKey = @"CPImageViewImageKey";
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
if (_sendsActionOnEndEditing)
|
||||
[aCoder encodeBool:_sendsActionOnEndEditing forKey:CPControlSendsActionOnEndEditingKey];
|
||||
|
||||
if (_value !== nil)
|
||||
[aCoder encodeObject:_value forKey:CPControlValueKey];
|
||||
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
Testing browsers:
|
||||
WebKit r50235 (Safari 4.0.3+)
|
||||
FireFox 3.5
|
||||
Opera 10.0.0
|
||||
|
||||
Implemented class methods:
|
||||
Webkit : All
|
||||
IE : All
|
||||
FireFox Win : All
|
||||
FireFox Mac : All except closedHandCursor disappearingItemCursor // Firefox mac does not support url cursors
|
||||
Opera : All except resizeLeftRightCursor resizeUpDownCursor operationNotAllowedCursor dragCopyCursor dragLinkCursor contextualMenuCursor openHandCursor closedHandCursor disappearingItemCursor // Opera does not support url cursors so these won't work with images
|
||||
*/
|
||||
|
||||
#include "Platform/Platform.h"
|
||||
|
||||
var currentCursor = nil,
|
||||
cursorStack = [],
|
||||
cursors = {},
|
||||
cursorURLFormat = nil;
|
||||
|
||||
@implementation CPCursor : CPObject
|
||||
{
|
||||
CPString _cssString;
|
||||
BOOL _isSetOnMouseEntered @accessors(readwrite, getter=isSetOnMouseEntered, setter=setOnMouseEntered:);
|
||||
BOOL _isSetOnMouseExited @accessors(readwrite, getter=isSetOnMouseExited, setter=setOnMouseExited:);
|
||||
}
|
||||
|
||||
+ (CPCursor)currentCursor
|
||||
{
|
||||
return currentCursor;
|
||||
}
|
||||
|
||||
- (id)initWithCSSString:(CPString)aString
|
||||
{
|
||||
if (self = [super init])
|
||||
_cssString = aString;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (CPCursor)cursorWithCSSString:(CPString)cssString
|
||||
{
|
||||
var cursor = cursors[cssString];
|
||||
|
||||
if (typeof cursor == 'undefined')
|
||||
{
|
||||
cursor = [[CPCursor alloc] initWithCSSString:cssString];
|
||||
cursors[cssString] = cursor;
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
+ (CPCursor)cursorWithImageNamed:(CPString)imageName
|
||||
{
|
||||
if (!cursorURLFormat)
|
||||
{
|
||||
cursorURLFormat = @"url(" + [[CPBundle bundleForClass:self] resourcePath] + @"/CPCursor/%@.cur)";
|
||||
|
||||
if (CPBrowserIsEngine(CPGeckoBrowserEngine))
|
||||
cursorURLFormat += ", default";
|
||||
}
|
||||
|
||||
var url = [CPString stringWithFormat:cursorURLFormat, imageName];
|
||||
|
||||
return [[CPCursor alloc] initWithCSSString:url];
|
||||
}
|
||||
|
||||
- (CPString)_cssString
|
||||
{
|
||||
return _cssString;
|
||||
}
|
||||
|
||||
+ (CPCursor)arrowCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"default"]; // WebKit | FF | opera | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)crosshairCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"crosshair"]; // WebKit | FF | opera | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)IBeamCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"text"]; // WebKit | FF | opera | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)pointingHandCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"pointer"]; // WebKit | FF | opera | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeDownCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:"s-resize"]; // WebKit | FF | opera
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeUpCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:@"n-resize"]; // WebKit | FF | opera
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeLeftCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:@"w-resize"]; // WebKit | FF | opera
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeRightCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:@"e-resize"]; // WebKit | FF | opera
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeLeftRightCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"col-resize"]; // WebKit | FF | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeUpDownCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"row-resize"]; // WebKit | FF | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)operationNotAllowedCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"not-allowed"]; // WebKit | FF | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)dragCopyCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:@"copy"]; // WebKit | FF
|
||||
}
|
||||
|
||||
+ (CPCursor)dragLinkCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:@"alias"]; // WebKit | FF
|
||||
}
|
||||
|
||||
+ (CPCursor)contextualMenuCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:@"context-menu"]; // WebKit | FF Mac . Not impl FF Win.
|
||||
}
|
||||
|
||||
+ (CPCursor)openHandCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPWebKitBrowserEngine))
|
||||
return [CPCursor cursorWithCSSString:@"-webkit-grab"];
|
||||
else if (CPBrowserIsEngine(CPGeckoBrowserEngine) || CPBrowserIsEngine(CPOperaBrowserEngine))
|
||||
return [CPCursor cursorWithCSSString:@"move"];
|
||||
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)]; // WebKit only. move in FFMac|Opera
|
||||
}
|
||||
|
||||
+ (CPCursor)closedHandCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPWebKitBrowserEngine))
|
||||
return [CPCursor cursorWithCSSString:@"-webkit-grabbing"];
|
||||
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)]; // WebKit only
|
||||
}
|
||||
|
||||
+ (CPCursor)disappearingItemCursor
|
||||
{
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)]; // None
|
||||
}
|
||||
|
||||
+ (void)hide
|
||||
{
|
||||
[self _setCursorCSS:"none"]; // Not supported in IE
|
||||
}
|
||||
|
||||
+ (void)unhide
|
||||
{
|
||||
[self _setCursorCSS:[currentCursor _cssString]]
|
||||
}
|
||||
|
||||
+ (void)setHiddenUntilMouseMoves:(BOOL)flag
|
||||
{
|
||||
if (flag)
|
||||
[CPCursor hide];
|
||||
else
|
||||
[CPCursor unhide];
|
||||
}
|
||||
|
||||
- (id)initWithImage:(CPImage)image hotSpot:(CPPoint)hotSpot
|
||||
{
|
||||
return [self initWithCSSString:"url(" + [image filename] + ")"];
|
||||
}
|
||||
|
||||
- (void)mouseEntered:(CPEvent)event
|
||||
{
|
||||
}
|
||||
|
||||
- (void)mouseExited:(CPEvent)event
|
||||
{
|
||||
}
|
||||
|
||||
- (void)set
|
||||
{
|
||||
currentCursor = self;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
[[self class] _setCursorCSS:_cssString];
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
+ (void)_setCursorCSS:(CPString)aString
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var platformWindows = [[CPPlatformWindow visiblePlatformWindows] allObjects];
|
||||
for (var i = 0, count = [platformWindows count]; i < count; i++)
|
||||
platformWindows[i]._DOMBodyElement.style.cursor = aString;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)push
|
||||
{
|
||||
currentCursor = cursorStack.push(self);
|
||||
}
|
||||
|
||||
- (void)pop
|
||||
{
|
||||
[CPCursor pop];
|
||||
}
|
||||
|
||||
+ (void)pop
|
||||
{
|
||||
if (cursorStack.length > 1)
|
||||
{
|
||||
cursorStack.pop();
|
||||
currentCursor = cursorStack[cursorStack.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)coder
|
||||
{
|
||||
if (self = [super init])
|
||||
_cssString = [coder decodeObjectForKey:@"CPCursorNameKey"];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)coder
|
||||
{
|
||||
[coder encodeObject:_cssString forKey:@"CPCursorNameKey"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -280,7 +280,11 @@ var CPDocumentUntitledCount = 0;
|
||||
else if (viewController)
|
||||
{
|
||||
var view = [viewController view],
|
||||
theWindow = [[CPWindow alloc] initWithContentRect:[view frame] styleMask:CPTitledWindowMask | CPClosableWindowMask | CPMiniaturizableWindowMask | CPResizableWindowMask];
|
||||
viewFrame = [view frame];
|
||||
|
||||
viewFrame.origin = CGPointMake(50, 50);
|
||||
|
||||
var theWindow = [[CPWindow alloc] initWithContentRect:viewFrame styleMask:CPTitledWindowMask | CPClosableWindowMask | CPMiniaturizableWindowMask | CPResizableWindowMask];
|
||||
|
||||
windowController = [[CPWindowController alloc] initWithWindow:theWindow];
|
||||
}
|
||||
@@ -480,7 +484,7 @@ var CPDocumentUntitledCount = 0;
|
||||
else
|
||||
[_writeRequest setHTTPMethod:@"PUT"];
|
||||
|
||||
[_writeRequest setHTTPBody:[data string]];
|
||||
[_writeRequest setHTTPBody:[data rawString]];
|
||||
|
||||
[_writeRequest setValue:@"close" forHTTPHeaderField:@"Connection"];
|
||||
|
||||
@@ -563,7 +567,7 @@ var CPDocumentUntitledCount = 0;
|
||||
// READ
|
||||
if (aConnection == _readConnection)
|
||||
{
|
||||
[self readFromData:[CPData dataWithString:aData] ofType:session.fileType error:nil];
|
||||
[self readFromData:[CPData dataWithRawString:aData] ofType:session.fileType error:nil];
|
||||
|
||||
objj_msgSend(session.delegate, session.didReadSelector, self, YES, session.contextInfo);
|
||||
}
|
||||
@@ -884,8 +888,7 @@ var CPDocumentUntitledCount = 0;
|
||||
[_canCloseAlert setDelegate:self];
|
||||
[_canCloseAlert setAlertStyle:CPWarningAlertStyle];
|
||||
[_canCloseAlert setTitle:@"Unsaved Document"];
|
||||
[_canCloseAlert setMessageText:sprintf(@"Do you want to save the changes you've made to the document \"%@\"?",
|
||||
[self displayName] || [self fileName])];
|
||||
[_canCloseAlert setMessageText:@"Do you want to save the changes you've made to the document \"" + ([self displayName] || [self fileName]) + "\"?"];
|
||||
|
||||
[_canCloseAlert addButtonWithTitle:@"Save"];
|
||||
[_canCloseAlert addButtonWithTitle:@"Cancel"];
|
||||
|
||||
@@ -150,6 +150,10 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
||||
|
||||
CGPoint _draggingLocation;
|
||||
id _draggingDestination;
|
||||
|
||||
CGPoint _startDragLocation;
|
||||
BOOL _shouldSlideBack;
|
||||
unsigned _dragOperation;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -189,6 +193,11 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)draggingDestination
|
||||
{
|
||||
return _draggingDestination;
|
||||
}
|
||||
|
||||
- (CGPoint)draggingLocation
|
||||
{
|
||||
return _draggingLocation
|
||||
@@ -260,7 +269,6 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
||||
|
||||
if (_implementedDraggingSourceMethods & CPDraggingSource_draggedImage_endAt_operation_)
|
||||
[_draggingSource draggedImage:[_draggedView image] endedAt:aLocation operation:anOperation];
|
||||
|
||||
else if (_implementedDraggingSourceMethods & CPDraggingSource_draggedView_endedAt_operation_)
|
||||
[_draggingSource draggedView:_draggedView endedAt:aLocation operation:anOperation];
|
||||
|
||||
@@ -296,6 +304,7 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
||||
_draggingPasteboard = aPasteboard || [CPPasteboard pasteboardWithName:CPDragPboard];
|
||||
_draggingSource = aSourceObject;
|
||||
_draggingDestination = nil;
|
||||
_shouldSlideBack = slideBack;
|
||||
|
||||
// The offset is based on the distance from where we want the view to be initially from where the mouse is initially
|
||||
// Hence the use of mouseDownEvent's location and view's location in global coordinates.
|
||||
@@ -310,7 +319,7 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
||||
_draggingOffset = _CGSizeMake(mouseDownEventLocation.x - viewLocation.x, mouseDownEventLocation.y - viewLocation.y);
|
||||
}
|
||||
else
|
||||
_draggingOffset = _CGSizeMakerZero();
|
||||
_draggingOffset = _CGSizeMakeZero();
|
||||
|
||||
if ([CPPlatform isBrowser])
|
||||
[_draggedWindow setPlatformWindow:[aWindow platformWindow]];
|
||||
@@ -320,7 +329,8 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
||||
var mouseLocation = [CPEvent mouseLocation];
|
||||
|
||||
// Place it where the mouse pointer is.
|
||||
[_draggedWindow setFrameOrigin:_CGPointMake(mouseLocation.x - _draggingOffset.width, mouseLocation.y - _draggingOffset.height)];
|
||||
_startDragLocation = _CGPointMake(mouseLocation.x - _draggingOffset.width, mouseLocation.y - _draggingOffset.height);
|
||||
[_draggedWindow setFrameOrigin:_startDragLocation];
|
||||
[_draggedWindow setFrameSize:[aView frame].size];
|
||||
|
||||
[[_draggedWindow contentView] addSubview:aView];
|
||||
@@ -385,15 +395,18 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
|
||||
|
||||
if (type === CPLeftMouseUp)
|
||||
{
|
||||
[self performDragOperationInPlatformWindow:platformWindow];
|
||||
[self draggingEndedInPlatformWindow:platformWindow globalLocation:platformWindowLocation operation:CPDragOperationNone];
|
||||
// Make sure we do not finalize (cancel) the drag if the last drag update was disallowed
|
||||
if (_dragOperation !== CPDragOperationNone)
|
||||
[self performDragOperationInPlatformWindow:platformWindow];
|
||||
|
||||
[self draggingEndedInPlatformWindow:platformWindow globalLocation:platformWindowLocation operation:_dragOperation];
|
||||
|
||||
// Stop tracking events.
|
||||
return;
|
||||
}
|
||||
|
||||
[self draggingSourceUpdatedWithGlobalLocation:platformWindowLocation];
|
||||
[self draggingUpdatedInPlatformWindow:platformWindow location:platformWindowLocation];
|
||||
_dragOperation = [self draggingUpdatedInPlatformWindow:platformWindow location:platformWindowLocation];
|
||||
|
||||
// If we're not a mouse up, then we're going to want to grab the next event.
|
||||
[CPApp setTarget:self selector:@selector(trackDragging:)
|
||||
|
||||
@@ -285,6 +285,17 @@ var _CPEventPeriodicEventPeriod = 0,
|
||||
return _CGPointMakeCopy(_location);
|
||||
}
|
||||
|
||||
- (CGPoint)globalLocation
|
||||
{
|
||||
var theWindow = [self window],
|
||||
location = [self locationInWindow];
|
||||
|
||||
if (theWindow)
|
||||
return [theWindow convertBaseToGlobal:location];
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns event information as a bit mask
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
*/
|
||||
@implementation CPFlashMovie : CPObject
|
||||
{
|
||||
CPString _fileName;
|
||||
CPString _filename;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -38,9 +38,9 @@
|
||||
@param aFilename the swf to load
|
||||
@return the initialized CPFlashMovie
|
||||
*/
|
||||
+ (id)flashMovieWithFile:(CPString)aFileName
|
||||
+ (id)flashMovieWithFile:(CPString)aFilename
|
||||
{
|
||||
return [[self alloc] initWithFile:aFileName];
|
||||
return [[self alloc] initWithFile:aFilename];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -48,14 +48,37 @@
|
||||
@param aFilename the swf to load
|
||||
@return the initialized CPFlashMovie
|
||||
*/
|
||||
- (id)initWithFile:(CPString)aFileName
|
||||
- (id)initWithFile:(CPString)aFilename
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
_fileName = aFileName;
|
||||
_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
|
||||
@@ -23,6 +23,9 @@
|
||||
@import "CPFlashMovie.j"
|
||||
@import "CPView.j"
|
||||
|
||||
#include "Platform/Platform.h"
|
||||
|
||||
var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@@ -31,9 +34,13 @@
|
||||
{
|
||||
CPFlashMovie _flashMovie;
|
||||
|
||||
DOMElement _DOMEmbedElement;
|
||||
DOMElement _DOMMParamElement;
|
||||
CPDictionary _params;
|
||||
CPDictionary _paramElements;
|
||||
#if PLATFORM(DOM)
|
||||
DOMElement _DOMParamElement;
|
||||
DOMElement _DOMObjectElement;
|
||||
DOMElement _DOMInnerObjectElement;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
@@ -42,35 +49,32 @@
|
||||
|
||||
if (self)
|
||||
{
|
||||
_DOMObjectElement = document.createElement("object");
|
||||
_DOMObjectElement.width = "100%";
|
||||
_DOMObjectElement.height = "100%";
|
||||
_DOMObjectElement.style.top = "0px";
|
||||
_DOMObjectElement.style.left = "0px";
|
||||
|
||||
_DOMParamElement = document.createElement("param");
|
||||
_DOMParamElement.name = "movie";
|
||||
|
||||
_DOMObjectElement.appendChild(_DOMParamElement);
|
||||
|
||||
var param = document.createElement("param");
|
||||
|
||||
param.name = "wmode";
|
||||
param.value = "transparent";
|
||||
|
||||
_DOMObjectElement.appendChild(param);
|
||||
|
||||
_DOMEmbedElement = document.createElement("embed");
|
||||
|
||||
_DOMEmbedElement.type = "application/x-shockwave-flash";
|
||||
_DOMEmbedElement.setAttribute("wmode", "transparent");
|
||||
_DOMEmbedElement.width = "100%";
|
||||
_DOMEmbedElement.height = "100%";
|
||||
|
||||
// IE requires this thing to be in the _DOMElement and not the _DOMObjectElement.
|
||||
_DOMElement.appendChild(_DOMEmbedElement);
|
||||
|
||||
_DOMElement.appendChild(_DOMObjectElement);
|
||||
#if PLATFORM(DOM)
|
||||
if (!CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
{
|
||||
_DOMObjectElement = document.createElement(@"object");
|
||||
_DOMObjectElement.width = @"100%";
|
||||
_DOMObjectElement.height = @"100%";
|
||||
_DOMObjectElement.style.top = @"0px";
|
||||
_DOMObjectElement.style.left = @"0px";
|
||||
_DOMObjectElement.type = @"application/x-shockwave-flash";
|
||||
_DOMObjectElement.setAttribute(@"classid", IEFlashCLSID);
|
||||
|
||||
_DOMParamElement = document.createElement(@"param");
|
||||
_DOMParamElement.name = @"movie";
|
||||
|
||||
_DOMInnerObjectElement = document.createElement(@"object");
|
||||
_DOMInnerObjectElement.width = @"100%";
|
||||
_DOMInnerObjectElement.height = @"100%";
|
||||
|
||||
_DOMObjectElement.appendChild(_DOMParamElement);
|
||||
_DOMObjectElement.appendChild(_DOMInnerObjectElement);
|
||||
|
||||
_DOMElement.appendChild(_DOMObjectElement);
|
||||
}
|
||||
else
|
||||
[self _rebuildIEObjects];
|
||||
#endif
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -82,11 +86,15 @@
|
||||
return;
|
||||
|
||||
_flashMovie = aFlashMovie;
|
||||
|
||||
_DOMParamElement.value = aFlashMovie._fileName;
|
||||
|
||||
if (_DOMEmbedElement)
|
||||
_DOMEmbedElement.src = aFlashMovie._fileName;
|
||||
#if PLATFORM(DOM)
|
||||
if (!CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
{
|
||||
_DOMParamElement.value = [aFlashMovie filename];
|
||||
_DOMInnerObjectElement.data = [aFlashMovie filename];
|
||||
}
|
||||
else
|
||||
[self _rebuildIEObjects];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (CPFlashMovie)flashMovie
|
||||
@@ -94,6 +102,90 @@
|
||||
return _flashMovie;
|
||||
}
|
||||
|
||||
- (void)setFlashVars:(CPDictionary)aDictionary
|
||||
{
|
||||
var varString = @"",
|
||||
enumerator = [aDictionary keyEnumerator];
|
||||
|
||||
var key;
|
||||
while (key = [enumerator nextObject])
|
||||
varString = [varString stringByAppendingFormat:@"&%@=%@", key, [aDictionary objectForKey:key]];
|
||||
|
||||
if (!_params)
|
||||
_params = [CPDictionary dictionary];
|
||||
|
||||
[_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
|
||||
_params = aDictionary;
|
||||
#if PLATFORM(DOM)
|
||||
if (!CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
{
|
||||
_paramElements = [CPDictionary dictionary];
|
||||
|
||||
var enumerator = [_params keyEnumerator],
|
||||
key;
|
||||
|
||||
while (key = [enumerator nextObject] && _DOMObjectElement)
|
||||
{
|
||||
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])
|
||||
paramString = [paramString stringByAppendingFormat:@"<param name='%@' value='%@' />", key, [_params objectForKey:key]];
|
||||
|
||||
_DOMObjectElement = document.createElement(@"object");
|
||||
_DOMElement.appendChild(_DOMObjectElement);
|
||||
|
||||
_DOMObjectElement.outerHTML = [CPString stringWithFormat:@"<object classid=%@ width=%@ height=%@>%@</object>", IEFlashCLSID, CGRectGetWidth([self bounds]), CGRectGetHeight([self bounds]), paramString];
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)mouseDragged:(CPEvent)anEvent
|
||||
{
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
|
||||
@@ -20,10 +20,13 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
var _CPFonts = {};
|
||||
_CPFontSystemFontFace = @"Arial";
|
||||
var _CPFonts = {},
|
||||
_CPFontSystemFontFace = @"Arial, sans-serif",
|
||||
_CPWrapRegExp = new RegExp("\\s*,\\s*", "g");
|
||||
|
||||
#define _CPCachedFont(aName, aSize, isBold) _CPFonts[(isBold ? @"bold " : @"") + ROUND(aSize) + @"px '" + aName + @"'"]
|
||||
|
||||
#define _CPCreateCSSString(aName, aSize, isBold) (isBold ? @"bold " : @"") + ROUND(aSize) + @"px " + ((aName === _CPFontSystemFontFace) ? aName : (@"\"" + aName.replace(_CPWrapRegExp, '", "') + @"\", " + _CPFontSystemFontFace))
|
||||
#define _CPCachedFont(aName, aSize, isBold) _CPFonts[_CPCreateCSSString(aName, aSize, isBold)]
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@@ -95,7 +98,7 @@ var _CPFonts = {};
|
||||
_size = aSize;
|
||||
_isBold = isBold;
|
||||
|
||||
_cssString = (_isBold ? @"bold " : @"") + ROUND(aSize) + @"px '" + aName + @"'";
|
||||
_cssString = _CPCreateCSSString(_name, _size, _isBold);
|
||||
|
||||
_CPFonts[_cssString] = self;
|
||||
}
|
||||
@@ -127,6 +130,16 @@ var _CPFonts = {};
|
||||
return _name;
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)anObject
|
||||
{
|
||||
return [anObject isKindOfClass:[CPFont class]] && [anObject cssString] === [self cssString];
|
||||
}
|
||||
|
||||
- (CPString)description
|
||||
{
|
||||
return [CPString stringWithFormat:@"%@ %@ %f pt.", [super description], [self familyName], [self size]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPFontNameKey = @"CPFontNameKey",
|
||||
|
||||
@@ -234,9 +234,9 @@ function CPRectContainsPoint(aRect, aPoint)
|
||||
@param possibleInner the CGRect to test if it fits inside \c possibleOuter.
|
||||
@return BOOL \c YES if \c possibleInner fits inside \c possibleOuter.
|
||||
*/
|
||||
function CPRectContainsRect(lhsRect, rhsRect)
|
||||
function CPRectContainsRect(possibleOuter, possibleInner)
|
||||
{
|
||||
return CPRectEqualToRect(CPUnionRect(lhsRect, rhsRect), rhsRect);
|
||||
return CGRectContainsRect(possibleOuter, possibleInner);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* 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/CPBundle.j>
|
||||
@import <Foundation/CPNotificationCenter.j>
|
||||
@import <Foundation/CPObject.j>
|
||||
@@ -28,6 +28,9 @@
|
||||
|
||||
@import "CPGeometry.j"
|
||||
|
||||
#include "Platform/Platform.h"
|
||||
|
||||
|
||||
CPImageLoadStatusInitialized = 0;
|
||||
CPImageLoadStatusLoading = 1;
|
||||
CPImageLoadStatusCompleted = 2;
|
||||
@@ -38,17 +41,32 @@ CPImageLoadStatusReadError = 6;
|
||||
|
||||
CPImageDidLoadNotification = @"CPImageDidLoadNotification";
|
||||
|
||||
// Image Names
|
||||
CPImageNameColorPanel = @"CPImageNameColorPanel";
|
||||
CPImageNameColorPanelHighlighted = @"CPImageNameColorPanelHighlighted";
|
||||
|
||||
var imagesForNames = { },
|
||||
AppKitImageForNames = { };
|
||||
|
||||
AppKitImageForNames[CPImageNameColorPanel] = CGSizeMake(26.0, 29.0);
|
||||
AppKitImageForNames[CPImageNameColorPanelHighlighted] = CGSizeMake(26.0, 29.0);
|
||||
|
||||
function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
{
|
||||
if (!aBundle)
|
||||
aBundle = [CPBundle mainBundle];
|
||||
|
||||
|
||||
if (aSize)
|
||||
return [[CPImage alloc] initWithContentsOfFile:[aBundle pathForResource:aFilename] size:aSize];
|
||||
|
||||
|
||||
return [[CPImage alloc] initWithContentsOfFile:[aBundle pathForResource:aFilename]];
|
||||
}
|
||||
|
||||
function CPAppKitImage(aFilename, aSize)
|
||||
{
|
||||
return CPImageInBundle(aFilename, aSize, [CPBundle bundleForClass:[CPView class]]);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPImage
|
||||
@@ -74,10 +92,11 @@ function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
{
|
||||
CGSize _size;
|
||||
CPString _filename;
|
||||
|
||||
CPString _name;
|
||||
|
||||
id _delegate;
|
||||
unsigned _loadStatus;
|
||||
|
||||
|
||||
Image _image;
|
||||
}
|
||||
|
||||
@@ -97,14 +116,14 @@ function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
- (id)initByReferencingFile:(CPString)aFilename size:(CGSize)aSize
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
||||
if (self)
|
||||
{
|
||||
_size = CPSizeCreateCopy(aSize);
|
||||
_filename = aFilename;
|
||||
_loadStatus = CPImageLoadStatusInitialized;
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -117,10 +136,10 @@ function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
- (id)initWithContentsOfFile:(CPString)aFilename size:(CGSize)aSize
|
||||
{
|
||||
self = [self initByReferencingFile:aFilename size:aSize];
|
||||
|
||||
|
||||
if (self)
|
||||
[self load];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -133,10 +152,10 @@ function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
- (id)initWithContentsOfFile:(CPString)aFilename
|
||||
{
|
||||
self = [self initByReferencingFile:aFilename size:CGSizeMake(-1, -1)];
|
||||
|
||||
|
||||
if (self)
|
||||
[self load];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -165,6 +184,45 @@ function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
return _size;
|
||||
}
|
||||
|
||||
+ (id)imageNamed:(CPString)aName
|
||||
{
|
||||
var image = imagesForNames[aName];
|
||||
|
||||
if (image)
|
||||
return image;
|
||||
|
||||
var imageOrSize = AppKitImageForNames[aName];
|
||||
|
||||
if (!imageOrSize.isa)
|
||||
{
|
||||
imageOrSize = CPAppKitImage("CPImage/" + aName + ".png", imageOrSize);
|
||||
|
||||
[imageOrSize setName:aName];
|
||||
|
||||
AppKitImageForNames[aName] = imageOrSize;
|
||||
}
|
||||
|
||||
return imageOrSize;
|
||||
}
|
||||
|
||||
- (void)setName:(CPString)aName
|
||||
{
|
||||
if (_name === aName)
|
||||
return;
|
||||
|
||||
if (imagesForNames[aName] === self)
|
||||
imagesForNames[aName] = nil;
|
||||
|
||||
_name = aName;
|
||||
|
||||
imagesForNames[aName] = self;
|
||||
}
|
||||
|
||||
- (CPString)name
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the receiver's delegate.
|
||||
@param the delegate
|
||||
@@ -200,9 +258,10 @@ function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
{
|
||||
if (_loadStatus == CPImageLoadStatusLoading || _loadStatus == CPImageLoadStatusCompleted)
|
||||
return;
|
||||
|
||||
|
||||
_loadStatus = CPImageLoadStatusLoading;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_image = new Image();
|
||||
|
||||
var isSynchronous = YES;
|
||||
@@ -219,7 +278,7 @@ function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
}
|
||||
[self _derefFromImage];
|
||||
}
|
||||
|
||||
|
||||
_image.onerror = function ()
|
||||
{
|
||||
if (isSynchronous)
|
||||
@@ -231,7 +290,7 @@ function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
}
|
||||
[self _derefFromImage];
|
||||
}
|
||||
|
||||
|
||||
_image.onabort = function ()
|
||||
{
|
||||
if (isSynchronous)
|
||||
@@ -243,10 +302,13 @@ function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
}
|
||||
[self _derefFromImage];
|
||||
}
|
||||
|
||||
|
||||
_image.src = _filename;
|
||||
|
||||
isSynchronous = NO;
|
||||
|
||||
// onload and friends may fire after this point but BEFORE the end of the run loop,
|
||||
// crazy, I know. So don't set isSynchronous here, rather wait a bit longer.
|
||||
window.setTimeout(function() { isSynchronous = NO; }, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
- (BOOL)isThreePartImage
|
||||
@@ -279,7 +341,7 @@ function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPImageDidLoadNotification
|
||||
object:self];
|
||||
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(imageDidLoad:)])
|
||||
[_delegate imageDidLoad:self];
|
||||
}
|
||||
@@ -288,7 +350,7 @@ function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
- (void)_imageDidError
|
||||
{
|
||||
_loadStatus = CPImageLoadStatusReadError;
|
||||
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(imageDidError:)])
|
||||
[_delegate imageDidError:self];
|
||||
}
|
||||
@@ -297,7 +359,7 @@ function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
- (void)_imageDidAbort
|
||||
{
|
||||
_loadStatus = CPImageLoadStatusCancelled;
|
||||
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(imageDidAbort:)])
|
||||
[_delegate imageDidAbort:self];
|
||||
}
|
||||
@@ -337,7 +399,7 @@ function CPImageInBundle(aFilename, aSize, aBundle)
|
||||
- (id)initWithImageSlices:(CPArray)imageSlices isVertical:(BOOL)isVertical
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
||||
if (self)
|
||||
{
|
||||
_imageSlices = imageSlices;
|
||||
@@ -382,13 +444,13 @@ var CPThreePartImageImageSlicesKey = @"CPThreePartImageImageSlicesKey",
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
||||
if (self)
|
||||
{
|
||||
_imageSlices = [aCoder decodeObjectForKey:CPThreePartImageImageSlicesKey];
|
||||
_isVertical = [aCoder decodeBoolForKey:CPThreePartImageIsVerticalKey];
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -409,10 +471,10 @@ var CPThreePartImageImageSlicesKey = @"CPThreePartImageImageSlicesKey",
|
||||
- (id)initWithImageSlices:(CPArray)imageSlices
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
||||
if (self)
|
||||
_imageSlices = imageSlices;
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -445,10 +507,10 @@ var CPNinePartImageImageSlicesKey = @"CPNinePartImageImageSlicesKey";
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
||||
if (self)
|
||||
_imageSlices = [aCoder decodeObjectForKey:CPNinePartImageImageSlicesKey];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,24 +31,10 @@
|
||||
|
||||
#include "CoreGraphics/CGGeometry.h"
|
||||
|
||||
|
||||
/*
|
||||
@global
|
||||
@group CPImageScaling
|
||||
*/
|
||||
CPScaleProportionally = 0;
|
||||
/*
|
||||
@global
|
||||
@group CPImageScaling
|
||||
*/
|
||||
CPScaleToFit = 1;
|
||||
/*
|
||||
@global
|
||||
@group CPImageScaling
|
||||
*/
|
||||
CPScaleNone = 2;
|
||||
|
||||
|
||||
var CPImageViewShadowBackgroundColor = nil;
|
||||
|
||||
var LEFT_SHADOW_INSET = 3.0,
|
||||
@@ -225,6 +211,11 @@ var LEFT_SHADOW_INSET = 3.0,
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (unsigned)imageScaling
|
||||
{
|
||||
return [self currentValueForThemeAttribute:@"image-scaling"];
|
||||
}
|
||||
|
||||
/*!
|
||||
Toggles the display of the image view.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,556 @@
|
||||
|
||||
#include "../CoreGraphics/CGGeometry.h"
|
||||
#include "../Platform/Platform.h"
|
||||
|
||||
@import "_CPMenuWindow.j"
|
||||
|
||||
|
||||
var MENUBAR_HEIGHT = 28.0,
|
||||
MENUBAR_MARGIN = 10.0,
|
||||
MENUBAR_LEFT_MARGIN = 10.0,
|
||||
MENUBAR_RIGHT_MARGIN = 10.0;
|
||||
|
||||
var _CPMenuBarWindowBackgroundColor = nil,
|
||||
_CPMenuBarWindowFont = nil;
|
||||
|
||||
@implementation _CPMenuBarWindow : CPPanel
|
||||
{
|
||||
CPMenu _menu;
|
||||
CPView _highlightView;
|
||||
CPArray _menuItemViews;
|
||||
|
||||
CPMenuItem _trackingMenuItem;
|
||||
|
||||
CPImageView _iconImageView;
|
||||
CPTextField _titleField;
|
||||
|
||||
CPColor _textColor;
|
||||
CPColor _titleColor;
|
||||
|
||||
CPColor _textShadowColor;
|
||||
CPColor _titleShadowColor;
|
||||
|
||||
CPColor _highlightColor;
|
||||
CPColor _highlightTextColor;
|
||||
CPColor _highlightTextShadowColor;
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self != [_CPMenuBarWindow class])
|
||||
return;
|
||||
|
||||
var bundle = [CPBundle bundleForClass:self];
|
||||
|
||||
_CPMenuBarWindowFont = [CPFont boldSystemFontOfSize:12.0];
|
||||
}
|
||||
|
||||
+ (CPFont)font
|
||||
{
|
||||
return _CPMenuBarWindowFont;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
// This only shows up in browser land, so don't bother calculating metrics in desktop.
|
||||
var contentRect = [[CPPlatformWindow primaryPlatformWindow] contentBounds];
|
||||
|
||||
contentRect.size.height = MENUBAR_HEIGHT;
|
||||
|
||||
self = [super initWithContentRect:contentRect styleMask:CPBorderlessWindowMask];
|
||||
|
||||
if (self)
|
||||
{
|
||||
[self setLevel:CPMainMenuWindowLevel];
|
||||
[self setAutoresizingMask:CPWindowWidthSizable];
|
||||
|
||||
var contentView = [self contentView];
|
||||
|
||||
[contentView setAutoresizesSubviews:NO];
|
||||
|
||||
[self setBecomesKeyOnlyIfNeeded:YES];
|
||||
|
||||
//
|
||||
_iconImageView = [[CPImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 16.0, 16.0)];
|
||||
|
||||
[contentView addSubview:_iconImageView];
|
||||
|
||||
_titleField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
[_titleField setFont:[CPFont boldSystemFontOfSize:13.0]];
|
||||
[_titleField setAlignment:CPCenterTextAlignment];
|
||||
[_titleField setTextShadowOffset:CGSizeMake(0, 1)];
|
||||
|
||||
[contentView addSubview:_titleField];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setTitle:(CPString)aTitle
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var bundleName = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPBundleName"];
|
||||
|
||||
if (![bundleName length])
|
||||
document.title = aTitle;
|
||||
else if ([aTitle length])
|
||||
document.title = aTitle + @" - " + bundleName;
|
||||
else
|
||||
document.title = bundleName;
|
||||
#endif
|
||||
|
||||
[_titleField setStringValue:aTitle];
|
||||
[_titleField sizeToFit];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)setIconImage:(CPImage)anImage
|
||||
{
|
||||
[_iconImageView setImage:anImage];
|
||||
[_iconImageView setHidden:anImage == nil];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)setIconImageAlphaValue:(float)anAlphaValue
|
||||
{
|
||||
[_iconImageView setAlphaValue:anAlphaValue];
|
||||
}
|
||||
|
||||
- (void)setColor:(CPColor)aColor
|
||||
{
|
||||
if (!aColor)
|
||||
{
|
||||
if (!_CPMenuBarWindowBackgroundColor)
|
||||
_CPMenuBarWindowBackgroundColor = [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[_CPMenuBarWindow class]] pathForResource:@"_CPMenuBarWindow/_CPMenuBarWindowBackground.png"] size:CGSizeMake(1.0, 28.0)]];
|
||||
|
||||
[[self contentView] setBackgroundColor:_CPMenuBarWindowBackgroundColor];
|
||||
}
|
||||
else
|
||||
[[self contentView] setBackgroundColor:aColor];
|
||||
}
|
||||
|
||||
- (void)setTextColor:(CPColor)aColor
|
||||
{
|
||||
if (_textColor == aColor)
|
||||
return;
|
||||
|
||||
_textColor = aColor;
|
||||
|
||||
[_menuItemViews makeObjectsPerformSelector:@selector(setTextColor:) withObject:_textColor];
|
||||
}
|
||||
|
||||
- (void)setTitleColor:(CPColor)aColor
|
||||
{
|
||||
if (_titleColor == aColor)
|
||||
return;
|
||||
|
||||
_titleColor = aColor;
|
||||
|
||||
[_titleField setTextColor:aColor ? aColor : [CPColor blackColor]];
|
||||
}
|
||||
|
||||
- (void)setTextShadowColor:(CPColor)aColor
|
||||
{
|
||||
if (_textShadowColor == aColor)
|
||||
return;
|
||||
|
||||
_textShadowColor = aColor;
|
||||
|
||||
[_menuItemViews makeObjectsPerformSelector:@selector(setTextShadowColor:) withObject:_textShadowColor];
|
||||
}
|
||||
|
||||
- (void)setTitleShadowColor:(CPColor)aColor
|
||||
{
|
||||
if (_titleShadowColor == aColor)
|
||||
return;
|
||||
|
||||
_titleShadowColor = aColor;
|
||||
|
||||
[_titleField setTextShadowColor:aColor ? aColor : [CPColor whiteColor]];
|
||||
}
|
||||
|
||||
- (void)setHighlightColor:(CPColor)aColor
|
||||
{
|
||||
if (_highlightColor == aColor)
|
||||
return;
|
||||
|
||||
_highlightColor = aColor;
|
||||
}
|
||||
|
||||
- (void)setHighlightTextColor:(CPColor)aColor
|
||||
{
|
||||
if (_highlightTextColor == aColor)
|
||||
return;
|
||||
|
||||
_highlightTextColor = aColor;
|
||||
|
||||
// [_menuItemViews makeObjectsPerformSelector:@selector(setActivateColor:) withObject:_highlightTextColor];
|
||||
}
|
||||
|
||||
- (void)setHighlightTextShadowColor:(CPColor)aColor
|
||||
{
|
||||
if (_highlightTextShadowColor == aColor)
|
||||
return;
|
||||
|
||||
_highlightTextShadowColor = aColor;
|
||||
|
||||
// [_menuItemViews makeObjectsPerformSelector:@selector(setActivateShadowColor:) withObject:_highlightTextShadowColor];
|
||||
}
|
||||
|
||||
- (void)setMenu:(CPMenu)aMenu
|
||||
{
|
||||
if (_menu == aMenu)
|
||||
return;
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
if (_menu)
|
||||
{
|
||||
[defaultCenter
|
||||
removeObserver:self
|
||||
name:CPMenuDidAddItemNotification
|
||||
object:_menu];
|
||||
|
||||
[defaultCenter
|
||||
removeObserver:self
|
||||
name:CPMenuDidChangeItemNotification
|
||||
object:_menu];
|
||||
|
||||
[defaultCenter
|
||||
removeObserver:self
|
||||
name:CPMenuDidRemoveItemNotification
|
||||
object:_menu];
|
||||
|
||||
var items = [_menu itemArray],
|
||||
count = items.length;
|
||||
|
||||
while (count--)
|
||||
[[items[count] _menuItemView] removeFromSuperview];
|
||||
}
|
||||
|
||||
_menu = aMenu;
|
||||
|
||||
if (_menu)
|
||||
{
|
||||
[defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(menuDidAddItem:)
|
||||
name:CPMenuDidAddItemNotification
|
||||
object:_menu];
|
||||
|
||||
[defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(menuDidChangeItem:)
|
||||
name:CPMenuDidChangeItemNotification
|
||||
object:_menu];
|
||||
|
||||
[defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(menuDidRemoveItem:)
|
||||
name:CPMenuDidRemoveItemNotification
|
||||
object:_menu];
|
||||
}
|
||||
|
||||
_menuItemViews = [];
|
||||
|
||||
var contentView = [self contentView],
|
||||
items = [_menu itemArray],
|
||||
count = items.length;
|
||||
|
||||
for (index = 0; index < count; ++index)
|
||||
{
|
||||
var item = items[index],
|
||||
menuItemView = [item _menuItemView];
|
||||
|
||||
_menuItemViews.push(menuItemView);
|
||||
|
||||
[menuItemView setTextColor:_textColor];
|
||||
[menuItemView setHidden:[item isHidden]];
|
||||
|
||||
[menuItemView synchronizeWithMenuItem];
|
||||
|
||||
[contentView addSubview:menuItemView];
|
||||
}
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)menuDidChangeItem:(CPNotification)aNotification
|
||||
{
|
||||
var menuItem = [_menu itemAtIndex:[[aNotification userInfo] objectForKey:@"CPMenuItemIndex"]],
|
||||
menuItemView = [menuItem _menuItemView];
|
||||
|
||||
[menuItemView setHidden:[menuItem isHidden]];
|
||||
[menuItemView synchronizeWithMenuItem];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)menuDidAddItem:(CPNotification)aNotification
|
||||
{
|
||||
var index = [[aNotification userInfo] objectForKey:@"CPMenuItemIndex"],
|
||||
menuItem = [_menu itemAtIndex:index],
|
||||
menuItemView = [menuItem _menuItemView];
|
||||
|
||||
[_menuItemViews insertObject:menuItemView atIndex:index];
|
||||
|
||||
[menuItemView setTextColor:_textColor];
|
||||
[menuItemView setHidden:[menuItem isHidden]];
|
||||
|
||||
[menuItemView synchronizeWithMenuItem];
|
||||
|
||||
[[self contentView] addSubview:menuItemView];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)menuDidRemoveItem:(CPNotification)aNotification
|
||||
{
|
||||
var index = [[aNotification userInfo] objectForKey:@"CPMenuItemIndex"],
|
||||
menuItemView = [_menuItemViews objectAtIndex:index];
|
||||
|
||||
[_menuItemViews removeObjectAtIndex:index];
|
||||
|
||||
[menuItemView removeFromSuperview];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
var constraintRect = CGRectInset([[self platformWindow] visibleFrame], 5.0, 0.0);
|
||||
|
||||
constraintRect.size.height -= 5.0;
|
||||
|
||||
[[_CPMenuManager sharedMenuManager]
|
||||
beginTracking:anEvent
|
||||
menuContainer:self
|
||||
constraintRect:constraintRect
|
||||
callback:function(aMenuContainer, aMenu)
|
||||
{
|
||||
[aMenu _performActionOfHighlightedItemChain];
|
||||
[aMenu _highlightItemAtIndex:CPNotFound];
|
||||
}];
|
||||
}
|
||||
|
||||
- (CPFont)font
|
||||
{
|
||||
[CPFont systemFontOfSize:12.0];
|
||||
}
|
||||
|
||||
- (void)tile
|
||||
{
|
||||
var items = [_menu itemArray],
|
||||
index = 0,
|
||||
count = items.length,
|
||||
|
||||
x = MENUBAR_LEFT_MARGIN,
|
||||
y = 0.0,
|
||||
isLeftAligned = YES;
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var item = items[index];
|
||||
|
||||
if ([item isSeparatorItem])
|
||||
{
|
||||
x = CGRectGetWidth([self frame]) - MENUBAR_RIGHT_MARGIN;
|
||||
isLeftAligned = NO;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ([item isHidden])
|
||||
continue;
|
||||
|
||||
var menuItemView = [item _menuItemView],
|
||||
frame = [menuItemView frame];
|
||||
|
||||
if (isLeftAligned)
|
||||
{
|
||||
[menuItemView setFrame:CGRectMake(x, 0.0, CGRectGetWidth(frame), MENUBAR_HEIGHT)];
|
||||
|
||||
x += CGRectGetWidth([menuItemView frame]);
|
||||
}
|
||||
else
|
||||
{
|
||||
[menuItemView setFrame:CGRectMake(x - CGRectGetWidth(frame), 0.0, CGRectGetWidth(frame), MENUBAR_HEIGHT)];
|
||||
|
||||
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
|
||||
{
|
||||
var size = [self frame].size;
|
||||
|
||||
[super setFrame:aRect display:shouldDisplay animate:shouldAnimate];
|
||||
|
||||
if (!_CGSizeEqualToSize(size, aRect.size))
|
||||
[self tile];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPMenuBarWindow (CPMenuContainer)
|
||||
|
||||
- (BOOL)isMenuBar
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (CGRect)globalFrame
|
||||
{
|
||||
return [self frame];
|
||||
}
|
||||
|
||||
- (_CPManagerScrollingState)scrollingStateForPoint:(CGPoint)aGlobalLocation
|
||||
{
|
||||
return _CPMenuManagerScrollingStateNone;
|
||||
}
|
||||
|
||||
- (CPInteger)itemIndexAtPoint:(CGPoint)aPoint
|
||||
{
|
||||
var items = [_menu itemArray],
|
||||
index = items.length;
|
||||
|
||||
while (index--)
|
||||
{
|
||||
var item = items[index];
|
||||
|
||||
if ([item isHidden] || [item isSeparatorItem])
|
||||
continue;
|
||||
|
||||
if (CGRectContainsPoint([self rectForItemAtIndex:index], aPoint))
|
||||
return index;
|
||||
}
|
||||
|
||||
return CPNotFound;
|
||||
}
|
||||
|
||||
- (CGRect)rectForItemAtIndex:(CPInteger)anIndex
|
||||
{
|
||||
var menuItem = [_menu itemAtIndex:anIndex === CPNotFound ? 0 : anIndex];
|
||||
|
||||
return [[menuItem _menuItemView] frame];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPMenuBarView : _CPMenuView
|
||||
{
|
||||
}
|
||||
|
||||
- (CGRect)rectForItemAtIndex:(int)anIndex
|
||||
{
|
||||
return [_menuItemViews[anIndex === CPNotFound ? 0 : anIndex] frame];
|
||||
}
|
||||
|
||||
- (int)itemIndexAtPoint:(CGPoint)aPoint
|
||||
{
|
||||
var bounds = [self bounds];
|
||||
|
||||
if (!CGRectContainsPoint(bounds, aPoint))
|
||||
return CPNotFound;
|
||||
|
||||
var x = aPoint.x,
|
||||
low = 0,
|
||||
high = _visibleMenuItemInfos.length - 1;
|
||||
|
||||
while (low <= high)
|
||||
{
|
||||
var middle = FLOOR(low + (high - low) / 2),
|
||||
info = _visibleMenuItemInfos[middle],
|
||||
frame = [info.view frame];
|
||||
|
||||
if (x < CGRectGetMinX(frame))
|
||||
high = middle - 1;
|
||||
|
||||
else if (x > CGRectGetMaxX(frame))
|
||||
low = middle + 1;
|
||||
|
||||
else
|
||||
return info.index;
|
||||
}
|
||||
|
||||
return CPNotFound;
|
||||
}
|
||||
|
||||
- (void)tile
|
||||
{
|
||||
var items = [_menu itemArray],
|
||||
index = 0,
|
||||
count = items.length,
|
||||
|
||||
x = MENUBAR_LEFT_MARGIN,
|
||||
y = 0.0,
|
||||
isLeftAligned = YES;
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var item = items[index];
|
||||
|
||||
if ([item isSeparatorItem])
|
||||
{
|
||||
x = CGRectGetWidth([self frame]) - MENUBAR_RIGHT_MARGIN;
|
||||
isLeftAligned = NO;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ([item isHidden])
|
||||
continue;
|
||||
|
||||
var menuItemView = [item _menuItemView],
|
||||
frame = [menuItemView frame];
|
||||
|
||||
if (isLeftAligned)
|
||||
{
|
||||
[menuItemView setFrameOrigin:CGPointMake(x, (MENUBAR_HEIGHT - 1.0 - CGRectGetHeight(frame)) / 2.0)];
|
||||
|
||||
x += CGRectGetWidth([menuItemView frame]) + MENUBAR_MARGIN;
|
||||
}
|
||||
else
|
||||
{
|
||||
[menuItemView setFrameOrigin:CGPointMake(x - CGRectGetWidth(frame), (MENUBAR_HEIGHT - 1.0 - CGRectGetHeight(frame)) / 2.0)];
|
||||
|
||||
x = CGRectGetMinX([menuItemView frame]) - MENUBAR_MARGIN;
|
||||
}
|
||||
}
|
||||
|
||||
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)];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,370 @@
|
||||
|
||||
#include "../CoreGraphics/CGGeometry.h"
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
|
||||
_CPMenuManagerScrollingStateUp = -1,
|
||||
_CPMenuManagerScrollingStateDown = 1,
|
||||
_CPMenuManagerScrollingStateNone = 0;
|
||||
|
||||
var STICKY_TIME_INTERVAL = 500;
|
||||
|
||||
var SharedMenuManager = nil;
|
||||
|
||||
@implementation _CPMenuManager: CPObject
|
||||
{
|
||||
CPTimeInterval _startTime;
|
||||
int _scrollingState;
|
||||
CGPoint _lastGlobalLocation;
|
||||
|
||||
CPView _lastMouseOverMenuView;
|
||||
|
||||
CGRect _constraintRect;
|
||||
CPMutableArray _menuContainerStack;
|
||||
|
||||
Function _trackingCallback;
|
||||
}
|
||||
|
||||
+ (_CPMenuManager)sharedMenuManager
|
||||
{
|
||||
if (!SharedMenuManager)
|
||||
SharedMenuManager = [[_CPMenuManager alloc] init];
|
||||
|
||||
return SharedMenuManager;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if (SharedMenuManager)
|
||||
return SharedMenuManager;
|
||||
|
||||
return [super init];
|
||||
}
|
||||
|
||||
- (id)trackingMenuContainer
|
||||
{
|
||||
return _menuContainerStack[0];
|
||||
}
|
||||
|
||||
- (CPMenu)trackingMenu
|
||||
{
|
||||
return [[self trackingMenuContainer] menu];
|
||||
}
|
||||
|
||||
- (void)beginTracking:(CPEvent)anEvent
|
||||
menuContainer:(id)aMenuContainer
|
||||
constraintRect:(CGRect)aRect
|
||||
callback:(Function)aCallback
|
||||
{
|
||||
var menu = [aMenuContainer menu];
|
||||
|
||||
CPApp._activeMenu = menu;
|
||||
|
||||
_startTime = [anEvent timestamp];//new Date();
|
||||
_scrollingState = _CPMenuManagerScrollingStateNone;
|
||||
|
||||
_constraintRect = aRect;
|
||||
_menuContainerStack = [aMenuContainer];
|
||||
_trackingCallback = aCallback;
|
||||
|
||||
if (menu === [CPApp mainMenu])
|
||||
{
|
||||
var globalLocation = [anEvent globalLocation];
|
||||
|
||||
// Find which menu window the mouse is currently on top of
|
||||
var menuLocation = [aMenuContainer convertGlobalToBase:globalLocation];
|
||||
|
||||
// Find out the item the mouse is currently on top of
|
||||
var activeItemIndex = [aMenuContainer itemIndexAtPoint:menuLocation],
|
||||
activeItem = activeItemIndex !== CPNotFound ? [menu itemAtIndex:activeItemIndex] : nil;
|
||||
|
||||
_menuBarButtonItemIndex = activeItemIndex;
|
||||
_menuBarButtonMenuContainer = aMenuContainer;
|
||||
|
||||
if ([activeItem _isMenuBarButton])
|
||||
return [self trackMenuBarButtonEvent:anEvent];
|
||||
}
|
||||
|
||||
[self trackEvent:anEvent];
|
||||
}
|
||||
|
||||
- (void)trackEvent:(CPEvent)anEvent
|
||||
{
|
||||
var type = [anEvent type],
|
||||
trackingMenu = [self trackingMenu];
|
||||
|
||||
// Close Menu Event.
|
||||
if (type === CPAppKitDefined)
|
||||
return [self completeTracking]
|
||||
|
||||
[CPApp setTarget:self selector:@selector(trackEvent:) forNextEventMatchingMask:CPPeriodicMask | CPMouseMovedMask | CPLeftMouseDraggedMask | CPLeftMouseUpMask | CPAppKitDefinedMask untilDate:nil inMode:nil dequeue:YES];
|
||||
|
||||
// Periodic events don't have a valid location.
|
||||
var globalLocation = type === CPPeriodic ? _lastGlobalLocation : [anEvent globalLocation];
|
||||
|
||||
// Remember this for the next periodic event.
|
||||
_lastGlobalLocation = globalLocation;
|
||||
|
||||
// Find which menu window the mouse is currently on top of
|
||||
var activeMenuContainer = [self menuContainerForPoint:globalLocation],
|
||||
activeMenu = [activeMenuContainer menu],
|
||||
menuLocation = [activeMenuContainer convertGlobalToBase:globalLocation];
|
||||
|
||||
// Find out the item the mouse is currently on top of
|
||||
var activeItemIndex = activeMenuContainer ? [activeMenuContainer itemIndexAtPoint:menuLocation] : CPNotFound,
|
||||
activeItem = activeItemIndex !== CPNotFound ? [activeMenu itemAtIndex:activeItemIndex] : nil;
|
||||
|
||||
// If the item isn't enabled its as if we clicked on nothing.
|
||||
if (![activeItem isEnabled] || [activeItem _isMenuBarButton])
|
||||
{
|
||||
activeItemIndex = CPNotFound;
|
||||
activeItem = nil;
|
||||
}
|
||||
|
||||
var mouseOverMenuView = [activeItem view];
|
||||
|
||||
if (type === CPPeriodic)
|
||||
{
|
||||
if (_scrollingState === _CPMenuManagerScrollingStateUp)
|
||||
[activeMenuContainer scrollUp];
|
||||
|
||||
else if (_scrollingState === _CPMenuManagerScrollingStateDown)
|
||||
[activeMenuContainer scrollDown];
|
||||
}
|
||||
|
||||
// If we're over a custom menu view...
|
||||
if (mouseOverMenuView)
|
||||
{
|
||||
if (!_lastMouseOverMenuView)
|
||||
[activeMenu _highlightItemAtIndex:CPNotFound];
|
||||
|
||||
if (_lastMouseOverMenuView != mouseOverMenuView)
|
||||
{
|
||||
[mouseOverMenuView mouseExited:anEvent];
|
||||
// FIXME: Possibly multiple of these?
|
||||
[_lastMouseOverMenuView mouseEntered:anEvent];
|
||||
|
||||
_lastMouseOverMenuView = mouseOverMenuView;
|
||||
}
|
||||
|
||||
var menuContainerWindow = activeMenuContainer;
|
||||
|
||||
if (![menuContainerWindow isKindOfClass:[CPWindow class]])
|
||||
menuContainerWindow = [menuContainerWindow window];
|
||||
|
||||
[menuContainerWindow
|
||||
sendEvent:[CPEvent mouseEventWithType:type location:menuLocation modifierFlags:[anEvent modifierFlags]
|
||||
timestamp:[anEvent timestamp]
|
||||
windowNumber:menuContainerWindow
|
||||
context:nil
|
||||
eventNumber:0
|
||||
clickCount:[anEvent clickCount]
|
||||
pressure:[anEvent pressure]]];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_lastMouseOverMenuView)
|
||||
{
|
||||
[_lastMouseOverMenuView mouseExited:anEvent];
|
||||
_lastMouseOverMenuView = nil;
|
||||
}
|
||||
|
||||
[activeMenu _highlightItemAtIndex:activeItemIndex];
|
||||
|
||||
if (type === CPMouseMoved || type === CPLeftMouseDragged || type === CPLeftMouseDown)
|
||||
{
|
||||
var oldScrollingState = _scrollingState;
|
||||
|
||||
_scrollingState = [activeMenuContainer scrollingStateForPoint:globalLocation];
|
||||
|
||||
if (_scrollingState !== oldScrollingState)
|
||||
{
|
||||
if (_scrollingState === _CPMenuManagerScrollingStateNone)
|
||||
[CPEvent stopPeriodicEvents];
|
||||
|
||||
else if (oldScrollingState === _CPMenuManagerScrollingStateNone)
|
||||
[CPEvent startPeriodicEventsAfterDelay:0.0 withPeriod:0.04];
|
||||
}
|
||||
}
|
||||
else if (type === CPLeftMouseUp && ([anEvent timestamp] - _startTime > STICKY_TIME_INTERVAL))
|
||||
[trackingMenu cancelTracking];
|
||||
}
|
||||
|
||||
// If the item has a submenu, show it.
|
||||
if ([activeItem hasSubmenu])// && [activeItem action] === @selector(submenuAction:))
|
||||
{
|
||||
var activeItemRect = [activeMenuContainer rectForItemAtIndex:activeItemIndex];
|
||||
|
||||
if ([activeMenuContainer isMenuBar])
|
||||
var newMenuOrigin = CGPointMake(CGRectGetMinX(activeItemRect), CGRectGetMaxY(activeItemRect));
|
||||
else
|
||||
var newMenuOrigin = CGPointMake(CGRectGetMaxX(activeItemRect), CGRectGetMinY(activeItemRect));
|
||||
|
||||
newMenuOrigin = [activeMenuContainer convertBaseToGlobal:newMenuOrigin];
|
||||
|
||||
[self showMenu:[activeItem submenu] fromMenu:[activeItem menu] atPoint:newMenuOrigin];
|
||||
}
|
||||
|
||||
// This handles both the case where we've moved away from the menu, and where
|
||||
// we've moved to an item without a submenu.
|
||||
else
|
||||
[self showMenu:nil fromMenu:activeMenu atPoint:CGPointMakeZero()];
|
||||
}
|
||||
|
||||
- (void)trackMenuBarButtonEvent:(CPEvent)anEvent
|
||||
{
|
||||
var type = [anEvent type];
|
||||
|
||||
if (type === CPAppKitDefined)
|
||||
return [self completeTracking];
|
||||
|
||||
var globalLocation = [anEvent globalLocation];
|
||||
|
||||
// Find which menu window the mouse is currently on top of
|
||||
var menu = [self trackingMenu],
|
||||
trackingMenuContainer = [self trackingMenuContainer],
|
||||
menuLocation = [trackingMenuContainer convertGlobalToBase:globalLocation];
|
||||
|
||||
if ([trackingMenuContainer itemIndexAtPoint:menuLocation] === _menuBarButtonItemIndex)
|
||||
[menu _highlightItemAtIndex:_menuBarButtonItemIndex];
|
||||
|
||||
else
|
||||
[menu _highlightItemAtIndex:CPNotFound];
|
||||
|
||||
[CPApp setTarget:self selector:@selector(trackMenuBarButtonEvent:) forNextEventMatchingMask:CPPeriodicMask | CPMouseMovedMask | CPLeftMouseDraggedMask | CPLeftMouseUpMask | CPAppKitDefinedMask untilDate:nil inMode:nil dequeue:YES];
|
||||
|
||||
if (type === CPLeftMouseUp)
|
||||
[menu cancelTracking];
|
||||
}
|
||||
|
||||
- (void)completeTracking
|
||||
{
|
||||
var trackingMenu = [self trackingMenu];
|
||||
|
||||
// Stop all periodic events at this point.
|
||||
[CPEvent stopPeriodicEvents];
|
||||
|
||||
// Get the highlighted item from the original menu.
|
||||
var highlightedItem = [trackingMenu highlightedItem];
|
||||
|
||||
// Hide all submenus.
|
||||
[self showMenu:nil fromMenu:trackingMenu atPoint:nil];
|
||||
|
||||
var delegate = [trackingMenu delegate];
|
||||
|
||||
if ([delegate respondsToSelector:@selector(menuDidClose:)])
|
||||
[delegate menuDidClose:trackingMenu];
|
||||
|
||||
if (_trackingCallback)
|
||||
_trackingCallback([self trackingMenuContainer], trackingMenu);
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPMenuDidEndTrackingNotification
|
||||
object:trackingMenu];
|
||||
|
||||
CPApp._activeMenu = nil;
|
||||
}
|
||||
|
||||
- (id)menuContainerForPoint:(float)aGlobalLocation
|
||||
{
|
||||
var count = [_menuContainerStack count],
|
||||
firstMenuContainer = _menuContainerStack[0];
|
||||
|
||||
// Trivial case.
|
||||
if (count === 1)
|
||||
return firstMenuContainer;
|
||||
|
||||
var firstMenuWindowIndex = 0,
|
||||
lastMenuWindowIndex = count - 1;
|
||||
|
||||
// If the first menu container is a bar, then it has to fall strictly within its bounds.
|
||||
if ([firstMenuContainer isMenuBar])
|
||||
{
|
||||
if (CGRectContainsPoint([firstMenuContainer globalFrame], aGlobalLocation))
|
||||
return firstMenuContainer;
|
||||
|
||||
firstMenuWindowIndex = 1;
|
||||
}
|
||||
|
||||
var index = count,
|
||||
x = aGlobalLocation.x,
|
||||
closerDeltaX = Infinity,
|
||||
closerMenuContainer = nil;
|
||||
|
||||
while (index-- > firstMenuWindowIndex)
|
||||
{
|
||||
var menuContainer = _menuContainerStack[index],
|
||||
menuContainerFrame = [menuContainer globalFrame],
|
||||
menuContainerMinX = _CGRectGetMinX(menuContainerFrame),
|
||||
menuContainerMaxX = _CGRectGetMaxX(menuContainerFrame);
|
||||
|
||||
// If within the x bounds of this menu container, return it.
|
||||
if (x < menuContainerMaxX && x >= menuContainerMinX)
|
||||
return menuContainer;
|
||||
|
||||
// If this is either the first or last menu *window*, check to see how close we are to it.
|
||||
if (index === firstMenuWindowIndex || index === lastMenuWindowIndex)
|
||||
{
|
||||
var deltaX = ABS(x < menuContainerMinX ? menuContainerMinX - x : menuContainerMaxX - x);
|
||||
|
||||
if (deltaX < closerDeltaX)
|
||||
{
|
||||
closerMenuContainer = menuContainer;
|
||||
closerDeltaX = deltaX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return closerMenuContainer;
|
||||
}
|
||||
|
||||
- (void)showMenu:(CPMenu)newMenu fromMenu:(CPMenu)baseMenu atPoint:(CGPoint)aGlobalLocation
|
||||
{
|
||||
var count = _menuContainerStack.length,
|
||||
index = count;
|
||||
|
||||
// Hide all menus up to the base menu...
|
||||
while (index--)
|
||||
{
|
||||
var menuContainer = _menuContainerStack[index],
|
||||
menu = [menuContainer menu];
|
||||
|
||||
// If we reach the base menu, or this menu is already being shown, break.
|
||||
if (menu === baseMenu)
|
||||
break;
|
||||
|
||||
// If this menu is already being shown, unhighlight and return.
|
||||
if (menu === newMenu)//&& [menu supermenu] === baseMenu)
|
||||
return [newMenu _highlightItemAtIndex:CPNotFound];
|
||||
|
||||
[menuContainer orderOut:self];
|
||||
[menuContainer setMenu:nil];
|
||||
|
||||
[_CPMenuWindow poolMenuWindow:menuContainer];
|
||||
[_menuContainerStack removeObjectAtIndex:index];
|
||||
}
|
||||
|
||||
if (!newMenu)
|
||||
return;
|
||||
|
||||
// Unhighlight any previously highlighted item.
|
||||
[newMenu _highlightItemAtIndex:CPNotFound];
|
||||
|
||||
var menuWindow = [_CPMenuWindow menuWindowWithMenu:newMenu font:[_menuContainerStack[0] font]];
|
||||
|
||||
[_menuContainerStack addObject:menuWindow];
|
||||
|
||||
[menuWindow setConstraintRect:_constraintRect];
|
||||
|
||||
// If our parent menu is a menu bar...
|
||||
if (baseMenu === [self trackingMenu] && [[self trackingMenuContainer] isMenuBar])
|
||||
[menuWindow setBackgroundStyle:_CPMenuWindowMenuBarBackgroundStyle];
|
||||
else
|
||||
[menuWindow setBackgroundStyle:_CPMenuWindowPopUpBackgroundStyle];
|
||||
|
||||
[menuWindow setFrameOrigin:aGlobalLocation];
|
||||
[menuWindow orderFront:self];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,548 @@
|
||||
|
||||
#include "../CoreGraphics/CGGeometry.h"
|
||||
|
||||
|
||||
var _CPMenuWindowPool = [],
|
||||
_CPMenuWindowPoolCapacity = 5,
|
||||
|
||||
_CPMenuWindowBackgroundColors = [];
|
||||
|
||||
_CPMenuWindowMenuBarBackgroundStyle = 0;
|
||||
_CPMenuWindowPopUpBackgroundStyle = 1;
|
||||
_CPMenuWindowAttachedMenuBackgroundStyle = 2;
|
||||
|
||||
var STICKY_TIME_INTERVAL = 500,
|
||||
|
||||
TOP_MARGIN = 5.0,
|
||||
LEFT_MARGIN = 1.0,
|
||||
RIGHT_MARGIN = 1.0,
|
||||
BOTTOM_MARGIN = 5.0,
|
||||
|
||||
SCROLL_INDICATOR_HEIGHT = 16.0;
|
||||
|
||||
/*
|
||||
@ignore
|
||||
*/
|
||||
@implementation _CPMenuWindow : CPWindow
|
||||
{
|
||||
_CPMenuView _menuView;
|
||||
CPClipView _menuClipView;
|
||||
|
||||
CPImageView _moreAboveView;
|
||||
CPImageView _moreBelowView;
|
||||
|
||||
CGRect _unconstrainedFrame;
|
||||
CGRect _constraintRect;
|
||||
}
|
||||
|
||||
+ (id)menuWindowWithMenu:(CPMenu)aMenu font:(CPFont)aFont
|
||||
{
|
||||
var menuWindow = nil;
|
||||
|
||||
if (_CPMenuWindowPool.length)
|
||||
{
|
||||
menuWindow = _CPMenuWindowPool.pop();
|
||||
|
||||
// Do this so that coordinates will be accurate.
|
||||
[menuWindow setFrameOrigin:CGPointMakeZero()];
|
||||
}
|
||||
else
|
||||
menuWindow = [[_CPMenuWindow alloc] init];
|
||||
|
||||
[menuWindow setFont:aFont];
|
||||
[menuWindow setMenu:aMenu];
|
||||
[menuWindow setMinWidth:[aMenu minimumWidth]];
|
||||
|
||||
return menuWindow;
|
||||
}
|
||||
|
||||
+ (void)poolMenuWindow:(_CPMenuWindow)aMenuWindow
|
||||
{
|
||||
if (!aMenuWindow || _CPMenuWindowPool.length >= _CPMenuWindowPoolCapacity)
|
||||
return;
|
||||
|
||||
_CPMenuWindowPool.push(aMenuWindow);
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self != [_CPMenuWindow class])
|
||||
return;
|
||||
|
||||
var bundle = [CPBundle bundleForClass:self];
|
||||
|
||||
_CPMenuWindowMoreAboveImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindowMoreAbove.png"] size:CGSizeMake(38.0, 18.0)];
|
||||
_CPMenuWindowMoreBelowImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindowMoreBelow.png"] size:CGSizeMake(38.0, 18.0)];
|
||||
}
|
||||
|
||||
- (id)initWithContentRect:(CGRect)aRect styleMask:(unsigned)aStyleMask
|
||||
{
|
||||
_constraintRect = _CGRectMakeZero();
|
||||
_unconstrainedFrame = _CGRectMakeZero();
|
||||
|
||||
self = [super initWithContentRect:aRect styleMask:CPBorderlessWindowMask];
|
||||
|
||||
if (self)
|
||||
{
|
||||
[self setLevel:CPPopUpMenuWindowLevel];
|
||||
[self setHasShadow:YES];
|
||||
[self setShadowStyle:CPMenuWindowShadowStyle];
|
||||
[self setAcceptsMouseMovedEvents:YES];
|
||||
|
||||
var contentView = [self contentView];
|
||||
|
||||
_menuView = [[_CPMenuView alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
_menuClipView = [[CPClipView alloc] initWithFrame:CGRectMake(LEFT_MARGIN, TOP_MARGIN, 0.0, 0.0)];
|
||||
[_menuClipView setDocumentView:_menuView];
|
||||
|
||||
[contentView addSubview:_menuClipView];
|
||||
|
||||
_moreAboveView = [[CPImageView alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
[_moreAboveView setImage:_CPMenuWindowMoreAboveImage];
|
||||
[_moreAboveView setFrameSize:[_CPMenuWindowMoreAboveImage size]];
|
||||
|
||||
[contentView addSubview:_moreAboveView];
|
||||
|
||||
_moreBelowView = [[CPImageView alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
[_moreBelowView setImage:_CPMenuWindowMoreBelowImage];
|
||||
[_moreBelowView setFrameSize:[_CPMenuWindowMoreBelowImage size]];
|
||||
|
||||
[contentView addSubview:_moreBelowView];
|
||||
|
||||
[self setShadowStyle:CPWindowShadowStyleMenu];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (float)_standardLeftMargin
|
||||
{
|
||||
return LEFT_MARGIN;
|
||||
}
|
||||
|
||||
- (void)setFont:(CPFont)aFont
|
||||
{
|
||||
[_menuView setFont:aFont];
|
||||
}
|
||||
|
||||
- (CPFont)font
|
||||
{
|
||||
return [_menuView font];
|
||||
}
|
||||
|
||||
+ (CPColor)backgroundColorForBackgroundStyle:(_CPMenuWindowBackgroundStyle)aBackgroundStyle
|
||||
{
|
||||
var color = _CPMenuWindowBackgroundColors[aBackgroundStyle];
|
||||
|
||||
if (!color)
|
||||
{
|
||||
var bundle = [CPBundle bundleForClass:[self class]];
|
||||
|
||||
if (aBackgroundStyle == _CPMenuWindowPopUpBackgroundStyle)
|
||||
color = [CPColor colorWithPatternImage:[[CPNinePartImage alloc] initWithImageSlices:
|
||||
[
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindowRounded0.png"] size:CGSizeMake(4.0, 4.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindow1.png"] size:CGSizeMake(1.0, 4.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindowRounded2.png"] size:CGSizeMake(4.0, 4.0)],
|
||||
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindow3.png"] size:CGSizeMake(4.0, 1.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindow4.png"] size:CGSizeMake(1.0, 1.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindow5.png"] size:CGSizeMake(4.0, 1.0)],
|
||||
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindowRounded6.png"] size:CGSizeMake(4.0, 4.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindow7.png"] size:CGSizeMake(1.0, 4.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindowRounded8.png"] size:CGSizeMake(4.0, 4.0)]
|
||||
]]];
|
||||
|
||||
else if (aBackgroundStyle == _CPMenuWindowMenuBarBackgroundStyle)
|
||||
color = [CPColor colorWithPatternImage:[[CPNinePartImage alloc] initWithImageSlices:
|
||||
[
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindow3.png"] size:CGSizeMake(4.0, 0.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindow4.png"] size:CGSizeMake(1.0, 0.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindow5.png"] size:CGSizeMake(4.0, 0.0)],
|
||||
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindow3.png"] size:CGSizeMake(4.0, 1.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindow4.png"] size:CGSizeMake(1.0, 1.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindow5.png"] size:CGSizeMake(4.0, 1.0)],
|
||||
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindowRounded6.png"] size:CGSizeMake(4.0, 4.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindow7.png"] size:CGSizeMake(1.0, 4.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuWindow/_CPMenuWindowRounded8.png"] size:CGSizeMake(4.0, 4.0)]
|
||||
]]];
|
||||
|
||||
_CPMenuWindowBackgroundColors[aBackgroundStyle] = color;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
- (void)setBackgroundStyle:(_CPMenuWindowBackgroundStyle)aBackgroundStyle
|
||||
{
|
||||
[self setBackgroundColor:[[self class] backgroundColorForBackgroundStyle:aBackgroundStyle]];
|
||||
}
|
||||
|
||||
- (void)setMenu:(CPMenu)aMenu
|
||||
{
|
||||
[aMenu _setMenuWindow:self];
|
||||
[_menuView setMenu:aMenu];
|
||||
|
||||
var menuViewSize = [_menuView frame].size;
|
||||
|
||||
[self setFrameSize:CGSizeMake(LEFT_MARGIN + menuViewSize.width + RIGHT_MARGIN, TOP_MARGIN + menuViewSize.height + BOTTOM_MARGIN)];
|
||||
|
||||
[_menuView scrollPoint:CGPointMake(0.0, 0.0)];
|
||||
[_menuClipView setFrame:CGRectMake(LEFT_MARGIN, TOP_MARGIN, menuViewSize.width, menuViewSize.height)];
|
||||
}
|
||||
|
||||
- (void)setMinWidth:(float)aWidth
|
||||
{
|
||||
var size = [self unconstrainedFrame].size;
|
||||
|
||||
[self setFrameSize:CGSizeMake(MAX(size.width, aWidth), size.height)];
|
||||
}
|
||||
|
||||
- (CPMenu)menu
|
||||
{
|
||||
return [_menuView menu];
|
||||
}
|
||||
|
||||
- (void)orderFront:(id)aSender
|
||||
{
|
||||
[self setFrame:_unconstrainedFrame];
|
||||
|
||||
[super orderFront:aSender];
|
||||
}
|
||||
|
||||
- (void)setConstraintRect:(CGRect)aRect
|
||||
{
|
||||
_constraintRect = aRect;
|
||||
|
||||
[self setFrame:_unconstrainedFrame];
|
||||
}
|
||||
|
||||
- (CGRect)unconstrainedFrame
|
||||
{
|
||||
return _CGRectMakeCopy(_unconstrainedFrame);
|
||||
}
|
||||
|
||||
// We need this because if not this will call setFrame: with -frame instead of -unconstrainedFrame, turning
|
||||
// the constrained frame into the unconstrained frame.
|
||||
- (void)setFrameOrigin:(CGPoint)aPoint
|
||||
{
|
||||
[super setFrame:_CGRectMake(aPoint.x, aPoint.y, _CGRectGetWidth(_unconstrainedFrame), _CGRectGetHeight(_unconstrainedFrame))];
|
||||
}
|
||||
|
||||
- (void)setFrameSize:(CGSize)aSize
|
||||
{
|
||||
[super setFrame:_CGRectMake(_CGRectGetMinX(_unconstrainedFrame), _CGRectGetMinY(_unconstrainedFrame), aSize.width, aSize.height)];
|
||||
}
|
||||
|
||||
- (void)setFrame:(CGRect)aFrame display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate
|
||||
{
|
||||
// FIXME: There are integral window issues with platform windows.
|
||||
// FIXME: This gets called far too often.
|
||||
_unconstrainedFrame = _CGRectMakeCopy(aFrame);
|
||||
|
||||
var constrainedFrame = CGRectIntersection(_unconstrainedFrame, _constraintRect);
|
||||
|
||||
// We don't want to simply intersect the visible frame and the unconstrained frame.
|
||||
// We should be allowing as much of the width to fit as possible (pushing back and forward).
|
||||
constrainedFrame.origin.x = CGRectGetMinX(_unconstrainedFrame);
|
||||
constrainedFrame.size.width = CGRectGetWidth(_unconstrainedFrame);
|
||||
|
||||
if (CGRectGetWidth(constrainedFrame) > CGRectGetWidth(_constraintRect))
|
||||
constrainedFrame.size.width = CGRectGetWidth(_constraintRect);
|
||||
|
||||
if (CGRectGetMaxX(constrainedFrame) > CGRectGetMaxX(_constraintRect))
|
||||
constrainedFrame.origin.x -= CGRectGetMaxX(constrainedFrame) - CGRectGetMaxX(_constraintRect);
|
||||
|
||||
if (CGRectGetMinX(constrainedFrame) < CGRectGetMinX(_constraintRect))
|
||||
constrainedFrame.origin.x = CGRectGetMinX(_constraintRect);
|
||||
|
||||
[super setFrame:constrainedFrame display:shouldDisplay animate:shouldAnimate];
|
||||
|
||||
// This needs to happen before changing the frame.
|
||||
var menuViewOrigin = CGPointMake(CGRectGetMinX(aFrame) + LEFT_MARGIN, CGRectGetMinY(aFrame) + TOP_MARGIN),
|
||||
moreAbove = menuViewOrigin.y < CGRectGetMinY(constrainedFrame) + TOP_MARGIN,
|
||||
moreBelow = menuViewOrigin.y + CGRectGetHeight([_menuView frame]) > CGRectGetMaxY(constrainedFrame) - BOTTOM_MARGIN,
|
||||
|
||||
topMargin = TOP_MARGIN,
|
||||
bottomMargin = BOTTOM_MARGIN,
|
||||
|
||||
contentView = [self contentView],
|
||||
bounds = [contentView bounds];
|
||||
|
||||
if (moreAbove)
|
||||
{
|
||||
topMargin += SCROLL_INDICATOR_HEIGHT;
|
||||
|
||||
var frame = [_moreAboveView frame];
|
||||
|
||||
[_moreAboveView setFrameOrigin:CGPointMake((CGRectGetWidth(bounds) - CGRectGetWidth(frame)) / 2.0, (TOP_MARGIN + SCROLL_INDICATOR_HEIGHT - CGRectGetHeight(frame)) / 2.0)];
|
||||
}
|
||||
|
||||
[_moreAboveView setHidden:!moreAbove];
|
||||
|
||||
if (moreBelow)
|
||||
{
|
||||
bottomMargin += SCROLL_INDICATOR_HEIGHT;
|
||||
|
||||
[_moreBelowView setFrameOrigin:CGPointMake((CGRectGetWidth(bounds) - CGRectGetWidth([_moreBelowView frame])) / 2.0, CGRectGetHeight(bounds) - SCROLL_INDICATOR_HEIGHT - BOTTOM_MARGIN)];
|
||||
}
|
||||
|
||||
[_moreBelowView setHidden:!moreBelow];
|
||||
|
||||
var clipFrame = CGRectMake(LEFT_MARGIN, topMargin, CGRectGetWidth(constrainedFrame) - LEFT_MARGIN - RIGHT_MARGIN, CGRectGetHeight(constrainedFrame) - topMargin - bottomMargin)
|
||||
|
||||
[_menuClipView setFrame:clipFrame];
|
||||
[_menuView setFrameSize:CGSizeMake(CGRectGetWidth(clipFrame), CGRectGetHeight([_menuView frame]))];
|
||||
|
||||
[_menuView scrollPoint:CGPointMake(0.0, [self convertBaseToGlobal:clipFrame.origin].y - menuViewOrigin.y)];
|
||||
}
|
||||
|
||||
- (BOOL)hasMinimumNumberOfVisibleItems
|
||||
{
|
||||
var visibleRect = [_menuView visibleRect];
|
||||
|
||||
// Clearly if the entire view isn't visible the minimum won't be visible.
|
||||
if (CGRectIsEmpty(visibleRect))
|
||||
return NO;
|
||||
|
||||
var numberOfUnhiddenItems = [_menuView numberOfUnhiddenItems],
|
||||
minimumNumberOfVisibleItems = MIN(numberOfUnhiddenItems, 3),
|
||||
count = 0,
|
||||
index = [_menuView itemIndexAtPoint:[_menuView convertPoint:[_menuClipView frame].origin fromView:nil]];
|
||||
|
||||
for (; index < numberOfUnhiddenItems && count < minimumNumberOfVisibleItems; ++index)
|
||||
{
|
||||
var itemRect = [_menuView rectForUnhiddenItemAtIndex:index],
|
||||
visibleItemRect = CGRectIntersection(visibleRect, itemRect);
|
||||
|
||||
// As soon as we get to the first unhidden item that is no longer visible, stop.
|
||||
if (CGRectIsEmpty(visibleItemRect))
|
||||
break;
|
||||
|
||||
// If the item is *completely* visible, count it.
|
||||
if (CGRectEqualToRect(visibleItemRect, itemRect))
|
||||
++count;
|
||||
}
|
||||
|
||||
return count >= minimumNumberOfVisibleItems;
|
||||
}
|
||||
|
||||
- (BOOL)canScrollUp
|
||||
{
|
||||
return ![_moreAboveView isHidden];
|
||||
}
|
||||
|
||||
- (BOOL)canScrollDown
|
||||
{
|
||||
return ![_moreBelowView isHidden];
|
||||
}
|
||||
|
||||
- (BOOL)canScroll
|
||||
{
|
||||
return [self canScrollUp] || [self canScrollDown];
|
||||
}
|
||||
|
||||
- (void)scrollUp
|
||||
{
|
||||
if (CGRectGetMinY(_unconstrainedFrame) >= CGRectGetMinY(_constraintRect))
|
||||
return;
|
||||
|
||||
_unconstrainedFrame.origin.y += 10;
|
||||
|
||||
[self setFrame:_unconstrainedFrame];
|
||||
}
|
||||
|
||||
- (void)scrollDown
|
||||
{
|
||||
if (CGRectGetMaxY(_unconstrainedFrame) <= CGRectGetHeight(_constraintRect))
|
||||
return;
|
||||
|
||||
_unconstrainedFrame.origin.y -= 10;
|
||||
|
||||
[self setFrame:_unconstrainedFrame];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPMenuWindow (CPMenuContainer)
|
||||
|
||||
- (CGRect)globalFrame
|
||||
{
|
||||
return [self frame];
|
||||
}
|
||||
|
||||
- (BOOL)isMenuBar
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (_CPManagerScrollingState)scrollingStateForPoint:(CGPoint)aGlobalLocation
|
||||
{
|
||||
var frame = [self frame];
|
||||
|
||||
if (![self canScroll])
|
||||
return _CPMenuManagerScrollingStateNone;
|
||||
|
||||
// If we're at or above of the top scroll indicator...
|
||||
if (aGlobalLocation.y < CGRectGetMinY(frame) + TOP_MARGIN + SCROLL_INDICATOR_HEIGHT)
|
||||
return _CPMenuManagerScrollingStateUp;
|
||||
|
||||
// If we're at or below the bottom scroll indicator...
|
||||
if (aGlobalLocation.y > CGRectGetMaxY(frame) - BOTTOM_MARGIN - SCROLL_INDICATOR_HEIGHT)
|
||||
return _CPMenuManagerScrollingStateDown;
|
||||
|
||||
return _CPMenuManagerScrollingStateNone;
|
||||
}
|
||||
|
||||
- (float)deltaYForItemAtIndex:(int)anIndex
|
||||
{
|
||||
return TOP_MARGIN + CGRectGetMinY([_menuView rectForItemAtIndex:anIndex]);
|
||||
}
|
||||
|
||||
- (CGPoint)rectForItemAtIndex:(int)anIndex
|
||||
{
|
||||
return [_menuView convertRect:[_menuView rectForItemAtIndex:anIndex] toView:nil];
|
||||
}
|
||||
|
||||
- (int)itemIndexAtPoint:(CGPoint)aPoint
|
||||
{
|
||||
// Don't return indexes of items that aren't visible.
|
||||
if (!CGRectContainsPoint([_menuClipView bounds], [_menuClipView convertPoint:aPoint fromView:nil]))
|
||||
return NO;
|
||||
|
||||
return [_menuView itemIndexAtPoint:[_menuView convertPoint:aPoint fromView:nil]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
@ignore
|
||||
*/
|
||||
|
||||
@implementation _CPMenuView : CPView
|
||||
{
|
||||
CPArray _menuItemViews;
|
||||
CPArray _visibleMenuItemInfos;
|
||||
|
||||
CPFont _font @accessors(property=font);
|
||||
}
|
||||
|
||||
- (unsigned)numberOfUnhiddenItems
|
||||
{
|
||||
return _visibleMenuItemInfos.length;
|
||||
}
|
||||
|
||||
- (CGRect)rectForUnhiddenItemAtIndex:(int)anIndex
|
||||
{
|
||||
return [self rectForItemAtIndex:_visibleMenuItemInfos[anIndex].index];
|
||||
}
|
||||
|
||||
- (CGRect)rectForItemAtIndex:(int)anIndex
|
||||
{
|
||||
return [_menuItemViews[anIndex === CPNotFound ? 0 : anIndex] frame];
|
||||
}
|
||||
|
||||
- (int)itemIndexAtPoint:(CGPoint)aPoint
|
||||
{
|
||||
var x = aPoint.x,
|
||||
bounds = [self bounds];
|
||||
|
||||
if (x < CGRectGetMinX(bounds) || x > CGRectGetMaxX(bounds))
|
||||
return CPNotFound;
|
||||
|
||||
var y = aPoint.y,
|
||||
low = 0,
|
||||
high = _visibleMenuItemInfos.length - 1;
|
||||
|
||||
while (low <= high)
|
||||
{
|
||||
var middle = FLOOR(low + (high - low) / 2),
|
||||
info = _visibleMenuItemInfos[middle]
|
||||
frame = [info.view frame];
|
||||
|
||||
if (y < CGRectGetMinY(frame))
|
||||
high = middle - 1;
|
||||
|
||||
else if (y > CGRectGetMaxY(frame))
|
||||
low = middle + 1;
|
||||
|
||||
else
|
||||
return info.index;
|
||||
}
|
||||
|
||||
return CPNotFound;
|
||||
}
|
||||
|
||||
- (void)tile
|
||||
{
|
||||
[_menuItemViews makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
||||
|
||||
_menuItemViews = [];
|
||||
_visibleMenuItemInfos = [];
|
||||
|
||||
var menu = [self menu];
|
||||
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
var items = [menu itemArray],
|
||||
index = 0,
|
||||
count = [items count],
|
||||
maxWidth = 0,
|
||||
y = 0,
|
||||
showsStateColumn = [menu showsStateColumn];
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var item = items[index],
|
||||
view = [item _menuItemView];
|
||||
|
||||
_menuItemViews.push(view);
|
||||
|
||||
if ([item isHidden])
|
||||
continue;
|
||||
|
||||
_visibleMenuItemInfos.push({ view:view, index:index });
|
||||
|
||||
[view setFont:_font];
|
||||
[view setShowsStateColumn:showsStateColumn];
|
||||
[view synchronizeWithMenuItem];
|
||||
|
||||
[view setFrameOrigin:CGPointMake(0.0, y)];
|
||||
|
||||
[self addSubview:view];
|
||||
|
||||
var size = [view minSize],
|
||||
width = size.width;
|
||||
|
||||
if (maxWidth < width)
|
||||
maxWidth = width;
|
||||
|
||||
y += size.height;
|
||||
}
|
||||
|
||||
for (index = 0; index < count; ++index)
|
||||
{
|
||||
var view = _menuItemViews[index];
|
||||
|
||||
[view setFrameSize:CGSizeMake(maxWidth, CGRectGetHeight([view frame]))];
|
||||
}
|
||||
|
||||
[self setAutoresizesSubviews:NO];
|
||||
[self setFrameSize:CGSizeMake(maxWidth, y)];
|
||||
[self setAutoresizesSubviews:YES];
|
||||
}
|
||||
|
||||
- (void)setMenu:(CPMenu)aMenu
|
||||
{
|
||||
[super setMenu:aMenu];
|
||||
[self tile];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -24,9 +24,10 @@
|
||||
@import <Foundation/CPObject.j>
|
||||
@import <Foundation/CPString.j>
|
||||
|
||||
@import <AppKit/CPImage.j>
|
||||
@import <AppKit/CPMenu.j>
|
||||
@import <AppKit/CPView.j>
|
||||
@import "CPImage.j"
|
||||
@import "CPMenu.j"
|
||||
@import "CPView.j"
|
||||
@import "_CPMenuItemView.j"
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@@ -108,7 +109,9 @@
|
||||
|
||||
_keyEquivalent = aKeyEquivalent || @"";
|
||||
_keyEquivalentModifierMask = CPPlatformActionKeyMask;
|
||||
|
||||
|
||||
_indentationLevel = 0;
|
||||
|
||||
_mnemonicLocation = CPNotFound;
|
||||
}
|
||||
|
||||
@@ -448,20 +451,32 @@ CPOffState
|
||||
*/
|
||||
- (void)setSubmenu:(CPMenu)aMenu
|
||||
{
|
||||
var supermenu = [_submenu supermenu];
|
||||
|
||||
if (supermenu == self)
|
||||
if (_submenu === aMenu)
|
||||
return;
|
||||
|
||||
|
||||
var supermenu = [_submenu supermenu];
|
||||
|
||||
if (supermenu)
|
||||
return alert("bad");
|
||||
|
||||
[_submenu setSupermenu:_menu];
|
||||
|
||||
[CPException raise:CPInvalidArgumentException
|
||||
reason: @"Can't add submenu \"" + [aMenu title] + "\" to item \"" + [self title] + "\", because it is already submenu of \"" + [[aMenu supermenu] title] + "\""];
|
||||
|
||||
_submenu = aMenu;
|
||||
|
||||
|
||||
if (_submenu)
|
||||
{
|
||||
[_submenu setSupermenu:_menu];
|
||||
|
||||
[self setTarget:_menu];
|
||||
[self setAction:@selector(submenuAction:)];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setTarget:nil];
|
||||
[self setAction:NULL];
|
||||
}
|
||||
|
||||
[_menuItemView setDirty];
|
||||
|
||||
|
||||
[_menu itemChanged:self];
|
||||
}
|
||||
|
||||
@@ -570,6 +585,43 @@ CPControlKeyMask
|
||||
return _keyEquivalentModifierMask;
|
||||
}
|
||||
|
||||
- (CPString)keyEquivalentStringRepresentation
|
||||
{
|
||||
if (![_keyEquivalent length])
|
||||
return @"";
|
||||
|
||||
var string = _keyEquivalent.toUpperCase(),
|
||||
needsShift = _keyEquivalentModifierMask & CPShiftKeyMask || string === _keyEquivalent;
|
||||
|
||||
if (CPBrowserIsOperatingSystem(CPMacOperatingSystem))
|
||||
{
|
||||
if (_keyEquivalentModifierMask & CPCommandKeyMask)
|
||||
string = "⌘" + string;
|
||||
|
||||
if (needsShift)
|
||||
string = "⇧" + string;
|
||||
|
||||
if (_keyEquivalentModifierMask & CPAlternateKeyMask)
|
||||
string = "⌥" + string;
|
||||
|
||||
if (_keyEquivalentModifierMask & CPControlKeyMask)
|
||||
string = "^" + string;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (needsShift)
|
||||
string = "Shift-" + string;
|
||||
|
||||
if (_keyEquivalentModifierMask & CPAlternateKeyMask)
|
||||
string = "Alt-" + string;
|
||||
|
||||
if (_keyEquivalentModifierMask & CPControlKeyMask || _keyEquivalentModifierMask & CPCommandKeyMask)
|
||||
string = "Ctrl-" + string;
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
// Managing Mnemonics
|
||||
/*!
|
||||
Sets the index of the mnemonic character in the title. The character
|
||||
@@ -643,7 +695,7 @@ CPControlKeyMask
|
||||
- (void)setIndentationLevel:(unsigned)aLevel
|
||||
{
|
||||
if (aLevel < 0)
|
||||
[CPException raise:CPInvalidArgumentException reason:"setIndentationLevel: argument must be greater than 0."];
|
||||
[CPException raise:CPInvalidArgumentException reason:"setIndentationLevel: argument must be greater than or equal to 0."];
|
||||
|
||||
_indentationLevel = MIN(15, aLevel);
|
||||
}
|
||||
@@ -742,6 +794,16 @@ CPControlKeyMask
|
||||
return _menuItemView;
|
||||
}
|
||||
|
||||
- (BOOL)_isSelectable
|
||||
{
|
||||
return ![self submenu] || [self action] !== @selector(submenuAction:) || [self target] !== [self menu];
|
||||
}
|
||||
|
||||
- (BOOL)_isMenuBarButton
|
||||
{
|
||||
return ![self submenu] && [self menu] === [CPApp mainMenu];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
|
||||
@@ -765,6 +827,8 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
|
||||
CPMenuItemKeyEquivalentKey = @"CPMenuItemKeyEquivalentKey",
|
||||
CPMenuItemKeyEquivalentModifierMaskKey = @"CPMenuItemKeyEquivalentModifierMaskKey",
|
||||
|
||||
CPMenuItemIndentationLevelKey = @"CPMenuItemIndentationLevelKey",
|
||||
|
||||
CPMenuItemRepresentedObjectKey = @"CPMenuItemRepresentedObjectKey",
|
||||
CPMenuItemViewKey = @"CPMenuItemViewKey";
|
||||
|
||||
@@ -804,8 +868,9 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
|
||||
// CPImage _offStateImage;
|
||||
// CPImage _mixedStateImage;
|
||||
|
||||
_submenu = DEFAULT_VALUE(CPMenuItemSubmenuKey, nil);
|
||||
// This order matters because setSubmenu: needs _menu to be around.
|
||||
_menu = DEFAULT_VALUE(CPMenuItemMenuKey, nil);
|
||||
[self setSubmenu:DEFAULT_VALUE(CPMenuItemSubmenuKey, nil)];
|
||||
|
||||
_keyEquivalent = [aCoder decodeObjectForKey:CPMenuItemKeyEquivalentKey] || @"";
|
||||
_keyEquivalentModifierMask = [aCoder decodeObjectForKey:CPMenuItemKeyEquivalentModifierMaskKey] || 0;
|
||||
@@ -813,7 +878,9 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
|
||||
// int _mnemonicLocation;
|
||||
|
||||
// BOOL _isAlternate;
|
||||
// int _indentationLevel;
|
||||
|
||||
// Default is 0.
|
||||
[self setIndentationLevel:[aCoder decodeIntForKey:CPMenuItemIndentationLevelKey] || 0];
|
||||
|
||||
// CPString _toolTip;
|
||||
|
||||
@@ -856,423 +923,11 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
|
||||
if (_keyEquivalentModifierMask)
|
||||
[aCoder encodeObject:_keyEquivalentModifierMask forKey:CPMenuItemKeyEquivalentModifierMaskKey];
|
||||
|
||||
if (_indentationLevel > 0)
|
||||
[aCoder encodeInt:_indentationLevel forKey:CPMenuItemIndentationLevelKey];
|
||||
|
||||
ENCODE_IFNOT(CPMenuItemRepresentedObjectKey, _representedObject, nil);
|
||||
ENCODE_IFNOT(CPMenuItemViewKey, _view, nil);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var LEFT_MARGIN = 3.0,
|
||||
RIGHT_MARGIN = 16.0,
|
||||
STATE_COLUMN_WIDTH = 14.0,
|
||||
INDENTATION_WIDTH = 17.0,
|
||||
VERTICAL_MARGIN = 4.0;
|
||||
|
||||
var _CPMenuItemSelectionColor = nil,
|
||||
_CPMenuItemTextShadowColor = nil,
|
||||
|
||||
_CPMenuItemDefaultStateImages = [],
|
||||
_CPMenuItemDefaultStateHighlightedImages = [];
|
||||
|
||||
/*
|
||||
@ignore
|
||||
*/
|
||||
@implementation _CPMenuItemView : CPView
|
||||
{
|
||||
CPMenuItem _menuItem;
|
||||
|
||||
CPFont _font;
|
||||
CPColor _textColor;
|
||||
CPColor _textShadowColor;
|
||||
CPColor _activateColor;
|
||||
CPColor _activateShadowColor;
|
||||
|
||||
CGSize _minSize;
|
||||
BOOL _isDirty;
|
||||
BOOL _showsStateColumn;
|
||||
BOOL _belongsToMenuBar;
|
||||
|
||||
CPImageView _stateView;
|
||||
_CPImageAndTextView _imageAndTextView;
|
||||
CPView _submenuView;
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self != [_CPMenuItemView class])
|
||||
return;
|
||||
|
||||
_CPMenuItemSelectionColor = [CPColor colorWithCalibratedRed:95.0 / 255.0 green:131.0 / 255.0 blue:185.0 / 255.0 alpha:1.0];
|
||||
_CPMenuItemTextShadowColor = [CPColor colorWithCalibratedRed:26.0 / 255.0 green: 73.0 / 255.0 blue:109.0 / 255.0 alpha:1.0]
|
||||
|
||||
var bundle = [CPBundle bundleForClass:self];
|
||||
|
||||
_CPMenuItemDefaultStateImages[CPOffState] = nil;
|
||||
_CPMenuItemDefaultStateHighlightedImages[CPOffState] = nil;
|
||||
|
||||
_CPMenuItemDefaultStateImages[CPOnState] = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPMenuItem/CPMenuItemOnState.png"] size:CGSizeMake(14.0, 14.0)];
|
||||
_CPMenuItemDefaultStateHighlightedImages[CPOnState] = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPMenuItem/CPMenuItemOnStateHighlighted.png"] size:CGSizeMake(14.0, 14.0)];
|
||||
|
||||
_CPMenuItemDefaultStateImages[CPMixedState] = nil;
|
||||
_CPMenuItemDefaultStateHighlightedImages[CPMixedState] = nil;
|
||||
}
|
||||
|
||||
+ (float)leftMargin
|
||||
{
|
||||
return LEFT_MARGIN + STATE_COLUMN_WIDTH;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame forMenuItem:(CPMenuItem)aMenuItem
|
||||
{
|
||||
self = [super initWithFrame:aFrame];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_menuItem = aMenuItem;
|
||||
_showsStateColumn = YES;
|
||||
_isDirty = YES;
|
||||
|
||||
[self setAutoresizingMask:CPViewWidthSizable];
|
||||
|
||||
[self synchronizeWithMenuItem];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CGSize)minSize
|
||||
{
|
||||
return _minSize;
|
||||
}
|
||||
|
||||
- (void)setDirty
|
||||
{
|
||||
_isDirty = YES;
|
||||
}
|
||||
|
||||
- (void)synchronizeWithMenuItem
|
||||
{
|
||||
if (!_isDirty)
|
||||
return;
|
||||
|
||||
_isDirty = NO;
|
||||
|
||||
var view = [_menuItem view];
|
||||
|
||||
if ([_menuItem isSeparatorItem])
|
||||
{
|
||||
var line = [[CPView alloc] initWithFrame:CGRectMake(0.0, 5.0, 10.0, 1.0)];
|
||||
|
||||
view = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 10.0)];
|
||||
|
||||
[view setAutoresizingMask:CPViewWidthSizable];
|
||||
[line setAutoresizingMask:CPViewWidthSizable];
|
||||
|
||||
[line setBackgroundColor:[CPColor lightGrayColor]];
|
||||
|
||||
[view addSubview:line];
|
||||
}
|
||||
|
||||
if (view)
|
||||
{
|
||||
[_imageAndTextView removeFromSuperview];
|
||||
_imageAndTextView = nil;
|
||||
|
||||
[_stateView removeFromSuperview];
|
||||
_stateView = nil;
|
||||
|
||||
[_submenuView removeFromSuperview];
|
||||
_submenuView = nil;
|
||||
|
||||
_minSize = [view frame].size;
|
||||
|
||||
[self setFrameSize:_minSize];
|
||||
|
||||
[self addSubview:view];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// State Column
|
||||
var x = _belongsToMenuBar ? 0.0 : (LEFT_MARGIN + [_menuItem indentationLevel] * INDENTATION_WIDTH);
|
||||
|
||||
if (_showsStateColumn)
|
||||
{
|
||||
if (!_stateView)
|
||||
{
|
||||
_stateView = [[CPImageView alloc] initWithFrame:CGRectMake(x, (CGRectGetHeight([self frame]) - STATE_COLUMN_WIDTH) / 2.0, STATE_COLUMN_WIDTH, STATE_COLUMN_WIDTH)];
|
||||
|
||||
[_stateView setAutoresizingMask:CPViewMinYMargin | CPViewMaxYMargin];
|
||||
|
||||
[self addSubview:_stateView];
|
||||
}
|
||||
|
||||
var state = [_menuItem state];
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case CPOffState:
|
||||
case CPOnState:
|
||||
case CPMixedState: [_stateView setImage:_CPMenuItemDefaultStateImages[state]];
|
||||
break;
|
||||
|
||||
default: [_stateView setImage:nil];
|
||||
}
|
||||
|
||||
x += STATE_COLUMN_WIDTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
[_stateView removeFromSuperview];
|
||||
|
||||
_stateView = nil;
|
||||
}
|
||||
|
||||
// Image and Title
|
||||
|
||||
if (!_imageAndTextView)
|
||||
{
|
||||
_imageAndTextView = [[_CPImageAndTextView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 0.0)];
|
||||
|
||||
[_imageAndTextView setImagePosition:CPImageLeft];
|
||||
[_imageAndTextView setTextShadowOffset:CGSizeMake(0.0, 1.0)];
|
||||
|
||||
[self addSubview:_imageAndTextView];
|
||||
}
|
||||
|
||||
var font = [_menuItem font];
|
||||
|
||||
if (!font)
|
||||
font = _font;
|
||||
|
||||
[_imageAndTextView setFont:font];
|
||||
[_imageAndTextView setVerticalAlignment:CPCenterVerticalTextAlignment];
|
||||
[_imageAndTextView setImage:[_menuItem image]];
|
||||
[_imageAndTextView setText:[_menuItem title]];
|
||||
[_imageAndTextView setTextColor:[self textColor]];
|
||||
[_imageAndTextView setTextShadowColor:[self textShadowColor]];
|
||||
[_imageAndTextView setTextShadowOffset:CGSizeMake(0, 1)];
|
||||
[_imageAndTextView setFrameOrigin:CGPointMake(x, VERTICAL_MARGIN)];
|
||||
[_imageAndTextView sizeToFit];
|
||||
|
||||
var frame = [_imageAndTextView frame];
|
||||
|
||||
// frame.size.height += 1.0;
|
||||
// [_imageAndTextView setFrame:frame];
|
||||
|
||||
frame.size.height += 2 * VERTICAL_MARGIN;
|
||||
|
||||
x += CGRectGetWidth(frame);
|
||||
|
||||
// Submenu Arrow
|
||||
if ([_menuItem hasSubmenu])
|
||||
{
|
||||
x += 3.0;
|
||||
|
||||
if (!_submenuView)
|
||||
{
|
||||
_submenuView = [[_CPMenuItemArrowView alloc] initWithFrame:CGRectMake(0.0, 0.0, 10.0, 10.0)];
|
||||
|
||||
[self addSubview:_submenuView];
|
||||
}
|
||||
|
||||
[_submenuView setHidden:NO];
|
||||
[_submenuView setColor:_belongsToMenuBar ? [self textColor] : nil];
|
||||
[_submenuView setFrameOrigin:CGPointMake(x, (CGRectGetHeight(frame) - 10.0) / 2.0)];
|
||||
|
||||
x += 10.0;
|
||||
}
|
||||
else
|
||||
[_submenuView setHidden:YES];
|
||||
|
||||
_minSize = CGSizeMake(x + (_belongsToMenuBar ? 0.0 : RIGHT_MARGIN) + 3.0, CGRectGetHeight(frame));
|
||||
|
||||
[self setFrameSize:_minSize];
|
||||
}
|
||||
|
||||
- (CGFloat)overlapOffsetWidth
|
||||
{
|
||||
return LEFT_MARGIN + ([[_menuItem menu] showsStateColumn] ? STATE_COLUMN_WIDTH : 0.0);
|
||||
}
|
||||
|
||||
- (void)setShowsStateColumn:(BOOL)shouldShowStateColumn
|
||||
{
|
||||
_showsStateColumn = shouldShowStateColumn;
|
||||
}
|
||||
|
||||
- (void)setBelongsToMenuBar:(BOOL)shouldBelongToMenuBar
|
||||
{
|
||||
_belongsToMenuBar = shouldBelongToMenuBar;
|
||||
}
|
||||
|
||||
- (void)highlight:(BOOL)shouldHighlight
|
||||
{
|
||||
// ASSERT(![_menuItem view]);
|
||||
|
||||
if (_belongsToMenuBar)
|
||||
[_imageAndTextView setImage:shouldHighlight ? [_menuItem alternateImage] : [_menuItem image]];
|
||||
|
||||
else if ([_menuItem isEnabled])
|
||||
{
|
||||
if (shouldHighlight)
|
||||
{
|
||||
[self setBackgroundColor:_CPMenuItemSelectionColor];
|
||||
|
||||
[_imageAndTextView setTextColor:[CPColor whiteColor]];
|
||||
[_imageAndTextView setTextShadowColor:_CPMenuItemTextShadowColor];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setBackgroundColor:nil];
|
||||
|
||||
[_imageAndTextView setTextColor:[self textColor]];
|
||||
[_imageAndTextView setTextShadowColor:[self textShadowColor]];
|
||||
}
|
||||
|
||||
var state = [_menuItem state];
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case CPOffState:
|
||||
case CPOnState:
|
||||
case CPMixedState: [_stateView setImage:shouldHighlight ? _CPMenuItemDefaultStateHighlightedImages[state] : _CPMenuItemDefaultStateImages[state]];
|
||||
break;
|
||||
|
||||
default: [_stateView setImage:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)activate:(BOOL)shouldActivate
|
||||
{
|
||||
[_imageAndTextView setImage:[_menuItem image]];
|
||||
|
||||
if (shouldActivate)
|
||||
{
|
||||
[_imageAndTextView setTextColor:[self activateColor] || [CPColor whiteColor]];
|
||||
[_imageAndTextView setTextShadowColor:[self activateShadowColor] || [CPColor blackColor]];
|
||||
[_submenuView setColor:[self activateColor] || [CPColor whiteColor]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_imageAndTextView setTextColor:[self textColor]];
|
||||
[_imageAndTextView setTextShadowColor:[self textShadowColor]];
|
||||
[_submenuView setColor:[self textColor]];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)eventOnSubmenu:(CPEvent)anEvent
|
||||
{
|
||||
if (![_menuItem hasSubmenu])
|
||||
return NO;
|
||||
|
||||
return CGRectContainsPoint([_submenuView frame], [self convertPoint:[anEvent locationInWindow] fromView:nil]);
|
||||
}
|
||||
|
||||
- (BOOL)isHidden
|
||||
{
|
||||
return [_menuItem isHidden];
|
||||
}
|
||||
|
||||
- (CPMenuItem)menuItem
|
||||
{
|
||||
return _menuItem;
|
||||
}
|
||||
|
||||
- (void)setFont:(CPFont)aFont
|
||||
{
|
||||
if (_font == aFont)
|
||||
return;
|
||||
|
||||
_font = aFont;
|
||||
|
||||
[self setDirty];
|
||||
}
|
||||
|
||||
- (void)setTextColor:(CPColor)aColor
|
||||
{
|
||||
if (_textColor == aColor)
|
||||
return;
|
||||
|
||||
_textColor = aColor;
|
||||
|
||||
[_imageAndTextView setTextColor:[self textColor]];
|
||||
[_submenuView setColor:[self textColor]];
|
||||
}
|
||||
|
||||
- (CPColor)textColor
|
||||
{
|
||||
return [_menuItem isEnabled] ? (_textColor ? _textColor : [CPColor colorWithCalibratedRed:70.0 / 255.0 green:69.0 / 255.0 blue:69.0 / 255.0 alpha:1.0]) : [CPColor lightGrayColor];
|
||||
}
|
||||
|
||||
- (void)setTextShadowColor:(CPColor)aColor
|
||||
{
|
||||
if (_textShadowColor == aColor)
|
||||
return;
|
||||
|
||||
_textShadowColor = aColor;
|
||||
|
||||
[_imageAndTextView setTextShadowColor:[self textShadowColor]];
|
||||
//[_submenuView setColor:[self textColor]];
|
||||
}
|
||||
|
||||
- (CPColor)textShadowColor
|
||||
{
|
||||
return [_menuItem isEnabled] ? (_textShadowColor ? _textShadowColor : [CPColor colorWithWhite:1.0 alpha:0.8]) : [CPColor colorWithWhite:0.8 alpha:0.8];
|
||||
}
|
||||
|
||||
- (void)setActivateColor:(CPColor)aColor
|
||||
{
|
||||
_activateColor = aColor;
|
||||
}
|
||||
|
||||
- (CPColor)activateColor
|
||||
{
|
||||
return _activateColor;
|
||||
}
|
||||
|
||||
- (void)setActivateShadowColor:(CPColor)aColor
|
||||
{
|
||||
_activateShadowColor = aColor;
|
||||
}
|
||||
|
||||
- (CPColor)activateShadowColor
|
||||
{
|
||||
return _activateShadowColor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPMenuItemArrowView : CPView
|
||||
{
|
||||
CPColor _color;
|
||||
}
|
||||
|
||||
- (void)setColor:(CPColor)aColor
|
||||
{
|
||||
if (_color == aColor)
|
||||
return;
|
||||
|
||||
_color = aColor;
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)aRect
|
||||
{
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort];
|
||||
|
||||
CGContextBeginPath(context);
|
||||
|
||||
CGContextMoveToPoint(context, 1.0, 4.0);
|
||||
CGContextAddLineToPoint(context, 9.0, 4.0);
|
||||
CGContextAddLineToPoint(context, 5.0, 8.0);
|
||||
CGContextAddLineToPoint(context, 1.0, 4.0);
|
||||
|
||||
CGContextClosePath(context);
|
||||
|
||||
CGContextSetFillColor(context, _color);
|
||||
CGContextFillPath(context);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,235 @@
|
||||
var HORIZONTAL_MARGIN = 8.0,
|
||||
SUBMENU_INDICATOR_MARGIN = 3.0,
|
||||
VERTICAL_MARGIN = 4.0;
|
||||
|
||||
var SelectionColor = nil,
|
||||
SUBMENU_INDICATOR_COLOR = nil,
|
||||
_CPMenuItemSelectionColor = nil,
|
||||
_CPMenuItemTextShadowColor = nil,
|
||||
|
||||
_CPMenuItemDefaultStateImages = [],
|
||||
_CPMenuItemDefaultStateHighlightedImages = [];
|
||||
|
||||
@implementation _CPMenuItemMenuBarView : CPView
|
||||
{
|
||||
CPMenuItem _menuItem @accessors(property=menuItem);
|
||||
|
||||
CPFont _font;
|
||||
CPColor _textColor;
|
||||
CPColor _textShadowColor;
|
||||
|
||||
BOOL _isDirty;
|
||||
|
||||
_CPImageAndTextView _imageAndTextView;
|
||||
CPView _submenuIndicatorView;
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self !== [_CPMenuItemMenuBarView class])
|
||||
return;
|
||||
|
||||
var bundle = [CPBundle bundleForClass:self];
|
||||
|
||||
SelectionColor = [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuBarWindow/_CPMenuBarWindowBackgroundSelected.png"] size:CGSizeMake(1.0, 28.0)]];
|
||||
|
||||
SUBMENU_INDICATOR_COLOR = [CPColor grayColor];
|
||||
|
||||
_CPMenuItemSelectionColor = [CPColor colorWithCalibratedRed:95.0 / 255.0 green:131.0 / 255.0 blue:185.0 / 255.0 alpha:1.0];
|
||||
_CPMenuItemTextShadowColor = [CPColor colorWithCalibratedRed:26.0 / 255.0 green: 73.0 / 255.0 blue:109.0 / 255.0 alpha:1.0];
|
||||
|
||||
_CPMenuItemDefaultStateImages[CPOffState] = nil;
|
||||
_CPMenuItemDefaultStateHighlightedImages[CPOffState] = nil;
|
||||
|
||||
_CPMenuItemDefaultStateImages[CPOnState] = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPMenuItem/CPMenuItemOnState.png"] size:CGSizeMake(14.0, 14.0)];
|
||||
_CPMenuItemDefaultStateHighlightedImages[CPOnState] = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPMenuItem/CPMenuItemOnStateHighlighted.png"] size:CGSizeMake(14.0, 14.0)];
|
||||
|
||||
_CPMenuItemDefaultStateImages[CPMixedState] = nil;
|
||||
_CPMenuItemDefaultStateHighlightedImages[CPMixedState] = nil;
|
||||
}
|
||||
|
||||
+ (id)view
|
||||
{
|
||||
return [[self alloc] init];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
self = [super initWithFrame:aFrame];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_imageAndTextView = [[_CPImageAndTextView alloc] initWithFrame:CGRectMake(HORIZONTAL_MARGIN, 0.0, 0.0, 0.0)];
|
||||
|
||||
[_imageAndTextView setImagePosition:CPImageLeft];
|
||||
[_imageAndTextView setTextShadowOffset:CGSizeMake(0.0, 1.0)];
|
||||
[_imageAndTextView setAutoresizingMask:CPViewMinYMargin | CPViewMaxYMargin];
|
||||
|
||||
[self addSubview:_imageAndTextView];
|
||||
|
||||
_submenuIndicatorView = [[_CPMenuItemMenuBarSubmenuIndicatorView alloc] initWithFrame:CGRectMake(0.0, 0.0, 9.0, 6.0)];
|
||||
|
||||
[_submenuIndicatorView setAutoresizingMask:CPViewMinYMargin | CPViewMaxYMargin];
|
||||
|
||||
[self addSubview:_submenuIndicatorView];
|
||||
|
||||
[self setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPColor)textColor
|
||||
{
|
||||
if (![_menuItem isEnabled])
|
||||
return [CPColor lightGrayColor];
|
||||
|
||||
return _textColor || [CPColor colorWithCalibratedRed:70.0 / 255.0 green:69.0 / 255.0 blue:69.0 / 255.0 alpha:1.0];
|
||||
}
|
||||
|
||||
- (CPColor)textShadowColor
|
||||
{
|
||||
if (![_menuItem isEnabled])
|
||||
return [CPColor colorWithWhite:0.8 alpha:0.8];
|
||||
|
||||
return _textShadowColor || [CPColor colorWithWhite:1.0 alpha:0.8];
|
||||
}
|
||||
|
||||
- (void)update
|
||||
{
|
||||
var x = HORIZONTAL_MARGIN,
|
||||
height = 0.0;
|
||||
|
||||
[_imageAndTextView setFont:[_menuItem font] || [_CPMenuBarWindow font]];
|
||||
[_imageAndTextView setVerticalAlignment:CPCenterVerticalTextAlignment];
|
||||
[_imageAndTextView setImage:[_menuItem image]];
|
||||
[_imageAndTextView setText:[_menuItem title]];
|
||||
[_imageAndTextView setTextColor:[self textColor]];
|
||||
[_imageAndTextView setTextShadowColor:[self textShadowColor]];
|
||||
[_imageAndTextView setTextShadowOffset:CGSizeMake(0.0, 1.0)];
|
||||
[_imageAndTextView sizeToFit];
|
||||
|
||||
var imageAndTextViewFrame = [_imageAndTextView frame];
|
||||
|
||||
imageAndTextViewFrame.origin.x = x;
|
||||
x += CGRectGetWidth(imageAndTextViewFrame);
|
||||
height = MAX(height, CGRectGetHeight(imageAndTextViewFrame));
|
||||
|
||||
var hasSubmenuIndicator = [_menuItem hasSubmenu] && [_menuItem action];
|
||||
|
||||
if (hasSubmenuIndicator)
|
||||
{
|
||||
[_submenuIndicatorView setHidden:NO];
|
||||
[_submenuIndicatorView setColor:[self textColor]];
|
||||
[_submenuIndicatorView setShadowColor:[self textShadowColor]];
|
||||
|
||||
var submenuViewFrame = [_submenuIndicatorView frame];
|
||||
|
||||
submenuViewFrame.origin.x = x + SUBMENU_INDICATOR_MARGIN;
|
||||
|
||||
x = CGRectGetMaxX(submenuViewFrame);
|
||||
height = MAX(height, CGRectGetHeight(submenuViewFrame));
|
||||
}
|
||||
else
|
||||
[_submenuIndicatorView setHidden:YES];
|
||||
|
||||
height += 2.0 * VERTICAL_MARGIN;
|
||||
|
||||
imageAndTextViewFrame.origin.y = FLOOR((height - CGRectGetHeight(imageAndTextViewFrame)) / 2.0);
|
||||
[_imageAndTextView setFrame:imageAndTextViewFrame];
|
||||
|
||||
if (hasSubmenuIndicator)
|
||||
{
|
||||
submenuViewFrame.origin.y = FLOOR((height - CGRectGetHeight(submenuViewFrame)) / 2.0) + 1.0;
|
||||
[_submenuIndicatorView setFrame:submenuViewFrame];
|
||||
}
|
||||
|
||||
_minSize = CGSizeMake(x + HORIZONTAL_MARGIN, height);
|
||||
|
||||
[self setAutoresizesSubviews:NO];
|
||||
[self setFrameSize:_minSize];
|
||||
[self setAutoresizesSubviews:YES];
|
||||
}
|
||||
|
||||
- (void)highlight:(BOOL)shouldHighlight
|
||||
{
|
||||
// FIXME: This should probably be even throw.
|
||||
if (![_menuItem isEnabled])
|
||||
shouldHighlight = NO;
|
||||
|
||||
if (shouldHighlight)
|
||||
{
|
||||
if (![_menuItem _isMenuBarButton])
|
||||
[self setBackgroundColor:SelectionColor];
|
||||
|
||||
[_imageAndTextView setImage:[_menuItem alternateImage] || [_menuItem image]];
|
||||
[_imageAndTextView setTextColor:[CPColor whiteColor]];
|
||||
[_imageAndTextView setTextShadowColor:_CPMenuItemTextShadowColor];
|
||||
|
||||
[_submenuIndicatorView setColor:[CPColor whiteColor]];
|
||||
[_submenuIndicatorView setShadowColor:[CPColor colorWithWhite:0.1 alpha:0.7]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setBackgroundColor:nil];
|
||||
|
||||
[_imageAndTextView setImage:[_menuItem image]];
|
||||
[_imageAndTextView setTextColor:[self textColor]];
|
||||
[_imageAndTextView setTextShadowColor:[self textShadowColor]];
|
||||
|
||||
[_submenuIndicatorView setColor:[self textColor]];
|
||||
[_submenuIndicatorView setShadowColor:[self textShadowColor]];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPMenuItemMenuBarSubmenuIndicatorView : CPView
|
||||
{
|
||||
CPColor _color;
|
||||
CPColor _shadowColor;
|
||||
}
|
||||
|
||||
- (void)setColor:(CPColor)aColor
|
||||
{
|
||||
if (_color === aColor)
|
||||
return;
|
||||
|
||||
_color = aColor;
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)setShadowColor:(CPColor)aColor
|
||||
{
|
||||
if (_shadowColor === aColor)
|
||||
return;
|
||||
|
||||
_shadowColor = aColor;
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)aRect
|
||||
{
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
bounds = [self bounds];
|
||||
|
||||
bounds.size.height -= 1.0;
|
||||
bounds.size.width -= 2.0;
|
||||
bounds.origin.x += 1.0;
|
||||
|
||||
CGContextBeginPath(context);
|
||||
|
||||
CGContextMoveToPoint(context, CGRectGetMinX(bounds), CGRectGetMinY(bounds));
|
||||
CGContextAddLineToPoint(context, CGRectGetMaxX(bounds), CGRectGetMinY(bounds));
|
||||
CGContextAddLineToPoint(context, CGRectGetMidX(bounds), CGRectGetMaxY(bounds));
|
||||
|
||||
CGContextClosePath(context);
|
||||
|
||||
CGContextSetShadowWithColor(context, CGSizeMake(0.0, 1.0), 1.1, _shadowColor);
|
||||
CGContextSetFillColor(context, _color);
|
||||
CGContextFillPath(context);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
@import <AppKit/CPView.j>
|
||||
|
||||
|
||||
@implementation _CPMenuItemSeparatorView : CPView
|
||||
{
|
||||
}
|
||||
|
||||
+ (id)view
|
||||
{
|
||||
return [[self alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 10.0)];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
self = [super initWithFrame:aFrame];
|
||||
|
||||
if (self)
|
||||
[self setAutoresizingMask:CPViewWidthSizable];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)aRect
|
||||
{
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
bounds = [self bounds];
|
||||
|
||||
CGContextBeginPath(context);
|
||||
|
||||
CGContextMoveToPoint(context, CGRectGetMinX(bounds), FLOOR(CGRectGetMidY(bounds)) - 0.5);
|
||||
CGContextAddLineToPoint(context, CGRectGetMaxX(bounds), FLOOR(CGRectGetMidY(bounds)) - 0.5);
|
||||
|
||||
CGContextSetStrokeColor(context, [CPColor lightGrayColor]);
|
||||
CGContextStrokePath(context);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,300 @@
|
||||
var LEFT_MARGIN = 3.0,
|
||||
RIGHT_MARGIN = 14.0 + 3.0,
|
||||
STATE_COLUMN_WIDTH = 14.0,
|
||||
INDENTATION_WIDTH = 17.0,
|
||||
VERTICAL_MARGIN = 4.0,
|
||||
|
||||
RIGHT_COLUMNS_MARGIN = 30.0,
|
||||
KEY_EQUIVALENT_MARGIN = 10.0;
|
||||
|
||||
var SUBMENU_INDICATOR_COLOR = nil,
|
||||
_CPMenuItemSelectionColor = nil,
|
||||
_CPMenuItemTextShadowColor = nil,
|
||||
|
||||
_CPMenuItemDefaultStateImages = [],
|
||||
_CPMenuItemDefaultStateHighlightedImages = [];
|
||||
|
||||
@implementation _CPMenuItemStandardView : CPView
|
||||
{
|
||||
CPMenuItem _menuItem @accessors(property=menuItem);
|
||||
|
||||
CPFont _font;
|
||||
CPColor _textColor;
|
||||
CPColor _textShadowColor;
|
||||
|
||||
CGSize _minSize @accessors(readonly, property=minSize);
|
||||
BOOL _isDirty;
|
||||
|
||||
CPImageView _stateView;
|
||||
_CPImageAndTextView _imageAndTextView;
|
||||
_CPImageAndTextView _keyEquivalentView;
|
||||
CPView _submenuIndicatorView;
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self !== [_CPMenuItemStandardView class])
|
||||
return;
|
||||
|
||||
SUBMENU_INDICATOR_COLOR = [CPColor grayColor];
|
||||
|
||||
_CPMenuItemSelectionColor = [CPColor colorWithCalibratedRed:95.0 / 255.0 green:131.0 / 255.0 blue:185.0 / 255.0 alpha:1.0];
|
||||
_CPMenuItemTextShadowColor = [CPColor colorWithCalibratedRed:26.0 / 255.0 green: 73.0 / 255.0 blue:109.0 / 255.0 alpha:1.0]
|
||||
|
||||
var bundle = [CPBundle bundleForClass:self];
|
||||
|
||||
_CPMenuItemDefaultStateImages[CPOffState] = nil;
|
||||
_CPMenuItemDefaultStateHighlightedImages[CPOffState] = nil;
|
||||
|
||||
_CPMenuItemDefaultStateImages[CPOnState] = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPMenuItem/CPMenuItemOnState.png"] size:CGSizeMake(14.0, 14.0)];
|
||||
_CPMenuItemDefaultStateHighlightedImages[CPOnState] = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPMenuItem/CPMenuItemOnStateHighlighted.png"] size:CGSizeMake(14.0, 14.0)];
|
||||
|
||||
_CPMenuItemDefaultStateImages[CPMixedState] = nil;
|
||||
_CPMenuItemDefaultStateHighlightedImages[CPMixedState] = nil;
|
||||
}
|
||||
|
||||
+ (id)view
|
||||
{
|
||||
return [[self alloc] init];
|
||||
}
|
||||
|
||||
+ (float)_standardLeftMargin
|
||||
{
|
||||
return LEFT_MARGIN + STATE_COLUMN_WIDTH;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
self = [super initWithFrame:aFrame];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_stateView = [[CPImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 0.0)];
|
||||
|
||||
[_stateView setImageScaling:CPScaleNone];
|
||||
|
||||
[self addSubview:_stateView];
|
||||
|
||||
_imageAndTextView = [[_CPImageAndTextView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 0.0)];
|
||||
|
||||
[_imageAndTextView setImagePosition:CPImageLeft];
|
||||
[_imageAndTextView setTextShadowOffset:CGSizeMake(0.0, 1.0)];
|
||||
|
||||
[self addSubview:_imageAndTextView];
|
||||
|
||||
_keyEquivalentView = [[_CPImageAndTextView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 0.0)];
|
||||
|
||||
[_keyEquivalentView setImagePosition:CPNoImage];
|
||||
[_keyEquivalentView setTextShadowOffset:CGSizeMake(0.0, 1.0)];
|
||||
[_keyEquivalentView setAutoresizingMask:CPViewMinXMargin];
|
||||
|
||||
[self addSubview:_keyEquivalentView];
|
||||
|
||||
_submenuIndicatorView = [[_CPMenuItemSubmenuIndicatorView alloc] initWithFrame:CGRectMake(0.0, 0.0, 8.0, 10.0)];
|
||||
|
||||
[_submenuIndicatorView setColor:SUBMENU_INDICATOR_COLOR];
|
||||
[_submenuIndicatorView setAutoresizingMask:CPViewMinXMargin];
|
||||
|
||||
[self addSubview:_submenuIndicatorView];
|
||||
|
||||
[self setAutoresizingMask:CPViewWidthSizable];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPColor)textColor
|
||||
{
|
||||
if (![_menuItem isEnabled])
|
||||
return [CPColor lightGrayColor];
|
||||
|
||||
return _textColor || [CPColor colorWithCalibratedRed:70.0 / 255.0 green:69.0 / 255.0 blue:69.0 / 255.0 alpha:1.0];
|
||||
}
|
||||
|
||||
- (CPColor)textShadowColor
|
||||
{
|
||||
if (![_menuItem isEnabled])
|
||||
return nil;
|
||||
|
||||
return _textShadowColor || [CPColor colorWithWhite:1.0 alpha:0.8];
|
||||
}
|
||||
|
||||
- (void)setFont:(CPFont)aFont
|
||||
{
|
||||
_font = aFont;
|
||||
}
|
||||
|
||||
- (void)update
|
||||
{
|
||||
var x = LEFT_MARGIN + [_menuItem indentationLevel] * INDENTATION_WIDTH,
|
||||
height = 0.0,
|
||||
hasStateColumn = [[_menuItem menu] showsStateColumn];
|
||||
|
||||
if (hasStateColumn)
|
||||
{
|
||||
[_stateView setHidden:NO];
|
||||
[_stateView setImage:_CPMenuItemDefaultStateImages[[_menuItem state]] || nil];
|
||||
|
||||
x += STATE_COLUMN_WIDTH;
|
||||
}
|
||||
else
|
||||
[_stateView setHidden:YES];
|
||||
|
||||
[_imageAndTextView setFont:[_menuItem font] || _font];
|
||||
[_imageAndTextView setVerticalAlignment:CPCenterVerticalTextAlignment];
|
||||
[_imageAndTextView setImage:[_menuItem image]];
|
||||
[_imageAndTextView setText:[_menuItem title]];
|
||||
[_imageAndTextView setTextColor:[self textColor]];
|
||||
[_imageAndTextView setTextShadowColor:[self textShadowColor]];
|
||||
[_imageAndTextView setTextShadowOffset:CGSizeMake(0.0, 1.0)];
|
||||
[_imageAndTextView sizeToFit];
|
||||
|
||||
var imageAndTextViewFrame = [_imageAndTextView frame];
|
||||
|
||||
imageAndTextViewFrame.origin.x = x;
|
||||
x += CGRectGetWidth(imageAndTextViewFrame);
|
||||
height = MAX(height, CGRectGetHeight(imageAndTextViewFrame));
|
||||
|
||||
var hasKeyEquivalent = !![_menuItem keyEquivalent],
|
||||
hasSubmenu = [_menuItem hasSubmenu];
|
||||
|
||||
if (hasKeyEquivalent || hasSubmenu)
|
||||
x += RIGHT_COLUMNS_MARGIN;
|
||||
|
||||
if (hasKeyEquivalent)
|
||||
{
|
||||
[_keyEquivalentView setFont:[_menuItem font] || _font];
|
||||
[_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, VERTICAL_MARGIN)];
|
||||
[_keyEquivalentView sizeToFit];
|
||||
|
||||
var keyEquivalentViewFrame = [_keyEquivalentView frame];
|
||||
|
||||
keyEquivalentViewFrame.origin.x = x;
|
||||
x += CGRectGetWidth(keyEquivalentViewFrame);
|
||||
height = MAX(height, CGRectGetHeight(keyEquivalentViewFrame));
|
||||
|
||||
if (hasSubmenu)
|
||||
x += RIGHT_COLUMNS_MARGIN;
|
||||
}
|
||||
else
|
||||
[_keyEquivalentView setHidden:YES];
|
||||
|
||||
if (hasSubmenu)
|
||||
{
|
||||
[_submenuIndicatorView setHidden:NO];
|
||||
|
||||
var submenuViewFrame = [_submenuIndicatorView frame];
|
||||
|
||||
submenuViewFrame.origin.x = x;
|
||||
|
||||
x += CGRectGetWidth(submenuViewFrame);
|
||||
height = MAX(height, CGRectGetHeight(submenuViewFrame));
|
||||
}
|
||||
else
|
||||
[_submenuIndicatorView setHidden:YES];
|
||||
|
||||
height += 2.0 * VERTICAL_MARGIN;
|
||||
|
||||
imageAndTextViewFrame.origin.y = FLOOR((height - CGRectGetHeight(imageAndTextViewFrame)) / 2.0);
|
||||
[_imageAndTextView setFrame:imageAndTextViewFrame];
|
||||
|
||||
if (hasStateColumn)
|
||||
[_stateView setFrameSize:CGSizeMake(STATE_COLUMN_WIDTH, height)];
|
||||
|
||||
if (hasKeyEquivalent)
|
||||
{
|
||||
keyEquivalentViewFrame.origin.y = FLOOR((height - CGRectGetHeight(keyEquivalentViewFrame)) / 2.0);
|
||||
[_keyEquivalentView setFrame:keyEquivalentViewFrame];
|
||||
}
|
||||
|
||||
if (hasSubmenu)
|
||||
{
|
||||
submenuViewFrame.origin.y = FLOOR((height - CGRectGetHeight(submenuViewFrame)) / 2.0);
|
||||
[_submenuIndicatorView setFrame:submenuViewFrame];
|
||||
}
|
||||
|
||||
_minSize = CGSizeMake(x + RIGHT_MARGIN, height);
|
||||
|
||||
[self setAutoresizesSubviews:NO];
|
||||
[self setFrameSize:_minSize];
|
||||
[self setAutoresizesSubviews:YES];
|
||||
}
|
||||
|
||||
- (void)highlight:(BOOL)shouldHighlight
|
||||
{
|
||||
// FIXME: This should probably be even throw.
|
||||
if (![_menuItem isEnabled])
|
||||
return;
|
||||
|
||||
if (shouldHighlight)
|
||||
{
|
||||
[self setBackgroundColor:_CPMenuItemSelectionColor];
|
||||
|
||||
[_imageAndTextView setImage:[_menuItem alternateImage] || [_menuItem image]];
|
||||
[_imageAndTextView setTextColor:[CPColor whiteColor]];
|
||||
[_keyEquivalentView setTextColor:[CPColor whiteColor]];
|
||||
[_submenuIndicatorView setColor:[CPColor whiteColor]];
|
||||
|
||||
[_imageAndTextView setTextShadowColor:_CPMenuItemTextShadowColor];
|
||||
[_keyEquivalentView setTextShadowColor:_CPMenuItemTextShadowColor];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setBackgroundColor:nil];
|
||||
|
||||
[_imageAndTextView setImage:[_menuItem image]];
|
||||
[_imageAndTextView setTextColor:[self textColor]];
|
||||
[_keyEquivalentView setTextColor:[self textColor]];
|
||||
[_submenuIndicatorView setColor:SUBMENU_INDICATOR_COLOR];
|
||||
|
||||
[_imageAndTextView setTextShadowColor:[self textShadowColor]];
|
||||
[_keyEquivalentView setTextShadowColor:[self textShadowColor]];
|
||||
}
|
||||
|
||||
if (shouldHighlight)
|
||||
[_stateView setImage:_CPMenuItemDefaultStateHighlightedImages[[_menuItem state]] || nil];
|
||||
else
|
||||
[_stateView setImage:_CPMenuItemDefaultStateImages[[_menuItem state]] || nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPMenuItemSubmenuIndicatorView : CPView
|
||||
{
|
||||
CPColor _color;
|
||||
}
|
||||
|
||||
- (void)setColor:(CPColor)aColor
|
||||
{
|
||||
if (_color === aColor)
|
||||
return;
|
||||
|
||||
_color = aColor;
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)aRect
|
||||
{
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
bounds = [self bounds];
|
||||
|
||||
CGContextBeginPath(context);
|
||||
|
||||
CGContextMoveToPoint(context, CGRectGetMinX(bounds), CGRectGetMinY(bounds));
|
||||
CGContextAddLineToPoint(context, CGRectGetMaxX(bounds), CGRectGetMidY(bounds));
|
||||
CGContextAddLineToPoint(context, CGRectGetMinX(bounds), CGRectGetMaxY(bounds));
|
||||
|
||||
CGContextClosePath(context);
|
||||
|
||||
CGContextSetFillColor(context, _color);
|
||||
CGContextFillPath(context);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,255 @@
|
||||
|
||||
@import "_CPMenuItemSeparatorView.j"
|
||||
@import "_CPMenuItemStandardView.j"
|
||||
@import "_CPMenuItemMenuBarView.j"
|
||||
|
||||
|
||||
var LEFT_MARGIN = 3.0,
|
||||
RIGHT_MARGIN = 16.0,
|
||||
STATE_COLUMN_WIDTH = 14.0,
|
||||
INDENTATION_WIDTH = 17.0,
|
||||
VERTICAL_MARGIN = 4.0;
|
||||
|
||||
var _CPMenuItemSelectionColor = nil,
|
||||
_CPMenuItemTextShadowColor = nil,
|
||||
|
||||
_CPMenuItemDefaultStateImages = [],
|
||||
_CPMenuItemDefaultStateHighlightedImages = [];
|
||||
|
||||
/*
|
||||
@ignore
|
||||
*/
|
||||
@implementation _CPMenuItemView : CPView
|
||||
{
|
||||
CPMenuItem _menuItem;
|
||||
CPView _view;
|
||||
|
||||
CPFont _font;
|
||||
CPColor _textColor;
|
||||
CPColor _textShadowColor;
|
||||
|
||||
CGSize _minSize;
|
||||
BOOL _isDirty;
|
||||
BOOL _showsStateColumn;
|
||||
|
||||
CPImageView _stateView;
|
||||
_CPImageAndTextView _imageAndTextView;
|
||||
CPView _submenuView;
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self != [_CPMenuItemView class])
|
||||
return;
|
||||
|
||||
_CPMenuItemSelectionColor = [CPColor colorWithCalibratedRed:95.0 / 255.0 green:131.0 / 255.0 blue:185.0 / 255.0 alpha:1.0];
|
||||
_CPMenuItemTextShadowColor = [CPColor colorWithCalibratedRed:26.0 / 255.0 green: 73.0 / 255.0 blue:109.0 / 255.0 alpha:1.0]
|
||||
|
||||
var bundle = [CPBundle bundleForClass:self];
|
||||
|
||||
_CPMenuItemDefaultStateImages[CPOffState] = nil;
|
||||
_CPMenuItemDefaultStateHighlightedImages[CPOffState] = nil;
|
||||
|
||||
_CPMenuItemDefaultStateImages[CPOnState] = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPMenuItem/CPMenuItemOnState.png"] size:CGSizeMake(14.0, 14.0)];
|
||||
_CPMenuItemDefaultStateHighlightedImages[CPOnState] = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPMenuItem/CPMenuItemOnStateHighlighted.png"] size:CGSizeMake(14.0, 14.0)];
|
||||
|
||||
_CPMenuItemDefaultStateImages[CPMixedState] = nil;
|
||||
_CPMenuItemDefaultStateHighlightedImages[CPMixedState] = nil;
|
||||
}
|
||||
|
||||
+ (float)leftMargin
|
||||
{
|
||||
return LEFT_MARGIN + STATE_COLUMN_WIDTH;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame forMenuItem:(CPMenuItem)aMenuItem
|
||||
{
|
||||
self = [super initWithFrame:aFrame];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_menuItem = aMenuItem;
|
||||
_showsStateColumn = YES;
|
||||
_isDirty = YES;
|
||||
|
||||
[self setAutoresizingMask:CPViewWidthSizable];
|
||||
|
||||
[self synchronizeWithMenuItem];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CGSize)minSize
|
||||
{
|
||||
return _minSize;
|
||||
}
|
||||
|
||||
- (void)setDirty
|
||||
{
|
||||
_isDirty = YES;
|
||||
}
|
||||
|
||||
- (void)synchronizeWithMenuItem
|
||||
{
|
||||
var menuItemView = [_menuItem view];
|
||||
|
||||
if ([_menuItem isSeparatorItem])
|
||||
{
|
||||
if (![_view isKindOfClass:[_CPMenuItemSeparatorView class]])
|
||||
{
|
||||
[_view removeFromSuperview];
|
||||
_view = [_CPMenuItemSeparatorView view];
|
||||
}
|
||||
}
|
||||
else if (menuItemView)
|
||||
{
|
||||
if (_view !== menuItemView)
|
||||
{
|
||||
[_view removeFromSuperview];
|
||||
_view = menuItemView;
|
||||
}
|
||||
}
|
||||
|
||||
else if ([_menuItem menu] == [CPApp mainMenu])
|
||||
{
|
||||
if (![_view isKindOfClass:[_CPMenuItemMenuBarView class]])
|
||||
{
|
||||
[_view removeFromSuperview];
|
||||
_view = [_CPMenuItemMenuBarView view];
|
||||
}
|
||||
|
||||
[_view setMenuItem:_menuItem];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (![_view isKindOfClass:[_CPMenuItemStandardView class]])
|
||||
{
|
||||
[_view removeFromSuperview];
|
||||
_view = [_CPMenuItemStandardView view];
|
||||
}
|
||||
|
||||
[_view setMenuItem:_menuItem];
|
||||
}
|
||||
|
||||
if ([_view superview] !== self)
|
||||
[self addSubview:_view];
|
||||
|
||||
if ([_view respondsToSelector:@selector(update)])
|
||||
[_view update];
|
||||
|
||||
_minSize = [_view frame].size;
|
||||
[self setAutoresizesSubviews:NO];
|
||||
[self setFrameSize:_minSize];
|
||||
[self setAutoresizesSubviews:YES];
|
||||
}
|
||||
|
||||
- (void)setShowsStateColumn:(BOOL)shouldShowStateColumn
|
||||
{
|
||||
_showsStateColumn = shouldShowStateColumn;
|
||||
}
|
||||
|
||||
- (void)highlight:(BOOL)shouldHighlight
|
||||
{
|
||||
if ([_view respondsToSelector:@selector(highlight:)])
|
||||
[_view highlight:shouldHighlight];
|
||||
}
|
||||
|
||||
- (BOOL)eventOnSubmenu:(CPEvent)anEvent
|
||||
{
|
||||
if (![_menuItem hasSubmenu])
|
||||
return NO;
|
||||
|
||||
return CGRectContainsPoint([_submenuView frame], [self convertPoint:[anEvent locationInWindow] fromView:nil]);
|
||||
}
|
||||
|
||||
- (BOOL)isHidden
|
||||
{
|
||||
return [_menuItem isHidden];
|
||||
}
|
||||
|
||||
- (CPMenuItem)menuItem
|
||||
{
|
||||
return _menuItem;
|
||||
}
|
||||
|
||||
- (void)setFont:(CPFont)aFont
|
||||
{
|
||||
if (_font === aFont)
|
||||
return;
|
||||
|
||||
_font = aFont;
|
||||
|
||||
if ([_view respondsToSelector:@selector(setFont:)])
|
||||
[_view setFont:aFont];
|
||||
|
||||
[self setDirty];
|
||||
}
|
||||
|
||||
- (void)setTextColor:(CPColor)aColor
|
||||
{
|
||||
if (_textColor == aColor)
|
||||
return;
|
||||
|
||||
_textColor = aColor;
|
||||
|
||||
[_imageAndTextView setTextColor:[self textColor]];
|
||||
[_submenuView setColor:[self textColor]];
|
||||
}
|
||||
|
||||
- (CPColor)textColor
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)setTextShadowColor:(CPColor)aColor
|
||||
{
|
||||
if (_textShadowColor == aColor)
|
||||
return;
|
||||
|
||||
_textShadowColor = aColor;
|
||||
|
||||
[_imageAndTextView setTextShadowColor:[self textShadowColor]];
|
||||
//[_submenuView setColor:[self textColor]];
|
||||
}
|
||||
|
||||
- (CPColor)textShadowColor
|
||||
{
|
||||
return [_menuItem isEnabled] ? (_textShadowColor ? _textShadowColor : [CPColor colorWithWhite:1.0 alpha:0.8]) : [CPColor colorWithWhite:0.8 alpha:0.8];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPMenuItemArrowView : CPView
|
||||
{
|
||||
CPColor _color;
|
||||
}
|
||||
|
||||
- (void)setColor:(CPColor)aColor
|
||||
{
|
||||
if (_color == aColor)
|
||||
return;
|
||||
|
||||
_color = aColor;
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)aRect
|
||||
{
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort];
|
||||
|
||||
CGContextBeginPath(context);
|
||||
|
||||
CGContextMoveToPoint(context, 1.0, 4.0);
|
||||
CGContextAddLineToPoint(context, 9.0, 4.0);
|
||||
CGContextAddLineToPoint(context, 5.0, 8.0);
|
||||
CGContextAddLineToPoint(context, 1.0, 4.0);
|
||||
|
||||
CGContextClosePath(context);
|
||||
|
||||
CGContextSetFillColor(context, _color);
|
||||
CGContextFillPath(context);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -50,6 +50,15 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
|
||||
|
||||
CPOutlineViewDataSource_outlineView_sortDescriptorsDidChange_ = 1 << 10;
|
||||
|
||||
|
||||
var CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_ = 1 << 1,
|
||||
CPOutlineViewDelegate_outlineView_shouldSelectItem_ = 1 << 2,
|
||||
CPOutlineViewDelegate_outlineView_heightOfRowByItem_ = 1 << 3,
|
||||
CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_ = 1 << 4,
|
||||
CPOutlineViewDelegate_outlineView_isGroupItem_ = 1 << 5;
|
||||
|
||||
CPOutlineViewDropOnItemIndex = -1;
|
||||
|
||||
@implementation CPOutlineView : CPTableView
|
||||
{
|
||||
id _outlineViewDataSource;
|
||||
@@ -60,6 +69,7 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
|
||||
BOOL _indentationMarkerFollowsDataView;
|
||||
|
||||
CPInteger _implementedOutlineViewDataSourceMethods;
|
||||
CPInteger _implementedOutlineViewDelegateMethods;
|
||||
|
||||
Object _rootItemInfo;
|
||||
CPMutableArray _itemsForRows;
|
||||
@@ -69,6 +79,12 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
|
||||
CPArray _disclosureControlsForRows;
|
||||
CPData _disclosureControlData;
|
||||
CPArray _disclosureControlQueue;
|
||||
|
||||
BOOL _shouldRetargetItem;
|
||||
id _retargetedItem;
|
||||
|
||||
BOOL _shouldRetargetChildIndex;
|
||||
CPInteger _retargedChildIndex;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
@@ -77,6 +93,9 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
|
||||
|
||||
if (self)
|
||||
{
|
||||
|
||||
_selectionHighlightStyle = CPTableViewSelectionHighlightStyleSourceList;
|
||||
|
||||
// The root item has weight "0", thus represents the weight solely of its descendants.
|
||||
_rootItemInfo = { isExpanded:YES, isExpandable:NO, level:-1, row:-1, children:[], weight:0 };
|
||||
|
||||
@@ -84,10 +103,17 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
|
||||
_itemInfosForItems = { };
|
||||
_disclosureControlsForRows = [];
|
||||
|
||||
_retargetedItem = nil;
|
||||
_shouldRetargetItem = NO;
|
||||
|
||||
_retargedChildIndex = nil;
|
||||
_shouldRetargetChildIndex = NO;
|
||||
|
||||
[self setIndentationPerLevel:16.0];
|
||||
[self setIndentationMarkerFollowsDataView:YES];
|
||||
|
||||
[super setDataSource:[[_CPOutlineViewTableViewDataSource alloc] initWithOutlineView:self]];
|
||||
[super setDelegate:[[_CPOutlineViewTableViewDelegate alloc] initWithOutlineView:self]];
|
||||
|
||||
[self setDisclosureControlPrototype:[[CPDisclosureButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 10.0, 10.0)]];
|
||||
}
|
||||
@@ -181,20 +207,32 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
|
||||
|
||||
- (void)expandItem:(id)anItem
|
||||
{
|
||||
if (!anItem)
|
||||
return;
|
||||
[self expandItem:anItem expandChildren:NO];
|
||||
}
|
||||
|
||||
var itemInfo = _itemInfosForItems[[anItem UID]];
|
||||
- (void)expandItem:(id)anItem expandChildren:(BOOL)shouldExpandChildren
|
||||
{
|
||||
var itemInfo = null;
|
||||
|
||||
if (!anItem)
|
||||
itemInfo = _rootItemInfo;
|
||||
else
|
||||
itemInfo = _itemInfosForItems[[anItem UID]];
|
||||
|
||||
if (!itemInfo)
|
||||
return;
|
||||
|
||||
if (itemInfo.isExpanded)
|
||||
return;
|
||||
|
||||
|
||||
itemInfo.isExpanded = YES;
|
||||
|
||||
[self reloadItem:anItem reloadChildren:YES];
|
||||
|
||||
if (shouldExpandChildren)
|
||||
{
|
||||
var children = itemInfo.children,
|
||||
childIndex = children.length;
|
||||
|
||||
while (childIndex--)
|
||||
[self expandItem:children[childIndex] expandChildren:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)collapseItem:(id)anItem
|
||||
@@ -235,7 +273,7 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
|
||||
return _itemsForRows[aRow] || nil;
|
||||
}
|
||||
|
||||
- (CPInteger)rowForItem:(id)aItem
|
||||
- (CPInteger)rowForItem:(id)anItem
|
||||
{
|
||||
if (!anItem)
|
||||
return _rootItemInfo.row;
|
||||
@@ -324,7 +362,13 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
|
||||
if (!itemInfo)
|
||||
return nil;
|
||||
|
||||
return itemInfo.parent;
|
||||
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)
|
||||
parent = nil;
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
- (CGRect)frameOfOutlineDataViewAtColumn:(CPInteger)aColumn row:(CPInteger)aRow
|
||||
@@ -338,6 +382,45 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
|
||||
return frame;
|
||||
}
|
||||
|
||||
- (void)selectRowIndexes:(CPIndexSet)rows byExtendingSelection:(BOOL)shouldExtendSelection
|
||||
{
|
||||
// First un highlight the old disclosure controls
|
||||
var previousSelectedRows = [];
|
||||
[[self selectedRowIndexes] getIndexes:previousSelectedRows maxCount:-1 inIndexRange:nil];
|
||||
|
||||
var index = [previousSelectedRows count];
|
||||
while (index--)
|
||||
{
|
||||
var rowIndex = previousSelectedRows[index],
|
||||
item = [self itemAtRow:rowIndex];
|
||||
|
||||
if (![self isExpandable:item])
|
||||
continue;
|
||||
|
||||
var control = _disclosureControlsForRows[rowIndex];
|
||||
[control setHighlighted:NO];
|
||||
}
|
||||
|
||||
[super selectRowIndexes:rows byExtendingSelection:shouldExtendSelection];
|
||||
|
||||
// Now highlight the new disclosure controls
|
||||
var selectedRows = [];
|
||||
[rows getIndexes:selectedRows maxCount:-1 inIndexRange:nil];
|
||||
|
||||
var index = [selectedRows count];
|
||||
while (index--)
|
||||
{
|
||||
var rowIndex = selectedRows[index],
|
||||
item = [self itemAtRow:rowIndex];
|
||||
|
||||
if (![self isExpandable:item])
|
||||
continue;
|
||||
|
||||
var control = _disclosureControlsForRows[rowIndex];
|
||||
[control setHighlighted:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
{
|
||||
if (_outlineViewDelegate === aDelegate)
|
||||
@@ -372,63 +455,24 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
|
||||
object:self];
|
||||
}
|
||||
|
||||
_outlineViewDelegate = aDelegate;/*
|
||||
_implementedDelegateMethods = 0;
|
||||
_outlineViewDelegate = aDelegate;
|
||||
_implementedOutlineViewDelegateMethods = 0;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(selectionShouldChangeInTableView:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_selectionShouldChangeInTableView_;
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:dataViewForTableColumn:item:)])
|
||||
_implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:shouldSelectItem:)])
|
||||
_implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_shouldSelectItem_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:heightOfRowByItem:)])
|
||||
_implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_heightOfRowByItem_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:dataViewForTableColumn:row:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_dataViewForTableColumn_row_;
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:willDisplayView:forTableColumn:item:)])
|
||||
_implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:didClickTableColumn:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_didClickTableColumn_;
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:isGroupItem:)])
|
||||
_implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_isGroupItem_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:didDragTableColumn:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_didDragTableColumn_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:heightOfRow:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_heightOfRow_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:isGroupRow:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_isGroupRow_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:mouseDownInHeaderOfTableColumn:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_mouseDownInHeaderOfTableColumn_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:nextTypeSelectMatchFromRow:toRow:forString:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_nextTypeSelectMatchFromRow_toRow_forString_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:selectionIndexesForProposedSelection:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_selectionIndexesForProposedSelection_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:shouldEditTableColumn:row:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_shouldEditTableColumn_row_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:shouldSelectRow:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_shouldSelectRow_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:shouldSelectTableColumn:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_shouldSelectTableColumn_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:shouldShowViewExpansionForTableColumn:row:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_shouldShowViewExpansionForTableColumn_row_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:shouldTrackView:forTableColumn:row:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_shouldTrackView_forTableColumn_row_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:shouldTypeSelectForEvent:withCurrentSearchString:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_shouldTypeSelectForEvent_withCurrentSearchString_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:toolTipForView:rect:tableColumn:row:mouseLocation:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_toolTipForView_rect_tableColumn_row_mouseLocation_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:typeSelectStringForTableColumn:row:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_typeSelectStringForTableColumn_row_;
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(tableView:willDisplayView:forTableColumn:row:)])
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_willDisplayView_forTableColumn_row_;
|
||||
*/
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineViewColumnDidMove:)])
|
||||
[defaultCenter
|
||||
addObserver:_outlineViewDelegate
|
||||
@@ -488,6 +532,55 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
|
||||
return [super frameOfDataViewAtColumn:aColumn row:aRow];
|
||||
}
|
||||
|
||||
- (void)setDropItem:(id)theItem dropChildIndex:(int)theIndex
|
||||
{
|
||||
_retargetedItem = theItem;
|
||||
_shouldRetargetItem = YES;
|
||||
|
||||
_retargedChildIndex = theIndex;
|
||||
_shouldRetargetChildIndex = YES;
|
||||
}
|
||||
|
||||
- (id)_parentItemForUpperRow:(int)theUpperRowIndex andLowerRow:(int)theLowerRowIndex atMouseOffset:(CPPoint)theOffset
|
||||
{
|
||||
if (_shouldRetargetItem)
|
||||
return _retargetedItem;
|
||||
|
||||
var lowerLevel = [self levelForRow:theLowerRowIndex]
|
||||
upperItem = [self itemAtRow:theUpperRowIndex];
|
||||
upperLevel = [self levelForItem:upperItem];
|
||||
|
||||
// If the row above us has a higher level the item can be added to multiple parent items
|
||||
// Determine which one by looping through all possible parents and return the first
|
||||
// of which the indentation level is larger than the current x offset
|
||||
while (upperLevel > lowerLevel)
|
||||
{
|
||||
upperLevel = [self levelForItem:upperItem];
|
||||
|
||||
// See if this item's indentation level matches the mouse offset
|
||||
if (theOffset.x > (upperLevel + 1) * [self indentationPerLevel])
|
||||
return [self parentForItem:upperItem];
|
||||
|
||||
// Check the next parent
|
||||
upperItem = [self parentForItem:upperItem];
|
||||
}
|
||||
|
||||
return [self parentForItem:[self itemAtRow:theLowerRowIndex]];
|
||||
}
|
||||
|
||||
- (CPRect)_rectForDropHighlightViewBetweenUpperRow:(int)theUpperRowIndex andLowerRow:(int)theLowerRowIndex offset:(CPPoint)theOffset
|
||||
{
|
||||
// Call super and the update x to reflect the current indentation level
|
||||
var rect = [super _rectForDropHighlightViewBetweenUpperRow:theUpperRowIndex andLowerRow:theLowerRowIndex offset:theOffset],
|
||||
parentItem = [self _parentItemForUpperRow:theUpperRowIndex andLowerRow:theLowerRowIndex atMouseOffset:theOffset],
|
||||
level = [self levelForItem:parentItem];
|
||||
|
||||
rect.origin.x = (level + 1) * [self indentationPerLevel];
|
||||
rect.size.width -= rect.origin.x; // This assumes that the x returned by super is zero
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (void)_loadDataViewsInRows:(CPIndexSet)rows columns:(CPIndexSet)columns
|
||||
{
|
||||
[super _loadDataViewsInRows:rows columns:columns];
|
||||
@@ -618,140 +711,147 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_
|
||||
|
||||
@end
|
||||
|
||||
// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever...
|
||||
var _reloadItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem)
|
||||
{
|
||||
if (!anItem)
|
||||
return;
|
||||
|
||||
// Get the existing info if it exists.
|
||||
var itemInfosForItems = anOutlineView._itemInfosForItems,
|
||||
dataSource = anOutlineView._outlineViewDataSource,
|
||||
itemUID = [anItem UID],
|
||||
itemInfo = itemInfosForItems[itemUID];
|
||||
|
||||
// If we're not in the tree, then just bail.
|
||||
if (!itemInfo)
|
||||
return [];
|
||||
|
||||
// See if the item itself can be swapped out.
|
||||
var parent = itemInfo.parent,
|
||||
parentItemInfo = parent ? itemInfosForItems[[parent UID]] : anOutlineView._rootItemInfo,
|
||||
parentChildren = parentItemInfo.children,
|
||||
index = [parentChildren indexOfObjectIdenticalTo:anItem],
|
||||
newItem = [dataSource outlineView:anOutlineView child:index ofItem:parent];
|
||||
|
||||
if (anItem !== newItem)
|
||||
{
|
||||
itemInfosForItems[[anItem UID]] = nil;
|
||||
itemInfosForItems[[newItem UID]] = itemInfo;
|
||||
|
||||
parentChildren[index] = newItem;
|
||||
anOutlineView._itemsForRows[itemInfo.row] = newItem;
|
||||
}
|
||||
|
||||
itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:newItem];
|
||||
itemInfo.isExpanded = itemInfo.isExpandable && itemInfo.isExpanded;
|
||||
}
|
||||
|
||||
var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem, /*BOOL*/ isIntermediate)
|
||||
{
|
||||
var itemInfosForItems = anOutlineView._itemInfosForItems,
|
||||
dataSource = anOutlineView._outlineViewDataSource;
|
||||
|
||||
if (!anItem)
|
||||
var itemInfo = anOutlineView._rootItemInfo;
|
||||
|
||||
else
|
||||
with(anOutlineView)
|
||||
{
|
||||
// Get the existing info if it exists.
|
||||
var itemUID = [anItem UID],
|
||||
var itemInfosForItems = _itemInfosForItems,
|
||||
dataSource = _outlineViewDataSource,
|
||||
itemUID = [anItem UID],
|
||||
itemInfo = itemInfosForItems[itemUID];
|
||||
|
||||
|
||||
// If we're not in the tree, then just bail.
|
||||
if (!itemInfo)
|
||||
return [];
|
||||
|
||||
itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:anItem];
|
||||
|
||||
// If we were previously expanded, but now no longer expandable, "de-expand".
|
||||
// NOTE: we are *not* collapsing, thus no notification is posted.
|
||||
if (!itemInfo.isExpandable && itemInfo.isExpanded)
|
||||
|
||||
// See if the item itself can be swapped out.
|
||||
var parent = itemInfo.parent,
|
||||
parentItemInfo = parent ? itemInfosForItems[[parent UID]] : _rootItemInfo,
|
||||
parentChildren = parentItemInfo.children,
|
||||
index = [parentChildren indexOfObjectIdenticalTo:anItem],
|
||||
newItem = [dataSource outlineView:anOutlineView child:index ofItem:parent];
|
||||
|
||||
if (anItem !== newItem)
|
||||
{
|
||||
itemInfo.isExpanded = NO;
|
||||
itemInfosForItems[[anItem UID]] = nil;
|
||||
itemInfosForItems[[newItem UID]] = itemInfo;
|
||||
|
||||
parentChildren[index] = newItem;
|
||||
_itemsForRows[itemInfo.row] = newItem;
|
||||
}
|
||||
|
||||
itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:newItem];
|
||||
itemInfo.isExpanded = itemInfo.isExpandable && itemInfo.isExpanded;
|
||||
}
|
||||
}
|
||||
|
||||
// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever...
|
||||
var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem, /*BOOL*/ isIntermediate)
|
||||
{
|
||||
with(anOutlineView)
|
||||
{
|
||||
var itemInfosForItems = _itemInfosForItems,
|
||||
dataSource = _outlineViewDataSource;
|
||||
|
||||
if (!anItem)
|
||||
var itemInfo = _rootItemInfo;
|
||||
|
||||
else
|
||||
{
|
||||
// Get the existing info if it exists.
|
||||
var itemUID = [anItem UID],
|
||||
itemInfo = itemInfosForItems[itemUID];
|
||||
|
||||
// If we're not in the tree, then just bail.
|
||||
if (!itemInfo)
|
||||
return [];
|
||||
|
||||
itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:anItem];
|
||||
|
||||
// If we were previously expanded, but now no longer expandable, "de-expand".
|
||||
// NOTE: we are *not* collapsing, thus no notification is posted.
|
||||
if (!itemInfo.isExpandable && itemInfo.isExpanded)
|
||||
{
|
||||
itemInfo.isExpanded = NO;
|
||||
itemInfo.children = [];
|
||||
}
|
||||
}
|
||||
|
||||
// The root item does not count as a descendant.
|
||||
var weight = itemInfo.weight,
|
||||
descendants = anItem ? [anItem] : [];
|
||||
|
||||
if (itemInfo.isExpanded && (!(_implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_shouldDeferDisplayingChildrenOfItem_) ||
|
||||
![dataSource outlineView:anOutlineView shouldDeferDisplayingChildrenOfItem:anItem]))
|
||||
{
|
||||
var index = 0,
|
||||
count = [dataSource outlineView:anOutlineView numberOfChildrenOfItem:anItem],
|
||||
level = itemInfo.level + 1;
|
||||
|
||||
itemInfo.children = [];
|
||||
}
|
||||
}
|
||||
|
||||
// The root item does not count as a descendant.
|
||||
var weight = itemInfo.weight,
|
||||
descendants = anItem ? [anItem] : [];
|
||||
|
||||
if (itemInfo.isExpanded && (!(anOutlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_shouldDeferDisplayingChildrenOfItem_) ||
|
||||
![dataSource outlineView:anOutlineView shouldDeferDisplayingChildrenOfItem:anItem]))
|
||||
{
|
||||
var index = 0,
|
||||
count = [dataSource outlineView:anOutlineView numberOfChildrenOfItem:anItem],
|
||||
level = itemInfo.level + 1;
|
||||
|
||||
itemInfo.children = [];
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var childItem = [dataSource outlineView:anOutlineView child:index ofItem:anItem],
|
||||
childItemInfo = itemInfosForItems[[childItem UID]];
|
||||
|
||||
if (!childItemInfo)
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
childItemInfo = { isExpanded:NO, isExpandable:NO, children:[], weight:1 };
|
||||
itemInfosForItems[[childItem UID]] = childItemInfo;
|
||||
var childItem = [dataSource outlineView:anOutlineView child:index ofItem:anItem],
|
||||
childItemInfo = itemInfosForItems[[childItem UID]];
|
||||
|
||||
if (!childItemInfo)
|
||||
{
|
||||
childItemInfo = { isExpanded:NO, isExpandable:NO, children:[], weight:1 };
|
||||
itemInfosForItems[[childItem UID]] = childItemInfo;
|
||||
}
|
||||
|
||||
itemInfo.children[index] = childItem;
|
||||
|
||||
var childDescendants = _loadItemInfoForItem(anOutlineView, childItem, YES);
|
||||
|
||||
childItemInfo.parent = anItem;
|
||||
childItemInfo.level = level;
|
||||
descendants = descendants.concat(childDescendants);
|
||||
}
|
||||
|
||||
itemInfo.children[index] = childItem;
|
||||
|
||||
var childDescendants = _loadItemInfoForItem(anOutlineView, childItem, YES);
|
||||
|
||||
childItemInfo.parent = anItem;
|
||||
childItemInfo.level = level;
|
||||
descendants = descendants.concat(childDescendants);
|
||||
}
|
||||
}
|
||||
|
||||
itemInfo.weight = descendants.length;
|
||||
|
||||
if (!isIntermediate)
|
||||
{
|
||||
// row = -1 is the root item, so just go to row 0 since it is ignored.
|
||||
var index = MAX(itemInfo.row, 0),
|
||||
itemsForRows = anOutlineView._itemsForRows;
|
||||
|
||||
descendants.unshift(index, weight);
|
||||
|
||||
itemsForRows.splice.apply(itemsForRows, descendants);
|
||||
|
||||
var count = itemsForRows.length;
|
||||
|
||||
for (; index < count; ++index)
|
||||
itemInfosForItems[[itemsForRows[index] UID]].row = index;
|
||||
|
||||
var deltaWeight = itemInfo.weight - weight;
|
||||
|
||||
if (deltaWeight !== 0)
|
||||
|
||||
itemInfo.weight = descendants.length;
|
||||
|
||||
if (!isIntermediate)
|
||||
{
|
||||
var parent = itemInfo.parent;
|
||||
|
||||
while (parent)
|
||||
// row = -1 is the root item, so just go to row 0 since it is ignored.
|
||||
var index = MAX(itemInfo.row, 0),
|
||||
itemsForRows = _itemsForRows;
|
||||
|
||||
descendants.unshift(index, weight);
|
||||
|
||||
itemsForRows.splice.apply(itemsForRows, descendants);
|
||||
|
||||
var count = itemsForRows.length;
|
||||
|
||||
for (; index < count; ++index)
|
||||
itemInfosForItems[[itemsForRows[index] UID]].row = index;
|
||||
|
||||
var deltaWeight = itemInfo.weight - weight;
|
||||
|
||||
if (deltaWeight !== 0)
|
||||
{
|
||||
var parentItemInfo = itemInfosForItems[[parent UID]];
|
||||
|
||||
parentItemInfo.weight += deltaWeight;
|
||||
parent = parentItemInfo.parent;
|
||||
var parent = itemInfo.parent;
|
||||
|
||||
while (parent)
|
||||
{
|
||||
var parentItemInfo = itemInfosForItems[[parent UID]];
|
||||
|
||||
parentItemInfo.weight += deltaWeight;
|
||||
parent = parentItemInfo.parent;
|
||||
}
|
||||
|
||||
if (anItem)
|
||||
_rootItemInfo.weight += deltaWeight;
|
||||
}
|
||||
|
||||
if (anItem)
|
||||
anOutlineView._rootItemInfo.weight += deltaWeight;
|
||||
}
|
||||
}
|
||||
|
||||
}//end of with
|
||||
return descendants;
|
||||
}
|
||||
|
||||
@@ -780,6 +880,93 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return [_outlineView._outlineViewDataSource outlineView:_outlineView objectValueForTableColumn:aTableColumn byItem:_outlineView._itemsForRows[aRow]];
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableColumn writeRowsWithIndexes:(CPIndexSet)theIndexes toPasteboard:(CPPasteboard)thePasteboard
|
||||
{
|
||||
if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_writeItems_toPasteboard_))
|
||||
return NO;
|
||||
|
||||
var rowIndexes = [];
|
||||
[theIndexes getIndexes:rowIndexes maxCount:[theIndexes count] inIndexRange:nil];
|
||||
|
||||
var rowIndex = [rowIndexes count],
|
||||
items = [];
|
||||
|
||||
while (rowIndex--)
|
||||
[items addObject:[_outlineView itemAtRow:[rowIndexes objectAtIndex:rowIndex]]];
|
||||
|
||||
return [_outlineView._outlineViewDataSource outlineView:_outlineView writeItems:items toPasteboard:thePasteboard];
|
||||
}
|
||||
|
||||
- (int)_childIndexForDropOperation:(CPTableViewDropOperation)theDropOperation row:(int)theRow offset:(CPPoint)theOffset
|
||||
{
|
||||
if (_outlineView._shouldRetargetChildIndex)
|
||||
return _outlineView._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,
|
||||
children = itemInfo.children;
|
||||
|
||||
childIndex = [children indexOfObject:[_outlineView itemAtRow:theRow]];
|
||||
|
||||
if (childIndex === CPNotFound)
|
||||
childIndex = children.length;
|
||||
}
|
||||
else if (theDropOperation === CPTableViewDropOn)
|
||||
childIndex = -1;
|
||||
|
||||
return childIndex;
|
||||
}
|
||||
|
||||
- (void)_parentItemForDropOperation:(CPTableViewDropOperation)theDropOperation row:(int)theRow offset:(CPPoint)theOffset
|
||||
{
|
||||
if (theDropOperation === CPTableViewDropAbove)
|
||||
return [_outlineView _parentItemForUpperRow:theRow - 1 andLowerRow:theRow atMouseOffset:theOffset]
|
||||
|
||||
return [_outlineView itemAtRow:theRow];
|
||||
}
|
||||
|
||||
- (CPDragOperation)tableView:(CPTableView)aTableView validateDrop:(id < CPDraggingInfo >)theInfo
|
||||
proposedRow:(int)theRow proposedDropOperation:(CPTableViewDropOperation)theOperation
|
||||
{
|
||||
if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_validateDrop_proposedItem_proposedChildIndex_))
|
||||
return CPDragOperationNone;
|
||||
|
||||
// Make sure the retargeted item and index are reset
|
||||
_outlineView._retargetedItem = nil;
|
||||
_outlineView._shouldRetargetItem = NO;
|
||||
|
||||
_outlineView._retargedChildIndex = nil;
|
||||
_outlineView._shouldRetargetChildIndex = NO;
|
||||
|
||||
var location = [_outlineView 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];
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView acceptDrop:(id <CPDraggingInfo>)theInfo row:(int)theRow dropOperation:(CPTableViewDropOperation)theOperation
|
||||
{
|
||||
if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_acceptDrop_item_childIndex_))
|
||||
return NO;
|
||||
|
||||
var location = [_outlineView 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;
|
||||
|
||||
_outlineView._retargedChildIndex = nil;
|
||||
_outlineView._shouldRetargetChildIndex = NO;
|
||||
|
||||
return [_outlineView._outlineViewDataSource outlineView:_outlineView acceptDrop:theInfo item:parentItem childIndex:childIndex];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPOutlineViewTableViewDelegate : CPObject
|
||||
@@ -797,6 +984,54 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPView)tableView:(CPTableView)theTableView dataViewForTableColumn:(CPTableColumn)theTableColumn row:(int)theRow
|
||||
{
|
||||
var dataView = nil;
|
||||
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_))
|
||||
dataView = [_outlineView._outlineViewDelegate outlineView:_outlineView
|
||||
dataViewForTableColumn:theTableColumn
|
||||
item:[_outlineView itemAtRow:theRow]];
|
||||
|
||||
if (!dataView)
|
||||
dataView = [theTableColumn dataViewForRow:theRow];
|
||||
|
||||
return dataView;
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)theTableView shouldSelectRow:(int)theRow
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldSelectItem_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView shouldSelectItem:[_outlineView itemAtRow:theRow]];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (float)tableView:(CPTableView)theTableView heightOfRow:(int)theRow
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_heightOfRowByItem_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView heightOfRowByItem:[_outlineView itemAtRow:theRow]];
|
||||
|
||||
return [theTableView rowHeight];
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView willDisplayView:(id)aView forTableColumn:(CPTableColumn)aTableColumn row:(int)aRowIndex
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_))
|
||||
{
|
||||
var item = [_outlineView itemAtRow:aRowIndex];
|
||||
[_outlineView._outlineViewDelegate outlineView:_outlineView willDisplayView:aView forTableColumn:aTableColumn item:item];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView isGroupRow:(int)row
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_isGroupItem_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView isGroupItem:[_outlineView itemAtRow:theRow]];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPDisclosureButton : CPButton
|
||||
@@ -846,7 +1081,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
|
||||
CGContextClosePath(context);
|
||||
|
||||
CGContextSetFillColor(context, ([self themeState] & CPThemeState("highlighted")) ? [CPColor blackColor] : [CPColor grayColor]);
|
||||
CGContextSetFillColor(context, [self isHighlighted] ? [CPColor whiteColor] : [CPColor grayColor]);
|
||||
CGContextFillPath(context);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,11 +43,14 @@ CPURLPboardType = @"CPURLPboardType";
|
||||
CPImagesPboardType = @"CPImagesPboardType";
|
||||
CPVideosPboardType = @"CPVideosPboardType";
|
||||
|
||||
UTF8PboardType = @"public.utf8-plain-text";
|
||||
|
||||
// Deprecated
|
||||
CPImagePboardType = @"CPImagePboardType";
|
||||
|
||||
|
||||
var CPPasteboards = nil;
|
||||
var CPPasteboards = nil,
|
||||
supportsNativePasteboard = NO;
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@@ -63,6 +66,8 @@ var CPPasteboards = nil;
|
||||
|
||||
unsigned _changeCount;
|
||||
CPString _stateUID;
|
||||
|
||||
WebScriptObject _nativePasteboard;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -76,6 +81,9 @@ var CPPasteboards = nil;
|
||||
[self setVersion:1.0];
|
||||
|
||||
CPPasteboards = [CPDictionary dictionary];
|
||||
|
||||
if (typeof window.cpPasteboardWithName !== "undefined")
|
||||
supportsNativePasteboard = YES;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -94,7 +102,7 @@ var CPPasteboards = nil;
|
||||
+ (id)pasteboardWithName:(CPString)aName
|
||||
{
|
||||
var pasteboard = [CPPasteboards objectForKey:aName];
|
||||
|
||||
|
||||
if (pasteboard)
|
||||
return pasteboard;
|
||||
|
||||
@@ -118,6 +126,12 @@ var CPPasteboards = nil;
|
||||
_provided = [CPDictionary dictionary];
|
||||
|
||||
_changeCount = 0;
|
||||
|
||||
if (supportsNativePasteboard)
|
||||
{
|
||||
_nativePasteboard = window.cpPasteboardWithName(aName);
|
||||
[self _synchronizePasteboard];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -146,7 +160,16 @@ 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;
|
||||
}
|
||||
|
||||
@@ -157,6 +180,12 @@ 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];
|
||||
|
||||
@@ -167,7 +196,16 @@ var CPPasteboards = nil;
|
||||
|
||||
while (count--)
|
||||
[_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;
|
||||
}
|
||||
|
||||
@@ -180,7 +218,10 @@ var CPPasteboards = nil;
|
||||
- (BOOL)setData:(CPData)aData forType:(CPString)aType
|
||||
{
|
||||
[_provided setObject:aData forKey:aType];
|
||||
|
||||
|
||||
if (aType === CPStringPboardType)
|
||||
[self setData:aData forType:UTF8PboardType];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -192,7 +233,7 @@ var CPPasteboards = nil;
|
||||
*/
|
||||
- (BOOL)setPropertyList:(id)aPropertyList forType:(CPString)aType
|
||||
{
|
||||
return [self setData:[CPPropertyListSerialization dataFromPropertyList:aPropertyList format:CPPropertyListXMLFormat_v1_0 errorDescription:nil] forType:aType];
|
||||
return [self setData:[CPPropertyListSerialization dataFromPropertyList:aPropertyList format:CPPropertyList280NorthFormat_v1_0] forType:aType];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -203,7 +244,7 @@ var CPPasteboards = nil;
|
||||
*/
|
||||
- (void)setString:(CPString)aString forType:(CPString)aType
|
||||
{
|
||||
return [self setPropertyList:aString forType:aType];
|
||||
[self setPropertyList:aString forType:aType];
|
||||
}
|
||||
|
||||
// Determining Types
|
||||
@@ -223,6 +264,7 @@ var CPPasteboards = nil;
|
||||
*/
|
||||
- (CPArray)types
|
||||
{
|
||||
[self _synchronizePasteboard];
|
||||
return _types;
|
||||
}
|
||||
|
||||
@@ -251,16 +293,46 @@ var CPPasteboards = nil;
|
||||
|
||||
if (owner)
|
||||
{
|
||||
[owner pasteboard:self provideDataForType:aType];
|
||||
|
||||
++_changeCount;
|
||||
|
||||
[owner pasteboard:self provideDataForType:aType];
|
||||
return [_provided objectForKey:aType];
|
||||
}
|
||||
|
||||
if (aType === CPStringPboardType)
|
||||
return [self dataForType:UTF8PboardType];
|
||||
|
||||
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
|
||||
@@ -271,7 +343,7 @@ var CPPasteboards = nil;
|
||||
var data = [self dataForType:aType];
|
||||
|
||||
if (data)
|
||||
return [CPPropertyListSerialization propertyListFromData:data format:CPPropertyListXMLFormat_v1_0 errorDescription:nil];
|
||||
return [CPPropertyListSerialization propertyListFromData:data format:CPPropertyList280NorthFormat_v1_0];
|
||||
|
||||
return nil;
|
||||
}
|
||||
@@ -343,7 +415,7 @@ var DOMDataTransferPasteboard = nil;
|
||||
if (type === CPStringPboardType)
|
||||
_dataTransfer.setData(type, [aPasteboard stringForType:type]);
|
||||
else
|
||||
_dataTransfer.setData(type, [[aPasteboard dataForType:type] string]);
|
||||
_dataTransfer.setData(type, [[aPasteboard dataForType:type] rawString]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,9 +429,9 @@ var DOMDataTransferPasteboard = nil;
|
||||
var dataString = _dataTransfer.getData(aType);
|
||||
|
||||
if (aType === CPStringPboardType)
|
||||
return [CPData dataFromPropertyList:dataString format:kCFPropertyList280NorthFormat_v1_0 errorDescription:0];
|
||||
return [CPData dataFromPropertyList:dataString format:kCFPropertyList280NorthFormat_v1_0];
|
||||
|
||||
return [CPData dataWithString:dataString];
|
||||
return [CPData dataWithRawString:dataString];
|
||||
}
|
||||
|
||||
- (id)propertyListForType:(CPString)aType
|
||||
@@ -367,7 +439,7 @@ var DOMDataTransferPasteboard = nil;
|
||||
if (aType === CPStringPboardType)
|
||||
return _dataTransfer.getData(aType);
|
||||
|
||||
return [CPPropertyListSerialization propertyListFromData:[self dataForType:aType] format:CPPropertyListUnknownFormat errorDescription:nil];
|
||||
return [CPPropertyListSerialization propertyListFromData:[self dataForType:aType] format:CPPropertyListUnknownFormat];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -638,21 +638,49 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
||||
{
|
||||
if (![self isEnabled] || ![self numberOfItems])
|
||||
return;
|
||||
|
||||
|
||||
[self highlight:YES];
|
||||
|
||||
var menu = [self menu],
|
||||
theWindow = [self window],
|
||||
menuWindow = [_CPMenuWindow menuWindowWithMenu:menu font:[self font]];
|
||||
|
||||
[menuWindow setDelegate:self];
|
||||
[menuWindow setBackgroundStyle:_CPMenuWindowPopUpBackgroundStyle];
|
||||
|
||||
// Pull Down Menus show up directly below their buttons.
|
||||
bounds = [self bounds],
|
||||
minimumWidth = CGRectGetWidth(bounds);
|
||||
|
||||
// FIXME: setFont: should set the font on the menu.
|
||||
[menu setFont:[self font]];
|
||||
|
||||
if ([self pullsDown])
|
||||
var menuOrigin = [theWindow convertBaseToGlobal:[self convertPoint:CGPointMake(0.0, CGRectGetMaxY([self bounds])) toView:nil]];
|
||||
|
||||
// Pop Up Menus attempt to show up "on top" of the selected item.
|
||||
{
|
||||
var positionedItem = nil,
|
||||
location = CGPointMake(0.0, CGRectGetMaxY(bounds));
|
||||
}
|
||||
else
|
||||
{
|
||||
var contentRect = [self contentRectForBounds:bounds],
|
||||
positionedItem = [self selectedItem],
|
||||
standardLeftMargin = [_CPMenuWindow _standardLeftMargin] + [_CPMenuItemStandardView _standardLeftMargin],
|
||||
location = CGPointMake(CGRectGetMinX(contentRect) - standardLeftMargin, 0.0);
|
||||
|
||||
minimumWidth += standardLeftMargin;
|
||||
}
|
||||
|
||||
[menu setMinimumWidth:minimumWidth];
|
||||
|
||||
[menu
|
||||
_popUpMenuPositioningItem:positionedItem
|
||||
atLocation:location
|
||||
topY:CGRectGetMinY(bounds)
|
||||
bottomY:CGRectGetMaxY(bounds)
|
||||
inView:self
|
||||
callback:function(aMenu)
|
||||
{
|
||||
[self highlight:NO];
|
||||
|
||||
var highlightedItem = [aMenu highlightedItem];
|
||||
|
||||
if ([highlightedItem _isSelectable])
|
||||
[self selectItem:highlightedItem];
|
||||
}];
|
||||
/*
|
||||
else
|
||||
{
|
||||
// This is confusing, I KNOW, so let me explain it to you.
|
||||
@@ -660,43 +688,14 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
||||
// 1. So calculate where our content is, then calculate where the menu item is.
|
||||
// 2. Move LEFT by whatever indentation we have (offsetWidths, aka, window margin, item margin, etc).
|
||||
// 3. MOVE UP by the difference in sizes of the content and menu item, this will only work if the content is vertically centered.
|
||||
var contentRect = [self convertRect:[self contentRectForBounds:[self bounds]] toView:nil],
|
||||
var contentRect = [self convertRect:[self contentRectForBounds:bounds] toView:nil],
|
||||
menuOrigin = [theWindow convertBaseToGlobal:contentRect.origin],
|
||||
menuItemRect = [menuWindow rectForItemAtIndex:_selectedIndex];
|
||||
|
||||
|
||||
menuOrigin.x -= CGRectGetMinX(menuItemRect) + [menuWindow overlapOffsetWidth] + [[[menu itemAtIndex:_selectedIndex] _menuItemView] overlapOffsetWidth];
|
||||
menuOrigin.y -= CGRectGetMinY(menuItemRect) + (CGRectGetHeight(menuItemRect) - CGRectGetHeight(contentRect)) / 2.0;
|
||||
}
|
||||
|
||||
[menuWindow setFrameOrigin:menuOrigin];
|
||||
|
||||
var menuMaxX = CGRectGetMaxX([menuWindow frame]),
|
||||
buttonMaxX = [theWindow convertBaseToGlobal:CGPointMake(CGRectGetMaxX([self convertRect:[self bounds] toView:nil]), 0.0)].x;
|
||||
|
||||
if (menuMaxX < buttonMaxX)
|
||||
[menuWindow setMinWidth:CGRectGetWidth([menuWindow frame]) + buttonMaxX - menuMaxX - ([self pullsDown] ? 0.0 : VISIBLE_MARGIN)];
|
||||
|
||||
[menuWindow orderFront:self];
|
||||
[menuWindow beginTrackingWithEvent:anEvent sessionDelegate:self didEndSelector:@selector(menuWindowDidFinishTracking:highlightedItem:)];
|
||||
}
|
||||
|
||||
/*
|
||||
@ignore
|
||||
*/
|
||||
- (void)menuWindowDidFinishTracking:(_CPMenuWindow)aMenuWindow highlightedItem:(CPMenuItem)aMenuItem
|
||||
{
|
||||
[_CPMenuWindow poolMenuWindow:aMenuWindow];
|
||||
|
||||
[self highlight:NO];
|
||||
|
||||
var index = [_menu indexOfItem:aMenuItem];
|
||||
|
||||
if (index == CPNotFound)
|
||||
return;
|
||||
|
||||
[self selectItemAtIndex:index];
|
||||
|
||||
[CPApp sendAction:[aMenuItem action] to:[aMenuItem target] from:aMenuItem];
|
||||
}
|
||||
|
||||
- (void)_popUpItemAction:(id)aSender
|
||||
|
||||
@@ -104,17 +104,14 @@ var CPProgressIndicatorSpinningStyleColors = nil,
|
||||
for (; start <= end; ++start)
|
||||
{
|
||||
CPProgressIndicatorBezelBorderViewPool[start] = [];
|
||||
|
||||
CPProgressIndicatorBezelBorderViewPool[start][CPMiniControlSize] = [];
|
||||
CPProgressIndicatorBezelBorderViewPool[start][CPSmallControlSize] = [];
|
||||
CPProgressIndicatorBezelBorderViewPool[start][CPRegularControlSize] = [];
|
||||
}
|
||||
|
||||
CPProgressIndicatorClassName = [self className];
|
||||
|
||||
|
||||
CPProgressIndicatorStyleIdentifiers = [];
|
||||
|
||||
|
||||
CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle] = @"Bar";
|
||||
CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorSpinningStyle] = @"Spinny";
|
||||
CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle] = @"HUDBar";
|
||||
@@ -126,30 +123,20 @@ var CPProgressIndicatorSpinningStyleColors = nil,
|
||||
CPProgressIndicatorStyleSizes = [];
|
||||
|
||||
// Bar Sttyle
|
||||
var prefix = CPProgressIndicatorClassName + @"BezelBorder" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle];
|
||||
var prefixes = [
|
||||
CPProgressIndicatorClassName + @"BezelBorder" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle],
|
||||
CPProgressIndicatorClassName + @"Bar" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle],
|
||||
CPProgressIndicatorClassName + @"BezelBorder" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle],
|
||||
CPProgressIndicatorClassName + @"Bar" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle]
|
||||
];
|
||||
|
||||
CPProgressIndicatorStyleSizes[prefix + regularIdentifier] = [_CGSizeMake(3.0, 15.0), _CGSizeMake(1.0, 15.0), _CGSizeMake(3.0, 15.0)];
|
||||
CPProgressIndicatorStyleSizes[prefix + smallIdentifier] = [_CGSizeMake(3.0, 15.0), _CGSizeMake(1.0, 15.0), _CGSizeMake(3.0, 15.0)];
|
||||
CPProgressIndicatorStyleSizes[prefix + miniIdentifier] = [_CGSizeMake(3.0, 15.0), _CGSizeMake(1.0, 15.0), _CGSizeMake(3.0, 15.0)];
|
||||
|
||||
prefix = CPProgressIndicatorClassName + @"Bar" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle];
|
||||
|
||||
CPProgressIndicatorStyleSizes[prefix + regularIdentifier] = _CGSizeMake(1.0, 9.0);
|
||||
CPProgressIndicatorStyleSizes[prefix + smallIdentifier] = _CGSizeMake(1.0, 9.0);
|
||||
CPProgressIndicatorStyleSizes[prefix + miniIdentifier] = _CGSizeMake(1.0, 9.0);
|
||||
|
||||
// HUD Bar Style
|
||||
prefix = CPProgressIndicatorClassName + @"BezelBorder" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle];
|
||||
|
||||
CPProgressIndicatorStyleSizes[prefix + regularIdentifier] = [_CGSizeMake(3.0, 15.0), _CGSizeMake(1.0, 15.0), _CGSizeMake(3.0, 15.0)];
|
||||
CPProgressIndicatorStyleSizes[prefix + smallIdentifier] = [_CGSizeMake(3.0, 15.0), _CGSizeMake(1.0, 15.0), _CGSizeMake(3.0, 15.0)];
|
||||
CPProgressIndicatorStyleSizes[prefix + miniIdentifier] = [_CGSizeMake(3.0, 15.0), _CGSizeMake(1.0, 15.0), _CGSizeMake(3.0, 15.0)];
|
||||
|
||||
prefix = CPProgressIndicatorClassName + @"Bar" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle];
|
||||
|
||||
CPProgressIndicatorStyleSizes[prefix + regularIdentifier] = _CGSizeMake(1.0, 9.0);
|
||||
CPProgressIndicatorStyleSizes[prefix + smallIdentifier] = _CGSizeMake(1.0, 9.0);
|
||||
CPProgressIndicatorStyleSizes[prefix + miniIdentifier] = _CGSizeMake(1.0, 9.0);
|
||||
for (var i = 0, count = prefixes.length; i<count; i++)
|
||||
{
|
||||
var prefix = prefixes[i];
|
||||
CPProgressIndicatorStyleSizes[prefix + regularIdentifier] = [_CGSizeMake(3.0, 16.0), _CGSizeMake(1.0, 16.0), _CGSizeMake(3.0, 16.0)];
|
||||
CPProgressIndicatorStyleSizes[prefix + smallIdentifier] = [_CGSizeMake(3.0, 16.0), _CGSizeMake(1.0, 16.0), _CGSizeMake(3.0, 16.0)];
|
||||
CPProgressIndicatorStyleSizes[prefix + miniIdentifier] = [_CGSizeMake(3.0, 16.0), _CGSizeMake(1.0, 16.0), _CGSizeMake(3.0, 16.0)];
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
@@ -428,21 +415,25 @@ var CPProgressIndicatorSpinningStyleColors = nil,
|
||||
|
||||
if (!_barView)
|
||||
{
|
||||
_barView = [[CPView alloc] initWithFrame:CGRectMake(2.0, 2.0, 0.0, 9.0)];
|
||||
|
||||
[_barView setBackgroundColor:[CPColor redColor]];
|
||||
|
||||
_barView = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 16.0)];
|
||||
[self addSubview:_barView];
|
||||
}
|
||||
|
||||
[_barView setBackgroundColor:_CPControlColorWithPatternImage(
|
||||
[_barView setBackgroundColor:_CPControlThreePartImagePattern(
|
||||
NO,
|
||||
CPProgressIndicatorStyleSizes,
|
||||
CPProgressIndicatorClassName,
|
||||
@"Bar",
|
||||
CPProgressIndicatorStyleIdentifiers[_style],
|
||||
_CPControlIdentifierForControlSize(_controlSize))];
|
||||
|
||||
[_barView setFrameSize:CGSizeMake(CGRectGetWidth([self bounds]) * (_doubleValue - _minValue) / (_maxValue - _minValue) - 4.0, 9.0)];
|
||||
|
||||
var width = CGRectGetWidth([self bounds]),
|
||||
barWidth = width * ((_doubleValue - _minValue) / (_maxValue - _minValue));
|
||||
|
||||
if (barWidth > 0.0 && barWidth < 4.0)
|
||||
barWidth = 4.0;
|
||||
|
||||
[_barView setFrameSize:CGSizeMake(barWidth, 16.0)];
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
|
||||
@@ -175,6 +175,9 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
|
||||
{
|
||||
CPSet _radios;
|
||||
CPRadio _selectedRadio;
|
||||
|
||||
id _target @accessors(property=target);
|
||||
SEL _action @accessors(property=action);
|
||||
}
|
||||
|
||||
- (id)init
|
||||
@@ -213,6 +216,8 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
|
||||
|
||||
[_selectedRadio setState:CPOffState];
|
||||
_selectedRadio = aRadio;
|
||||
|
||||
[CPApp sendAction:_action to:_target from:self];
|
||||
}
|
||||
|
||||
- (CPRadio)selectedRadio
|
||||
|
||||
@@ -27,6 +27,9 @@ CPDeleteKeyCode = 8;
|
||||
CPTabKeyCode = 9;
|
||||
CPReturnKeyCode = 13;
|
||||
CPEscapeKeyCode = 27;
|
||||
CPSpaceKeyCode = 32;
|
||||
CPPageUpKeyCode = 33;
|
||||
CPPageDownKeyCode = 34;
|
||||
CPLeftArrowKeyCode = 37;
|
||||
CPUpArrowKeyCode = 38;
|
||||
CPRightArrowKeyCode = 39;
|
||||
@@ -105,6 +108,10 @@ CPDownArrowKeyCode = 40;
|
||||
|
||||
switch([event keyCode])
|
||||
{
|
||||
case CPPageUpKeyCode: [self doCommandBySelector:@selector(pageUp:)];
|
||||
break;
|
||||
case CPPageDownKeyCode: [self doCommandBySelector:@selector(pageDown:)];
|
||||
break;
|
||||
case CPLeftArrowKeyCode: [self doCommandBySelector:@selector(moveLeft:)];
|
||||
break;
|
||||
case CPRightArrowKeyCode: [self doCommandBySelector:@selector(moveRight:)];
|
||||
|
||||
@@ -315,7 +315,10 @@
|
||||
_hasHorizontalScroller = shouldHaveHorizontalScroller;
|
||||
|
||||
if (_hasHorizontalScroller && !_horizontalScroller)
|
||||
[self setHorizontalScroller:[[CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, _CGRectGetWidth([self bounds]), [CPScroller scrollerWidth])]];
|
||||
{
|
||||
[self setHorizontalScroller:[[CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, MAX(_CGRectGetWidth([self bounds]), [CPScroller scrollerWidth]+1), [CPScroller scrollerWidth])]];
|
||||
[[self horizontalScroller] setFrameSize:CGSizeMake(_CGRectGetWidth([self bounds]), [CPScroller scrollerWidth])];
|
||||
}
|
||||
|
||||
[self reflectScrolledClipView:_contentView];
|
||||
}
|
||||
@@ -373,7 +376,10 @@
|
||||
_hasVerticalScroller = shouldHaveVerticalScroller;
|
||||
|
||||
if (_hasVerticalScroller && !_verticalScroller)
|
||||
[self setVerticalScroller:[[CPScroller alloc] initWithFrame:_CGRectMake(0.0, 0.0, [CPScroller scrollerWidth], _CGRectGetHeight([self bounds]))]];
|
||||
{
|
||||
[self setVerticalScroller:[[CPScroller alloc] initWithFrame:_CGRectMake(0.0, 0.0, [CPScroller scrollerWidth], MAX(_CGRectGetHeight([self bounds]), [CPScroller scrollerWidth]+1))]];
|
||||
[[self verticalScroller] setFrameSize:CGSizeMake([CPScroller scrollerWidth], _CGRectGetHeight([self bounds]))];
|
||||
}
|
||||
|
||||
[self reflectScrolledClipView:_contentView];
|
||||
}
|
||||
@@ -677,38 +683,48 @@
|
||||
|
||||
- (void)keyDown:(CPEvent)anEvent
|
||||
{
|
||||
var keyCode = [anEvent keyCode],
|
||||
documentFrame = [[self documentView] frame],
|
||||
[self interpretKeyEvents:[anEvent]];
|
||||
}
|
||||
|
||||
- (void)pageUp:(id)sender
|
||||
{
|
||||
var contentBounds = [_contentView bounds];
|
||||
[self moveByOffset:CGSizeMake(0.0, -(_CGRectGetHeight(contentBounds) - _verticalPageScroll))];
|
||||
}
|
||||
|
||||
- (void)pageDown:(id)sender
|
||||
{
|
||||
var contentBounds = [_contentView bounds];
|
||||
[self moveByOffset:CGSizeMake(0.0, _CGRectGetHeight(contentBounds) - _verticalPageScroll)];
|
||||
}
|
||||
|
||||
- (void)moveLeft:(id)sender
|
||||
{
|
||||
[self moveByOffset:CGSizeMake(-_horizontalLineScroll, 0.0)];
|
||||
}
|
||||
|
||||
- (void)moveRight:(id)sender
|
||||
{
|
||||
[self moveByOffset:CGSizeMake(_horizontalLineScroll, 0.0)];
|
||||
}
|
||||
|
||||
- (void)moveUp:(id)sender
|
||||
{
|
||||
[self moveByOffset:CGSizeMake(0.0, -_verticalLineScroll)];
|
||||
}
|
||||
|
||||
- (void)moveDown:(id)sender
|
||||
{
|
||||
[self moveByOffset:CGSizeMake(0.0, _verticalLineScroll)];
|
||||
}
|
||||
|
||||
- (void)moveByOffset:(CGSize)aSize
|
||||
{
|
||||
var documentFrame = [[self documentView] frame],
|
||||
contentBounds = [_contentView bounds];
|
||||
|
||||
switch (keyCode)
|
||||
{
|
||||
case 33: /*pageup*/
|
||||
contentBounds.origin.y -= _CGRectGetHeight(contentBounds) - _verticalPageScroll;
|
||||
break;
|
||||
|
||||
case 34: /*pagedown*/
|
||||
contentBounds.origin.y += _CGRectGetHeight(contentBounds) - _verticalPageScroll;
|
||||
break;
|
||||
|
||||
case 38: /*up arrow*/
|
||||
contentBounds.origin.y -= _verticalLineScroll;
|
||||
break;
|
||||
|
||||
case 40: /*down arrow*/
|
||||
contentBounds.origin.y += _verticalLineScroll;
|
||||
break;
|
||||
|
||||
case 37: /*left arrow*/
|
||||
contentBounds.origin.x -= _horizontalLineScroll;
|
||||
break;
|
||||
|
||||
case 49: /*right arrow*/
|
||||
contentBounds.origin.x += _horizontalLineScroll;
|
||||
break;
|
||||
|
||||
default: return [super keyDown:anEvent];
|
||||
}
|
||||
contentBounds.origin.x += aSize.width;
|
||||
contentBounds.origin.y += aSize.height;
|
||||
|
||||
[_contentView scrollToPoint:contentBounds.origin];
|
||||
[_headerClipView scrollToPoint:CGPointMake(contentBounds.origin, 0)];
|
||||
@@ -716,16 +732,18 @@
|
||||
|
||||
@end
|
||||
|
||||
var CPScrollViewContentViewKey = "CPScrollViewContentView",
|
||||
CPScrollViewVLineScrollKey = "CPScrollViewVLineScroll",
|
||||
CPScrollViewHLineScrollKey = "CPScrollViewHLineScroll",
|
||||
CPScrollViewVPageScrollKey = "CPScrollViewVPageScroll",
|
||||
CPScrollViewHPageScrollKey = "CPScrollViewHPageScroll",
|
||||
CPScrollViewHasVScrollerKey = "CPScrollViewHasVScroller",
|
||||
CPScrollViewHasHScrollerKey = "CPScrollViewHasHScroller",
|
||||
CPScrollViewVScrollerKey = "CPScrollViewVScroller",
|
||||
CPScrollViewHScrollerKey = "CPScrollViewHScroller",
|
||||
CPScrollViewAutohidesScrollerKey = "CPScrollViewAutohidesScroller";
|
||||
var CPScrollViewContentViewKey = "CPScrollViewContentView",
|
||||
CPScrollViewHeaderClipViewKey = "CPScrollViewHeaderClipViewKey",
|
||||
CPScrollViewVLineScrollKey = "CPScrollViewVLineScroll",
|
||||
CPScrollViewHLineScrollKey = "CPScrollViewHLineScroll",
|
||||
CPScrollViewVPageScrollKey = "CPScrollViewVPageScroll",
|
||||
CPScrollViewHPageScrollKey = "CPScrollViewHPageScroll",
|
||||
CPScrollViewHasVScrollerKey = "CPScrollViewHasVScroller",
|
||||
CPScrollViewHasHScrollerKey = "CPScrollViewHasHScroller",
|
||||
CPScrollViewVScrollerKey = "CPScrollViewVScroller",
|
||||
CPScrollViewHScrollerKey = "CPScrollViewHScroller",
|
||||
CPScrollViewAutohidesScrollerKey = "CPScrollViewAutohidesScroller",
|
||||
CPScrollViewCornerViewKey = "CPScrollViewCornerViewKey";
|
||||
|
||||
@implementation CPScrollView (CPCoding)
|
||||
|
||||
@@ -740,6 +758,7 @@ var CPScrollViewContentViewKey = "CPScrollViewContentView",
|
||||
_horizontalPageScroll = [aCoder decodeFloatForKey:CPScrollViewHPageScrollKey];
|
||||
|
||||
_contentView = [aCoder decodeObjectForKey:CPScrollViewContentViewKey];
|
||||
_headerClipView = [aCoder decodeObjectForKey:CPScrollViewHeaderClipViewKey];
|
||||
|
||||
_verticalScroller = [aCoder decodeObjectForKey:CPScrollViewVScrollerKey];
|
||||
_horizontalScroller = [aCoder decodeObjectForKey:CPScrollViewHScrollerKey];
|
||||
@@ -747,7 +766,9 @@ var CPScrollViewContentViewKey = "CPScrollViewContentView",
|
||||
_hasVerticalScroller = [aCoder decodeBoolForKey:CPScrollViewHasVScrollerKey];
|
||||
_hasHorizontalScroller = [aCoder decodeBoolForKey:CPScrollViewHasHScrollerKey];
|
||||
_autohidesScrollers = [aCoder decodeBoolForKey:CPScrollViewAutohidesScrollerKey];
|
||||
|
||||
|
||||
_cornerView = [aCoder decodeObjectForKey:CPScrollViewCornerViewKey];
|
||||
|
||||
// Do to the anything goes nature of decoding, our subviews may not exist yet, so layout at the end of the run loop when we're sure everything is in a correct state.
|
||||
[[CPRunLoop currentRunLoop] performSelector:@selector(reflectScrolledClipView:) target:self argument:_contentView order:0 modes:[CPDefaultRunLoopMode]];
|
||||
}
|
||||
@@ -760,7 +781,8 @@ var CPScrollViewContentViewKey = "CPScrollViewContentView",
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
[aCoder encodeObject:_contentView forKey:CPScrollViewContentViewKey];
|
||||
|
||||
[aCoder encodeObject:_headerClipView forKey:CPScrollViewHeaderClipViewKey];
|
||||
|
||||
[aCoder encodeObject:_verticalScroller forKey:CPScrollViewVScrollerKey];
|
||||
[aCoder encodeObject:_horizontalScroller forKey:CPScrollViewHScrollerKey];
|
||||
|
||||
@@ -772,6 +794,8 @@ var CPScrollViewContentViewKey = "CPScrollViewContentView",
|
||||
[aCoder encodeBool:_hasVerticalScroller forKey:CPScrollViewHasVScrollerKey];
|
||||
[aCoder encodeBool:_hasHorizontalScroller forKey:CPScrollViewHasHScrollerKey];
|
||||
[aCoder encodeBool:_autohidesScrollers forKey:CPScrollViewAutohidesScrollerKey];
|
||||
|
||||
[aCoder encodeObject:_cornerView forKey:CPScrollViewCornerViewKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -79,7 +79,7 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
|
||||
|
||||
+ (id)themeAttributes
|
||||
{
|
||||
return [CPDictionary dictionaryWithObjects:[ nil, nil, nil, nil,
|
||||
return [CPDictionary dictionaryWithObjects:[ [CPNull null], [CPNull null], [CPNull null], [CPNull null],
|
||||
_CGSizeMakeZero(), _CGSizeMakeZero(), _CGInsetMakeZero(), _CGInsetMakeZero(), _CGSizeMakeZero()]
|
||||
forKeys:[ @"knob-slot-color",
|
||||
@"decrement-line-color",
|
||||
@@ -235,21 +235,21 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
|
||||
*/
|
||||
- (void)checkSpaceForParts
|
||||
{
|
||||
var bounds = [self bounds];
|
||||
var bounds = [self bounds];
|
||||
|
||||
// Assume we won't be needing the arrows.
|
||||
if (_knobProportion === 1.0)
|
||||
{
|
||||
_usableParts = CPNoScrollerParts;
|
||||
|
||||
_partRects[CPScrollerDecrementPage] = _CGRectMakeZero();
|
||||
_partRects[CPScrollerKnob] = _CGRectMakeZero();
|
||||
_partRects[CPScrollerIncrementPage] = _CGRectMakeZero();
|
||||
_partRects[CPScrollerDecrementLine] = _CGRectMakeZero();
|
||||
_partRects[CPScrollerIncrementLine] = _CGRectMakeZero();
|
||||
_partRects[CPScrollerDecrementPage] = CGRectMakeZero();
|
||||
_partRects[CPScrollerKnob] = CGRectMakeZero();
|
||||
_partRects[CPScrollerIncrementPage] = CGRectMakeZero();
|
||||
_partRects[CPScrollerDecrementLine] = CGRectMakeZero();
|
||||
_partRects[CPScrollerIncrementLine] = CGRectMakeZero();
|
||||
|
||||
// In this case, the slot is the entirety of the scroller.
|
||||
_partRects[CPScrollerKnobSlot] = _CGRectMakeCopy(bounds);
|
||||
_partRects[CPScrollerKnobSlot] = CGRectMakeCopy(bounds);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -279,8 +279,18 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
|
||||
_partRects[CPScrollerIncrementPage] = _CGRectMake(0.0, knobLocation + knobHeight, width, height - (knobLocation + knobHeight) - effectiveIncrementLineHeight);
|
||||
_partRects[CPScrollerKnobSlot] = _CGRectMake(trackInset.left, effectiveDecrementLineHeight, width - trackInset.left - trackInset.right, slotHeight);
|
||||
_partRects[CPScrollerDecrementLine] = _CGRectMake(0.0, 0.0, decrementLineSize.width, decrementLineSize.height);
|
||||
_partRects[CPScrollerIncrementLine] = _CGRectMake(0.0, height - incrementLineSize.height, incrementLineSize.width, incrementLineSize.height);
|
||||
}
|
||||
_partRects[CPScrollerIncrementLine] = _CGRectMake(0.0, height - incrementLineSize.height, incrementLineSize.width, incrementLineSize.height);
|
||||
|
||||
if(height < knobHeight + decrementLineSize.height + incrementLineSize.height + trackInset.top + trackInset.bottom)
|
||||
_partRects[CPScrollerKnob] = _CGRectMakeZero();
|
||||
|
||||
if(height < decrementLineSize.height + incrementLineSize.height - 2)
|
||||
{
|
||||
_partRects[CPScrollerIncrementLine] = _CGRectMakeZero();
|
||||
_partRects[CPScrollerDecrementLine] = _CGRectMakeZero();
|
||||
_partRects[CPScrollerKnobSlot] = _CGRectMake(trackInset.left, 0, width - trackInset.left - trackInset.right, height);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
@@ -300,6 +310,16 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
|
||||
_partRects[CPScrollerKnobSlot] = _CGRectMake(effectiveDecrementLineWidth, trackInset.top, slotWidth, height - trackInset.top - trackInset.bottom);
|
||||
_partRects[CPScrollerDecrementLine] = _CGRectMake(0.0, 0.0, decrementLineSize.width, decrementLineSize.height);
|
||||
_partRects[CPScrollerIncrementLine] = _CGRectMake(width - incrementLineSize.width, 0.0, incrementLineSize.width, incrementLineSize.height);
|
||||
|
||||
if(width < knobWidth + decrementLineSize.width + incrementLineSize.width + trackInset.left + trackInset.right)
|
||||
_partRects[CPScrollerKnob] = _CGRectMakeZero();
|
||||
|
||||
if(width < decrementLineSize.width + incrementLineSize.width - 2)
|
||||
{
|
||||
_partRects[CPScrollerIncrementLine] = _CGRectMakeZero();
|
||||
_partRects[CPScrollerDecrementLine] = _CGRectMakeZero();
|
||||
_partRects[CPScrollerKnobSlot] = _CGRectMake(0.0, 0.0, width, slotHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,40 +89,35 @@ var CPSearchFieldSearchImage = nil,
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self != nil)
|
||||
{
|
||||
_recentSearches = [CPArray array];
|
||||
_maximumRecents = 10;
|
||||
_sendsWholeSearchString = NO;
|
||||
_sendsSearchStringImmediately = NO;
|
||||
|
||||
[self setBezeled:YES];
|
||||
[self setBezelStyle:CPTextFieldRoundedBezel];
|
||||
[self setBordered:YES];
|
||||
[self setEditable:YES];
|
||||
[self setDelegate:self];
|
||||
|
||||
_cancelButton = [[CPButton alloc] initWithFrame:CPMakeRect(frame.size.width - 27,(frame.size.height-22)/2,22,22)];
|
||||
[self resetCancelButton];
|
||||
|
||||
|
||||
[_cancelButton setHidden:YES];
|
||||
[_cancelButton setAutoresizingMask:CPViewMinXMargin];
|
||||
[self addSubview:_cancelButton];
|
||||
|
||||
_searchButton = [[CPButton alloc] initWithFrame:CPMakeRect(5,(frame.size.height-25)/2,25,25)];
|
||||
[_searchButton setBezelStyle:CPRegularSquareBezelStyle];
|
||||
[_searchButton setAutoresizingMask:CPViewMaxXMargin]
|
||||
[_searchButton setBordered:NO];
|
||||
[_searchButton setImageScaling:CPScaleToFit];
|
||||
{
|
||||
_recentSearches = [CPArray array];
|
||||
_maximumRecents = 10;
|
||||
_sendsWholeSearchString = NO;
|
||||
_sendsSearchStringImmediately = NO;
|
||||
_recentsAutosaveName = nil;
|
||||
|
||||
[self setBezeled:YES];
|
||||
[self setBezelStyle:CPTextFieldRoundedBezel];
|
||||
[self setBordered:YES];
|
||||
[self setEditable:YES];
|
||||
[self setDelegate:self];
|
||||
|
||||
_cancelButton = [[CPButton alloc] initWithFrame:CPMakeRect(frame.size.width - 27,(frame.size.height-22)/2,22,22)];
|
||||
[self resetCancelButton];
|
||||
[_cancelButton setHidden:YES];
|
||||
[_cancelButton setAutoresizingMask:CPViewMinXMargin];
|
||||
[self addSubview:_cancelButton];
|
||||
|
||||
_searchButton = [[CPButton alloc] initWithFrame:CPMakeRect(5,(frame.size.height-25)/2,25,25)];
|
||||
[self resetSearchButton];
|
||||
[self addSubview:_searchButton];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_cancelButton._DOMElement.style.cursor = "default";
|
||||
_searchButton._DOMElement.style.cursor = "default";
|
||||
#endif
|
||||
|
||||
[self setSearchMenuTemplate:[self _searchMenuTemplate]];
|
||||
[self addSubview:_searchButton];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
@@ -133,11 +128,13 @@ var CPSearchFieldSearchImage = nil,
|
||||
|
||||
[copy setCancelButton:[_cancelButton copy]];
|
||||
[copy setSearchButton:[_searchButton copy]];
|
||||
[copy setrecentsAutosaveName:[_recentsAutosaveName copy]];
|
||||
[copy setSendsWholeSearchString:[_sendsWholeSearchString copy]];
|
||||
[copy setSendsSearchStringImmediately:[_sendsSearchStringImmediately copy]];
|
||||
[copy setMaximumRecents:_maximumRecents];
|
||||
[copy setSearchMenutemplate:[_searchMenuTemplate copy]];
|
||||
if (_recentsAutosaveName)
|
||||
[copy setrecentsAutosaveName:[_recentsAutosaveName copy]];
|
||||
if (_searchMenuTemplate)
|
||||
[copy setSearchMenutemplate:[_searchMenuTemplate copy]];
|
||||
|
||||
return copy;
|
||||
}
|
||||
@@ -172,11 +169,11 @@ var CPSearchFieldSearchImage = nil,
|
||||
target,
|
||||
button = [self searchButton];
|
||||
|
||||
if (_searchMenuTemplate == nil)
|
||||
if (_searchMenuTemplate === nil)
|
||||
{
|
||||
searchButtonImage = CPSearchFieldSearchImage;
|
||||
action = [self action];
|
||||
target = [self target];
|
||||
action = @selector(_sendAction:);
|
||||
target = self;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -185,7 +182,10 @@ var CPSearchFieldSearchImage = nil,
|
||||
target = self;
|
||||
}
|
||||
|
||||
[button setBordered:NO];
|
||||
[button setImageScaling:CPScaleToFit];
|
||||
[button setImage:searchButtonImage];
|
||||
[button setAutoresizingMask:CPViewMaxXMargin];
|
||||
[button setTarget:target];
|
||||
[button setAction:action];
|
||||
}
|
||||
@@ -215,11 +215,11 @@ var CPSearchFieldSearchImage = nil,
|
||||
- (void)resetCancelButton
|
||||
{
|
||||
var button = [self cancelButton];
|
||||
[button setBezelStyle:CPRegularSquareBezelStyle];
|
||||
[button setBordered:NO];
|
||||
[button setImageScaling:CPScaleToFit];
|
||||
[button setImage:CPSearchFieldCancelImage];
|
||||
[button setAlternateImage:CPSearchFieldCancelPressedImage];
|
||||
[button setAutoresizingMask:CPViewMinXMargin];
|
||||
[button setTarget:self];
|
||||
[button setAction:@selector(_searchFieldCancel:)];
|
||||
}
|
||||
@@ -255,7 +255,7 @@ var CPSearchFieldSearchImage = nil,
|
||||
@param rect The current bounding rectangle for the search button.
|
||||
Subclasses can override this method to return a new bounding rectangle for the search button. You might use this method to provide a custom layout for the search field control.
|
||||
*/
|
||||
- (CPRect)searchButtonRectForBounds:(CPRect)rect // fix
|
||||
- (CPRect)searchButtonRectForBounds:(CPRect)rect
|
||||
{
|
||||
return [_searchButton frame];
|
||||
}
|
||||
@@ -290,6 +290,7 @@ var CPSearchFieldSearchImage = nil,
|
||||
_searchMenuTemplate = menu;
|
||||
|
||||
[self resetSearchButton];
|
||||
[self _loadRecentSearchList];
|
||||
[self _updateSearchMenu];
|
||||
}
|
||||
|
||||
@@ -370,10 +371,10 @@ var CPSearchFieldSearchImage = nil,
|
||||
*/
|
||||
- (void)setRecentSearches:(CPArray)searches
|
||||
{
|
||||
var max = MIN([self maximumRecents],[searches count]);
|
||||
var searches = [searches subarrayWithRange:CPMakeRange(0,max)];
|
||||
_recentSearches = searches;
|
||||
var max = MIN([self maximumRecents], [searches count]),
|
||||
searches = [searches subarrayWithRange:CPMakeRange(0, max)];
|
||||
|
||||
_recentSearches = searches;
|
||||
[self _autosaveRecentSearchList];
|
||||
}
|
||||
|
||||
@@ -392,12 +393,13 @@ var CPSearchFieldSearchImage = nil,
|
||||
*/
|
||||
- (void)setRecentsAutosaveName:(CPString)name
|
||||
{
|
||||
if (_recentsAutosaveName != nil)
|
||||
[self _deregisterForAutosaveNotification];
|
||||
|
||||
_recentsAutosaveName = name;
|
||||
|
||||
if(name != nil)
|
||||
if (_recentsAutosaveName != nil)
|
||||
[self _registerForAutosaveNotification];
|
||||
else
|
||||
[self _deregisterForAutosaveNotification];
|
||||
}
|
||||
|
||||
// Private methods and subclassing
|
||||
@@ -425,95 +427,110 @@ var CPSearchFieldSearchImage = nil,
|
||||
|
||||
- (void)_updateCancelButtonVisibility
|
||||
{
|
||||
[_cancelButton setHidden:([[self stringValue] length] == 0)];
|
||||
[_cancelButton setHidden:([[self stringValue] length] === 0)];
|
||||
}
|
||||
|
||||
- (void)controlTextDidChange:(CPNotification)aNotification
|
||||
{
|
||||
if(!_sendsWholeSearchString)
|
||||
if (![self sendsWholeSearchString])
|
||||
{
|
||||
if(_sendsSearchStringImmediately)
|
||||
if ([self sendsSearchStringImmediately])
|
||||
[self _sendPartialString];
|
||||
else
|
||||
{
|
||||
[_partialStringTimer invalidate];
|
||||
var timeInterval = [CPSearchField _keyboardDelayForPartialSearchString:[self stringValue]];
|
||||
|
||||
_partialStringTimer = [CPTimer scheduledTimerWithTimeInterval:timeInterval target:self selector:@selector(_sendPartialString) userInfo:nil repeats:NO];
|
||||
_partialStringTimer = [CPTimer scheduledTimerWithTimeInterval:timeInterval
|
||||
target:self
|
||||
selector:@selector(_sendPartialString)
|
||||
userInfo:nil
|
||||
repeats:NO];
|
||||
}
|
||||
}
|
||||
|
||||
[self _updateCancelButtonVisibility];
|
||||
}
|
||||
|
||||
- (void)_sendAction:(id)sender
|
||||
{
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
}
|
||||
|
||||
- (void)sendAction:(SEL)anAction to:(id)anObject
|
||||
{
|
||||
[super sendAction:anAction to:anObject];
|
||||
|
||||
[_partialStringTimer invalidate];
|
||||
|
||||
var current_value = [self objectValue];
|
||||
if(current_value != nil && current_value != "" && ![_recentSearches containsObject:current_value])
|
||||
{
|
||||
[self _addStringToRecentSearches:current_value];
|
||||
[self _updateSearchMenu];
|
||||
}
|
||||
|
||||
[self _addStringToRecentSearches:[self stringValue]];
|
||||
[self _updateCancelButtonVisibility];
|
||||
}
|
||||
|
||||
- (void)_addStringToRecentSearches:(CPString)string
|
||||
{
|
||||
var newSearches = [CPMutableArray arrayWithArray:_recentSearches];
|
||||
[newSearches addObject:string];
|
||||
[self setRecentSearches:newSearches];
|
||||
if (string === nil || string === @"" || [_recentSearches containsObject:string])
|
||||
return;
|
||||
|
||||
var searches = [CPMutableArray arrayWithArray:_recentSearches];
|
||||
[searches addObject:string];
|
||||
[self setRecentSearches:searches];
|
||||
[self _updateSearchMenu];
|
||||
}
|
||||
|
||||
- (BOOL)trackMouse:(CPEvent)event
|
||||
{
|
||||
var rect;
|
||||
var point;
|
||||
var location = [event locationInWindow];
|
||||
var rect,
|
||||
point,
|
||||
location = [event locationInWindow];
|
||||
|
||||
point = [self convertPoint:location fromView:nil];
|
||||
|
||||
rect = [self searchButtonRectForBounds:[self frame]];
|
||||
|
||||
if (CPRectContainsPoint(rect,point))
|
||||
{
|
||||
return [[self searchButton] trackMouse:event];
|
||||
}
|
||||
{
|
||||
return [[self searchButton] trackMouse:event];
|
||||
}
|
||||
|
||||
rect = [self cancelButtonRectForBounds:[self frame]];
|
||||
if (CPRectContainsPoint(rect,point))
|
||||
{
|
||||
return [[self cancelButton] trackMouse:event];
|
||||
}
|
||||
{
|
||||
return [[self cancelButton] trackMouse:event];
|
||||
}
|
||||
|
||||
return [super trackMouse:event];
|
||||
}
|
||||
|
||||
- (CPMenu)_searchMenuTemplate
|
||||
- (CPMenu)_defaultSearchMenuTemplate
|
||||
{
|
||||
var template, item;
|
||||
|
||||
template = [[CPMenu alloc] init];
|
||||
|
||||
item = [[CPMenuItem alloc] initWithTitle:@"Recent searches" action:NULL keyEquivalent:@""];
|
||||
item = [[CPMenuItem alloc] initWithTitle:@"Recent searches"
|
||||
action:NULL
|
||||
keyEquivalent:@""];
|
||||
[item setTag:CPSearchFieldRecentsTitleMenuItemTag];
|
||||
[item setEnabled:NO];
|
||||
[template addItem:item];
|
||||
|
||||
item = [[CPMenuItem alloc] initWithTitle:@"Recent search item" action:@selector(_searchFieldSearch:) keyEquivalent:@""];
|
||||
item = [[CPMenuItem alloc] initWithTitle:@"Recent search item"
|
||||
action:@selector(_searchFieldSearch:)
|
||||
keyEquivalent:@""];
|
||||
[item setTag:CPSearchFieldRecentsMenuItemTag];
|
||||
[item setTarget:self];
|
||||
[template addItem:item];
|
||||
|
||||
item = [[CPMenuItem alloc] initWithTitle:@"Clear recent searches" action:@selector(_searchFieldClearRecents:) keyEquivalent:@""];
|
||||
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:NULL keyEquivalent:@""];
|
||||
item = [[CPMenuItem alloc] initWithTitle:@"No recent searches"
|
||||
action:NULL
|
||||
keyEquivalent:@""];
|
||||
[item setTag:CPSearchFieldNoRecentsMenuItemTag];
|
||||
[item setEnabled:NO];
|
||||
[template addItem:item];
|
||||
@@ -523,41 +540,56 @@ var CPSearchFieldSearchImage = nil,
|
||||
|
||||
- (void)_updateSearchMenu
|
||||
{
|
||||
if(_searchMenuTemplate == nil)
|
||||
if (_searchMenuTemplate === nil)
|
||||
return;
|
||||
|
||||
var i, menu = [[CPMenu alloc] init];
|
||||
var countOfRecents = [_recentSearches count];
|
||||
var i, menu = [[CPMenu alloc] init],
|
||||
countOfRecents = [_recentSearches count],
|
||||
numberOfItems = [_searchMenuTemplate numberOfItems];
|
||||
|
||||
for (i = 0; i < [_searchMenuTemplate numberOfItems]; i++)
|
||||
for (i = 0; i < numberOfItems; i++)
|
||||
{
|
||||
var item = [_searchMenuTemplate itemAtIndex:i];
|
||||
var tag = [item tag];
|
||||
var item = [_searchMenuTemplate itemAtIndex:i],
|
||||
tag = [item tag];
|
||||
|
||||
if(tag == CPSearchFieldClearRecentsMenuItemTag && countOfRecents != 0)
|
||||
if (!(tag === CPSearchFieldRecentsTitleMenuItemTag && countOfRecents === 0) &&
|
||||
!(tag === CPSearchFieldClearRecentsMenuItemTag && countOfRecents === 0) &&
|
||||
!(tag === CPSearchFieldNoRecentsMenuItemTag && countOfRecents != 0) &&
|
||||
!(tag === CPSearchFieldRecentsMenuItemTag))
|
||||
{
|
||||
var separator = [CPMenuItem separatorItem];
|
||||
[menu addItem:separator];
|
||||
}
|
||||
var itemAction, itemTarget;
|
||||
switch (tag)
|
||||
{
|
||||
case CPSearchFieldRecentsTitleMenuItemTag : itemAction = NULL; itemTarget = NULL; break;
|
||||
case CPSearchFieldClearRecentsMenuItemTag : itemAction = @selector(_searchFieldClearRecents:); itemTarget = self; break;
|
||||
case CPSearchFieldNoRecentsMenuItemTag : itemAction = NULL; itemTarget = NULL; break;
|
||||
default: itemAction = [item action]; itemTarget = [item target]; break;
|
||||
}
|
||||
|
||||
if (tag === CPSearchFieldClearRecentsMenuItemTag || tag === CPSearchFieldRecentsTitleMenuItemTag)
|
||||
{
|
||||
var separator = [CPMenuItem separatorItem];
|
||||
[separator setEnabled:NO];
|
||||
[menu addItem:separator];
|
||||
}
|
||||
|
||||
if (!(tag == CPSearchFieldRecentsTitleMenuItemTag && countOfRecents == 0) &&
|
||||
!(tag == CPSearchFieldClearRecentsMenuItemTag && countOfRecents == 0) &&
|
||||
!(tag == CPSearchFieldNoRecentsMenuItemTag && countOfRecents != 0) &&
|
||||
!(tag == CPSearchFieldRecentsMenuItemTag))
|
||||
{
|
||||
var templateItem = [[CPMenuItem alloc] initWithTitle:[item title] action:[item action] keyEquivalent:[item keyEquivalent]];
|
||||
[templateItem setTarget:[item target]];
|
||||
[templateItem setEnabled:[item isEnabled]];
|
||||
[templateItem setTag:[item tag]];
|
||||
var templateItem = [[CPMenuItem alloc] initWithTitle:[item title]
|
||||
action:itemAction
|
||||
keyEquivalent:[item keyEquivalent]];
|
||||
[templateItem setTarget:itemTarget];
|
||||
[templateItem setEnabled:([item isEnabled] && itemAction != NULL)];
|
||||
[templateItem setTag:tag];
|
||||
[menu addItem:templateItem];
|
||||
}
|
||||
else if (tag == CPSearchFieldRecentsMenuItemTag)
|
||||
else if (tag === CPSearchFieldRecentsMenuItemTag)
|
||||
{
|
||||
var j;
|
||||
for (j = 0; j < countOfRecents; j++)
|
||||
{
|
||||
var rencentItem = [[CPMenuItem alloc] initWithTitle:[_recentSearches objectAtIndex:j] action:[item action] keyEquivalent:[item keyEquivalent]];
|
||||
[rencentItem setTarget:[item target]];
|
||||
var rencentItem = [[CPMenuItem alloc] initWithTitle:[_recentSearches objectAtIndex:j]
|
||||
action:@selector(_searchFieldSearch:)
|
||||
keyEquivalent:[item keyEquivalent]];
|
||||
[rencentItem setTarget:self];
|
||||
[menu addItem:rencentItem];
|
||||
}
|
||||
}
|
||||
@@ -565,16 +597,15 @@ var CPSearchFieldSearchImage = nil,
|
||||
_searchMenu = menu;
|
||||
}
|
||||
|
||||
|
||||
- (void)_showMenu:(id)sender
|
||||
{
|
||||
if(_searchMenu == nil || ![self isEnabled])
|
||||
if (_searchMenu === nil || [_searchMenu numberOfItems] === 0 || ![self isEnabled])
|
||||
return;
|
||||
|
||||
[super selectText:nil];
|
||||
var aFrame = [[self superview] convertRect:[self frame] toView:nil],
|
||||
location = CPMakePoint(aFrame.origin.x + 10, aFrame.origin.y + aFrame.size.height - 4);
|
||||
|
||||
var origin = CPMakePoint([self frame].origin.x, [self frame].origin.y + [self frame].size.height);
|
||||
var anEvent = [CPEvent keyEventWithType:CPRightMouseDown location:origin modifierFlags:0 timestamp:[CPDate date] windowNumber:1 context:[[CPGraphicsContext currentContext] graphicsPort] characters:"" charactersIgnoringModifiers:"" isARepeat:NO keyCode:0];
|
||||
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];
|
||||
|
||||
[CPMenu popUpContextMenu:_searchMenu withEvent:anEvent forView:sender];
|
||||
}
|
||||
@@ -586,16 +617,21 @@ var CPSearchFieldSearchImage = nil,
|
||||
|
||||
- (void)_searchFieldCancel:(id)sender
|
||||
{
|
||||
[self setObjectValue:nil];
|
||||
[self setObjectValue:@""];
|
||||
[self _sendPartialString];
|
||||
[self _updateCancelButtonVisibility];
|
||||
[sender setHidden:YES];
|
||||
}
|
||||
|
||||
- (void)_searchFieldSearch:(id)sender
|
||||
{
|
||||
[self setObjectValue:[sender title]];
|
||||
var searchString = [sender title];
|
||||
|
||||
if ([sender tag] != CPSearchFieldRecentsMenuItemTag)
|
||||
[self _addStringToRecentSearches:searchString];
|
||||
|
||||
[self setObjectValue:searchString];
|
||||
[self _sendPartialString];
|
||||
|
||||
[self _updateCancelButtonVisibility];
|
||||
}
|
||||
|
||||
@@ -615,52 +651,48 @@ var CPSearchFieldSearchImage = nil,
|
||||
[[CPNotificationCenter defaultCenter] removeObserver:self name:@"CPAutosavedRecentsChangedNotification" object:nil];
|
||||
}
|
||||
|
||||
- (void)_updateAutosavedRecents:(id)notification
|
||||
{
|
||||
var name = [notification object];
|
||||
var list = [self recentSearches];
|
||||
|
||||
[[CPUserDefaults standardUserDefaults] setObject:list forKey:name];
|
||||
|
||||
}
|
||||
|
||||
- (void)_autosaveRecentSearchList
|
||||
{
|
||||
if(_recentsAutosaveName != nil)
|
||||
if (_recentsAutosaveName != nil)
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:@"CPAutosavedRecentsChangedNotification" object:_recentsAutosaveName];
|
||||
}
|
||||
|
||||
- (void)_updateAutosavedRecents:(id)notification
|
||||
{
|
||||
var list = [self recentSearches],
|
||||
name = [notification object],
|
||||
bundle_name = [[[CPBundle mainBundle] infoDictionary] objectForKey:"CPBundleName"],
|
||||
cookie_name = [bundle_name lowercaseString] + "." + [notification object],
|
||||
|
||||
cookie = [[CPCookie alloc] initWithName:cookie_name],
|
||||
cookie_value = [list componentsJoinedByString:@","];
|
||||
|
||||
[cookie setValue:cookie_value
|
||||
expires:[[CPDate alloc] initWithTimeIntervalSinceNow:3600*24*365]
|
||||
domain:(window.location.href.hostname)];
|
||||
}
|
||||
|
||||
- (void)_loadRecentSearchList
|
||||
{
|
||||
var list,
|
||||
name = [self recentsAutosaveName];
|
||||
|
||||
list = [[CPUserDefaults standardUserDefaults] objectForKey:name];
|
||||
_recentSearches = list;
|
||||
}
|
||||
if (name === nil)
|
||||
return;
|
||||
|
||||
/*
|
||||
- (BOOL)trackMouse:(CPEvent)theEvent inRect:(CPRect)cellFrame ofView:(CPView)aTextView untilMouseUp:(BOOL)flag
|
||||
{
|
||||
}
|
||||
var bundle_name = [[[CPBundle mainBundle] infoDictionary] objectForKey:"CPBundleName"],
|
||||
cookie_name = [bundle_name lowercaseString] + "." + name,
|
||||
|
||||
- (BOOL)_trimRecentSearchList
|
||||
{
|
||||
}
|
||||
cookie = [[CPCookie alloc] initWithName:cookie_name];
|
||||
|
||||
- (void)_trackButton:(CPButton)button forEvent:(CPEvent)event inRect:(CPRect)rect ofView:(id)view
|
||||
{
|
||||
if (cookie != nil)
|
||||
{
|
||||
var cookie_value = [cookie value];
|
||||
list = (cookie_value != @"") ? [cookie_value componentsSeparatedByString:@","] : [CPArray array];
|
||||
_recentSearches = list;
|
||||
}
|
||||
}
|
||||
|
||||
- (id)_selectOrEdit:(CPRect)rect inView:(id)view target:(id)target editor:(id)editor event:(id)event start:(int)start end:(int)end
|
||||
{
|
||||
}
|
||||
|
||||
- (void)resetCursorRect:(CPRect)rect inView:(id)view
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
||||
var CPSearchButtonKey = @"CPSearchButtonKey",
|
||||
@@ -679,11 +711,13 @@ var CPSearchButtonKey = @"CPSearchButtonKey",
|
||||
|
||||
[coder encodeObject:_searchButton forKey:CPSearchButtonKey];
|
||||
[coder encodeObject:_cancelButton forKey:CPCancelButtonKey];
|
||||
[coder encodeObject:_recentsAutosaveName forKey:CPRecentsAutosaveNameKey];
|
||||
[coder encodeBool:_sendsWholeSearchString forKey:CPSendsWholeSearchStringKey];
|
||||
[coder encodeBool:_sendsSearchStringImmediately forKey:CPSendsSearchStringImmediatelyKey];
|
||||
[coder encodeInt:_maximumRecents forKey:CPMaximumRecentsKey];
|
||||
[coder encodeObject:_searchMenuTemplate forKey:CPSearchMenuTemplateKey];
|
||||
if (_recentsAutosaveName)
|
||||
[coder encodeObject:_recentsAutosaveName forKey:CPRecentsAutosaveNameKey];
|
||||
if (_searchMenuTemplate)
|
||||
[coder encodeObject:_searchMenuTemplate forKey:CPSearchMenuTemplateKey];
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)coder
|
||||
@@ -696,8 +730,10 @@ var CPSearchButtonKey = @"CPSearchButtonKey",
|
||||
_sendsWholeSearchString = [coder decodeBoolForKey:CPSendsWholeSearchStringKey];
|
||||
_sendsSearchStringImmediately = [coder decodeBoolForKey:CPSendsSearchStringImmediatelyKey];
|
||||
_maximumRecents = [coder decodeIntForKey:CPMaximumRecentsKey];
|
||||
[self setSearchMenuTemplate:[coder decodeObjectForKey:CPSearchMenuTemplateKey]];
|
||||
[self resetCancelButton];
|
||||
var template = [coder decodeObjectForKey:CPSearchMenuTemplateKey];
|
||||
if (template)
|
||||
[self setSearchMenuTemplate:template];
|
||||
|
||||
[self setDelegate:self];
|
||||
|
||||
return self;
|
||||
|
||||
@@ -26,20 +26,8 @@
|
||||
|
||||
#include "CoreGraphics/CGGeometry.h"
|
||||
|
||||
/*
|
||||
@global
|
||||
@group CPSegmentSwitchTracking
|
||||
*/
|
||||
CPSegmentSwitchTrackingSelectOne = 0;
|
||||
/*
|
||||
@global
|
||||
@group CPSegmentSwitchTracking
|
||||
*/
|
||||
CPSegmentSwitchTrackingSelectAny = 1;
|
||||
/*
|
||||
@global
|
||||
@group CPSegmentSwitchTracking
|
||||
*/
|
||||
CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
/*!
|
||||
@@ -68,7 +56,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
+ (id)themeAttributes
|
||||
{
|
||||
return [CPDictionary dictionaryWithObjects:[CPCenterTextAlignment, CPCenterVerticalTextAlignment, CPImageLeft, CPScaleNone, _CGInsetMakeZero(), _CGInsetMakeZero(), nil, nil, nil, nil, 1.0, 24.0]
|
||||
return [CPDictionary dictionaryWithObjects:[CPCenterTextAlignment, CPCenterVerticalTextAlignment, CPImageLeft, CPScaleNone, _CGInsetMakeZero(), _CGInsetMakeZero(), [CPNull null], [CPNull null], [CPNull null], [CPNull null], 1.0, 24.0]
|
||||
forKeys:[@"alignment", @"vertical-alignment", @"image-position", @"image-scaling", @"bezel-inset", @"content-inset", @"left-segment-bezel-color", @"right-segment-bezel-color", @"center-segment-bezel-color", @"divider-bezel-color", @"divider-thickness", @"default-height"]];
|
||||
}
|
||||
|
||||
@@ -375,7 +363,10 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (void)setEnabled:(BOOL)isEnabled forSegment:(unsigned)aSegment
|
||||
{
|
||||
_segments[aSegment].enabled = isEnabled;
|
||||
if (isEnabled)
|
||||
_themeStates[aSegment] &= ~CPThemeStateDisabled;
|
||||
else
|
||||
_themeStates[aSegment] |= CPThemeStateDisabled;
|
||||
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
@@ -388,7 +379,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (BOOL)isEnabledForSegment:(unsigned)aSegment
|
||||
{
|
||||
return _segments[aSegment].enabled;
|
||||
return !(_themeStates[aSegment] & CPThemeStateDisabled)
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -462,30 +453,28 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
}
|
||||
else if (aName === "right-segment-bezel")
|
||||
{
|
||||
var lastSegmentLeftOffset = [self _leftOffsetForSegment:[self _indexOfLastSegment]];
|
||||
|
||||
return CPRectMake(lastSegmentLeftOffset + [self widthForSegment:[self _indexOfLastSegment]] - contentInset.right,
|
||||
return CPRectMake(CGRectGetWidth([self bounds]) - contentInset.right,
|
||||
bezelInset.top,
|
||||
contentInset.right,
|
||||
height);
|
||||
}
|
||||
else if (aName.substring(0, "segment-bezel".length) == "segment-bezel")
|
||||
else if (aName.indexOf("segment-bezel") === 0)
|
||||
{
|
||||
var segment = parseInt(aName.substring("segment-bezel-".length), 10),
|
||||
frame = CGRectCreateCopy(_segments[segment].frame);
|
||||
|
||||
if (segment == 0)
|
||||
if (segment === 0)
|
||||
{
|
||||
frame.origin.x += contentInset.left;
|
||||
frame.size.width -= contentInset.left;
|
||||
}
|
||||
|
||||
if (segment == _segments.length - 1)
|
||||
frame.size.width -= contentInset.right;
|
||||
if (segment === _segments.length - 1)
|
||||
frame.size.width = CGRectGetWidth([self bounds]) - contentInset.right - frame.origin.x;
|
||||
|
||||
return frame;
|
||||
}
|
||||
else if (aName.substring(0, "divider-bezel".length) == "divider-bezel")
|
||||
else if (aName.indexOf("divider-bezel") === 0)
|
||||
{
|
||||
var segment = parseInt(aName.substring("divider-bezel-".length), 10),
|
||||
width = [self widthForSegment:segment],
|
||||
@@ -494,7 +483,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
return CGRectMake(left + width, bezelInset.top, thickness, height);
|
||||
}
|
||||
else if (aName.substring(0, "segment-content".length) == "segment-content")
|
||||
else if (aName.indexOf("segment-content") === 0)
|
||||
{
|
||||
var segment = parseInt(aName.substring("segment-content-".length), 10);
|
||||
|
||||
@@ -517,8 +506,12 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
if (_segments.length <= 0)
|
||||
return;
|
||||
|
||||
var themeState = _themeStates[0];
|
||||
|
||||
themeState |= _themeState & CPThemeStateDisabled;
|
||||
|
||||
var leftCapColor = [self valueForThemeAttribute:@"left-segment-bezel-color"
|
||||
inState:_themeStates[0]];
|
||||
inState:themeState];
|
||||
|
||||
var leftBezelView = [self layoutEphemeralSubviewNamed:@"left-segment-bezel"
|
||||
positioned:CPWindowBelow
|
||||
@@ -526,8 +519,12 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
[leftBezelView setBackgroundColor:leftCapColor];
|
||||
|
||||
var themeState = _themeStates[_themeStates.length - 1];
|
||||
|
||||
themeState |= _themeState & CPThemeStateDisabled;
|
||||
|
||||
var rightCapColor = [self valueForThemeAttribute:@"right-segment-bezel-color"
|
||||
inState:_themeStates[_themeStates.length - 1]];
|
||||
inState:themeState];
|
||||
|
||||
var rightBezelView = [self layoutEphemeralSubviewNamed:@"right-segment-bezel"
|
||||
positioned:CPWindowBelow
|
||||
@@ -703,7 +700,16 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
while (count--)
|
||||
if (CGRectContainsPoint(_segments[count].frame, aPoint))
|
||||
return count;
|
||||
|
||||
|
||||
if (_segments.length)
|
||||
{
|
||||
var adjustedLastFrame = CGRectCreateCopy(_segments[_segments.length - 1].frame);
|
||||
adjustedLastFrame.size.width = CGRectGetWidth([self bounds]) - adjustedLastFrame.origin.x;
|
||||
|
||||
if (CGRectContainsPoint(adjustedLastFrame, aPoint))
|
||||
return _segments.length - 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -734,7 +740,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
if (_trackingSegment == -1)
|
||||
return;
|
||||
|
||||
if (CGRectContainsPoint(_segments[_trackingSegment].frame, location))
|
||||
if (_trackingSegment === [self testSegment:location])
|
||||
{
|
||||
if (_trackingMode == CPSegmentSwitchTrackingSelectAny)
|
||||
{
|
||||
@@ -765,10 +771,13 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
if (type == CPLeftMouseDown)
|
||||
{
|
||||
_trackingHighlighted = YES;
|
||||
_trackingSegment = [self testSegment:location];
|
||||
|
||||
[self drawSegmentBezel:_trackingSegment highlight:YES];
|
||||
var trackingSegment = [self testSegment:location];
|
||||
if (trackingSegment > -1 && [self isEnabledForSegment:trackingSegment])
|
||||
{
|
||||
_trackingHighlighted = YES;
|
||||
_trackingSegment = trackingSegment;
|
||||
[self drawSegmentBezel:_trackingSegment highlight:YES];
|
||||
}
|
||||
}
|
||||
|
||||
else if (type == CPLeftMouseDragged)
|
||||
@@ -776,12 +785,11 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
if (_trackingSegment == -1)
|
||||
return;
|
||||
|
||||
var highlighted = CGRectContainsPoint(_segments[_trackingSegment].frame, location);
|
||||
|
||||
var highlighted = [self testSegment:location] === _trackingSegment;
|
||||
if (highlighted != _trackingHighlighted)
|
||||
{
|
||||
_trackingHighlighted = highlighted;
|
||||
|
||||
|
||||
[self drawSegmentBezel:_trackingSegment highlight:_trackingHighlighted];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ CPCircularSlider = 1;
|
||||
|
||||
+ (id)themeAttributes
|
||||
{
|
||||
return [CPDictionary dictionaryWithObjects:[nil, _CGSizeMakeZero(), 0.0, nil]
|
||||
return [CPDictionary dictionaryWithObjects:[[CPNull null], _CGSizeMakeZero(), 0.0, [CPNull null]]
|
||||
forKeys:[@"knob-color", @"knob-size", @"track-width", @"track-color"]];
|
||||
}
|
||||
|
||||
|
||||
@@ -45,14 +45,16 @@
|
||||
CPTextField _saturationLabel;
|
||||
CPTextField _brightnessLabel;
|
||||
CPTextField _hexLabel;
|
||||
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
DOMElement _redValue;
|
||||
DOMElement _greenValue;
|
||||
DOMElement _blueValue;
|
||||
DOMElement _hueValue;
|
||||
DOMElement _saturationValue;
|
||||
DOMElement _brightnessValue;
|
||||
DOMElement _hexValue;
|
||||
DOMElement _hexValue;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (id)initWithPickerMask:(int)mask colorPanel:(CPColorPanel)owningColorPanel
|
||||
@@ -81,7 +83,8 @@
|
||||
[_redSlider setTarget: self];
|
||||
[_redSlider setAction: @selector(sliderChanged:)];
|
||||
[_redSlider setAutoresizingMask: CPViewWidthSizable];
|
||||
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var updateFunction = function(aDOMEvent)
|
||||
{
|
||||
if(isNaN(this.value))
|
||||
@@ -147,6 +150,7 @@
|
||||
|
||||
redValue._DOMElement.appendChild(_redValue);
|
||||
[_contentView addSubview: redValue];
|
||||
#endif
|
||||
|
||||
_greenLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 58, 15, 20)];
|
||||
[_greenLabel setStringValue: "G"];
|
||||
@@ -159,6 +163,7 @@
|
||||
[_greenSlider setAction: @selector(sliderChanged:)];
|
||||
[_greenSlider setAutoresizingMask: CPViewWidthSizable];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
//green value input box
|
||||
var greenValue = [[CPView alloc] initWithFrame: CPRectMake(aFrame.size.width - 45, 58, 45, 20)];
|
||||
[greenValue setAutoresizingMask: CPViewMinXMargin];
|
||||
@@ -168,6 +173,7 @@
|
||||
|
||||
greenValue._DOMElement.appendChild(_greenValue);
|
||||
[_contentView addSubview: greenValue];
|
||||
#endif
|
||||
|
||||
_blueLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 81, 15, 20)];
|
||||
[_blueLabel setStringValue: "B"];
|
||||
@@ -180,6 +186,7 @@
|
||||
[_blueSlider setAction: @selector(sliderChanged:)];
|
||||
[_blueSlider setAutoresizingMask: CPViewWidthSizable];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
//blue value input box
|
||||
var blueValue = [[CPView alloc] initWithFrame: CPRectMake(aFrame.size.width - 45, 81, 45, 20)];
|
||||
[blueValue setAutoresizingMask: CPViewMinXMargin];
|
||||
@@ -189,7 +196,7 @@
|
||||
|
||||
blueValue._DOMElement.appendChild(_blueValue);
|
||||
[_contentView addSubview: blueValue];
|
||||
|
||||
#endif
|
||||
_hsbLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 120, 190, 20)];
|
||||
[_hsbLabel setStringValue: "Hue, Saturation, Brightness"];
|
||||
[_hsbLabel setTextColor:[CPColor blackColor]];
|
||||
@@ -205,6 +212,7 @@
|
||||
[_hueSlider setAction: @selector(sliderChanged:)];
|
||||
[_hueSlider setAutoresizingMask: CPViewWidthSizable];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
//red value input box
|
||||
var hueValue = [[CPView alloc] initWithFrame: CPRectMake(aFrame.size.width - 45, 145, 45, 20)];
|
||||
[hueValue setAutoresizingMask: CPViewMinXMargin];
|
||||
@@ -214,7 +222,7 @@
|
||||
|
||||
hueValue._DOMElement.appendChild(_hueValue);
|
||||
[_contentView addSubview: hueValue];
|
||||
|
||||
#endif
|
||||
_saturationLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 168, 15, 20)];
|
||||
[_saturationLabel setStringValue: "S"];
|
||||
[_saturationLabel setTextColor:[CPColor blackColor]];
|
||||
@@ -226,6 +234,7 @@
|
||||
[_saturationSlider setAction: @selector(sliderChanged:)];
|
||||
[_saturationSlider setAutoresizingMask: CPViewWidthSizable];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
//green value input box
|
||||
var saturationValue = [[CPView alloc] initWithFrame: CPRectMake(aFrame.size.width - 45, 168, 45, 20)];
|
||||
[saturationValue setAutoresizingMask: CPViewMinXMargin];
|
||||
@@ -235,7 +244,7 @@
|
||||
|
||||
saturationValue._DOMElement.appendChild(_saturationValue);
|
||||
[_contentView addSubview: saturationValue];
|
||||
|
||||
#endif
|
||||
_brightnessLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 191, 15, 20)];
|
||||
[_brightnessLabel setStringValue: "B"];
|
||||
[_brightnessLabel setTextColor:[CPColor blackColor]];
|
||||
@@ -247,6 +256,7 @@
|
||||
[_brightnessSlider setAction: @selector(sliderChanged:)];
|
||||
[_brightnessSlider setAutoresizingMask: CPViewWidthSizable];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
//blue value input box
|
||||
var brightnessValue = [[CPView alloc] initWithFrame: CPRectMake(aFrame.size.width - 45, 191, 45, 20)];
|
||||
[brightnessValue setAutoresizingMask: CPViewMinXMargin];
|
||||
@@ -256,11 +266,12 @@
|
||||
|
||||
brightnessValue._DOMElement.appendChild(_brightnessValue);
|
||||
[_contentView addSubview: brightnessValue];
|
||||
|
||||
#endif
|
||||
_hexLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 230, 30, 20)];
|
||||
[_hexLabel setStringValue: "Hex"];
|
||||
[_hexLabel setTextColor:[CPColor blackColor]];
|
||||
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
//hex input box
|
||||
_hexValue = _redValue.cloneNode(false);
|
||||
_hexValue.style.top = "228px";
|
||||
@@ -289,7 +300,8 @@
|
||||
};
|
||||
|
||||
_contentView._DOMElement.appendChild(_hexValue);
|
||||
|
||||
#endif
|
||||
|
||||
[_contentView addSubview: _rgbLabel];
|
||||
[_contentView addSubview: _redLabel];
|
||||
[_contentView addSubview: _greenLabel];
|
||||
@@ -380,7 +392,9 @@
|
||||
|
||||
- (void)updateHex:(CPColor)aColor
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
_hexValue.value = [aColor hexString];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)updateRGBSliders:(CPColor)aColor
|
||||
@@ -394,6 +408,7 @@
|
||||
|
||||
- (void)updateLabels
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
_hueValue.value = ROUND([_hueSlider floatValue]);
|
||||
_saturationValue.value = ROUND([_saturationSlider floatValue]);
|
||||
_brightnessValue.value = ROUND([_brightnessSlider floatValue]);
|
||||
@@ -401,6 +416,7 @@
|
||||
_redValue.value = ROUND([_redSlider floatValue] * 255);
|
||||
_greenValue.value = ROUND([_greenSlider floatValue] * 255);
|
||||
_blueValue.value = ROUND([_blueSlider floatValue] * 255);
|
||||
#endif
|
||||
}
|
||||
|
||||
- (CPImage)provideNewButtonImage
|
||||
|
||||
@@ -75,9 +75,9 @@ var CPSplitViewHorizontalImage = nil,
|
||||
if (self = [super initWithFrame:aFrame])
|
||||
{
|
||||
_currentDivider = CPNotFound;
|
||||
|
||||
|
||||
_DOMDividerElements = [];
|
||||
|
||||
|
||||
[self _setVertical:YES];
|
||||
}
|
||||
|
||||
@@ -102,9 +102,9 @@ var CPSplitViewHorizontalImage = nil,
|
||||
// Just re-adjust evenly.
|
||||
var frame = [self frame],
|
||||
dividerThickness = [self dividerThickness];
|
||||
|
||||
|
||||
[self _postNotificationWillResize];
|
||||
|
||||
|
||||
var eachSize = ROUND((frame.size[_sizeComponent] - dividerThickness * (_subviews.length - 1)) / _subviews.length),
|
||||
index = 0,
|
||||
count = _subviews.length;
|
||||
@@ -115,9 +115,9 @@ var CPSplitViewHorizontalImage = nil,
|
||||
else
|
||||
for (; index < count; ++index)
|
||||
[_subviews[index] setFrame:CGRectMake(0, ROUND((eachSize + dividerThickness) * index), frame.size.width, eachSize)];
|
||||
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
|
||||
[self _postNotificationDidResize];
|
||||
|
||||
}
|
||||
@@ -144,20 +144,21 @@ var CPSplitViewHorizontalImage = nil,
|
||||
{
|
||||
if (_isPaneSplitter == shouldBePaneSplitter)
|
||||
return;
|
||||
|
||||
|
||||
_isPaneSplitter = shouldBePaneSplitter;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_DOMDividerElements = [];
|
||||
#endif
|
||||
if(_DOMDividerElements[_drawingDivider])
|
||||
[self _setupDOMDivider]
|
||||
|
||||
// The divider changes size when pane splitter mode is toggled, so the
|
||||
// subviews need to change size too.
|
||||
_needsResizeSubviews = YES;
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)didAddSubview:(CPView)aSubview
|
||||
{
|
||||
_needsResizeSubviews = YES;
|
||||
// [self adjustSubviews];
|
||||
}
|
||||
|
||||
- (BOOL)isSubviewCollapsed:(CPView)subview
|
||||
@@ -169,9 +170,9 @@ var CPSplitViewHorizontalImage = nil,
|
||||
{
|
||||
var frame = [_subviews[aDivider] frame],
|
||||
rect = CGRectMakeZero();
|
||||
|
||||
|
||||
rect.size = [self frame].size;
|
||||
|
||||
|
||||
rect.size[_sizeComponent] = [self dividerThickness];
|
||||
rect.origin[_originComponent] = frame.origin[_originComponent] + frame.size[_sizeComponent];
|
||||
|
||||
@@ -181,19 +182,19 @@ var CPSplitViewHorizontalImage = nil,
|
||||
- (CGRect)effectiveRectOfDividerAtIndex:(int)aDivider
|
||||
{
|
||||
var realRect = [self rectOfDividerAtIndex:aDivider];
|
||||
|
||||
|
||||
var padding = 2;
|
||||
|
||||
|
||||
realRect.size[_sizeComponent] += padding * 2;
|
||||
realRect.origin[_originComponent] -= padding;
|
||||
|
||||
|
||||
return realRect;
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
var count = [_subviews count] - 1;
|
||||
|
||||
|
||||
while ((count--) > 0)
|
||||
{
|
||||
_drawingDivider = count;
|
||||
@@ -207,22 +208,18 @@ var CPSplitViewHorizontalImage = nil,
|
||||
if (!_DOMDividerElements[_drawingDivider])
|
||||
{
|
||||
_DOMDividerElements[_drawingDivider] = document.createElement("div");
|
||||
_DOMDividerElements[_drawingDivider].style.cursor = "move";
|
||||
|
||||
if(_isVertical)
|
||||
_DOMDividerElements[_drawingDivider].style.cursor = [[CPCursor resizeLeftRightCursor] _cssString];
|
||||
else
|
||||
_DOMDividerElements[_drawingDivider].style.cursor = [[CPCursor resizeUpDownCursor] _cssString];
|
||||
|
||||
_DOMDividerElements[_drawingDivider].style.position = "absolute";
|
||||
_DOMDividerElements[_drawingDivider].style.backgroundRepeat = "repeat";
|
||||
|
||||
CPDOMDisplayServerAppendChild(_DOMElement, _DOMDividerElements[_drawingDivider]);
|
||||
|
||||
if (_isPaneSplitter)
|
||||
{
|
||||
_DOMDividerElements[_drawingDivider].style.backgroundColor = "#A5A5A5";
|
||||
_DOMDividerElements[_drawingDivider].style.backgroundImage = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_DOMDividerElements[_drawingDivider].style.backgroundColor = "";
|
||||
_DOMDividerElements[_drawingDivider].style.backgroundImage = "url('"+_dividerImagePath+"')";
|
||||
}
|
||||
[self _setupDOMDivider];
|
||||
}
|
||||
|
||||
CPDOMDisplayServerSetStyleLeftTop(_DOMDividerElements[_drawingDivider], NULL, _CGRectGetMinX(aRect), _CGRectGetMinY(aRect));
|
||||
@@ -230,6 +227,20 @@ var CPSplitViewHorizontalImage = nil,
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)_setupDOMDivider
|
||||
{
|
||||
if (_isPaneSplitter)
|
||||
{
|
||||
_DOMDividerElements[_drawingDivider].style.backgroundColor = "#A5A5A5";
|
||||
_DOMDividerElements[_drawingDivider].style.backgroundImage = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_DOMDividerElements[_drawingDivider].style.backgroundColor = "";
|
||||
_DOMDividerElements[_drawingDivider].style.backgroundImage = "url('"+_dividerImagePath+"')";
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewWillDraw
|
||||
{
|
||||
[self _adjustSubviewsWithCalculatedSize];
|
||||
@@ -239,9 +250,9 @@ var CPSplitViewHorizontalImage = nil,
|
||||
{
|
||||
if (!_needsResizeSubviews)
|
||||
return;
|
||||
|
||||
|
||||
_needsResizeSubviews = NO;
|
||||
|
||||
|
||||
var subviews = [self subviews],
|
||||
count = subviews.length,
|
||||
oldSize = CGSizeMakeZero();
|
||||
@@ -256,10 +267,10 @@ var CPSplitViewHorizontalImage = nil,
|
||||
oldSize.width = CGRectGetWidth([self frame]);
|
||||
oldSize.height += [self dividerThickness] * (count - 1);
|
||||
}
|
||||
|
||||
|
||||
while (count--)
|
||||
oldSize[_sizeComponent] += [subviews[count] frame].size[_sizeComponent];
|
||||
|
||||
|
||||
[self resizeSubviewsWithOldSize:oldSize];
|
||||
}
|
||||
|
||||
@@ -272,7 +283,7 @@ var CPSplitViewHorizontalImage = nil,
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:)])
|
||||
effectiveRect = [_delegate splitView:self effectiveRect:effectiveRect forDrawnRect:effectiveRect ofDividerAtIndex:anIndex];
|
||||
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:additionalEffectiveRectOfDividerAtIndex:)])
|
||||
additionalRect = [_delegate splitView:self additionalEffectiveRectOfDividerAtIndex:anIndex];
|
||||
|
||||
@@ -283,9 +294,9 @@ var CPSplitViewHorizontalImage = nil,
|
||||
{
|
||||
if ([self isHidden] || ![self hitTests] || !CGRectContainsPoint([self frame], aPoint))
|
||||
return nil;
|
||||
|
||||
|
||||
var point = [self convertPoint:aPoint fromView:[self superview]];
|
||||
|
||||
|
||||
var count = [_subviews count] - 1;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
@@ -512,8 +523,6 @@ var CPSplitViewHorizontalImage = nil,
|
||||
}
|
||||
else if (totalSizableSpace && !isSizable)
|
||||
viewFrame.size[_sizeComponent] = [view frame].size[_sizeComponent];
|
||||
else
|
||||
alert("SHOULD NEVER GET HERE");
|
||||
|
||||
bounds.origin[_originComponent] += viewFrame.size[_sizeComponent] + dividerThickness;
|
||||
|
||||
|
||||
@@ -247,6 +247,8 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
|
||||
[_labelsView tabView:self didAddTabViewItem:aTabViewItem];
|
||||
|
||||
[aTabViewItem _setTabView:self];
|
||||
|
||||
if ([_tabViewItems count] == 1)
|
||||
[self selectFirstTabViewItem:self];
|
||||
|
||||
@@ -263,9 +265,11 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
var index = [self indexOfTabViewItem:aTabViewItem];
|
||||
|
||||
[_tabViewItems removeObjectIdenticalTo:aTabViewItem];
|
||||
|
||||
|
||||
[_labelsView tabView:self didRemoveTabViewItemAtIndex:index];
|
||||
|
||||
[aTabViewItem _setTabView:nil];
|
||||
|
||||
if (_delegateSelectors & CPTabViewDidChangeNumberOfTabViewItemsSelector)
|
||||
[_delegate tabViewDidChangeNumberOfTabViewItems:self];
|
||||
}
|
||||
@@ -492,6 +496,14 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
return contentRect;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the receiver's delegate.
|
||||
*/
|
||||
- (id)delegate
|
||||
{
|
||||
return _delegate;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the delegate for this tab view.
|
||||
@param aDelegate the tab view's delegate
|
||||
|
||||
@@ -58,6 +58,8 @@ CPPressedTab = 2;
|
||||
|
||||
CPView _view;
|
||||
CPView _auxiliaryView;
|
||||
|
||||
CPTabView _tabView;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
@@ -168,6 +170,14 @@ CPPressedTab = 2;
|
||||
return _tabView;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (void)_setTabView:(CPTabView)aView
|
||||
{
|
||||
_tabView = aView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPTabViewItemIdentifierKey = "CPTabViewItemIdentifierKey",
|
||||
|
||||
@@ -27,22 +27,11 @@
|
||||
|
||||
@import "CPTableHeaderView.j"
|
||||
|
||||
#include "CoreGraphics/CGGeometry.h"
|
||||
|
||||
/*
|
||||
@global
|
||||
@class CPTableColumn
|
||||
*/
|
||||
CPTableColumnNoResizing = 0;
|
||||
/*
|
||||
@global
|
||||
@class CPTableColumn
|
||||
*/
|
||||
CPTableColumnAutoresizingMask = 1;
|
||||
/*
|
||||
@global
|
||||
@class CPTableColumn
|
||||
*/
|
||||
CPTableColumnUserResizingMask = 2;
|
||||
CPTableColumnAutoresizingMask = 1 << 0;
|
||||
CPTableColumnUserResizingMask = 1 << 1;
|
||||
|
||||
@implementation CPTableColumn : CPObject
|
||||
{
|
||||
@@ -54,12 +43,15 @@ CPTableColumnUserResizingMask = 2;
|
||||
float _width;
|
||||
float _minWidth;
|
||||
float _maxWidth;
|
||||
unsigned _resizingMask;
|
||||
|
||||
id _identifier;
|
||||
BOOL _isEditable;
|
||||
CPSortDescriptor _sortDescriptorPrototype;
|
||||
BOOL _isHidden;
|
||||
CPString _headerToolTip;
|
||||
|
||||
BOOL _disableResizingPosting @accessors(property=disableResizingPosting);
|
||||
}
|
||||
|
||||
- (id)init
|
||||
@@ -78,15 +70,27 @@ CPTableColumnUserResizingMask = 2;
|
||||
_width = 100.0;
|
||||
_minWidth = 10.0;
|
||||
_maxWidth = 1000000.0;
|
||||
|
||||
_resizingMask = CPTableColumnAutoresizingMask | CPTableColumnUserResizingMask;
|
||||
_disableResizingPosting = NO;
|
||||
|
||||
[self setIdentifier:anIdentifier];
|
||||
[self setHeaderView:[CPTextField new]];
|
||||
[self setDataView:[CPTextField new]];
|
||||
|
||||
var header = [[_CPTableColumnHeaderView alloc] initWithFrame:CGRectMakeZero()];
|
||||
[self setHeaderView:header];
|
||||
|
||||
var textDataView = [CPTextField new];
|
||||
[textDataView setLineBreakMode:CPLineBreakByTruncatingTail];
|
||||
[textDataView setValue:[CPColor colorWithHexString:@"333333"] forThemeAttribute:@"text-color"];
|
||||
[textDataView setValue:[CPColor whiteColor] forThemeAttribute:@"text-color" inState:CPThemeStateHighlighted];
|
||||
[textDataView setValue:[CPFont boldSystemFontOfSize:12] forThemeAttribute:@"font" inState:CPThemeStateHighlighted];
|
||||
[textDataView setValue:CPCenterVerticalTextAlignment forThemeAttribute:@"vertical-alignment"];
|
||||
[self setDataView:textDataView];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)setTableView:(CPTableView)aTableView
|
||||
{
|
||||
_tableView = aTableView;
|
||||
@@ -117,18 +121,23 @@ CPTableColumnUserResizingMask = 2;
|
||||
|
||||
if (tableView)
|
||||
{
|
||||
var index = [[tableView tableColumns] indexOfObjectIdenticalTo:self];
|
||||
|
||||
// FIXME: THIS IS HORRIBLE. Don't just reload everything when a table column changes, just relayout the changed widths.
|
||||
tableView._reloadAllRows = YES;
|
||||
tableView._dirtyTableColumnRangeIndex = tableView._dirtyTableColumnRangeIndex < 0 ? index : MIN(index, tableView._dirtyTableColumnRangeIndex);
|
||||
|
||||
var index = [[tableView tableColumns] indexOfObjectIdenticalTo:self],
|
||||
dirtyTableColumnRangeIndex = tableView._dirtyTableColumnRangeIndex;
|
||||
|
||||
if (dirtyTableColumnRangeIndex < 0)
|
||||
tableView._dirtyTableColumnRangeIndex = index;
|
||||
else
|
||||
tableView._dirtyTableColumnRangeIndex = MIN(index, tableView._dirtyTableColumnRangeIndex);
|
||||
|
||||
var rows = tableView._exposedRows,
|
||||
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 tile];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPTableViewColumnDidResizeNotification
|
||||
object:tableView
|
||||
userInfo:[CPDictionary dictionaryWithObjects:[self, oldWidth] forKeys:[@"CPTableColumn", "CPOldWidth"]]];
|
||||
|
||||
if (!_disableResizingPosting)
|
||||
[self _postDidResizeNotificationWithOldWidth:oldWidth];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +177,7 @@ CPTableColumnUserResizingMask = 2;
|
||||
_maxWidth = aMaxWidth;
|
||||
|
||||
var width = [self width],
|
||||
newWidth = MAX(width, [self maxWidth]);
|
||||
newWidth = MIN(width, [self maxWidth]);
|
||||
|
||||
if (width !== newWidth)
|
||||
[self setWidth:newWidth];
|
||||
@@ -184,7 +193,7 @@ CPTableColumnUserResizingMask = 2;
|
||||
_resizingMask = aResizingMask;
|
||||
}
|
||||
|
||||
- (float)resizingMask
|
||||
- (unsigned)resizingMask
|
||||
{
|
||||
return _resizingMask;
|
||||
}
|
||||
@@ -221,6 +230,22 @@ CPTableColumnUserResizingMask = 2;
|
||||
return _headerView;
|
||||
}
|
||||
|
||||
/*!
|
||||
This method set's the "prototype" view which will be used to create all table cells in this column.
|
||||
|
||||
It creates a snapshot of aView, using keyed archiving, which is then copied over and over for each
|
||||
individual cell that is shown. As a result, changes made after calling this method won't be reflected.
|
||||
|
||||
Example:
|
||||
|
||||
[tableColumn setDataView:someView]; // snapshot taken
|
||||
[[tableColumn dataView] setSomething:x]; //won't work
|
||||
|
||||
This doesn't work because the snapshot is taken before the new property is applied. Instead, do:
|
||||
|
||||
[someView setSomething:x];
|
||||
[tableColumn setDataView:someView];
|
||||
*/
|
||||
- (void)setDataView:(CPView)aView
|
||||
{
|
||||
if (_dataView === aView)
|
||||
@@ -256,9 +281,9 @@ CPTableColumnUserResizingMask = 2;
|
||||
var dataView = [self dataViewForRow:aRowIndex],
|
||||
dataViewUID = [dataView UID];
|
||||
|
||||
var x = [self tableView]._cachedDataViews[dataViewUID];
|
||||
if (x && x.length)
|
||||
return x.pop();
|
||||
var x = [self tableView]._cachedDataViews[dataViewUID];
|
||||
if (x && x.length)
|
||||
return x.pop();
|
||||
|
||||
// if we haven't cached an archive of the data view, do it now
|
||||
if (!_dataViewData[dataViewUID])
|
||||
@@ -266,7 +291,8 @@ return x.pop();
|
||||
|
||||
// unarchive the data view cache
|
||||
var newDataView = [CPKeyedUnarchiver unarchiveObjectWithData:_dataViewData[dataViewUID]];
|
||||
newDataView.identifier = dataViewUID;
|
||||
newDataView.identifier = dataViewUID;
|
||||
|
||||
return newDataView;
|
||||
}
|
||||
|
||||
@@ -346,6 +372,14 @@ newDataView.identifier = dataViewUID;
|
||||
return _headerToolTip;
|
||||
}
|
||||
|
||||
- (void)_postDidResizeNotificationWithOldWidth:(float)oldWidth
|
||||
{
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPTableViewColumnDidResizeNotification
|
||||
object:[self tableView]
|
||||
userInfo:[CPDictionary dictionaryWithObjects:[self, oldWidth] forKeys:[@"CPTableColumn", "CPOldWidth"]]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey",
|
||||
@@ -371,14 +405,11 @@ var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey",
|
||||
_maxWidth = [aCoder decodeFloatForKey:CPTableColumnMaxWidthKey];
|
||||
|
||||
[self setIdentifier:[aCoder decodeObjectForKey:CPTableColumnIdentifierKey]];
|
||||
// [self setHeaderView:[aCoder decodeObjectForKey:CPTableColumnHeaderViewKey]];
|
||||
// [self setDataView:[aCoder decodeObjectForKey:CPTableColumnDataViewKey]];
|
||||
[self setHeaderView:[aCoder decodeObjectForKey:CPTableColumnHeaderViewKey]];
|
||||
[self setDataView:[aCoder decodeObjectForKey:CPTableColumnDataViewKey]];
|
||||
[self setHeaderView:[aCoder decodeObjectForKey:CPTableColumnHeaderViewKey]];
|
||||
|
||||
[self setHeaderView:[CPTextField new]];
|
||||
[self setDataView:[CPTextField new]];
|
||||
|
||||
|
||||
// _resizingMask = [aCoder decodeBoolForKey:CPTableColumnResizingMaskKey];
|
||||
_resizingMask = [aCoder decodeBoolForKey:CPTableColumnResizingMaskKey];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -392,10 +423,10 @@ var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey",
|
||||
[aCoder encodeObject:_minWidth forKey:CPTableColumnMinWidthKey];
|
||||
[aCoder encodeObject:_maxWidth forKey:CPTableColumnMaxWidthKey];
|
||||
|
||||
// [aCoder encodeObject:_headerView forKey:CPTableColumnHeaderViewKey];
|
||||
// [aCoder encodeObject:_dataView forKey:CPTableColumnDataViewKey];
|
||||
[aCoder encodeObject:_headerView forKey:CPTableColumnHeaderViewKey];
|
||||
[aCoder encodeObject:_dataView forKey:CPTableColumnDataViewKey];
|
||||
|
||||
// [aCoder encodeObject:_resizingMask forKey:CPTableColumnResizingMaskKey];
|
||||
[aCoder encodeObject:_resizingMask forKey:CPTableColumnResizingMaskKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -23,14 +23,139 @@
|
||||
@import "CPTableColumn.j"
|
||||
@import "CPTableView.j"
|
||||
@import "CPView.j"
|
||||
|
||||
var CPThemeStatePressed = CPThemeState("pressed");
|
||||
|
||||
@implementation _CPTableColumnHeaderView : CPView
|
||||
{
|
||||
_CPImageAndTextView _textField;
|
||||
}
|
||||
|
||||
- (void)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self)
|
||||
{
|
||||
[self _init];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_init
|
||||
{
|
||||
_textField = [[_CPImageAndTextView alloc] initWithFrame:CGRectMake(5, 1, CGRectGetWidth([self bounds]) - 10, CGRectGetHeight([self bounds]) - 1)];
|
||||
[_textField setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
|
||||
|
||||
[_textField setLineBreakMode:CPLineBreakByTruncatingTail];
|
||||
[_textField setTextColor: [CPColor colorWithHexString: @"333333"]];
|
||||
[_textField setFont:[CPFont boldSystemFontOfSize:12.0]];
|
||||
[_textField setAlignment:CPLeftTextAlignment];
|
||||
[_textField setVerticalAlignment:CPCenterVerticalTextAlignment];
|
||||
[_textField setTextShadowColor:[CPColor whiteColor]];
|
||||
[_textField setTextShadowOffset:CGSizeMake(0,1)];
|
||||
|
||||
[self addSubview:_textField];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
var themeState = [self themeState];
|
||||
|
||||
if(themeState & CPThemeStateHighlighted && themeState & CPThemeStatePressed)
|
||||
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview-highlighted-pressed.png", CGSizeMake(1.0, 22.0))]];
|
||||
else if (themeState & CPThemeStateHighlighted)
|
||||
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview-highlighted.png", CGSizeMake(1.0, 22.0))]];
|
||||
else if (themeState & CPThemeStatePressed)
|
||||
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview-pressed.png", CGSizeMake(1.0, 22.0))]];
|
||||
else
|
||||
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
|
||||
}
|
||||
|
||||
- (void)setStringValue:(CPString)string
|
||||
{
|
||||
[_textField setText:string];
|
||||
}
|
||||
|
||||
- (CPString)stringValue
|
||||
{
|
||||
return [_textField text];
|
||||
}
|
||||
|
||||
- (void)textField
|
||||
{
|
||||
return _textField;
|
||||
}
|
||||
|
||||
- (void)sizeToFit
|
||||
{
|
||||
[_textField sizeToFit];
|
||||
}
|
||||
|
||||
- (void)setFont:(CPFont)aFont
|
||||
{
|
||||
[_textField setFont:aFont];
|
||||
}
|
||||
|
||||
- (void)setValue:(id)aValue forThemeAttribute:(id)aKey
|
||||
{
|
||||
[_textField setValue:aValue forThemeAttribute:aKey];
|
||||
}
|
||||
|
||||
- (void)_setIndicatorImage:(CPImage)anImage
|
||||
{
|
||||
if (anImage)
|
||||
{
|
||||
[_textField setImage:anImage];
|
||||
[_textField setImagePosition:CPImageRight];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_textField setImagePosition:CPNoImage];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringValueKey",
|
||||
_CPTableColumnHeaderViewFontKey = @"_CPTableColumnHeaderViewFontKey",
|
||||
_CPTableColumnHeaderViewImageKey = @"_CPTableColumnHeaderViewImageKey";
|
||||
|
||||
@implementation _CPTableColumnHeaderView (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
if (self = [super initWithCoder:aCoder])
|
||||
{
|
||||
[self _init];
|
||||
[self _setIndicatorImage:[aCoder decodeObjectForKey:_CPTableColumnHeaderViewImageKey]];
|
||||
[self setStringValue:[aCoder decodeObjectForKey:_CPTableColumnHeaderViewStringValueKey]];
|
||||
[self setFont:[aCoder decodeObjectForKey:_CPTableColumnHeaderViewFontKey]];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
[aCoder encodeObject:[_textField text] forKey:_CPTableColumnHeaderViewStringValueKey];
|
||||
[aCoder encodeObject:[_textField image] forKey:_CPTableColumnHeaderViewImageKey];
|
||||
[aCoder encodeObject:[_textField font] forKey:_CPTableColumnHeaderViewFontKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPTableHeaderView : CPView
|
||||
{
|
||||
int _resizedColumn @accessors(readonly, property=resizedColumn);
|
||||
int _draggedColumn @accessors(readonly, property=draggedColumn);
|
||||
int _pressedColumn @accessors(readonly, property=pressedColumn);
|
||||
|
||||
float _draggedDistance @accessors(readonly, property=draggedDistance);
|
||||
float _lastLocation;
|
||||
float _columnOldWidth;
|
||||
|
||||
CPTableView _tableView @accessors(property=tableView);
|
||||
}
|
||||
@@ -41,9 +166,14 @@
|
||||
|
||||
if (self)
|
||||
{
|
||||
_resizedColumn = CPNotFound;
|
||||
_draggedColumn = CPNotFound;
|
||||
_resizedColumn = -1;
|
||||
_draggedColumn = -1;
|
||||
_pressedColumn = -1;
|
||||
_draggedDistance = 0.0;
|
||||
_lastLocation = nil;
|
||||
_columnOldWidth = nil;
|
||||
|
||||
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -51,95 +181,323 @@
|
||||
|
||||
- (int)columnAtPoint:(CGPoint)aPoint
|
||||
{
|
||||
if (!CGRectContainsPoint([self bounds], aPoint))
|
||||
return CPNotFound;
|
||||
|
||||
// at this point, we can essentially ignore height, because all columns have equal heights
|
||||
// and that height is equal to the height of our own bounds, which we know we are inside of
|
||||
|
||||
var index = 0,
|
||||
count = [[_tableView tableColumns] count],
|
||||
tableSpacing = [_tableView intercellSpacing],
|
||||
tableColumns = [_tableView tableColumns],
|
||||
leftOffset = 0,
|
||||
pointX = aPoint.x;
|
||||
|
||||
for (; index < count; index++)
|
||||
{
|
||||
var width = [tableColumns[index] width] + tableSpacing.width;
|
||||
|
||||
if (pointX >= leftOffset && pointX < leftOffset + width)
|
||||
return index;
|
||||
|
||||
leftOffset += width;
|
||||
}
|
||||
|
||||
return CPNotFound;
|
||||
return [_tableView columnAtPoint:CGPointMake(aPoint.x, 0)];
|
||||
}
|
||||
|
||||
- (CGRect)headerRectOfColumn:(int)aColumnIndex
|
||||
{
|
||||
var tableColumns = [_tableView tableColumns],
|
||||
tableSpacing = [_tableView intercellSpacing],
|
||||
bounds = [self bounds];
|
||||
var tableColumns = [_tableView tableColumns];
|
||||
|
||||
if (aColumnIndex < 0 || aColumnIndex > [tableColumns count])
|
||||
[CPException raise:"invalid" reason:"tried to get headerRectOfColumn: on invalid column"];
|
||||
|
||||
bounds.size.width = [tableColumns[aColumnIndex] width] + tableSpacing.width;
|
||||
|
||||
while (--aColumnIndex >= 0)
|
||||
bounds.origin.x += [tableColumns[aColumnIndex] width] + tableSpacing.width;
|
||||
// UPDATE COLUMN RANGES ?
|
||||
|
||||
var tableRange = _tableView._tableColumnRanges[aColumnIndex],
|
||||
bounds = [self bounds];
|
||||
|
||||
var rMinX = ROUND(tableRange.location);
|
||||
bounds.origin.x = rMinX;
|
||||
bounds.size.width = FLOOR(tableRange.length + tableRange.location - rMinX);
|
||||
|
||||
return bounds;
|
||||
}
|
||||
|
||||
- (CGRect)_cursorRectForColumn:(int)column
|
||||
{
|
||||
if (column == -1 || !([_tableView._tableColumns[column] resizingMask] & CPTableColumnUserResizingMask))
|
||||
return CGRectMakeZero();
|
||||
|
||||
var rect = [self headerRectOfColumn:column];
|
||||
|
||||
rect.origin.x = CGRectGetMaxX(rect) - 5;
|
||||
rect.size.width = 20;
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (void)_setPressedColumn:(CPInteger)column
|
||||
{
|
||||
if (_pressedColumn != -1)
|
||||
{
|
||||
var headerView = [_tableView._tableColumns[_pressedColumn] headerView];
|
||||
[headerView unsetThemeState:CPThemeStatePressed];
|
||||
}
|
||||
|
||||
if (column != -1)
|
||||
{
|
||||
var headerView = [_tableView._tableColumns[column] headerView];
|
||||
[headerView setThemeState:CPThemeStatePressed];
|
||||
}
|
||||
|
||||
_pressedColumn = column;
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)theEvent
|
||||
{
|
||||
var mouseLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil],
|
||||
clickedColumn = [self columnAtPoint:mouseLocation];
|
||||
|
||||
// should we send column -1 ?
|
||||
[_tableView _sendDelegateDidMouseDownInHeader:clickedColumn];
|
||||
|
||||
var resizeLocation = CGPointMake(mouseLocation.x - 5, mouseLocation.y),
|
||||
resizedColumn = [self columnAtPoint:resizeLocation];
|
||||
|
||||
if (resizedColumn == -1)
|
||||
return;
|
||||
|
||||
// 2 different tracking methods: one for resizing/stop-resizing, another one for selection/reordering
|
||||
if ([_tableView allowsColumnResizing]
|
||||
&& CGRectContainsPoint([self _cursorRectForColumn:resizedColumn], mouseLocation))
|
||||
{
|
||||
_resizedColumn = resizedColumn;
|
||||
[_tableView._tableColumns[_resizedColumn] setDisableResizingPosting:YES];
|
||||
[_tableView setDisableAutomaticResizing:YES];
|
||||
[self trackResizeWithEvent:theEvent];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self _setPressedColumn:clickedColumn];
|
||||
[self trackMouseWithEvent:theEvent];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)trackMouseWithEvent:(CPEvent)theEvent
|
||||
{
|
||||
var type = [theEvent type];
|
||||
|
||||
if (type == CPLeftMouseUp)
|
||||
{
|
||||
var location = [self convertPoint:[theEvent locationInWindow] fromView:nil],
|
||||
clickedColumn = [self columnAtPoint:location];
|
||||
|
||||
[self _setPressedColumn:-1];
|
||||
|
||||
if (clickedColumn != -1)
|
||||
[_tableView _didClickTableColumn:clickedColumn modifierFlags:[theEvent modifierFlags]];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
[CPApp setTarget:self selector:@selector(trackMouseWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask | CPLeftMouseDownMask untilDate:nil inMode:nil dequeue:YES];
|
||||
}
|
||||
|
||||
- (void)trackResizeWithEvent:(CPEvent)anEvent
|
||||
{
|
||||
var location = [self convertPoint:[anEvent locationInWindow] fromView:nil],
|
||||
tableColumn = [[_tableView tableColumns] objectAtIndex:_resizedColumn],
|
||||
type = [anEvent type];
|
||||
|
||||
if (_lastLocation == nil)
|
||||
_lastLocation = location;
|
||||
|
||||
if (_columnOldWidth == nil)
|
||||
_columnOldWidth = [tableColumn width];
|
||||
|
||||
if (type === CPLeftMouseUp)
|
||||
{
|
||||
[self _updateResizeCursor:anEvent];
|
||||
|
||||
[tableColumn _postDidResizeNotificationWithOldWidth:_columnOldWidth];
|
||||
[tableColumn setDisableResizingPosting:NO];
|
||||
[_tableView setDisableAutomaticResizing:NO];
|
||||
|
||||
_resizedColumn = -1;
|
||||
_lastLocation = nil;
|
||||
_columnOldWidth = nil;
|
||||
|
||||
return;
|
||||
}
|
||||
else if (type === CPLeftMouseDragged)
|
||||
{
|
||||
var newWidth = [tableColumn width] + location.x - _lastLocation.x;
|
||||
|
||||
if (newWidth < [tableColumn minWidth])
|
||||
[[CPCursor resizeRightCursor] set];
|
||||
else if (newWidth > [tableColumn maxWidth])
|
||||
[[CPCursor resizeLeftCursor] set];
|
||||
else
|
||||
{
|
||||
_tableView._lastColumnShouldSnap = NO;
|
||||
[tableColumn setWidth:newWidth];
|
||||
// FIXME: there has to be a better way to do this...
|
||||
// We should refactor the auto resizing crap.
|
||||
// We need to figure out the exact cocoa behavior here though.
|
||||
_lastLocation = location;
|
||||
|
||||
[[CPCursor resizeLeftRightCursor] set];
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
|
||||
[CPApp setTarget:self selector:@selector(trackResizeWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES];
|
||||
}
|
||||
|
||||
- (void)_updateResizeCursor:(CPEvent)theEvent
|
||||
{
|
||||
// never get stuck in resize cursor mode (FIXME take out when we turn on tracking rects)
|
||||
if (![_tableView allowsColumnResizing] || ([theEvent type] === CPLeftMouseUp && ![[self window] acceptsMouseMovedEvents]))
|
||||
{
|
||||
[[CPCursor arrowCursor] set];
|
||||
return;
|
||||
}
|
||||
|
||||
var mouseLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil],
|
||||
mouseOverLocation = CGPointMake(mouseLocation.x - 5, mouseLocation.y),
|
||||
overColumn = [self columnAtPoint:mouseOverLocation];
|
||||
|
||||
if (overColumn >= 0 && CGRectContainsPoint([self _cursorRectForColumn:overColumn], mouseLocation))
|
||||
{
|
||||
var tableColumn = [[_tableView tableColumns] objectAtIndex:overColumn],
|
||||
width = [tableColumn width];
|
||||
|
||||
if (width == [tableColumn minWidth])
|
||||
[[CPCursor resizeRightCursor] set];
|
||||
else if (width == [tableColumn maxWidth])
|
||||
[[CPCursor resizeLeftCursor] set];
|
||||
else
|
||||
[[CPCursor resizeLeftRightCursor] set];
|
||||
}
|
||||
else
|
||||
[[CPCursor arrowCursor] set];
|
||||
}
|
||||
|
||||
- (void)viewDidMoveToWindow
|
||||
{
|
||||
//if ([_tableView allowsColumnResizing])
|
||||
// [[self window] setAcceptsMouseMovedEvents:YES];
|
||||
}
|
||||
|
||||
- (void)mouseEntered:(CPEvent)theEvent
|
||||
{
|
||||
[self _updateResizeCursor:theEvent];
|
||||
}
|
||||
|
||||
- (void)mouseMoved:(CPEvent)theEvent
|
||||
{
|
||||
[self _updateResizeCursor:theEvent];
|
||||
}
|
||||
|
||||
- (void)mouseExited:(CPEvent)theEvent
|
||||
{
|
||||
// FIXME: we should use CPCursor push/pop (if previous currentCursor != arrow).
|
||||
[[CPCursor arrowCursor] set];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
var tableColumns = [_tableView tableColumns],
|
||||
count = [tableColumns count],
|
||||
columnRect = [self bounds],
|
||||
spacing = [_tableView intercellSpacing];
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
var tableColumns = [_tableView tableColumns],
|
||||
count = [tableColumns count];
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var column = [tableColumns objectAtIndex:i],
|
||||
headerView = [column headerView];
|
||||
|
||||
columnRect.size.width = [column width] + spacing.width;
|
||||
|
||||
[headerView setFrame:columnRect];
|
||||
|
||||
columnRect.origin.x += [column width] + spacing.width;
|
||||
|
||||
[self addSubview:headerView];
|
||||
|
||||
var frame = [self headerRectOfColumn:i];
|
||||
frame.size.height -= 0.5;
|
||||
if (i > 0)
|
||||
{
|
||||
frame.origin.x += 0.5;
|
||||
frame.size.width -= 1;
|
||||
}
|
||||
|
||||
[headerView setFrame:frame];
|
||||
|
||||
if([headerView superview] != self)
|
||||
[self addSubview:headerView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)aRect
|
||||
{
|
||||
[[_tableView gridColor] setStroke];
|
||||
if (!_tableView)
|
||||
return;
|
||||
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
exposedColumnIndexes = exposedColumnIndexes = [_tableView columnIndexesInRect:aRect],
|
||||
columnsArray = [];
|
||||
exposedColumnIndexes = [_tableView columnIndexesInRect:aRect],
|
||||
columnsArray = [],
|
||||
tableColumns = [_tableView tableColumns],
|
||||
exposedTableColumns = _tableView._exposedColumns,
|
||||
firstIndex = [exposedTableColumns firstIndex],
|
||||
exposedRange = CPMakeRange(firstIndex, [exposedTableColumns lastIndex] - firstIndex + 1);
|
||||
|
||||
[exposedColumnIndexes getIndexes:columnsArray maxCount:-1 inIndexRange:nil];
|
||||
CGContextSetLineWidth(context, 1);
|
||||
CGContextSetStrokeColor(context, [_tableView gridColor]);
|
||||
|
||||
[exposedColumnIndexes getIndexes:columnsArray maxCount:-1 inIndexRange:exposedRange];
|
||||
|
||||
var columnArrayIndex = 0,
|
||||
columnArrayCount = columnsArray.length;
|
||||
|
||||
for(; columnArrayIndex < columnArrayCount; ++columnArrayIndex)
|
||||
columnArrayCount = columnsArray.length,
|
||||
columnMaxX;
|
||||
|
||||
CGContextBeginPath(context);
|
||||
for(; columnArrayIndex < columnArrayCount; columnArrayIndex++)
|
||||
{
|
||||
// grab each column rect and add horizontal lines
|
||||
var columnToStroke = [self headerRectOfColumn:columnArrayIndex];
|
||||
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context, ROUND(columnToStroke.origin.x + columnToStroke.size.width) - 0.5, ROUND(columnToStroke.origin.y) - 0.5);
|
||||
CGContextAddLineToPoint(context, ROUND(columnToStroke.origin.x + columnToStroke.size.width) - 0.5, ROUND(columnToStroke.origin.y + columnToStroke.size.height) - 0.5);
|
||||
CGContextSetLineWidth(context, 1);
|
||||
CGContextStrokePath(context);
|
||||
// grab each column rect and add vertical lines
|
||||
var columnIndex = columnsArray[columnArrayIndex],
|
||||
columnToStroke = [self headerRectOfColumn:columnIndex];
|
||||
|
||||
columnMaxX = CGRectGetMaxX(columnToStroke);
|
||||
|
||||
CGContextMoveToPoint(context, ROUND(columnMaxX) + 0.5, ROUND(CGRectGetMinY(columnToStroke)));
|
||||
CGContextAddLineToPoint(context, ROUND(columnMaxX) + 0.5, ROUND(CGRectGetMaxY(columnToStroke)));
|
||||
}
|
||||
|
||||
CGContextClosePath(context);
|
||||
CGContextStrokePath(context);
|
||||
|
||||
/*
|
||||
var maxY = CGRectGetMaxY([self bounds]);
|
||||
// draw normal gradient for remaining space
|
||||
if (supportsCanvasGradient)
|
||||
{
|
||||
aRect.origin.x = columnMaxX - 0.5;
|
||||
aRect.size.width -= columnMaxX;
|
||||
CGContextBeginPath(context);
|
||||
CGContextAddRect(context, CGRectMake(columnMaxX + 1, 0, CGRectGetMaxX([self bounds]) - columnMaxX, CGRectGetHeight([self bounds])));
|
||||
CGContextClosePath(context);
|
||||
CGContextDrawLinearGradient(context, [_CPTableColumnHeaderView headerGradient], CGPointMake(0,0), CGPointMake(0, maxY - 1),0);
|
||||
}
|
||||
|
||||
// Draw bottom line
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context, 0, maxY - 0.5);
|
||||
CGContextAddLineToPoint(context, CGRectGetMaxX([self bounds]), maxY - 0.5);
|
||||
CGContextClosePath(context);
|
||||
CGContextStrokePath(context);
|
||||
*/
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPTableHeaderViewTableViewKey = @"CPTableHeaderViewTableViewKey";
|
||||
|
||||
@implementation CPTableHeaderView (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
if (self = [super initWithCoder:aCoder])
|
||||
{
|
||||
_resizedColumn = -1;
|
||||
_draggedColumn = -1;
|
||||
_pressedColumn = -1;
|
||||
_draggedDistance = 0.0;
|
||||
_lastLocation = nil;
|
||||
_columnOldWidth = nil;
|
||||
_tableView = [aCoder decodeObjectForKey:CPTableHeaderViewTableViewKey];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
[aCoder encodeObject:_tableView forKey:CPTableHeaderViewTableViewKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -24,19 +24,12 @@
|
||||
@import "CPControl.j"
|
||||
@import "CPStringDrawing.j"
|
||||
@import "CPCompatibility.j"
|
||||
@import "_CPImageAndTextView.j"
|
||||
|
||||
#include "CoreGraphics/CGGeometry.h"
|
||||
#include "Platform/Platform.h"
|
||||
#include "Platform/DOM/CPDOMDisplayServer.h"
|
||||
|
||||
|
||||
CPLineBreakByWordWrapping = 0;
|
||||
CPLineBreakByCharWrapping = 1;
|
||||
CPLineBreakByClipping = 2;
|
||||
CPLineBreakByTruncatingHead = 3;
|
||||
CPLineBreakByTruncatingTail = 4;
|
||||
CPLineBreakByTruncatingMiddle = 5;
|
||||
|
||||
CPTextFieldSquareBezel = 0; /*! A textfield bezel with a squared corners. */
|
||||
CPTextFieldRoundedBezel = 1; /*! A textfield bezel with rounded corners. */
|
||||
|
||||
@@ -55,11 +48,7 @@ var CPTextFieldDOMInputElement = nil,
|
||||
CPTextFieldInputIsActive = NO,
|
||||
CPTextFieldCachedSelectStartFunction = nil,
|
||||
CPTextFieldCachedDragFunction = nil,
|
||||
|
||||
CPTextFieldBlurFunction = nil,
|
||||
CPTextFieldKeyUpFunction = nil,
|
||||
CPTextFieldKeyPressFunction = nil,
|
||||
CPTextFieldKeyDownFunction = nil;
|
||||
CPTextFieldBlurFunction = nil;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -173,7 +162,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
+ (id)themeAttributes
|
||||
{
|
||||
return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMake(2.0, 2.0, 2.0, 2.0), nil]
|
||||
return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMake(2.0, 2.0, 2.0, 2.0), [CPNull null]]
|
||||
forKeys:[@"bezel-inset", @"content-inset", @"bezel-color"]];
|
||||
}
|
||||
|
||||
@@ -246,10 +235,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
CPTextFieldDOMPasswordInputElement.style.outline = "none";
|
||||
CPTextFieldDOMPasswordInputElement.type = "password";
|
||||
|
||||
CPTextFieldDOMPasswordInputElement.attachEvent("on" + CPDOMEventKeyUp, CPTextFieldKeyUpFunction);
|
||||
CPTextFieldDOMPasswordInputElement.attachEvent("on" + CPDOMEventKeyDown, CPTextFieldKeyDownFunction);
|
||||
CPTextFieldDOMPasswordInputElement.attachEvent("on" + CPDOMEventKeyPress, CPTextFieldKeyPressFunction);
|
||||
|
||||
CPTextFieldDOMPasswordInputElement.onblur = CPTextFieldBlurFunction;
|
||||
}
|
||||
|
||||
@@ -498,6 +483,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
window.setTimeout(function()
|
||||
{
|
||||
element.focus();
|
||||
[self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]];
|
||||
CPTextFieldInputOwner = self;
|
||||
}, 0.0);
|
||||
|
||||
@@ -509,14 +495,12 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
if (document.attachEvent)
|
||||
{
|
||||
CPTextFieldCachedSelectStartFunction = document.body.onselectstart;
|
||||
CPTextFieldCachedDragFunction = document.body.ondrag;
|
||||
CPTextFieldCachedSelectStartFunction = [[self window] platformWindow]._DOMBodyElement.onselectstart;
|
||||
CPTextFieldCachedDragFunction = [[self window] platformWindow]._DOMBodyElement.ondrag;
|
||||
|
||||
document.body.ondrag = function () {};
|
||||
document.body.onselectstart = function () {};
|
||||
[[self window] platformWindow]._DOMBodyElement.ondrag = function () {};
|
||||
[[self window] platformWindow]._DOMBodyElement.onselectstart = function () {};
|
||||
}
|
||||
|
||||
[self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]];
|
||||
#endif
|
||||
|
||||
return YES;
|
||||
@@ -556,8 +540,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
CPTextFieldCachedSelectStartFunction = nil;
|
||||
CPTextFieldCachedDragFunction = nil;
|
||||
|
||||
document.body.ondrag = CPTextFieldCachedDragFunction
|
||||
document.body.onselectstart = CPTextFieldCachedSelectStartFunction
|
||||
[[self window] platformWindow]._DOMBodyElement.ondrag = CPTextFieldCachedDragFunction;
|
||||
[[self window] platformWindow]._DOMBodyElement.onselectstart = CPTextFieldCachedSelectStartFunction;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -577,6 +561,14 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*!
|
||||
Text fields require panels to become key window, so this returns \c YES.
|
||||
*/
|
||||
- (BOOL)needsPanelToBecomeKey
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
// Don't track! (ever?)
|
||||
@@ -639,6 +631,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
else
|
||||
[[self window] selectNextKeyView:self];
|
||||
|
||||
if ([[[self window] firstResponder] respondsToSelector:@selector(selectText:)])
|
||||
[[[self window] firstResponder] selectText:self];
|
||||
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:NO];
|
||||
}
|
||||
else
|
||||
@@ -688,9 +683,10 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
- (void)setObjectValue:(id)aValue
|
||||
{
|
||||
[super setObjectValue:aValue];
|
||||
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
if (CPTextFieldInputOwner === self)
|
||||
|
||||
if (CPTextFieldInputOwner === self || [[self window] firstResponder] === self)
|
||||
[self _inputElement].value = aValue;
|
||||
#endif
|
||||
|
||||
@@ -781,11 +777,151 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
#if PLATFORM(DOM)
|
||||
var element = [self _inputElement];
|
||||
|
||||
if (element.parentNode === _DOMElement && ([self isEditable] || [self isSelectable]))
|
||||
window.setTimeout(function() { element.select(); }, 0);
|
||||
if (([self isEditable] || [self isSelectable]))
|
||||
{
|
||||
if ([[self window] firstResponder] === self)
|
||||
window.setTimeout(function() { element.select(); }, 0);
|
||||
else
|
||||
{
|
||||
[[self window] makeFirstResponder:self];
|
||||
window.setTimeout(function() {[self selectText:sender];}, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)copy:(id)sender
|
||||
{
|
||||
if (![CPPlatform isBrowser])
|
||||
{
|
||||
var selectedRange = [self selectedRange];
|
||||
|
||||
if (selectedRange.length < 1)
|
||||
return;
|
||||
|
||||
var pasteboard = [CPPasteboard generalPasteboard],
|
||||
stringValue = [self stringValue],
|
||||
stringForPasting = [stringValue substringWithRange:selectedRange];
|
||||
|
||||
[pasteboard declareTypes:[CPStringPboardType] owner:nil];
|
||||
[pasteboard setString:stringForPasting forType:CPStringPboardType];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cut:(id)sender
|
||||
{
|
||||
if (![CPPlatform isBrowser])
|
||||
{
|
||||
[self copy:sender];
|
||||
[self deleteBackwards:sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)paste:(id)sender
|
||||
{
|
||||
if (![CPPlatform isBrowser])
|
||||
{
|
||||
var pasteboard = [CPPasteboard generalPasteboard];
|
||||
|
||||
if (![[pasteboard types] containsObject:CPStringPboardType])
|
||||
return;
|
||||
|
||||
[self deleteBackwards:sender];
|
||||
|
||||
var selectedRange = [self selectedRange],
|
||||
stringValue = [self stringValue],
|
||||
pasteString = [pasteboard stringForType:CPStringPboardType],
|
||||
newValue = [stringValue stringByReplacingCharactersInRange:selectedRange withString:pasteString];
|
||||
|
||||
[self setStringValue:newValue];
|
||||
[self setSelectedRange:CPMakeRange(selectedRange.location+pasteString.length, 0)];
|
||||
}
|
||||
}
|
||||
|
||||
- (CPRange)selectedRange
|
||||
{
|
||||
if ([[self window] firstResponder] !== self)
|
||||
return CPMakeRange(0, 0);
|
||||
|
||||
// we wrap this in try catch because firefox will throw an exception in certain instances
|
||||
try
|
||||
{
|
||||
var inputElement = [self _inputElement],
|
||||
selectionStart = inputElement.selectionStart,
|
||||
selectionEnd = inputElement.selectionEnd;
|
||||
|
||||
if ([selectionStart isKindOfClass:CPNumber])
|
||||
return CPMakeRange(selectionStart, selectionEnd - selectionStart);
|
||||
|
||||
// browsers which don't support selectionStart/selectionEnd (aka IE).
|
||||
var theDocument = inputElement.ownerDocument || inputElement.document,
|
||||
selectionRange = theDocument.selection.createRange(),
|
||||
range = inputElement.createTextRange();
|
||||
|
||||
if (range.inRange(selectionRange))
|
||||
{
|
||||
range.setEndPoint('EndToStart', selectionRange);
|
||||
return CPMakeRange(range.text.length, selectionRange.text.length);
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
// fall through to the return
|
||||
}
|
||||
|
||||
return CGMakeRange(0, 0);
|
||||
}
|
||||
|
||||
- (void)setSelectedRange:(CPRange)aRange
|
||||
{
|
||||
if (![[self window] firstResponder] === self)
|
||||
return;
|
||||
|
||||
var inputElement = [self _inputElement];
|
||||
|
||||
try
|
||||
{
|
||||
if ([inputElement.selectionStart isKindOfClass:CPNumber])
|
||||
{
|
||||
inputElement.selectionStart = aRange.location;
|
||||
inputElement.selectionEnd = CPMaxRange(aRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
// browsers which don't support selectionStart/selectionEnd (aka IE).
|
||||
var theDocument = inputElement.ownerDocument || inputElement.document,
|
||||
existingRange = theDocument.selection.createRange(),
|
||||
range = inputElement.createTextRange();
|
||||
|
||||
if (range.inRange(existingRange))
|
||||
{
|
||||
range.collapse(true);
|
||||
range.move('character', aRange.location);
|
||||
range.moveEnd('character', aRange.length);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
- (void)selectAll:(id)sender
|
||||
{
|
||||
[self selectText:sender];
|
||||
}
|
||||
|
||||
- (void)deleteBackwards:(id)sender
|
||||
{
|
||||
var selectedRange = [self selectedRange],
|
||||
stringValue = [self stringValue],
|
||||
newValue = [stringValue stringByReplacingCharactersInRange:selectedRange withString:""];
|
||||
|
||||
[self setStringValue:newValue];
|
||||
[self setSelectedRange:CPMakeRange(selectedRange.location, 0)];
|
||||
}
|
||||
|
||||
#pragma mark Setting the Delegate
|
||||
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
@@ -902,6 +1038,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
var view = [[_CPImageAndTextView alloc] initWithFrame:_CGRectMakeZero()];
|
||||
//[view setImagePosition:CPNoImage];
|
||||
|
||||
[view setHitTests:NO];
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
@import <Foundation/CPString.j>
|
||||
|
||||
@import <Foundation/CPKeyedUnarchiver.j>
|
||||
|
||||
var CPThemesByName = { },
|
||||
CPThemeDefaultTheme = nil;
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
if (self)
|
||||
{
|
||||
_bundle = [[CPBundle alloc] initWithPath:aURL + "/Info.plist"];
|
||||
_bundle = [[CPBundle alloc] initWithPath:aURL];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -65,7 +65,7 @@
|
||||
{
|
||||
var path = [aBundle pathForResource:themes[count]],
|
||||
unarchiver = [[_CPThemeKeyedUnarchiver alloc]
|
||||
initForReadingWithData:[CPData dataWithString:objj_files[path].contents]
|
||||
initForReadingWithData:[[CPURL URLWithString:path] staticResourceData]
|
||||
bundle:_bundle];
|
||||
|
||||
[unarchiver decodeObjectForKey:@"root"];
|
||||
|
||||
@@ -58,7 +58,7 @@ var CPToolbarConfigurationsByIdentifier = nil;
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPToolbar
|
||||
|
||||
|
||||
A CPToolbar is displayed at the top of a window with multiple
|
||||
buttons (tools) that offer the user quick access to features.
|
||||
|
||||
@@ -73,7 +73,7 @@ var CPToolbarConfigurationsByIdentifier = nil;
|
||||
Called to obtain the toolbar's default item identifiers. Required.
|
||||
@param toolbar the toolbar to obtain identifiers for
|
||||
@return an array of default item identifiers in the order on the toolbar
|
||||
|
||||
|
||||
@delegate - (CPToolbarItem)toolbar:(CPToolbar)toolbar itemForItemIdentifier:(CPString)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag;
|
||||
Called to obtain a toolbar item. Required.
|
||||
@param toolbar the toolbar the item belongs to
|
||||
@@ -89,19 +89,19 @@ var CPToolbarConfigurationsByIdentifier = nil;
|
||||
BOOL _showsBaselineSeparator;
|
||||
BOOL _allowsUserCustomization;
|
||||
BOOL _isVisible;
|
||||
|
||||
|
||||
id _delegate;
|
||||
|
||||
|
||||
CPArray _itemIdentifiers;
|
||||
|
||||
|
||||
CPDictionary _identifiedItems;
|
||||
CPArray _defaultItems;
|
||||
CPArray _allowedItems;
|
||||
CPArray _selectableItems;
|
||||
|
||||
|
||||
CPArray _items;
|
||||
CPArray _itemsSortedByVisibilityPriority;
|
||||
|
||||
|
||||
CPView _toolbarView;
|
||||
CPWindow _window;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ var CPToolbarConfigurationsByIdentifier = nil;
|
||||
{
|
||||
if (self != [CPToolbar class])
|
||||
return;
|
||||
|
||||
|
||||
CPToolbarsByIdentifier = [CPDictionary dictionary];
|
||||
CPToolbarConfigurationsByIdentifier = [CPDictionary dictionary];
|
||||
}
|
||||
@@ -120,13 +120,13 @@ var CPToolbarConfigurationsByIdentifier = nil;
|
||||
+ (void)_addToolbar:(CPToolbar)toolbar forIdentifier:(CPString)identifier
|
||||
{
|
||||
var toolbarsSharingIdentifier = [CPToolbarsByIdentifier objectForKey:identifier];
|
||||
|
||||
|
||||
if (!toolbarsSharingIdentifier)
|
||||
{
|
||||
toolbarsSharingIdentifier = []
|
||||
[CPToolbarsByIdentifier setObject:toolbarsSharingIdentifier forKey:identifier];
|
||||
}
|
||||
|
||||
|
||||
[toolbarsSharingIdentifier addObject:toolbar];
|
||||
}
|
||||
|
||||
@@ -143,17 +143,17 @@ var CPToolbarConfigurationsByIdentifier = nil;
|
||||
- (id)initWithIdentifier:(CPString)anIdentifier
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
||||
if (self)
|
||||
{
|
||||
_items = [];
|
||||
|
||||
|
||||
_identifier = anIdentifier;
|
||||
_isVisible = YES;
|
||||
|
||||
|
||||
[CPToolbar _addToolbar:self forIdentifier:_identifier];
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ var CPToolbarConfigurationsByIdentifier = nil;
|
||||
*/
|
||||
- (void)setDisplayMode:(CPToolbarDisplayMode)aDisplayMode
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -198,7 +198,7 @@ var CPToolbarConfigurationsByIdentifier = nil;
|
||||
{
|
||||
if (_isVisible === aFlag)
|
||||
return;
|
||||
|
||||
|
||||
_isVisible = aFlag;
|
||||
|
||||
[_window _noteToolbarChanged];
|
||||
@@ -220,11 +220,11 @@ var CPToolbarConfigurationsByIdentifier = nil;
|
||||
*/
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
{
|
||||
if (_delegate == aDelegate)
|
||||
if (_delegate === aDelegate)
|
||||
return;
|
||||
|
||||
|
||||
_delegate = aDelegate;
|
||||
|
||||
|
||||
[self _reloadToolbarItems];
|
||||
}
|
||||
|
||||
@@ -240,57 +240,68 @@ var CPToolbarConfigurationsByIdentifier = nil;
|
||||
if (!_toolbarView)
|
||||
{
|
||||
_toolbarView = [[_CPToolbarView alloc] initWithFrame:CPRectMake(0.0, 0.0, 1200.0, 59.0)];
|
||||
|
||||
|
||||
[_toolbarView setToolbar:self];
|
||||
[_toolbarView setAutoresizingMask:CPViewWidthSizable];
|
||||
[_toolbarView reloadToolbarItems];
|
||||
}
|
||||
|
||||
|
||||
return _toolbarView;
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
- (void)_reloadToolbarItems
|
||||
{
|
||||
if (!_delegate)
|
||||
return;
|
||||
// As of OS X 10.5 (Leopard), toolbar items can be set in IB and a
|
||||
// toolbar delegate is optional. Toolbar items can be combined from
|
||||
// both IB and a delegate (see Apple's NSToolbar guide for IB, for more details).
|
||||
|
||||
var count = [_itemIdentifiers count];
|
||||
|
||||
if (!count)
|
||||
// _defaultItems may have been loaded from Cib
|
||||
_itemIdentifiers = [_defaultItems valueForKey:@"itemIdentifier"] || [];
|
||||
|
||||
if (_delegate)
|
||||
{
|
||||
_itemIdentifiers = [[_delegate toolbarDefaultItemIdentifiers:self] mutableCopy];
|
||||
count = [_itemIdentifiers count];
|
||||
var itemIdentifiersFromDelegate = [[_delegate toolbarDefaultItemIdentifiers:self] mutableCopy];
|
||||
|
||||
if (itemIdentifiersFromDelegate)
|
||||
_itemIdentifiers = [_itemIdentifiers arrayByAddingObjectsFromArray:itemIdentifiersFromDelegate];
|
||||
}
|
||||
|
||||
var index = 0,
|
||||
count = [_itemIdentifiers count];
|
||||
|
||||
_items = [];
|
||||
|
||||
var index = 0;
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var identifier = _itemIdentifiers[index],
|
||||
item = [CPToolbarItem _standardItemWithItemIdentifier:identifier];
|
||||
|
||||
|
||||
// May come from a Cib.
|
||||
if (!item)
|
||||
item = [_identifiedItems objectForKey:identifier];
|
||||
|
||||
if (!item && _delegate)
|
||||
item = [_delegate toolbar:self itemForItemIdentifier:identifier willBeInsertedIntoToolbar:YES];
|
||||
|
||||
|
||||
item = [item copy];
|
||||
|
||||
if (item == nil)
|
||||
|
||||
if (item === nil)
|
||||
[CPException raise:CPInvalidArgumentException
|
||||
reason:sprintf(@"_delegate %s returned nil toolbar item returned for identifier %s", _delegate, identifier)];
|
||||
|
||||
reason:@"Toolbar delegate " + _delegate + " returned nil toolbar item for identifier \"" + identifier + "\""];
|
||||
|
||||
item._toolbar = self;
|
||||
|
||||
[_items addObject:item];
|
||||
}
|
||||
|
||||
|
||||
// _items = [[self _defaultToolbarItems] mutableCopy];
|
||||
|
||||
|
||||
// Store items sorted by priority. We want items to be removed first at the end of the array,
|
||||
// items to be removed last at the front.
|
||||
|
||||
|
||||
_itemsSortedByVisibilityPriority = [_items sortedArrayUsingFunction:_CPToolbarItemVisibilityPriorityCompare context:NULL];
|
||||
|
||||
|
||||
[_toolbarView reloadToolbarItems];
|
||||
}
|
||||
|
||||
@@ -339,9 +350,9 @@ var CPToolbarConfigurationsByIdentifier = nil;
|
||||
item = [[_delegate toolbar:self itemForItemIdentifier:identifier willBeInsertedIntoToolbar:toolbar] copy];
|
||||
if (!item)
|
||||
[CPException raise:CPInvalidArgumentException
|
||||
reason:sprintf(@"_delegate %s returned nil toolbar item returned for identifier %s", _delegate, identifier)];
|
||||
reason:@"Toolbar delegate " + _delegate + " returned nil toolbar item for identifier " + identifier];
|
||||
}
|
||||
|
||||
|
||||
[_identifiedItems setObject:item forKey:identifier];
|
||||
}
|
||||
|
||||
@@ -350,7 +361,7 @@ var CPToolbarConfigurationsByIdentifier = nil;
|
||||
|
||||
/* @ignore */
|
||||
- (id)_itemsWithIdentifiers:(CPArray)identifiers
|
||||
{
|
||||
{
|
||||
var items = [];
|
||||
for (var i = 0; i < identifiers.length; i++)
|
||||
[items addObject:[self _itemForItemIdentifier:identifiers[i] willBeInsertedIntoToolbar:NO]];
|
||||
@@ -359,28 +370,62 @@ var CPToolbarConfigurationsByIdentifier = nil;
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
-(id)_defaultToolbarItems
|
||||
- (id)_defaultToolbarItems
|
||||
{
|
||||
if (!_defaultItems)
|
||||
if ([_delegate respondsToSelector:@selector(toolbarDefaultItemIdentifiers:)])
|
||||
_defaultItems = [self _itemsWithIdentifiers:[_delegate toolbarDefaultItemIdentifiers:self]];
|
||||
|
||||
if (!_defaultItems && [_delegate respondsToSelector:@selector(toolbarDefaultItemIdentifiers:)])
|
||||
{
|
||||
_defaultItems = [];
|
||||
|
||||
var identifiers = [_delegate toolbarDefaultItemIdentifiers:self],
|
||||
index = 0,
|
||||
count = [identifiers count];
|
||||
|
||||
for (; index < count; ++index)
|
||||
[_defaultItems addObject:[self _itemForItemIdentifier:identifiers[index] willBeInsertedIntoToolbar:NO]];
|
||||
}
|
||||
|
||||
return _defaultItems;
|
||||
}
|
||||
|
||||
/*!
|
||||
Notifies the toolbar that an item has been changed. This will cause the toolbar to reload its items.
|
||||
@param anItem the item that has been changed
|
||||
*/
|
||||
- (void)toolbarItemDidChange:(CPToolbarItem)anItem
|
||||
{
|
||||
if ([_identifiedItems objectForKey:[anItem itemIdentifier]])
|
||||
[_identifiedItems setObject:anItem forKey:[anItem itemIdentifier]];
|
||||
|
||||
var index = 0,
|
||||
count = [_items count];
|
||||
|
||||
for (; index <= count; ++index)
|
||||
{
|
||||
var item = _items[index];
|
||||
|
||||
if ([item itemIdentifier] === [anItem itemIdentifier])
|
||||
{
|
||||
_items[index] = anItem;
|
||||
_itemsSortedByVisibilityPriority = [_items sortedArrayUsingFunction:_CPToolbarItemVisibilityPriorityCompare context:NULL];
|
||||
|
||||
[_toolbarView reloadToolbarItems];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
var CPToolbarIdentifierKey = "CPToolbarIdentifierKey",
|
||||
CPToolbarDisplayModeKey = "CPToolbarDisplayModeKey",
|
||||
CPToolbarShowsBaselineSeparatorKey = "CPToolbarShowsBaselineSeparatorKey",
|
||||
CPToolbarAllowsUserCustomizationKey = "CPToolbarAllowsUserCustomizationKey",
|
||||
CPToolbarIsVisibleKey = "CPToolbarIsVisibleKey",
|
||||
CPToolbarDelegateKey = "CPToolbarDelegateKey",
|
||||
CPToolbarIdentifiedItemsKey = "CPToolbarIdentifiedItemsKey",
|
||||
CPToolbarDefaultItemsKey = "CPToolbarDefaultItemsKey",
|
||||
CPToolbarAllowedItemsKey = "CPToolbarAllowedItemsKey",
|
||||
CPToolbarSelectableItemsKey = "CPToolbarSelectableItemsKey";
|
||||
var CPToolbarIdentifierKey = @"CPToolbarIdentifierKey",
|
||||
CPToolbarDisplayModeKey = @"CPToolbarDisplayModeKey",
|
||||
CPToolbarShowsBaselineSeparatorKey = @"CPToolbarShowsBaselineSeparatorKey",
|
||||
CPToolbarAllowsUserCustomizationKey = @"CPToolbarAllowsUserCustomizationKey",
|
||||
CPToolbarIsVisibleKey = @"CPToolbarIsVisibleKey",
|
||||
CPToolbarDelegateKey = @"CPToolbarDelegateKey",
|
||||
CPToolbarIdentifiedItemsKey = @"CPToolbarIdentifiedItemsKey",
|
||||
CPToolbarDefaultItemsKey = @"CPToolbarDefaultItemsKey",
|
||||
CPToolbarAllowedItemsKey = @"CPToolbarAllowedItemsKey",
|
||||
CPToolbarSelectableItemsKey = @"CPToolbarSelectableItemsKey";
|
||||
|
||||
@implementation CPToolbar (CPCoding)
|
||||
|
||||
@@ -391,26 +436,39 @@ var CPToolbarIdentifierKey = "CPToolbarIdentifierKey",
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
|
||||
if (self)
|
||||
{
|
||||
_identifier = [aCoder decodeObjectForKey:CPToolbarIdentifierKey];
|
||||
_displayMode = [aCoder decodeIntForKey:CPToolbarDisplayModeKey];
|
||||
_showsBaselineSeparator = [aCoder decodeBoolForKey:CPToolbarShowsBaselineSeparatorKey];
|
||||
_allowsUserCustomization = [aCoder decodeBoolForKey:CPToolbarAllowsUserCustomizationKey];
|
||||
_isVisible = [aCoder decodeBoolForKey:CPToolbarIsVisibleKey];
|
||||
|
||||
_identifiedItems = [aCoder decodeObjectForKey:CPToolbarIdentifiedItemsKey];
|
||||
_defaultItems = [aCoder decodeObjectForKey:CPToolbarDefaultItemsKey];
|
||||
_allowedItems = [aCoder decodeObjectForKey:CPToolbarAllowedItemsKey];
|
||||
_selectableItems = [aCoder decodeObjectForKey:CPToolbarSelectableItemsKey];
|
||||
|
||||
_identifier = [aCoder decodeObjectForKey:CPToolbarIdentifierKey];
|
||||
_displayMode = [aCoder decodeIntForKey:CPToolbarDisplayModeKey];
|
||||
_showsBaselineSeparator = [aCoder decodeBoolForKey:CPToolbarShowsBaselineSeparatorKey];
|
||||
_allowsUserCustomization = [aCoder decodeBoolForKey:CPToolbarAllowsUserCustomizationKey];
|
||||
_isVisible = [aCoder decodeBoolForKey:CPToolbarIsVisibleKey];
|
||||
|
||||
_identifiedItems = [aCoder decodeObjectForKey:CPToolbarIdentifiedItemsKey];
|
||||
_defaultItems = [aCoder decodeObjectForKey:CPToolbarDefaultItemsKey];
|
||||
_allowedItems = [aCoder decodeObjectForKey:CPToolbarAllowedItemsKey];
|
||||
_selectableItems = [aCoder decodeObjectForKey:CPToolbarSelectableItemsKey];
|
||||
|
||||
[[_identifiedItems allValues] makeObjectsPerformSelector:@selector(_setToolbar:) withObject:self];
|
||||
|
||||
_items = [];
|
||||
|
||||
[CPToolbar _addToolbar:self forIdentifier:_identifier];
|
||||
|
||||
|
||||
// This won't come from a Cib, but can come from manual encoding.
|
||||
[self setDelegate:[aCoder decodeObjectForKey:CPToolbarDelegateKey]];
|
||||
|
||||
// Because we don't know if a delegate will be set later (it is optional
|
||||
// as of OS X 10.5), we need to call -_reloadToolbarItems here.
|
||||
// In order to load any toolbar items that may have been configured in the
|
||||
// Cib. Unfortunatelly this means that if there is a delegate
|
||||
// specified, it will be read later and the resulting call to -setDelegate:
|
||||
// will cause -_reloadToolbarItems] to run again :-(
|
||||
// FIXME: Can we make this better?
|
||||
[self _reloadToolbarItems];
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -420,18 +478,18 @@ var CPToolbarIdentifierKey = "CPToolbarIdentifierKey",
|
||||
*/
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[aCoder encodeObject:_identifier forKey:CPToolbarIdentifierKey];
|
||||
[aCoder encodeInt:_displayMode forKey:CPToolbarDisplayModeKey];
|
||||
[aCoder encodeBool:_showsBaselineSeparator forKey:CPToolbarShowsBaselineSeparatorKey];
|
||||
[aCoder encodeObject:_identifier forKey:CPToolbarIdentifierKey];
|
||||
[aCoder encodeInt:_displayMode forKey:CPToolbarDisplayModeKey];
|
||||
[aCoder encodeBool:_showsBaselineSeparator forKey:CPToolbarShowsBaselineSeparatorKey];
|
||||
[aCoder encodeBool:_allowsUserCustomization forKey:CPToolbarAllowsUserCustomizationKey];
|
||||
[aCoder encodeBool:_isVisible forKey:CPToolbarIsVisibleKey];
|
||||
|
||||
[aCoder encodeObject:_identifiedItems forKey:CPToolbarIdentifiedItemsKey];
|
||||
[aCoder encodeObject:_defaultItems forKey:CPToolbarDefaultItemsKey];
|
||||
[aCoder encodeObject:_allowedItems forKey:CPToolbarAllowedItemsKey];
|
||||
[aCoder encodeObject:_selectableItems forKey:CPToolbarSelectableItemsKey];
|
||||
|
||||
[aCoder encodeConditionalObject:_delegate forKey:CPToolbarDelegateKey];
|
||||
[aCoder encodeBool:_isVisible forKey:CPToolbarIsVisibleKey];
|
||||
|
||||
[aCoder encodeObject:_identifiedItems forKey:CPToolbarIdentifiedItemsKey];
|
||||
[aCoder encodeObject:_defaultItems forKey:CPToolbarDefaultItemsKey];
|
||||
[aCoder encodeObject:_allowedItems forKey:CPToolbarAllowedItemsKey];
|
||||
[aCoder encodeObject:_selectableItems forKey:CPToolbarSelectableItemsKey];
|
||||
|
||||
[aCoder encodeConditionalObject:_delegate forKey:CPToolbarDelegateKey];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -454,10 +512,10 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
@implementation _CPToolbarView : CPView
|
||||
{
|
||||
CPToolbar _toolbar;
|
||||
|
||||
|
||||
CPIndexSet _flexibleWidthIndexes;
|
||||
CPIndexSet _visibleFlexibleWidthIndexes;
|
||||
|
||||
|
||||
CPDictionary _itemInfos;
|
||||
JSObject _viewsForToolbarItems;
|
||||
|
||||
@@ -467,7 +525,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
CPPopUpButton _additionalItemsButton;
|
||||
CPColor _labelColor;
|
||||
CPColor _labelShadowColor;
|
||||
|
||||
|
||||
float _minWidth;
|
||||
|
||||
BOOL _FIXME_isHUD;
|
||||
@@ -475,11 +533,11 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self != [_CPToolbarView class])
|
||||
if (self !== [_CPToolbarView class])
|
||||
return;
|
||||
|
||||
|
||||
var bundle = [CPBundle bundleForClass:self];
|
||||
|
||||
|
||||
_CPToolbarViewExtraItemsImage = [[CPImage alloc] initWithContentsOfFile: [bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsImage.png"] size: CPSizeMake(10.0, 15.0)];
|
||||
|
||||
_CPToolbarViewExtraItemsAlternateImage = [[CPImage alloc] initWithContentsOfFile: [bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsAlternateImage.png"] size:CGSizeMake(10.0, 15.0)];
|
||||
@@ -488,23 +546,23 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
self = [super initWithFrame:aFrame];
|
||||
|
||||
|
||||
if (self)
|
||||
{
|
||||
_minWidth = 0;
|
||||
|
||||
|
||||
_labelColor = [CPColor blackColor];
|
||||
_labelShadowColor = [CPColor colorWithWhite:1.0 alpha:0.75];
|
||||
|
||||
|
||||
_additionalItemsButton = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 10.0, 15.0) pullsDown:YES];
|
||||
[_additionalItemsButton setBordered:NO];
|
||||
|
||||
[_additionalItemsButton setImagePosition:CPImageOnly];
|
||||
[[_additionalItemsButton menu] setShowsStateColumn:NO];
|
||||
|
||||
|
||||
[_additionalItemsButton setAlternateImage:_CPToolbarViewExtraItemsAlternateImage];
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -551,17 +609,17 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
minWidth = _minWidth,
|
||||
// FIXME: This should be a CPSet.
|
||||
invisibleItemsSortedByPriority = [];
|
||||
|
||||
|
||||
_visibleItems = items;
|
||||
|
||||
// We only have hidden items if our actual width is smaller than our
|
||||
// We only have hidden items if our actual width is smaller than our
|
||||
// minimum width for hiding items.
|
||||
if (itemsWidth < minWidth)
|
||||
{
|
||||
itemsWidth -= TOOLBAR_EXTRA_ITEMS_WIDTH;
|
||||
|
||||
|
||||
_visibleItems = [_visibleItems copy];
|
||||
|
||||
|
||||
var itemsSortedByVisibilityPriority = [_toolbar itemsSortedByVisibilityPriority],
|
||||
count = itemsSortedByVisibilityPriority.length;
|
||||
|
||||
@@ -620,18 +678,18 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
|
||||
[view setHidden:NO];
|
||||
}
|
||||
|
||||
|
||||
var remainingSpace = itemsWidth - minWidth,
|
||||
proportionate = 0.0;
|
||||
|
||||
// Continue to distribute space proportionately while we have it,
|
||||
// and there are flexible items left that want it. (Those with max
|
||||
// Continue to distribute space proportionately while we have it,
|
||||
// and there are flexible items left that want it. (Those with max
|
||||
// widths may eventually not want it anymore).
|
||||
while (remainingSpace && [flexibleItemIndexes count])
|
||||
{
|
||||
// Divy out the space.
|
||||
proportionate += remainingSpace / [flexibleItemIndexes count];
|
||||
|
||||
|
||||
// Reset the remaining space to 0
|
||||
remainingSpace = 0.0;
|
||||
|
||||
@@ -654,7 +712,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
[view setFrameSize:CGSizeMake(constrainedWidth, height)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now that all the visible items are the correct width, give them their final frames.
|
||||
var index = 0,
|
||||
count = _visibleItems.length,
|
||||
@@ -676,9 +734,9 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
{
|
||||
var index = 0,
|
||||
count = [items count];
|
||||
|
||||
|
||||
_invisibleItems = [];
|
||||
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var item = items[index];
|
||||
@@ -732,18 +790,17 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
hasNonSeparatorItem = YES;
|
||||
|
||||
[_additionalItemsButton addItemWithTitle:[item label]];
|
||||
|
||||
|
||||
var menuItem = [_additionalItemsButton itemArray][index + 1];
|
||||
|
||||
|
||||
[menuItem setImage:[item image]];
|
||||
|
||||
|
||||
[menuItem setTarget:[item target]];
|
||||
[menuItem setAction:[item action]];
|
||||
}
|
||||
}
|
||||
else
|
||||
[_additionalItemsButton removeFromSuperview];
|
||||
|
||||
}
|
||||
|
||||
- (void)reloadToolbarItems
|
||||
@@ -751,14 +808,14 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
// Get rid of all our current subviews.
|
||||
var subviews = [self subviews],
|
||||
count = subviews.length;
|
||||
|
||||
|
||||
while (count--)
|
||||
[subviews[count] removeFromSuperview];
|
||||
|
||||
|
||||
// Populate with new subviews.
|
||||
var items = [_toolbar items],
|
||||
index = 0;
|
||||
|
||||
|
||||
count = items.length;
|
||||
|
||||
_minWidth = TOOLBAR_ITEM_MARGIN;
|
||||
@@ -774,7 +831,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
|
||||
_minWidth += [view minSize].width + TOOLBAR_ITEM_MARGIN;
|
||||
}
|
||||
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
@@ -785,13 +842,13 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
|
||||
{
|
||||
var lhsVisibilityPriority = [lhs visibilityPriority],
|
||||
rhsVisibilityPriority = [rhs visibilityPriority];
|
||||
|
||||
|
||||
if (lhsVisibilityPriority == rhsVisibilityPriority)
|
||||
return CPOrderedSame;
|
||||
|
||||
|
||||
if (lhsVisibilityPriority > rhsVisibilityPriority)
|
||||
return CPOrderedAscending;
|
||||
|
||||
|
||||
return CPOrderedDescending;
|
||||
}
|
||||
|
||||
@@ -837,7 +894,16 @@ var TOP_MARGIN = 5.0,
|
||||
|
||||
_toolbar = aToolbar;
|
||||
|
||||
[_toolbarItem addObserver:self forKeyPath:"enabled" options:0 context:NULL];
|
||||
var keyPaths = [@"label", @"image", @"alternateImage", @"minSize", @"maxSize", @"target", @"action", @"enabled"],
|
||||
index = 0,
|
||||
count = [keyPaths count];
|
||||
|
||||
for (; index < count; ++index)
|
||||
[_toolbarItem
|
||||
addObserver:self
|
||||
forKeyPath:keyPaths[index]
|
||||
options:0
|
||||
context:NULL];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -918,6 +984,8 @@ var TOP_MARGIN = 5.0,
|
||||
[_labelField setStringValue:[_toolbarItem label]];
|
||||
[_labelField sizeToFit]; // FIXME
|
||||
|
||||
[self setEnabled:[_toolbarItem isEnabled]];
|
||||
|
||||
_labelSize = [_labelField frame].size;
|
||||
|
||||
_minSize = CGSizeMake(MAX(_labelSize.width, minSize.width), _labelSize.height + minSize.height + LABEL_MARGIN + TOP_MARGIN);
|
||||
@@ -957,7 +1025,14 @@ var TOP_MARGIN = 5.0,
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
if ([_toolbarItem view])
|
||||
return;
|
||||
return [[self nextResponder] mouseDown:anEvent];
|
||||
|
||||
var identifier = [_toolbarItem itemIdentifier];
|
||||
|
||||
if (identifier === CPToolbarSpaceItemIdentifier ||
|
||||
identifier === CPToolbarFlexibleSpaceItemIdentifier ||
|
||||
identifier === CPToolbarSeparatorItemIdentifier)
|
||||
return [[self nextResponder] mouseDown:anEvent];
|
||||
|
||||
[super mouseDown:anEvent];
|
||||
}
|
||||
@@ -1020,14 +1095,27 @@ var TOP_MARGIN = 5.0,
|
||||
[_labelField setTextShadowColor:[self FIXME_labelShadowColor]];
|
||||
}
|
||||
|
||||
- (void)sendAction:(SEL)anAction to:(id)aSender
|
||||
{
|
||||
[CPApp sendAction:anAction to:aSender from:_toolbarItem];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(CPString)aKeyPath
|
||||
ofObject:(id)anObject
|
||||
change:(CPDictionary)aChange
|
||||
context:(id)aContext
|
||||
{
|
||||
// FIXME: Not clear if -synchronizeWindowTitleWithDocumentName is the best way to go.
|
||||
if (aKeyPath === "enabled")
|
||||
[self setEnabled:[anObject isEnabled]];
|
||||
|
||||
else if (aKeyPath === @"target")
|
||||
[self setTarget:[anObject target]];
|
||||
|
||||
else if (aKeyPath === @"action")
|
||||
[self setAction:[anObject action]];
|
||||
|
||||
else
|
||||
[self updateFromItem];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -26,35 +26,18 @@
|
||||
@import <AppKit/CPImage.j>
|
||||
@import <AppKit/CPView.j>
|
||||
|
||||
|
||||
/*
|
||||
@global
|
||||
@class CPToolbarItem
|
||||
*/
|
||||
CPToolbarItemVisibilityPriorityStandard = 0;
|
||||
/*
|
||||
@global
|
||||
@class CPToolbarItem
|
||||
*/
|
||||
CPToolbarItemVisibilityPriorityLow = -1000;
|
||||
/*
|
||||
@global
|
||||
@class CPToolbarItem
|
||||
*/
|
||||
CPToolbarItemVisibilityPriorityHigh = 1000;
|
||||
/*
|
||||
@global
|
||||
@class CPToolbarItem
|
||||
*/
|
||||
CPToolbarItemVisibilityPriorityUser = 2000;
|
||||
|
||||
CPToolbarSeparatorItemIdentifier = @"CPToolbarSeparatorItemIdentifier";
|
||||
CPToolbarSpaceItemIdentifier = @"CPToolbarSpaceItemIdentifier";
|
||||
CPToolbarFlexibleSpaceItemIdentifier = @"CPToolbarFlexibleSpaceItemIdentifier";
|
||||
CPToolbarShowColorsItemIdentifier = @"CPToolbarShowColorsItemIdentifier";
|
||||
CPToolbarShowFontsItemIdentifier = @"CPToolbarShowFontsItemIdentifier";
|
||||
CPToolbarCustomizeToolbarItemIdentifier = @"CPToolbarCustomizeToolbarItemIdentifier";
|
||||
CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
|
||||
CPToolbarSeparatorItemIdentifier = @"CPToolbarSeparatorItem";
|
||||
CPToolbarSpaceItemIdentifier = @"CPToolbarSpaceItem";
|
||||
CPToolbarFlexibleSpaceItemIdentifier = @"CPToolbarFlexibleSpaceItem";
|
||||
CPToolbarShowColorsItemIdentifier = @"CPToolbarShowColorsItem";
|
||||
CPToolbarShowFontsItemIdentifier = @"CPToolbarShowFontsItem";
|
||||
CPToolbarCustomizeToolbarItemIdentifier = @"CPToolbarCustomizeToolbarItem";
|
||||
CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@@ -65,9 +48,9 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
|
||||
@implementation CPToolbarItem : CPObject
|
||||
{
|
||||
CPString _itemIdentifier;
|
||||
|
||||
|
||||
CPToolbar _toolbar;
|
||||
|
||||
|
||||
CPString _label;
|
||||
CPString _paletteLabel;
|
||||
CPString _toolTip;
|
||||
@@ -77,12 +60,12 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
|
||||
BOOL _isEnabled;
|
||||
CPImage _image;
|
||||
CPImage _alternateImage;
|
||||
|
||||
|
||||
CPView _view;
|
||||
|
||||
|
||||
CGSize _minSize;
|
||||
CGSize _maxSize;
|
||||
|
||||
|
||||
int _visibilityPriority;
|
||||
|
||||
BOOL _autovalidates;
|
||||
@@ -114,6 +97,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
|
||||
_maxSize = CGSizeMakeZero();
|
||||
|
||||
_visibilityPriority = CPToolbarItemVisibilityPriorityStandard;
|
||||
_autovalidates = YES;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -136,6 +120,12 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
|
||||
return _toolbar;
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
- (void)_setToolbar:(CPToolbar)aToolbar
|
||||
{
|
||||
_toolbar = aToolbar;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the item's label
|
||||
*/
|
||||
@@ -190,7 +180,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
|
||||
- (void)setToolTip:(CPString)aToolTip
|
||||
{
|
||||
if ([_view respondsToSelector:@selector(setToolTip:)])
|
||||
[view setToolTip:aToolTip];
|
||||
[_view setToolTip:aToolTip];
|
||||
|
||||
_toolTip = aToolTip;
|
||||
}
|
||||
@@ -315,8 +305,8 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
|
||||
if (!_image)
|
||||
return;
|
||||
|
||||
if (_minSize.width == 0 && _minSize.height == 0 &&
|
||||
_maxSize.width == 0 && _maxSize.height == 0)
|
||||
if (_minSize.width === 0 && _minSize.height === 0 &&
|
||||
_maxSize.width === 0 && _maxSize.height === 0)
|
||||
{
|
||||
var imageSize = [_image size];
|
||||
|
||||
@@ -395,6 +385,9 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
|
||||
*/
|
||||
- (void)setMinSize:(CGSize)aMinSize
|
||||
{
|
||||
if(!aMinSize.height || !aMinSize.width)
|
||||
return;
|
||||
|
||||
_minSize = CGSizeMakeCopy(aMinSize);
|
||||
|
||||
// Try to provide some sanity: Make maxSize >= minSize
|
||||
@@ -415,6 +408,9 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
|
||||
*/
|
||||
- (void)setMaxSize:(CGSize)aMaxSize
|
||||
{
|
||||
if(!aMaxSize.height || !aMaxSize.width)
|
||||
return;
|
||||
|
||||
_maxSize = CGSizeMakeCopy(aMaxSize);
|
||||
|
||||
// Try to provide some sanity: Make minSize <= maxSize
|
||||
@@ -495,15 +491,97 @@ CPToolbarItemVisibilityPriorityUser
|
||||
|
||||
@end
|
||||
|
||||
var CPToolbarItemItemIdentifierKey = @"CPToolbarItemItemIdentifierKey",
|
||||
CPToolbarItemLabelKey = @"CPToolbarItemLabelKey",
|
||||
CPToolbarItemPaletteLabelKey = @"CPToolbarItemPaletteLabelKey",
|
||||
CPToolbarItemToolTipKey = @"CPToolbarItemToolTipKey",
|
||||
CPToolbarItemTagKey = @"CPToolbarItemTagKey",
|
||||
CPToolbarItemTargetKey = @"CPToolbarItemTargetKey",
|
||||
CPToolbarItemActionKey = @"CPToolbarItemActionKey",
|
||||
CPToolbarItemEnabledKey = @"CPToolbarItemEnabledKey",
|
||||
CPToolbarItemImageKey = @"CPToolbarItemImageKey",
|
||||
CPToolbarItemAlternateImageKey = @"CPToolbarItemAlternateImageKey",
|
||||
CPToolbarItemViewKey = @"CPToolbarItemViewKey",
|
||||
CPToolbarItemMinSizeKey = @"CPToolbarItemMinSizeKey",
|
||||
CPToolbarItemMaxSizeKey = @"CPToolbarItemMaxSizeKey",
|
||||
CPToolbarItemVisibilityPriorityKey = @"CPToolbarItemVisibilityPriorityKey",
|
||||
CPToolbarItemAutovalidatesKey = @"CPToolbarItemAutovalidatesKey";
|
||||
|
||||
@implementation CPToolbarItem (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_itemIdentifier = [aCoder decodeObjectForKey:CPToolbarItemItemIdentifierKey];
|
||||
|
||||
_minSize = [aCoder decodeSizeForKey:CPToolbarItemMinSizeKey];
|
||||
_maxSize = [aCoder decodeSizeForKey:CPToolbarItemMaxSizeKey];
|
||||
|
||||
[self setLabel:[aCoder decodeObjectForKey:CPToolbarItemLabelKey]];
|
||||
[self setPaletteLabel:[aCoder decodeObjectForKey:CPToolbarItemPaletteLabelKey]];
|
||||
[self setToolTip:[aCoder decodeObjectForKey:CPToolbarItemToolTipKey]];
|
||||
|
||||
[self setTag:[aCoder decodeObjectForKey:CPToolbarItemTagKey]];
|
||||
[self setTarget:[aCoder decodeObjectForKey:CPToolbarItemTargetKey]];
|
||||
[self setAction:CPSelectorFromString([aCoder decodeObjectForKey:CPToolbarItemActionKey])];
|
||||
|
||||
[self setEnabled:[aCoder decodeBoolForKey:CPToolbarItemEnabledKey]];
|
||||
|
||||
[self setImage:[aCoder decodeObjectForKey:CPToolbarItemImageKey]];
|
||||
[self setAlternateImage:[aCoder decodeObjectForKey:CPToolbarItemAlternateImageKey]];
|
||||
|
||||
[self setView:[aCoder decodeObjectForKey:CPToolbarItemViewKey]];
|
||||
|
||||
[self setVisibilityPriority:[aCoder decodeIntForKey:CPToolbarItemVisibilityPriorityKey]];
|
||||
[self setAutovalidates:[aCoder decodeBoolForKey:CPToolbarItemAutovalidatesKey]];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[aCoder encodeObject:_itemIdentifier forKey:CPToolbarItemItemIdentifierKey];
|
||||
|
||||
[aCoder encodeObject:[self label] forKey:CPToolbarItemLabelKey];
|
||||
[aCoder encodeObject:[self paletteLabel] forKey:CPToolbarItemPaletteLabelKey];
|
||||
|
||||
[aCoder encodeObject:[self toolTip] forKey:CPToolbarItemToolTipKey];
|
||||
|
||||
[aCoder encodeObject:[self tag] forKey:CPToolbarItemTagKey];
|
||||
[aCoder encodeObject:[self target] forKey:CPToolbarItemTargetKey];
|
||||
[aCoder encodeObject:[self action] forKey:CPToolbarItemActionKey];
|
||||
|
||||
[aCoder encodeObject:[self isEnabled] forKey:CPToolbarItemEnabledKey];
|
||||
|
||||
[aCoder encodeObject:[self image] forKey:CPToolbarItemImageKey];
|
||||
[aCoder encodeObject:[self alternateImage] forKey:CPToolbarItemAlternateImageKey];
|
||||
|
||||
[aCoder encodeObject:[self view] forKey:CPToolbarItemViewKey];
|
||||
|
||||
[aCoder encodeSize:[self minSize] forKey:CPToolbarItemMinSizeKey];
|
||||
[aCoder encodeSize:[self maxSize] forKey:CPToolbarItemMaxSizeKey];
|
||||
|
||||
[aCoder encodeObject:[self visibilityPriority] forKey:CPToolbarItemVisibilityPriorityKey];
|
||||
[aCoder encodeBool:[self autovalidates] forKey:CPToolbarItemAutovalidatesKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPToolbarItem (CPCopying)
|
||||
|
||||
- (id)copy
|
||||
{
|
||||
var copy = [[[self class] alloc] initWithItemIdentifier:_itemIdentifier];
|
||||
|
||||
|
||||
if (_view)
|
||||
[copy setView:[CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:_view]]];
|
||||
|
||||
|
||||
[copy _setToolbar:_toolbar];
|
||||
|
||||
[copy setLabel:_label];
|
||||
[copy setPaletteLabel:_paletteLabel];
|
||||
[copy setToolTip:[self toolTip]];
|
||||
@@ -511,7 +589,7 @@ CPToolbarItemVisibilityPriorityUser
|
||||
[copy setTag:[self tag]];
|
||||
[copy setTarget:[self target]];
|
||||
[copy setAction:[self action]];
|
||||
|
||||
|
||||
[copy setEnabled:[self isEnabled]];
|
||||
|
||||
[copy setImage:[self image]];
|
||||
@@ -519,9 +597,10 @@ CPToolbarItemVisibilityPriorityUser
|
||||
|
||||
[copy setMinSize:_minSize];
|
||||
[copy setMaxSize:_maxSize];
|
||||
|
||||
[copy setVisibilityPriority:_visibilityPriority];
|
||||
|
||||
|
||||
[copy setVisibilityPriority:[self visibilityPriority]];
|
||||
[copy setAutovalidates:[self autovalidates]];
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
@@ -534,26 +613,12 @@ CPToolbarItemVisibilityPriorityUser
|
||||
/* @ignore */
|
||||
+ (CPToolbarItem)_standardItemWithItemIdentifier:(CPString)anItemIdentifier
|
||||
{
|
||||
var item = [[CPToolbarItem alloc] initWithItemIdentifier:anItemIdentifier];
|
||||
|
||||
switch (anItemIdentifier)
|
||||
{
|
||||
case CPToolbarSeparatorItemIdentifier: [item setMinSize:CGSizeMake(2.0, 0.0)];
|
||||
[item setMaxSize:CGSizeMake(2.0, 100000.0)];
|
||||
|
||||
return item;
|
||||
|
||||
case CPToolbarSpaceItemIdentifier: [item setMinSize:CGSizeMake(32.0, 32.0)];
|
||||
[item setMaxSize:CGSizeMake(32.0, 32.0)];
|
||||
|
||||
return item;
|
||||
|
||||
case CPToolbarFlexibleSpaceItemIdentifier: [item setMinSize:CGSizeMake(32.0, 32.0)];
|
||||
[item setMaxSize:CGSizeMake(10000.0, 32.0)];
|
||||
|
||||
return item;
|
||||
|
||||
case CPToolbarShowColorsItemIdentifier: return nil;
|
||||
case CPToolbarSeparatorItemIdentifier: return [_CPToolbarSeparatorItem new];
|
||||
case CPToolbarSpaceItemIdentifier: return [_CPToolbarSpaceItem new];
|
||||
case CPToolbarFlexibleSpaceItemIdentifier: return [_CPToolbarFlexibleSpaceItem new];
|
||||
case CPToolbarShowColorsItemIdentifier: return [_CPToolbarShowColorsItem new];
|
||||
case CPToolbarShowFontsItemIdentifier: return nil;
|
||||
case CPToolbarCustomizeToolbarItemIdentifier: return nil;
|
||||
case CPToolbarPrintItemIdentifier: return nil;
|
||||
@@ -563,3 +628,9 @@ CPToolbarItemVisibilityPriorityUser
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@import "_CPToolbarFlexibleSpaceItem.j"
|
||||
@import "_CPToolbarShowColorsItem.j"
|
||||
@import "_CPToolbarSeparatorItem.j"
|
||||
@import "_CPToolbarSpaceItem.j"
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
id _representedObject @accessors(readonly, property=representedObject);
|
||||
|
||||
CPTreeNode _parentNode @accessors(readonly, property=parentNode);
|
||||
CPMutableArray _childNodes @accessors(readonly, property=childNodes);
|
||||
CPMutableArray _childNodes;
|
||||
}
|
||||
|
||||
+ (id)treeNodeWithRepresentedObject:(id)anObject
|
||||
@@ -33,16 +33,23 @@
|
||||
return [_childNodes count] <= 0;
|
||||
}
|
||||
|
||||
- (CPArray)childNodes
|
||||
{
|
||||
return [_childNodes copy];
|
||||
}
|
||||
|
||||
- (CPMutableArray)mutableChildNodes
|
||||
{
|
||||
return [self mutableArrayValueForKey:@"childNodes"];
|
||||
}
|
||||
|
||||
- (void)insertObject:(id)anObject inChildNodesAtIndex:(CPInteger)anIndex
|
||||
- (void)insertObject:(id)aTreeNode inChildNodesAtIndex:(CPInteger)anIndex
|
||||
{
|
||||
anObject._parentNode = self;
|
||||
[[aTreeNode._parentNode mutableChildNodes] removeObjectIdenticalTo:aTreeNode];
|
||||
|
||||
[_childNodes addObject:anObject];
|
||||
aTreeNode._parentNode = self;
|
||||
|
||||
[_childNodes insertObject:aTreeNode atIndex:anIndex];
|
||||
}
|
||||
|
||||
- (void)removeObjectFromChildNodesAtIndex:(CPInteger)anIndex
|
||||
@@ -52,13 +59,14 @@
|
||||
[_childNodes removeObjectAtIndex:anIndex];
|
||||
}
|
||||
|
||||
- (void)replaceObjectFromChildNodesAtIndex:(CPInteger)anIndex withObject:(id)anObject
|
||||
- (void)replaceObjectFromChildNodesAtIndex:(CPInteger)anIndex withObject:(id)aTreeNode
|
||||
{
|
||||
var oldObject = [_childNodes objectAtIndex:anIndex];
|
||||
var oldTreeNode = [_childNodes objectAtIndex:anIndex];
|
||||
|
||||
oldObject._parentNode = nil;
|
||||
oldTreeNode._parentNode = nil;
|
||||
aTreeNode._parentNode = self;
|
||||
|
||||
[_childNodes replaceObjectAtIndex:anIndex withObject:anObject];
|
||||
[_childNodes replaceObjectAtIndex:anIndex withObject:aTreeNode];
|
||||
}
|
||||
|
||||
- (id)objectInChildNodesAtIndex:(CPInteger)anIndex
|
||||
@@ -80,3 +88,32 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPTreeNodeRepresentedObjectKey = @"CPTreeNodeRepresentedObjectKey",
|
||||
CPTreeNodeParentNodeKey = @"CPTreeNodeParentNodeKey",
|
||||
CPTreeNodeChildNodesKey = @"CPTreeNodeChildNodesKey";
|
||||
|
||||
@implementation CPTreeNode (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_representedObject = [aCoder decodeObjectForKey:CPTreeNodeRepresentedObjectKey];
|
||||
_parentNode = [aCoder decodeObjectForKey:CPTreeNodeParentNodeKey];
|
||||
_childNodes = [aCoder decodeObjectForKey:CPTreeNodeChildNodesKey];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[aCoder encodeObject:_representedObject forKey:CPTreeNodeRepresentedObjectKey];
|
||||
[aCoder encodeConditionalObject:_parentNode forKey:CPTreeNodeParentNodeKey];
|
||||
[aCoder encodeObject:_childNodes forKey:CPTreeNodeChildNodesKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -238,6 +238,11 @@ var CPViewFlags = { },
|
||||
return [CPSet setWithObjects:@"frameOrigin", @"frameSize"];
|
||||
}
|
||||
|
||||
+ (CPSet)keyPathsForValuesAffectingBounds
|
||||
{
|
||||
return [CPSet setWithObjects:@"boundsOrigin", @"boundsSize"];
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
return [self initWithFrame:CGRectMakeZero()];
|
||||
@@ -308,7 +313,7 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (CPArray)subviews
|
||||
{
|
||||
return _subviews;
|
||||
return [_subviews copy];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -441,7 +446,7 @@ var CPViewFlags = { },
|
||||
|
||||
[_superview willRemoveSubview:self];
|
||||
|
||||
[[_superview subviews] removeObject:self];
|
||||
[_superview._subviews removeObject:self];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
CPDOMDisplayServerRemoveChild(_superview._DOMElement, _DOMElement);
|
||||
@@ -468,6 +473,75 @@ var CPViewFlags = { },
|
||||
[self _insertSubview:aView atIndex:index];
|
||||
}
|
||||
|
||||
- (void)setSubviews:(CPArray)newSubviews
|
||||
{
|
||||
if (!newSubviews)
|
||||
[CPException raise:CPInvalidArgumentException reason:"newSubviews cannot be nil in -[CPView setSubviews:]"];
|
||||
|
||||
// Trivial Case 0: Same array somehow
|
||||
if ([_subviews isEqual:newSubviews])
|
||||
return;
|
||||
|
||||
// Trivial Case 1: No current subviews, simply add all new subviews.
|
||||
if ([_subviews count] === 0)
|
||||
{
|
||||
var index = 0,
|
||||
count = [newSubviews count];
|
||||
|
||||
for (; index < count; ++index)
|
||||
[self addSubview:newSubviews[index]];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Trivial Case 2: No new subviews, simply remove all current subviews.
|
||||
if ([newSubviews count] === 0)
|
||||
{
|
||||
var count = [_subviews count];
|
||||
|
||||
while (count--)
|
||||
[_subviews[count] removeFromSuperview];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Find out the views that were removed.
|
||||
var removedSubviews = [CPMutableSet setWithArray:_subviews];
|
||||
|
||||
[removedSubviews removeObjectsInArray:newSubviews];
|
||||
[removedSubviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
||||
|
||||
// Find out which views need to be added.
|
||||
var addedSubviews = [CPMutableSet setWithArray:newSubviews];
|
||||
|
||||
[addedSubviews removeObjectsInArray:_subviews];
|
||||
|
||||
var addedSubview = nil,
|
||||
addedSubviewEnumerator = [addedSubviews objectEnumerator];
|
||||
|
||||
while (addedSubview = [addedSubviewEnumerator nextObject])
|
||||
[self addSubview:addedSubview];
|
||||
|
||||
// If the order is fine, no need to reorder.
|
||||
if ([_subviews isEqual:newSubviews])
|
||||
return;
|
||||
|
||||
_subviews = [newSubviews copy];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var index = 0,
|
||||
count = [_subviews count];
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var subview = _subviews[index];
|
||||
|
||||
CPDOMDisplayServerRemoveChild(_DOMElement, subview._DOMElement);
|
||||
CPDOMDisplayServerAppendChild(_DOMElement, subview._DOMElement);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
- (void)_setWindow:(CPWindow)aWindow
|
||||
{
|
||||
@@ -596,7 +670,7 @@ var CPViewFlags = { },
|
||||
|
||||
- (void)viewWithTag:(CPInteger)aTag
|
||||
{
|
||||
if ([self tag] === aTag)
|
||||
if ([self tag] == aTag)
|
||||
return self;
|
||||
|
||||
var index = 0,
|
||||
@@ -816,6 +890,16 @@ var CPViewFlags = { },
|
||||
return _CGRectMakeCopy(_bounds);
|
||||
}
|
||||
|
||||
- (CGPoint)boundsOrigin
|
||||
{
|
||||
return _CGPointMakeCopy(_bounds.origin);
|
||||
}
|
||||
|
||||
- (CGSize)boundsSize
|
||||
{
|
||||
return _CGSizeMakeCopy(_bounds.size);
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the location of the receiver inside its frame. The method
|
||||
posts a CPViewBoundsDidChangeNotification to the
|
||||
@@ -1202,6 +1286,14 @@ var CPViewFlags = { },
|
||||
return self;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c YES if this view requires a panel to become key. Normally only text fields, so this returns \c NO.
|
||||
*/
|
||||
- (BOOL)needsPanelToBecomeKey
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c YES if mouse events aren't needed by the receiver and can be sent to the superview. The
|
||||
default implementation returns \c NO if the view is opaque.
|
||||
@@ -1666,8 +1758,9 @@ setBoundsOrigin:
|
||||
_DOMContentsElement.style.width = ROUND(_CGRectGetWidth(_frame)) + "px";
|
||||
_DOMContentsElement.style.height = ROUND(_CGRectGetHeight(_frame)) + "px";
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
CPDOMDisplayServerAppendChild(_DOMElement, _DOMContentsElement);
|
||||
|
||||
#endif
|
||||
_graphicsContext = [CPGraphicsContext graphicsContextWithGraphicsPort:graphicsPort flipped:YES];
|
||||
}
|
||||
|
||||
@@ -1863,12 +1956,11 @@ setBoundsOrigin:
|
||||
|
||||
- (BOOL)performKeyEquivalent:(CPEvent)anEvent
|
||||
{
|
||||
var subviews = [self subviews],
|
||||
count = [subviews count];
|
||||
var count = [_subviews count];
|
||||
|
||||
// Is reverse iteration correct here? It matches the other (correct) code like hit testing.
|
||||
while (count--)
|
||||
if ([subviews[count] performKeyEquivalent:anEvent])
|
||||
if ([_subviews[count] performKeyEquivalent:anEvent])
|
||||
return YES;
|
||||
|
||||
return NO;
|
||||
@@ -2046,7 +2138,8 @@ setBoundsOrigin:
|
||||
|
||||
var theClass = [self class],
|
||||
CPViewClass = [CPView class],
|
||||
attributes = [];
|
||||
attributes = [],
|
||||
nullValue = [CPNull null];
|
||||
|
||||
for (; theClass && theClass !== CPViewClass; theClass = [theClass superclass])
|
||||
{
|
||||
@@ -2070,9 +2163,10 @@ setBoundsOrigin:
|
||||
|
||||
while (attributeCount--)
|
||||
{
|
||||
var attributeName = attributeKeys[attributeCount];
|
||||
var attributeName = attributeKeys[attributeCount],
|
||||
attributeValue = [attributeDictionary objectForKey:attributeName];
|
||||
|
||||
attributes.push([attributeDictionary objectForKey:attributeName]);
|
||||
attributes.push(attributeValue === nullValue ? nil : attributeValue);
|
||||
attributes.push(attributeName);
|
||||
}
|
||||
}
|
||||
@@ -2200,7 +2294,7 @@ setBoundsOrigin:
|
||||
return [_themeAttributes[aName] value];
|
||||
}
|
||||
|
||||
- (void)currentValueForThemeAttribute:(CPString)aName
|
||||
- (id)currentValueForThemeAttribute:(CPString)aName
|
||||
{
|
||||
if (!_themeAttributes || !_themeAttributes[aName])
|
||||
[CPException raise:CPInvalidArgumentException reason:[self className] + " does not contain theme attribute '" + aName + "'"];
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* CPFlashView.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Klaas Pieter Annema on September 3, 2009.
|
||||
* Copyright 2009, Sofa BV
|
||||
*
|
||||
* 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 <AppKit/CPAnimation.j>
|
||||
|
||||
CPViewAnimationTargetKey = @"CPViewAnimationTarget";
|
||||
CPViewAnimationStartFrameKey = @"CPViewAnimationStartFrame";
|
||||
CPViewAnimationEndFrameKey = @"CPViewAnimationEndFrame";
|
||||
CPViewAnimationEffectKey = @"CPViewAnimationEffect";
|
||||
|
||||
CPViewAnimationFadeInEffect = @"CPViewAnimationFadeIn";
|
||||
CPViewAnimationFadeOutEffect = @"CPViewAnimationFadeOut";
|
||||
|
||||
@implementation CPViewAnimation : CPAnimation
|
||||
{
|
||||
CPArray _viewAnimations;
|
||||
}
|
||||
|
||||
- (id)initWithViewAnimations:(CPArray)viewAnimations
|
||||
{
|
||||
if (self = [super initWithDuration:0.5 animationCurve:CPAnimationLinear])
|
||||
{
|
||||
[self setViewAnimations:viewAnimations];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)startAnimation
|
||||
{
|
||||
var animationIndex = [_viewAnimations count];
|
||||
while (animationIndex--)
|
||||
{
|
||||
var dictionary = [_viewAnimations objectAtIndex:animationIndex],
|
||||
view = [self _targetView:dictionary],
|
||||
startFrame = [self _startFrame:dictionary];
|
||||
|
||||
[view setFrame:startFrame];
|
||||
|
||||
var effect = [self _effect:dictionary];
|
||||
if (effect === CPViewAnimationFadeInEffect)
|
||||
{
|
||||
[view setAlphaValue:0.0];
|
||||
[view setHidden:NO];
|
||||
}
|
||||
else if (effect === CPViewAnimationFadeOutEffect)
|
||||
[view setAlphaValue:1.0];
|
||||
}
|
||||
|
||||
[super startAnimation];
|
||||
}
|
||||
|
||||
- (void)setCurrentProgress:(NSAnimationProgress)progress
|
||||
{
|
||||
[super setCurrentProgress:progress];
|
||||
|
||||
var animationIndex = [_viewAnimations count];
|
||||
while (animationIndex--)
|
||||
{
|
||||
var dictionary = [_viewAnimations objectAtIndex:animationIndex],
|
||||
view = [self _targetView:dictionary]
|
||||
startFrame = [self _startFrame:dictionary]
|
||||
endFrame = [self _endFrame:dictionary]
|
||||
differenceFrame = CPRectMakeZero();
|
||||
|
||||
differenceFrame.origin.x = endFrame.origin.x - startFrame.origin.x;
|
||||
differenceFrame.origin.y = endFrame.origin.y - startFrame.origin.y;
|
||||
differenceFrame.size.width = endFrame.size.width - startFrame.size.width;
|
||||
differenceFrame.size.height = endFrame.size.height - startFrame.size.height;
|
||||
|
||||
var intermediateFrame = CPRectMakeZero();
|
||||
intermediateFrame.origin.x = startFrame.origin.x + differenceFrame.origin.x * progress;
|
||||
intermediateFrame.origin.y = startFrame.origin.y + differenceFrame.origin.y * progress;
|
||||
intermediateFrame.size.width = startFrame.size.width + differenceFrame.size.width * progress;
|
||||
intermediateFrame.size.height = startFrame.size.height + differenceFrame.size.height * progress;
|
||||
|
||||
[view setFrame:intermediateFrame];
|
||||
|
||||
// Update the view's alpha value
|
||||
var effect = [self _effect:dictionary];
|
||||
if (effect === CPViewAnimationFadeInEffect)
|
||||
[view setAlphaValue:1.0 * progress];
|
||||
else if (effect === CPViewAnimationFadeOutEffect)
|
||||
[view setAlphaValue:1.0 + ( 0.0 - 1.0 ) * progress];
|
||||
|
||||
if (progress === 1.0)
|
||||
[view setHidden:CPRectIsNull(endFrame) || [view alphaValue] === 0.0];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)stopAnimation
|
||||
{
|
||||
var animationIndex = [_viewAnimations count];
|
||||
while (animationIndex--)
|
||||
{
|
||||
var dictionary = [_viewAnimations objectAtIndex:animationIndex],
|
||||
view = [self _targetView:dictionary],
|
||||
endFrame = [self _endFrame:dictionary];
|
||||
|
||||
[view setFrame:endFrame];
|
||||
|
||||
var effect = [self _effect:dictionary];
|
||||
if (effect === CPViewAnimationFadeInEffect)
|
||||
[view setAlphaValue:1.0];
|
||||
else if (effect === CPViewAnimationFadeOutEffect)
|
||||
[view setAlphaValue:0.0];
|
||||
|
||||
[view setHidden:CPRectIsNull(endFrame) || [view alphaValue] === 0.0];
|
||||
}
|
||||
|
||||
[super stopAnimation];
|
||||
}
|
||||
|
||||
- (id)_targetView:(CPDictionary)dictionary
|
||||
{
|
||||
var targetView = [dictionary valueForKey:CPViewAnimationTargetKey];
|
||||
if (!targetView)
|
||||
[CPException raise:CPInternalInconsistencyException reason:[CPString stringWithFormat:@"view animation: %@ does not have a target view", [dictionary description]]];
|
||||
|
||||
return targetView;
|
||||
}
|
||||
|
||||
- (CPRect)_startFrame:(CPDictionary)dictionary
|
||||
{
|
||||
var startFrame = [dictionary valueForKey:CPViewAnimationStartFrameKey];
|
||||
if (!startFrame)
|
||||
return [[self _targetView:dictionary] frame];
|
||||
|
||||
return startFrame;
|
||||
}
|
||||
|
||||
- (CPRect)_endFrame:(CPDictionary)dictionary
|
||||
{
|
||||
var endFrame = [dictionary valueForKey:CPViewAnimationEndFrameKey];
|
||||
if (!endFrame)
|
||||
return [[self _targetView:dictionary] frame];
|
||||
|
||||
return endFrame;
|
||||
}
|
||||
|
||||
- (CPString)_effect:(CPDictionary)dictionary
|
||||
{
|
||||
return [dictionary valueForKey:CPViewAnimationEffectKey];
|
||||
}
|
||||
|
||||
- (CPArray)viewAnimations
|
||||
{
|
||||
return _viewAnimations;
|
||||
}
|
||||
|
||||
- (void)setViewAnimations:(CPArray)viewAnimations
|
||||
{
|
||||
if (viewAnimations != _viewAnimations)
|
||||
{
|
||||
[self stopAnimation];
|
||||
_viewAnimations = [viewAnimations copy];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
@import <AppKit/CPResponder.j>
|
||||
|
||||
var CPViewControllerCachedCibs;
|
||||
|
||||
/*! @class CPViewController
|
||||
The CPViewController class provides the fundamental view-management controller for Cappuccino applications.
|
||||
@@ -56,6 +57,12 @@
|
||||
CPDictionary _cibExternalNameTable @accessors(property=cibExternalNameTable, readonly);
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self === CPViewController)
|
||||
CPViewControllerCachedCibs = [CPDictionary dictionary];
|
||||
}
|
||||
|
||||
/*!
|
||||
Convenience initializer calls -initWithCibName:bundle: with nil for both parameters.
|
||||
*/
|
||||
@@ -113,11 +120,16 @@
|
||||
{
|
||||
if (_view)
|
||||
return;
|
||||
|
||||
// check if a cib is already cached for the current _cibName
|
||||
var cib = [CPViewControllerCachedCibs objectForKey:_cibName];
|
||||
|
||||
// if (_cibName)
|
||||
// [CPException raise: reason:];
|
||||
|
||||
var cib = [[CPCib alloc] initWithContentsOfURL:[_cibBundle pathForResource:_cibName + @".cib"]];
|
||||
if (!cib)
|
||||
{
|
||||
// if the cib isn't cached yet : fetch it and cache it
|
||||
cib = [[CPCib alloc] initWithContentsOfURL:[_cibBundle pathForResource:_cibName + @".cib"]];
|
||||
[CPViewControllerCachedCibs setObject:cib forKey:_cibName];
|
||||
}
|
||||
|
||||
[cib instantiateCibWithExternalNameTable:_cibExternalNameTable];
|
||||
}
|
||||
@@ -126,8 +138,6 @@
|
||||
Returns the view that the controller manages.
|
||||
If this property is nil, the controller sends loadView to itself to create the view that it manages.
|
||||
Subclasses should override the loadView method to create any custom views. The default value is nil.
|
||||
|
||||
Note: An error will not be thrown if after -loadView, the view property is still nil. -view will simply return nil, but will continue to call -loadView on subsequent calls.
|
||||
*/
|
||||
- (CPView)view
|
||||
{
|
||||
@@ -143,14 +153,34 @@
|
||||
if (_view === nil && [cibOwner isKindOfClass:[CPDocument class]])
|
||||
[self setView:[cibOwner valueForKey:@"view"]];
|
||||
|
||||
if (!_view)
|
||||
{
|
||||
var reason = [CPString stringWithFormat:@"View for %@ could not be loaded from Cib or no view specified. Override loadView to load the view manually.", self];
|
||||
|
||||
[CPException raise:CPInternalInconsistencyException reason:reason];
|
||||
}
|
||||
|
||||
if ([cibOwner respondsToSelector:@selector(viewControllerDidLoadCib:)])
|
||||
[cibOwner viewControllerDidLoadCib:self];
|
||||
|
||||
[self viewDidLoad];
|
||||
}
|
||||
|
||||
return _view;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
This method is called after the view controller has loaded its associated views into memory.
|
||||
This method is called regardless of whether the views were stored in a nib file or created programmatically in the loadView method.
|
||||
This method is most commonly used to perform additional initialization steps on views that are loaded from nib files.
|
||||
*/
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Manually sets the view that the controller manages.
|
||||
Setting to nil will cause -loadView to be called on all subsequent calls of -view.
|
||||
|
||||
@@ -150,8 +150,10 @@ CPWebViewScrollNative = 2;
|
||||
|
||||
|
||||
_frameView = [[CPView alloc] initWithFrame:[self bounds]];
|
||||
[_frameView setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
|
||||
|
||||
_scrollView = [[CPScrollView alloc] initWithFrame:[self bounds]];
|
||||
[_scrollView setAutohidesScrollers:YES];
|
||||
[_scrollView setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
|
||||
[_scrollView setDocumentView:_frameView];
|
||||
|
||||
@@ -166,7 +168,6 @@ CPWebViewScrollNative = 2;
|
||||
- (void)setFrameSize:(CPSize)aSize
|
||||
{
|
||||
[super setFrameSize:aSize];
|
||||
|
||||
[self _resizeWebFrame];
|
||||
}
|
||||
|
||||
@@ -180,7 +181,7 @@ CPWebViewScrollNative = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
[_frameView setFrameSize:[_scrollView bounds].size];
|
||||
[_frameView setFrameSize:[_scrollView contentSize]];
|
||||
|
||||
// try to get the document size so we can correctly set the frame
|
||||
var win = null;
|
||||
|
||||
@@ -175,6 +175,9 @@ CPWindowBelow = 2;
|
||||
CPWindowWillCloseNotification = @"CPWindowWillCloseNotification";
|
||||
CPWindowDidBecomeMainNotification = @"CPWindowDidBecomeMainNotification";
|
||||
CPWindowDidResignMainNotification = @"CPWindowDidResignMainNotification";
|
||||
CPWindowDidBecomeKeyNotification = @"CPWindowDidBecomeKeyNotification";
|
||||
CPWindowDidResignKeyNotification = @"CPWindowDidResignKeyNotification";
|
||||
CPWindowDidResizeNotification = @"CPWindowDidResizeNotification";
|
||||
CPWindowDidMoveNotification = @"CPWindowDidMoveNotification";
|
||||
CPWindowWillBeginSheetNotification = @"CPWindowWillBeginSheetNotification";
|
||||
CPWindowDidEndSheetNotification = @"CPWindowDidEndSheetNotification";
|
||||
@@ -333,6 +336,11 @@ var CPWindowSaveImage = nil,
|
||||
CPWindowSavingImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"] size:CGSizeMake(16.0, 16.0)]
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
return [self initWithContentRect:_CGRectMakeZero() styleMask:CPTitledWindowMask];
|
||||
}
|
||||
|
||||
/*!
|
||||
Initializes the window. The method also takes a style bit mask made up
|
||||
of any of the following values:
|
||||
@@ -608,8 +616,17 @@ CPTexturedBackgroundWindowMask
|
||||
@param shouldDisplay whether the window should redraw its views
|
||||
@param shouldAnimate whether the window resize should be animated
|
||||
*/
|
||||
- (void)_setClippedFrame:(CGRect)aFrame display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate
|
||||
{
|
||||
aFrame.size.width = MIN(MAX(aFrame.size.width, _minSize.width), _maxSize.width)
|
||||
aFrame.size.height = MIN(MAX(aFrame.size.height, _minSize.height), _maxSize.height);
|
||||
[self setFrame:aFrame display:shouldDisplay animate:shouldAnimate];
|
||||
}
|
||||
|
||||
- (void)setFrame:(CGRect)aFrame display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate
|
||||
{
|
||||
aFrame = _CGRectMakeCopy(aFrame);
|
||||
|
||||
var value = aFrame.origin.x,
|
||||
delta = value - FLOOR(value);
|
||||
|
||||
@@ -665,16 +682,16 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
if (!_CGSizeEqualToSize(size, newSize))
|
||||
{
|
||||
size.width = MIN(MAX(newSize.width, _minSize.width), _maxSize.width);
|
||||
size.height = MIN(MAX(newSize.height, _minSize.height), _maxSize.height);
|
||||
size.width = newSize.width;
|
||||
size.height = newSize.height;
|
||||
|
||||
[_windowView setFrameSize:size];
|
||||
|
||||
if (_hasShadow)
|
||||
[_shadowView setFrameSize:_CGSizeMake(SHADOW_MARGIN_LEFT + size.width + SHADOW_MARGIN_RIGHT, SHADOW_MARGIN_BOTTOM + size.height + SHADOW_MARGIN_TOP + SHADOW_DISTANCE)];
|
||||
|
||||
if (!_isAnimating && [_delegate respondsToSelector:@selector(windowDidResize:)])
|
||||
[_delegate windowDidResize:self];
|
||||
if (!_isAnimating)
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidResizeNotification object:self];
|
||||
}
|
||||
|
||||
if ([self _sharesChromeWithPlatformWindow])
|
||||
@@ -684,7 +701,7 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
- (void)setFrame:(CGRect)aFrame display:(BOOL)shouldDisplay
|
||||
{
|
||||
[super setFrame:aFrame display:shouldDisplay animate:NO];
|
||||
[self _setClippedFrame:aFrame display:shouldDisplay animate:NO];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -692,7 +709,7 @@ CPTexturedBackgroundWindowMask
|
||||
*/
|
||||
- (void)setFrame:(CGRect)aFrame
|
||||
{
|
||||
[self setFrame:aFrame display:YES animate:NO];
|
||||
[self _setClippedFrame:aFrame display:YES animate:NO];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -701,7 +718,7 @@ CPTexturedBackgroundWindowMask
|
||||
*/
|
||||
- (void)setFrameOrigin:(CGPoint)anOrigin
|
||||
{
|
||||
[self setFrame:_CGRectMake(anOrigin.x, anOrigin.y, _CGRectGetWidth(_frame), _CGRectGetHeight(_frame)) display:YES animate:NO];
|
||||
[self _setClippedFrame:_CGRectMake(anOrigin.x, anOrigin.y, _CGRectGetWidth(_frame), _CGRectGetHeight(_frame)) display:YES animate:NO];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -710,7 +727,7 @@ CPTexturedBackgroundWindowMask
|
||||
*/
|
||||
- (void)setFrameSize:(CGSize)aSize
|
||||
{
|
||||
[self setFrame:_CGRectMake(_CGRectGetMinX(_frame), _CGRectGetMinY(_frame), aSize.width, aSize.height) display:YES animate:NO];
|
||||
[self _setClippedFrame:_CGRectMake(_CGRectGetMinX(_frame), _CGRectGetMinY(_frame), aSize.width, aSize.height) display:YES animate:NO];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -747,12 +764,7 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
[_platformWindow order:CPWindowOut window:self relativeTo:nil];
|
||||
|
||||
if ([CPApp keyWindow] == self)
|
||||
{
|
||||
[self resignKeyWindow];
|
||||
|
||||
CPApp._keyWindow = nil;
|
||||
}
|
||||
[self _updateMainAndKeyWindows];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -771,6 +783,11 @@ CPTexturedBackgroundWindowMask
|
||||
*/
|
||||
- (void)setLevel:(int)aLevel
|
||||
{
|
||||
if (aLevel === _level)
|
||||
return;
|
||||
|
||||
[_platformWindow moveWindow:self fromLevel:_level toLevel:aLevel];
|
||||
|
||||
_level = aLevel;
|
||||
|
||||
if ([self _sharesChromeWithPlatformWindow])
|
||||
@@ -1051,13 +1068,31 @@ CPTexturedBackgroundWindowMask
|
||||
*/
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
{
|
||||
// FIXME: Unregister for notifications!
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
[defaultCenter removeObserver:_delegate name:CPWindowDidResignKeyNotification object:self];
|
||||
[defaultCenter removeObserver:_delegate name:CPWindowDidBecomeKeyNotification object:self];
|
||||
[defaultCenter removeObserver:_delegate name:CPWindowDidBecomeMainNotification object:self];
|
||||
[defaultCenter removeObserver:_delegate name:CPWindowDidResignMainNotification object:self];
|
||||
[defaultCenter removeObserver:_delegate name:CPWindowDidMoveNotification object:self];
|
||||
[defaultCenter removeObserver:_delegate name:CPWindowDidResizeNotification object:self];
|
||||
|
||||
_delegate = aDelegate;
|
||||
|
||||
_delegateRespondsToWindowWillReturnUndoManagerSelector = [_delegate respondsToSelector:@selector(windowWillReturnUndoManager:)];
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
if ([_delegate respondsToSelector:@selector(windowDidResignKey:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(windowDidResignKey:)
|
||||
name:CPWindowDidResignKeyNotification
|
||||
object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(windowDidBecomeKey:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(windowDidBecomeKey:)
|
||||
name:CPWindowDidBecomeKeyNotification
|
||||
object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(windowDidBecomeMain:)])
|
||||
[defaultCenter
|
||||
@@ -1079,6 +1114,13 @@ CPTexturedBackgroundWindowMask
|
||||
selector:@selector(windowDidMove:)
|
||||
name:CPWindowDidMoveNotification
|
||||
object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(windowDidResize:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(windowDidResize:)
|
||||
name:CPWindowDidResizeNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1126,7 +1168,7 @@ CPTexturedBackgroundWindowMask
|
||||
\c aResponder accept first responder, then finally tell it to become first responder.
|
||||
@return \c YES if the attempt was successful. \c NO otherwise.
|
||||
*/
|
||||
- (void)makeFirstResponder:(CPResponder)aResponder
|
||||
- (BOOL)makeFirstResponder:(CPResponder)aResponder
|
||||
{
|
||||
if (_firstResponder == aResponder)
|
||||
return YES;
|
||||
@@ -1306,7 +1348,7 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
var theWindow = [anEvent window];
|
||||
|
||||
if ([theWindow isKeyWindow] || [theWindow becomesKeyOnlyIfNeeded])
|
||||
if ([theWindow isKeyWindow] || [theWindow becomesKeyOnlyIfNeeded] && ![_leftMouseDownView needsPanelToBecomeKey])
|
||||
return [_leftMouseDownView mouseDown:anEvent];
|
||||
else
|
||||
{
|
||||
@@ -1396,8 +1438,14 @@ CPTexturedBackgroundWindowMask
|
||||
*/
|
||||
- (void)becomeKeyWindow
|
||||
{
|
||||
if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(becomeKeyWindow)])
|
||||
CPApp._keyWindow = self;
|
||||
|
||||
if (_firstResponder !== self && [_firstResponder respondsToSelector:@selector(becomeKeyWindow)])
|
||||
[_firstResponder becomeKeyWindow];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPWindowDidBecomeKeyNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1434,13 +1482,10 @@ CPTexturedBackgroundWindowMask
|
||||
*/
|
||||
- (void)makeKeyWindow
|
||||
{
|
||||
if (![self canBecomeKeyWindow])
|
||||
if ([CPApp keyWindow] === self || ![self canBecomeKeyWindow])
|
||||
return;
|
||||
|
||||
[CPApp._keyWindow resignKeyWindow];
|
||||
|
||||
CPApp._keyWindow = self;
|
||||
|
||||
[[CPApp keyWindow] resignKeyWindow];
|
||||
[self becomeKeyWindow];
|
||||
}
|
||||
|
||||
@@ -1451,9 +1496,12 @@ CPTexturedBackgroundWindowMask
|
||||
{
|
||||
if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(resignKeyWindow)])
|
||||
[_firstResponder resignKeyWindow];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(windowDidResignKey:)])
|
||||
[_delegate windowDidResignKey:self];
|
||||
|
||||
CPApp._keyWindow = nil;
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPWindowDidResignKeyNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1482,7 +1530,7 @@ CPTexturedBackgroundWindowMask
|
||||
[_inclusiveRegisteredDraggedTypes unionSet:pasteboardTypes];
|
||||
}
|
||||
|
||||
- (void)_noteUnregisteredDraggedTypes:(CPArray)pasteboardTypes
|
||||
- (void)_noteUnregisteredDraggedTypes:(CPSet)pasteboardTypes
|
||||
{
|
||||
if (!pasteboardTypes)
|
||||
return;
|
||||
@@ -1642,6 +1690,8 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
[[self platformWindow] miniaturize:sender];
|
||||
|
||||
[self _updateMainAndKeyWindows];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidMiniaturizeNotification object:self];
|
||||
|
||||
_isMiniaturized = YES;
|
||||
@@ -1678,6 +1728,17 @@ CPTexturedBackgroundWindowMask
|
||||
if (!(_styleMask & CPClosableWindowMask))
|
||||
return;
|
||||
|
||||
if ([self isFullBridge])
|
||||
{
|
||||
var event = [CPApp currentEvent];
|
||||
|
||||
if ([event type] === CPKeyDown && [event characters] === "w" && ([event modifierFlags] & CPPlatformActionKeyMask))
|
||||
{
|
||||
[[self platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Only send ONE windowShouldClose: message.
|
||||
if ([_delegate respondsToSelector:@selector(windowShouldClose:)])
|
||||
{
|
||||
@@ -1766,13 +1827,10 @@ CPTexturedBackgroundWindowMask
|
||||
*/
|
||||
- (void)makeMainWindow
|
||||
{
|
||||
if (![self canBecomeMainWindow])
|
||||
if ([CPApp mainWindow] === self || ![self canBecomeMainWindow])
|
||||
return;
|
||||
|
||||
[CPApp._mainWindow resignMainWindow];
|
||||
|
||||
CPApp._mainWindow = self;
|
||||
|
||||
[[CPApp mainWindow] resignMainWindow];
|
||||
[self becomeMainWindow];
|
||||
}
|
||||
|
||||
@@ -1781,9 +1839,11 @@ CPTexturedBackgroundWindowMask
|
||||
*/
|
||||
- (void)becomeMainWindow
|
||||
{
|
||||
CPApp._mainWindow = self;
|
||||
|
||||
[self _synchronizeMenuBarTitleWithWindowTitle];
|
||||
[self _synchronizeSaveMenuWithDocumentSaving];
|
||||
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPWindowDidBecomeMainNotification
|
||||
object:self];
|
||||
@@ -1797,6 +1857,71 @@ CPTexturedBackgroundWindowMask
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPWindowDidResignMainNotification
|
||||
object:self];
|
||||
|
||||
CPApp._mainWindow = nil;
|
||||
}
|
||||
|
||||
- (void)_updateMainAndKeyWindows
|
||||
{
|
||||
var allWindows = [CPApp orderedWindows],
|
||||
windowCount = [allWindows count];
|
||||
|
||||
if (!windowCount)
|
||||
return;
|
||||
|
||||
if ([self isKeyWindow])
|
||||
{
|
||||
var keyWindow = [CPApp keyWindow];
|
||||
[self resignKeyWindow];
|
||||
|
||||
if (keyWindow && keyWindow !== self && [keyWindow canBecomeKeyWindow])
|
||||
[keyWindow makeKeyWindow];
|
||||
else
|
||||
{
|
||||
var menuWindow = [CPApp mainMenu]._menuWindow;
|
||||
for (var i = 0; i < windowCount; i++)
|
||||
{
|
||||
var currentWindow = allWindows[i];
|
||||
if (currentWindow === self || currentWindow === menuWindow)
|
||||
continue;
|
||||
|
||||
if ([currentWindow isVisible] && [currentWindow canBecomeKeyWindow])
|
||||
{
|
||||
[currentWindow makeKeyWindow];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (![CPApp keyWindow])
|
||||
[keyWindow makeKeyWindow];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ([self isMainWindow])
|
||||
{
|
||||
var mainWindow = [CPApp mainWindow];
|
||||
[self resignMainWindow];
|
||||
|
||||
if (mainWindow && mainWindow !== self && [mainWindow canBecomeMainWindow])
|
||||
[mainWindow makeMainWindow];
|
||||
else
|
||||
{
|
||||
var menuWindow = [CPApp mainMenu]._menuWindow;
|
||||
for (var i = 0; i < windowCount; i++)
|
||||
{
|
||||
var currentWindow = allWindows[i];
|
||||
if (currentWindow === self || currentWindow === menuWindow)
|
||||
continue;
|
||||
|
||||
if ([currentWindow isVisible] && [currentWindow canBecomeMainWindow])
|
||||
{
|
||||
[currentWindow makeMainWindow];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Managing Toolbars
|
||||
@@ -1882,8 +2007,8 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
sheetFrame.origin.y = CGRectGetMinY(_frame) + CGRectGetMinY(contentRect);
|
||||
sheetFrame.origin.x = CGRectGetMinX(_frame) + FLOOR((CGRectGetWidth(_frame) - CGRectGetWidth(sheetFrame)) / 2.0);
|
||||
|
||||
[attachedSheet setFrameOrigin:sheetFrame.origin];
|
||||
|
||||
[attachedSheet setFrame:sheetFrame display:YES animate:NO];
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
@@ -1917,7 +2042,7 @@ CPTexturedBackgroundWindowMask
|
||||
[CPApp runModalForWindow:aSheet];
|
||||
|
||||
[aSheet orderFront:self];
|
||||
[aSheet setFrame:startFrame];
|
||||
[aSheet setFrame:startFrame display:YES animate:NO];
|
||||
_sheetContext["opened"] = YES;
|
||||
|
||||
[aSheet _setFrame:endFrame delegate:self duration:0.2 curve:CPAnimationEaseOut];
|
||||
@@ -1981,7 +2106,8 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
- (void)_setUpMasksForView:(CPView)aView
|
||||
{
|
||||
var views = [CPArray arrayWithArray:[aView subviews]];
|
||||
var views = [aView subviews];
|
||||
|
||||
[views addObject:aView];
|
||||
|
||||
for (var i = 0, count = [views count]; i < count; i++)
|
||||
@@ -1996,7 +2122,8 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
- (void)_restoreMasksForView:(CPView)aView
|
||||
{
|
||||
var views = [CPArray arrayWithArray:[aView subviews]];
|
||||
var views = [aView subviews];
|
||||
|
||||
[views addObject:aView];
|
||||
|
||||
for (var i = 0, count = [views count]; i < count; i++)
|
||||
@@ -2351,9 +2478,21 @@ var keyViewComparator = function(a, b, context)
|
||||
*/
|
||||
- (CPUndoManager)undoManager
|
||||
{
|
||||
// If we've ever created an undo manager, return it.
|
||||
if (_undoManager)
|
||||
return _undoManager;
|
||||
|
||||
// If not, check to see if the document has one.
|
||||
var documentUndoManager = [[_windowController document] undoManager];
|
||||
|
||||
if (documentUndoManager)
|
||||
return documentUndoManager;
|
||||
|
||||
// If not, check to see if the delegate has one.
|
||||
if (_delegateRespondsToWindowWillReturnUndoManagerSelector)
|
||||
return [_delegate windowWillReturnUndoManager:self];
|
||||
|
||||
|
||||
// If not, create one.
|
||||
if (!_undoManager)
|
||||
_undoManager = [[CPUndoManager alloc] init];
|
||||
|
||||
@@ -2459,9 +2598,13 @@ var interpolate = function(fromValue, toValue, progress)
|
||||
|
||||
if (value == 1.0)
|
||||
_window._isAnimating = NO;
|
||||
|
||||
[_window setFrameOrigin:CGPointMake(interpolate(CGRectGetMinX(_startFrame), CGRectGetMinX(_targetFrame), value), interpolate(CGRectGetMinY(_startFrame), CGRectGetMinY(_targetFrame), value))];
|
||||
[_window setFrameSize:CGSizeMake(interpolate(CGRectGetWidth(_startFrame), CGRectGetWidth(_targetFrame), value), interpolate(CGRectGetHeight(_startFrame), CGRectGetHeight(_targetFrame), value))];
|
||||
|
||||
var newFrame = CGRectMake(interpolate(CGRectGetMinX(_startFrame), CGRectGetMinX(_targetFrame), value),
|
||||
interpolate(CGRectGetMinY(_startFrame), CGRectGetMinY(_targetFrame), value),
|
||||
interpolate(CGRectGetWidth(_startFrame), CGRectGetWidth(_targetFrame), value),
|
||||
interpolate(CGRectGetHeight(_startFrame), CGRectGetHeight(_targetFrame), value));
|
||||
|
||||
[_window setFrame:newFrame display:YES animate:NO];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -48,7 +48,7 @@ var HUD_TITLEBAR_HEIGHT = 26.0;
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/HUD/CPWindowHUDBackground2.png"] size:CPSizeMake(6.0, 78.0)],
|
||||
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/HUD/CPWindowHUDBackground3.png"] size:CPSizeMake(6.0, 1.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/HUD/CPWindowHUDBackground4.png"] size:CPSizeMake(1.0, 1.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/HUD/CPWindowHUDBackground4.png"] size:CPSizeMake(5.0, 5.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/HUD/CPWindowHUDBackground5.png"] size:CPSizeMake(6.0, 1.0)],
|
||||
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/HUD/CPWindowHUDBackground6.png"] size:CPSizeMake(6.0, 6.0)],
|
||||
|
||||
@@ -37,6 +37,7 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
|
||||
CPView _toolbarView;
|
||||
// BOOL _isAnimatingToolbar;
|
||||
|
||||
|
||||
CGRect _resizeFrame;
|
||||
CGPoint _mouseDraggedPoint;
|
||||
@@ -160,10 +161,15 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
if (!visibleFrame)
|
||||
visibleFrame = [[CPPlatformWindow primaryPlatformWindow] visibleFrame];
|
||||
|
||||
var minPointY = 0;
|
||||
|
||||
if([CPMenu menuBarVisible])
|
||||
minPointY = [[CPApp mainMenu] menuBarHeight];
|
||||
|
||||
var restrictedPoint = CGPointMake(0, 0);
|
||||
|
||||
restrictedPoint.x = MIN(MAX(aPoint.x, -_frame.size.width + 4.0), CGRectGetMaxX(visibleFrame) - 4.0);
|
||||
restrictedPoint.y = MIN(MAX(aPoint.y, 0.0), CGRectGetMaxY(visibleFrame) - 8.0);
|
||||
restrictedPoint.y = MIN(MAX(aPoint.y, minPointY), CGRectGetMaxY(visibleFrame) - 8.0);
|
||||
|
||||
return restrictedPoint;
|
||||
}
|
||||
@@ -222,7 +228,7 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (CPImage)showsResizeIndicator
|
||||
- (BOOL)showsResizeIndicator
|
||||
{
|
||||
return _resizeIndicator !== nil;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
{
|
||||
var theWindow = [self window];
|
||||
|
||||
if ([theWindow respondsToSelector:@selector(becomesKeyOnlyIfNeeded)] && [theWindow becomesKeyOnlyIfNeeded])
|
||||
if ([theWindow respondsToSelector:@selector(becomesKeyOnlyIfNeeded)] && [theWindow becomesKeyOnlyIfNeeded])
|
||||
[theWindow orderFront:aSender];
|
||||
else
|
||||
[theWindow makeKeyAndOrderFront:aSender];
|
||||
@@ -173,6 +173,14 @@
|
||||
|
||||
if (_window === nil && [_cibOwner isKindOfClass:[CPDocument class]])
|
||||
[self setWindow:[_cibOwner valueForKey:@"window"]];
|
||||
|
||||
if (!_window)
|
||||
{
|
||||
var reason = [CPString stringWithFormat:@"Window for %@ could not be loaded from Cib or no window specified. \
|
||||
Override loadWindow to load the window manually.", self];
|
||||
|
||||
[CPException raise:CPInternalInconsistencyException reason:reason];
|
||||
}
|
||||
|
||||
[self windowDidLoad];
|
||||
[_document windowControllerDidLoadCib:self];
|
||||
|
||||
@@ -60,7 +60,7 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
|
||||
|
||||
if (self)
|
||||
{
|
||||
_data = [CPURLConnection sendSynchronousRequest:[CPURLRequest requestWithURL:aURL] returningResponse:nil error:nil];
|
||||
_data = [CPURLConnection sendSynchronousRequest:[CPURLRequest requestWithURL:aURL] returningResponse:nil];
|
||||
_awakenCustomResources = YES;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
|
||||
|
||||
- (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data
|
||||
{
|
||||
_data = [CPData dataWithString:data];
|
||||
_data = [CPData dataWithRawString:data];
|
||||
}
|
||||
|
||||
- (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
var selectorName = _label,
|
||||
selectorNameLength = [selectorName length];
|
||||
|
||||
if (selectorNameLength && selectorName[selectorNameLength - 1] !== ':')
|
||||
if (selectorNameLength && selectorName.charAt(selectorNameLength - 1) !== ':')
|
||||
selectorName += ':';
|
||||
|
||||
var selector = CPSelectorFromString(selectorName);
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
|
||||
var CPCibOwner = @"CPCibOwner";
|
||||
|
||||
var LoadInfoForCib = {};
|
||||
|
||||
@implementation CPObject (CPCibLoading)
|
||||
|
||||
- (void)awakeFromCib
|
||||
@@ -63,9 +61,11 @@ var LoadInfoForCib = {};
|
||||
|
||||
+ (void)loadCibFile:(CPString)anAbsolutePath externalNameTable:(CPDictionary)aNameTable loadDelegate:aDelegate
|
||||
{
|
||||
var cib = [[CPCib alloc] initWithContentsOfURL:anAbsolutePath loadDelegate:self];
|
||||
|
||||
LoadInfoForCib[[cib UID]] = { loadDelegate:aDelegate, externalNameTable:aNameTable };
|
||||
[[CPCib alloc]
|
||||
initWithContentsOfURL:anAbsolutePath
|
||||
loadDelegate:[[_CPCibLoadDelegate alloc]
|
||||
initWithLoadDelegate:aDelegate
|
||||
externalNameTable:aNameTable]];
|
||||
}
|
||||
|
||||
+ (void)loadCibNamed:(CPString)aName owner:(id)anOwner loadDelegate:(id)aDelegate
|
||||
@@ -82,20 +82,40 @@ var LoadInfoForCib = {};
|
||||
|
||||
- (void)loadCibFile:(CPString)aFileName externalNameTable:(CPDictionary)aNameTable loadDelegate:(id)aDelegate
|
||||
{
|
||||
var cib = [[CPCib alloc] initWithCibNamed:aFileName bundle:self loadDelegate:[self class]];
|
||||
|
||||
LoadInfoForCib[[cib UID]] = { loadDelegate:aDelegate, externalNameTable:aNameTable };
|
||||
}
|
||||
|
||||
+ (void)cibDidFinishLoading:(CPCib)aCib
|
||||
{
|
||||
var loadInfo = LoadInfoForCib[[aCib UID]];
|
||||
|
||||
delete LoadInfoForCib[[aCib UID]];
|
||||
|
||||
[aCib instantiateCibWithExternalNameTable:loadInfo.externalNameTable];
|
||||
|
||||
[loadInfo.loadDelegate cibDidFinishLoading:aCib];
|
||||
[[CPCib alloc]
|
||||
initWithCibNamed:aFileName
|
||||
bundle:self
|
||||
loadDelegate:[[_CPCibLoadDelegate alloc]
|
||||
initWithLoadDelegate:aDelegate
|
||||
externalNameTable:aNameTable]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPCibLoadDelegate : CPObject
|
||||
{
|
||||
id _loadDelegate;
|
||||
CPDictionary _externalNameTable;
|
||||
}
|
||||
|
||||
- (id)initWithLoadDelegate:(id)aLoadDelegate externalNameTable:(id)anExternalNameTable
|
||||
{
|
||||
self = [self init];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_loadDelegate = aLoadDelegate;
|
||||
_externalNameTable = anExternalNameTable;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)cibDidFinishLoading:(CPCib)aCib
|
||||
{
|
||||
[aCib instantiateCibWithExternalNameTable:_externalNameTable];
|
||||
|
||||
[_loadDelegate cibDidFinishLoading:aCib];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -83,7 +83,7 @@ var _CPCibCustomResourceClassNameKey = @"_CPCibCustomResourceClassNameKey",
|
||||
if ([aCoder respondsToSelector:@selector(bundle)] &&
|
||||
(![aCoder respondsToSelector:@selector(awakenCustomResources)] || [aCoder awakenCustomResources]))
|
||||
if (_className === @"CPImage")
|
||||
return [[CPImage alloc] initWithContentsOfFile:[[aCoder bundle] pathForResource:_resourceName] size:[_properties objectForKey:@"size"]];
|
||||
return [[CPImage alloc] initWithContentsOfFile:[[aCoder bundle] pathForResource:_resourceName] size:_properties.valueForKey(@"size")];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,13 @@
|
||||
|
||||
- (void)setCustomClassName:(CPString)aClassName
|
||||
{
|
||||
if (_className === aClassName)
|
||||
return;
|
||||
|
||||
_className = aClassName;
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -97,9 +103,7 @@ var _CPCibCustomViewClassNameKey = @"_CPCibCustomViewClassNameKey";
|
||||
[view setBounds:[self bounds]];
|
||||
|
||||
// Since the object replacement logic hasn't had a chance to kick in yet, we need to do it manually:
|
||||
|
||||
// we need to copy subviews since each time we add a subview to a different view its removed from the original subviews array
|
||||
var subviews = [[self subviews] copy],
|
||||
var subviews = [self subviews],
|
||||
index = 0,
|
||||
count = subviews.length;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinS
|
||||
_CPCibWindowTemplateWindowViewKey = @"_CPCibWindowTemplateWindowViewKey",
|
||||
|
||||
_CPCibWindowTemplateWindowAutorecalculatesKeyViewLoop = @"_CPCibWindowTemplateWindowAutorecalculatesKeyViewLoop";
|
||||
_CPCibWindowTemplateWindowIsFullPlatformWindowKey = @"_CPCibWindowTemplateWindowIsFullPlatformWindowKey";
|
||||
_CPCibWindowTemplateWindowIsFullPlatformWindowKey = @"_CPCibWindowTemplateWindowIsFullPlatformWindowKey";
|
||||
|
||||
@implementation _CPCibWindowTemplate : CPObject
|
||||
{
|
||||
@@ -134,9 +134,8 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinS
|
||||
[theWindow setMinSize:_minSize];
|
||||
if (_maxSize)
|
||||
[theWindow setMaxSize:_maxSize];
|
||||
[theWindow setLevel:CPFloatingWindowLevel];
|
||||
|
||||
//[result setHidesOnDeactivate:(_wtFlags&0x80000000)?YES:NO];
|
||||
//[result setHidesOnDeactivate:(_wtFlags&0x80000000)?YES:NO];
|
||||
[theWindow setTitle:_windowTitle];
|
||||
|
||||
// FIXME: we can't autoresize yet...
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
|
||||
require("../common.jake");
|
||||
|
||||
var framework = require("objective-j/jake").framework;
|
||||
var BundleTask = require("objective-j/jake").BundleTask;
|
||||
|
||||
$BUILD_PATH = FILE.join($BUILD_DIR, $CONFIGURATION, 'AppKit');
|
||||
|
||||
AppKitFiles = new FileList("**/*.j").exclude('CoreGraphics/CGContextCanvas.j', 'CoreGraphics/CGContextVML.j', 'Themes/**/*', 'Tools/**/*');
|
||||
AppKitFiles = new FileList("**/*.j").exclude('CoreGraphics/CGContextCanvas.j', 'CoreGraphics/CGContextVML.j', 'Themes/**/*', 'Tools/**/*', "Platform/DOM/CPPlatform.j", "Platform/DOM/CPPlatformString.j");
|
||||
|
||||
FIXME_fileDependency (FILE.join("Platform", "CPPlatform.j"), FILE.join("Platform", "DOM", "CPPlatform.j"));
|
||||
FIXME_fileDependency (FILE.join("Platform", "CPPlatformString.j"), FILE.join("Platform", "DOM", "CPPlatformString.j"));
|
||||
|
||||
appKitTask = framework ("AppKit", function(appKitTask)
|
||||
{
|
||||
@@ -15,7 +20,7 @@ appKitTask = framework ("AppKit", function(appKitTask)
|
||||
appKitTask.setEmail("feedback @nospam@ 280north.com");
|
||||
appKitTask.setSummary("AppKit classes for Cappuccino");
|
||||
appKitTask.setIdentifier("com.280n.AppKit");
|
||||
appKitTask.setVersion("0.7.9");
|
||||
appKitTask.setVersion(getCappuccinoVersion());
|
||||
appKitTask.setLicense(BundleTask.License.LGPL_v2_1);
|
||||
appKitTask.setSources(AppKitFiles);
|
||||
appKitTask.setResources(new FileList("Resources/**/*"));
|
||||
|
||||
@@ -1,72 +1,82 @@
|
||||
/*
|
||||
* CPPlatform.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2010, 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>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
||||
@implementation CPPlatform : CPObject
|
||||
@implementation CPBasePlatform : CPObject
|
||||
{
|
||||
}
|
||||
|
||||
+ (void)bootstrap
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var body = document.getElementsByTagName("body")[0];
|
||||
|
||||
body.innerHTML = ""; // Get rid of anything that might be lingering in the body element.
|
||||
body.style.overflow = "hidden";
|
||||
|
||||
if (document.documentElement)
|
||||
document.documentElement.style.overflow = "hidden";
|
||||
#endif
|
||||
|
||||
[CPPlatformString bootstrap];
|
||||
[CPPlatformWindow setPrimaryPlatformWindow:[[CPPlatformWindow alloc] _init]];
|
||||
}
|
||||
|
||||
+ (BOOL)isBrowser
|
||||
{
|
||||
return typeof window.cpIsDesktop === "undefined";
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (BOOL)supportsDragAndDrop
|
||||
{
|
||||
return CPFeatureIsCompatible(CPHTMLDragAndDropFeature);
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (BOOL)supportsNativeMainMenu
|
||||
{
|
||||
return (typeof window["cpSetMainMenu"] === "function");
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (void)terminateApplication
|
||||
{
|
||||
if (typeof window["cpTerminate"] === "function")
|
||||
window.cpTerminate();
|
||||
}
|
||||
|
||||
+ (void)activateIgnoringOtherApps:(BOOL)shouldIgnoreOtherApps
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (typeof window["cpActivateIgnoringOtherApps"] === "function")
|
||||
window.cpActivateIgnoringOtherApps(!!shouldIgnoreOtherApps);
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (void)deactivate
|
||||
{
|
||||
}
|
||||
|
||||
+ (void)hideOtherApplications:(id)aSender
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (typeof window["cpHideOtherApplications"] === "function")
|
||||
window.cpHideOtherApplications();
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (void)hide:(id)aSender
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (typeof window["cpHide"] === "function")
|
||||
window.cpHide();
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
#include "DOM/CPPlatform.j"
|
||||
#else
|
||||
@implementation CPPlatform : CPBasePlatform
|
||||
{
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,24 @@
|
||||
|
||||
/*
|
||||
* CPPlatformString.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2010, 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>
|
||||
|
||||
@@ -6,99 +26,26 @@
|
||||
#include "Platform.h"
|
||||
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var DOMIFrameElement = nil,
|
||||
DOMSpanElement = nil,
|
||||
DefaultFont = nil;
|
||||
#endif
|
||||
|
||||
@implementation CPPlatformString : CPObject
|
||||
@implementation CPBasePlatformString : CPObject
|
||||
{
|
||||
}
|
||||
|
||||
+ (void)bootstrap
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
DOMIFrameElement = document.createElement("iframe");
|
||||
|
||||
DOMIFrameElement.name = name = "iframe_" + FLOOR(RAND() * 10000);
|
||||
DOMIFrameElement.style.position = "absolute";
|
||||
DOMIFrameElement.style.left = "-100px";
|
||||
DOMIFrameElement.style.top = "-100px";
|
||||
DOMIFrameElement.style.width = "1px";
|
||||
DOMIFrameElement.style.height = "1px";
|
||||
DOMIFrameElement.style.borderWidth = "0px";
|
||||
DOMIFrameElement.style.background = "blue";
|
||||
DOMIFrameElement.style.overflow = "hidden";
|
||||
DOMIFrameElement.style.zIndex = 100000000000;
|
||||
|
||||
document.getElementsByTagName("body")[0].appendChild(DOMIFrameElement);
|
||||
|
||||
var DOMIFrameDocument = (DOMIFrameElement.contentDocument || DOMIFrameElement.contentWindow.document);
|
||||
|
||||
DOMIFrameDocument.write("<html><head></head><body></body></html>");
|
||||
DOMIFrameDocument.close();
|
||||
|
||||
DOMSpanElement = DOMIFrameDocument.createElement("span");
|
||||
|
||||
DOMSpanElement.style.position = "absolute";
|
||||
DOMSpanElement.style.whiteSpace = "pre";
|
||||
DOMSpanElement.style.visibility = "visible";
|
||||
DOMSpanElement.style.padding = "0px";
|
||||
DOMSpanElement.style.margin = "0px";
|
||||
DOMSpanElement.style.background = "red";
|
||||
|
||||
DOMIFrameDocument.getElementsByTagName("body")[0].appendChild(DOMSpanElement);
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (CGSize)sizeOfString:(CPString)aString withFont:(CPFont)aFont forWidth:(float)aWidth
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (!aFont)
|
||||
{
|
||||
if (!DefaultFont)
|
||||
DefaultFont = [CPFont systemFontOfSize:12.0];
|
||||
|
||||
aFont = DefaultFont;
|
||||
}
|
||||
|
||||
var style = DOMSpanElement.style;
|
||||
|
||||
if (aWidth === NULL)
|
||||
{
|
||||
style.width = "";
|
||||
style.whiteSpace = "pre";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
style.width = ROUND(aWidth) + "px";
|
||||
|
||||
if (document.attachEvent)
|
||||
style.wordWrap = "break-word";
|
||||
|
||||
else
|
||||
{
|
||||
style.whiteSpace = "-o-pre-wrap";
|
||||
style.whiteSpace = "-pre-wrap";
|
||||
style.whiteSpace = "-moz-pre-wrap";
|
||||
style.whiteSpace = "pre-wrap";
|
||||
}
|
||||
}
|
||||
|
||||
style.font = [aFont cssString];
|
||||
|
||||
if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature))
|
||||
DOMSpanElement.innerText = aString;
|
||||
|
||||
else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature))
|
||||
DOMSpanElement.textContent = aString;
|
||||
|
||||
return _CGSizeMake(DOMSpanElement.clientWidth, DOMSpanElement.clientHeight);
|
||||
#else
|
||||
return _CGSizeMakeZero();
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
#include "DOM/CPPlatformString.j"
|
||||
#else
|
||||
@implementation CPPlatformString : CPBasePlatformString
|
||||
{
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,31 @@
|
||||
/*
|
||||
* CPPlatformWindow.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2010, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
#import "Platform.h"
|
||||
#import "../CoreGraphics/CGGeometry.h"
|
||||
|
||||
|
||||
var PrimaryPlatformWindow = NULL;
|
||||
|
||||
@implementation CPPlatformWindow : CPObject
|
||||
@@ -30,6 +52,10 @@ var PrimaryPlatformWindow = NULL;
|
||||
|
||||
Object _charCodes;
|
||||
unsigned _keyCode;
|
||||
unsigned _lastKey;
|
||||
BOOL _capsLockActive;
|
||||
BOOL _ignoreNativeCopyOrCutEvent;
|
||||
BOOL _ignoreNativePastePreparation;
|
||||
|
||||
BOOL _DOMEventMode;
|
||||
|
||||
@@ -41,6 +67,11 @@ var PrimaryPlatformWindow = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (CPSet)visiblePlatformWindows
|
||||
{
|
||||
return [CPSet set];
|
||||
}
|
||||
|
||||
+ (CPPlatformWindow)primaryPlatformWindow
|
||||
{
|
||||
return PrimaryPlatformWindow;
|
||||
@@ -95,7 +126,7 @@ var PrimaryPlatformWindow = NULL;
|
||||
|
||||
frame.origin = CGPointMakeZero();
|
||||
|
||||
if ([CPMenu menuBarVisible])
|
||||
if ([CPMenu menuBarVisible] && [CPPlatformWindow primaryPlatformWindow] === self)
|
||||
{
|
||||
var menuBarHeight = [[CPApp mainMenu] menuBarHeight];
|
||||
|
||||
@@ -106,7 +137,7 @@ var PrimaryPlatformWindow = NULL;
|
||||
return frame;
|
||||
}
|
||||
|
||||
- (void)usableContentFrame
|
||||
- (CGRect)usableContentFrame
|
||||
{
|
||||
return [self visibleFrame];
|
||||
}
|
||||
@@ -165,6 +196,20 @@ var PrimaryPlatformWindow = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)moveWindow:(CPWindow)aWindow fromLevel:(int)fromLevel toLevel:(int)toLevel
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (!aWindow._isVisible)
|
||||
return;
|
||||
|
||||
var fromLayer = [self layerAtLevel:fromLevel create:NO],
|
||||
toLayer = [self layerAtLevel:toLevel create:YES];
|
||||
|
||||
[fromLayer removeWindow:aWindow];
|
||||
[toLayer insertWindow:aWindow atIndex:CPNotFound];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)setLevel:(CPInteger)aLevel
|
||||
{
|
||||
_level = aLevel;
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* CPPlatform+DOM.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2010, 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
|
||||
*/
|
||||
|
||||
if (typeof window["CPPlatformEnableHTMLDragAndDrop"] === "undefined")
|
||||
CPPlatformEnableHTMLDragAndDrop = NO;
|
||||
|
||||
CPPlatformDidClearBodyElementNotification = @"CPPlatformDidClearBodyElementNotification";
|
||||
CPPlatformWillClearBodyElementNotification = @"CPPlatformWillClearBodyElementNotification";
|
||||
|
||||
var screenNeedsInitialization = NO,
|
||||
mainBodyElement = nil,
|
||||
elementRemovalTest = new RegExp("\\bcpdontremove\\b", "g");
|
||||
|
||||
@implementation CPPlatform : CPBasePlatform
|
||||
{
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self !== [CPPlatform class])
|
||||
return;
|
||||
|
||||
screenNeedsInitialization = [CPPlatform isBrowser];
|
||||
}
|
||||
|
||||
+ (BOOL)isBrowser
|
||||
{
|
||||
return typeof window.cpIsDesktop === "undefined";
|
||||
}
|
||||
|
||||
+ (BOOL)supportsDragAndDrop
|
||||
{
|
||||
return CPFeatureIsCompatible(CPHTMLDragAndDropFeature) && (CPPlatformEnableHTMLDragAndDrop || ![self isBrowser]);
|
||||
}
|
||||
|
||||
+ (BOOL)supportsNativeMainMenu
|
||||
{
|
||||
return (typeof window["cpSetMainMenu"] === "function");
|
||||
}
|
||||
|
||||
+ (void)terminateApplication
|
||||
{
|
||||
if (typeof window["cpTerminate"] === "function")
|
||||
window.cpTerminate();
|
||||
}
|
||||
|
||||
+ (void)activateIgnoringOtherApps:(BOOL)shouldIgnoreOtherApps
|
||||
{
|
||||
if (typeof window["cpActivateIgnoringOtherApps"] === "function")
|
||||
window.cpActivateIgnoringOtherApps(!!shouldIgnoreOtherApps);
|
||||
}
|
||||
|
||||
+ (void)deactivate
|
||||
{
|
||||
if (typeof window["cpDeactivate"] === "function")
|
||||
window.cpDeactivate();
|
||||
}
|
||||
|
||||
+ (void)hideOtherApplications:(id)aSender
|
||||
{
|
||||
if (typeof window["cpHideOtherApplications"] === "function")
|
||||
window.cpHideOtherApplications();
|
||||
}
|
||||
|
||||
+ (void)hide:(id)aSender
|
||||
{
|
||||
if (typeof window["cpHide"] === "function")
|
||||
window.cpHide();
|
||||
}
|
||||
|
||||
+ (DOMElement)mainBodyElement
|
||||
{
|
||||
if (!mainBodyElement)
|
||||
mainBodyElement = document.getElementById("cappuccino-body") || document.body;
|
||||
|
||||
return mainBodyElement;
|
||||
}
|
||||
|
||||
+ (void)initializeScreenIfNecessary
|
||||
{
|
||||
if (!screenNeedsInitialization)
|
||||
return;
|
||||
|
||||
screenNeedsInitialization = NO;
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPPlatformWillClearBodyElementNotification
|
||||
object:self];
|
||||
|
||||
var bodyElement = [self mainBodyElement];
|
||||
|
||||
// Get rid of any of the original contents of the page.
|
||||
var children = bodyElement.childNodes,
|
||||
length = children.length;
|
||||
|
||||
while (length--)
|
||||
{
|
||||
var element = children[length];
|
||||
if (!element.className || element.className.match(elementRemovalTest) === null)
|
||||
bodyElement.removeChild(element);
|
||||
}
|
||||
|
||||
bodyElement.style.overflow = "hidden";
|
||||
|
||||
if (document.documentElement)
|
||||
document.documentElement.style.overflow = "hidden";
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPPlatformDidClearBodyElementNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* CPPlatformString.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2010, 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
|
||||
*/
|
||||
|
||||
#include "../CoreGraphics/CGGeometry.h"
|
||||
|
||||
var DOMSpanElement = nil,
|
||||
DOMIFrameElement = nil,
|
||||
DefaultFont = nil;
|
||||
|
||||
@implementation CPPlatformString : CPBasePlatformString
|
||||
{
|
||||
}
|
||||
|
||||
+ (void)bootstrap
|
||||
{
|
||||
[self createDOMElements];
|
||||
}
|
||||
|
||||
+ (void)createDOMElements
|
||||
{
|
||||
DOMIFrameElement = document.createElement("iframe");
|
||||
// necessary for Safari caching bug:
|
||||
DOMIFrameElement.name = "iframe_" + FLOOR(RAND() * 10000);
|
||||
DOMIFrameElement.style.position = "absolute";
|
||||
DOMIFrameElement.style.left = "-100px";
|
||||
DOMIFrameElement.style.top = "-100px";
|
||||
DOMIFrameElement.style.width = "1px";
|
||||
DOMIFrameElement.style.height = "1px";
|
||||
DOMIFrameElement.style.borderWidth = "0px";
|
||||
DOMIFrameElement.style.overflow = "hidden";
|
||||
DOMIFrameElement.style.zIndex = 100000000000;
|
||||
DOMIFrameElement.className = "cpdontremove";
|
||||
|
||||
var bodyElement = [CPPlatform mainBodyElement];
|
||||
|
||||
bodyElement.appendChild(DOMIFrameElement);
|
||||
|
||||
var DOMIFrameDocument = (DOMIFrameElement.contentDocument || DOMIFrameElement.contentWindow.document);
|
||||
DOMIFrameDocument.write("<html><head></head><body></body></html>");
|
||||
DOMIFrameDocument.close();
|
||||
|
||||
// IE needs this wide <div> to prevent unwanted text wrapping:
|
||||
var DOMDivElement = DOMIFrameDocument.createElement("div");
|
||||
DOMDivElement.style.position = "absolute";
|
||||
DOMDivElement.style.width = "100000px";
|
||||
|
||||
DOMIFrameDocument.body.appendChild(DOMDivElement);
|
||||
|
||||
DOMSpanElement = DOMIFrameDocument.createElement("span");
|
||||
DOMSpanElement.style.position = "absolute";
|
||||
DOMSpanElement.style.whiteSpace = "pre";
|
||||
DOMSpanElement.style.visibility = "visible";
|
||||
DOMSpanElement.style.padding = "0px";
|
||||
DOMSpanElement.style.margin = "0px";
|
||||
|
||||
DOMDivElement.appendChild(DOMSpanElement);
|
||||
}
|
||||
|
||||
+ (CGSize)sizeOfString:(CPString)aString withFont:(CPFont)aFont forWidth:(float)aWidth
|
||||
{
|
||||
if (!aFont)
|
||||
{
|
||||
if (!DefaultFont)
|
||||
DefaultFont = [CPFont systemFontOfSize:12.0];
|
||||
|
||||
aFont = DefaultFont;
|
||||
}
|
||||
|
||||
if (!DOMIFrameElement)
|
||||
[self createDOMElements];
|
||||
|
||||
var style = DOMSpanElement.style;
|
||||
|
||||
if (!aWidth)
|
||||
{
|
||||
style.width = "";
|
||||
style.whiteSpace = "pre";
|
||||
}
|
||||
else
|
||||
{
|
||||
style.width = ROUND(aWidth) + "px";
|
||||
style.wordWrap = "break-word";
|
||||
style.whiteSpace = "-o-pre-wrap";
|
||||
style.whiteSpace = "-pre-wrap";
|
||||
style.whiteSpace = "-moz-pre-wrap";
|
||||
style.whiteSpace = "pre-wrap";
|
||||
}
|
||||
|
||||
style.font = [aFont cssString];
|
||||
|
||||
if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature))
|
||||
DOMSpanElement.innerText = aString;
|
||||
else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature))
|
||||
DOMSpanElement.textContent = aString;
|
||||
|
||||
return _CGSizeMake(DOMSpanElement.clientWidth, DOMSpanElement.clientHeight);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* _CPDOMWindow.j
|
||||
* CPPlatformWindow+DOM.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
@@ -66,7 +66,7 @@
|
||||
* until the first key is released. This can cause a key event to be fired with
|
||||
* a keyCode for the first key and a charCode for the second key.
|
||||
*
|
||||
* Safari in keypress
|
||||
* Safari 2 in keypress (not supported)
|
||||
*
|
||||
* charCode keyCode which
|
||||
* ENTER: 13 13 13
|
||||
@@ -117,26 +117,12 @@
|
||||
|
||||
@import "CPPlatform.j"
|
||||
@import "CPPlatformWindow.j"
|
||||
@import "CPPlatformWindow+DOMKeys.j"
|
||||
|
||||
#import "../../CoreGraphics/CGGeometry.h"
|
||||
|
||||
|
||||
var DoubleClick = "dblclick",
|
||||
MouseDown = "mousedown",
|
||||
MouseUp = "mouseup",
|
||||
MouseMove = "mousemove",
|
||||
MouseDrag = "mousedrag",
|
||||
KeyUp = "keyup",
|
||||
KeyDown = "keydown",
|
||||
KeyPress = "keypress",
|
||||
Copy = "copy",
|
||||
Paste = "paste",
|
||||
Resize = "resize",
|
||||
ScrollWheel = "mousewheel",
|
||||
TouchStart = "touchstart",
|
||||
TouchMove = "touchmove",
|
||||
TouchEnd = "touchend",
|
||||
TouchCancel = "touchcancel";
|
||||
// List of all open native windows
|
||||
var PlatformWindows = [CPSet set];
|
||||
|
||||
// Define up here so compressor knows about em.
|
||||
var CPDOMEventGetClickCount,
|
||||
@@ -148,9 +134,12 @@ var CPDOMEventGetClickCount,
|
||||
//might be mac only, we should investigate futher later.
|
||||
var KeyCodesToPrevent = {},
|
||||
CharacterKeysToPrevent = {},
|
||||
KeyCodesWithoutKeyPressEvents = { '8':1, '9':1, '16':1, '33':1, '34':1, '35':1, '36':1, '37':1, '38':1, '39':1, '40':1, '46':1, '33':1, '34':1 };
|
||||
MozKeyCodeToKeyCodeMap = {
|
||||
61: 187, // =, equals
|
||||
59: 186 // ;, semicolon
|
||||
};
|
||||
|
||||
var CTRL_KEY_CODE = 17;
|
||||
KeyCodesToPrevent[CPKeyCodes.A] = YES;
|
||||
|
||||
var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
|
||||
@@ -239,11 +228,40 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
_DOMWindow.blur();
|
||||
}
|
||||
|
||||
- (void)createDOMElements
|
||||
{
|
||||
var theDocument = _DOMWindow.document;
|
||||
|
||||
// This guy fixes an issue in Firefox where if you focus the URL field, we stop getting key events
|
||||
_DOMFocusElement = theDocument.createElement("input");
|
||||
|
||||
_DOMFocusElement.style.position = "absolute";
|
||||
_DOMFocusElement.style.zIndex = "-1000";
|
||||
_DOMFocusElement.style.opacity = "0";
|
||||
_DOMFocusElement.style.filter = "alpha(opacity=0)";
|
||||
_DOMFocusElement.className = "cpdontremove";
|
||||
|
||||
_DOMBodyElement.appendChild(_DOMFocusElement);
|
||||
|
||||
// Create Native Pasteboard handler.
|
||||
_DOMPasteboardElement = theDocument.createElement("textarea");
|
||||
|
||||
_DOMPasteboardElement.style.position = "absolute";
|
||||
_DOMPasteboardElement.style.top = "-10000px";
|
||||
_DOMPasteboardElement.style.zIndex = "999";
|
||||
_DOMPasteboardElement.className = "cpdontremove";
|
||||
|
||||
_DOMBodyElement.appendChild(_DOMPasteboardElement);
|
||||
|
||||
// Make sure the pastboard element is blurred.
|
||||
_DOMPasteboardElement.blur();
|
||||
}
|
||||
|
||||
- (void)registerDOMWindow
|
||||
{
|
||||
var theDocument = _DOMWindow.document;
|
||||
|
||||
_DOMBodyElement = theDocument.getElementsByTagName("body")[0];
|
||||
_DOMBodyElement = theDocument.getElementById("cappuccino-body") || theDocument.body;
|
||||
|
||||
// FIXME: Always do this?
|
||||
if ([CPPlatform supportsDragAndDrop])
|
||||
@@ -251,27 +269,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
|
||||
_DOMBodyElement.webkitTouchCallout = "none";
|
||||
|
||||
_DOMFocusElement = theDocument.createElement("input");
|
||||
|
||||
_DOMFocusElement.style.position = "absolute";
|
||||
_DOMFocusElement.style.zIndex = "-1000";
|
||||
_DOMFocusElement.style.opacity = "0";
|
||||
_DOMFocusElement.style.filter = "alpha(opacity=0)";
|
||||
|
||||
_DOMBodyElement.appendChild(_DOMFocusElement);
|
||||
|
||||
// Create Native Pasteboard handler.
|
||||
_DOMPasteboardElement = theDocument.createElement("input");
|
||||
|
||||
_DOMPasteboardElement.style.position = "absolute";
|
||||
_DOMPasteboardElement.style.top = "-10000px";
|
||||
_DOMPasteboardElement.style.zIndex = "99";
|
||||
|
||||
_DOMBodyElement.appendChild(_DOMPasteboardElement);
|
||||
|
||||
// Make sure the pastboard element is blurred.
|
||||
_DOMPasteboardElement.blur();
|
||||
|
||||
[self createDOMElements];
|
||||
[self _addLayers];
|
||||
|
||||
var theClass = [self class],
|
||||
@@ -283,6 +281,14 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
resizeEventImplementation = class_getMethodImplementation(theClass, resizeEventSelector),
|
||||
resizeEventCallback = function (anEvent) { resizeEventImplementation(self, nil, anEvent); },
|
||||
|
||||
copyEventSelector = @selector(copyEvent:),
|
||||
copyEventImplementation = class_getMethodImplementation(theClass, copyEventSelector),
|
||||
copyEventCallback = function (anEvent) {copyEventImplementation(self, nil, anEvent); },
|
||||
|
||||
pasteEventSelector = @selector(pasteEvent:),
|
||||
pasteEventImplementation = class_getMethodImplementation(theClass, pasteEventSelector),
|
||||
pasteEventCallback = function (anEvent) {pasteEventImplementation(self, nil, anEvent); },
|
||||
|
||||
keyEventSelector = @selector(keyEvent:),
|
||||
keyEventImplementation = class_getMethodImplementation(theClass, keyEventSelector),
|
||||
keyEventCallback = function (anEvent) { keyEventImplementation(self, nil, anEvent); },
|
||||
@@ -315,6 +321,10 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
theDocument.addEventListener("mousedown", mouseEventCallback, NO);
|
||||
theDocument.addEventListener("mousemove", mouseEventCallback, NO);
|
||||
|
||||
theDocument.addEventListener("beforecopy", copyEventCallback, NO);
|
||||
theDocument.addEventListener("beforecut", copyEventCallback, NO);
|
||||
theDocument.addEventListener("beforepaste", pasteEventCallback, NO);
|
||||
|
||||
theDocument.addEventListener("keyup", keyEventCallback, NO);
|
||||
theDocument.addEventListener("keydown", keyEventCallback, NO);
|
||||
theDocument.addEventListener("keypress", keyEventCallback, NO);
|
||||
@@ -342,6 +352,10 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
theDocument.removeEventListener("keydown", keyEventCallback, NO);
|
||||
theDocument.removeEventListener("keypress", keyEventCallback, NO);
|
||||
|
||||
theDocument.removeEventListener("beforecopy", copyEventCallback, NO);
|
||||
theDocument.removeEventListener("beforecut", copyEventCallback, NO);
|
||||
theDocument.removeEventListener("beforepaste", pasteEventCallback, NO);
|
||||
|
||||
theDocument.removeEventListener("touchstart", touchEventCallback, NO);
|
||||
theDocument.removeEventListener("touchend", touchEventCallback, NO);
|
||||
theDocument.removeEventListener("touchmove", touchEventCallback, NO);
|
||||
@@ -354,6 +368,8 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
|
||||
//_DOMWindow.removeEventListener("beforeunload", this, NO);
|
||||
|
||||
[PlatformWindows removeObject:self];
|
||||
|
||||
self._DOMWindow = nil;
|
||||
}, NO);
|
||||
}
|
||||
@@ -373,8 +389,8 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
_DOMWindow.onmousewheel = scrollEventCallback;
|
||||
theDocument.onmousewheel = scrollEventCallback;
|
||||
|
||||
theDocument.body.ondrag = function () { return NO; };
|
||||
theDocument.body.onselectstart = function () { return _DOMWindow.event.srcElement === _DOMPasteboardElement; };
|
||||
_DOMBodyElement.ondrag = function () { return NO; };
|
||||
_DOMBodyElement.onselectstart = function () { return _DOMWindow.event.srcElement === _DOMPasteboardElement; };
|
||||
|
||||
_DOMWindow.attachEvent("onbeforeunload", function()
|
||||
{
|
||||
@@ -395,16 +411,30 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
_DOMWindow.onmousewheel = NULL;
|
||||
theDocument.onmousewheel = NULL;
|
||||
|
||||
theDocument.body.ondrag = NULL;
|
||||
theDocument.body.onselectstart = NULL;
|
||||
_DOMBodyElement.ondrag = NULL;
|
||||
_DOMBodyElement.onselectstart = NULL;
|
||||
|
||||
//_DOMWindow.removeEvent("beforeunload", this);
|
||||
|
||||
[PlatformWindows removeObject:self];
|
||||
|
||||
self._DOMWindow = nil;
|
||||
}, NO);
|
||||
}
|
||||
}
|
||||
|
||||
+ (CPSet)visiblePlatformWindows
|
||||
{
|
||||
if ([[CPPlatformWindow primaryPlatformWindow] isVisible])
|
||||
{
|
||||
var set = [CPSet setWithSet:PlatformWindows];
|
||||
[set addObject:[CPPlatformWindow primaryPlatformWindow]];
|
||||
return set;
|
||||
}
|
||||
else
|
||||
return PlatformWindows;
|
||||
}
|
||||
|
||||
- (void)orderFront:(id)aSender
|
||||
{
|
||||
if (_DOMWindow)
|
||||
@@ -412,6 +442,8 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
|
||||
_DOMWindow = window.open("", "_blank", "menubar=no,location=no,resizable=yes,scrollbars=no,status=no,left=" + _CGRectGetMinX(_contentRect) + ",top=" + _CGRectGetMinY(_contentRect) + ",width=" + _CGRectGetWidth(_contentRect) + ",height=" + _CGRectGetHeight(_contentRect));
|
||||
|
||||
[PlatformWindows addObject:self];
|
||||
|
||||
// FIXME: cpSetFrame?
|
||||
_DOMWindow.document.write("<html><head></head><body style = 'background-color:transparent;'></body></html>");
|
||||
_DOMWindow.document.close();
|
||||
@@ -426,6 +458,8 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
}
|
||||
|
||||
[self registerDOMWindow];
|
||||
|
||||
_DOMBodyElement.style.cursor = [[CPCursor currentCursor] _cssString];
|
||||
}
|
||||
|
||||
- (void)orderOut:(id)aSender
|
||||
@@ -458,11 +492,12 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
DOMDragElement.style.left = -_CGRectGetWidth(draggedWindowFrame) + "px";
|
||||
DOMDragElement.style.top = -_CGRectGetHeight(draggedWindowFrame) + "px";
|
||||
|
||||
document.getElementsByTagName("body")[0].appendChild(DOMDragElement);
|
||||
_DOMBodyElement.appendChild(DOMDragElement);
|
||||
|
||||
var draggingOffset = [dragServer draggingOffset];
|
||||
|
||||
aDOMEvent.dataTransfer.setDragImage(DOMDragElement, draggingOffset.width, draggingOffset.height);
|
||||
aDOMEvent.dataTransfer.effectAllowed = "all";
|
||||
|
||||
[dragServer draggingStartedInPlatformWindow:self globalLocation:[CPPlatform isBrowser] ? location : _CGPointMake(aDOMEvent.screenX, aDOMEvent.screenY)];
|
||||
}
|
||||
@@ -538,12 +573,11 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
(aDOMEvent.ctrlKey ? CPControlKeyMask : 0) |
|
||||
(aDOMEvent.altKey ? CPAlternateKeyMask : 0) |
|
||||
(aDOMEvent.metaKey ? CPCommandKeyMask : 0);
|
||||
|
||||
|
||||
//We want to stop propagation if this is a command key AND this character or keycode has been added to our blacklist
|
||||
StopDOMEventPropagation = !(modifierFlags & (CPControlKeyMask | CPCommandKeyMask)) ||
|
||||
|
||||
//We want to stop propagation if this is a command key AND this character or keycode has been added to our blacklist
|
||||
StopDOMEventPropagation = !!(!(modifierFlags & (CPControlKeyMask | CPCommandKeyMask)) ||
|
||||
CharacterKeysToPrevent[String.fromCharCode(aDOMEvent.keyCode || aDOMEvent.charCode).toLowerCase()] ||
|
||||
KeyCodesToPrevent[aDOMEvent.keyCode];
|
||||
KeyCodesToPrevent[aDOMEvent.keyCode]);
|
||||
|
||||
var isNativePasteEvent = NO,
|
||||
isNativeCopyOrCutEvent = NO,
|
||||
@@ -552,56 +586,80 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
switch (aDOMEvent.type)
|
||||
{
|
||||
case "keydown": // Grab and store the keycode now since it is correct and consistent at this point.
|
||||
_keyCode = aDOMEvent.keyCode;
|
||||
if (aDOMEvent.keyCode.keyCode in MozKeyCodeToKeyCodeMap)
|
||||
_keyCode = MozKeyCodeToKeyCodeMap[aDOMEvent.keyCode];
|
||||
else
|
||||
_keyCode = aDOMEvent.keyCode;
|
||||
|
||||
var characters = String.fromCharCode(_keyCode).toLowerCase();
|
||||
overrideCharacters = modifierFlags & CPShiftKeyMask ? characters.toUpperCase() : characters;
|
||||
|
||||
// If this could be a native PASTE event, then we need to further examine it before
|
||||
// sending a CPEvent. Select our element to see if anything gets pasted in it.
|
||||
if (characters == "v" && (modifierFlags & CPPlatformActionKeyMask))
|
||||
overrideCharacters = (modifierFlags & CPShiftKeyMask || _capsLockActive) ? characters.toUpperCase() : characters;
|
||||
|
||||
// check for caps lock state
|
||||
if (_keyCode === CPKeyCodes.CAPS_LOCK)
|
||||
_capsLockActive = YES;
|
||||
|
||||
if (modifierFlags & (CPControlKeyMask | CPCommandKeyMask))
|
||||
{
|
||||
_DOMPasteboardElement.select();
|
||||
_DOMPasteboardElement.value = "";
|
||||
|
||||
isNativePasteEvent = YES;
|
||||
//we are simply going to skip all keypress events that use cmd/ctrl key
|
||||
//this lets us be consistent in all browsers and send on the keydown
|
||||
//which means we can cancel the event early enough, but only if sendEvent needs to
|
||||
|
||||
var eligibleForCopyPaste = [self _validateCopyCutOrPasteEvent:aDOMEvent flags:modifierFlags];
|
||||
|
||||
// If this could be a native PASTE event, then we need to further examine it before
|
||||
// sending a CPEvent. Select our element to see if anything gets pasted in it.
|
||||
if (characters === "v" && eligibleForCopyPaste)
|
||||
{
|
||||
if (!_ignoreNativePastePreparation)
|
||||
{
|
||||
_DOMPasteboardElement.select();
|
||||
_DOMPasteboardElement.value = "";
|
||||
}
|
||||
|
||||
isNativePasteEvent = YES;
|
||||
}
|
||||
|
||||
// However, of this could be a native COPY event, we need to let the normal event-process take place so it
|
||||
// can capture our internal Cappuccino pasteboard.
|
||||
else if ((characters == "c" || characters == "x") && eligibleForCopyPaste)
|
||||
{
|
||||
isNativeCopyOrCutEvent = YES;
|
||||
|
||||
if (_ignoreNativeCopyOrCutEvent)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (CPKeyCodes.firesKeyPressEvent(_keyCode, _lastKey, aDOMEvent.shiftKey, aDOMEvent.ctrlKey, aDOMEvent.altKey))
|
||||
{
|
||||
// this branch is taken by events which fire keydown, keypress, and keyup.
|
||||
// this is the only time we'll ALLOW character keys to propagate (needed for text fields)
|
||||
StopDOMEventPropagation = NO;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
//this branch is taken by "remedial" key events
|
||||
// In this state we continue to keypress and send the CPEvent
|
||||
}
|
||||
|
||||
// Normally we return now because we let keypress send the actual CPEvent keyDown event, since we don't have
|
||||
// a complete set of information yet.
|
||||
|
||||
// However, of this could be a native COPY event, we need to let the normal event-process take place so it
|
||||
// can capture our internal Cappuccino pasteboard.
|
||||
else if ((characters == "c" || characters == "x") && (modifierFlags & CPPlatformActionKeyMask))
|
||||
isNativeCopyOrCutEvent = YES;
|
||||
case "keypress":
|
||||
// we unconditionally break on keypress events with modifiers,
|
||||
// because we forced the event to be sent on the keydown
|
||||
if (aDOMEvent.type === "keypress" && (modifierFlags & (CPControlKeyMask | CPCommandKeyMask)))
|
||||
break;
|
||||
|
||||
// Also, certain browsers (IE and Safari), have broken keyboard supportwhere they don't send keypresses for certain events.
|
||||
// So, allow the keypress event to handle the event if we are not a browser with broken (remedial) key support...
|
||||
else if (!CPFeatureIsCompatible(CPJavascriptRemedialKeySupport))
|
||||
return;
|
||||
|
||||
// Or, if this is not one of those special keycodes, and also not a ctrl+event
|
||||
else if (!KeyCodesWithoutKeyPressEvents[_keyCode] && (_keyCode == CTRL_KEY_CODE || !(modifierFlags & CPControlKeyMask)))
|
||||
return;
|
||||
|
||||
// If this is in fact our broke state, continue to keypress and send the keydown.
|
||||
case "keypress": // If the source of this event is our pasteboard element, then simply let it continue
|
||||
// as normal, so that the paste event can successfully complete.
|
||||
|
||||
if ((aDOMEvent.target || aDOMEvent.srcElement) == _DOMPasteboardElement)
|
||||
return;
|
||||
|
||||
var keyCode = _keyCode,
|
||||
charCode = aDOMEvent.keyCode || aDOMEvent.charCode,
|
||||
isARepeat = (_charCodes[keyCode] != nil);
|
||||
|
||||
_lastKey = keyCode;
|
||||
_charCodes[keyCode] = charCode;
|
||||
|
||||
var characters = overrideCharacters || String.fromCharCode(charCode),
|
||||
charactersIgnoringModifiers = characters.toLowerCase();
|
||||
|
||||
// Safari won't send proper capitalization during cmd-key events
|
||||
if (!overrideCharacters && (modifierFlags & CPCommandKeyMask) && (modifierFlags & CPShiftKeyMask))
|
||||
if (!overrideCharacters && (modifierFlags & CPCommandKeyMask) && ((modifierFlags & CPShiftKeyMask) || _capsLockActive))
|
||||
characters = characters.toUpperCase();
|
||||
|
||||
event = [CPEvent keyEventWithType:CPKeyDown location:location modifierFlags:modifierFlags
|
||||
@@ -612,7 +670,6 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
{
|
||||
_pasteboardKeyDownEvent = event;
|
||||
window.setNativeTimeout(function () { [self _checkPasteboardElement] }, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -620,12 +677,20 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
case "keyup": var keyCode = aDOMEvent.keyCode,
|
||||
charCode = _charCodes[keyCode];
|
||||
|
||||
_keyCode = -1;
|
||||
_lastKey = -1;
|
||||
_charCodes[keyCode] = nil;
|
||||
|
||||
_ignoreNativeCopyOrCutEvent = NO;
|
||||
_ignoreNativePastePreparation = NO;
|
||||
|
||||
// check for caps lock state
|
||||
if (keyCode === CPKeyCodes.CAPS_LOCK)
|
||||
_capsLockActive = NO;
|
||||
|
||||
var characters = String.fromCharCode(charCode),
|
||||
charactersIgnoringModifiers = characters.toLowerCase();
|
||||
|
||||
if (!(modifierFlags & CPShiftKeyMask))
|
||||
if (!(modifierFlags & CPShiftKeyMask) && (modifierFlags & CPCommandKeyMask) && !_capsLockActive)
|
||||
characters = charactersIgnoringModifiers;
|
||||
|
||||
event = [CPEvent keyEventWithType:CPKeyUp location:location modifierFlags:modifierFlags
|
||||
@@ -633,40 +698,126 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
characters:characters charactersIgnoringModifiers:charactersIgnoringModifiers isARepeat:NO keyCode:keyCode];
|
||||
break;
|
||||
}
|
||||
|
||||
if (event)
|
||||
|
||||
if (event && !isNativePasteEvent)
|
||||
{
|
||||
event._DOMEvent = aDOMEvent;
|
||||
|
||||
|
||||
[CPApp sendEvent:event];
|
||||
|
||||
if (isNativeCopyOrCutEvent)
|
||||
{
|
||||
var pasteboard = [CPPasteboard generalPasteboard],
|
||||
types = [pasteboard types];
|
||||
|
||||
// If this is a native copy event, then check if the pasteboard has anything in it.
|
||||
if (types.length)
|
||||
{
|
||||
if ([types indexOfObjectIdenticalTo:CPStringPboardType] != CPNotFound)
|
||||
_DOMPasteboardElement.value = [pasteboard stringForType:CPStringPboardType];
|
||||
else
|
||||
_DOMPasteboardElement.value = [pasteboard _generateStateUID];
|
||||
|
||||
_DOMPasteboardElement.select();
|
||||
|
||||
window.setNativeTimeout(function() { [self _clearPasteboardElement]; }, 0);
|
||||
}
|
||||
|
||||
return;
|
||||
[self _primePasteboardElement];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (StopDOMEventPropagation)
|
||||
CPDOMEventStop(aDOMEvent, self);
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
- (void)copyEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
if ([self _validateCopyCutOrPasteEvent:aDOMEvent flags:CPPlatformActionKeyMask] && !_ignoreNativeCopyOrCutEvent)
|
||||
{
|
||||
//we have to send out a fake copy or cut event so that we can force the copy/cut mechanisms to take place
|
||||
var cut = aDOMEvent.type === "beforecut",
|
||||
keyCode = cut ? CPKeyCodes.X : CPKeyCodes.C,
|
||||
characters = cut ? "x" : "c",
|
||||
timestamp = aDOMEvent.timeStamp ? aDOMEvent.timeStamp : new Date(),
|
||||
windowNumber = [[CPApp keyWindow] windowNumber],
|
||||
modifierFlags = CPPlatformActionKeyMask;
|
||||
|
||||
event = [CPEvent keyEventWithType:CPKeyDown location:location modifierFlags:modifierFlags
|
||||
timestamp:timestamp windowNumber:windowNumber context:nil
|
||||
characters:characters charactersIgnoringModifiers:characters isARepeat:NO keyCode:keyCode];
|
||||
|
||||
event._DOMEvent = aDOMEvent;
|
||||
[CPApp sendEvent:event];
|
||||
|
||||
[self _primePasteboardElement];
|
||||
|
||||
//then we have to IGNORE the real keyboard event to prevent a double copy
|
||||
//safari also sends the beforecopy event twice, so we additionally check here and prevent two events
|
||||
_ignoreNativeCopyOrCutEvent = YES;
|
||||
}
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
- (void)pasteEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
if ([self _validateCopyCutOrPasteEvent:aDOMEvent flags:CPPlatformActionKeyMask])
|
||||
{
|
||||
_DOMPasteboardElement.focus();
|
||||
_DOMPasteboardElement.select();
|
||||
_DOMPasteboardElement.value = "";
|
||||
_ignoreNativePastePreparation = YES;
|
||||
}
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
- (void)_validateCopyCutOrPasteEvent:(DOMEvent)aDOMEvent flags:(unsigned)modifierFlags
|
||||
{
|
||||
return (
|
||||
((aDOMEvent.target || aDOMEvent.srcElement).nodeName.toUpperCase() !== "INPUT" &&
|
||||
(aDOMEvent.target || aDOMEvent.srcElement).nodeName.toUpperCase() !== "TEXTAREA"
|
||||
) || aDOMEvent.target === _DOMPasteboardElement
|
||||
) &&
|
||||
(modifierFlags & CPPlatformActionKeyMask);
|
||||
}
|
||||
|
||||
- (void)_primePasteboardElement
|
||||
{
|
||||
var pasteboard = [CPPasteboard generalPasteboard],
|
||||
types = [pasteboard types];
|
||||
|
||||
if (types.length)
|
||||
{
|
||||
if ([types indexOfObjectIdenticalTo:CPStringPboardType] != CPNotFound)
|
||||
_DOMPasteboardElement.value = [pasteboard stringForType:CPStringPboardType];
|
||||
else
|
||||
_DOMPasteboardElement.value = [pasteboard _generateStateUID];
|
||||
|
||||
_DOMPasteboardElement.focus();
|
||||
_DOMPasteboardElement.select();
|
||||
|
||||
window.setNativeTimeout(function() { [self _clearPasteboardElement]; }, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)_checkPasteboardElement
|
||||
{
|
||||
var value = _DOMPasteboardElement.value;
|
||||
|
||||
if ([value length])
|
||||
{
|
||||
var pasteboard = [CPPasteboard generalPasteboard];
|
||||
|
||||
if ([pasteboard _stateUID] != value)
|
||||
{
|
||||
[pasteboard declareTypes:[CPStringPboardType] owner:self];
|
||||
[pasteboard setString:value forType:CPStringPboardType];
|
||||
}
|
||||
}
|
||||
|
||||
[self _clearPasteboardElement];
|
||||
|
||||
[CPApp sendEvent:_pasteboardKeyDownEvent];
|
||||
|
||||
_pasteboardKeyDownEvent = nil;
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
- (void)_clearPasteboardElement
|
||||
{
|
||||
_DOMPasteboardElement.value = "";
|
||||
_DOMPasteboardElement.blur();
|
||||
}
|
||||
|
||||
- (void)scrollEvent:(DOMEvent)aDOMEvent
|
||||
@@ -750,7 +901,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
|
||||
if (StopDOMEventPropagation)
|
||||
CPDOMEventStop(aDOMEvent, self);
|
||||
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
@@ -760,6 +911,9 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
// We should pay attention to mouse down and mouse up in conjunction with this.
|
||||
//window.liveResize = YES;
|
||||
|
||||
if ([CPPlatform isBrowser])
|
||||
[CPApp._activeMenu cancelTracking];
|
||||
|
||||
var oldSize = [self contentRect].size;
|
||||
|
||||
[self updateFromNativeContentRect];
|
||||
@@ -954,7 +1108,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
(CPArray)orderedWindowsAtLevel:(int)aLevel
|
||||
{
|
||||
var layer = [self layerAtLevel:aLevel create:NO];
|
||||
|
||||
|
||||
if (!layer)
|
||||
return [];
|
||||
|
||||
@@ -964,7 +1118,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
- (CPDOMWindowLayer)layerAtLevel:(int)aLevel create:(BOOL)aFlag
|
||||
{
|
||||
var layer = [_windowLayers objectForKey:aLevel];
|
||||
|
||||
|
||||
// If the layer doesn't currently exist, and the create flag is true,
|
||||
// create the layer.
|
||||
if (!layer && aFlag)
|
||||
@@ -972,7 +1126,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
layer = [[CPDOMWindowLayer alloc] initWithLevel:aLevel];
|
||||
|
||||
[_windowLayers setObject:layer forKey:aLevel];
|
||||
|
||||
|
||||
// Find the nearest layer. This is similar to a binary search,
|
||||
// only we know we won't find the value.
|
||||
var low = 0,
|
||||
@@ -989,7 +1143,11 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
low = middle + 1;
|
||||
}
|
||||
|
||||
[_windowLevels insertObject:aLevel atIndex:_windowLevels[middle] > aLevel ? middle : middle + 1];
|
||||
var insertionIndex = 0;
|
||||
if (middle !== undefined)
|
||||
insertionIndex = _windowLevels[middle] > aLevel ? middle : middle + 1
|
||||
|
||||
[_windowLevels insertObject:aLevel atIndex:insertionIndex];
|
||||
layer._DOMElement.style.zIndex = aLevel;
|
||||
_DOMBodyElement.appendChild(layer._DOMElement);
|
||||
}
|
||||
@@ -999,17 +1157,23 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
|
||||
- (void)order:(CPWindowOrderingMode)aPlace window:(CPWindow)aWindow relativeTo:(CPWindow)otherWindow
|
||||
{
|
||||
[CPPlatform initializeScreenIfNecessary];
|
||||
|
||||
// Grab the appropriate level for the layer, and create it if
|
||||
// necessary (if we are not simply removing the window).
|
||||
var layer = [self layerAtLevel:[aWindow level] create:aPlace != CPWindowOut];
|
||||
|
||||
var layer = [self layerAtLevel:[aWindow level] create:aPlace !== CPWindowOut];
|
||||
|
||||
// Ignore otherWindow, simply remove this window from it's level.
|
||||
// If layer is nil, this will be a no-op.
|
||||
if (aPlace == CPWindowOut)
|
||||
if (aPlace === CPWindowOut)
|
||||
return [layer removeWindow:aWindow];
|
||||
|
||||
var insertionIndex = CPNotFound;
|
||||
if (otherWindow)
|
||||
insertionIndex = aPlace === CPWindowAbove ? otherWindow._index + 1 : otherWindow._index;
|
||||
|
||||
// Place the window at the appropriate index.
|
||||
[layer insertWindow:aWindow atIndex:(otherWindow ? (aPlace == CPWindowAbove ? otherWindow._index + 1 : otherWindow._index) : CPNotFound)];
|
||||
[layer insertWindow:aWindow atIndex:insertionIndex];
|
||||
}
|
||||
|
||||
- (void)_removeLayers
|
||||
@@ -1077,8 +1241,16 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
StopDOMEventPropagation = !aFlag;
|
||||
}
|
||||
|
||||
- (BOOL)_willPropagateCurrentDOMEvent
|
||||
{
|
||||
return !StopDOMEventPropagation;
|
||||
}
|
||||
|
||||
- (CPWindow)hitTest:(CPPoint)location
|
||||
{if (self._only) return self._only;
|
||||
{
|
||||
if (self._only)
|
||||
return self._only;
|
||||
|
||||
var levels = _windowLevels,
|
||||
layers = _windowLayers,
|
||||
levelCount = levels.length,
|
||||
@@ -1101,37 +1273,6 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
return theWindow;
|
||||
}
|
||||
|
||||
- (void)_checkPasteboardElement
|
||||
{
|
||||
var value = _DOMPasteboardElement.value;
|
||||
|
||||
if ([value length])
|
||||
{
|
||||
var pasteboard = [CPPasteboard generalPasteboard];
|
||||
|
||||
if ([pasteboard _stateUID] != value)
|
||||
{
|
||||
[pasteboard declareTypes:[CPStringPboardType] owner:self];
|
||||
|
||||
[pasteboard setString:value forType:CPStringPboardType];
|
||||
}
|
||||
}
|
||||
|
||||
[self _clearPasteboardElement];
|
||||
|
||||
[CPApp sendEvent:_pasteboardKeyDownEvent];
|
||||
|
||||
_pasteboardKeyDownEvent = nil;
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
- (void)_clearPasteboardElement
|
||||
{
|
||||
_DOMPasteboardElement.value = "";
|
||||
_DOMPasteboardElement.blur();
|
||||
}
|
||||
|
||||
/*!
|
||||
When using command (mac) or control (windows), keys are propagated to the browser by default.
|
||||
To prevent a character key from propagating (to prevent its default action, and instead use it
|
||||
@@ -1247,19 +1388,25 @@ var CPDOMEventStop = function(aDOMEvent, aPlatformWindow)
|
||||
|
||||
function CPWindowObjectList()
|
||||
{
|
||||
var platformWindow = [CPPlatformWindow primaryPlatformWindow],
|
||||
levels = platformWindow._windowLevels,
|
||||
layers = platformWindow._windowLayers,
|
||||
levelCount = levels.length,
|
||||
var platformWindows = [CPPlatformWindow visiblePlatformWindows],
|
||||
platformWindowEnumerator = [platformWindows objectEnumerator],
|
||||
platformWindow = nil,
|
||||
windowObjects = [];
|
||||
|
||||
while (levelCount--)
|
||||
while (platformWindow = [platformWindowEnumerator nextObject])
|
||||
{
|
||||
var windows = [layers objectForKey:levels[levelCount]]._windows,
|
||||
windowCount = windows.length;
|
||||
var levels = platformWindow._windowLevels,
|
||||
layers = platformWindow._windowLayers,
|
||||
levelCount = levels.length;
|
||||
|
||||
while (windowCount--)
|
||||
windowObjects.push(windows[windowCount]);
|
||||
while (levelCount--)
|
||||
{
|
||||
var windows = [layers objectForKey:levels[levelCount]]._windows,
|
||||
windowCount = windows.length;
|
||||
|
||||
while (windowCount--)
|
||||
windowObjects.push(windows[windowCount]);
|
||||
}
|
||||
}
|
||||
|
||||
return windowObjects;
|
||||
@@ -1267,20 +1414,11 @@ function CPWindowObjectList()
|
||||
|
||||
function CPWindowList()
|
||||
{
|
||||
var platformWindow = [CPPlatformWindow primaryPlatformWindow],
|
||||
levels = platformWindow._windowLevels,
|
||||
layers = platformWindow._windowLayers,
|
||||
levelCount = levels.length,
|
||||
windowNumbers = [];
|
||||
var windowObjectList = CPWindowObjectList(),
|
||||
windowList = [];
|
||||
|
||||
while (levelCount--)
|
||||
{
|
||||
var windows = [layers objectForKey:levels[levelCount]]._windows,
|
||||
windowCount = windows.length;
|
||||
for (var i = 0, count = [windowObjectList count]; i < count; i++)
|
||||
windowList.push([windowObjectList[i] windowNumber]);
|
||||
|
||||
while (windowCount--)
|
||||
windowNumbers.push([windows[windowCount] windowNumber]);
|
||||
}
|
||||
|
||||
return windowNumbers;
|
||||
return windowList;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* CPPlatformWindow+DOMKeys.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Ross Boucher.
|
||||
* Copyright 2009, 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
|
||||
*/
|
||||
|
||||
// Keycodes taken and modified from Google Closure, available under Apache 2 License
|
||||
|
||||
CPKeyCodes = {
|
||||
BACKSPACE: 8,
|
||||
TAB: 9,
|
||||
NUM_CENTER: 12,
|
||||
ENTER: 13,
|
||||
SHIFT: 16,
|
||||
CTRL: 17,
|
||||
ALT: 18,
|
||||
PAUSE: 19,
|
||||
CAPS_LOCK: 20,
|
||||
ESC: 27,
|
||||
SPACE: 32,
|
||||
PAGE_UP: 33, // also NUM_NORTH_EAST
|
||||
PAGE_DOWN: 34, // also NUM_SOUTH_EAST
|
||||
END: 35, // also NUM_SOUTH_WEST
|
||||
HOME: 36, // also NUM_NORTH_WEST
|
||||
LEFT: 37, // also NUM_WEST
|
||||
UP: 38, // also NUM_NORTH
|
||||
RIGHT: 39, // also NUM_EAST
|
||||
DOWN: 40, // also NUM_SOUTH
|
||||
PRINT_SCREEN: 44,
|
||||
INSERT: 45, // also NUM_INSERT
|
||||
DELETE: 46, // also NUM_DELETE
|
||||
ZERO: 48,
|
||||
ONE: 49,
|
||||
TWO: 50,
|
||||
THREE: 51,
|
||||
FOUR: 52,
|
||||
FIVE: 53,
|
||||
SIX: 54,
|
||||
SEVEN: 55,
|
||||
EIGHT: 56,
|
||||
NINE: 57,
|
||||
QUESTION_MARK: 63, // needs localization
|
||||
A: 65,
|
||||
B: 66,
|
||||
C: 67,
|
||||
D: 68,
|
||||
E: 69,
|
||||
F: 70,
|
||||
G: 71,
|
||||
H: 72,
|
||||
I: 73,
|
||||
J: 74,
|
||||
K: 75,
|
||||
L: 76,
|
||||
M: 77,
|
||||
N: 78,
|
||||
O: 79,
|
||||
P: 80,
|
||||
Q: 81,
|
||||
R: 82,
|
||||
S: 83,
|
||||
T: 84,
|
||||
U: 85,
|
||||
V: 86,
|
||||
W: 87,
|
||||
X: 88,
|
||||
Y: 89,
|
||||
Z: 90,
|
||||
META: 91,
|
||||
CONTEXT_MENU: 93,
|
||||
NUM_ZERO: 96,
|
||||
NUM_ONE: 97,
|
||||
NUM_TWO: 98,
|
||||
NUM_THREE: 99,
|
||||
NUM_FOUR: 100,
|
||||
NUM_FIVE: 101,
|
||||
NUM_SIX: 102,
|
||||
NUM_SEVEN: 103,
|
||||
NUM_EIGHT: 104,
|
||||
NUM_NINE: 105,
|
||||
NUM_MULTIPLY: 106,
|
||||
NUM_PLUS: 107,
|
||||
NUM_MINUS: 109,
|
||||
NUM_PERIOD: 110,
|
||||
NUM_DIVISION: 111,
|
||||
F1: 112,
|
||||
F2: 113,
|
||||
F3: 114,
|
||||
F4: 115,
|
||||
F5: 116,
|
||||
F6: 117,
|
||||
F7: 118,
|
||||
F8: 119,
|
||||
F9: 120,
|
||||
F10: 121,
|
||||
F11: 122,
|
||||
F12: 123,
|
||||
NUMLOCK: 144,
|
||||
SEMICOLON: 186, // needs localization
|
||||
DASH: 189, // needs localization
|
||||
EQUALS: 187, // needs localization
|
||||
COMMA: 188, // needs localization
|
||||
PERIOD: 190, // needs localization
|
||||
SLASH: 191, // needs localization
|
||||
APOSTROPHE: 192, // needs localization
|
||||
SINGLE_QUOTE: 222, // needs localization
|
||||
OPEN_SQUARE_BRACKET: 219, // needs localization
|
||||
BACKSLASH: 220, // needs localization
|
||||
CLOSE_SQUARE_BRACKET: 221, // needs localization
|
||||
WIN_KEY: 224,
|
||||
MAC_FF_META: 224, // Firefox (Gecko) fires this for the meta key instead of 91
|
||||
WIN_IME: 229
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* Returns true if the key fires a keypress event in the current browser.
|
||||
*
|
||||
* Accoridng to MSDN [1] IE only fires keypress events for the following keys:
|
||||
* - Letters: A - Z (uppercase and lowercase)
|
||||
* - Numerals: 0 - 9
|
||||
* - Symbols: ! @ # $ % ^ & * ( ) _ - + = < [ ] { } , . / ? \ | ' ` " ~
|
||||
* - System: ESC, SPACEBAR, ENTER
|
||||
*
|
||||
* That's not entirely correct though, for instance there's no distinction
|
||||
* between upper and lower case letters.
|
||||
*
|
||||
* [1] http://msdn2.microsoft.com/en-us/library/ms536939(VS.85).aspx)
|
||||
*
|
||||
* Safari is similar to IE, but does not fire keypress for ESC.
|
||||
*
|
||||
* Additionally, IE6 does not fire keydown or keypress events for letters when
|
||||
* the control or alt keys are held down and the shift key is not. IE7 does
|
||||
* fire keydown in these cases, though, but not keypress.
|
||||
*
|
||||
* @param keyCode A key code.
|
||||
* @param opt_heldKeyCode Key code of a currently-held key.
|
||||
* @param opt_shiftKey Whether the shift key is held down.
|
||||
* @param opt_ctrlKey Whether the control key is held down.
|
||||
* @param opt_altKey Whether the alt key is held down.
|
||||
* @return Returns YES if it's a key that fires a keypress event.
|
||||
*/
|
||||
CPKeyCodes.firesKeyPressEvent = function(keyCode, opt_heldKeyCode, opt_shiftKey, opt_ctrlKey, opt_altKey)
|
||||
{
|
||||
if (!CPFeatureIsCompatible(CPJavascriptRemedialKeySupport))
|
||||
return true;
|
||||
|
||||
if (CPBrowserIsOperatingSystem(CPMacOperatingSystem) && opt_altKey)
|
||||
return CPKeyCodes.isCharacterKey(keyCode);
|
||||
|
||||
// Alt but not AltGr which is represented as Alt+Ctrl.
|
||||
if (opt_altKey && !opt_ctrlKey)
|
||||
return false;
|
||||
|
||||
// Saves Ctrl or Alt + key for IE7, which won't fire keypress.
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine) && !opt_shiftKey && (opt_ctrlKey || opt_altKey))
|
||||
return false;
|
||||
|
||||
// When Ctrl+<somekey> is held in IE, it only fires a keypress once, but it
|
||||
// continues to fire keydown events as the event repeats.
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine) && opt_ctrlKey && opt_heldKeyCode == keyCode)
|
||||
return false;
|
||||
|
||||
switch (keyCode)
|
||||
{
|
||||
case CPKeyCodes.ENTER: return true;
|
||||
case CPKeyCodes.ESC: return !CPBrowserIsEngine(CPWebKitBrowserEngine);
|
||||
}
|
||||
|
||||
return CPKeyCodes.isCharacterKey(keyCode);
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* Test for whether or not a given keyCode represents a character key.
|
||||
*
|
||||
* @param keyCode A key code.
|
||||
* @return Returns YES if the keyCode is a character key.
|
||||
*/
|
||||
CPKeyCodes.isCharacterKey = function(keyCode)
|
||||
{
|
||||
if (keyCode >= CPKeyCodes.ZERO && keyCode <= CPKeyCodes.NINE)
|
||||
return true;
|
||||
|
||||
if (keyCode >= CPKeyCodes.NUM_ZERO && keyCode <= CPKeyCodes.NUM_MULTIPLY)
|
||||
return true;
|
||||
|
||||
if (keyCode >= CPKeyCodes.A && keyCode <= CPKeyCodes.Z)
|
||||
return true;
|
||||
|
||||
switch (keyCode)
|
||||
{
|
||||
case CPKeyCodes.SPACE:
|
||||
case CPKeyCodes.QUESTION_MARK:
|
||||
case CPKeyCodes.NUM_PLUS:
|
||||
case CPKeyCodes.NUM_MINUS:
|
||||
case CPKeyCodes.NUM_PERIOD:
|
||||
case CPKeyCodes.NUM_DIVISION:
|
||||
case CPKeyCodes.SEMICOLON:
|
||||
case CPKeyCodes.DASH:
|
||||
case CPKeyCodes.EQUALS:
|
||||
case CPKeyCodes.COMMA:
|
||||
case CPKeyCodes.PERIOD:
|
||||
case CPKeyCodes.SLASH:
|
||||
case CPKeyCodes.APOSTROPHE:
|
||||
case CPKeyCodes.SINGLE_QUOTE:
|
||||
case CPKeyCodes.OPEN_SQUARE_BRACKET:
|
||||
case CPKeyCodes.BACKSLASH:
|
||||
case CPKeyCodes.CLOSE_SQUARE_BRACKET:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
@@ -0,0 +1,18 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div>Test custom cursors with .cur images.</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(disappearingItemCursor.cur), default">disappearingItemCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(closedHandCursor.cur), default">closedHandCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(contextMenuCursor.cur), default">contextMenuCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(dragCopyCursor.cur), default">dragCopyCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(dragLinkCursor.cur), default">dragLinkCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(openHandCursor.cur), default">openHandCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(resizeDownCursor.cur), default">resizeDownCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(resizeLeftCursor.cur), default">resizeLeftCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(resizeRightCursor.cur), default">resizeRightCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(resizeUpCursor.cur), default">resizeUpCursor</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 135 B |
|
After Width: | Height: | Size: 259 B |
|
After Width: | Height: | Size: 164 B |
|
After Width: | Height: | Size: 252 B |
|
After Width: | Height: | Size: 246 B |
|
After Width: | Height: | Size: 178 B |