Compare commits
1040 Commits
WIDGET_IDL
...
CVS
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5d6b83e4c | ||
|
|
f3548d4772 | ||
|
|
8633625794 | ||
|
|
9323b18962 | ||
|
|
d8ebef8633 | ||
|
|
d8ff43782f | ||
|
|
806e3f40cd | ||
|
|
b8febcc271 | ||
|
|
814809437c | ||
|
|
4d52510e79 | ||
|
|
440593ffd1 | ||
|
|
9827b1d455 | ||
|
|
19b5a1e558 | ||
|
|
1cd0327569 | ||
|
|
75a2c4fce1 | ||
|
|
6f9ff35120 | ||
|
|
7f58cc3a0b | ||
|
|
6277f3a3b3 | ||
|
|
a4a3169649 | ||
|
|
072fc1a666 | ||
|
|
0c627abfcd | ||
|
|
3185d0a81d | ||
|
|
4d423eecaf | ||
|
|
0317a9ec8d | ||
|
|
c8460fa4ce | ||
|
|
2fce42c8be | ||
|
|
34c5281c43 | ||
|
|
463f69ae27 | ||
|
|
8ebe80d3dc | ||
|
|
37a76d8a25 | ||
|
|
63bce01588 | ||
|
|
18e9b9d2f5 | ||
|
|
b3711cec39 | ||
|
|
dde9a9185e | ||
|
|
3f737c9dc4 | ||
|
|
873c0b8d47 | ||
|
|
2a3924d2e0 | ||
|
|
a542382c77 | ||
|
|
909afc64d2 | ||
|
|
270c5df832 | ||
|
|
da9f453e91 | ||
|
|
6bc5327b10 | ||
|
|
0acd8acee3 | ||
|
|
9c363797fa | ||
|
|
f0ad8b22a7 | ||
|
|
0abb41fb24 | ||
|
|
2d2a382150 | ||
|
|
74f7c311eb | ||
|
|
210deb53ba | ||
|
|
e121b35d4c | ||
|
|
3b846f9edf | ||
|
|
f2b4462a33 | ||
|
|
e68238933b | ||
|
|
49f795c9c9 | ||
|
|
bbc03d38ad | ||
|
|
eb9061c0ef | ||
|
|
093237bea8 | ||
|
|
9cbd053f44 | ||
|
|
789e4a6e68 | ||
|
|
b895b64505 | ||
|
|
3e56d44211 | ||
|
|
226a10c27a | ||
|
|
9259952dca | ||
|
|
d548e091c7 | ||
|
|
e623d0cd2b | ||
|
|
645b1aba54 | ||
|
|
9cb4c25b8a | ||
|
|
04a7745986 | ||
|
|
e33d697bbd | ||
|
|
3e4a7413ef | ||
|
|
e08fc8df48 | ||
|
|
9d3f958db2 | ||
|
|
4cb578fb28 | ||
|
|
067e9e08c7 | ||
|
|
b7e4e49c84 | ||
|
|
3007f63368 | ||
|
|
bc13612958 | ||
|
|
18d4872487 | ||
|
|
50fb78a575 | ||
|
|
43efe84083 | ||
|
|
14d9729d57 | ||
|
|
1c91cf67ee | ||
|
|
661f8f1993 | ||
|
|
33f38025b2 | ||
|
|
f59d48eecf | ||
|
|
36d221edd9 | ||
|
|
e39c37dd58 | ||
|
|
2975241aaf | ||
|
|
60280cb48a | ||
|
|
c89e48e233 | ||
|
|
af6d54dbdd | ||
|
|
ea6a04a363 | ||
|
|
9acc778e9e | ||
|
|
9b7d72b4f3 | ||
|
|
48263cb73e | ||
|
|
946d493f92 | ||
|
|
c7896988cd | ||
|
|
866322d95e | ||
|
|
8ba9c7c1f8 | ||
|
|
7491373c1e | ||
|
|
0a71d36864 | ||
|
|
5f745cfd66 | ||
|
|
1347e8f244 | ||
|
|
376ee7ffc4 | ||
|
|
c49f31fb70 | ||
|
|
064759d0a6 | ||
|
|
4cc8b798cc | ||
|
|
e8c68e85db | ||
|
|
2d2078838d | ||
|
|
06ca9ef5c4 | ||
|
|
a0aa1b960a | ||
|
|
34cb9deb75 | ||
|
|
6dfda342cc | ||
|
|
416447022b | ||
|
|
c5129bc74b | ||
|
|
59aaafb7d0 | ||
|
|
10a148d16b | ||
|
|
9c33ecf2b8 | ||
|
|
73b2bf9d78 | ||
|
|
78e2d8b9b1 | ||
|
|
c2335df585 | ||
|
|
28de62d660 | ||
|
|
d0d34df829 | ||
|
|
9c0c764b13 | ||
|
|
12a011a2e9 | ||
|
|
b893071648 | ||
|
|
6d496c35bf | ||
|
|
14334bc5ea | ||
|
|
22f1039803 | ||
|
|
a4426a97a5 | ||
|
|
8d5737519d | ||
|
|
b3785299ff | ||
|
|
821cb4f5b2 | ||
|
|
250dbce4cf | ||
|
|
3cadc697e1 | ||
|
|
eecbd2d60c | ||
|
|
d69c3be183 | ||
|
|
6aa6a226a0 | ||
|
|
683eda7a2e | ||
|
|
057541d810 | ||
|
|
1359dee773 | ||
|
|
fb48c801ad | ||
|
|
252994d3f4 | ||
|
|
579a822e8a | ||
|
|
17726547ac | ||
|
|
aae40a4d2d | ||
|
|
53caf671cb | ||
|
|
2aaf45465d | ||
|
|
36a43a236d | ||
|
|
309ba432a9 | ||
|
|
7f72e574c1 | ||
|
|
e3f84eb9e4 | ||
|
|
619a993e2c | ||
|
|
d272bf5abd | ||
|
|
fab3227026 | ||
|
|
1caffddc3f | ||
|
|
dad4df6919 | ||
|
|
332b7443db | ||
|
|
f347f08869 | ||
|
|
9083887386 | ||
|
|
7516584ad9 | ||
|
|
b1974e5540 | ||
|
|
d807cd69da | ||
|
|
b5cd4ed681 | ||
|
|
cb1644bdd6 | ||
|
|
e7a07c934b | ||
|
|
4353d33c01 | ||
|
|
4b07a41a74 | ||
|
|
2475291b21 | ||
|
|
928088a46d | ||
|
|
5c5ba7aa15 | ||
|
|
2b381da127 | ||
|
|
b0844bfd3a | ||
|
|
489f3fc875 | ||
|
|
e96f49b91f | ||
|
|
989168e646 | ||
|
|
caca355dec | ||
|
|
01e83014a6 | ||
|
|
dcd63f4da3 | ||
|
|
5132f68d26 | ||
|
|
9101132f9e | ||
|
|
c41e517028 | ||
|
|
fc95d0c6a1 | ||
|
|
6c0a9f5fc0 | ||
|
|
34e280d8c3 | ||
|
|
971976b8c4 | ||
|
|
93aed372f7 | ||
|
|
aa390e05d8 | ||
|
|
1a22e3ed7e | ||
|
|
1896cfefef | ||
|
|
410ce267d5 | ||
|
|
fcb9e9bf51 | ||
|
|
37e2169b4e | ||
|
|
2e8166fd64 | ||
|
|
3f42f06246 | ||
|
|
7519f0fc4c | ||
|
|
7062dc3e8b | ||
|
|
8c90b18f03 | ||
|
|
51c5a4e65e | ||
|
|
169ef88ab4 | ||
|
|
e0c55754d5 | ||
|
|
b7194daf71 | ||
|
|
01e298fd41 | ||
|
|
091955e9a0 | ||
|
|
76b98f20a7 | ||
|
|
51d691cc02 | ||
|
|
45e857d860 | ||
|
|
28bd74e177 | ||
|
|
eb73055cf6 | ||
|
|
2c17cc458b | ||
|
|
d10b7ecd53 | ||
|
|
028e053c7f | ||
|
|
252f4090ad | ||
|
|
9599670719 | ||
|
|
100e540599 | ||
|
|
b383080e9b | ||
|
|
f40460044c | ||
|
|
967990a454 | ||
|
|
120ec26f3b | ||
|
|
f686bba5d8 | ||
|
|
1d1cd2baaf | ||
|
|
b6030ceac7 | ||
|
|
258a2a6d4a | ||
|
|
2f38d972f2 | ||
|
|
afe30290c8 | ||
|
|
19cd8f1747 | ||
|
|
3ee2fa81c3 | ||
|
|
2ebb109791 | ||
|
|
8344cba9ee | ||
|
|
7c82b0b5f1 | ||
|
|
1f838ed9cc | ||
|
|
288ad892dc | ||
|
|
0067ebd9f5 | ||
|
|
3ed94d5f1f | ||
|
|
74de522d21 | ||
|
|
318689d640 | ||
|
|
06a85f06f3 | ||
|
|
fa0386eb21 | ||
|
|
980b8b883b | ||
|
|
b237b4f45e | ||
|
|
e5bf02a97b | ||
|
|
ffbff9e7c8 | ||
|
|
f07d66246d | ||
|
|
6c6ce1b3d7 | ||
|
|
c813db9f21 | ||
|
|
eb1e3503ae | ||
|
|
f62900eb59 | ||
|
|
0e926140f9 | ||
|
|
639989c1df | ||
|
|
78accf0d1a | ||
|
|
d7505330dd | ||
|
|
b166fe020d | ||
|
|
55f10b405f | ||
|
|
8bcbaf642c | ||
|
|
a5420e53d5 | ||
|
|
611923e583 | ||
|
|
4e84b82b51 | ||
|
|
865a79a1b5 | ||
|
|
5e7fed7a2f | ||
|
|
ed816f5fa6 | ||
|
|
da470df1ca | ||
|
|
4ff5cdca2a | ||
|
|
991d518e3e | ||
|
|
d8984b315e | ||
|
|
c5fccc649e | ||
|
|
419cb327c4 | ||
|
|
7860787b10 | ||
|
|
ccf37b21ec | ||
|
|
0ba95a928f | ||
|
|
569c87328e | ||
|
|
941d2435ba | ||
|
|
68944c6b5c | ||
|
|
1122546a7f | ||
|
|
b77b7f8e29 | ||
|
|
1eb33cb46e | ||
|
|
c0fbb70022 | ||
|
|
ec97378850 | ||
|
|
df2bf72c59 | ||
|
|
7527b7b206 | ||
|
|
a252dee761 | ||
|
|
05ab0a848d | ||
|
|
d0cd134272 | ||
|
|
e89f59cad5 | ||
|
|
dd050726f8 | ||
|
|
02f74ae132 | ||
|
|
a017529e6b | ||
|
|
7083308cff | ||
|
|
6430228b19 | ||
|
|
7ba4c213b3 | ||
|
|
84470b2c93 | ||
|
|
270ce881b4 | ||
|
|
173cc583c1 | ||
|
|
651e1ddd8a | ||
|
|
30e53d03e9 | ||
|
|
0a71bb415f | ||
|
|
daf51ae193 | ||
|
|
e20da712ec | ||
|
|
a4d81273ff | ||
|
|
931605d622 | ||
|
|
ba241132ea | ||
|
|
36bb330940 | ||
|
|
328d62f08f | ||
|
|
6a952509ef | ||
|
|
3295631735 | ||
|
|
f12855c796 | ||
|
|
121acfa205 | ||
|
|
01eb918031 | ||
|
|
63d606d58f | ||
|
|
8f331211d9 | ||
|
|
e2e17b4ff5 | ||
|
|
d5785373e3 | ||
|
|
1299fd6c0b | ||
|
|
7021f197de | ||
|
|
df37832d89 | ||
|
|
6d83d361f0 | ||
|
|
93c11dbc7d | ||
|
|
6a84236160 | ||
|
|
8b985c46d4 | ||
|
|
bd0a1b5cb4 | ||
|
|
b765a3d4c4 | ||
|
|
06ac17fb62 | ||
|
|
4dbf02b9bd | ||
|
|
da4d6e495b | ||
|
|
b6c93b5c5c | ||
|
|
6d6b3023f8 | ||
|
|
d31b3296a7 | ||
|
|
bb0622beb7 | ||
|
|
342865f5fe | ||
|
|
e6f4dfa6bc | ||
|
|
f52acaed14 | ||
|
|
888a71ee23 | ||
|
|
90932ba7f3 | ||
|
|
b845870367 | ||
|
|
c3b9e376e5 | ||
|
|
59ee43f7fc | ||
|
|
a30fed502d | ||
|
|
d65bc1efa0 | ||
|
|
932343b896 | ||
|
|
4443e74058 | ||
|
|
9a868467c2 | ||
|
|
6a9e7e63c8 | ||
|
|
2fc190da13 | ||
|
|
d6fa660ea6 | ||
|
|
2c4f182411 | ||
|
|
159030e89c | ||
|
|
c140cc2ce4 | ||
|
|
8023b08ebc | ||
|
|
c90da152c8 | ||
|
|
f9f813ef1c | ||
|
|
8fad354f5e | ||
|
|
9a58260a6e | ||
|
|
d1bd5d5e97 | ||
|
|
ea86098377 | ||
|
|
dcfe02ab7b | ||
|
|
cb5728cc3b | ||
|
|
1a57622faf | ||
|
|
5bfc12b38e | ||
|
|
fb01047518 | ||
|
|
a8e3ac3d29 | ||
|
|
8d648e06d7 | ||
|
|
c49588441a | ||
|
|
d9793670d5 | ||
|
|
865140e021 | ||
|
|
6e44e98669 | ||
|
|
97ae527556 | ||
|
|
c2c9a9c0b6 | ||
|
|
058528945e | ||
|
|
b3d531541b | ||
|
|
f52490e687 | ||
|
|
16ba6581af | ||
|
|
7fe99209ab | ||
|
|
64aa89c32a | ||
|
|
770be8200a | ||
|
|
574bed9e24 | ||
|
|
d468916c06 | ||
|
|
9dbd192f71 | ||
|
|
e618bdbebb | ||
|
|
7f3afb38db | ||
|
|
1ef39b7b56 | ||
|
|
a29fb3f1d9 | ||
|
|
907eec02fc | ||
|
|
cb001a0982 | ||
|
|
6320eadc46 | ||
|
|
30a83caa1d | ||
|
|
765cdf4fa9 | ||
|
|
f818f184a0 | ||
|
|
2478da99aa | ||
|
|
27e760dac4 | ||
|
|
84d2d35991 | ||
|
|
7f7558dc5d | ||
|
|
2705d8b72b | ||
|
|
0a8ef0fe92 | ||
|
|
8191c9d684 | ||
|
|
79880beab5 | ||
|
|
7db449cd06 | ||
|
|
18dd71d7d3 | ||
|
|
8d3833cb33 | ||
|
|
580e6e380c | ||
|
|
f5924be40d | ||
|
|
886d9b7c4f | ||
|
|
d2773dffe3 | ||
|
|
79da82091a | ||
|
|
8927726ce7 | ||
|
|
4aa916c066 | ||
|
|
a193449dbf | ||
|
|
6d47545512 | ||
|
|
d568e564ce | ||
|
|
9a6d1be468 | ||
|
|
c3710aa7cf | ||
|
|
ab9846ab1e | ||
|
|
bfb9762e5a | ||
|
|
f49139b533 | ||
|
|
19c0e43ded | ||
|
|
d69dd3df67 | ||
|
|
dc683794a3 | ||
|
|
dc6d4aa6fa | ||
|
|
99e13cf601 | ||
|
|
66eaef7892 | ||
|
|
5ff13771d4 | ||
|
|
c6019b3551 | ||
|
|
3be8f0bb27 | ||
|
|
f82a173c1b | ||
|
|
c4fd2231d1 | ||
|
|
22765f12e4 | ||
|
|
fb8e1bdb06 | ||
|
|
9c16516bfc | ||
|
|
a4f420d4fb | ||
|
|
6a697df2cd | ||
|
|
fabbe52905 | ||
|
|
b625f8c219 | ||
|
|
3270b2a66f | ||
|
|
84003fe77b | ||
|
|
2a38ee05b4 | ||
|
|
9dcd28272e | ||
|
|
bae6f56e4b | ||
|
|
deff3927b7 | ||
|
|
6f9a832691 | ||
|
|
5e3057bc5f | ||
|
|
062e198b32 | ||
|
|
52eb9ba5eb | ||
|
|
ba85b17922 | ||
|
|
69fbd973a0 | ||
|
|
041db07f43 | ||
|
|
60a9b36aae | ||
|
|
075aedf4ee | ||
|
|
ca11a90c92 | ||
|
|
84e4143c7e | ||
|
|
abd3497f8c | ||
|
|
6389e9eed1 | ||
|
|
16a80cecba | ||
|
|
bbf17a2772 | ||
|
|
5b712622da | ||
|
|
0eec4f1a12 | ||
|
|
e18af2d0ee | ||
|
|
0f9df28d81 | ||
|
|
655211e9e0 | ||
|
|
e62cab32bc | ||
|
|
ff64ed5645 | ||
|
|
7ac835a8b2 | ||
|
|
b44472476c | ||
|
|
7ce12116c7 | ||
|
|
16bf5b4e43 | ||
|
|
f5cc851bd0 | ||
|
|
2b7533ef10 | ||
|
|
24c8eb13e7 | ||
|
|
7bfc990fcf | ||
|
|
b978d371e9 | ||
|
|
8c7166d122 | ||
|
|
273f420e23 | ||
|
|
edef6fb916 | ||
|
|
2aa7b332a8 | ||
|
|
db039d9432 | ||
|
|
97b88d421f | ||
|
|
4b800ef247 | ||
|
|
199c8166c7 | ||
|
|
fbecb0f668 | ||
|
|
1dd1cfee5a | ||
|
|
52d84b804d | ||
|
|
a0ade5ef67 | ||
|
|
4b226a4436 | ||
|
|
07d74ceef4 | ||
|
|
d4f79e4e21 | ||
|
|
093e5bfd97 | ||
|
|
3ba1fc9867 | ||
|
|
127e23606e | ||
|
|
be500f5f77 | ||
|
|
28f1fa0323 | ||
|
|
15a67038a4 | ||
|
|
579c8e2248 | ||
|
|
312671bf23 | ||
|
|
cc845797fa | ||
|
|
8c486b4dbf | ||
|
|
3da62e7fd4 | ||
|
|
d75c5a8f47 | ||
|
|
fefde390b5 | ||
|
|
d1916dab07 | ||
|
|
12ad3a8ea1 | ||
|
|
41ae9835a0 | ||
|
|
42395fb4cd | ||
|
|
02844df3be | ||
|
|
c9fbdb8075 | ||
|
|
9470ef781b | ||
|
|
450082561c | ||
|
|
de2f3b6942 | ||
|
|
c3ba33bbb8 | ||
|
|
d6eb736cf5 | ||
|
|
f0ebe3333d | ||
|
|
0a89ba79ef | ||
|
|
479c02d23b | ||
|
|
af65076fcc | ||
|
|
867ac81c42 | ||
|
|
1c2af52291 | ||
|
|
524f22fa3d | ||
|
|
f562178cfd | ||
|
|
ff8d0b5547 | ||
|
|
32ae9a79ff | ||
|
|
dee37d8ec6 | ||
|
|
14bcf4dfb6 | ||
|
|
53ff6e3994 | ||
|
|
dea623bfa3 | ||
|
|
c631c144f2 | ||
|
|
2064c545e9 | ||
|
|
7edab401af | ||
|
|
70d8dbcabe | ||
|
|
fdf016b522 | ||
|
|
eb6f6392d7 | ||
|
|
7d127002f9 | ||
|
|
4d74acf338 | ||
|
|
4c6b85103e | ||
|
|
fc64e1c69b | ||
|
|
c322512ff3 | ||
|
|
3b7075a69b | ||
|
|
3848b18fe7 | ||
|
|
b0bb720dd1 | ||
|
|
5735cf240f | ||
|
|
32093a83c6 | ||
|
|
f291b097d5 | ||
|
|
1c08cd13d9 | ||
|
|
d66d5defc6 | ||
|
|
e6f28ca7ba | ||
|
|
e414c28907 | ||
|
|
c94e8e9c8e | ||
|
|
a566a33989 | ||
|
|
1452789bbd | ||
|
|
cc675f4462 | ||
|
|
b591bc9b02 | ||
|
|
15352050f2 | ||
|
|
27bf7b0e38 | ||
|
|
15925c0587 | ||
|
|
6fb1b8e0d6 | ||
|
|
f536f04be7 | ||
|
|
46858a98ee | ||
|
|
759b90d985 | ||
|
|
3b5f2c1e21 | ||
|
|
e143bf497c | ||
|
|
750861810b | ||
|
|
c0cc4a7df7 | ||
|
|
df73818e4c | ||
|
|
7ba994995c | ||
|
|
cfd4889e52 | ||
|
|
09be733a85 | ||
|
|
70a3da2b30 | ||
|
|
3f1f724756 | ||
|
|
76ea87ea04 | ||
|
|
9754a010ca | ||
|
|
5ca75e8020 | ||
|
|
75b915c855 | ||
|
|
82ee650dbf | ||
|
|
879bafb0b6 | ||
|
|
fd723643f2 | ||
|
|
5dbbb4bb89 | ||
|
|
28bab47569 | ||
|
|
391cdf28f4 | ||
|
|
a2221d154c | ||
|
|
571b348058 | ||
|
|
af37c61c55 | ||
|
|
f958803974 | ||
|
|
4bac26a215 | ||
|
|
834be86386 | ||
|
|
01e635a3a6 | ||
|
|
4d9fe202fe | ||
|
|
faac109667 | ||
|
|
7ef56b5288 | ||
|
|
bde00ceef7 | ||
|
|
ac6276e5cd | ||
|
|
13d46b9f86 | ||
|
|
c0b38598d6 | ||
|
|
c959c10bfc | ||
|
|
1e7a6bdb4d | ||
|
|
7425479597 | ||
|
|
9cdcbef4af | ||
|
|
9eb3c904c6 | ||
|
|
94a677a8af | ||
|
|
9d922a368f | ||
|
|
1424e84e14 | ||
|
|
f2333c7dab | ||
|
|
a57d0470d2 | ||
|
|
dc0146ae24 | ||
|
|
1978802be8 | ||
|
|
51e85831e8 | ||
|
|
0a87564964 | ||
|
|
946d742a4d | ||
|
|
bc8b6d116e | ||
|
|
0a81ee7839 | ||
|
|
52995d7ec4 | ||
|
|
deecdfd350 | ||
|
|
5fc1175eb9 | ||
|
|
b84b2685ff | ||
|
|
99aaa55232 | ||
|
|
4e6e50c103 | ||
|
|
b17c92e839 | ||
|
|
d5ce80751a | ||
|
|
b87e5bb00d | ||
|
|
a72c992c6f | ||
|
|
080879ab10 | ||
|
|
78b500998c | ||
|
|
7097d190f2 | ||
|
|
f49a6fc3a9 | ||
|
|
9299843cda | ||
|
|
0925de79f3 | ||
|
|
b1873070a7 | ||
|
|
5b962a0f3c | ||
|
|
6b11a987a4 | ||
|
|
d016fe35cc | ||
|
|
be68b07064 | ||
|
|
c45dd4d212 | ||
|
|
3600061916 | ||
|
|
f7d9ac0919 | ||
|
|
542eeddaf1 | ||
|
|
0b8b118754 | ||
|
|
4c88fb3ec4 | ||
|
|
75bf4aa54d | ||
|
|
88babc4d7b | ||
|
|
ada22baf14 | ||
|
|
d46c14654b | ||
|
|
578092310a | ||
|
|
032742ad4c | ||
|
|
7c76fd51f5 | ||
|
|
48f3a0603c | ||
|
|
20945ad3ee | ||
|
|
b286c0c010 | ||
|
|
9c68bc61cc | ||
|
|
cd534a023e | ||
|
|
ac743ecce8 | ||
|
|
68ccc3d94a | ||
|
|
cedec739aa | ||
|
|
cd59845c25 | ||
|
|
84fb96cb65 | ||
|
|
6b2d99d685 | ||
|
|
e6c61c5ffe | ||
|
|
b84f7a78de | ||
|
|
f6d3593b2e | ||
|
|
d6ec571916 | ||
|
|
a378b87978 | ||
|
|
734f2fb55c | ||
|
|
4cdb11b194 | ||
|
|
7258a74fc0 | ||
|
|
944a16f933 | ||
|
|
3b3d0e4e1b | ||
|
|
f614c92aba | ||
|
|
e16887dc96 | ||
|
|
12980882c5 | ||
|
|
1e0b48570c | ||
|
|
3412f4f935 | ||
|
|
9baa358bf2 | ||
|
|
9b0345f34f | ||
|
|
0209785bbb | ||
|
|
7ef083b590 | ||
|
|
97336400bc | ||
|
|
a633fa30b6 | ||
|
|
52a561a9c0 | ||
|
|
45c9c2b5a6 | ||
|
|
ea30288c1f | ||
|
|
77f9635cce | ||
|
|
3963f45810 | ||
|
|
210400fa8f | ||
|
|
9d0be77836 | ||
|
|
223352ad77 | ||
|
|
852ba0f2aa | ||
|
|
58d7842b20 | ||
|
|
bf992aac1f | ||
|
|
ba3a9ad68c | ||
|
|
522636a5de | ||
|
|
6f9ef9e6d4 | ||
|
|
a1c9b6dcaa | ||
|
|
743ccfad5b | ||
|
|
055d89c0e3 | ||
|
|
3188df57a2 | ||
|
|
bf35f71ce1 | ||
|
|
49e47e3066 | ||
|
|
30cf63de80 | ||
|
|
3e9e75feec | ||
|
|
ccc05991a3 | ||
|
|
c39e2405d9 | ||
|
|
478e94b19b | ||
|
|
541b381b71 | ||
|
|
0851c72b83 | ||
|
|
644f5864a9 | ||
|
|
c4175bcb0e | ||
|
|
58cd4c0ef8 | ||
|
|
a17b679975 | ||
|
|
e8d09fd3a6 | ||
|
|
ccf2994b95 | ||
|
|
7277b119b3 | ||
|
|
c0d2a0e2f2 | ||
|
|
347134e10d | ||
|
|
2eb2dcca67 | ||
|
|
9446096dca | ||
|
|
7362f1b13f | ||
|
|
148aeb9479 | ||
|
|
89bd8c3bc9 | ||
|
|
f3bc03de75 | ||
|
|
d69298a9d2 | ||
|
|
417b06f591 | ||
|
|
9fce7b0c15 | ||
|
|
e7538bfe37 | ||
|
|
9c726938af | ||
|
|
bed7f86409 | ||
|
|
7a33492452 | ||
|
|
08f88ab066 | ||
|
|
9fc68e8c6c | ||
|
|
a81253b229 | ||
|
|
0d44d897c3 | ||
|
|
8e1de98ab5 | ||
|
|
011f173694 | ||
|
|
2ffbb4f583 | ||
|
|
6563efab51 | ||
|
|
c70061dbb3 | ||
|
|
a591a0e509 | ||
|
|
6dd1042b5d | ||
|
|
b98dbfaa02 | ||
|
|
3e38e2ea2a | ||
|
|
cb8f332910 | ||
|
|
32644723fe | ||
|
|
25f4419ba0 | ||
|
|
c4429f5066 | ||
|
|
15caf3db1c | ||
|
|
d89dab4e33 | ||
|
|
6e8fa75abe | ||
|
|
b9147e6fd2 | ||
|
|
35708ce998 | ||
|
|
d48f50c349 | ||
|
|
190716d4ac | ||
|
|
74e6cc86a3 | ||
|
|
b576ab2cb5 | ||
|
|
c9f9d5ee25 | ||
|
|
3a0fa24595 | ||
|
|
be0faff780 | ||
|
|
7b445faf02 | ||
|
|
3f799e031d | ||
|
|
71408231d2 | ||
|
|
3a3369076f | ||
|
|
934632fc76 | ||
|
|
bdf07b5f16 | ||
|
|
f082f7eb5e | ||
|
|
2f507e7b3c | ||
|
|
b18dd56b44 | ||
|
|
bfa9612c50 | ||
|
|
71a5f24ba3 | ||
|
|
b8d939ca6e | ||
|
|
28fb79fcef | ||
|
|
869cfacaf7 | ||
|
|
79a8db9e5d | ||
|
|
53b538cfc8 | ||
|
|
efca1f8c77 | ||
|
|
28e1dfd154 | ||
|
|
1c6394c2d0 | ||
|
|
4518901d71 | ||
|
|
31eba671e2 | ||
|
|
08ffd64c70 | ||
|
|
149b556a40 | ||
|
|
12bc995595 | ||
|
|
ab205b541a | ||
|
|
b51d6a324e | ||
|
|
f037c3b791 | ||
|
|
040d9254e3 | ||
|
|
230b7ea144 | ||
|
|
495ac5394c | ||
|
|
3924a3e115 | ||
|
|
ac914fc99e | ||
|
|
33cab018e9 | ||
|
|
e03ce189b4 | ||
|
|
b605bcf7c8 | ||
|
|
2e1f51d842 | ||
|
|
e532cb3ce3 | ||
|
|
6278c9cdb6 | ||
|
|
08e25e2af2 | ||
|
|
9230e0bd2b | ||
|
|
f10ff94359 | ||
|
|
699606d62a | ||
|
|
b4e6b84fea | ||
|
|
32816676db | ||
|
|
dfe61b8c0c | ||
|
|
23d28fee69 | ||
|
|
185c444bad | ||
|
|
bb00d4e082 | ||
|
|
bc20c13bee | ||
|
|
0685d4013e | ||
|
|
6c0dabbcc9 | ||
|
|
51378fb74f | ||
|
|
ae215e19d6 | ||
|
|
2aa4acab95 | ||
|
|
8626b336eb | ||
|
|
feff21ed38 | ||
|
|
ebce0e90ac | ||
|
|
a87258a834 | ||
|
|
bcb12509a4 | ||
|
|
54966bf91e | ||
|
|
011094c243 | ||
|
|
dc5a959bfb | ||
|
|
8fdcb733f6 | ||
|
|
a4aa98059e | ||
|
|
beb412d2f0 | ||
|
|
cd7adcfa5b | ||
|
|
ddfb13e8bd | ||
|
|
6455b470d5 | ||
|
|
2e0f295a75 | ||
|
|
0fe83f199b | ||
|
|
3bf966446e | ||
|
|
d280db659f | ||
|
|
52fa2d449f | ||
|
|
bd2b8bbb50 | ||
|
|
9540a1b2bb | ||
|
|
a4303afba6 | ||
|
|
3f98b22adb | ||
|
|
3f9c7372e6 | ||
|
|
628723cd09 | ||
|
|
d84901b036 | ||
|
|
c12b68d3bc | ||
|
|
7159500167 | ||
|
|
8c517b89c5 | ||
|
|
489535b9e0 | ||
|
|
0899d7c171 | ||
|
|
2c951d67c1 | ||
|
|
685d8d596e | ||
|
|
ac0f716288 | ||
|
|
4a9749eec3 | ||
|
|
37f1655b17 | ||
|
|
aa9be56cfa | ||
|
|
b4b00ba592 | ||
|
|
41337e7380 | ||
|
|
3c9599e418 | ||
|
|
fa598b6cae | ||
|
|
ff7384e823 | ||
|
|
9c58478520 | ||
|
|
1664bd1228 | ||
|
|
455a608f47 | ||
|
|
0db46fd24d | ||
|
|
2306c86ff9 | ||
|
|
9598e1278f | ||
|
|
016eba860a | ||
|
|
e62c5f3e87 | ||
|
|
8aa6b7aa38 | ||
|
|
de7b2e5e74 | ||
|
|
17b2b4cace | ||
|
|
0b401a86ba | ||
|
|
8fff423963 | ||
|
|
4046113676 | ||
|
|
f6d25e7c68 | ||
|
|
90d52f24b4 | ||
|
|
14a4b48d16 | ||
|
|
5475d74886 | ||
|
|
aa82528d79 | ||
|
|
2359272160 | ||
|
|
1d765d463d | ||
|
|
fc4c559faa | ||
|
|
af2c5a6328 | ||
|
|
66f0536716 | ||
|
|
cdbe7612ce | ||
|
|
0afa0bedfe | ||
|
|
239d60872d | ||
|
|
74b117887f | ||
|
|
eb8deb8c1b | ||
|
|
f0a6db6e3e | ||
|
|
1192ec6846 | ||
|
|
d721125978 | ||
|
|
4c19332cbb | ||
|
|
4fa6ebaa6d | ||
|
|
c9603305c7 | ||
|
|
9145c77cc4 | ||
|
|
eaaefb2093 | ||
|
|
59997b00eb | ||
|
|
55b9838dc4 | ||
|
|
81d2477caa | ||
|
|
40b89da05b | ||
|
|
0ce90ca711 | ||
|
|
c34375d22a | ||
|
|
d2eaa239f7 | ||
|
|
4f1bf46f5d | ||
|
|
7eedfae1ee | ||
|
|
03b778a6f7 | ||
|
|
6311b52e3d | ||
|
|
a3570edb7f | ||
|
|
9246660bae | ||
|
|
db15162105 | ||
|
|
af9cdee1dc | ||
|
|
50c6f531fe | ||
|
|
3b535ab2ef | ||
|
|
3e9e763bae | ||
|
|
288c2fdcfb | ||
|
|
66a3fad9de | ||
|
|
6558fcffeb | ||
|
|
ef2c286317 | ||
|
|
19a71ea13f | ||
|
|
36e083362c | ||
|
|
d2b440e23a | ||
|
|
1c2b2f6390 | ||
|
|
86725c9808 | ||
|
|
0cb4e10e77 | ||
|
|
1c9d47ade0 | ||
|
|
ff1ff17b9d | ||
|
|
2eb916adb2 | ||
|
|
41dd85d37f | ||
|
|
d0d0e41c47 | ||
|
|
c3e71c904f | ||
|
|
b6cc6b0ab0 | ||
|
|
399a1319c0 | ||
|
|
77b37126c4 | ||
|
|
240237eba0 | ||
|
|
2e4127024c | ||
|
|
322798e844 | ||
|
|
94f2a23952 | ||
|
|
18a7fb8d42 | ||
|
|
b36e29928a | ||
|
|
9a1b140b6b | ||
|
|
90cd1e6284 | ||
|
|
9f5a8b5090 | ||
|
|
6c3f751156 | ||
|
|
e9dac37427 | ||
|
|
bc66d4807f | ||
|
|
508a0c5b7d | ||
|
|
795fab8784 | ||
|
|
3ecbfc5cdf | ||
|
|
f038869d64 | ||
|
|
0c2f0d51f9 | ||
|
|
75c8c9cd12 | ||
|
|
da97767078 | ||
|
|
eaf44edde8 | ||
|
|
ed2580f15a | ||
|
|
cd941313ec | ||
|
|
f25b9d367d | ||
|
|
da4024048d | ||
|
|
a50c5f3df5 | ||
|
|
4133a2fff5 | ||
|
|
50068fd6e0 | ||
|
|
7835dfb07e | ||
|
|
86f12df7f4 | ||
|
|
9895a33add | ||
|
|
90b1f42534 | ||
|
|
0534ba836d | ||
|
|
1193314ab4 | ||
|
|
3c1923f753 | ||
|
|
e5cdcb3d9a | ||
|
|
1917b8abfe | ||
|
|
9060bb7e6c | ||
|
|
ac349d4f71 | ||
|
|
ef523b7bc1 | ||
|
|
b928008ea2 | ||
|
|
8d9a25274c | ||
|
|
dc26a2c638 | ||
|
|
7eed8aaa95 | ||
|
|
7f3f2e7069 | ||
|
|
5022c51b04 | ||
|
|
1b6a18b9e4 | ||
|
|
d3baf5491f | ||
|
|
ef0e29ec51 | ||
|
|
142225cef1 | ||
|
|
1a870b97f1 | ||
|
|
e1737fe531 | ||
|
|
712d5c7659 | ||
|
|
b72d84c381 | ||
|
|
5da81c87c7 | ||
|
|
f47d01c612 | ||
|
|
86ee025299 | ||
|
|
f6d5221996 | ||
|
|
07e158b4cf | ||
|
|
39323d24e7 | ||
|
|
16b1141bdf | ||
|
|
c3494a9ffb | ||
|
|
bd5ca95ced | ||
|
|
612bb1db4c | ||
|
|
e912c2233e | ||
|
|
200e34d9af | ||
|
|
ca4aac906f | ||
|
|
3dfcb47c99 | ||
|
|
c571661492 | ||
|
|
4efb5b42d5 | ||
|
|
e2b731d7df | ||
|
|
67890faf02 | ||
|
|
741f87253e | ||
|
|
ff2d0533a2 | ||
|
|
8c170e98ee | ||
|
|
0a6c37218a | ||
|
|
7a48580674 | ||
|
|
e1b393609a | ||
|
|
61705e7f39 | ||
|
|
59b25d549c | ||
|
|
4e1923d3ad | ||
|
|
42184097f4 | ||
|
|
285283e32e | ||
|
|
780e7132fd | ||
|
|
1f12de6f96 | ||
|
|
64c2d4fe86 | ||
|
|
69ec6c9b26 | ||
|
|
34f7a63ece | ||
|
|
aed86d7f55 | ||
|
|
e42eb9313a | ||
|
|
ac3d91fcff | ||
|
|
ade56298bb | ||
|
|
26bb29ed10 | ||
|
|
a981cb2868 | ||
|
|
2c843652fd | ||
|
|
bf6316462c | ||
|
|
a8c2a315be | ||
|
|
da2095c0dc | ||
|
|
2f25a96f14 | ||
|
|
24cefa52e6 | ||
|
|
deebca4e10 | ||
|
|
163649cbd0 | ||
|
|
04637210d9 | ||
|
|
2e268f54e5 | ||
|
|
7c54ad976a | ||
|
|
4d36473556 | ||
|
|
bb72e03927 | ||
|
|
90f49df885 | ||
|
|
f6b2303084 | ||
|
|
055feb1f4f | ||
|
|
2471a39269 | ||
|
|
f8f515a025 | ||
|
|
1cfea69ffd | ||
|
|
8da5559e0f | ||
|
|
f6ec8c8015 | ||
|
|
f896ef768d | ||
|
|
457fc28670 | ||
|
|
3dc6e05d82 | ||
|
|
830f8c1257 | ||
|
|
31bda0647d | ||
|
|
7c49c9f9ea | ||
|
|
698d1ed095 | ||
|
|
6ee88bb33f |
617
mozilla/htmlparser/src/nsAVLTree.cpp
Normal file
617
mozilla/htmlparser/src/nsAVLTree.cpp
Normal file
@@ -0,0 +1,617 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsAVLTree.h"
|
||||
|
||||
|
||||
enum eLean {eLeft,eNeutral,eRight};
|
||||
|
||||
struct NS_COM nsAVLNode {
|
||||
public:
|
||||
|
||||
nsAVLNode(void* aValue) {
|
||||
mLeft=0;
|
||||
mRight=0;
|
||||
mSkew=eNeutral;
|
||||
mValue=aValue;
|
||||
}
|
||||
|
||||
nsAVLNode* mLeft;
|
||||
nsAVLNode* mRight;
|
||||
eLean mSkew;
|
||||
void* mValue;
|
||||
};
|
||||
|
||||
|
||||
/************************************************************
|
||||
Now begin the tree class. Don't forget that the comparison
|
||||
between nodes must occur via the comparitor function,
|
||||
otherwise all you're testing is pointer addresses.
|
||||
************************************************************/
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
nsAVLTree::nsAVLTree(nsAVLNodeComparitor& aComparitor,
|
||||
nsAVLNodeFunctor* aDeallocator) :
|
||||
mComparitor(aComparitor), mDeallocator(aDeallocator) {
|
||||
mRoot=0;
|
||||
mCount=0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
avlDeleteTree(nsAVLNode* aNode){
|
||||
if (aNode) {
|
||||
avlDeleteTree(aNode->mLeft);
|
||||
avlDeleteTree(aNode->mRight);
|
||||
delete aNode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/27/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsAVLTree::~nsAVLTree(){
|
||||
if (mDeallocator) {
|
||||
ForEachDepthFirst(*mDeallocator);
|
||||
}
|
||||
avlDeleteTree(mRoot);
|
||||
}
|
||||
|
||||
|
||||
class CDoesntExist: public nsAVLNodeFunctor {
|
||||
public:
|
||||
CDoesntExist(const nsAVLTree& anotherTree) : mOtherTree(anotherTree) {
|
||||
}
|
||||
virtual void* operator()(void* anItem) {
|
||||
void* result=mOtherTree.FindItem(anItem);
|
||||
if(result)
|
||||
return nsnull;
|
||||
return anItem;
|
||||
}
|
||||
protected:
|
||||
const nsAVLTree& mOtherTree;
|
||||
};
|
||||
|
||||
/**
|
||||
* This method compares two trees (members by identity).
|
||||
* @update gess12/27/98
|
||||
* @param tree to compare against
|
||||
* @return true if they are identical (contain same stuff).
|
||||
*/
|
||||
PRBool nsAVLTree::operator==(const nsAVLTree& aCopy) const{
|
||||
CDoesntExist functor(aCopy);
|
||||
void* theItem=FirstThat(functor);
|
||||
PRBool result=PRBool(!theItem);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/27/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlRotateRight(nsAVLNode*& aRootNode){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
|
||||
ptr2=aRootNode->mRight;
|
||||
if(ptr2->mSkew==eRight) {
|
||||
aRootNode->mRight=ptr2->mLeft;
|
||||
ptr2->mLeft=aRootNode;
|
||||
aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else {
|
||||
ptr3=ptr2->mLeft;
|
||||
ptr2->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=ptr2;
|
||||
aRootNode->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=aRootNode;
|
||||
if(ptr3->mSkew==eLeft)
|
||||
ptr2->mSkew=eRight;
|
||||
else ptr2->mSkew=eNeutral;
|
||||
if(ptr3->mSkew==eRight)
|
||||
aRootNode->mSkew=eLeft;
|
||||
else aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr3;
|
||||
}
|
||||
aRootNode->mSkew=eNeutral;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/27/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlRotateLeft(nsAVLNode*& aRootNode){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
|
||||
ptr2=aRootNode->mLeft;
|
||||
if(ptr2->mSkew==eLeft) {
|
||||
aRootNode->mLeft=ptr2->mRight;
|
||||
ptr2->mRight=aRootNode;
|
||||
aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else {
|
||||
ptr3=ptr2->mRight;
|
||||
ptr2->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=ptr2;
|
||||
aRootNode->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=aRootNode;
|
||||
if(ptr3->mSkew==eRight)
|
||||
ptr2->mSkew=eLeft;
|
||||
else ptr2->mSkew=eNeutral;
|
||||
if(ptr3->mSkew==eLeft)
|
||||
aRootNode->mSkew=eRight;
|
||||
else aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr3;
|
||||
}
|
||||
aRootNode->mSkew=eNeutral;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static eAVLStatus
|
||||
avlInsert(nsAVLNode*& aRootNode, nsAVLNode* aNewNode,
|
||||
nsAVLNodeComparitor& aComparitor) {
|
||||
eAVLStatus result=eAVL_unknown;
|
||||
|
||||
if(!aRootNode) {
|
||||
aRootNode = aNewNode;
|
||||
return eAVL_ok;
|
||||
}
|
||||
|
||||
if(aNewNode==aRootNode->mValue) {
|
||||
return eAVL_duplicate;
|
||||
}
|
||||
|
||||
PRInt32 theCompareResult=aComparitor(aRootNode->mValue,aNewNode->mValue);
|
||||
if(0 < theCompareResult) { //if(anItem<aRootNode->mValue)
|
||||
result=avlInsert(aRootNode->mLeft,aNewNode,aComparitor);
|
||||
if(eAVL_ok==result) {
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
avlRotateLeft(aRootNode);
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eRight:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eLeft;
|
||||
break;
|
||||
} //switch
|
||||
}//if
|
||||
} //if
|
||||
else {
|
||||
result=avlInsert(aRootNode->mRight,aNewNode,aComparitor);
|
||||
if(eAVL_ok==result) {
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eRight:
|
||||
avlRotateRight(aRootNode);
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eRight;
|
||||
break;
|
||||
} //switch
|
||||
}
|
||||
} //if
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static void
|
||||
avlBalanceLeft(nsAVLNode*& aRootNode, PRBool& delOk){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
eLean balnc2;
|
||||
eLean balnc3;
|
||||
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
ptr2=aRootNode->mLeft;
|
||||
balnc2=ptr2->mSkew;
|
||||
if(balnc2!=eRight) {
|
||||
aRootNode->mLeft=ptr2->mRight;
|
||||
ptr2->mRight=aRootNode;
|
||||
if(balnc2==eNeutral){
|
||||
aRootNode->mSkew=eLeft;
|
||||
ptr2->mSkew=eRight;
|
||||
delOk=PR_FALSE;
|
||||
}
|
||||
else{
|
||||
aRootNode->mSkew=eNeutral;
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else{
|
||||
ptr3=ptr2->mRight;
|
||||
balnc3=ptr3->mSkew;
|
||||
ptr2->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=ptr2;
|
||||
aRootNode->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=aRootNode;
|
||||
if(balnc3==eRight) {
|
||||
ptr2->mSkew=eLeft;
|
||||
}
|
||||
else {
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
if(balnc3==eLeft) {
|
||||
aRootNode->mSkew=eRight;
|
||||
}
|
||||
else {
|
||||
aRootNode->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr3;
|
||||
ptr3->mSkew=eNeutral;
|
||||
}
|
||||
break;
|
||||
|
||||
case eRight:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
break;
|
||||
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eLeft;
|
||||
delOk=PR_FALSE;
|
||||
break;
|
||||
}//switch
|
||||
return;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static void
|
||||
avlBalanceRight(nsAVLNode*& aRootNode, PRBool& delOk){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
eLean balnc2;
|
||||
eLean balnc3;
|
||||
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
break;
|
||||
|
||||
case eRight:
|
||||
ptr2=aRootNode->mRight;
|
||||
balnc2=ptr2->mSkew;
|
||||
if(balnc2!=eLeft) {
|
||||
aRootNode->mRight=ptr2->mLeft;
|
||||
ptr2->mLeft=aRootNode;
|
||||
if(balnc2==eNeutral){
|
||||
aRootNode->mSkew=eRight;
|
||||
ptr2->mSkew=eLeft;
|
||||
delOk=PR_FALSE;
|
||||
}
|
||||
else{
|
||||
aRootNode->mSkew=eNeutral;
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else{
|
||||
ptr3=ptr2->mLeft;
|
||||
balnc3=ptr3->mSkew;
|
||||
ptr2->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=ptr2;
|
||||
aRootNode->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=aRootNode;
|
||||
if(balnc3==eLeft) {
|
||||
ptr2->mSkew=eRight;
|
||||
}
|
||||
else {
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
if(balnc3==eRight) {
|
||||
aRootNode->mSkew=eLeft;
|
||||
}
|
||||
else {
|
||||
aRootNode->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr3;
|
||||
ptr3->mSkew=eNeutral;
|
||||
}
|
||||
break;
|
||||
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eRight;
|
||||
delOk=PR_FALSE;
|
||||
break;
|
||||
}//switch
|
||||
return;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static eAVLStatus
|
||||
avlRemoveChildren(nsAVLNode*& aRootNode,nsAVLNode*& anotherNode, PRBool& delOk){
|
||||
eAVLStatus result=eAVL_ok;
|
||||
|
||||
if(!anotherNode->mRight){
|
||||
aRootNode->mValue=anotherNode->mValue; //swap
|
||||
anotherNode=anotherNode->mLeft;
|
||||
delOk=PR_TRUE;
|
||||
}
|
||||
else{
|
||||
avlRemoveChildren(aRootNode,anotherNode->mRight,delOk);
|
||||
if(delOk)
|
||||
avlBalanceLeft(anotherNode,delOk);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static eAVLStatus
|
||||
avlRemove(nsAVLNode*& aRootNode, void* anItem, PRBool& delOk,
|
||||
nsAVLNodeComparitor& aComparitor){
|
||||
eAVLStatus result=eAVL_ok;
|
||||
|
||||
if(!aRootNode)
|
||||
delOk=PR_FALSE;
|
||||
else {
|
||||
PRInt32 cmp=aComparitor(anItem,aRootNode->mValue);
|
||||
if(cmp<0){
|
||||
avlRemove(aRootNode->mLeft,anItem,delOk,aComparitor);
|
||||
if(delOk)
|
||||
avlBalanceRight(aRootNode,delOk);
|
||||
}
|
||||
else if(cmp>0){
|
||||
avlRemove(aRootNode->mRight,anItem,delOk,aComparitor);
|
||||
if(delOk)
|
||||
avlBalanceLeft(aRootNode,delOk);
|
||||
}
|
||||
else{ //they match...
|
||||
nsAVLNode* temp=aRootNode;
|
||||
if(!aRootNode->mRight) {
|
||||
aRootNode=aRootNode->mLeft;
|
||||
delOk=PR_TRUE;
|
||||
delete temp;
|
||||
}
|
||||
else if(!aRootNode->mLeft) {
|
||||
aRootNode=aRootNode->mRight;
|
||||
delOk=PR_TRUE;
|
||||
delete temp;
|
||||
}
|
||||
else {
|
||||
avlRemoveChildren(aRootNode,aRootNode->mLeft,delOk);
|
||||
if(delOk)
|
||||
avlBalanceRight(aRootNode,delOk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
eAVLStatus
|
||||
nsAVLTree::AddItem(void* anItem){
|
||||
eAVLStatus result=eAVL_ok;
|
||||
|
||||
nsAVLNode* theNewNode=new nsAVLNode(anItem);
|
||||
result=avlInsert(mRoot,theNewNode,mComparitor);
|
||||
if(eAVL_duplicate!=result)
|
||||
mCount++;
|
||||
else {
|
||||
delete theNewNode;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
void* nsAVLTree::FindItem(void* aValue) const{
|
||||
nsAVLNode* result=mRoot;
|
||||
PRInt32 count=0;
|
||||
while(result) {
|
||||
count++;
|
||||
PRInt32 cmp=mComparitor(aValue,result->mValue);
|
||||
if(0==cmp) {
|
||||
//we matched...
|
||||
break;
|
||||
}
|
||||
else if(0>cmp){
|
||||
//theNode was greater...
|
||||
result=result->mLeft;
|
||||
}
|
||||
else {
|
||||
//aValue is greater...
|
||||
result=result->mRight;
|
||||
}
|
||||
}
|
||||
if(result) {
|
||||
return result->mValue;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/30/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
eAVLStatus
|
||||
nsAVLTree::RemoveItem(void* aValue){
|
||||
PRBool delOk=PR_TRUE;
|
||||
eAVLStatus result=avlRemove(mRoot,aValue,delOk,mComparitor);
|
||||
if(eAVL_ok==result)
|
||||
mCount--;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlForEachDepthFirst(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor){
|
||||
if(aNode) {
|
||||
avlForEachDepthFirst(aNode->mLeft,aFunctor);
|
||||
avlForEachDepthFirst(aNode->mRight,aFunctor);
|
||||
aFunctor(aNode->mValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void
|
||||
nsAVLTree::ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const{
|
||||
::avlForEachDepthFirst(mRoot,aFunctor);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlForEach(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
|
||||
if(aNode) {
|
||||
avlForEach(aNode->mLeft,aFunctor);
|
||||
aFunctor(aNode->mValue);
|
||||
avlForEach(aNode->mRight,aFunctor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void
|
||||
nsAVLTree::ForEach(nsAVLNodeFunctor& aFunctor) const{
|
||||
::avlForEach(mRoot,aFunctor);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void*
|
||||
avlFirstThat(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
|
||||
void* result=nsnull;
|
||||
if(aNode) {
|
||||
result = avlFirstThat(aNode->mLeft,aFunctor);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = aFunctor(aNode->mValue);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = avlFirstThat(aNode->mRight,aFunctor);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void*
|
||||
nsAVLTree::FirstThat(nsAVLNodeFunctor& aFunctor) const{
|
||||
return ::avlFirstThat(mRoot,aFunctor);
|
||||
}
|
||||
|
||||
74
mozilla/htmlparser/src/nsAVLTree.h
Normal file
74
mozilla/htmlparser/src/nsAVLTree.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsAVLTree_h___
|
||||
#define nsAVLTree_h___
|
||||
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
|
||||
enum eAVLStatus {eAVL_unknown,eAVL_ok,eAVL_fail,eAVL_duplicate};
|
||||
|
||||
|
||||
struct nsAVLNode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/26/98
|
||||
* @param anObject1 is the first object to be compared
|
||||
* @param anObject2 is the second object to be compared
|
||||
* @return -1,0,1 if object1 is less, equal, greater than object2
|
||||
*/
|
||||
class NS_COM nsAVLNodeComparitor {
|
||||
public:
|
||||
virtual PRInt32 operator()(void* anItem1,void* anItem2)=0;
|
||||
};
|
||||
|
||||
class NS_COM nsAVLNodeFunctor {
|
||||
public:
|
||||
virtual void* operator()(void* anItem)=0;
|
||||
};
|
||||
|
||||
class NS_COM nsAVLTree {
|
||||
public:
|
||||
nsAVLTree(nsAVLNodeComparitor& aComparitor, nsAVLNodeFunctor* aDeallocator);
|
||||
~nsAVLTree(void);
|
||||
|
||||
PRBool operator==(const nsAVLTree& aOther) const;
|
||||
PRInt32 GetCount(void) const {return mCount;}
|
||||
|
||||
//main functions...
|
||||
eAVLStatus AddItem(void* anItem);
|
||||
eAVLStatus RemoveItem(void* anItem);
|
||||
void* FindItem(void* anItem) const;
|
||||
void ForEach(nsAVLNodeFunctor& aFunctor) const;
|
||||
void ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const;
|
||||
void* FirstThat(nsAVLNodeFunctor& aFunctor) const;
|
||||
|
||||
protected:
|
||||
|
||||
nsAVLNode* mRoot;
|
||||
PRInt32 mCount;
|
||||
nsAVLNodeComparitor& mComparitor;
|
||||
nsAVLNodeFunctor* mDeallocator;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsAVLTree_h___ */
|
||||
|
||||
617
mozilla/parser/htmlparser/src/nsAVLTree.cpp
Normal file
617
mozilla/parser/htmlparser/src/nsAVLTree.cpp
Normal file
@@ -0,0 +1,617 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsAVLTree.h"
|
||||
|
||||
|
||||
enum eLean {eLeft,eNeutral,eRight};
|
||||
|
||||
struct NS_COM nsAVLNode {
|
||||
public:
|
||||
|
||||
nsAVLNode(void* aValue) {
|
||||
mLeft=0;
|
||||
mRight=0;
|
||||
mSkew=eNeutral;
|
||||
mValue=aValue;
|
||||
}
|
||||
|
||||
nsAVLNode* mLeft;
|
||||
nsAVLNode* mRight;
|
||||
eLean mSkew;
|
||||
void* mValue;
|
||||
};
|
||||
|
||||
|
||||
/************************************************************
|
||||
Now begin the tree class. Don't forget that the comparison
|
||||
between nodes must occur via the comparitor function,
|
||||
otherwise all you're testing is pointer addresses.
|
||||
************************************************************/
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
nsAVLTree::nsAVLTree(nsAVLNodeComparitor& aComparitor,
|
||||
nsAVLNodeFunctor* aDeallocator) :
|
||||
mComparitor(aComparitor), mDeallocator(aDeallocator) {
|
||||
mRoot=0;
|
||||
mCount=0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
avlDeleteTree(nsAVLNode* aNode){
|
||||
if (aNode) {
|
||||
avlDeleteTree(aNode->mLeft);
|
||||
avlDeleteTree(aNode->mRight);
|
||||
delete aNode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/27/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsAVLTree::~nsAVLTree(){
|
||||
if (mDeallocator) {
|
||||
ForEachDepthFirst(*mDeallocator);
|
||||
}
|
||||
avlDeleteTree(mRoot);
|
||||
}
|
||||
|
||||
|
||||
class CDoesntExist: public nsAVLNodeFunctor {
|
||||
public:
|
||||
CDoesntExist(const nsAVLTree& anotherTree) : mOtherTree(anotherTree) {
|
||||
}
|
||||
virtual void* operator()(void* anItem) {
|
||||
void* result=mOtherTree.FindItem(anItem);
|
||||
if(result)
|
||||
return nsnull;
|
||||
return anItem;
|
||||
}
|
||||
protected:
|
||||
const nsAVLTree& mOtherTree;
|
||||
};
|
||||
|
||||
/**
|
||||
* This method compares two trees (members by identity).
|
||||
* @update gess12/27/98
|
||||
* @param tree to compare against
|
||||
* @return true if they are identical (contain same stuff).
|
||||
*/
|
||||
PRBool nsAVLTree::operator==(const nsAVLTree& aCopy) const{
|
||||
CDoesntExist functor(aCopy);
|
||||
void* theItem=FirstThat(functor);
|
||||
PRBool result=PRBool(!theItem);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/27/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlRotateRight(nsAVLNode*& aRootNode){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
|
||||
ptr2=aRootNode->mRight;
|
||||
if(ptr2->mSkew==eRight) {
|
||||
aRootNode->mRight=ptr2->mLeft;
|
||||
ptr2->mLeft=aRootNode;
|
||||
aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else {
|
||||
ptr3=ptr2->mLeft;
|
||||
ptr2->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=ptr2;
|
||||
aRootNode->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=aRootNode;
|
||||
if(ptr3->mSkew==eLeft)
|
||||
ptr2->mSkew=eRight;
|
||||
else ptr2->mSkew=eNeutral;
|
||||
if(ptr3->mSkew==eRight)
|
||||
aRootNode->mSkew=eLeft;
|
||||
else aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr3;
|
||||
}
|
||||
aRootNode->mSkew=eNeutral;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/27/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlRotateLeft(nsAVLNode*& aRootNode){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
|
||||
ptr2=aRootNode->mLeft;
|
||||
if(ptr2->mSkew==eLeft) {
|
||||
aRootNode->mLeft=ptr2->mRight;
|
||||
ptr2->mRight=aRootNode;
|
||||
aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else {
|
||||
ptr3=ptr2->mRight;
|
||||
ptr2->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=ptr2;
|
||||
aRootNode->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=aRootNode;
|
||||
if(ptr3->mSkew==eRight)
|
||||
ptr2->mSkew=eLeft;
|
||||
else ptr2->mSkew=eNeutral;
|
||||
if(ptr3->mSkew==eLeft)
|
||||
aRootNode->mSkew=eRight;
|
||||
else aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr3;
|
||||
}
|
||||
aRootNode->mSkew=eNeutral;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static eAVLStatus
|
||||
avlInsert(nsAVLNode*& aRootNode, nsAVLNode* aNewNode,
|
||||
nsAVLNodeComparitor& aComparitor) {
|
||||
eAVLStatus result=eAVL_unknown;
|
||||
|
||||
if(!aRootNode) {
|
||||
aRootNode = aNewNode;
|
||||
return eAVL_ok;
|
||||
}
|
||||
|
||||
if(aNewNode==aRootNode->mValue) {
|
||||
return eAVL_duplicate;
|
||||
}
|
||||
|
||||
PRInt32 theCompareResult=aComparitor(aRootNode->mValue,aNewNode->mValue);
|
||||
if(0 < theCompareResult) { //if(anItem<aRootNode->mValue)
|
||||
result=avlInsert(aRootNode->mLeft,aNewNode,aComparitor);
|
||||
if(eAVL_ok==result) {
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
avlRotateLeft(aRootNode);
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eRight:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eLeft;
|
||||
break;
|
||||
} //switch
|
||||
}//if
|
||||
} //if
|
||||
else {
|
||||
result=avlInsert(aRootNode->mRight,aNewNode,aComparitor);
|
||||
if(eAVL_ok==result) {
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eRight:
|
||||
avlRotateRight(aRootNode);
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eRight;
|
||||
break;
|
||||
} //switch
|
||||
}
|
||||
} //if
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static void
|
||||
avlBalanceLeft(nsAVLNode*& aRootNode, PRBool& delOk){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
eLean balnc2;
|
||||
eLean balnc3;
|
||||
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
ptr2=aRootNode->mLeft;
|
||||
balnc2=ptr2->mSkew;
|
||||
if(balnc2!=eRight) {
|
||||
aRootNode->mLeft=ptr2->mRight;
|
||||
ptr2->mRight=aRootNode;
|
||||
if(balnc2==eNeutral){
|
||||
aRootNode->mSkew=eLeft;
|
||||
ptr2->mSkew=eRight;
|
||||
delOk=PR_FALSE;
|
||||
}
|
||||
else{
|
||||
aRootNode->mSkew=eNeutral;
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else{
|
||||
ptr3=ptr2->mRight;
|
||||
balnc3=ptr3->mSkew;
|
||||
ptr2->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=ptr2;
|
||||
aRootNode->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=aRootNode;
|
||||
if(balnc3==eRight) {
|
||||
ptr2->mSkew=eLeft;
|
||||
}
|
||||
else {
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
if(balnc3==eLeft) {
|
||||
aRootNode->mSkew=eRight;
|
||||
}
|
||||
else {
|
||||
aRootNode->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr3;
|
||||
ptr3->mSkew=eNeutral;
|
||||
}
|
||||
break;
|
||||
|
||||
case eRight:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
break;
|
||||
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eLeft;
|
||||
delOk=PR_FALSE;
|
||||
break;
|
||||
}//switch
|
||||
return;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static void
|
||||
avlBalanceRight(nsAVLNode*& aRootNode, PRBool& delOk){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
eLean balnc2;
|
||||
eLean balnc3;
|
||||
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
break;
|
||||
|
||||
case eRight:
|
||||
ptr2=aRootNode->mRight;
|
||||
balnc2=ptr2->mSkew;
|
||||
if(balnc2!=eLeft) {
|
||||
aRootNode->mRight=ptr2->mLeft;
|
||||
ptr2->mLeft=aRootNode;
|
||||
if(balnc2==eNeutral){
|
||||
aRootNode->mSkew=eRight;
|
||||
ptr2->mSkew=eLeft;
|
||||
delOk=PR_FALSE;
|
||||
}
|
||||
else{
|
||||
aRootNode->mSkew=eNeutral;
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else{
|
||||
ptr3=ptr2->mLeft;
|
||||
balnc3=ptr3->mSkew;
|
||||
ptr2->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=ptr2;
|
||||
aRootNode->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=aRootNode;
|
||||
if(balnc3==eLeft) {
|
||||
ptr2->mSkew=eRight;
|
||||
}
|
||||
else {
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
if(balnc3==eRight) {
|
||||
aRootNode->mSkew=eLeft;
|
||||
}
|
||||
else {
|
||||
aRootNode->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr3;
|
||||
ptr3->mSkew=eNeutral;
|
||||
}
|
||||
break;
|
||||
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eRight;
|
||||
delOk=PR_FALSE;
|
||||
break;
|
||||
}//switch
|
||||
return;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static eAVLStatus
|
||||
avlRemoveChildren(nsAVLNode*& aRootNode,nsAVLNode*& anotherNode, PRBool& delOk){
|
||||
eAVLStatus result=eAVL_ok;
|
||||
|
||||
if(!anotherNode->mRight){
|
||||
aRootNode->mValue=anotherNode->mValue; //swap
|
||||
anotherNode=anotherNode->mLeft;
|
||||
delOk=PR_TRUE;
|
||||
}
|
||||
else{
|
||||
avlRemoveChildren(aRootNode,anotherNode->mRight,delOk);
|
||||
if(delOk)
|
||||
avlBalanceLeft(anotherNode,delOk);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static eAVLStatus
|
||||
avlRemove(nsAVLNode*& aRootNode, void* anItem, PRBool& delOk,
|
||||
nsAVLNodeComparitor& aComparitor){
|
||||
eAVLStatus result=eAVL_ok;
|
||||
|
||||
if(!aRootNode)
|
||||
delOk=PR_FALSE;
|
||||
else {
|
||||
PRInt32 cmp=aComparitor(anItem,aRootNode->mValue);
|
||||
if(cmp<0){
|
||||
avlRemove(aRootNode->mLeft,anItem,delOk,aComparitor);
|
||||
if(delOk)
|
||||
avlBalanceRight(aRootNode,delOk);
|
||||
}
|
||||
else if(cmp>0){
|
||||
avlRemove(aRootNode->mRight,anItem,delOk,aComparitor);
|
||||
if(delOk)
|
||||
avlBalanceLeft(aRootNode,delOk);
|
||||
}
|
||||
else{ //they match...
|
||||
nsAVLNode* temp=aRootNode;
|
||||
if(!aRootNode->mRight) {
|
||||
aRootNode=aRootNode->mLeft;
|
||||
delOk=PR_TRUE;
|
||||
delete temp;
|
||||
}
|
||||
else if(!aRootNode->mLeft) {
|
||||
aRootNode=aRootNode->mRight;
|
||||
delOk=PR_TRUE;
|
||||
delete temp;
|
||||
}
|
||||
else {
|
||||
avlRemoveChildren(aRootNode,aRootNode->mLeft,delOk);
|
||||
if(delOk)
|
||||
avlBalanceRight(aRootNode,delOk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
eAVLStatus
|
||||
nsAVLTree::AddItem(void* anItem){
|
||||
eAVLStatus result=eAVL_ok;
|
||||
|
||||
nsAVLNode* theNewNode=new nsAVLNode(anItem);
|
||||
result=avlInsert(mRoot,theNewNode,mComparitor);
|
||||
if(eAVL_duplicate!=result)
|
||||
mCount++;
|
||||
else {
|
||||
delete theNewNode;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
void* nsAVLTree::FindItem(void* aValue) const{
|
||||
nsAVLNode* result=mRoot;
|
||||
PRInt32 count=0;
|
||||
while(result) {
|
||||
count++;
|
||||
PRInt32 cmp=mComparitor(aValue,result->mValue);
|
||||
if(0==cmp) {
|
||||
//we matched...
|
||||
break;
|
||||
}
|
||||
else if(0>cmp){
|
||||
//theNode was greater...
|
||||
result=result->mLeft;
|
||||
}
|
||||
else {
|
||||
//aValue is greater...
|
||||
result=result->mRight;
|
||||
}
|
||||
}
|
||||
if(result) {
|
||||
return result->mValue;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/30/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
eAVLStatus
|
||||
nsAVLTree::RemoveItem(void* aValue){
|
||||
PRBool delOk=PR_TRUE;
|
||||
eAVLStatus result=avlRemove(mRoot,aValue,delOk,mComparitor);
|
||||
if(eAVL_ok==result)
|
||||
mCount--;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlForEachDepthFirst(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor){
|
||||
if(aNode) {
|
||||
avlForEachDepthFirst(aNode->mLeft,aFunctor);
|
||||
avlForEachDepthFirst(aNode->mRight,aFunctor);
|
||||
aFunctor(aNode->mValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void
|
||||
nsAVLTree::ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const{
|
||||
::avlForEachDepthFirst(mRoot,aFunctor);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlForEach(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
|
||||
if(aNode) {
|
||||
avlForEach(aNode->mLeft,aFunctor);
|
||||
aFunctor(aNode->mValue);
|
||||
avlForEach(aNode->mRight,aFunctor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void
|
||||
nsAVLTree::ForEach(nsAVLNodeFunctor& aFunctor) const{
|
||||
::avlForEach(mRoot,aFunctor);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void*
|
||||
avlFirstThat(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
|
||||
void* result=nsnull;
|
||||
if(aNode) {
|
||||
result = avlFirstThat(aNode->mLeft,aFunctor);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = aFunctor(aNode->mValue);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = avlFirstThat(aNode->mRight,aFunctor);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void*
|
||||
nsAVLTree::FirstThat(nsAVLNodeFunctor& aFunctor) const{
|
||||
return ::avlFirstThat(mRoot,aFunctor);
|
||||
}
|
||||
|
||||
74
mozilla/parser/htmlparser/src/nsAVLTree.h
Normal file
74
mozilla/parser/htmlparser/src/nsAVLTree.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsAVLTree_h___
|
||||
#define nsAVLTree_h___
|
||||
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
|
||||
enum eAVLStatus {eAVL_unknown,eAVL_ok,eAVL_fail,eAVL_duplicate};
|
||||
|
||||
|
||||
struct nsAVLNode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/26/98
|
||||
* @param anObject1 is the first object to be compared
|
||||
* @param anObject2 is the second object to be compared
|
||||
* @return -1,0,1 if object1 is less, equal, greater than object2
|
||||
*/
|
||||
class NS_COM nsAVLNodeComparitor {
|
||||
public:
|
||||
virtual PRInt32 operator()(void* anItem1,void* anItem2)=0;
|
||||
};
|
||||
|
||||
class NS_COM nsAVLNodeFunctor {
|
||||
public:
|
||||
virtual void* operator()(void* anItem)=0;
|
||||
};
|
||||
|
||||
class NS_COM nsAVLTree {
|
||||
public:
|
||||
nsAVLTree(nsAVLNodeComparitor& aComparitor, nsAVLNodeFunctor* aDeallocator);
|
||||
~nsAVLTree(void);
|
||||
|
||||
PRBool operator==(const nsAVLTree& aOther) const;
|
||||
PRInt32 GetCount(void) const {return mCount;}
|
||||
|
||||
//main functions...
|
||||
eAVLStatus AddItem(void* anItem);
|
||||
eAVLStatus RemoveItem(void* anItem);
|
||||
void* FindItem(void* anItem) const;
|
||||
void ForEach(nsAVLNodeFunctor& aFunctor) const;
|
||||
void ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const;
|
||||
void* FirstThat(nsAVLNodeFunctor& aFunctor) const;
|
||||
|
||||
protected:
|
||||
|
||||
nsAVLNode* mRoot;
|
||||
PRInt32 mCount;
|
||||
nsAVLNodeComparitor& mComparitor;
|
||||
nsAVLNodeFunctor* mDeallocator;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsAVLTree_h___ */
|
||||
|
||||
717
mozilla/string/obsolete/nsStr.cpp
Normal file
717
mozilla/string/obsolete/nsStr.cpp
Normal file
@@ -0,0 +1,717 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/******************************************************************************************
|
||||
MODULE NOTES:
|
||||
|
||||
This file contains the nsStr data structure.
|
||||
This general purpose buffer management class is used as the basis for our strings.
|
||||
It's benefits include:
|
||||
1. An efficient set of library style functions for manipulating nsStrs
|
||||
2. Support for 1 and 2 byte character strings (which can easily be increased to n)
|
||||
3. Unicode awareness and interoperability.
|
||||
|
||||
*******************************************************************************************/
|
||||
|
||||
#include "nsStr.h"
|
||||
#include "bufferRoutines.h"
|
||||
#include "stdio.h" //only used for printf
|
||||
#include "nsCRT.h"
|
||||
#include "nsDeque.h"
|
||||
|
||||
|
||||
//static const char* kCallFindChar = "For better performance, call FindChar() for targets whose length==1.";
|
||||
//static const char* kCallRFindChar = "For better performance, call RFindChar() for targets whose length==1.";
|
||||
|
||||
static const PRUnichar gCommonEmptyBuffer[1] = {0};
|
||||
|
||||
/**
|
||||
* This method initializes all the members of the nsStr structure
|
||||
*
|
||||
* @update gess10/30/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsStr::Initialize(nsStr& aDest,eCharSize aCharSize) {
|
||||
aDest.mStr=(char*)gCommonEmptyBuffer;
|
||||
aDest.mLength=0;
|
||||
aDest.mCapacity=0;
|
||||
aDest.mCharSize=aCharSize;
|
||||
aDest.mOwnsBuffer=0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes all the members of the nsStr structure
|
||||
* @update gess10/30/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsStr::Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 aLength,eCharSize aCharSize,PRBool aOwnsBuffer){
|
||||
aDest.mStr=(aCString) ? aCString : (char*)gCommonEmptyBuffer;
|
||||
aDest.mLength=aLength;
|
||||
aDest.mCapacity=aCapacity;
|
||||
aDest.mCharSize=aCharSize;
|
||||
aDest.mOwnsBuffer=aOwnsBuffer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This member destroys the memory buffer owned by an nsStr object (if it actually owns it)
|
||||
* @update gess10/30/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsStr::Destroy(nsStr& aDest) {
|
||||
if((aDest.mStr) && (aDest.mStr!=(char*)gCommonEmptyBuffer)) {
|
||||
Free(aDest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method gets called when the internal buffer needs
|
||||
* to grow to a given size. The original contents are not preserved.
|
||||
* @update gess 3/30/98
|
||||
* @param aNewLength -- new capacity of string in charSize units
|
||||
* @return void
|
||||
*/
|
||||
PRBool nsStr::EnsureCapacity(nsStr& aString,PRUint32 aNewLength) {
|
||||
PRBool result=PR_TRUE;
|
||||
if(aNewLength>aString.mCapacity) {
|
||||
result=Realloc(aString,aNewLength);
|
||||
if(aString.mStr)
|
||||
AddNullTerminator(aString);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the internal buffer needs
|
||||
* to grow to a given size. The original contents ARE preserved.
|
||||
* @update gess 3/30/98
|
||||
* @param aNewLength -- new capacity of string in charSize units
|
||||
* @return void
|
||||
*/
|
||||
PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
|
||||
PRBool result=PR_TRUE;
|
||||
if(aNewLength>aDest.mCapacity) {
|
||||
nsStr theTempStr;
|
||||
nsStr::Initialize(theTempStr,aDest.mCharSize);
|
||||
|
||||
result=EnsureCapacity(theTempStr,aNewLength);
|
||||
if(result) {
|
||||
if(aDest.mLength) {
|
||||
Append(theTempStr,aDest,0,aDest.mLength);
|
||||
}
|
||||
Free(aDest);
|
||||
aDest.mStr = theTempStr.mStr;
|
||||
theTempStr.mStr=0; //make sure to null this out so that you don't lose the buffer you just stole...
|
||||
aDest.mLength=theTempStr.mLength;
|
||||
aDest.mCapacity=theTempStr.mCapacity;
|
||||
aDest.mOwnsBuffer=theTempStr.mOwnsBuffer;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the contents of aDest with aSource, up to aCount of chars.
|
||||
* @update gess10/30/98
|
||||
* @param aDest is the nsStr that gets changed.
|
||||
* @param aSource is where chars are copied from
|
||||
* @param aCount is the number of chars copied from aSource
|
||||
*/
|
||||
void nsStr::Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
if(&aDest!=&aSource){
|
||||
Truncate(aDest,0);
|
||||
Append(aDest,aSource,anOffset,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method appends the given nsStr to this one. Note that we have to
|
||||
* pay attention to the underlying char-size of both structs.
|
||||
* @update gess10/30/98
|
||||
* @param aDest is the nsStr to be manipulated
|
||||
* @param aSource is where char are copied from
|
||||
* @aCount is the number of bytes to be copied
|
||||
*/
|
||||
void nsStr::Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
if(anOffset<aSource.mLength){
|
||||
PRUint32 theRealLen=(aCount<0) ? aSource.mLength : MinInt(aCount,aSource.mLength);
|
||||
PRUint32 theLength=(anOffset+theRealLen<aSource.mLength) ? theRealLen : (aSource.mLength-anOffset);
|
||||
if(0<theLength){
|
||||
|
||||
PRBool isBigEnough=PR_TRUE;
|
||||
if(aDest.mLength+theLength > aDest.mCapacity) {
|
||||
isBigEnough=GrowCapacity(aDest,aDest.mLength+theLength);
|
||||
}
|
||||
|
||||
if(isBigEnough) {
|
||||
//now append new chars, starting at offset
|
||||
(*gCopyChars[aSource.mCharSize][aDest.mCharSize])(aDest.mStr,aDest.mLength,aSource.mStr,anOffset,theLength);
|
||||
|
||||
aDest.mLength+=theLength;
|
||||
AddNullTerminator(aDest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method inserts up to "aCount" chars from a source nsStr into a dest nsStr.
|
||||
* @update gess10/30/98
|
||||
* @param aDest is the nsStr that gets changed
|
||||
* @param aDestOffset is where in aDest the insertion is to occur
|
||||
* @param aSource is where chars are copied from
|
||||
* @param aSrcOffset is where in aSource chars are copied from
|
||||
* @param aCount is the number of chars from aSource to be inserted into aDest
|
||||
*/
|
||||
void nsStr::Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount){
|
||||
//there are a few cases for insert:
|
||||
// 1. You're inserting chars into an empty string (assign)
|
||||
// 2. You're inserting onto the end of a string (append)
|
||||
// 3. You're inserting onto the 1..n-1 pos of a string (the hard case).
|
||||
if(0<aSource.mLength){
|
||||
if(aDest.mLength){
|
||||
if(aDestOffset<aDest.mLength){
|
||||
PRInt32 theRealLen=(aCount<0) ? aSource.mLength : MinInt(aCount,aSource.mLength);
|
||||
PRInt32 theLength=(aSrcOffset+theRealLen<aSource.mLength) ? theRealLen : (aSource.mLength-aSrcOffset);
|
||||
|
||||
if(aSrcOffset<aSource.mLength) {
|
||||
//here's the only new case we have to handle.
|
||||
//chars are really being inserted into our buffer...
|
||||
|
||||
if(aDest.mLength+theLength > aDest.mCapacity) {
|
||||
nsStr theTempStr;
|
||||
nsStr::Initialize(theTempStr,aDest.mCharSize);
|
||||
|
||||
PRBool isBigEnough=EnsureCapacity(theTempStr,aDest.mLength+theLength); //grow the temp buffer to the right size
|
||||
|
||||
if(isBigEnough) {
|
||||
if(aDestOffset) {
|
||||
Append(theTempStr,aDest,0,aDestOffset); //first copy leftmost data...
|
||||
}
|
||||
|
||||
Append(theTempStr,aSource,0,aSource.mLength); //next copy inserted (new) data
|
||||
|
||||
PRUint32 theRemains=aDest.mLength-aDestOffset;
|
||||
if(theRemains) {
|
||||
Append(theTempStr,aDest,aDestOffset,theRemains); //next copy rightmost data
|
||||
}
|
||||
|
||||
Free(aDest);
|
||||
aDest.mStr = theTempStr.mStr;
|
||||
theTempStr.mStr=0; //make sure to null this out so that you don't lose the buffer you just stole...
|
||||
aDest.mCapacity=theTempStr.mCapacity;
|
||||
aDest.mOwnsBuffer=theTempStr.mOwnsBuffer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
//shift the chars right by theDelta...
|
||||
(*gShiftChars[aDest.mCharSize][KSHIFTRIGHT])(aDest.mStr,aDest.mLength,aDestOffset,theLength);
|
||||
|
||||
//now insert new chars, starting at offset
|
||||
(*gCopyChars[aSource.mCharSize][aDest.mCharSize])(aDest.mStr,aDestOffset,aSource.mStr,aSrcOffset,theLength);
|
||||
}
|
||||
|
||||
//finally, make sure to update the string length...
|
||||
aDest.mLength+=theLength;
|
||||
AddNullTerminator(aDest);
|
||||
|
||||
}//if
|
||||
//else nothing to do!
|
||||
}
|
||||
else Append(aDest,aSource,0,aCount);
|
||||
}
|
||||
else Append(aDest,aSource,0,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method deletes up to aCount chars from aDest
|
||||
* @update gess10/30/98
|
||||
* @param aDest is the nsStr to be manipulated
|
||||
* @param aDestOffset is where in aDest deletion is to occur
|
||||
* @param aCount is the number of chars to be deleted in aDest
|
||||
*/
|
||||
void nsStr::Delete(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount){
|
||||
if(aDestOffset<aDest.mLength){
|
||||
|
||||
PRUint32 theDelta=aDest.mLength-aDestOffset;
|
||||
PRUint32 theLength=(theDelta<aCount) ? theDelta : aCount;
|
||||
|
||||
if(aDestOffset+theLength<aDest.mLength) {
|
||||
|
||||
//if you're here, it means we're cutting chars out of the middle of the string...
|
||||
//so shift the chars left by theLength...
|
||||
(*gShiftChars[aDest.mCharSize][KSHIFTLEFT])(aDest.mStr,aDest.mLength,aDestOffset,theLength);
|
||||
aDest.mLength-=theLength;
|
||||
AddNullTerminator(aDest);
|
||||
}
|
||||
else Truncate(aDest,aDestOffset);
|
||||
}//if
|
||||
}
|
||||
|
||||
/**
|
||||
* This method truncates the given nsStr at given offset
|
||||
* @update gess10/30/98
|
||||
* @param aDest is the nsStr to be truncated
|
||||
* @param aDestOffset is where in aDest truncation is to occur
|
||||
*/
|
||||
void nsStr::Truncate(nsStr& aDest,PRUint32 aDestOffset){
|
||||
if(aDestOffset<aDest.mLength){
|
||||
aDest.mLength=aDestOffset;
|
||||
AddNullTerminator(aDest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method forces the given string to upper or lowercase
|
||||
* @update gess1/7/99
|
||||
* @param aDest is the string you're going to change
|
||||
* @param aToUpper: if TRUE, then we go uppercase, otherwise we go lowercase
|
||||
* @return
|
||||
*/
|
||||
void nsStr::ChangeCase(nsStr& aDest,PRBool aToUpper) {
|
||||
// somehow UnicharUtil return failed, fallback to the old ascii only code
|
||||
gCaseConverters[aDest.mCharSize](aDest.mStr,aDest.mLength,aToUpper);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess1/7/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsStr::Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){
|
||||
|
||||
if((aDest.mLength>0) && aSet){
|
||||
PRInt32 theIndex=-1;
|
||||
PRInt32 theMax=aDest.mLength;
|
||||
PRInt32 theSetLen=nsCRT::strlen(aSet);
|
||||
|
||||
if(aEliminateLeading) {
|
||||
while(++theIndex<=theMax) {
|
||||
PRUnichar theChar=GetCharAt(aDest,theIndex);
|
||||
PRInt32 thePos=gFindChars[eOneByte](aSet,theSetLen,0,theChar,PR_FALSE);
|
||||
if(kNotFound==thePos)
|
||||
break;
|
||||
}
|
||||
if(0<theIndex) {
|
||||
if(theIndex<theMax) {
|
||||
Delete(aDest,0,theIndex);
|
||||
}
|
||||
else Truncate(aDest,0);
|
||||
}
|
||||
}
|
||||
|
||||
if(aEliminateTrailing) {
|
||||
theIndex=aDest.mLength;
|
||||
PRInt32 theNewLen=theIndex;
|
||||
while(--theIndex>0) {
|
||||
PRUnichar theChar=GetCharAt(aDest,theIndex); //read at end now...
|
||||
PRInt32 thePos=gFindChars[eOneByte](aSet,theSetLen,0,theChar,PR_FALSE);
|
||||
if(kNotFound<thePos)
|
||||
theNewLen=theIndex;
|
||||
else break;
|
||||
}
|
||||
if(theNewLen<theMax) {
|
||||
Truncate(aDest,theNewLen);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess1/7/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsStr::CompressSet(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){
|
||||
Trim(aDest,aSet,aEliminateLeading,aEliminateTrailing);
|
||||
PRUint32 aNewLen=gCompressChars[aDest.mCharSize](aDest.mStr,aDest.mLength,aSet);
|
||||
aDest.mLength=aNewLen;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess1/7/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsStr::StripChars(nsStr& aDest,const char* aSet){
|
||||
if((0<aDest.mLength) && (aSet)) {
|
||||
PRUint32 aNewLen=gStripChars[aDest.mCharSize](aDest.mStr,aDest.mLength,aSet);
|
||||
aDest.mLength=aNewLen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************
|
||||
Searching methods...
|
||||
**************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* This searches aDest for a given substring
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aDest string to search
|
||||
* @param aTarget is the substring you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::FindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
// NS_PRECONDITION(aTarget.mLength!=1,kCallFindChar);
|
||||
|
||||
PRInt32 result=kNotFound;
|
||||
|
||||
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
|
||||
PRInt32 theMax=aDest.mLength-aTarget.mLength;
|
||||
PRInt32 index=(0<=anOffset) ? anOffset : 0;
|
||||
|
||||
if((aDest.mLength>=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){
|
||||
PRInt32 theTargetMax=aTarget.mLength;
|
||||
while(index<=theMax) {
|
||||
PRInt32 theSubIndex=-1;
|
||||
PRBool matches=PR_TRUE;
|
||||
while((++theSubIndex<theTargetMax) && (matches)){
|
||||
PRUnichar theChar=(aIgnoreCase) ? nsCRT::ToLower(GetCharAt(aDest,index+theSubIndex)) : GetCharAt(aDest,index+theSubIndex);
|
||||
PRUnichar theTargetChar=(aIgnoreCase) ? nsCRT::ToLower(GetCharAt(aTarget,theSubIndex)) : GetCharAt(aTarget,theSubIndex);
|
||||
matches=PRBool(theChar==theTargetChar);
|
||||
}
|
||||
if(matches) {
|
||||
result=index;
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
} //while
|
||||
}//if
|
||||
}//if
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This searches aDest for a given character
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aDest string to search
|
||||
* @param char is the character you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::FindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
PRInt32 result=kNotFound;
|
||||
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
|
||||
PRUint32 index=(0<=anOffset) ? (PRUint32)anOffset : 0;
|
||||
result=gFindChars[aDest.mCharSize](aDest.mStr,aDest.mLength,index,aChar,aIgnoreCase);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This searches aDest for a character found in aSet.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aDest string to search
|
||||
* @param aSet contains a list of chars to be searched for
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::FindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
//NS_PRECONDITION(aSet.mLength!=1,kCallFindChar);
|
||||
|
||||
PRInt32 index=(0<=anOffset) ? anOffset-1 : -1;
|
||||
PRInt32 thePos;
|
||||
|
||||
//Note that the search is inverted here. We're scanning aDest, one char at a time
|
||||
//but doing the search against the given set. That's why we use 0 as the offset below.
|
||||
if((0<aDest.mLength) && (0<aSet.mLength)){
|
||||
while(++index<(PRInt32)aDest.mLength) {
|
||||
PRUnichar theChar=GetCharAt(aDest,index);
|
||||
thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
|
||||
if(kNotFound!=thePos)
|
||||
return index;
|
||||
} //while
|
||||
}
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
Reverse Searching methods...
|
||||
**************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* This searches aDest (in reverse) for a given substring
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aDest string to search
|
||||
* @param aTarget is the substring you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search (counting from left)
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::RFindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
//NS_PRECONDITION(aTarget.mLength!=1,kCallRFindChar);
|
||||
|
||||
PRInt32 result=kNotFound;
|
||||
|
||||
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
|
||||
PRInt32 index=(0<=anOffset) ? anOffset : aDest.mLength-1;
|
||||
|
||||
if((aDest.mLength>=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){
|
||||
|
||||
nsStr theCopy;
|
||||
nsStr::Initialize(theCopy,eOneByte);
|
||||
nsStr::Assign(theCopy,aTarget,0,aTarget.mLength);
|
||||
if(aIgnoreCase){
|
||||
nsStr::ChangeCase(theCopy,PR_FALSE); //force to lowercase
|
||||
}
|
||||
|
||||
PRInt32 theTargetMax=theCopy.mLength;
|
||||
while(index>=0) {
|
||||
PRInt32 theSubIndex=-1;
|
||||
PRBool matches=PR_FALSE;
|
||||
if(index+theCopy.mLength<=aDest.mLength) {
|
||||
matches=PR_TRUE;
|
||||
while((++theSubIndex<theTargetMax) && (matches)){
|
||||
PRUnichar theDestChar=(aIgnoreCase) ? nsCRT::ToLower(GetCharAt(aDest,index+theSubIndex)) : GetCharAt(aDest,index+theSubIndex);
|
||||
PRUnichar theTargetChar=GetCharAt(theCopy,theSubIndex);
|
||||
matches=PRBool(theDestChar==theTargetChar);
|
||||
} //while
|
||||
} //if
|
||||
if(matches) {
|
||||
result=index;
|
||||
break;
|
||||
}
|
||||
index--;
|
||||
} //while
|
||||
nsStr::Destroy(theCopy);
|
||||
}//if
|
||||
}//if
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This searches aDest (in reverse) for a given character
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aDest string to search
|
||||
* @param char is the character you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::RFindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
PRInt32 result=kNotFound;
|
||||
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
|
||||
PRUint32 index=(0<=anOffset) ? anOffset : aDest.mLength-1;
|
||||
result=gRFindChars[aDest.mCharSize](aDest.mStr,aDest.mLength,index,aChar,aIgnoreCase);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This searches aDest (in reverese) for a character found in aSet.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aDest string to search
|
||||
* @param aSet contains a list of chars to be searched for
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
//NS_PRECONDITION(aSet.mLength!=1,kCallRFindChar);
|
||||
|
||||
PRInt32 index=(0<=anOffset) ? anOffset : aDest.mLength;
|
||||
PRInt32 thePos;
|
||||
|
||||
//note that the search is inverted here. We're scanning aDest, one char at a time
|
||||
//but doing the search against the given set. That's why we use 0 as the offset below.
|
||||
if(0<aDest.mLength) {
|
||||
while(--index>=0) {
|
||||
PRUnichar theChar=GetCharAt(aDest,index);
|
||||
thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
|
||||
if(kNotFound!=thePos)
|
||||
return index;
|
||||
} //while
|
||||
}
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compare source and dest strings, up to an (optional max) number of chars
|
||||
* @param aDest is the first str to compare
|
||||
* @param aSource is the second str to compare
|
||||
* @param aCount -- if (-1), then we use length of longer string; if (0<aCount) then it gives the max # of chars to compare
|
||||
* @param aIgnorecase tells us whether to search with case sensitivity
|
||||
* @return aDest<aSource=-1;aDest==aSource==0;aDest>aSource=1
|
||||
*/
|
||||
PRInt32 nsStr::Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
|
||||
PRInt32 result=0;
|
||||
|
||||
if(aCount) {
|
||||
PRInt32 minlen=(aSource.mLength<aDest.mLength) ? aSource.mLength : aDest.mLength;
|
||||
|
||||
if(0==minlen) {
|
||||
if ((aDest.mLength == 0) && (aSource.mLength == 0))
|
||||
return 0;
|
||||
if (aDest.mLength == 0)
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
PRInt32 maxlen=(aSource.mLength<aDest.mLength) ? aDest.mLength : aSource.mLength;
|
||||
aCount = (aCount<0) ? maxlen : MinInt(aCount,maxlen);
|
||||
result=(*gCompare[aDest.mCharSize][aSource.mCharSize])(aDest.mStr,aSource.mStr,aCount,aIgnoreCase);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
PRBool nsStr::Alloc(nsStr& aDest,PRUint32 aCount) {
|
||||
|
||||
static int mAllocCount=0;
|
||||
mAllocCount++;
|
||||
|
||||
//we're given the acount value in charunits; now scale up to next multiple.
|
||||
PRUint32 theNewCapacity=kDefaultStringSize;
|
||||
while(theNewCapacity<aCount){
|
||||
theNewCapacity<<=1;
|
||||
}
|
||||
|
||||
aDest.mCapacity=theNewCapacity++;
|
||||
PRUint32 theSize=(theNewCapacity<<aDest.mCharSize);
|
||||
aDest.mStr = (char*)nsAllocator::Alloc(theSize);
|
||||
|
||||
PRBool result=PR_FALSE;
|
||||
if(aDest.mStr) {
|
||||
aDest.mOwnsBuffer=1;
|
||||
result=PR_TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
PRBool nsStr::Free(nsStr& aDest){
|
||||
if(aDest.mStr){
|
||||
if(aDest.mOwnsBuffer){
|
||||
nsAllocator::Free(aDest.mStr);
|
||||
}
|
||||
aDest.mStr=0;
|
||||
aDest.mOwnsBuffer=0;
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsStr::Realloc(nsStr& aDest,PRUint32 aCount){
|
||||
|
||||
nsStr temp;
|
||||
memcpy(&temp,&aDest,sizeof(aDest));
|
||||
|
||||
PRBool result=Alloc(temp,aCount);
|
||||
if(result) {
|
||||
Free(aDest);
|
||||
aDest.mStr=temp.mStr;
|
||||
aDest.mCapacity=temp.mCapacity;
|
||||
aDest.mOwnsBuffer=temp.mOwnsBuffer;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
CBufDescriptor::CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
|
||||
mBuffer=aString;
|
||||
mCharSize=eOneByte;
|
||||
mStackBased=aStackBased;
|
||||
mIsConst=PR_FALSE;
|
||||
mLength=mCapacity=0;
|
||||
if(aString && aCapacity>1) {
|
||||
mCapacity=aCapacity-1;
|
||||
mLength=(-1==aLength) ? strlen(aString) : aLength;
|
||||
if(mLength>PRInt32(mCapacity))
|
||||
mLength=mCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
CBufDescriptor::CBufDescriptor(const char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
|
||||
mBuffer=(char*)aString;
|
||||
mCharSize=eOneByte;
|
||||
mStackBased=aStackBased;
|
||||
mIsConst=PR_TRUE;
|
||||
mLength=mCapacity=0;
|
||||
if(aString && aCapacity>1) {
|
||||
mCapacity=aCapacity-1;
|
||||
mLength=(-1==aLength) ? strlen(aString) : aLength;
|
||||
if(mLength>PRInt32(mCapacity))
|
||||
mLength=mCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CBufDescriptor::CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
|
||||
mBuffer=(char*)aString;
|
||||
mCharSize=eTwoByte;
|
||||
mStackBased=aStackBased;
|
||||
mLength=mCapacity=0;
|
||||
mIsConst=PR_FALSE;
|
||||
if(aString && aCapacity>1) {
|
||||
mCapacity=aCapacity-1;
|
||||
mLength=(-1==aLength) ? nsCRT::strlen(aString) : aLength;
|
||||
if(mLength>PRInt32(mCapacity))
|
||||
mLength=mCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
CBufDescriptor::CBufDescriptor(const PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
|
||||
mBuffer=(char*)aString;
|
||||
mCharSize=eTwoByte;
|
||||
mStackBased=aStackBased;
|
||||
mLength=mCapacity=0;
|
||||
mIsConst=PR_TRUE;
|
||||
if(aString && aCapacity>1) {
|
||||
mCapacity=aCapacity-1;
|
||||
mLength=(-1==aLength) ? nsCRT::strlen(aString) : aLength;
|
||||
if(mLength>PRInt32(mCapacity))
|
||||
mLength=mCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
450
mozilla/string/obsolete/nsStr.h
Normal file
450
mozilla/string/obsolete/nsStr.h
Normal file
@@ -0,0 +1,450 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
MODULE NOTES:
|
||||
|
||||
1. There are two philosophies to building string classes:
|
||||
A. Hide the underlying buffer & offer API's allow indirect iteration
|
||||
B. Reveal underlying buffer, risk corruption, but gain performance
|
||||
|
||||
We chose the option B for performance reasons.
|
||||
|
||||
2 Our internal buffer always holds capacity+1 bytes.
|
||||
|
||||
The nsStr struct is a simple structure (no methods) that contains
|
||||
the necessary info to be described as a string. This simple struct
|
||||
is manipulated by the static methods provided in this class.
|
||||
(Which effectively makes this a library that works on structs).
|
||||
|
||||
There are also object-based versions called nsString and nsAutoString
|
||||
which use nsStr but makes it look at feel like an object.
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
/***********************************************************************
|
||||
ASSUMPTIONS:
|
||||
|
||||
1. nsStrings and nsAutoString are always null terminated.
|
||||
2. If you try to set a null char (via SetChar()) a new length is set
|
||||
3. nsCStrings can be upsampled into nsString without data loss
|
||||
4. Char searching is faster than string searching. Use char interfaces
|
||||
if your needs will allow it.
|
||||
5. It's easy to use the stack for nsAutostring buffer storage (fast too!).
|
||||
See the CBufDescriptor class in this file.
|
||||
6. It's ONLY ok to provide non-null-terminated buffers to Append() and Insert()
|
||||
provided you specify a 0<n value for the optional count argument.
|
||||
7. Downsampling from nsString to nsCString is lossy -- avoid it if possible!
|
||||
8. Calls to ToNewCString() and ToNewUnicode() should be matched with calls to Recycle().
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
/**********************************************************************************
|
||||
|
||||
AND NOW FOR SOME GENERAL DOCUMENTATION ON STRING USAGE...
|
||||
|
||||
The fundamental datatype in the string library is nsStr. It's a structure that
|
||||
provides the buffer storage and meta-info. It also provides a C-style library
|
||||
of functions for direct manipulation (for those of you who prefer K&R to Bjarne).
|
||||
|
||||
Here's a diagram of the class hierarchy:
|
||||
|
||||
nsStr
|
||||
|___nsString
|
||||
| |
|
||||
| ------nsAutoString
|
||||
|
|
||||
|___nsCString
|
||||
|
|
||||
------nsCAutoString
|
||||
|
||||
Why so many string classes? The 4 variants give you the control you need to
|
||||
determine the best class for your purpose. There are 2 dimensions to this
|
||||
flexibility: 1) stack vs. heap; and 2) 1-byte chars vs. 2-byte chars.
|
||||
|
||||
Note: While nsAutoString and nsCAutoString begin life using stack-based storage,
|
||||
they may not stay that way. Like all nsString classes, autostrings will
|
||||
automatically grow to contain the data you provide. When autostrings
|
||||
grow beyond their intrinsic buffer, they switch to heap based allocations.
|
||||
(We avoid alloca to avoid considerable platform difficulties; see the
|
||||
GNU documentation for more details).
|
||||
|
||||
I should also briefly mention that all the string classes use a "memory agent"
|
||||
object to perform memory operations. This class proxies the standard nsAllocator
|
||||
for actual memory calls, but knows the structure of nsStr making heap operations
|
||||
more localized.
|
||||
|
||||
|
||||
CHOOSING A STRING CLASS:
|
||||
|
||||
In order to choose a string class for you purpose, use this handy table:
|
||||
|
||||
heap-based stack-based
|
||||
-----------------------------------
|
||||
ascii data | nsCString nsCAutoString |
|
||||
|----------------------------------
|
||||
unicode data | nsString nsAutoString |
|
||||
-----------------------------------
|
||||
|
||||
|
||||
Note: The i18n folks will stenuously object if we get too carried away with the
|
||||
use of nsCString's that pass interface boundaries. Try to limit your
|
||||
use of these to external interfaces that demand them, or for your own
|
||||
private purposes in cases where they'll never be seen by humans.
|
||||
|
||||
|
||||
PERFORMANCE CONSIDERATIONS:
|
||||
|
||||
Here are a few tricks to know in order to get better string performance:
|
||||
|
||||
1) Try to limit conversions between ascii and unicode; By sticking with nsString
|
||||
wherever possible your code will be i18n-compliant.
|
||||
|
||||
|
||||
2) Preallocating your string buffer cuts down trips to the allocator. So if you
|
||||
have need for an arbitrarily large buffer, pre-size it like this:
|
||||
|
||||
{
|
||||
nsString mBuffer;
|
||||
mBuffer.SetCapacity(aReasonableSize);
|
||||
}
|
||||
|
||||
3) Allocating nsAutoString or nsCAutoString on the heap is memory inefficient
|
||||
(after all, the whole point is to avoid a heap allocation of the buffer).
|
||||
|
||||
|
||||
4) Consider using an autoString to write into your arbitrarily-sized stack buffers, rather
|
||||
than it's own buffers.
|
||||
|
||||
For example, let's say you're going to call printf() to emit pretty-printed debug output
|
||||
of your object. You know from experience that the pretty-printed version of your object
|
||||
exceeds the capacity of an autostring. Ignoring memory considerations, you could simply
|
||||
use nsCString, appending the stringized version of each of your class's data members.
|
||||
This will probably result in calls to the heap manager.
|
||||
|
||||
But there's a way to do this without necessarily having to call the heap manager.
|
||||
All you do is declare a stack based buffer and instruct nsCString to use that instead
|
||||
of it's own internal buffer by using the CBufDescriptor class:
|
||||
|
||||
{
|
||||
char theBuffer[256];
|
||||
CBufDescritor theBufDecriptor( theBuffer, PR_TRUE, sizeof(theBuffer), 0);
|
||||
nsCAutoString s3( theBufDescriptor );
|
||||
s3="HELLO, my name is inigo montoya, you killed my father, prepare to die!.";
|
||||
}
|
||||
|
||||
The assignment statment to s3 will cause the given string to be written to your
|
||||
stack-based buffer via the normal nsString/nsCString interfaces. Cool, huh?
|
||||
Note however that just like any other nsStringXXX use, if you write more data
|
||||
than will fit in the buffer, a visit to the heap manager will be in order.
|
||||
|
||||
|
||||
**********************************************************************************/
|
||||
|
||||
|
||||
#ifndef _nsStr
|
||||
#define _nsStr
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include <string.h>
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
enum eCharSize {eOneByte=0,eTwoByte=1};
|
||||
#define kDefaultCharSize eTwoByte
|
||||
#define kRadix10 (10)
|
||||
#define kRadix16 (16)
|
||||
#define kAutoDetect (100)
|
||||
#define kRadixUnknown (kAutoDetect+1)
|
||||
const PRInt32 kDefaultStringSize = 64;
|
||||
const PRInt32 kNotFound = -1;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
class NS_COM CBufDescriptor {
|
||||
public:
|
||||
CBufDescriptor(char* aString, PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
|
||||
CBufDescriptor(const char* aString, PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
|
||||
CBufDescriptor(PRUnichar* aString, PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
|
||||
CBufDescriptor(const PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
|
||||
|
||||
char* mBuffer;
|
||||
eCharSize mCharSize;
|
||||
PRUint32 mCapacity;
|
||||
PRInt32 mLength;
|
||||
PRBool mStackBased;
|
||||
PRBool mIsConst;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
struct NS_COM nsStr {
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
nsStr() {
|
||||
MOZ_COUNT_CTOR(nsStr);
|
||||
}
|
||||
|
||||
~nsStr() {
|
||||
MOZ_COUNT_DTOR(nsStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes an nsStr for use
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aString is the nsStr to be initialized
|
||||
* @param aCharSize tells us the requested char size (1 or 2 bytes)
|
||||
*/
|
||||
static void Initialize(nsStr& aDest,eCharSize aCharSize);
|
||||
|
||||
/**
|
||||
* This method initializes an nsStr for use
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aString is the nsStr to be initialized
|
||||
* @param aCharSize tells us the requested char size (1 or 2 bytes)
|
||||
*/
|
||||
static void Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 aLength,eCharSize aCharSize,PRBool aOwnsBuffer);
|
||||
|
||||
/**
|
||||
* This method destroys the given nsStr, and *MAY*
|
||||
* deallocate it's memory depending on the setting
|
||||
* of the internal mOwnsBUffer flag.
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aString is the nsStr to be manipulated
|
||||
* @param anAgent is the allocator to be used to the nsStr
|
||||
*/
|
||||
static void Destroy(nsStr& aDest);
|
||||
|
||||
/**
|
||||
* These methods are where memory allocation/reallocation occur.
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aString is the nsStr to be manipulated
|
||||
* @param anAgent is the allocator to be used on the nsStr
|
||||
* @return
|
||||
*/
|
||||
static PRBool EnsureCapacity(nsStr& aString,PRUint32 aNewLength);
|
||||
static PRBool GrowCapacity(nsStr& aString,PRUint32 aNewLength);
|
||||
|
||||
/**
|
||||
* These methods are used to append content to the given nsStr
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be appended to
|
||||
* @param aSource is the buffer to be copied from
|
||||
* @param anOffset tells us where in source to start copying
|
||||
* @param aCount tells us the (max) # of chars to copy
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* These methods are used to assign contents of a source string to dest string
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be appended to
|
||||
* @param aSource is the buffer to be copied from
|
||||
* @param anOffset tells us where in source to start copying
|
||||
* @param aCount tells us the (max) # of chars to copy
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* These methods are used to insert content from source string to the dest nsStr
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be appended to
|
||||
* @param aDestOffset tells us where in dest to start insertion
|
||||
* @param aSource is the buffer to be copied from
|
||||
* @param aSrcOffset tells us where in source to start copying
|
||||
* @param aCount tells us the (max) # of chars to insert
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* This method deletes chars from the given str.
|
||||
* The given allocator may choose to resize the str as well.
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be deleted from
|
||||
* @param aDestOffset tells us where in dest to start deleting
|
||||
* @param aCount tells us the (max) # of chars to delete
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Delete(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount);
|
||||
|
||||
/**
|
||||
* This method is used to truncate the given string.
|
||||
* The given allocator may choose to resize the str as well (but it's not likely).
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be appended to
|
||||
* @param aDestOffset tells us where in dest to start insertion
|
||||
* @param aSource is the buffer to be copied from
|
||||
* @param aSrcOffset tells us where in source to start copying
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Truncate(nsStr& aDest,PRUint32 aDestOffset);
|
||||
|
||||
/**
|
||||
* This method is used to perform a case conversion on the given string
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be case shifted
|
||||
* @param toUpper tells us to go upper vs. lower
|
||||
*/
|
||||
static void ChangeCase(nsStr& aDest,PRBool aToUpper);
|
||||
|
||||
|
||||
/**
|
||||
* This method trims chars (given in aSet) from the edges of given buffer
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the buffer to be manipulated
|
||||
* @param aSet tells us which chars to remove from given buffer
|
||||
* @param aEliminateLeading tells us whether to strip chars from the start of the buffer
|
||||
* @param aEliminateTrailing tells us whether to strip chars from the start of the buffer
|
||||
*/
|
||||
static void Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing);
|
||||
|
||||
/**
|
||||
* This method compresses duplicate runs of a given char from the given buffer
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the buffer to be manipulated
|
||||
* @param aSet tells us which chars to compress from given buffer
|
||||
* @param aChar is the replacement char
|
||||
* @param aEliminateLeading tells us whether to strip chars from the start of the buffer
|
||||
* @param aEliminateTrailing tells us whether to strip chars from the start of the buffer
|
||||
*/
|
||||
static void CompressSet(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing);
|
||||
|
||||
/**
|
||||
* This method removes all occurances of chars in given set from aDest
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the buffer to be manipulated
|
||||
* @param aSet tells us which chars to compress from given buffer
|
||||
* @param aChar is the replacement char
|
||||
* @param aEliminateLeading tells us whether to strip chars from the start of the buffer
|
||||
* @param aEliminateTrailing tells us whether to strip chars from the start of the buffer
|
||||
*/
|
||||
static void StripChars(nsStr& aDest,const char* aSet);
|
||||
|
||||
/**
|
||||
* This method compares the data bewteen two nsStr's
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aStr1 is the first buffer to be compared
|
||||
* @param aStr2 is the 2nd buffer to be compared
|
||||
* @param aCount is the number of chars to compare
|
||||
* @param aIgnorecase tells us whether to use a case-sensitive comparison
|
||||
* @return -1,0,1 depending on <,==,>
|
||||
*/
|
||||
static PRInt32 Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase);
|
||||
|
||||
/**
|
||||
* These methods scan the given string for 1 or more chars in a given direction
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be searched to
|
||||
* @param aSource (or aChar) is the substr we're looking to find
|
||||
* @param aIgnoreCase tells us whether to search in a case-sensitive manner
|
||||
* @param anOffset tells us where in the dest string to start searching
|
||||
* @return the index of the source (substr) in dest, or -1 (kNotFound) if not found.
|
||||
*/
|
||||
static PRInt32 FindSubstr(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 FindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 FindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
|
||||
static PRInt32 RFindSubstr(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 RFindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
|
||||
|
||||
PRUint32 mLength;
|
||||
PRUint32 mCapacity;
|
||||
eCharSize mCharSize;
|
||||
PRBool mOwnsBuffer;
|
||||
|
||||
union {
|
||||
char* mStr;
|
||||
PRUnichar* mUStr;
|
||||
};
|
||||
|
||||
private:
|
||||
static PRBool Alloc(nsStr& aString,PRUint32 aCount);
|
||||
static PRBool Realloc(nsStr& aString,PRUint32 aCount);
|
||||
static PRBool Free(nsStr& aString);
|
||||
|
||||
};
|
||||
|
||||
/**************************************************************
|
||||
A couple of tiny helper methods used in the string classes.
|
||||
**************************************************************/
|
||||
|
||||
inline PRInt32 MinInt(PRInt32 anInt1,PRInt32 anInt2){
|
||||
return (anInt1<anInt2) ? anInt1 : anInt2;
|
||||
}
|
||||
|
||||
inline PRInt32 MaxInt(PRInt32 anInt1,PRInt32 anInt2){
|
||||
return (anInt1<anInt2) ? anInt2 : anInt1;
|
||||
}
|
||||
|
||||
inline void AddNullTerminator(nsStr& aDest) {
|
||||
if(eTwoByte==aDest.mCharSize)
|
||||
aDest.mUStr[aDest.mLength]=0;
|
||||
else aDest.mStr[aDest.mLength]=0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the given buffer to the heap manager. Calls allocator::Free()
|
||||
* @return string length
|
||||
*/
|
||||
inline void Recycle( char* aBuffer) { nsAllocator::Free(aBuffer); }
|
||||
inline void Recycle( PRUnichar* aBuffer) { nsAllocator::Free(aBuffer); }
|
||||
|
||||
/**
|
||||
* This method is used to access a given char in the given string
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be appended to
|
||||
* @param anIndex tells us where in dest to get the char from
|
||||
* @return the given char, or 0 if anIndex is out of range
|
||||
*/
|
||||
inline PRUnichar GetCharAt(const nsStr& aDest,PRUint32 anIndex){
|
||||
if(anIndex<aDest.mLength) {
|
||||
return (eTwoByte==aDest.mCharSize) ? aDest.mUStr[anIndex] : aDest.mStr[anIndex];
|
||||
}//if
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
1865
mozilla/string/obsolete/nsString.cpp
Normal file
1865
mozilla/string/obsolete/nsString.cpp
Normal file
File diff suppressed because it is too large
Load Diff
747
mozilla/string/obsolete/nsString.h
Normal file
747
mozilla/string/obsolete/nsString.h
Normal file
@@ -0,0 +1,747 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
MODULE NOTES:
|
||||
|
||||
See nsStr.h for a more general description of string classes.
|
||||
|
||||
This version of the nsString class offers many improvements over the
|
||||
original version:
|
||||
1. Wide and narrow chars
|
||||
2. Allocators
|
||||
3. Much smarter autostrings
|
||||
4. Subsumable strings
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
#ifndef _nsCString_
|
||||
#define _nsCString_
|
||||
|
||||
#include "nsString2.h"
|
||||
#include "prtypes.h"
|
||||
#include "nscore.h"
|
||||
#include <stdio.h>
|
||||
#include "nsStr.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
|
||||
class NS_COM nsSubsumeCStr;
|
||||
|
||||
class NS_COM nsCString : public nsStr {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
nsCString();
|
||||
|
||||
/**
|
||||
* This constructor accepts an isolatin string
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
*/
|
||||
nsCString(const char* aCString,PRInt32 aLength=-1);
|
||||
|
||||
/**
|
||||
* This constructor accepts a unichar string
|
||||
* @param aCString is a ptr to a 2-byte cstr
|
||||
*/
|
||||
nsCString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
|
||||
/**
|
||||
* This is a copy constructor that accepts an nsStr
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString(const nsStr&);
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString(const nsCString& aString);
|
||||
|
||||
/**
|
||||
* This constructor takes a subsumestr
|
||||
* @param reference to subsumestr
|
||||
*/
|
||||
nsCString(nsSubsumeCStr& aSubsumeStr);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*
|
||||
*/
|
||||
virtual ~nsCString();
|
||||
|
||||
/**
|
||||
* Retrieve the length of this string
|
||||
* @return string length
|
||||
*/
|
||||
inline PRInt32 Length() const { return (PRInt32)mLength; }
|
||||
|
||||
/**
|
||||
* Retrieve the size of this string
|
||||
* @return string length
|
||||
*/
|
||||
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
|
||||
|
||||
|
||||
/**
|
||||
* Call this method if you want to force a different string capacity
|
||||
* @update gess7/30/98
|
||||
* @param aLength -- contains new length for mStr
|
||||
* @return
|
||||
*/
|
||||
void SetLength(PRUint32 aLength) {
|
||||
Truncate(aLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new length of the string.
|
||||
* @param aLength is new string length.
|
||||
* @return nada
|
||||
*/
|
||||
void SetCapacity(PRUint32 aLength);
|
||||
/**
|
||||
* This method truncates this string to given length.
|
||||
*
|
||||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void Truncate(PRInt32 anIndex=0);
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether or not the characters in this
|
||||
* string are in sorted order.
|
||||
*
|
||||
* @return TRUE if ordered.
|
||||
*/
|
||||
PRBool IsOrdered(void) const;
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether or not this string has a length of 0
|
||||
*
|
||||
* @return TRUE if empty.
|
||||
*/
|
||||
PRBool IsEmpty(void) const {
|
||||
return PRBool(0==mLength);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Accessor methods...
|
||||
*********************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve const ptr to internal buffer; DO NOT TRY TO FREE IT!
|
||||
*/
|
||||
const char* GetBuffer(void) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get nth character.
|
||||
*/
|
||||
PRUnichar operator[](PRUint32 anIndex) const;
|
||||
PRUnichar CharAt(PRUint32 anIndex) const;
|
||||
PRUnichar First(void) const;
|
||||
PRUnichar Last(void) const;
|
||||
|
||||
PRBool SetCharAt(PRUnichar aChar,PRUint32 anIndex);
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
String creation methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Create a new string by appending given string to this
|
||||
* @param aString -- 2nd string to be appended
|
||||
* @return new string
|
||||
*/
|
||||
nsSubsumeCStr operator+(const nsCString& aString);
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given char*.
|
||||
* @param aCString is a ptr to cstring to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsSubsumeCStr operator+(const char* aCString);
|
||||
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given char.
|
||||
* @param aChar is a char to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsSubsumeCStr operator+(PRUnichar aChar);
|
||||
nsSubsumeCStr operator+(char aChar);
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
Lexomorphic transforms...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Converts chars in this to lowercase
|
||||
* @update gess 7/27/98
|
||||
*/
|
||||
void ToLowerCase();
|
||||
|
||||
|
||||
/**
|
||||
* Converts chars in this to lowercase, and
|
||||
* stores them in aOut
|
||||
* @update gess 7/27/98
|
||||
* @param aOut is a string to contain result
|
||||
*/
|
||||
void ToLowerCase(nsCString& aString) const;
|
||||
|
||||
/**
|
||||
* Converts chars in this to uppercase
|
||||
* @update gess 7/27/98
|
||||
*/
|
||||
void ToUpperCase();
|
||||
|
||||
/**
|
||||
* Converts chars in this to lowercase, and
|
||||
* stores them in a given output string
|
||||
* @update gess 7/27/98
|
||||
* @param aOut is a string to contain result
|
||||
*/
|
||||
void ToUpperCase(nsCString& aString) const;
|
||||
|
||||
|
||||
/**
|
||||
* This method is used to remove all occurances of the
|
||||
* characters found in aSet from this string.
|
||||
*
|
||||
* @param aSet -- characters to be cut from this
|
||||
* @return *this
|
||||
*/
|
||||
nsCString& StripChars(const char* aSet);
|
||||
nsCString& StripChar(char aChar);
|
||||
|
||||
/**
|
||||
* This method strips whitespace throughout the string
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsCString& StripWhitespace();
|
||||
|
||||
/**
|
||||
* swaps occurence of 1 string for another
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsCString& ReplaceChar(PRUnichar aOldChar,PRUnichar aNewChar);
|
||||
nsCString& ReplaceChar(const char* aSet,PRUnichar aNewChar);
|
||||
|
||||
PRInt32 CountChar(PRUnichar aChar);
|
||||
|
||||
/**
|
||||
* This method trims characters found in aTrimSet from
|
||||
* either end of the underlying string.
|
||||
*
|
||||
* @param aTrimSet -- contains chars to be trimmed from
|
||||
* both ends
|
||||
* @return this
|
||||
*/
|
||||
nsCString& Trim(const char* aSet,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
|
||||
/**
|
||||
* This method strips whitespace from string.
|
||||
* You can control whether whitespace is yanked from
|
||||
* start and end of string as well.
|
||||
*
|
||||
* @param aEliminateLeading controls stripping of leading ws
|
||||
* @param aEliminateTrailing controls stripping of trailing ws
|
||||
* @return this
|
||||
*/
|
||||
nsCString& CompressSet(const char* aSet, PRUnichar aChar,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
|
||||
/**
|
||||
* This method strips whitespace from string.
|
||||
* You can control whether whitespace is yanked from
|
||||
* start and end of string as well.
|
||||
*
|
||||
* @param aEliminateLeading controls stripping of leading ws
|
||||
* @param aEliminateTrailing controls stripping of trailing ws
|
||||
* @return this
|
||||
*/
|
||||
nsCString& CompressWhitespace( PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
|
||||
/**********************************************************************
|
||||
string conversion methods...
|
||||
*********************************************************************/
|
||||
|
||||
operator char*() {return mStr;}
|
||||
operator const char*() const {return (const char*)mStr;}
|
||||
|
||||
/**
|
||||
* This method constructs a new nsCString that is a clone
|
||||
* of this string.
|
||||
*
|
||||
*/
|
||||
nsCString* ToNewString() const;
|
||||
|
||||
/**
|
||||
* Creates an ISOLatin1 clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @return ptr to new isolatin1 string
|
||||
*/
|
||||
char* ToNewCString() const;
|
||||
|
||||
/**
|
||||
* Creates a unicode clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @return ptr to new unicode string
|
||||
*/
|
||||
PRUnichar* ToNewUnicode() const;
|
||||
|
||||
/**
|
||||
* Copies data from internal buffer onto given char* buffer
|
||||
* NOTE: This only copies as many chars as will fit in given buffer (clips)
|
||||
* @param aBuf is the buffer where data is stored
|
||||
* @param aBuflength is the max # of chars to move to buffer
|
||||
* @return ptr to given buffer
|
||||
*/
|
||||
char* ToCString(char* aBuf,PRUint32 aBufLength,PRUint32 anOffset=0) const;
|
||||
|
||||
/**
|
||||
* Perform string to float conversion.
|
||||
* @param aErrorCode will contain error if one occurs
|
||||
* @return float rep of string value
|
||||
*/
|
||||
float ToFloat(PRInt32* aErrorCode) const;
|
||||
|
||||
/**
|
||||
* Try to derive the radix from the value contained in this string
|
||||
* @return kRadix10, kRadix16 or kAutoDetect (meaning unknown)
|
||||
*/
|
||||
PRUint32 DetermineRadix(void);
|
||||
|
||||
/**
|
||||
* Perform string to int conversion.
|
||||
* @param aErrorCode will contain error if one occurs
|
||||
* @return int rep of string value
|
||||
*/
|
||||
PRInt32 ToInteger(PRInt32* aErrorCode,PRUint32 aRadix=kRadix10) const;
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
String manipulation methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Functionally equivalent to assign or operator=
|
||||
*
|
||||
*/
|
||||
nsCString& SetString(const char* aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
nsCString& SetString(const nsStr& aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
|
||||
/**
|
||||
* assign given string to this string
|
||||
* @param aStr: buffer to be assigned to this
|
||||
* @param alength is the length of the given str (or -1)
|
||||
if you want me to determine its length
|
||||
* @return this
|
||||
*/
|
||||
nsCString& Assign(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(const char* aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(PRUnichar aChar);
|
||||
nsCString& Assign(char aChar);
|
||||
|
||||
/**
|
||||
* here come a bunch of assignment operators...
|
||||
* @param aString: string to be added to this
|
||||
* @return this
|
||||
*/
|
||||
nsCString& operator=(const nsCString& aString) {return Assign(aString);}
|
||||
nsCString& operator=(const nsStr& aString) {return Assign(aString);}
|
||||
nsCString& operator=(PRUnichar aChar) {return Assign(aChar);}
|
||||
nsCString& operator=(char aChar) {return Assign(aChar);}
|
||||
nsCString& operator=(const char* aCString) {return Assign(aCString);}
|
||||
nsCString& operator=(const PRUnichar* aString) {return Assign(aString);}
|
||||
#ifdef AIX
|
||||
nsCString& operator=(const nsSubsumeCStr& aSubsumeString); // AIX requires a const here
|
||||
#else
|
||||
nsCString& operator=(nsSubsumeCStr& aSubsumeString);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsCString& operator+=(const nsCString& aString){return Append(aString,aString.mLength);}
|
||||
nsCString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsCString& operator+=(PRUnichar aChar){return Append(aChar);}
|
||||
nsCString& operator+=(char aChar){return Append(aChar);}
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
* This version computes the length of your given string
|
||||
*
|
||||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,aString.mLength);}
|
||||
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
*
|
||||
* @param aString is the source to be appended to this
|
||||
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsCString& Append(const nsCString& aString,PRInt32 aCount);
|
||||
nsCString& Append(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsCString& Append(const char* aString,PRInt32 aCount=-1);
|
||||
nsCString& Append(PRUnichar aChar);
|
||||
nsCString& Append(char aChar);
|
||||
nsCString& Append(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
|
||||
nsCString& Append(float aFloat);
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
* starting at the leftmost offset.
|
||||
*
|
||||
*
|
||||
* @param aCopy -- Receiving string
|
||||
* @param aCount -- number of chars to copy
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRUint32 Left(nsCString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
* starting at the given offset.
|
||||
*
|
||||
*
|
||||
* @param aCopy -- Receiving string
|
||||
* @param aCount -- number of chars to copy
|
||||
* @param anOffset -- position where copying begins
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRUint32 Mid(nsCString& aCopy,PRUint32 anOffset,PRInt32 aCount) const;
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
* starting at rightmost char.
|
||||
*
|
||||
*
|
||||
* @param aCopy -- Receiving string
|
||||
* @param aCount -- number of chars to copy
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRUint32 Right(nsCString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
*
|
||||
* @param aCopy -- String to be inserted into this
|
||||
* @param anOffset -- insertion position within this str
|
||||
* @param aCount -- number of chars to be copied from aCopy
|
||||
* @return number of chars inserted into this.
|
||||
*/
|
||||
nsCString& Insert(const nsCString& aCopy,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* Insert a given string into this string at
|
||||
* a specified offset.
|
||||
*
|
||||
* @param aString* to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
nsCString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* Insert a single char into this string at
|
||||
* a specified offset.
|
||||
*
|
||||
* @param character to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
nsCString& Insert(PRUnichar aChar,PRUint32 anOffset);
|
||||
nsCString& Insert(char aChar,PRUint32 anOffset);
|
||||
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
* starting at anOffset, continuing for aCount chars.
|
||||
*
|
||||
* @param anOffset -- start pos for cut operation
|
||||
* @param aCount -- number of chars to be cut
|
||||
* @return *this
|
||||
*/
|
||||
nsCString& Cut(PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
Searching methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Search for given character within this string.
|
||||
* This method does so by using a binary search,
|
||||
* so your string HAD BETTER BE ORDERED!
|
||||
*
|
||||
* @param aChar is the unicode char to be found
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 BinarySearch(PRUnichar aChar) const;
|
||||
|
||||
/**
|
||||
* Search for given substring within this string
|
||||
*
|
||||
* @param aString is substring to be sought in this
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 Find(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
/**
|
||||
* Search for given char within this string
|
||||
*
|
||||
* @param aString is substring to be sought in this
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 FindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the first character
|
||||
* found in the given charset
|
||||
* @param aString contains set of chars to be found
|
||||
* @param anOffset tells us where to start searching in this
|
||||
* @return -1 if not found, else the offset in this
|
||||
*/
|
||||
PRInt32 FindCharInSet(const char* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 FindCharInSet(const PRUnichar* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 FindCharInSet(const nsStr& aString,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
* This methods scans the string backwards, looking for the given string
|
||||
* @param aString is substring to be sought in this
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 RFind(const char* aCString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
* Search for given char within this string
|
||||
*
|
||||
* @param aString is substring to be sought in this
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 RFindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the last character
|
||||
* found in the given string
|
||||
* @param aString contains set of chars to be found
|
||||
* @param anOffset tells us where to start searching in this
|
||||
* @return -1 if not found, else the offset in this
|
||||
*/
|
||||
PRInt32 RFindCharInSet(const char* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFindCharInSet(const PRUnichar* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFindCharInSet(const nsStr& aString,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
Comparison methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Compares a given string type to this string.
|
||||
* @update gess 7/27/98
|
||||
* @param S is the string to be compared
|
||||
* @param aIgnoreCase tells us how to treat case
|
||||
* @param aCount tells us how many chars to compare
|
||||
* @return -1,0,1
|
||||
*/
|
||||
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
* These methods compare a given string type to this one
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator==(const nsStr &aString) const;
|
||||
PRBool operator==(const char* aString) const;
|
||||
PRBool operator==(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods perform a !compare of a given string type to this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE
|
||||
*/
|
||||
PRBool operator!=(const nsStr &aString) const;
|
||||
PRBool operator!=(const char* aString) const;
|
||||
PRBool operator!=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is < than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator<(const nsStr &aString) const;
|
||||
PRBool operator<(const char* aString) const;
|
||||
PRBool operator<(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is > than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator>(const nsStr &S) const;
|
||||
PRBool operator>(const char* aString) const;
|
||||
PRBool operator>(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is <= than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator<=(const nsStr &S) const;
|
||||
PRBool operator<=(const char* aString) const;
|
||||
PRBool operator<=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is >= than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator>=(const nsStr &S) const;
|
||||
PRBool operator>=(const char* aString) const;
|
||||
PRBool operator>=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* Compare this to given string; note that we compare full strings here.
|
||||
* The optional length argument just lets us know how long the given string is.
|
||||
* If you provide a length, it is compared to length of this string as an
|
||||
* optimization.
|
||||
*
|
||||
* @param aString -- the string to compare to this
|
||||
* @param aCount -- number of chars in given string you want to compare
|
||||
* @return TRUE if equal
|
||||
*/
|
||||
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
|
||||
PRBool EqualsIgnoreCase(const nsStr& aString) const;
|
||||
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
|
||||
PRBool EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aCount=-1) const;
|
||||
|
||||
|
||||
static void Recycle(nsCString* aString);
|
||||
static nsCString* CreateString(void);
|
||||
|
||||
};
|
||||
|
||||
extern NS_COM int fputs(const nsCString& aString, FILE* out);
|
||||
//ostream& operator<<(ostream& aStream,const nsCString& aString);
|
||||
//virtual void DebugDump(ostream& aStream) const;
|
||||
|
||||
|
||||
/**************************************************************
|
||||
Here comes the AutoString class which uses internal memory
|
||||
(typically found on the stack) for its default buffer.
|
||||
If the buffer needs to grow, it gets reallocated on the heap.
|
||||
**************************************************************/
|
||||
|
||||
class NS_COM nsCAutoString : public nsCString {
|
||||
public:
|
||||
|
||||
nsCAutoString();
|
||||
nsCAutoString(const char* aString,PRInt32 aLength=-1);
|
||||
nsCAutoString(const CBufDescriptor& aBuffer);
|
||||
nsCAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
nsCAutoString(const nsStr& aString);
|
||||
nsCAutoString(const nsCAutoString& aString);
|
||||
|
||||
#ifdef AIX
|
||||
nsCAutoString(const nsSubsumeCStr& aSubsumeStr); // AIX requires a const
|
||||
#else
|
||||
nsCAutoString(nsSubsumeCStr& aSubsumeStr);
|
||||
#endif // AIX
|
||||
nsCAutoString(PRUnichar aChar);
|
||||
virtual ~nsCAutoString();
|
||||
|
||||
nsCAutoString& operator=(const nsCString& aString) {nsCString::Assign(aString); return *this;}
|
||||
nsCAutoString& operator=(const char* aCString) {nsCString::Assign(aCString); return *this;}
|
||||
nsCAutoString& operator=(PRUnichar aChar) {nsCString::Assign(aChar); return *this;}
|
||||
nsCAutoString& operator=(char aChar) {nsCString::Assign(aChar); return *this;}
|
||||
|
||||
/**
|
||||
* Retrieve the size of this string
|
||||
* @return string length
|
||||
*/
|
||||
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
|
||||
|
||||
char mBuffer[kDefaultStringSize];
|
||||
};
|
||||
|
||||
|
||||
/***************************************************************
|
||||
The subsumestr class is very unusual.
|
||||
It differs from a normal string in that it doesn't use normal
|
||||
copy semantics when another string is assign to this.
|
||||
Instead, it "steals" the contents of the source string.
|
||||
|
||||
This is very handy for returning nsString classes as part of
|
||||
an operator+(...) for example, in that it cuts down the number
|
||||
of copy operations that must occur.
|
||||
|
||||
You should probably not use this class unless you really know
|
||||
what you're doing.
|
||||
***************************************************************/
|
||||
class NS_COM nsSubsumeCStr : public nsCString {
|
||||
public:
|
||||
nsSubsumeCStr(nsStr& aString);
|
||||
nsSubsumeCStr(PRUnichar* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
|
||||
nsSubsumeCStr(char* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
2233
mozilla/string/obsolete/nsString2.cpp
Normal file
2233
mozilla/string/obsolete/nsString2.cpp
Normal file
File diff suppressed because it is too large
Load Diff
840
mozilla/string/obsolete/nsString2.h
Normal file
840
mozilla/string/obsolete/nsString2.h
Normal file
@@ -0,0 +1,840 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
MODULE NOTES:
|
||||
|
||||
See nsStr.h for a more general description of string classes.
|
||||
|
||||
This version of the nsString class offers many improvements over the
|
||||
original version:
|
||||
1. Wide and narrow chars
|
||||
2. Allocators
|
||||
3. Much smarter autostrings
|
||||
4. Subsumable strings
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
#ifndef _nsString_
|
||||
#define _nsString_
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nscore.h"
|
||||
#include <stdio.h>
|
||||
#include "nsString.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsStr.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
class nsISizeOfHandler;
|
||||
|
||||
|
||||
#define nsString2 nsString
|
||||
#define nsAutoString2 nsAutoString
|
||||
|
||||
|
||||
class NS_COM nsSubsumeStr;
|
||||
class NS_COM nsString : public nsStr {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
nsString();
|
||||
|
||||
|
||||
/**
|
||||
* This constructor accepts an isolatin string
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
*/
|
||||
nsString(const char* aCString);
|
||||
|
||||
/**
|
||||
* This constructor accepts a unichar string
|
||||
* @param aCString is a ptr to a 2-byte cstr
|
||||
*/
|
||||
nsString(const PRUnichar* aString);
|
||||
|
||||
/**
|
||||
* This is a copy constructor that accepts an nsStr
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString(const nsStr&);
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString(const nsString& aString);
|
||||
|
||||
/**
|
||||
* This constructor takes a subsumestr
|
||||
* @param reference to subsumestr
|
||||
*/
|
||||
nsString(nsSubsumeStr& aSubsumeStr);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*
|
||||
*/
|
||||
virtual ~nsString();
|
||||
|
||||
/**
|
||||
* Retrieve the length of this string
|
||||
* @return string length
|
||||
*/
|
||||
inline PRInt32 Length() const { return (PRInt32)mLength; }
|
||||
|
||||
/**
|
||||
* Retrieve the size of this string
|
||||
* @return string length
|
||||
*/
|
||||
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
|
||||
|
||||
|
||||
/**
|
||||
* Call this method if you want to force a different string length
|
||||
* @update gess7/30/98
|
||||
* @param aLength -- contains new length for mStr
|
||||
* @return
|
||||
*/
|
||||
void SetLength(PRUint32 aLength) {
|
||||
Truncate(aLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new length of the string.
|
||||
* @param aLength is new string length.
|
||||
* @return nada
|
||||
*/
|
||||
void SetCapacity(PRUint32 aLength);
|
||||
|
||||
/**
|
||||
* This method truncates this string to given length.
|
||||
*
|
||||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void Truncate(PRInt32 anIndex=0);
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether or not the characters in this
|
||||
* string are in sorted order.
|
||||
*
|
||||
* @return TRUE if ordered.
|
||||
*/
|
||||
PRBool IsOrdered(void) const;
|
||||
|
||||
/**
|
||||
* Determine whether or not the characters in this
|
||||
* string are in store as 1 or 2 byte (unicode) strings.
|
||||
*
|
||||
* @return TRUE if ordered.
|
||||
*/
|
||||
PRBool IsUnicode(void) const {
|
||||
PRBool result=PRBool(mCharSize==eTwoByte);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether or not this string has a length of 0
|
||||
*
|
||||
* @return TRUE if empty.
|
||||
*/
|
||||
PRBool IsEmpty(void) const {
|
||||
return PRBool(0==mLength);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Getters/Setters...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Retrieve const ptr to internal buffer; DO NOT TRY TO FREE IT!
|
||||
*/
|
||||
const char* GetBuffer(void) const;
|
||||
const PRUnichar* GetUnicode(void) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get nth character.
|
||||
*/
|
||||
PRUnichar operator[](PRUint32 anIndex) const;
|
||||
PRUnichar CharAt(PRUint32 anIndex) const;
|
||||
PRUnichar First(void) const;
|
||||
PRUnichar Last(void) const;
|
||||
|
||||
/**
|
||||
* Set nth character.
|
||||
*/
|
||||
PRBool SetCharAt(PRUnichar aChar,PRUint32 anIndex);
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
String concatenation methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Create a new string by appending given string to this
|
||||
* @param aString -- 2nd string to be appended
|
||||
* @return new subsumable string
|
||||
*/
|
||||
nsSubsumeStr operator+(const nsStr& aString);
|
||||
nsSubsumeStr operator+(const nsString& aString);
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given cstring
|
||||
* @param aCString is a ptr to cstring to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsSubsumeStr operator+(const char* aCString);
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given prunichar*.
|
||||
* @param aString is a ptr to UC-string to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsSubsumeStr operator+(const PRUnichar* aString);
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given char.
|
||||
* @param aChar is a char to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsSubsumeStr operator+(char aChar);
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given char.
|
||||
* @param aChar is a unichar to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsSubsumeStr operator+(PRUnichar aChar);
|
||||
|
||||
/**********************************************************************
|
||||
Lexomorphic transforms...
|
||||
*********************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Converts chars in this to lowercase
|
||||
* @update gess 7/27/98
|
||||
*/
|
||||
void ToLowerCase();
|
||||
|
||||
|
||||
/**
|
||||
* Converts chars in this to lowercase, and
|
||||
* stores them in aOut
|
||||
* @update gess 7/27/98
|
||||
* @param aOut is a string to contain result
|
||||
*/
|
||||
void ToLowerCase(nsString& aString) const;
|
||||
|
||||
/**
|
||||
* Converts chars in this to uppercase
|
||||
* @update gess 7/27/98
|
||||
*/
|
||||
void ToUpperCase();
|
||||
|
||||
/**
|
||||
* Converts chars in this to lowercase, and
|
||||
* stores them in a given output string
|
||||
* @update gess 7/27/98
|
||||
* @param aOut is a string to contain result
|
||||
*/
|
||||
void ToUpperCase(nsString& aString) const;
|
||||
|
||||
|
||||
/**
|
||||
* This method is used to remove all occurances of the
|
||||
* characters found in aSet from this string.
|
||||
*
|
||||
* @param aSet -- characters to be cut from this
|
||||
* @return *this
|
||||
*/
|
||||
nsString& StripChars(const char* aSet);
|
||||
nsString& StripChar(char aChar);
|
||||
|
||||
/**
|
||||
* This method strips whitespace throughout the string
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& StripWhitespace();
|
||||
|
||||
/**
|
||||
* swaps occurence of 1 string for another
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& ReplaceChar(PRUnichar anOldChar,PRUnichar aNewChar);
|
||||
nsString& ReplaceChar(const char* aSet,PRUnichar aNewChar);
|
||||
|
||||
PRInt32 CountChar(PRUnichar aChar);
|
||||
|
||||
/**
|
||||
* This method trims characters found in aTrimSet from
|
||||
* either end of the underlying string.
|
||||
*
|
||||
* @param aTrimSet -- contains chars to be trimmed from
|
||||
* both ends
|
||||
* @return this
|
||||
*/
|
||||
nsString& Trim(const char* aSet,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
|
||||
/**
|
||||
* This method strips whitespace from string.
|
||||
* You can control whether whitespace is yanked from
|
||||
* start and end of string as well.
|
||||
*
|
||||
* @param aEliminateLeading controls stripping of leading ws
|
||||
* @param aEliminateTrailing controls stripping of trailing ws
|
||||
* @return this
|
||||
*/
|
||||
nsString& CompressSet(const char* aSet, PRUnichar aChar,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
|
||||
/**
|
||||
* This method strips whitespace from string.
|
||||
* You can control whether whitespace is yanked from
|
||||
* start and end of string as well.
|
||||
*
|
||||
* @param aEliminateLeading controls stripping of leading ws
|
||||
* @param aEliminateTrailing controls stripping of trailing ws
|
||||
* @return this
|
||||
*/
|
||||
nsString& CompressWhitespace( PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
|
||||
/**********************************************************************
|
||||
string conversion methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* This method constructs a new nsString is a clone of this string.
|
||||
*
|
||||
*/
|
||||
nsString* ToNewString() const;
|
||||
|
||||
/**
|
||||
* Creates an ISOLatin1 clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @return ptr to new isolatin1 string
|
||||
*/
|
||||
char* ToNewCString() const;
|
||||
|
||||
/**
|
||||
* Creates an UTF8 clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @return ptr to new isolatin1 string
|
||||
*/
|
||||
char* ToNewUTF8String() const;
|
||||
|
||||
/**
|
||||
* Creates a unicode clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @return ptr to new unicode string
|
||||
*/
|
||||
PRUnichar* ToNewUnicode() const;
|
||||
|
||||
/**
|
||||
* Copies data from internal buffer onto given char* buffer
|
||||
* NOTE: This only copies as many chars as will fit in given buffer (clips)
|
||||
* @param aBuf is the buffer where data is stored
|
||||
* @param aBuflength is the max # of chars to move to buffer
|
||||
* @return ptr to given buffer
|
||||
*/
|
||||
char* ToCString(char* aBuf,PRUint32 aBufLength,PRUint32 anOffset=0) const;
|
||||
|
||||
/**
|
||||
* Perform string to float conversion.
|
||||
* @param aErrorCode will contain error if one occurs
|
||||
* @return float rep of string value
|
||||
*/
|
||||
float ToFloat(PRInt32* aErrorCode) const;
|
||||
|
||||
/**
|
||||
* Try to derive the radix from the value contained in this string
|
||||
* @return kRadix10, kRadix16 or kAutoDetect (meaning unknown)
|
||||
*/
|
||||
PRUint32 DetermineRadix(void);
|
||||
|
||||
/**
|
||||
* Perform string to int conversion.
|
||||
* @param aErrorCode will contain error if one occurs
|
||||
* @return int rep of string value
|
||||
*/
|
||||
PRInt32 ToInteger(PRInt32* aErrorCode,PRUint32 aRadix=kRadix10) const;
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
String manipulation methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Functionally equivalent to assign or operator=
|
||||
*
|
||||
*/
|
||||
nsString& SetString(const char* aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
nsString& SetString(const PRUnichar* aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
nsString& SetString(const nsString& aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
|
||||
/**
|
||||
* assign given string to this string
|
||||
* @param aStr: buffer to be assigned to this
|
||||
* @param alength is the length of the given str (or -1)
|
||||
if you want me to determine its length
|
||||
* @return this
|
||||
*/
|
||||
nsString& Assign(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsString& Assign(const char* aString,PRInt32 aCount=-1);
|
||||
nsString& Assign(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
nsString& Assign(char aChar);
|
||||
nsString& Assign(PRUnichar aChar);
|
||||
|
||||
/**
|
||||
* here come a bunch of assignment operators...
|
||||
* @param aString: string to be added to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& operator=(const nsString& aString) {return Assign(aString);}
|
||||
nsString& operator=(const nsStr& aString) {return Assign(aString);}
|
||||
nsString& operator=(char aChar) {return Assign(aChar);}
|
||||
nsString& operator=(PRUnichar aChar) {return Assign(aChar);}
|
||||
nsString& operator=(const char* aCString) {return Assign(aCString);}
|
||||
nsString& operator=(const PRUnichar* aString) {return Assign(aString);}
|
||||
#ifdef AIX
|
||||
nsString& operator=(const nsSubsumeStr& aSubsumeString); // AIX requires a const here
|
||||
#else
|
||||
nsString& operator=(nsSubsumeStr& aSubsumeString);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsString& operator+=(const nsStr& aString){return Append(aString,aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString){return Append(aString,aString.mLength);}
|
||||
nsString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
//nsString& operator+=(char aChar){return Append(aChar);}
|
||||
nsString& operator+=(const PRUnichar* aUCString) {return Append(aUCString);}
|
||||
nsString& operator+=(PRUnichar aChar){return Append(aChar);}
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
* This version computes the length of your given string
|
||||
*
|
||||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,aString.mLength);}
|
||||
nsString& Append(const nsString& aString) {return Append(aString,aString.mLength);}
|
||||
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
*
|
||||
* @param aString is the source to be appended to this
|
||||
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsString& Append(const nsStr& aString,PRInt32 aCount);
|
||||
nsString& Append(const nsString& aString,PRInt32 aCount);
|
||||
nsString& Append(const char* aString,PRInt32 aCount=-1);
|
||||
nsString& Append(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
nsString& Append(char aChar);
|
||||
nsString& Append(PRUnichar aChar);
|
||||
nsString& Append(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
|
||||
nsString& Append(float aFloat);
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
* starting at the leftmost offset.
|
||||
*
|
||||
*
|
||||
* @param aCopy -- Receiving string
|
||||
* @param aCount -- number of chars to copy
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRUint32 Left(nsString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
* starting at the given offset.
|
||||
*
|
||||
*
|
||||
* @param aCopy -- Receiving string
|
||||
* @param aCount -- number of chars to copy
|
||||
* @param anOffset -- position where copying begins
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRUint32 Mid(nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) const;
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
* starting at rightmost char.
|
||||
*
|
||||
*
|
||||
* @param aCopy -- Receiving string
|
||||
* @param aCount -- number of chars to copy
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRUint32 Right(nsString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
*
|
||||
* @param aCopy -- String to be inserted into this
|
||||
* @param anOffset -- insertion position within this str
|
||||
* @param aCount -- number of chars to be copied from aCopy
|
||||
* @return number of chars inserted into this.
|
||||
*/
|
||||
nsString& Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* Insert a given string into this string at
|
||||
* a specified offset.
|
||||
*
|
||||
* @param aString* to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
nsString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
nsString& Insert(const PRUnichar* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* Insert a single char into this string at
|
||||
* a specified offset.
|
||||
*
|
||||
* @param character to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
//nsString& Insert(char aChar,PRUint32 anOffset);
|
||||
nsString& Insert(PRUnichar aChar,PRUint32 anOffset);
|
||||
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
* starting at anOffset, continuing for aCount chars.
|
||||
*
|
||||
* @param anOffset -- start pos for cut operation
|
||||
* @param aCount -- number of chars to be cut
|
||||
* @return *this
|
||||
*/
|
||||
nsString& Cut(PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
Searching methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Search for given character within this string.
|
||||
* This method does so by using a binary search,
|
||||
* so your string HAD BETTER BE ORDERED!
|
||||
*
|
||||
* @param aChar is the unicode char to be found
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 BinarySearch(PRUnichar aChar) const;
|
||||
|
||||
/**
|
||||
* Search for given substring within this string
|
||||
*
|
||||
* @param aString is substring to be sought in this
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 Find(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
* Search for given char within this string
|
||||
*
|
||||
* @param aString is substring to be sought in this
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
//PRInt32 Find(PRUnichar aChar,PRInt32 offset=-1,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
PRInt32 FindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the first character
|
||||
* found in the given charset
|
||||
* @param aString contains set of chars to be found
|
||||
* @param anOffset tells us where to start searching in this
|
||||
* @return -1 if not found, else the offset in this
|
||||
*/
|
||||
PRInt32 FindCharInSet(const char* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 FindCharInSet(const PRUnichar* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 FindCharInSet(const nsStr& aString,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
* This methods scans the string backwards, looking for the given string
|
||||
* @param aString is substring to be sought in this
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this strig to start searching (counting from left)
|
||||
*/
|
||||
PRInt32 RFind(const char* aCString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
* Search for given char within this string
|
||||
*
|
||||
* @param aString is substring to be sought in this
|
||||
* @param anOffset tells us where in this strig to start searching (counting from left)
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
//PRInt32 RFind(PRUnichar aChar,PRInt32 offset=-1,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
PRInt32 RFindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the last character
|
||||
* found in the given string
|
||||
* @param aString contains set of chars to be found
|
||||
* @param anOffset tells us where in this strig to start searching (counting from left)
|
||||
* @return -1 if not found, else the offset in this
|
||||
*/
|
||||
PRInt32 RFindCharInSet(const char* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFindCharInSet(const PRUnichar* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFindCharInSet(const nsStr& aString,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
Comparison methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Compares a given string type to this string.
|
||||
* @update gess 7/27/98
|
||||
* @param S is the string to be compared
|
||||
* @param aIgnoreCase tells us how to treat case
|
||||
* @param aCount tells us how many chars to compare
|
||||
* @return -1,0,1
|
||||
*/
|
||||
virtual PRInt32 Compare(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
* These methods compare a given string type to this one
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator==(const nsString &aString) const;
|
||||
PRBool operator==(const nsStr &aString) const;
|
||||
PRBool operator==(const char *aString) const;
|
||||
PRBool operator==(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods perform a !compare of a given string type to this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE
|
||||
*/
|
||||
PRBool operator!=(const nsString &aString) const;
|
||||
PRBool operator!=(const nsStr &aString) const;
|
||||
PRBool operator!=(const char* aString) const;
|
||||
PRBool operator!=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is < than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator<(const nsString &aString) const;
|
||||
PRBool operator<(const nsStr &aString) const;
|
||||
PRBool operator<(const char* aString) const;
|
||||
PRBool operator<(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is > than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator>(const nsString &aString) const;
|
||||
PRBool operator>(const nsStr &S) const;
|
||||
PRBool operator>(const char* aString) const;
|
||||
PRBool operator>(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is <= than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator<=(const nsString &aString) const;
|
||||
PRBool operator<=(const nsStr &S) const;
|
||||
PRBool operator<=(const char* aString) const;
|
||||
PRBool operator<=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is >= than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator>=(const nsString &aString) const;
|
||||
PRBool operator>=(const nsStr &S) const;
|
||||
PRBool operator>=(const char* aString) const;
|
||||
PRBool operator>=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* Compare this to given string; note that we compare full strings here.
|
||||
* The optional length argument just lets us know how long the given string is.
|
||||
* If you provide a length, it is compared to length of this string as an
|
||||
* optimization.
|
||||
*
|
||||
* @param aString -- the string to compare to this
|
||||
* @param aCount -- number of chars to be compared.
|
||||
* @return TRUE if equal
|
||||
*/
|
||||
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(/*FIX: const */nsIAtom* anAtom,PRBool aIgnoreCase) const;
|
||||
PRBool Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
|
||||
PRBool EqualsIgnoreCase(const nsString& aString) const;
|
||||
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
|
||||
PRBool EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const;
|
||||
PRBool EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const;
|
||||
|
||||
/**
|
||||
* Determine if given buffer is plain ascii
|
||||
*
|
||||
* @param aBuffer -- if null, then we test *this, otherwise we test given buffer
|
||||
* @return TRUE if is all ascii chars or if strlen==0
|
||||
*/
|
||||
PRBool IsASCII(const PRUnichar* aBuffer=0);
|
||||
|
||||
|
||||
/**
|
||||
* Determine if given char is a valid space character
|
||||
*
|
||||
* @param aChar is character to be tested
|
||||
* @return TRUE if is valid space char
|
||||
*/
|
||||
static PRBool IsSpace(PRUnichar ch);
|
||||
|
||||
/**
|
||||
* Determine if given char in valid alpha range
|
||||
*
|
||||
* @param aChar is character to be tested
|
||||
* @return TRUE if in alpha range
|
||||
*/
|
||||
static PRBool IsAlpha(PRUnichar ch);
|
||||
|
||||
/**
|
||||
* Determine if given char is valid digit
|
||||
*
|
||||
* @param aChar is character to be tested
|
||||
* @return TRUE if char is a valid digit
|
||||
*/
|
||||
static PRBool IsDigit(PRUnichar ch);
|
||||
|
||||
static void Recycle(nsString* aString);
|
||||
static nsString* CreateString(void);
|
||||
|
||||
};
|
||||
|
||||
extern NS_COM int fputs(const nsString& aString, FILE* out);
|
||||
//ostream& operator<<(ostream& aStream,const nsString& aString);
|
||||
//virtual void DebugDump(ostream& aStream) const;
|
||||
|
||||
|
||||
/**************************************************************
|
||||
Here comes the AutoString class which uses internal memory
|
||||
(typically found on the stack) for its default buffer.
|
||||
If the buffer needs to grow, it gets reallocated on the heap.
|
||||
**************************************************************/
|
||||
|
||||
class NS_COM nsAutoString : public nsString {
|
||||
public:
|
||||
|
||||
nsAutoString();
|
||||
nsAutoString(const char* aCString,PRInt32 aLength=-1);
|
||||
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
|
||||
nsAutoString(const CBufDescriptor& aBuffer);
|
||||
nsAutoString(const nsStr& aString);
|
||||
nsAutoString(const nsAutoString& aString);
|
||||
#ifdef AIX
|
||||
nsAutoString(const nsSubsumeStr& aSubsumeStr); // AIX requires a const
|
||||
#else
|
||||
nsAutoString(nsSubsumeStr& aSubsumeStr);
|
||||
#endif // AIX
|
||||
nsAutoString(PRUnichar aChar);
|
||||
virtual ~nsAutoString();
|
||||
|
||||
nsAutoString& operator=(const nsStr& aString) {nsString::Assign(aString); return *this;}
|
||||
nsAutoString& operator=(const nsAutoString& aString) {nsString::Assign(aString); return *this;}
|
||||
nsAutoString& operator=(const char* aCString) {nsString::Assign(aCString); return *this;}
|
||||
nsAutoString& operator=(char aChar) {nsString::Assign(aChar); return *this;}
|
||||
nsAutoString& operator=(const PRUnichar* aBuffer) {nsString::Assign(aBuffer); return *this;}
|
||||
nsAutoString& operator=(PRUnichar aChar) {nsString::Assign(aChar); return *this;}
|
||||
|
||||
/**
|
||||
* Retrieve the size of this string
|
||||
* @return string length
|
||||
*/
|
||||
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
|
||||
|
||||
char mBuffer[kDefaultStringSize<<eTwoByte];
|
||||
};
|
||||
|
||||
|
||||
|
||||
/***************************************************************
|
||||
The subsumestr class is very unusual.
|
||||
It differs from a normal string in that it doesn't use normal
|
||||
copy semantics when another string is assign to this.
|
||||
Instead, it "steals" the contents of the source string.
|
||||
|
||||
This is very handy for returning nsString classes as part of
|
||||
an operator+(...) for example, in that it cuts down the number
|
||||
of copy operations that must occur.
|
||||
|
||||
You should probably not use this class unless you really know
|
||||
what you're doing.
|
||||
***************************************************************/
|
||||
class NS_COM nsSubsumeStr : public nsString {
|
||||
public:
|
||||
nsSubsumeStr(nsStr& aString);
|
||||
nsSubsumeStr(PRUnichar* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
|
||||
nsSubsumeStr(char* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
179
mozilla/string/obsolete/nsXPIDLString.cpp
Normal file
179
mozilla/string/obsolete/nsXPIDLString.cpp
Normal file
@@ -0,0 +1,179 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsDebug.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "plstr.h"
|
||||
|
||||
// If the allocator changes, fix it here.
|
||||
#define XPIDL_STRING_ALLOC(__len) ((PRUnichar*) nsAllocator::Alloc((__len) * sizeof(PRUnichar)))
|
||||
#define XPIDL_CSTRING_ALLOC(__len) ((char*) nsAllocator::Alloc((__len) * sizeof(char)))
|
||||
#define XPIDL_FREE(__ptr) (nsAllocator::Free(__ptr))
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsXPIDLString
|
||||
|
||||
nsXPIDLString::nsXPIDLString()
|
||||
: mBuf(0),
|
||||
mBufOwner(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsXPIDLString::~nsXPIDLString()
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
}
|
||||
|
||||
|
||||
nsXPIDLString::operator const PRUnichar*()
|
||||
{
|
||||
return mBuf;
|
||||
}
|
||||
|
||||
|
||||
PRUnichar*
|
||||
nsXPIDLString::Copy(const PRUnichar* aString)
|
||||
{
|
||||
NS_ASSERTION(aString, "null ptr");
|
||||
if (! aString)
|
||||
return 0;
|
||||
|
||||
PRInt32 len = 0;
|
||||
|
||||
{
|
||||
const PRUnichar* p = aString;
|
||||
while (*p++)
|
||||
len++;
|
||||
}
|
||||
|
||||
PRUnichar* result = XPIDL_STRING_ALLOC(len + 1);
|
||||
if (result) {
|
||||
PRUnichar* q = result;
|
||||
while (*aString) {
|
||||
*q = *aString;
|
||||
q++;
|
||||
aString++;
|
||||
}
|
||||
*q = '\0';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
PRUnichar**
|
||||
nsXPIDLString::StartAssignmentByValue()
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
|
||||
mBuf = 0;
|
||||
mBufOwner = PR_TRUE;
|
||||
return &mBuf;
|
||||
}
|
||||
|
||||
|
||||
const PRUnichar**
|
||||
nsXPIDLString::StartAssignmentByReference()
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
|
||||
mBuf = 0;
|
||||
mBufOwner = PR_FALSE;
|
||||
return (const PRUnichar**) &mBuf;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsXPIDLCString
|
||||
|
||||
nsXPIDLCString::nsXPIDLCString()
|
||||
: mBuf(0),
|
||||
mBufOwner(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsXPIDLCString::~nsXPIDLCString()
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
}
|
||||
|
||||
|
||||
nsXPIDLCString& nsXPIDLCString::operator =(const char* aCString)
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
|
||||
mBuf = Copy(aCString);
|
||||
mBufOwner = PR_TRUE;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
nsXPIDLCString::operator const char*()
|
||||
{
|
||||
return mBuf;
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
nsXPIDLCString::Copy(const char* aCString)
|
||||
{
|
||||
NS_ASSERTION(aCString, "null ptr");
|
||||
if (! aCString)
|
||||
return 0;
|
||||
|
||||
PRInt32 len = PL_strlen(aCString);
|
||||
char* result = XPIDL_CSTRING_ALLOC(len + 1);
|
||||
if (result)
|
||||
PL_strcpy(result, aCString);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
char**
|
||||
nsXPIDLCString::StartAssignmentByValue()
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
|
||||
mBuf = 0;
|
||||
mBufOwner = PR_TRUE;
|
||||
return &mBuf;
|
||||
}
|
||||
|
||||
|
||||
const char**
|
||||
nsXPIDLCString::StartAssignmentByReference()
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
|
||||
mBuf = 0;
|
||||
mBufOwner = PR_FALSE;
|
||||
return (const char**) &mBuf;
|
||||
}
|
||||
|
||||
|
||||
302
mozilla/string/obsolete/nsXPIDLString.h
Normal file
302
mozilla/string/obsolete/nsXPIDLString.h
Normal file
@@ -0,0 +1,302 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A set of string wrapper classes that ease transition to use of XPIDL
|
||||
interfaces. nsXPIDLString and nsXPIDLCString are to XPIDL `wstring'
|
||||
and `string' out params as nsCOMPtr is to generic XPCOM interface
|
||||
pointers. They help you deal with object ownership.
|
||||
|
||||
Consider the following interface:
|
||||
|
||||
interface nsIFoo {
|
||||
attribute string Bar;
|
||||
};
|
||||
|
||||
This will generate the following C++ header file:
|
||||
|
||||
class nsIFoo {
|
||||
NS_IMETHOD SetBar(const PRUnichar* aValue);
|
||||
NS_IMETHOD GetBar(PRUnichar* *aValue);
|
||||
};
|
||||
|
||||
The GetBar() method will allocate a copy of the nsIFoo object's
|
||||
"bar" attribute, and leave you to deal with freeing it:
|
||||
|
||||
nsIFoo* aFoo; // assume we get this somehow
|
||||
PRUnichar* bar;
|
||||
aFoo->GetFoo(&bar);
|
||||
// Use bar here...
|
||||
printf("bar is %s!\n", bar);
|
||||
nsAllocator::Free(bar);
|
||||
|
||||
This makes your life harder, because you need to convolute your code
|
||||
to ensure that you don't leak `bar'.
|
||||
|
||||
Enter nsXPIDLString, which manages the ownership of the allocated
|
||||
string, and automatically destroys it when the nsXPIDLString goes
|
||||
out of scope:
|
||||
|
||||
nsIFoo* aFoo;
|
||||
nsXPIDLString bar;
|
||||
aFoo->GetFoo( getter_Copies(bar) );
|
||||
// Use bar here...
|
||||
printf("bar is %s!\n", (const char*) bar);
|
||||
// no need to remember to nsAllocator::Free().
|
||||
|
||||
Like nsCOMPtr, nsXPIDLString uses some syntactic sugar to make it
|
||||
painfully clear exactly what the code expects. You need to wrap an
|
||||
nsXPIDLString object with either `getter_Copies()' or
|
||||
`getter_Shares()' before passing it to a getter: these tell the
|
||||
nsXPIDLString how ownership is being handled.
|
||||
|
||||
In the case of `getter_Copies()', the callee is allocating a copy
|
||||
(which is usually the case). In the case of `getter_Shares()', the
|
||||
callee is returning a const reference to `the real deal' (this can
|
||||
be done using the [shared] attribute in XPIDL).
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsXPIDLString_h__
|
||||
#define nsXPIDLString_h__
|
||||
|
||||
#include "nsCom.h"
|
||||
#include "prtypes.h"
|
||||
|
||||
#ifndef __PRUNICHAR__
|
||||
#define __PRUNICHAR__
|
||||
typedef PRUint16 PRUnichar;
|
||||
#endif /* __PRUNICHAR__ */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsXPIDLString
|
||||
//
|
||||
// A wrapper for Unicode strings. With the |getter_Copies()| and
|
||||
// |getter_Shares()| helper functions, this can be used instead of
|
||||
// the "naked" |PRUnichar*| interface for |wstring| parameters in
|
||||
// XPIDL interfaces.
|
||||
//
|
||||
|
||||
class NS_COM nsXPIDLString {
|
||||
private:
|
||||
PRUnichar* mBuf;
|
||||
PRBool mBufOwner;
|
||||
|
||||
PRUnichar** StartAssignmentByValue();
|
||||
const PRUnichar** StartAssignmentByReference();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Construct a new, uninitialized wrapper for a Unicode string.
|
||||
*/
|
||||
nsXPIDLString();
|
||||
|
||||
virtual ~nsXPIDLString();
|
||||
|
||||
/**
|
||||
* Return a reference to the immutable Unicode string.
|
||||
*/
|
||||
operator const PRUnichar*();
|
||||
|
||||
/**
|
||||
* Make a copy of the Unicode string. Use this function in the
|
||||
* callee to ensure that the correct memory allocator is used.
|
||||
*/
|
||||
static PRUnichar* Copy(const PRUnichar* aString);
|
||||
|
||||
// A helper class for assignment-by-value. This class is an
|
||||
// implementation detail and should not be considered part of the
|
||||
// public interface.
|
||||
class NS_COM GetterCopies {
|
||||
private:
|
||||
nsXPIDLString& mXPIDLString;
|
||||
|
||||
public:
|
||||
GetterCopies(nsXPIDLString& aXPIDLString)
|
||||
: mXPIDLString(aXPIDLString) {}
|
||||
|
||||
operator PRUnichar**() {
|
||||
return mXPIDLString.StartAssignmentByValue();
|
||||
}
|
||||
|
||||
friend GetterCopies getter_Copies(nsXPIDLString& aXPIDLString);
|
||||
};
|
||||
|
||||
friend class GetterCopies;
|
||||
|
||||
// A helper class for assignment-by-reference. This class is an
|
||||
// implementation detail and should not be considered part of the
|
||||
// public interface.
|
||||
class NS_COM GetterShares {
|
||||
private:
|
||||
nsXPIDLString& mXPIDLString;
|
||||
|
||||
public:
|
||||
GetterShares(nsXPIDLString& aXPIDLString)
|
||||
: mXPIDLString(aXPIDLString) {}
|
||||
|
||||
operator const PRUnichar**() {
|
||||
return mXPIDLString.StartAssignmentByReference();
|
||||
}
|
||||
|
||||
friend GetterShares getter_Shares(nsXPIDLString& aXPIDLString);
|
||||
};
|
||||
|
||||
friend class GetterShares;
|
||||
|
||||
private:
|
||||
// not to be implemented
|
||||
nsXPIDLString(nsXPIDLString& /* aXPIDLString */) {}
|
||||
nsXPIDLString& operator =(nsXPIDLString& /* aXPIDLString */) { return *this; }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Use this function to "wrap" the nsXPIDLString object that is to
|
||||
* receive an |out| value.
|
||||
*/
|
||||
inline nsXPIDLString::GetterCopies
|
||||
getter_Copies(nsXPIDLString& aXPIDLString)
|
||||
{
|
||||
return nsXPIDLString::GetterCopies(aXPIDLString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this function to "wrap" the nsXPIDLString object that is to
|
||||
* receive a |[shared] out| value.
|
||||
*/
|
||||
inline nsXPIDLString::GetterShares
|
||||
getter_Shares(nsXPIDLString& aXPIDLString)
|
||||
{
|
||||
return nsXPIDLString::GetterShares(aXPIDLString);
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsXPIDLCString
|
||||
//
|
||||
// A wrapper for Unicode strings. With the |getter_Copies()| and
|
||||
// |getter_Shares()| helper functions, this can be used instead of
|
||||
// the "naked" |char*| interface for |string| parameters in XPIDL
|
||||
// interfaces.
|
||||
//
|
||||
|
||||
class NS_COM nsXPIDLCString {
|
||||
private:
|
||||
char* mBuf;
|
||||
PRBool mBufOwner;
|
||||
|
||||
char** StartAssignmentByValue();
|
||||
const char** StartAssignmentByReference();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Construct a new, uninitialized wrapper for a single-byte string.
|
||||
*/
|
||||
nsXPIDLCString();
|
||||
|
||||
virtual ~nsXPIDLCString();
|
||||
|
||||
/**
|
||||
* Assign a single-byte string to this wrapper. Copies and owns the result.
|
||||
*/
|
||||
nsXPIDLCString& operator =(const char* aString);
|
||||
|
||||
/**
|
||||
* Return a reference to the immutable single-byte string.
|
||||
*/
|
||||
operator const char*();
|
||||
|
||||
/**
|
||||
* Make a copy of the single-byte string. Use this function in the
|
||||
* callee to ensure that the correct memory allocator is used.
|
||||
*/
|
||||
static char* Copy(const char* aString);
|
||||
|
||||
// A helper class for assignment-by-value. This class is an
|
||||
// implementation detail and should not be considered part of the
|
||||
// public interface.
|
||||
class NS_COM GetterCopies {
|
||||
private:
|
||||
nsXPIDLCString& mXPIDLString;
|
||||
|
||||
public:
|
||||
GetterCopies(nsXPIDLCString& aXPIDLString)
|
||||
: mXPIDLString(aXPIDLString) {}
|
||||
|
||||
operator char**() {
|
||||
return mXPIDLString.StartAssignmentByValue();
|
||||
}
|
||||
|
||||
friend GetterCopies getter_Copies(nsXPIDLCString& aXPIDLString);
|
||||
};
|
||||
|
||||
friend class GetterCopies;
|
||||
|
||||
// A helper class for assignment-by-reference. This class is an
|
||||
// implementation detail and should not be considered part of the
|
||||
// public interface.
|
||||
class NS_COM GetterShares {
|
||||
private:
|
||||
nsXPIDLCString& mXPIDLString;
|
||||
|
||||
public:
|
||||
GetterShares(nsXPIDLCString& aXPIDLString)
|
||||
: mXPIDLString(aXPIDLString) {}
|
||||
|
||||
operator const char**() {
|
||||
return mXPIDLString.StartAssignmentByReference();
|
||||
}
|
||||
|
||||
friend GetterShares getter_Shares(nsXPIDLCString& aXPIDLString);
|
||||
};
|
||||
|
||||
friend class GetterShares;
|
||||
|
||||
private:
|
||||
// not to be implemented
|
||||
nsXPIDLCString(nsXPIDLCString& /* aXPIDLString */) {}
|
||||
nsXPIDLCString& operator =(nsXPIDLCString& /* aXPIDLCString */) { return *this; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Use this function to "wrap" the nsXPIDLCString object that is to
|
||||
* receive an |out| value.
|
||||
*/
|
||||
inline nsXPIDLCString::GetterCopies
|
||||
getter_Copies(nsXPIDLCString& aXPIDLString)
|
||||
{
|
||||
return nsXPIDLCString::GetterCopies(aXPIDLString);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Use this function to "wrap" the nsXPIDLCString object that is to
|
||||
* receive a |[shared] out| value.
|
||||
*/
|
||||
inline nsXPIDLCString::GetterShares
|
||||
getter_Shares(nsXPIDLCString& aXPIDLString)
|
||||
{
|
||||
return nsXPIDLCString::GetterShares(aXPIDLString);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // nsXPIDLString_h__
|
||||
@@ -1,28 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
rem -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
rem
|
||||
rem The contents of this file are subject to the Netscape Public License
|
||||
rem Version 1.0 (the "NPL"); you may not use this file except in
|
||||
rem compliance with the NPL. You may obtain a copy of the NPL at
|
||||
rem http://www.mozilla.org/NPL/
|
||||
rem
|
||||
rem Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
rem WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
rem for the specific language governing rights and limitations under the
|
||||
rem NPL.
|
||||
rem
|
||||
rem The Initial Developer of this code under the NPL is Netscape
|
||||
rem Communications Corporation. Portions created by Netscape are
|
||||
rem Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
rem Reserved.
|
||||
rem
|
||||
|
||||
del s:\ns\raptor\ui\src\windows\win32_d.obj\%1.obj
|
||||
del s:\ns\raptor\ui\tests\windows\win32_d.obj\winmain.obj
|
||||
nmake -f makefile.win
|
||||
@@ -1,11 +0,0 @@
|
||||
//
|
||||
// Widget.Prefix
|
||||
//
|
||||
// Global prefix file for the Widget project.
|
||||
//
|
||||
|
||||
#include "MacPrefix.h"
|
||||
|
||||
#include <Quickdraw.h>
|
||||
#include <Events.h>
|
||||
#include <MacWindows.h>
|
||||
@@ -1,11 +0,0 @@
|
||||
//
|
||||
// WidgetDebug.Prefix
|
||||
//
|
||||
// Global prefix file for the debug Widget project.
|
||||
//
|
||||
|
||||
#include "MacPrefix_debug.h"
|
||||
|
||||
#include <Quickdraw.h>
|
||||
#include <Events.h>
|
||||
#include <MacWindows.h>
|
||||
@@ -1,22 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#define MAC_SHARED 1
|
||||
#define _IMPL_NS_WIDGET 1
|
||||
|
||||
#include "WidgetDebug.prefix"
|
||||
@@ -1,22 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#define MAC_SHARED 1
|
||||
#define _IMPL_NS_WIDGET 1
|
||||
|
||||
#include "Widget.prefix"
|
||||
@@ -1,21 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#define MAC_STATIC 1
|
||||
|
||||
#include "WidgetDebug.prefix"
|
||||
@@ -1,21 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#define MAC_STATIC 1
|
||||
|
||||
#include "Widget.prefix"
|
||||
Binary file not shown.
@@ -1,35 +0,0 @@
|
||||
# target: widgetDebug.shlb
|
||||
mozilla/widget/src/mac/nsAppShell.cpp
|
||||
mozilla/widget/src/mac/nsButton.cpp
|
||||
mozilla/widget/src/mac/nsCheckButton.cpp
|
||||
mozilla/widget/src/mac/nsFileWidget.cpp
|
||||
mozilla/widget/src/mac/nsLookAndFeel.cpp
|
||||
mozilla/widget/src/mac/nsMacControl.cpp
|
||||
mozilla/widget/src/mac/nsMacEventHandler.cpp
|
||||
mozilla/widget/src/mac/nsMacMessagePump.cpp
|
||||
mozilla/widget/src/mac/nsMacMessageSink.cpp
|
||||
mozilla/widget/src/mac/nsMacWindow.cpp
|
||||
mozilla/widget/src/mac/nsMenu.cpp
|
||||
mozilla/widget/src/mac/nsMenuBar.cpp
|
||||
mozilla/widget/src/mac/nsMenuItem.cpp
|
||||
mozilla/widget/src/mac/nsRadioButton.cpp
|
||||
mozilla/widget/src/mac/nsScrollbar.cpp
|
||||
mozilla/widget/src/mac/nsTextAreaWidget.cpp
|
||||
mozilla/widget/src/mac/nsTextWidget.cpp
|
||||
mozilla/widget/src/mac/nsToolkit.cpp
|
||||
mozilla/widget/src/mac/nsWidgetFactory.cpp
|
||||
mozilla/widget/src/mac/nsWidgetSupport.cpp
|
||||
mozilla/widget/src/mac/nsWindow.cpp
|
||||
mozilla/widget/src/xpwidgets/nsBaseWidget.cpp
|
||||
mozilla/widget/src/xpwidgets/nsHTColumn.cpp
|
||||
mozilla/widget/src/xpwidgets/nsHTControlStripItem.cpp
|
||||
mozilla/widget/src/xpwidgets/nsHTDataModel.cpp
|
||||
mozilla/widget/src/xpwidgets/nsHTItem.cpp
|
||||
mozilla/widget/src/xpwidgets/nsHTTreeDataModel.cpp
|
||||
mozilla/widget/src/xpwidgets/nsHTTreeItem.cpp
|
||||
mozilla/widget/src/xpwidgets/nsImageButton.cpp
|
||||
mozilla/widget/src/xpwidgets/nsMenuButton.cpp
|
||||
mozilla/widget/src/xpwidgets/nsToolbar.cpp
|
||||
mozilla/widget/src/xpwidgets/nsToolbarItemHolder.cpp
|
||||
mozilla/widget/src/xpwidgets/nsToolbarManager.cpp
|
||||
mozilla/widget/src/xpwidgets/nsTreeView.cpp
|
||||
Binary file not shown.
@@ -1,23 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..
|
||||
|
||||
|
||||
DIRS=public timer src
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
@@ -1,33 +0,0 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist:widget directory
|
||||
#
|
||||
|
||||
nsIDragSessionMac.h
|
||||
nsIWidget.h
|
||||
nsIKBStateControl.h
|
||||
nsIButton.h
|
||||
nsICheckButton.h
|
||||
nsIListWidget.h
|
||||
nsIComboBox.h
|
||||
nsITextWidget.h
|
||||
nsITextAreaWidget.h
|
||||
nsIComboBox.h
|
||||
nsIListBox.h
|
||||
nsIScrollbar.h
|
||||
nsGUIEvent.h
|
||||
nsIRadioButton.h
|
||||
nsIMouseListener.h
|
||||
nsIEventListener.h
|
||||
nsIFileWidget.h
|
||||
nsIMenuListener.h
|
||||
nsWidgetsCID.h
|
||||
nsILabel.h
|
||||
nsILookAndFeel.h
|
||||
nsWidgetSupport.h
|
||||
nsIMenu.h
|
||||
nsIMenuBar.h
|
||||
nsIMenuItem.h
|
||||
nsIPopUpMenu.h
|
||||
nsIKeyBindMgr.h
|
||||
nsStringUtil.h
|
||||
nsIContextMenu.h
|
||||
@@ -1,16 +0,0 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist:idl directory
|
||||
#
|
||||
|
||||
nsIAppShell.idl
|
||||
nsIFilePicker.idl
|
||||
nsIFileSpecWithUI.idl
|
||||
nsISound.idl
|
||||
nsIToolkit.idl
|
||||
nsITransferable.idl
|
||||
nsIDragSession.idl
|
||||
nsIDragService.idl
|
||||
nsIFormatConverter.idl
|
||||
nsIClipboard.idl
|
||||
nsIClipboardOwner.idl
|
||||
nsIRollupListener.idl
|
||||
@@ -1,92 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = raptor
|
||||
XPIDL_MODULE = widget
|
||||
|
||||
EXPORTS = \
|
||||
nsIFontSizeIterator.h \
|
||||
nsIFontNameIterator.h \
|
||||
nsIFontRetrieverService.h \
|
||||
nsIMenuBar.h \
|
||||
nsIMenu.h \
|
||||
nsIMenuItem.h \
|
||||
nsIPopUpMenu.h \
|
||||
nsIFileWidget.h \
|
||||
nsStringUtil.h \
|
||||
nsIKBStateControl.h \
|
||||
nsIButton.h \
|
||||
nsICheckButton.h \
|
||||
nsIListWidget.h \
|
||||
nsIComboBox.h \
|
||||
nsITextWidget.h \
|
||||
nsITextAreaWidget.h \
|
||||
nsIComboBox.h \
|
||||
nsIListBox.h \
|
||||
nsIScrollbar.h \
|
||||
nsGUIEvent.h \
|
||||
nsIRadioButton.h \
|
||||
nsIMouseListener.h \
|
||||
nsIEventListener.h \
|
||||
nsIMenuListener.h \
|
||||
nsWidgetsCID.h \
|
||||
nsILookAndFeel.h \
|
||||
nsILabel.h \
|
||||
nsIMenuBar.h \
|
||||
nsIMenu.h \
|
||||
nsIMenuItem.h \
|
||||
nsIPopUpMenu.h \
|
||||
nsIFontNameIterator.h \
|
||||
nsIFontSizeIterator.h \
|
||||
nsIFontRetrieverService.h \
|
||||
nsIContextMenu.h \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIAppShell.idl \
|
||||
nsIFilePicker.idl \
|
||||
nsIFileSpecWithUI.idl \
|
||||
nsIToolkit.idl \
|
||||
nsISound.idl \
|
||||
nsITransferable.idl \
|
||||
nsIDragSession.idl \
|
||||
nsIDragService.idl \
|
||||
nsIFormatConverter.idl \
|
||||
nsIClipboard.idl \
|
||||
nsIClipboardOwner.idl \
|
||||
nsIRollupListener.idl \
|
||||
nsIWidget.idl \
|
||||
nsIWindow.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_UI
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
|
||||
DEFINES=-D_IMPL_NS_UI
|
||||
MODULE=raptor
|
||||
XPIDL_MODULE=widget
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsIAppShell.idl \
|
||||
.\nsIFilePicker.idl \
|
||||
.\nsIFileSpecWithUI.idl \
|
||||
.\nsISound.idl \
|
||||
.\nsIToolkit.idl \
|
||||
.\nsITransferable.idl \
|
||||
.\nsIDragSession.idl \
|
||||
.\nsIDragService.idl \
|
||||
.\nsIFormatConverter.idl \
|
||||
.\nsIClipboard.idl \
|
||||
.\nsIClipboardOwner.idl \
|
||||
.\nsIRollupListener.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS=\
|
||||
nsIFontSizeIterator.h \
|
||||
nsIFontNameIterator.h \
|
||||
nsIFontRetrieverService.h \
|
||||
nsIFileWidget.h \
|
||||
nsIWidget.h \
|
||||
nsIKBStateControl.h \
|
||||
nsIButton.h \
|
||||
nsICheckButton.h \
|
||||
nsIListWidget.h \
|
||||
nsIComboBox.h \
|
||||
nsITextWidget.h \
|
||||
nsITextAreaWidget.h \
|
||||
nsIComboBox.h \
|
||||
nsIListBox.h \
|
||||
nsIScrollbar.h \
|
||||
nsGUIEvent.h \
|
||||
nsIRadioButton.h \
|
||||
nsIMouseListener.h \
|
||||
nsIEventListener.h \
|
||||
nsIMenuListener.h \
|
||||
nsWidgetsCID.h \
|
||||
nsStringUtil.h \
|
||||
nsILookAndFeel.h \
|
||||
nsILabel.h \
|
||||
nsIMenuBar.h \
|
||||
nsIMenu.h \
|
||||
nsIMenuItem.h \
|
||||
nsIContextMenu.h \
|
||||
nsIPopUpMenu.h \
|
||||
$(NULL)
|
||||
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
@@ -1,509 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsGUIEvent_h__
|
||||
#define nsGUIEvent_h__
|
||||
|
||||
#include "nsPoint.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
class nsIRenderingContext;
|
||||
class nsIRegion;
|
||||
class nsIWidget;
|
||||
class nsIMenuItem;
|
||||
|
||||
/**
|
||||
* Return status for event processors.
|
||||
*/
|
||||
|
||||
enum nsEventStatus {
|
||||
/// The event is ignored, do default processing
|
||||
nsEventStatus_eIgnore,
|
||||
/// The event is consumed, don't do default processing
|
||||
nsEventStatus_eConsumeNoDefault,
|
||||
/// The event is consumed, but do default processing
|
||||
nsEventStatus_eConsumeDoDefault
|
||||
};
|
||||
|
||||
/**
|
||||
* General event
|
||||
*/
|
||||
|
||||
struct nsEvent {
|
||||
/// See event struct types
|
||||
PRUint8 eventStructType;
|
||||
/// See GUI MESSAGES,
|
||||
PRUint32 message;
|
||||
/// in widget relative coordinates, modified to be relative to current view in layout.
|
||||
nsPoint point;
|
||||
// in widget relative coordinates, not modified by layout code.
|
||||
nsPoint refPoint;
|
||||
/// elapsed time, in milliseconds, from the time the system was started to the time the message was created
|
||||
PRUint32 time;
|
||||
// flags to hold event flow stage and capture/bubble cancellation status
|
||||
PRUint32 flags;
|
||||
};
|
||||
|
||||
/**
|
||||
* General graphic user interface event
|
||||
*/
|
||||
|
||||
struct nsGUIEvent : public nsEvent {
|
||||
/// Originator of the event
|
||||
nsIWidget* widget;
|
||||
/// Internal platform specific message.
|
||||
void* nativeMsg;
|
||||
};
|
||||
|
||||
/**
|
||||
* Window resize event
|
||||
*/
|
||||
|
||||
struct nsSizeEvent : public nsGUIEvent {
|
||||
/// x,y width, height in pixels (client area)
|
||||
nsRect *windowSize;
|
||||
/// width of entire window (in pixels)
|
||||
PRInt32 mWinWidth;
|
||||
/// height of entire window (in pixels)
|
||||
PRInt32 mWinHeight;
|
||||
};
|
||||
|
||||
/**
|
||||
* Window repaint event
|
||||
*/
|
||||
|
||||
struct nsPaintEvent : public nsGUIEvent {
|
||||
/// Context to paint in.
|
||||
nsIRenderingContext *renderingContext;
|
||||
/// area to paint (should be used instead of rect)
|
||||
nsIRegion *region;
|
||||
/// x,y, width, height in pixels of area to paint
|
||||
nsRect *rect;
|
||||
};
|
||||
|
||||
/**
|
||||
* Scrollbar event
|
||||
*/
|
||||
|
||||
struct nsScrollbarEvent : public nsGUIEvent {
|
||||
/// ranges between scrollbar 0 and (maxRange - thumbSize). See nsIScrollbar
|
||||
PRUint32 position;
|
||||
};
|
||||
|
||||
|
||||
struct nsInputEvent : public nsGUIEvent {
|
||||
/// PR_TRUE indicates the shift key is down
|
||||
PRBool isShift;
|
||||
/// PR_TRUE indicates the control key is down
|
||||
PRBool isControl;
|
||||
/// PR_TRUE indicates the alt key is down
|
||||
PRBool isAlt;
|
||||
/// PR_TRUE indicates the meta key is down
|
||||
/// (or, on Mac, the Command key)
|
||||
PRBool isMeta;
|
||||
};
|
||||
|
||||
/**
|
||||
* Mouse event
|
||||
*/
|
||||
|
||||
struct nsMouseEvent : public nsInputEvent {
|
||||
/// The number of mouse clicks
|
||||
PRUint32 clickCount;
|
||||
/// Special return code for MOUSE_ACTIVATE to signal
|
||||
/// if the target accepts activation (1), or denies it (0)
|
||||
PRBool acceptActivation;
|
||||
};
|
||||
|
||||
/**
|
||||
* Keyboard event
|
||||
*/
|
||||
|
||||
struct nsKeyEvent : public nsInputEvent {
|
||||
/// see NS_VK codes
|
||||
PRUint32 keyCode;
|
||||
/// OS translated Unicode char
|
||||
PRUint32 charCode;
|
||||
// indicates whether the event signifies a printable character
|
||||
PRBool isChar;
|
||||
};
|
||||
|
||||
/**
|
||||
* IME Related Events
|
||||
*/
|
||||
struct nsTextRange {
|
||||
PRUint32 mStartOffset;
|
||||
PRUint32 mEndOffset;
|
||||
PRUint32 mRangeType;
|
||||
};
|
||||
|
||||
typedef struct nsTextRange nsTextRange;
|
||||
typedef nsTextRange* nsTextRangeArray;
|
||||
|
||||
struct nsTextEventReply {
|
||||
nsPoint mCursorPosition;
|
||||
PRBool mCursorIsCollapsed;
|
||||
};
|
||||
|
||||
typedef struct nsTextEventReply nsTextEventReply;
|
||||
|
||||
struct nsTextEvent : public nsInputEvent {
|
||||
PRUnichar* theText;
|
||||
nsTextEventReply theReply;
|
||||
PRUint32 rangeCount;
|
||||
nsTextRangeArray rangeArray;
|
||||
PRBool isChar;
|
||||
};
|
||||
|
||||
struct nsCompositionEvent : public nsInputEvent {
|
||||
PRUint32 compositionMessage;
|
||||
nsTextEventReply theReply;
|
||||
};
|
||||
|
||||
/**
|
||||
* Tooltip event
|
||||
*/
|
||||
struct nsTooltipEvent : public nsGUIEvent {
|
||||
/// Index of tooltip area which generated the event. @see SetTooltips in nsIWidget
|
||||
PRUint32 tipIndex;
|
||||
};
|
||||
|
||||
/**
|
||||
* MenuItem event
|
||||
*
|
||||
* When this event occurs the widget field in nsGUIEvent holds the "target"
|
||||
* for the event
|
||||
*/
|
||||
|
||||
struct nsMenuEvent : public nsGUIEvent {
|
||||
nsIMenuItem * mMenuItem;
|
||||
PRUint32 mCommand;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Event status for D&D Event
|
||||
*/
|
||||
enum nsDragDropEventStatus {
|
||||
/// The event is a enter
|
||||
nsDragDropEventStatus_eDragEntered,
|
||||
/// The event is exit
|
||||
nsDragDropEventStatus_eDragExited,
|
||||
/// The event is drop
|
||||
nsDragDropEventStatus_eDrop
|
||||
};
|
||||
|
||||
/**
|
||||
* Event Struct Types
|
||||
*/
|
||||
#define NS_EVENT 1
|
||||
#define NS_GUI_EVENT 2
|
||||
#define NS_SIZE_EVENT 3
|
||||
#define NS_PAINT_EVENT 4
|
||||
#define NS_SCROLLBAR_EVENT 5
|
||||
#define NS_INPUT_EVENT 6
|
||||
#define NS_KEY_EVENT 7
|
||||
#define NS_MOUSE_EVENT 8
|
||||
|
||||
#define NS_MENU_EVENT 10
|
||||
#define NS_DRAGDROP_EVENT 11
|
||||
#define NS_TEXT_EVENT 12
|
||||
#define NS_COMPOSITION_START 13
|
||||
#define NS_COMPOSITION_END 14
|
||||
|
||||
/**
|
||||
* GUI MESSAGES
|
||||
*/
|
||||
//@{
|
||||
|
||||
#define NS_WINDOW_START 100
|
||||
|
||||
// Widget is being created
|
||||
#define NS_CREATE (NS_WINDOW_START)
|
||||
// Widget is being destroyed
|
||||
#define NS_DESTROY (NS_WINDOW_START + 1)
|
||||
// Widget was resized
|
||||
#define NS_SIZE (NS_WINDOW_START + 2)
|
||||
// Widget gained focus
|
||||
#define NS_GOTFOCUS (NS_WINDOW_START + 3)
|
||||
// Widget lost focus
|
||||
#define NS_LOSTFOCUS (NS_WINDOW_START + 4)
|
||||
// Widget got activated
|
||||
#define NS_ACTIVATE (NS_WINDOW_START + 5)
|
||||
// Widget got deactivated
|
||||
#define NS_DEACTIVATE (NS_WINDOW_START + 6)
|
||||
// Widget needs to be repainted
|
||||
#define NS_PAINT (NS_WINDOW_START + 30)
|
||||
// Key is pressed within a window
|
||||
#define NS_KEY_PRESS (NS_WINDOW_START + 31)
|
||||
// Key is released within a window
|
||||
#define NS_KEY_UP (NS_WINDOW_START + 32)
|
||||
// Key is pressed within a window
|
||||
#define NS_KEY_DOWN (NS_WINDOW_START + 33)
|
||||
// Window has been moved to a new location.
|
||||
// The events point contains the x, y location in screen coordinates
|
||||
#define NS_MOVE (NS_WINDOW_START + 34)
|
||||
|
||||
// Tab control's selected tab has changed
|
||||
#define NS_TABCHANGE (NS_WINDOW_START + 35)
|
||||
|
||||
|
||||
|
||||
// Menu item selected
|
||||
#define NS_MENU_SELECTED (NS_WINDOW_START + 38)
|
||||
|
||||
// Form control changed: currently == combo box selection changed
|
||||
// but could be expanded to mean textbox, checkbox changed, etc.
|
||||
// This is a GUI specific event that does not necessarily correspond
|
||||
// directly to a mouse click or a key press.
|
||||
#define NS_CONTROL_CHANGE (NS_WINDOW_START + 39)
|
||||
|
||||
// Indicates the display has changed depth
|
||||
#define NS_DISPLAYCHANGED (NS_WINDOW_START + 40)
|
||||
|
||||
|
||||
#define NS_MOUSE_MESSAGE_START 300
|
||||
#define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)
|
||||
#define NS_MOUSE_LEFT_BUTTON_UP (NS_MOUSE_MESSAGE_START + 1)
|
||||
#define NS_MOUSE_LEFT_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 2)
|
||||
#define NS_MOUSE_MIDDLE_BUTTON_UP (NS_MOUSE_MESSAGE_START + 10)
|
||||
#define NS_MOUSE_MIDDLE_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 11)
|
||||
#define NS_MOUSE_RIGHT_BUTTON_UP (NS_MOUSE_MESSAGE_START + 20)
|
||||
#define NS_MOUSE_RIGHT_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 21)
|
||||
#define NS_MOUSE_ENTER (NS_MOUSE_MESSAGE_START + 22)
|
||||
#define NS_MOUSE_EXIT (NS_MOUSE_MESSAGE_START + 23)
|
||||
#define NS_MOUSE_LEFT_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 24)
|
||||
#define NS_MOUSE_MIDDLE_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 25)
|
||||
#define NS_MOUSE_RIGHT_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 26)
|
||||
#define NS_MOUSE_LEFT_CLICK (NS_MOUSE_MESSAGE_START + 27)
|
||||
#define NS_MOUSE_MIDDLE_CLICK (NS_MOUSE_MESSAGE_START + 28)
|
||||
#define NS_MOUSE_RIGHT_CLICK (NS_MOUSE_MESSAGE_START + 29)
|
||||
#define NS_MOUSE_ACTIVATE (NS_MOUSE_MESSAGE_START + 30)
|
||||
|
||||
#define NS_SCROLLBAR_MESSAGE_START 1000
|
||||
#define NS_SCROLLBAR_POS (NS_SCROLLBAR_MESSAGE_START)
|
||||
#define NS_SCROLLBAR_PAGE_NEXT (NS_SCROLLBAR_MESSAGE_START + 1)
|
||||
#define NS_SCROLLBAR_PAGE_PREV (NS_SCROLLBAR_MESSAGE_START + 2)
|
||||
#define NS_SCROLLBAR_LINE_NEXT (NS_SCROLLBAR_MESSAGE_START + 3)
|
||||
#define NS_SCROLLBAR_LINE_PREV (NS_SCROLLBAR_MESSAGE_START + 4)
|
||||
|
||||
#define NS_STREAM_EVENT_START 1100
|
||||
#define NS_PAGE_LOAD (NS_STREAM_EVENT_START)
|
||||
#define NS_PAGE_UNLOAD (NS_STREAM_EVENT_START + 1)
|
||||
#define NS_IMAGE_LOAD (NS_STREAM_EVENT_START + 2)
|
||||
#define NS_IMAGE_ABORT (NS_STREAM_EVENT_START + 3)
|
||||
#define NS_IMAGE_ERROR (NS_STREAM_EVENT_START + 4)
|
||||
|
||||
#define NS_FORM_EVENT_START 1200
|
||||
#define NS_FORM_SUBMIT (NS_FORM_EVENT_START)
|
||||
#define NS_FORM_RESET (NS_FORM_EVENT_START + 1)
|
||||
#define NS_FORM_CHANGE (NS_FORM_EVENT_START + 2)
|
||||
#define NS_FORM_SELECTED (NS_FORM_EVENT_START + 3)
|
||||
#define NS_FORM_INPUT (NS_FORM_EVENT_START + 4)
|
||||
|
||||
//Need separate focus/blur notifications for non-native widgets
|
||||
#define NS_FOCUS_EVENT_START 1300
|
||||
#define NS_FOCUS_CONTENT (NS_FOCUS_EVENT_START)
|
||||
#define NS_BLUR_CONTENT (NS_FOCUS_EVENT_START + 1)
|
||||
|
||||
|
||||
#define NS_DRAGDROP_EVENT_START 1400
|
||||
#define NS_DRAGDROP_ENTER (NS_DRAGDROP_EVENT_START)
|
||||
#define NS_DRAGDROP_OVER (NS_DRAGDROP_EVENT_START + 1)
|
||||
#define NS_DRAGDROP_EXIT (NS_DRAGDROP_EVENT_START + 2)
|
||||
#define NS_DRAGDROP_DROP (NS_DRAGDROP_EVENT_START + 3)
|
||||
#define NS_DRAGDROP_GESTURE (NS_DRAGDROP_EVENT_START + 4)
|
||||
|
||||
// Events for popups
|
||||
#define NS_MENU_EVENT_START 1500
|
||||
#define NS_MENU_CREATE (NS_MENU_EVENT_START)
|
||||
#define NS_MENU_DESTROY (NS_MENU_EVENT_START+1)
|
||||
#define NS_MENU_ACTION (NS_MENU_EVENT_START+2)
|
||||
#define NS_XUL_BROADCAST (NS_MENU_EVENT_START+3)
|
||||
#define NS_XUL_COMMAND_UPDATE (NS_MENU_EVENT_START+4)
|
||||
//@}
|
||||
|
||||
|
||||
#define NS_IS_MOUSE_EVENT(evnt) \
|
||||
(((evnt)->message == NS_MOUSE_LEFT_BUTTON_DOWN) || \
|
||||
((evnt)->message == NS_MOUSE_LEFT_BUTTON_UP) || \
|
||||
((evnt)->message == NS_MOUSE_LEFT_CLICK) || \
|
||||
((evnt)->message == NS_MOUSE_LEFT_DOUBLECLICK) || \
|
||||
((evnt)->message == NS_MOUSE_MIDDLE_BUTTON_DOWN) || \
|
||||
((evnt)->message == NS_MOUSE_MIDDLE_BUTTON_UP) || \
|
||||
((evnt)->message == NS_MOUSE_MIDDLE_CLICK) || \
|
||||
((evnt)->message == NS_MOUSE_MIDDLE_DOUBLECLICK) || \
|
||||
((evnt)->message == NS_MOUSE_RIGHT_BUTTON_DOWN) || \
|
||||
((evnt)->message == NS_MOUSE_RIGHT_BUTTON_UP) || \
|
||||
((evnt)->message == NS_MOUSE_RIGHT_CLICK) || \
|
||||
((evnt)->message == NS_MOUSE_RIGHT_DOUBLECLICK) || \
|
||||
((evnt)->message == NS_MOUSE_ENTER) || \
|
||||
((evnt)->message == NS_MOUSE_EXIT) || \
|
||||
((evnt)->message == NS_MOUSE_MOVE))
|
||||
|
||||
#define NS_IS_KEY_EVENT(evnt) \
|
||||
(((evnt)->message == NS_KEY_DOWN) || \
|
||||
((evnt)->message == NS_KEY_PRESS) || \
|
||||
((evnt)->message == NS_KEY_UP))
|
||||
|
||||
/*
|
||||
* Virtual key bindings for keyboard events
|
||||
* NOTE: These are repeated in nsIDOMEvent.h and must be kept in sync
|
||||
*/
|
||||
|
||||
#define NS_VK_CANCEL 0x03
|
||||
#define NS_VK_BACK 0x08
|
||||
#define NS_VK_TAB 0x09
|
||||
#define NS_VK_CLEAR 0x0C
|
||||
#define NS_VK_RETURN 0x0D
|
||||
#define NS_VK_ENTER 0x0E
|
||||
#define NS_VK_SHIFT 0x10
|
||||
#define NS_VK_CONTROL 0x11
|
||||
#define NS_VK_ALT 0x12
|
||||
#define NS_VK_PAUSE 0x13
|
||||
#define NS_VK_CAPS_LOCK 0x14
|
||||
#define NS_VK_ESCAPE 0x1B
|
||||
#define NS_VK_SPACE 0x20
|
||||
#define NS_VK_PAGE_UP 0x21
|
||||
#define NS_VK_PAGE_DOWN 0x22
|
||||
#define NS_VK_END 0x23
|
||||
#define NS_VK_HOME 0x24
|
||||
#define NS_VK_LEFT 0x25
|
||||
#define NS_VK_UP 0x26
|
||||
#define NS_VK_RIGHT 0x27
|
||||
#define NS_VK_DOWN 0x28
|
||||
#define NS_VK_PRINTSCREEN 0x2C
|
||||
#define NS_VK_INSERT 0x2D
|
||||
#define NS_VK_DELETE 0x2E
|
||||
|
||||
// NS_VK_0 - NS_VK_9 match their ascii values
|
||||
#define NS_VK_0 0x30
|
||||
#define NS_VK_1 0x31
|
||||
#define NS_VK_2 0x32
|
||||
#define NS_VK_3 0x33
|
||||
#define NS_VK_4 0x34
|
||||
#define NS_VK_5 0x35
|
||||
#define NS_VK_6 0x36
|
||||
#define NS_VK_7 0x37
|
||||
#define NS_VK_8 0x38
|
||||
#define NS_VK_9 0x39
|
||||
|
||||
#define NS_VK_SEMICOLON 0x3B
|
||||
#define NS_VK_EQUALS 0x3D
|
||||
|
||||
// NS_VK_A - NS_VK_Z match their ascii values
|
||||
#define NS_VK_A 0x41
|
||||
#define NS_VK_B 0x42
|
||||
#define NS_VK_C 0x43
|
||||
#define NS_VK_D 0x44
|
||||
#define NS_VK_E 0x45
|
||||
#define NS_VK_F 0x46
|
||||
#define NS_VK_G 0x47
|
||||
#define NS_VK_H 0x48
|
||||
#define NS_VK_I 0x49
|
||||
#define NS_VK_J 0x4A
|
||||
#define NS_VK_K 0x4B
|
||||
#define NS_VK_L 0x4C
|
||||
#define NS_VK_M 0x4D
|
||||
#define NS_VK_N 0x4E
|
||||
#define NS_VK_O 0x4F
|
||||
#define NS_VK_P 0x50
|
||||
#define NS_VK_Q 0x51
|
||||
#define NS_VK_R 0x52
|
||||
#define NS_VK_S 0x53
|
||||
#define NS_VK_T 0x54
|
||||
#define NS_VK_U 0x55
|
||||
#define NS_VK_V 0x56
|
||||
#define NS_VK_W 0x57
|
||||
#define NS_VK_X 0x58
|
||||
#define NS_VK_Y 0x59
|
||||
#define NS_VK_Z 0x5A
|
||||
|
||||
#define NS_VK_NUMPAD0 0x60
|
||||
#define NS_VK_NUMPAD1 0x61
|
||||
#define NS_VK_NUMPAD2 0x62
|
||||
#define NS_VK_NUMPAD3 0x63
|
||||
#define NS_VK_NUMPAD4 0x64
|
||||
#define NS_VK_NUMPAD5 0x65
|
||||
#define NS_VK_NUMPAD6 0x66
|
||||
#define NS_VK_NUMPAD7 0x67
|
||||
#define NS_VK_NUMPAD8 0x68
|
||||
#define NS_VK_NUMPAD9 0x69
|
||||
#define NS_VK_MULTIPLY 0x6A
|
||||
#define NS_VK_ADD 0x6B
|
||||
#define NS_VK_SEPARATOR 0x6C
|
||||
#define NS_VK_SUBTRACT 0x6D
|
||||
#define NS_VK_DECIMAL 0x6E
|
||||
#define NS_VK_DIVIDE 0x6F
|
||||
#define NS_VK_F1 0x70
|
||||
#define NS_VK_F2 0x71
|
||||
#define NS_VK_F3 0x72
|
||||
#define NS_VK_F4 0x73
|
||||
#define NS_VK_F5 0x74
|
||||
#define NS_VK_F6 0x75
|
||||
#define NS_VK_F7 0x76
|
||||
#define NS_VK_F8 0x77
|
||||
#define NS_VK_F9 0x78
|
||||
#define NS_VK_F10 0x79
|
||||
#define NS_VK_F11 0x7A
|
||||
#define NS_VK_F12 0x7B
|
||||
#define NS_VK_F13 0x7C
|
||||
#define NS_VK_F14 0x7D
|
||||
#define NS_VK_F15 0x7E
|
||||
#define NS_VK_F16 0x7F
|
||||
#define NS_VK_F17 0x80
|
||||
#define NS_VK_F18 0x81
|
||||
#define NS_VK_F19 0x82
|
||||
#define NS_VK_F20 0x83
|
||||
#define NS_VK_F21 0x84
|
||||
#define NS_VK_F22 0x85
|
||||
#define NS_VK_F23 0x86
|
||||
#define NS_VK_F24 0x87
|
||||
|
||||
#define NS_VK_NUM_LOCK 0x90
|
||||
#define NS_VK_SCROLL_LOCK 0x91
|
||||
|
||||
#define NS_VK_COMMA 0xBC
|
||||
#define NS_VK_PERIOD 0xBE
|
||||
#define NS_VK_SLASH 0xBF
|
||||
#define NS_VK_BACK_QUOTE 0xC0
|
||||
#define NS_VK_OPEN_BRACKET 0xDB
|
||||
#define NS_VK_BACK_SLASH 0xDC
|
||||
#define NS_VK_CLOSE_BRACKET 0xDD
|
||||
#define NS_VK_QUOTE 0xDE
|
||||
|
||||
#define NS_EVENT_FLAG_NONE 0x0000
|
||||
#define NS_EVENT_FLAG_INIT 0x0001
|
||||
#define NS_EVENT_FLAG_BUBBLE 0x0002
|
||||
#define NS_EVENT_FLAG_CAPTURE 0x0004
|
||||
#define NS_EVENT_FLAG_STOP_DISPATCH 0x0008
|
||||
#define NS_EVENT_FLAG_NO_DEFAULT 0x0010
|
||||
|
||||
// IME Constants -- keep in synch with nsIDOMTextRange.h
|
||||
#define NS_TEXTRANGE_CARETPOSITION 0x01
|
||||
#define NS_TEXTRANGE_RAWINPUT 0X02
|
||||
#define NS_TEXTRANGE_SELECTEDRAWTEXT 0x03
|
||||
#define NS_TEXTRANGE_CONVERTEDTEXT 0x04
|
||||
#define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05
|
||||
|
||||
#endif // nsGUIEvent_h__
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
native int(int);
|
||||
[ptr] native nsDispatchListener(nsDispatchListener);
|
||||
[ptr] native nsIEventQueue(nsIEventQueue);
|
||||
[ptr] native UndefinednsIWidget(nsIWidget);
|
||||
[ref] native PRBoolRef(PRBool);
|
||||
[ref] native voidStarRef(void *);
|
||||
|
||||
%{ C++
|
||||
#include "nsIEventQueue.h"
|
||||
|
||||
/**
|
||||
* Flags for the getNativeData function.
|
||||
* See GetNativeData()
|
||||
*/
|
||||
#define NS_NATIVE_SHELL 0
|
||||
|
||||
/**
|
||||
* During the nsIAppShell Run method notify this listener
|
||||
* after each message dispatch.
|
||||
* @see SetDispatchListener member function of nsIAppShell
|
||||
*/
|
||||
class nsDispatchListener {
|
||||
public:
|
||||
virtual void AfterDispatch() = 0;
|
||||
};
|
||||
|
||||
class nsIWidget;
|
||||
%}
|
||||
|
||||
|
||||
[uuid(a0757c31-eeac-11d1-9ec1-00aa002fb821)]
|
||||
interface nsIAppShell : nsISupports
|
||||
{
|
||||
/**
|
||||
* Creates an application shell
|
||||
*/
|
||||
|
||||
void Create(inout int argc, inout string argv);
|
||||
|
||||
/**
|
||||
* Enter an event loop.
|
||||
* Don't leave until application exits.
|
||||
*/
|
||||
|
||||
void Run();
|
||||
|
||||
/**
|
||||
* Prepare to process events.
|
||||
*/
|
||||
|
||||
void Spinup();
|
||||
|
||||
/**
|
||||
* Prepare to stop processing events.
|
||||
*/
|
||||
|
||||
void Spindown();
|
||||
|
||||
/**
|
||||
* An event queue has been created or destroyed. Hook or unhook it from
|
||||
* your system, as necessary.
|
||||
* @param aQueue the queue in question
|
||||
* @param aListen PR_TRUE for a new queue wanting hooking up. PR_FALSE
|
||||
* for a queue wanting to be unhooked.
|
||||
*/
|
||||
void ListenToEventQueue(in nsIEventQueue aQueue, in PRBool aListen);
|
||||
|
||||
/**
|
||||
* After event dispatch execute app specific code
|
||||
*/
|
||||
|
||||
void GetNativeEvent(in PRBoolRef aRealEvent, in voidStarRef aEvent);
|
||||
|
||||
/**
|
||||
* After event dispatch execute app specific code
|
||||
*/
|
||||
|
||||
void DispatchNativeEvent(in PRBool aRealEvent, in voidStar aEvent);
|
||||
|
||||
/**
|
||||
* After event dispatch execute app specific code
|
||||
*/
|
||||
|
||||
void SetDispatchListener(in nsDispatchListener aDispatchListener);
|
||||
|
||||
/**
|
||||
* Exit the handle event loop
|
||||
*/
|
||||
|
||||
void Exit();
|
||||
|
||||
};
|
||||
|
||||
#endif // nsIAppShell_h__
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIButton_h__
|
||||
#define nsIButton_h__
|
||||
|
||||
#include "nsIWidget.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// {18032AD0-B265-11d1-AA2A-000000000000}
|
||||
#define NS_IBUTTON_IID \
|
||||
{ 0x18032ad0, 0xb265, 0x11d1, \
|
||||
{ 0xaa, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
/**
|
||||
* Push button widget.
|
||||
* Automatically shows itself as depressed when clicked on.
|
||||
*/
|
||||
class nsIButton : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IBUTTON_IID)
|
||||
|
||||
/**
|
||||
* Set the label
|
||||
*
|
||||
* @param Set the label to aText
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetLabel(const nsString &aText) = 0;
|
||||
|
||||
/**
|
||||
* Get the button label
|
||||
*
|
||||
* @param aBuffer contains label upon return
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetLabel(nsString &aBuffer) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,81 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsICheckButton_h__
|
||||
#define nsICheckButton_h__
|
||||
|
||||
// {961085F5-BD28-11d1-97EF-00609703C14E}
|
||||
#define NS_ICHECKBUTTON_IID \
|
||||
{ 0x961085f5, 0xbd28, 0x11d1, { 0x97, 0xef, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
|
||||
/**
|
||||
* Checkbox widget.
|
||||
* Can show itself in a checked or unchecked state.
|
||||
* The checkbox widget does not automatically show itself checked or unchecked when clicked on.
|
||||
*/
|
||||
class nsICheckButton : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICHECKBUTTON_IID)
|
||||
|
||||
/**
|
||||
* Set the button label
|
||||
*
|
||||
* @param aText button label
|
||||
* @result set to NS_OK if method successful
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetLabel(const nsString &aText) = 0;
|
||||
|
||||
/**
|
||||
* Get the button label
|
||||
*
|
||||
* @param aBuffer contains label upon return
|
||||
* @result set to NS_OK if method successful
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetLabel(nsString &aBuffer) = 0;
|
||||
|
||||
/**
|
||||
* Set the check state.
|
||||
* @param aState PR_TRUE show as checked. PR_FALSE show unchecked.
|
||||
* @result set to NS_OK if method successful
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetState(const PRBool aState) = 0;
|
||||
|
||||
/**
|
||||
* Get the check state.
|
||||
* @param aState PR_TRUE if checked. PR_FALSE if unchecked.
|
||||
* @result set to NS_OK if method successful
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetState(PRBool& aState) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsICheckButton_h__
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
|
||||
* Communications Corp. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Pinkerton
|
||||
*/
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISupportsArray.idl"
|
||||
#include "nsITransferable.idl"
|
||||
#include "nsIClipboardOwner.idl"
|
||||
|
||||
|
||||
[scriptable, uuid(8B5314BA-DB01-11d2-96CE-0060B0FB9956)]
|
||||
interface nsIClipboard : nsISupports
|
||||
{
|
||||
/**
|
||||
* Given a transferable, set the data on the native clipboard
|
||||
*
|
||||
* @param aTransferable The transferable
|
||||
* @param anOwner The owner of the transferable
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
void setData ( in nsITransferable aTransferable, in nsIClipboardOwner anOwner) ;
|
||||
|
||||
/**
|
||||
* Given a transferable, get the clipboard data.
|
||||
*
|
||||
* @param aTransferable The transferable
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
void getData ( in nsITransferable aTransferable ) ;
|
||||
|
||||
/**
|
||||
* This empties the clipboard and notifies the clipboard owner.
|
||||
* This empties the "logical" clipboard. It does not clear the native clipboard.
|
||||
*
|
||||
* @result NS_OK if successful.
|
||||
*/
|
||||
|
||||
void emptyClipboard ( ) ;
|
||||
|
||||
/**
|
||||
* Some platforms support deferred notification for putting data on the clipboard
|
||||
* This method forces the data onto the clipboard in its various formats
|
||||
* This may be used if the application going away.
|
||||
*
|
||||
* @result NS_OK if successful.
|
||||
*/
|
||||
|
||||
void forceDataToClipboard ( ) ;
|
||||
|
||||
/**
|
||||
* This provides a way to give correct UI feedback about, for instance, a paste
|
||||
* should be allowed. It does _NOT_ actually retreive the data and should be a very
|
||||
* inexpensive call. All it does is check if there is data on the clipboard matching
|
||||
* any of the flavors in the given list.
|
||||
*
|
||||
* @aFlavorList - nsISupportsString's in a nsISupportsArray (for JavaScript).
|
||||
* @outResult - if data is present matching one of
|
||||
* @result NS_OK if successful.
|
||||
*/
|
||||
boolean hasDataMatchingFlavors ( in nsISupportsArray aFlavorList ) ;
|
||||
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
|
||||
%}
|
||||
@@ -1,45 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
|
||||
* Communications Corp. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Pinkerton
|
||||
*/
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsITransferable.idl"
|
||||
|
||||
|
||||
[scriptable, uuid(5A31C7A1-E122-11d2-9A57-000064657374)]
|
||||
interface nsIClipboardOwner : nsISupports
|
||||
{
|
||||
/**
|
||||
* Notifies the owner of the clipboard transferable that the
|
||||
* transferable is being removed from the clipboard
|
||||
*
|
||||
* @param aTransferable The transferable
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
void LosingOwnership ( in nsITransferable aTransferable ) ;
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
|
||||
%}
|
||||
@@ -1,141 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIComboBox_h__
|
||||
#define nsIComboBox_h__
|
||||
|
||||
#include "nsIListWidget.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// {961085F6-BD28-11d1-97EF-00609703C14E}
|
||||
#define NS_ICOMBOBOX_IID \
|
||||
{ 0x961085f6, 0xbd28, 0x11d1, { 0x97, 0xef, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
|
||||
/**
|
||||
* Initialize combobox data
|
||||
*/
|
||||
|
||||
struct nsComboBoxInitData : public nsWidgetInitData {
|
||||
nsComboBoxInitData()
|
||||
: mDropDownHeight(0)
|
||||
{
|
||||
}
|
||||
|
||||
PRUint32 mDropDownHeight; // in pixels
|
||||
};
|
||||
|
||||
/**
|
||||
* Single selection drop down list. See nsIListWidget for capabilities
|
||||
*/
|
||||
|
||||
class nsIComboBox : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICOMBOBOX_IID);
|
||||
|
||||
/**
|
||||
* Set an item at the specific position
|
||||
*
|
||||
* @param aItem the item name. The item has to be null terminated
|
||||
* @param aPosition the position the item should be inserted at
|
||||
* 0 is at the top of the list
|
||||
* -1 is at the end of the list
|
||||
*/
|
||||
NS_IMETHOD AddItemAt(nsString &aItem, PRInt32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Finds the first occurrence of the specified item
|
||||
*
|
||||
* @param aItem the string to be filled
|
||||
* @param aStartPos the starting position (index)
|
||||
* @return PR_TRUE if successful, PR_FALSE otherwise
|
||||
*
|
||||
*/
|
||||
virtual PRInt32 FindItem(nsString &aItem, PRInt32 aStartPos) = 0;
|
||||
|
||||
/**
|
||||
* Returns the number of items in the list
|
||||
*
|
||||
* @return the number of items
|
||||
*
|
||||
*/
|
||||
virtual PRInt32 GetItemCount() = 0;
|
||||
|
||||
/**
|
||||
* Remove the first occurrence of the specified item
|
||||
*
|
||||
* @param aPosition the item position
|
||||
* 0 is at the top of the list
|
||||
* -1 is at the end of the list
|
||||
*
|
||||
* @return PR_TRUE if successful, PR_FALSE otherwise
|
||||
*
|
||||
*/
|
||||
virtual PRBool RemoveItemAt(PRInt32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Gets an item at a specific location
|
||||
*
|
||||
* @param anItem on return contains the string of the item at that position
|
||||
* @param aPosition the Position of the item
|
||||
*
|
||||
*/
|
||||
virtual PRBool GetItemAt(nsString& anItem, PRInt32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Gets the selected item for a single selection list
|
||||
*
|
||||
* @param aItem on return contains the string of the selected item
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetSelectedItem(nsString &aItem) = 0;
|
||||
|
||||
/**
|
||||
* Returns with the index of the selected item
|
||||
*
|
||||
* @return PRInt32, index of selected item
|
||||
*
|
||||
*/
|
||||
virtual PRInt32 GetSelectedIndex() = 0;
|
||||
|
||||
/**
|
||||
* Select the item at the specified position
|
||||
*
|
||||
* @param PRInt32, the item position
|
||||
* 0 is at the top of the list
|
||||
* -1 is at the end of the list
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SelectItem(PRInt32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Deselects all the items in the list
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Deselect() = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsIComboBox_h__
|
||||
|
||||
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIContextMenu_h__
|
||||
#define nsIContextMenu_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIWebShell.h"
|
||||
|
||||
class nsIMenuBar;
|
||||
class nsIMenu;
|
||||
class nsIMenuItem;
|
||||
class nsIMenuListener;
|
||||
|
||||
//Generate this!
|
||||
// {35A3DEC1-4992-11d2-8DBA-00609703C14E}
|
||||
#define NS_ICONTEXTMENU_IID \
|
||||
{ 0x35a3dec1, 0x4992, 0x11d2, \
|
||||
{ 0x8d, 0xba, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
/**
|
||||
* Menu widget
|
||||
*/
|
||||
class nsIContextMenu : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTEXTMENU_IID)
|
||||
|
||||
/**
|
||||
* Creates the context menu
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Create(nsISupports * aParent, const nsString& anAlignment, const nsString& anAnchorAlignment) = 0;
|
||||
|
||||
/**
|
||||
* Get the context menu's Parent
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetParent(nsISupports *&aParent) = 0;
|
||||
|
||||
/**
|
||||
* Adds a context menu Item
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD AddItem(nsISupports* aItem) = 0;
|
||||
|
||||
/**
|
||||
* Adds a separator
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD AddSeparator() = 0;
|
||||
|
||||
/**
|
||||
* Returns the number of context menu items
|
||||
* This does count separators as items
|
||||
*/
|
||||
NS_IMETHOD GetItemCount(PRUint32 &aCount) = 0;
|
||||
|
||||
/**
|
||||
* Returns a Menu or Menu Item at a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetItemAt(const PRUint32 aPos, nsISupports *& aMenuItem) = 0;
|
||||
|
||||
/**
|
||||
* Inserts a Menu Item at a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD InsertItemAt(const PRUint32 aPos, nsISupports * aMenuItem) = 0;
|
||||
|
||||
/**
|
||||
* Removes an Menu Item from a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD RemoveItem(const PRUint32 aPos) = 0;
|
||||
|
||||
/**
|
||||
* Removes all the Menu Items
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD RemoveAll() = 0;
|
||||
|
||||
/**
|
||||
* Gets Native MenuHandle
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetNativeData(void** aData) = 0;
|
||||
|
||||
/**
|
||||
* Adds menu listener for dynamic construction
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD AddMenuListener(nsIMenuListener * aMenuListener) = 0;
|
||||
|
||||
/**
|
||||
* Removes menu listener for dynamic construction
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD RemoveMenuListener(nsIMenuListener * aMenuListener) = 0;
|
||||
|
||||
/**
|
||||
* Set location
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetLocation(PRInt32 aX, PRInt32 aY) = 0;
|
||||
|
||||
/**
|
||||
* Set DOMNode
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetDOMNode(nsIDOMNode * aMenuNode) = 0;
|
||||
|
||||
/**
|
||||
* Set DOMElement
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetDOMElement(nsIDOMElement * aMenuElement) = 0;
|
||||
|
||||
/**
|
||||
* Set WebShell
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetWebShell(nsIWebShell * aWebShell) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,70 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
|
||||
* Communications Corp. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Pinkerton
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISupportsArray.idl"
|
||||
#include "nsIDragSession.idl"
|
||||
#include "nsIScriptableRegion.idl"
|
||||
|
||||
|
||||
[scriptable, uuid(8B5314BB-DB01-11d2-96CE-0060B0FB9956)]
|
||||
interface nsIDragService : nsISupports
|
||||
{
|
||||
const long DRAGDROP_ACTION_NONE = 0;
|
||||
const long DRAGDROP_ACTION_COPY = 1;
|
||||
const long DRAGDROP_ACTION_MOVE = 2;
|
||||
const long DRAGDROP_ACTION_LINK = 4;
|
||||
|
||||
/**
|
||||
* Starts a modal drag session with an array of transaferables
|
||||
*
|
||||
* @param aTransferables - an array of transferables to be dragged
|
||||
* @param aRegion - a region containing rectangles for cursor feedback,
|
||||
* in window coordinates.
|
||||
* @param aActionType - specified which of copy/move/link are allowed
|
||||
*/
|
||||
void invokeDragSession ( in nsISupportsArray aTransferables,
|
||||
in nsIScriptableRegion aRegion, in unsigned long aActionType );
|
||||
|
||||
/**
|
||||
* Returns the current Drag Session
|
||||
*/
|
||||
nsIDragSession getCurrentSession ( ) ;
|
||||
|
||||
/**
|
||||
* Tells the Drag Service to start a drag session. This is called when
|
||||
* an external drag occurs
|
||||
*/
|
||||
void startDragSession ( ) ;
|
||||
|
||||
/**
|
||||
* Tells the Drag Service to end a drag session. This is called when
|
||||
* an external drag occurs
|
||||
*/
|
||||
void endDragSession ( ) ;
|
||||
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
|
||||
%}
|
||||
@@ -1,80 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
|
||||
* Communications Corp. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Pinkerton
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISupportsArray.idl"
|
||||
#include "nsITransferable.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsSize.h"
|
||||
%}
|
||||
|
||||
native nsSize (nsSize);
|
||||
|
||||
|
||||
[scriptable, uuid(CBA22C53-FCCE-11d2-96D4-0060B0FB9956)]
|
||||
interface nsIDragSession : nsISupports
|
||||
{
|
||||
/**
|
||||
* Set the current state of the drag whether it can be dropped or not.
|
||||
* usually the target "frame" sets this so the native system can render the correct feedback
|
||||
*/
|
||||
attribute boolean canDrop;
|
||||
|
||||
/**
|
||||
* Sets the action (copy, move, link, et.c) for the current drag
|
||||
*/
|
||||
attribute unsigned long dragAction;
|
||||
|
||||
/**
|
||||
* Sets the current width and height if the drag target area.
|
||||
* It will contain the current size of the Frame that the drag is currently in
|
||||
*/
|
||||
attribute nsSize targetSize;
|
||||
|
||||
/**
|
||||
* Get the number items that were dropped
|
||||
*/
|
||||
readonly attribute unsigned long numDropItems;
|
||||
|
||||
/**
|
||||
* Get data from a Drag&Drop. Can be called while the drag is in process
|
||||
* or after the drop has completed.
|
||||
*
|
||||
* @param aTransferable the transferable for the data to be put into
|
||||
* @param aItemIndex which of multiple drag items, zero-based
|
||||
*/
|
||||
void getData ( in nsITransferable aTransferable, in unsigned long aItemIndex ) ;
|
||||
|
||||
/**
|
||||
* Check to set if ant of the native data on the clipboard matches this data flavor
|
||||
*
|
||||
* @result NS_OK if if the data flavor is supported and, NS_ERROR_FAILURE is it is not
|
||||
*/
|
||||
boolean isDataFlavorSupported ( in string aDataFlavor ) ;
|
||||
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
|
||||
%}
|
||||
@@ -1,51 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIDragSessionMac_h__
|
||||
#define nsIDragSessionMac_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include <Drag.h>
|
||||
|
||||
|
||||
#define NS_IDRAGSESSIONMAC_IID \
|
||||
{ 0x36c4c380, 0x09e2, 0x11d3, { 0xb0, 0x33, 0xa4, 0x20, 0xf4, 0x2c, 0xfd, 0x7c } };
|
||||
|
||||
|
||||
class nsIDragSessionMac : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDRAGSESSIONMAC_IID)
|
||||
|
||||
/**
|
||||
* Since the drag may originate in an external application, we need some way of
|
||||
* communicating the DragManager's DragRef to the session so it can use it
|
||||
* when filling in data requests.
|
||||
*
|
||||
* @param aDragRef the MacOS DragManager's ref number for the current drag
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetDragReference ( DragReference aDragRef ) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIEventListener_h__
|
||||
#define nsIEventListener_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
/**
|
||||
* Event listener interface.
|
||||
* Alternative to a callback for recieving events.
|
||||
*/
|
||||
|
||||
// {c83f6b80-d7ce-11d2-8360-c4c894c4917c}
|
||||
#define NS_IEVENTLISTENER_IID \
|
||||
{ 0xc83f6b80, 0xd7ce, 0x11d2, { 0x83, 0x60, 0xc4, 0xc8, 0x94, 0xc4, 0x91, 0x7c } }
|
||||
|
||||
class nsIEventListener : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IEVENTLISTENER_IID)
|
||||
|
||||
/**
|
||||
* Processes all events.
|
||||
* If a mouse listener is registered this method will not process mouse events.
|
||||
* @param anEvent the event to process. See nsGUIEvent.h for event types.
|
||||
*/
|
||||
|
||||
virtual nsEventStatus ProcessEvent(const nsGUIEvent & anEvent) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsIEventListener_h__
|
||||
@@ -1,75 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIFileDialogsMgr_h__
|
||||
#define nsIFileDialogsMgr_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
// {0ef98781-e34b-11d2-b345-00a0cc3c1cde}
|
||||
#define NS_IFILEDIALOGSMGR_IID \
|
||||
{ 0xef98781, 0xe34b, 0x11d2, { 0xb3, 0x45, 0x0, 0xa0, 0xcc, 0x3c, 0x1c, 0xde } }
|
||||
|
||||
#define NS_FILEDIALOGSMGR_CID \
|
||||
{ 0xef98784, 0xe34b, 0x11d2, { 0xb3, 0x45, 0x0, 0xa0, 0xcc, 0x3c, 0x1c, 0xde } }
|
||||
|
||||
enum nsFileDlgResults {
|
||||
nsFileDlgResults_Cancel, // User hit cancel, ignore selection
|
||||
nsFileDlgResults_OK, // User hit Ok, process selection
|
||||
nsFileDlgResults_Replace // User acknowledged file already exists so ok to replace, process selection
|
||||
};
|
||||
|
||||
/**
|
||||
* (native) File Dialogs utility.
|
||||
* Provides an XP wrapper to platform native file dialogs:
|
||||
* GetFile - Presents a file browser and returns an nsFileSpec for the selected file
|
||||
* GetFolder - Presents a folder/path selection dialog and returns an nsFileSpec
|
||||
* PutFile - Presents a file save dialog to the user and returns an nsFileSpec with
|
||||
* the name and path to save the file
|
||||
*
|
||||
*/
|
||||
|
||||
class nsIFileDialogsMgr : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFILEDIALOGSMGR_IID)
|
||||
|
||||
NS_IMETHOD GetFile(
|
||||
nsFileSpec & theFileSpec, // Populate with initial path for file dialog
|
||||
nsFileDlgResults & theResult, // Result from the file selection dialog prompt
|
||||
const nsString * promptString, // Window title for file selection dialog
|
||||
void * filterList) = 0;
|
||||
|
||||
NS_IMETHOD GetFolder(
|
||||
nsFileSpec & theFileSpec, // Populate with initial path for file dialog
|
||||
nsFileDlgResults & theResult, // Result from the folder selection dialog prompt
|
||||
const nsString * promptString) = 0; // Window title for folder selection dialog
|
||||
|
||||
NS_IMETHOD PutFile(
|
||||
nsFileSpec & theFileSpec, // Populate with initial path for file dialog
|
||||
nsFileDlgResults & theResult, // Result from the file save dialog prompt
|
||||
const nsString * promptString) = 0; // Window title for file save dialog
|
||||
|
||||
};
|
||||
|
||||
#endif // nsIFileDialogsMgr_h__
|
||||
@@ -1,96 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIFileSpec.idl"
|
||||
|
||||
interface nsIDOMWindow;
|
||||
|
||||
[scriptable, uuid(c47de916-1dd1-11b2-8141-82507fa02b21)]
|
||||
interface nsIFilePicker : nsISupports
|
||||
{
|
||||
const short modeLoad = 0; // Load a file or directory
|
||||
const short modeSave = 1; // Save a file or directory
|
||||
const short modeGetFolder = 2; // Select a fodler/directory
|
||||
|
||||
const short returnOK = 0; // User hit cancel, ignore selection
|
||||
const short returnCancel = 1; // User hit Ok, process selection
|
||||
const short returnReplace = 2; // User acknowledged file already exists so ok to replace, process selection
|
||||
|
||||
/**
|
||||
* Create the file widget.
|
||||
*
|
||||
* @param parent nsIDOMWindow parent. This dialog should be dependant on this parent.
|
||||
* @param title The title for the file widget
|
||||
* @param mode load, save, or get folder
|
||||
*
|
||||
*/
|
||||
void create(in nsIDOMWindow parent, in wstring title, in short mode);
|
||||
|
||||
/**
|
||||
* Set the list of file filters
|
||||
*
|
||||
* @param titles array of filter titles
|
||||
* @param filters array of filters to associate with titles
|
||||
* @param numberOfFilters number of filters.
|
||||
*
|
||||
*/
|
||||
void setFilterList(in long numberOfFilters,
|
||||
[array, size_is(numberOfFilters)] in wstring titles,
|
||||
[array, size_is(numberOfFilters)] in wstring filters);
|
||||
|
||||
/**
|
||||
* Get the index into the filter list for the type of file the user wants to save
|
||||
*
|
||||
* @param selectedFilter the index of the selected item in the filter list
|
||||
*
|
||||
*/
|
||||
readonly attribute long selectedFilter;
|
||||
|
||||
/* what is this? */
|
||||
attribute wstring defaultString;
|
||||
|
||||
/**
|
||||
* Set the directory that the file open/save dialog initially displays
|
||||
*
|
||||
* @param displayDirectory the name of the directory
|
||||
*
|
||||
*/
|
||||
attribute nsIFileSpec displayDirectory;
|
||||
|
||||
|
||||
/**
|
||||
* Get the nsFileSpec for the file or directory.
|
||||
*
|
||||
* @return Returns the file currently selected
|
||||
*/
|
||||
readonly attribute nsIFileSpec file;
|
||||
|
||||
/**
|
||||
* Show File Dialog. The dialog is displayed modally.
|
||||
*
|
||||
* @return returnOK if the user selects OK, returnCancel if the user selects cancel
|
||||
*
|
||||
*/
|
||||
short show();
|
||||
};
|
||||
@@ -1,112 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
// This is the only correct cross-platform way to specify a file.
|
||||
// Strings are not such a way. If you grew up on windows or unix, you
|
||||
// may think they are. Welcome to reality.
|
||||
|
||||
#include "nsIFileSpec.idl"
|
||||
|
||||
%{C++
|
||||
#include "nscore.h" // for NS_WIDGET
|
||||
#include "nsIComponentManager.h"
|
||||
%}
|
||||
native StandardFilterMask(nsIFileSpecWithUI::StandardFilterMask);
|
||||
|
||||
[scriptable, uuid(8ddf7681-139a-11d3-915f-dc1f8c138b7c)]
|
||||
interface nsIFileSpecWithUI : nsIFileSpec
|
||||
{
|
||||
%{C++
|
||||
//
|
||||
// The "choose" functions present the file picker UI in order to set the
|
||||
// value of the file spec.
|
||||
%}
|
||||
|
||||
%{C++
|
||||
// The mask for standard filters is given as follows:
|
||||
enum StandardFilterMask
|
||||
{
|
||||
eAllReadable = (1<<0)
|
||||
, eHTMLFiles = (1<<1)
|
||||
, eXMLFiles = (1<<2)
|
||||
, eImageFiles = (1<<3)
|
||||
, eMailFiles = (1<<4)
|
||||
, eTextFiles = (1<<5)
|
||||
, eAllFiles = (1<<6)
|
||||
|
||||
// Mask containing all the above default filters
|
||||
, eAllStandardFilters = (
|
||||
eAllReadable
|
||||
| eHTMLFiles
|
||||
| eXMLFiles
|
||||
| eImageFiles
|
||||
| eMailFiles
|
||||
| eTextFiles
|
||||
| eAllFiles)
|
||||
, eAllMailOutputFilters = (
|
||||
eHTMLFiles
|
||||
| eMailFiles
|
||||
| eTextFiles)
|
||||
|
||||
// The "extra filter" bit should be set if the "extra filter"
|
||||
// is passed in to chooseInputFile.
|
||||
, eExtraFilter = (1<<31)
|
||||
};
|
||||
enum { kNumStandardFilters = 7, kNumMailFilters = 3 };
|
||||
%}
|
||||
[noscript] void chooseInputFile(
|
||||
in string title
|
||||
, in StandardFilterMask standardFilterMask
|
||||
, in string extraFilterTitle
|
||||
, in string extraFilter
|
||||
);
|
||||
|
||||
[noscript] void chooseOutputFile(in string windowTitle,
|
||||
in string suggestedLeafName,
|
||||
in StandardFilterMask standardFilterMask);
|
||||
|
||||
string chooseFile(in string title);
|
||||
string chooseDirectory(in string title);
|
||||
};
|
||||
|
||||
%{C++
|
||||
// Define Progid and CID
|
||||
// {e3326a80-2816-11d3-a7e5-98cb48c74f3c}
|
||||
#define NS_FILESPECWITHUI_CID \
|
||||
{ 0xe3326a80, 0x2816, 0x11d3, { 0xa7, 0xe5, 0x98, 0xcb, 0x48, 0xc7, 0x4f, 0x3c } }
|
||||
|
||||
#define NS_FILESPECWITHUI_PROGID "component://netscape/filespecwithui"
|
||||
#define NS_FILESPECWITHUI_CLASSNAME "nsIFileSpecWithUI"
|
||||
|
||||
// Factory methods
|
||||
inline nsIFileSpecWithUI* NS_CreateFileSpecWithUI()
|
||||
{
|
||||
nsIFileSpecWithUI* spec = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(
|
||||
(const char*)NS_FILESPECWITHUI_PROGID,
|
||||
(nsISupports*)nsnull,
|
||||
(const nsID&)nsIFileSpecWithUI::GetIID(),
|
||||
(void**)&spec);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "ERROR: Could not make a file spec.");
|
||||
return spec;
|
||||
}
|
||||
%}
|
||||
@@ -1,178 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIFileWidget_h__
|
||||
#define nsIFileWidget_h__
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
class nsIWidget;
|
||||
class nsIDeviceContext;
|
||||
class nsIAppShell;
|
||||
class nsIToolkit;
|
||||
|
||||
// {F8030015-C342-11d1-97F0-00609703C14E}
|
||||
#define NS_IFILEWIDGET_IID \
|
||||
{ 0xf8030015, 0xc342, 0x11d1, { 0x97, 0xf0, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
|
||||
/**
|
||||
* File selector mode
|
||||
*/
|
||||
|
||||
enum nsFileDlgMode {
|
||||
/// Load a file or directory
|
||||
eMode_load,
|
||||
/// Save a file or directory
|
||||
eMode_save,
|
||||
/// Select a fodler/directory
|
||||
eMode_getfolder
|
||||
};
|
||||
|
||||
|
||||
enum nsFileDlgResults {
|
||||
nsFileDlgResults_Cancel, // User hit cancel, ignore selection
|
||||
nsFileDlgResults_OK, // User hit Ok, process selection
|
||||
nsFileDlgResults_Replace // User acknowledged file already exists so ok to replace, process selection
|
||||
};
|
||||
|
||||
/**
|
||||
* File selector widget.
|
||||
* Modally selects files for loading or saving from a list.
|
||||
*/
|
||||
|
||||
class nsIFileWidget : public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFILEWIDGET_IID)
|
||||
|
||||
/**
|
||||
* Create the file filter. This differs from the standard
|
||||
* widget Create method because it passes in the mode
|
||||
*
|
||||
* @param aParent the parent to place this widget into
|
||||
* @param aTitle The title for the file widget
|
||||
* @param aMode load or save
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Create(nsIWidget *aParent,
|
||||
const nsString& aTitle,
|
||||
nsFileDlgMode aMode,
|
||||
nsIDeviceContext *aContext = nsnull,
|
||||
nsIAppShell *aAppShell = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
void *aInitData = nsnull) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Set the list of file filters
|
||||
*
|
||||
* @param aNumberOfFilter number of filters.
|
||||
* @param aTitle array of filter titles
|
||||
* @param aFilter array of filters to associate with titles
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[]) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Get the index into the filter list for the type of file the user wants to save
|
||||
*
|
||||
* @param theType the index into the filter list
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetSelectedType(PRInt16& theType) = 0;
|
||||
|
||||
/**
|
||||
* Show File Dialog. The dialog is displayed modally.
|
||||
*
|
||||
* @return PR_TRUE if user selects OK, PR_FALSE if user selects CANCEL
|
||||
*
|
||||
*/
|
||||
|
||||
virtual PRBool Show() = 0;
|
||||
|
||||
/**
|
||||
* Get the nsFileSpec for the file or directory.
|
||||
*
|
||||
* @param aFile on exit it contains the file or directory selected
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetFile(nsFileSpec& aFile) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Set the default string that appears in file open/save dialog
|
||||
*
|
||||
* @param aString the name of the file
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetDefaultString(const nsString& aString) = 0;
|
||||
|
||||
/**
|
||||
* Set the directory that the file open/save dialog initially displays
|
||||
*
|
||||
* @param aDirectory the name of the directory
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory) = 0;
|
||||
|
||||
/**
|
||||
* Get the directory that the file open/save dialog was last displaying
|
||||
*
|
||||
* @param aDirectory the name of the directory
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory) = 0;
|
||||
|
||||
|
||||
virtual nsFileDlgResults GetFile(
|
||||
nsIWidget * aParent,
|
||||
const nsString & promptString, // Window title for the dialog
|
||||
nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog
|
||||
|
||||
virtual nsFileDlgResults GetFolder(
|
||||
nsIWidget * aParent,
|
||||
const nsString & promptString, // Window title for the dialog
|
||||
nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog
|
||||
|
||||
virtual nsFileDlgResults PutFile(
|
||||
nsIWidget * aParent,
|
||||
const nsString & promptString, // Window title for the dialog
|
||||
nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog
|
||||
|
||||
};
|
||||
|
||||
#endif // nsIFileWidget_h__
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIFontNameIterator_h__
|
||||
#define nsIFontNameIterator_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsString;
|
||||
|
||||
// {CEEB39D1-0949-11d3-9A87-0050046CDA96}
|
||||
#define NS_IFONTNAMEITERATOR_IID \
|
||||
{ 0xceeb39d1, 0x949, 0x11d3, { 0x9a, 0x87, 0x0, 0x50, 0x4, 0x6c, 0xda, 0x96 } };
|
||||
|
||||
class nsIFontNameIterator : public nsISupports
|
||||
// Fonts are identified by strings, |Get| and |Advance| are distinct to facility wrapping
|
||||
// with C++ objects as standard iterators.
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONTNAMEITERATOR_IID)
|
||||
|
||||
NS_IMETHOD Reset() = 0;
|
||||
// does not need to be called initially, returns iterator to initial state
|
||||
|
||||
NS_IMETHOD Get( nsString* aFontName ) = 0;
|
||||
// returns an error when no more names are available
|
||||
|
||||
NS_IMETHOD Advance() = 0;
|
||||
// returns an error when no more names are available
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,50 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIFontRetrieverService_h__
|
||||
#define nsIFontRetrieverService_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIFontNameIterator;
|
||||
class nsIFontSizeIterator;
|
||||
class nsString;
|
||||
|
||||
// {285EF9B2-094A-11d3-9A87-0050046CDA96}
|
||||
#define NS_IFONTRETRIEVERSERVICE_IID \
|
||||
{ 0x285ef9b2, 0x94a, 0x11d3, { 0x9a, 0x87, 0x0, 0x50, 0x4, 0x6c, 0xda, 0x96 } };
|
||||
|
||||
class nsIFontRetrieverService : public nsISupports
|
||||
// This (singleton) service exists soley as a factory to manufacture iterators
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONTRETRIEVERSERVICE_IID)
|
||||
|
||||
NS_IMETHOD CreateFontNameIterator( nsIFontNameIterator** aIterator ) = 0;
|
||||
|
||||
NS_IMETHOD CreateFontSizeIterator( const nsString &aFontName, nsIFontSizeIterator** aIterator ) = 0;
|
||||
|
||||
NS_IMETHOD IsFontScalable( const nsString &aFontName, PRBool* aResult ) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,51 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIFontSizeIterator_h__
|
||||
#define nsIFontSizeIterator_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsString;
|
||||
|
||||
// {285EF9B1-094A-11d3-9A87-0050046CDA96}
|
||||
#define NS_IFONTSIZEITERATOR_IID \
|
||||
{ 0x285ef9b1, 0x94a, 0x11d3, { 0x9a, 0x87, 0x0, 0x50, 0x4, 0x6c, 0xda, 0x96 } };
|
||||
|
||||
class nsIFontSizeIterator : public nsISupports
|
||||
// Font sizes are identified with doubles (e.g., for the possibility of fractional sizes from MM, etc.).
|
||||
// |Get| and |Advance| are distinct to facility wrapping with C++ objects as standard iterators.
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONTSIZEITERATOR_IID)
|
||||
|
||||
NS_IMETHOD Reset() = 0;
|
||||
// does not need to be called initially, returns iterator to initial state
|
||||
|
||||
NS_IMETHOD Get( double* aFontSize ) = 0;
|
||||
// returns an error when no more sizes are available
|
||||
|
||||
NS_IMETHOD Advance() = 0;
|
||||
// returns an error when no more sizes are available
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,69 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISupportsArray.idl"
|
||||
|
||||
|
||||
[scriptable, uuid(948A0023-E3A7-11d2-96CF-0060B0FB9956)]
|
||||
interface nsIFormatConverter : nsISupports
|
||||
{
|
||||
/**
|
||||
* Get the list of the "input" data flavors (mime types as nsISupportsString),
|
||||
* in otherwords, the flavors that this converter can convert "from" (the
|
||||
* incoming data to the converter).
|
||||
*/
|
||||
nsISupportsArray getInputDataFlavors ( ) ;
|
||||
|
||||
/**
|
||||
* Get the list of the "output" data flavors (mime types as nsISupportsString),
|
||||
* in otherwords, the flavors that this converter can convert "to" (the
|
||||
* outgoing data to the converter).
|
||||
*
|
||||
* @param aDataFlavorList fills list with supported flavors
|
||||
*/
|
||||
nsISupportsArray getOutputDataFlavors ( ) ;
|
||||
|
||||
/**
|
||||
* Determines whether a converion from one flavor to another is supported
|
||||
*
|
||||
* @param aFromFormatConverter flavor to convert from
|
||||
* @param aFromFormatConverter flavor to convert to
|
||||
*/
|
||||
boolean canConvert ( in string aFromDataFlavor, in string aToDataFlavor ) ;
|
||||
|
||||
/**
|
||||
* Converts from one flavor to another.
|
||||
*
|
||||
* @param aFromFormatConverter flavor to convert from
|
||||
* @param aFromFormatConverter flavor to convert to (destination own the memory)
|
||||
* @returns returns NS_OK if it was converted
|
||||
*/
|
||||
void convert ( in string aFromDataFlavor, in nsISupports aFromData, in unsigned long aDataLen,
|
||||
in string aToDataFlavor, out nsISupports aToData, out unsigned long aDataToLen ) ;
|
||||
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
|
||||
%}
|
||||
@@ -1,60 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIKeyBindMgr_h__
|
||||
#define nsIKeyBindMgr_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
// {a91c0821-de58-11d2-b345-00a0cc3c1cde}
|
||||
#define NS_IKEYBINDMGR_IID \
|
||||
{ 0xa91c0821, 0xde58, 0x11d2, \
|
||||
{ 0xb3, 0x45, 0x0, 0xa0, 0xcc, 0x3c, 0x1c, 0xde } }
|
||||
|
||||
// {8B5314BD-DB01-11d2-96CE-0060B0FB9977}
|
||||
#define NS_KEYBINDMGR_CID \
|
||||
{ 0x8b5314bd, 0xdb01, 0x11d2, { 0x96, 0xce, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x77 } }
|
||||
|
||||
/**
|
||||
* Keyboard Binding utility.
|
||||
* Given a key event and a DOM node to search executes any 'key' command
|
||||
* that matches the event
|
||||
*/
|
||||
|
||||
class nsIKeyBindMgr : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IKEYBINDMGR_IID)
|
||||
|
||||
NS_IMETHOD ProcessKeyEvent(
|
||||
nsIDOMDocument * domDoc,
|
||||
const nsKeyEvent & theEvent,
|
||||
nsIWebShell * webShell,
|
||||
nsEventStatus & theStatus) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsIKeyBindMgr_h__
|
||||
@@ -1,91 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsILabel_h__
|
||||
#define nsILabel_h__
|
||||
|
||||
#include "nsIWidget.h"
|
||||
#include "nsString.h"
|
||||
|
||||
/* F3131891-3DC7-11d2-8DB8-00609703C14E */
|
||||
#define NS_ILABEL_IID \
|
||||
{ 0xf3131891, 0x3dc7, 0x11d2, \
|
||||
{ 0x8d, 0xb8, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
/**
|
||||
* Label Alignments
|
||||
*/
|
||||
|
||||
enum nsLabelAlignment {
|
||||
eAlign_Right,
|
||||
eAlign_Left,
|
||||
eAlign_Center
|
||||
};
|
||||
|
||||
struct nsLabelInitData : public nsWidgetInitData {
|
||||
nsLabelInitData()
|
||||
: mAlignment(eAlign_Left)
|
||||
{
|
||||
}
|
||||
|
||||
nsLabelAlignment mAlignment;
|
||||
};
|
||||
|
||||
/**
|
||||
* Label widget.
|
||||
* Automatically shows itself as depressed when clicked on.
|
||||
*/
|
||||
class nsILabel : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ILABEL_IID)
|
||||
|
||||
/**
|
||||
* Set the label
|
||||
*
|
||||
* @param Set the label to aText
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetLabel(const nsString &aText) = 0;
|
||||
|
||||
/**
|
||||
* Get the button label
|
||||
*
|
||||
* @param aBuffer contains label upon return
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetLabel(nsString &aBuffer) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Set the Label Alignemnt for creation
|
||||
*
|
||||
* @param aAlignment the alignment
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
NS_IMETHOD SetAlignment(nsLabelAlignment aAlignment) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,183 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIListBox_h__
|
||||
#define nsIListBox_h__
|
||||
|
||||
#include "nsIListWidget.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// {F8030014-C342-11d1-97F0-00609703C14E}
|
||||
#define NS_ILISTBOX_IID \
|
||||
{ 0xf8030014, 0xc342, 0x11d1, { 0x97, 0xf0, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
|
||||
/**
|
||||
* Initialize list box data
|
||||
*/
|
||||
|
||||
struct nsListBoxInitData : public nsWidgetInitData {
|
||||
nsListBoxInitData()
|
||||
: mMultiSelect(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
PRBool mMultiSelect;
|
||||
};
|
||||
|
||||
/**
|
||||
* Single or multi selection list of items.
|
||||
* Unlike a nsIWidget, The the list widget must automatically clear
|
||||
* itself to the background color when paint messages are generated.
|
||||
* The listbox always has a vertical scrollbar. It never has a
|
||||
* horizontal scrollbar.
|
||||
*/
|
||||
|
||||
class nsIListBox : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ILISTBOX_IID)
|
||||
|
||||
/**
|
||||
* Set an item at the specific position
|
||||
*
|
||||
* @param aItem the item name. The item has to be null terminated
|
||||
* @param aPosition the position the item should be inserted at
|
||||
* 0 is at the top of the list
|
||||
* -1 is at the end of the list
|
||||
*/
|
||||
NS_IMETHOD AddItemAt(nsString &aItem, PRInt32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Finds the first occurrence of the specified item
|
||||
*
|
||||
* @param aItem the string to be filled
|
||||
* @param aStartPos the starting position (index)
|
||||
* @return PR_TRUE if successful, PR_FALSE otherwise
|
||||
*
|
||||
*/
|
||||
virtual PRInt32 FindItem(nsString &aItem, PRInt32 aStartPos) = 0;
|
||||
|
||||
/**
|
||||
* Returns the number of items in the list
|
||||
*
|
||||
* @return the number of items
|
||||
*
|
||||
*/
|
||||
virtual PRInt32 GetItemCount() = 0;
|
||||
|
||||
/**
|
||||
* Remove the first occurrence of the specified item
|
||||
*
|
||||
* @param aPosition the item position
|
||||
* 0 is at the top of the list
|
||||
* -1 is at the end of the list
|
||||
*
|
||||
* @return PR_TRUE if successful, PR_FALSE otherwise
|
||||
*
|
||||
*/
|
||||
virtual PRBool RemoveItemAt(PRInt32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Gets an item at a specific location
|
||||
*
|
||||
* @param anItem on return contains the string of the item at that position
|
||||
* @param aPosition the Position of the item
|
||||
*
|
||||
*/
|
||||
virtual PRBool GetItemAt(nsString& anItem, PRInt32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Gets the selected item for a single selection list
|
||||
*
|
||||
* @param aItem on return contains the string of the selected item
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetSelectedItem(nsString &aItem) = 0;
|
||||
|
||||
/**
|
||||
* Returns with the index of the selected item
|
||||
*
|
||||
* @return PRInt32, index of selected item
|
||||
*
|
||||
*/
|
||||
virtual PRInt32 GetSelectedIndex() = 0;
|
||||
|
||||
/**
|
||||
* Select the item at the specified position
|
||||
*
|
||||
* @param PRInt32, the item position
|
||||
* 0 is at the top of the list
|
||||
* -1 is at the end of the list
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SelectItem(PRInt32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Deselects all the items in the list
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Deselect() = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Set the listbox to be multi-select.
|
||||
* @param aMultiple PR_TRUE can have multiple selections. PR_FALSE single
|
||||
* selections only.
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetMultipleSelection(PRBool aMultipleSelections) = 0;
|
||||
|
||||
/**
|
||||
* Return the number of selected items. For single selection list box this
|
||||
* @return the number of selected items
|
||||
* can be 1 or 0.
|
||||
*
|
||||
*/
|
||||
virtual PRInt32 GetSelectedCount() = 0;
|
||||
|
||||
/**
|
||||
* Retrieves the indices of the selected items.
|
||||
* @param aIndices Array to hold the selected items. Use GetSelectedCount to
|
||||
* determine how large the array needs to be.
|
||||
* @param aSize Size of the aIndices array
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetSelectedIndices(PRInt32 aIndices[], PRInt32 aSize) = 0;
|
||||
|
||||
/**
|
||||
* Sets the indices of the selected items.
|
||||
* @param aIndices Array to hold the selected items. Use GetSelectedCount to
|
||||
* determine how large the array needs to be.
|
||||
* @param aSize Size of the aIndices array
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetSelectedIndices(PRInt32 aIndices[], PRInt32 aSize) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsIListBox_h__
|
||||
|
||||
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIListWidget_h__
|
||||
#define nsIListWidget_h__
|
||||
|
||||
#include "nsIWidget.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// {F8030013-C342-11d1-97F0-00609703C14E}
|
||||
#define NS_ILISTWIDGET_IID \
|
||||
{ 0xf8030013, 0xc342, 0x11d1, { 0x97, 0xf0, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
/**
|
||||
*
|
||||
* Base class for nsIListBox and nsIComboBox
|
||||
*
|
||||
*/
|
||||
|
||||
class nsIListWidget : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ILISTWIDGET_IID)
|
||||
|
||||
/**
|
||||
* Set an item at the specific position
|
||||
*
|
||||
* @param aItem the item name. The item has to be null terminated
|
||||
* @param aPosition the position the item should be inserted at
|
||||
* 0 is at the top of the list
|
||||
* -1 is at the end of the list
|
||||
*/
|
||||
NS_IMETHOD AddItemAt(nsString &aItem, PRInt32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Finds the first occurrence of the specified item
|
||||
*
|
||||
* @param aItem the string to be filled
|
||||
* @param aStartPos the starting position (index)
|
||||
* @return PR_TRUE if successful, PR_FALSE otherwise
|
||||
*
|
||||
*/
|
||||
virtual PRInt32 FindItem(nsString &aItem, PRInt32 aStartPos) = 0;
|
||||
|
||||
/**
|
||||
* Returns the number of items in the list
|
||||
*
|
||||
* @return the number of items
|
||||
*
|
||||
*/
|
||||
virtual PRInt32 GetItemCount() = 0;
|
||||
|
||||
/**
|
||||
* Remove the first occurrence of the specified item
|
||||
*
|
||||
* @param aPosition the item position
|
||||
* 0 is at the top of the list
|
||||
* -1 is at the end of the list
|
||||
*
|
||||
* @return PR_TRUE if successful, PR_FALSE otherwise
|
||||
*
|
||||
*/
|
||||
virtual PRBool RemoveItemAt(PRInt32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Gets an item at a specific location
|
||||
*
|
||||
* @param anItem on return contains the string of the item at that position
|
||||
* @param aPosition the Position of the item
|
||||
*
|
||||
*/
|
||||
virtual PRBool GetItemAt(nsString& anItem, PRInt32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Gets the selected item for a single selection list
|
||||
*
|
||||
* @param aItem on return contains the string of the selected item
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetSelectedItem(nsString &aItem) = 0;
|
||||
|
||||
/**
|
||||
* Returns with the index of the selected item
|
||||
*
|
||||
* @return PRInt32, index of selected item
|
||||
*
|
||||
*/
|
||||
virtual PRInt32 GetSelectedIndex() = 0;
|
||||
|
||||
/**
|
||||
* Select the item at the specified position
|
||||
*
|
||||
* @param PRInt32, the item position
|
||||
* 0 is at the top of the list
|
||||
* -1 is at the end of the list
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SelectItem(PRInt32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Deselects all the items in the list
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Deselect() = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsIListWidget_h__
|
||||
|
||||
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef __nsILookAndFeel
|
||||
#define __nsILookAndFeel
|
||||
#include "nsISupports.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsFont.h"
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
#include "nsSize.h"
|
||||
#endif
|
||||
|
||||
|
||||
// {21B51DE1-21A3-11d2-B6E0-00805F8A2676}
|
||||
#define NS_ILOOKANDFEEL_IID \
|
||||
{ 0x21b51de1, 0x21a3, 0x11d2, \
|
||||
{ 0xb6, 0xe0, 0x0, 0x80, 0x5f, 0x8a, 0x26, 0x76 } }
|
||||
|
||||
class nsILookAndFeel: public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ILOOKANDFEEL_IID)
|
||||
|
||||
typedef enum {
|
||||
eColor_WindowBackground,
|
||||
eColor_WindowForeground,
|
||||
eColor_WidgetBackground,
|
||||
eColor_WidgetForeground,
|
||||
eColor_WidgetSelectBackground,
|
||||
eColor_WidgetSelectForeground,
|
||||
eColor_Widget3DHighlight,
|
||||
eColor_Widget3DShadow,
|
||||
eColor_TextBackground,
|
||||
eColor_TextForeground,
|
||||
eColor_TextSelectBackground,
|
||||
eColor_TextSelectForeground,
|
||||
|
||||
// New CSS 2 color definitions
|
||||
eColor_activeborder,
|
||||
eColor_activecaption,
|
||||
eColor_appworkspace,
|
||||
eColor_background,
|
||||
eColor_buttonface,
|
||||
eColor_buttonhighlight,
|
||||
eColor_buttonshadow,
|
||||
eColor_buttontext,
|
||||
eColor_captiontext,
|
||||
eColor_graytext,
|
||||
eColor_highlight,
|
||||
eColor_highlighttext,
|
||||
eColor_inactiveborder,
|
||||
eColor_inactivecaption,
|
||||
eColor_inactivecaptiontext,
|
||||
eColor_infobackground,
|
||||
eColor_infotext,
|
||||
eColor_menu,
|
||||
eColor_menutext,
|
||||
eColor_scrollbar,
|
||||
eColor_threeddarkshadow,
|
||||
eColor_threedface,
|
||||
eColor_threedhighlight,
|
||||
eColor_threedlightshadow,
|
||||
eColor_threedshadow,
|
||||
eColor_window,
|
||||
eColor_windowframe,
|
||||
eColor_windowtext
|
||||
|
||||
} nsColorID;
|
||||
|
||||
typedef enum {
|
||||
eMetric_WindowTitleHeight,
|
||||
eMetric_WindowBorderWidth,
|
||||
eMetric_WindowBorderHeight,
|
||||
eMetric_Widget3DBorder,
|
||||
eMetric_TextFieldBorder, // Native border size
|
||||
eMetric_TextFieldHeight,
|
||||
eMetric_TextVerticalInsidePadding, // needed only because of GTK
|
||||
eMetric_TextShouldUseVerticalInsidePadding, // needed only because of GTK
|
||||
eMetric_TextHorizontalInsideMinimumPadding,
|
||||
eMetric_TextShouldUseHorizontalInsideMinimumPadding, // needed only because of GTK
|
||||
eMetric_ButtonHorizontalInsidePaddingNavQuirks,
|
||||
eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks,
|
||||
eMetric_CheckboxSize,
|
||||
eMetric_RadioboxSize,
|
||||
|
||||
eMetric_ListShouldUseHorizontalInsideMinimumPadding, // needed only because of GTK
|
||||
eMetric_ListHorizontalInsideMinimumPadding,
|
||||
|
||||
eMetric_ListShouldUseVerticalInsidePadding, // needed only because of GTK
|
||||
eMetric_ListVerticalInsidePadding, // needed only because of GTK
|
||||
|
||||
eMetric_CaretBlinkTime, // default, may be overriden by OS
|
||||
eMetric_CaretWidthTwips
|
||||
} nsMetricID;
|
||||
|
||||
typedef enum {
|
||||
eMetricFloat_TextFieldVerticalInsidePadding,
|
||||
eMetricFloat_TextFieldHorizontalInsidePadding,
|
||||
eMetricFloat_TextAreaVerticalInsidePadding,
|
||||
eMetricFloat_TextAreaHorizontalInsidePadding,
|
||||
eMetricFloat_ListVerticalInsidePadding,
|
||||
eMetricFloat_ListHorizontalInsidePadding,
|
||||
eMetricFloat_ButtonVerticalInsidePadding,
|
||||
eMetricFloat_ButtonHorizontalInsidePadding
|
||||
} nsMetricFloatID;
|
||||
|
||||
|
||||
NS_IMETHOD GetColor(const nsColorID aID, nscolor &aColor) = 0;
|
||||
NS_IMETHOD GetMetric(const nsMetricID aID, PRInt32 & aMetric) = 0;
|
||||
NS_IMETHOD GetMetric(const nsMetricFloatID aID, float & aMetric) = 0;
|
||||
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
typedef enum {
|
||||
eMetricSize_TextField = 0,
|
||||
eMetricSize_TextArea = 1,
|
||||
eMetricSize_ListBox = 2,
|
||||
eMetricSize_ComboBox = 3,
|
||||
eMetricSize_Radio = 4,
|
||||
eMetricSize_CheckBox = 5,
|
||||
eMetricSize_Button = 6
|
||||
} nsMetricNavWidgetID;
|
||||
|
||||
typedef enum {
|
||||
eMetricSize_Courier = 0,
|
||||
eMetricSize_SansSerif = 1
|
||||
} nsMetricNavFontID;
|
||||
|
||||
// This method returns the actual (or nearest estimate)
|
||||
// of the Navigator size for a given form control for a given font
|
||||
// and font size. This is used in NavQuirks mode to see how closely
|
||||
// we match its size
|
||||
NS_IMETHOD GetNavSize(const nsMetricNavWidgetID aWidgetID,
|
||||
const nsMetricNavFontID aFontID,
|
||||
const PRInt32 aFontSize,
|
||||
nsSize &aSize) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define nsLAF nsILookAndFeel
|
||||
|
||||
#endif /* __nsILookAndFeel */
|
||||
@@ -1,190 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIMenu_h__
|
||||
#define nsIMenu_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIWebShell.h"
|
||||
|
||||
class nsIMenuBar;
|
||||
class nsIMenu;
|
||||
class nsIMenuItem;
|
||||
class nsIMenuListener;
|
||||
|
||||
// {35A3DEC1-4992-11d2-8DBA-00609703C14E}
|
||||
#define NS_IMENU_IID \
|
||||
{ 0x35a3dec1, 0x4992, 0x11d2, \
|
||||
{ 0x8d, 0xba, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
|
||||
/**
|
||||
* Menu widget
|
||||
*/
|
||||
class nsIMenu : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMENU_IID)
|
||||
|
||||
/**
|
||||
* Creates the Menu
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Create(nsISupports * aParent, const nsString &aLabel) = 0;
|
||||
|
||||
/**
|
||||
* Get the Menu's Parent
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetParent(nsISupports *&aParent) = 0;
|
||||
|
||||
/**
|
||||
* Get the Menu label
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetLabel(nsString &aText) = 0;
|
||||
|
||||
/**
|
||||
* Set the Menu label
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetLabel(const nsString &aText) = 0;
|
||||
|
||||
/**
|
||||
* Get the Menu Access Key
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetAccessKey(nsString &aText) = 0;
|
||||
|
||||
/**
|
||||
* Set the Menu Access Key
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetAccessKey(const nsString &aText) = 0;
|
||||
|
||||
/**
|
||||
* Set the Menu enabled state
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetEnabled(PRBool aIsEnabled) = 0;
|
||||
|
||||
/**
|
||||
* Get the Menu enabled state
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetEnabled(PRBool* aIsEnabled) = 0;
|
||||
|
||||
/**
|
||||
* Query if this is the help menu. Mostly for MacOS voodoo.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD IsHelpMenu(PRBool* aIsHelpMenu) = 0;
|
||||
|
||||
/**
|
||||
* Adds a Menu Item
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD AddItem(nsISupports* aItem) = 0;
|
||||
|
||||
/**
|
||||
* Adds a separator
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD AddSeparator() = 0;
|
||||
|
||||
/**
|
||||
* Returns the number of menu items
|
||||
* This does count separators as items
|
||||
*/
|
||||
NS_IMETHOD GetItemCount(PRUint32 &aCount) = 0;
|
||||
|
||||
/**
|
||||
* Returns a Menu or Menu Item at a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetItemAt(const PRUint32 aPos, nsISupports *& aMenuItem) = 0;
|
||||
|
||||
/**
|
||||
* Inserts a Menu Item at a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD InsertItemAt(const PRUint32 aPos, nsISupports * aMenuItem) = 0;
|
||||
|
||||
/**
|
||||
* Removes an Menu Item from a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD RemoveItem(const PRUint32 aPos) = 0;
|
||||
|
||||
/**
|
||||
* Removes all the Menu Items
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD RemoveAll() = 0;
|
||||
|
||||
/**
|
||||
* Gets Native MenuHandle
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetNativeData(void** aData) = 0;
|
||||
|
||||
/**
|
||||
* Sets Native MenuHandle
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetNativeData(void* aData) = 0;
|
||||
|
||||
/**
|
||||
* Adds menu listener for dynamic construction
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD AddMenuListener(nsIMenuListener * aMenuListener) = 0;
|
||||
|
||||
/**
|
||||
* Removes menu listener for dynamic construction
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD RemoveMenuListener(nsIMenuListener * aMenuListener) = 0;
|
||||
|
||||
/**
|
||||
* Set DOMNode
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetDOMNode(nsIDOMNode * aMenuNode) = 0;
|
||||
|
||||
/**
|
||||
* Set DOMElement
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetDOMElement(nsIDOMElement * aMenuElement) = 0;
|
||||
|
||||
/**
|
||||
* Set WebShell
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetWebShell(nsIWebShell * aWebShell) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,120 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIMenuBar_h__
|
||||
#define nsIMenuBar_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIMenu.h"
|
||||
#include "nsIWebShell.h"
|
||||
|
||||
class nsIWidget;
|
||||
|
||||
// {BC658C81-4BEB-11d2-8DBB-00609703C14E}
|
||||
#define NS_IMENUBAR_IID \
|
||||
{ 0xbc658c81, 0x4beb, 0x11d2, \
|
||||
{ 0x8d, 0xbb, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
/**
|
||||
* MenuBar widget
|
||||
*/
|
||||
class nsIMenuBar : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMENUBAR_IID)
|
||||
|
||||
/**
|
||||
* Creates the MenuBar
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Create(nsIWidget * aParent) = 0;
|
||||
|
||||
/**
|
||||
* Get the MenuBar's Parent
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetParent(nsIWidget *&aParent) = 0;
|
||||
|
||||
/**
|
||||
* Set the MenuBar's Parent
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetParent(nsIWidget *aParent) = 0;
|
||||
|
||||
/**
|
||||
* Adds the Menu
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD AddMenu(nsIMenu * aMenu) = 0;
|
||||
|
||||
/**
|
||||
* Returns the number of menus
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetMenuCount(PRUint32 &aCount) = 0;
|
||||
|
||||
/**
|
||||
* Returns a Menu Item at a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetMenuAt(const PRUint32 aCount, nsIMenu *& aMenu) = 0;
|
||||
|
||||
/**
|
||||
* Inserts a Menu at a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD InsertMenuAt(const PRUint32 aCount, nsIMenu *& aMenu) = 0;
|
||||
|
||||
/**
|
||||
* Removes an Menu from a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD RemoveMenu(const PRUint32 aCount) = 0;
|
||||
|
||||
/**
|
||||
* Removes all the Menus
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD RemoveAll() = 0;
|
||||
|
||||
/**
|
||||
* Gets Native MenuHandle
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetNativeData(void*& aData) = 0;
|
||||
|
||||
/**
|
||||
* Sets Native MenuHandle. Temporary hack for mac until
|
||||
* nsMenuBar does it's own construction
|
||||
*/
|
||||
NS_IMETHOD SetNativeData(void* aData) = 0;
|
||||
|
||||
/**
|
||||
* Draw the menubar
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Paint() = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,189 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIMenuItem_h__
|
||||
#define nsIMenuItem_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
// {7F045771-4BEB-11d2-8DBB-00609703C14E}
|
||||
#define NS_IMENUITEM_IID \
|
||||
{ 0x7f045771, 0x4beb, 0x11d2, \
|
||||
{ 0x8d, 0xbb, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
class nsIMenu;
|
||||
class nsIPopUpMenu;
|
||||
class nsIWidget;
|
||||
class nsIMenuListener;
|
||||
|
||||
enum {
|
||||
knsMenuItemNoModifier = 0,
|
||||
knsMenuItemShiftModifier = (1 << 0),
|
||||
knsMenuItemAltModifier = (1 << 1),
|
||||
knsMenuItemControlModifier = (1 << 2),
|
||||
knsMenuItemCommandModifier = (1 << 3)
|
||||
};
|
||||
|
||||
/**
|
||||
* MenuItem widget
|
||||
*/
|
||||
class nsIMenuItem : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMENUITEM_IID)
|
||||
|
||||
/**
|
||||
* Creates the MenuItem
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Create(nsISupports * aParent,
|
||||
const nsString & aLabel,
|
||||
PRBool isSeparator) = 0;
|
||||
|
||||
/**
|
||||
* Get the MenuItem label
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetLabel(nsString &aText) = 0;
|
||||
|
||||
/**
|
||||
* Get the MenuItem label
|
||||
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetLabel(nsString &aText) = 0;
|
||||
|
||||
/**
|
||||
* Set the Menu shortcut char
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetShortcutChar(const nsString &aText) = 0;
|
||||
|
||||
/**
|
||||
* Get the Menu shortcut char
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetShortcutChar(nsString &aText) = 0;
|
||||
/**
|
||||
* Sets whether the item is enabled or disabled
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetEnabled(PRBool aIsEnabled) = 0;
|
||||
|
||||
/**
|
||||
* Gets whether the item is enabled or disabled
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetEnabled(PRBool *aIsEnabled) = 0;
|
||||
|
||||
/**
|
||||
* Sets whether the item is checked or not
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetChecked(PRBool aIsEnabled) = 0;
|
||||
|
||||
/**
|
||||
* Gets whether the item is checked or not
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetChecked(PRBool *aIsEnabled) = 0;
|
||||
|
||||
/**
|
||||
* Sets whether the item is a checkbox type
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetCheckboxType(PRBool aIsCheckbox) = 0;
|
||||
|
||||
/**
|
||||
* Gets whether the item is a checkbox type
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetCheckboxType(PRBool *aIsCheckbox) = 0;
|
||||
|
||||
/**
|
||||
* Gets the MenuItem Command identifier
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetCommand(PRUint32 & aCommand) = 0;
|
||||
|
||||
/**
|
||||
* Gets the target for MenuItem
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetTarget(nsIWidget *& aTarget) = 0;
|
||||
|
||||
/**
|
||||
* Gets Native Menu Handle
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetNativeData(void*& aData) = 0;
|
||||
|
||||
/**
|
||||
* Adds menu listener
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD AddMenuListener(nsIMenuListener * aMenuListener) = 0;
|
||||
|
||||
/**
|
||||
* Removes menu listener
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD RemoveMenuListener(nsIMenuListener * aMenuListener) = 0;
|
||||
|
||||
/**
|
||||
* Indicates whether it is a separator
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD IsSeparator(PRBool & aIsSep) = 0;
|
||||
|
||||
/**
|
||||
* Sets the JavaScript Command to be invoked when a "gui" event occurs on a source widget
|
||||
* @param aStrCmd the JS command to be cached for later execution
|
||||
* @return NS_OK
|
||||
*/
|
||||
NS_IMETHOD SetCommand(const nsString & aStrCmd) = 0;
|
||||
|
||||
/**
|
||||
* Executes the "cached" JavaScript Command
|
||||
* @return NS_OK if the command was executed properly, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD DoCommand() = 0;
|
||||
|
||||
NS_IMETHOD SetDOMNode(nsIDOMNode * aDOMNode) = 0;
|
||||
NS_IMETHOD GetDOMNode(nsIDOMNode ** aDOMNode) = 0;
|
||||
NS_IMETHOD SetDOMElement(nsIDOMElement * aDOMElement) = 0;
|
||||
NS_IMETHOD GetDOMElement(nsIDOMElement ** aDOMElement) = 0;
|
||||
NS_IMETHOD SetWebShell(nsIWebShell * aWebShell) = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetModifiers(PRUint8 aModifiers) = 0;
|
||||
NS_IMETHOD GetModifiers(PRUint8 * aModifiers) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,85 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIMenuListener_h__
|
||||
#define nsIMenuListener_h__
|
||||
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
// TODO: This needs to be generated!
|
||||
// {BC658C81-4BEB-11d2-8DBB-00609703C14E}
|
||||
#define NS_IMENULISTENER_IID \
|
||||
{ 0xbc658c81, 0x4beb, 0x11d2, \
|
||||
{ 0x8d, 0xbb, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x9e } }
|
||||
|
||||
static NS_DEFINE_IID(kIMenuListenerIID, NS_IMENULISTENER_IID);
|
||||
|
||||
/**
|
||||
*
|
||||
* Menu event listener
|
||||
* This interface should only be implemented by the menu manager
|
||||
* These are registered with nsWindows to recieve menu events
|
||||
*/
|
||||
|
||||
class nsIMenuListener : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMENULISTENER_IID)
|
||||
|
||||
/**
|
||||
* Processes a menu item selected event
|
||||
* @param aMenuEvent See nsGUIEvent.h
|
||||
* @return whether the event was consumed or ignored. See nsEventStatus
|
||||
*/
|
||||
virtual nsEventStatus MenuItemSelected(const nsMenuEvent & aMenuEvent) = 0;
|
||||
|
||||
/**
|
||||
* Processes a menu selected event
|
||||
* @param aMenuEvent See nsGUIEvent.h
|
||||
* @return whether the event was consumed or ignored. See nsEventStatus
|
||||
*/
|
||||
virtual nsEventStatus MenuSelected(const nsMenuEvent & aMenuEvent) = 0;
|
||||
|
||||
/**
|
||||
* Processes a menu deselect event
|
||||
* @param aMenuEvent See nsGUIEvent.h
|
||||
* @return whether the event was consumed or ignored. See nsEventStatus
|
||||
*/
|
||||
virtual nsEventStatus MenuDeselected(const nsMenuEvent & aMenuEvent) = 0;
|
||||
|
||||
virtual nsEventStatus MenuConstruct(
|
||||
|
||||
const nsMenuEvent & aMenuEvent,
|
||||
|
||||
nsIWidget * aParentWindow,
|
||||
|
||||
void * menubarNode,
|
||||
|
||||
void * aWebShell) = 0;
|
||||
|
||||
|
||||
|
||||
virtual nsEventStatus MenuDestruct(const nsMenuEvent & aMenuEvent) = 0;
|
||||
};
|
||||
|
||||
#endif // nsIMenuListener_h__
|
||||
@@ -1,75 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
|
||||
#ifndef nsIMouseListener_h__
|
||||
#define nsIMouseListener_h__
|
||||
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* Mouse up/down/move event listener
|
||||
*
|
||||
*/
|
||||
|
||||
// {c83f6b81-d7ce-11d2-8360-c4c894c4917c}
|
||||
#define NS_IMOUSELISTENER_IID \
|
||||
{ 0xc83f6b81, 0xd7ce, 0x11d2, { 0x83, 0x60, 0xc4, 0xc8, 0x94, 0xc4, 0x91, 0x7c } }
|
||||
|
||||
class nsIMouseListener : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMOUSELISTENER_IID)
|
||||
|
||||
/**
|
||||
* Processes a mouse pressed event
|
||||
* @param aMouseEvent See nsGUIEvent.h
|
||||
* @return whether the event was consumed or ignored. See nsEventStatus
|
||||
*/
|
||||
virtual nsEventStatus MousePressed(const nsGUIEvent & aMouseEvent) = 0;
|
||||
|
||||
/**
|
||||
* Processes a mouse release event
|
||||
* @param aMouseEvent See nsGUIEvent.h
|
||||
* @return whether the event was consumed or ignored. See nsEventStatus
|
||||
*/
|
||||
virtual nsEventStatus MouseReleased(const nsGUIEvent & aMouseEvent) = 0;
|
||||
|
||||
/**
|
||||
* Processes a mouse clicked event
|
||||
* @param aMouseEvent See nsGUIEvent.h
|
||||
* @return whether the event was consumed or ignored. See nsEventStatus
|
||||
*
|
||||
*/
|
||||
virtual nsEventStatus MouseClicked(const nsGUIEvent & aMouseEvent) = 0;
|
||||
|
||||
/**
|
||||
* Processes a mouse moved event
|
||||
* @param aMouseEvent See nsGUIEvent.h
|
||||
* @return whether the event was consumed or ignored. See nsEventStatus
|
||||
*/
|
||||
virtual nsEventStatus MouseMoved(const nsGUIEvent & aMouseEvent) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsIMouseListener_h__
|
||||
@@ -1,138 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIPopUpMenu_h__
|
||||
#define nsIPopUpMenu_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIMenuItem.h"
|
||||
|
||||
class nsIMenu;
|
||||
class nsIWidget;
|
||||
|
||||
// {F6CD4F21-53AF-11d2-8DC4-00609703C14E}
|
||||
#define NS_IPOPUPMENU_IID \
|
||||
{ 0xf6cd4f21, 0x53af, 0x11d2, \
|
||||
{ 0x8d, 0xc4, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
/**
|
||||
* PopUpMenu widget
|
||||
*/
|
||||
class nsIPopUpMenu : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPOPUPMENU_IID)
|
||||
|
||||
/**
|
||||
* Creates the PopUpMenu
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Create(nsIWidget * aParent) = 0;
|
||||
|
||||
/**
|
||||
* Adds a PopUpMenu Item
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD AddItem(const nsString &aText) = 0;
|
||||
|
||||
/**
|
||||
* Adds a PopUpMenu Item
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD AddItem(nsIMenuItem * aMenuItem) = 0;
|
||||
|
||||
/**
|
||||
* Adds a Cascading PopUpMenu
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD AddMenu(nsIMenu * aMenu) = 0;
|
||||
|
||||
/**
|
||||
* Adds Separator
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD AddSeparator() = 0;
|
||||
|
||||
/**
|
||||
* Returns the number of menu items
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetItemCount(PRUint32 &aCount) = 0;
|
||||
|
||||
/**
|
||||
* Returns a PopUpMenu Item at a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem) = 0;
|
||||
|
||||
/**
|
||||
* Inserts a PopUpMenu Item at a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD InsertItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem) = 0;
|
||||
|
||||
/**
|
||||
* Creates and inserts a PopUpMenu Item at a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD InsertItemAt(const PRUint32 aCount, const nsString & aMenuItemName) = 0;
|
||||
|
||||
/**
|
||||
* Creates and inserts a Separator at a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD InsertSeparator(const PRUint32 aCount) = 0;
|
||||
|
||||
/**
|
||||
* Removes an PopUpMenu Item from a specified Index
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD RemoveItem(const PRUint32 aCount) = 0;
|
||||
|
||||
/**
|
||||
* Removes all the PopUpMenu Items
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD RemoveAll() = 0;
|
||||
|
||||
/**
|
||||
* Shows menu and waits for action
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD ShowMenu(PRInt32 aX, PRInt32 aY) = 0;
|
||||
|
||||
/**
|
||||
* Gets Native MenuHandle
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetNativeData(void*& aData) = 0;
|
||||
|
||||
/**
|
||||
* Gets parent widget
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetParent(nsIWidget *& aParent) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,80 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIRadioButton_h__
|
||||
#define nsIRadioButton_h__
|
||||
|
||||
#include "nsIButton.h"
|
||||
|
||||
#define NS_IRADIOBUTTON_IID \
|
||||
{ 0x18032ad4, 0xb265, 0x11d2, \
|
||||
{ 0xaa, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
/**
|
||||
* RadioButton widget. Can show itself in a checked or unchecked state.
|
||||
* The RadioButton widget automatically shows itself checked or unchecked when clicked on.
|
||||
*/
|
||||
|
||||
class nsIRadioButton : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRADIOBUTTON_IID)
|
||||
|
||||
/**
|
||||
* Set the button label
|
||||
*
|
||||
* @param aText button label
|
||||
* @result set to NS_OK if method successful
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetLabel(const nsString &aText) = 0;
|
||||
|
||||
/**
|
||||
* Get the button label
|
||||
*
|
||||
* @param aBuffer contains label upon return
|
||||
* @result set to NS_OK if method successful
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetLabel(nsString &aBuffer) = 0;
|
||||
|
||||
/**
|
||||
* Set the check state.
|
||||
* @param aState PR_TRUE show as checked. PR_FALSE show unchecked.
|
||||
* @result set to NS_OK if method successful
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetState(const PRBool aState) = 0;
|
||||
|
||||
/**
|
||||
* Get the check state.
|
||||
* @param aState PR_TRUE if checked. PR_FALSE if unchecked.
|
||||
* @result set to NS_OK if method successful
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetState(PRBool& aState) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsIRadioButton_h__
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Rod Spears <rods@netscape.com>
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[uuid(23C2BA03-6C76-11d3-96ED-0060B0FB9956)]
|
||||
interface nsIRollupListener : nsISupports
|
||||
{
|
||||
/**
|
||||
* Notifies the object to rollup
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
void Rollup();
|
||||
};
|
||||
@@ -1,124 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIScrollbar_h__
|
||||
#define nsIScrollbar_h__
|
||||
|
||||
#include "nsIWidget.h"
|
||||
|
||||
// {18032AD2-B265-11d1-AA2A-000000000000}
|
||||
#define NS_ISCROLLBAR_IID \
|
||||
{ 0x18032ad2, 0xb265, 0x11d1, \
|
||||
{ 0xaa, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Scrollbar, converts mouse input into values that can be used
|
||||
* to shift the contents of a window.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
class nsIScrollbar : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISCROLLBAR_IID)
|
||||
|
||||
/**
|
||||
* Set the scrollbar range
|
||||
* @param aEndRange set range for scrollbar from 0 to aEndRange
|
||||
* @result NS_Ok if no errors
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetMaxRange(PRUint32 aEndRange) = 0;
|
||||
|
||||
/**
|
||||
* Get the scrollbar range
|
||||
* @return the upper end of the scrollbar range
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
NS_IMETHOD GetMaxRange(PRUint32& aMaxRange) = 0;
|
||||
|
||||
/**
|
||||
* Set the thumb position.
|
||||
* @param aPos a value between (startRange) and (endRange - thumbSize)
|
||||
* @result NS_Ok if no errors
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetPosition(PRUint32 aPos) = 0;
|
||||
|
||||
/**
|
||||
* Get the thumb position.
|
||||
* @return a value between (startRange) and (endRange - thumbSize)
|
||||
* @result NS_Ok if no errors
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetPosition(PRUint32& aPos) = 0;
|
||||
|
||||
/**
|
||||
* Set the thumb size.
|
||||
* @param aSize size of the thumb. Must be a value between
|
||||
* startRange and endRange
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
NS_IMETHOD SetThumbSize(PRUint32 aSize) = 0;
|
||||
|
||||
/**
|
||||
* Get the thumb size.
|
||||
* @return size of the thumb. The value is between
|
||||
* startRange and endRange
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
NS_IMETHOD GetThumbSize(PRUint32& aSize) = 0;
|
||||
|
||||
/**
|
||||
* Set the line increment.
|
||||
* @param aSize size of the line increment. The value must
|
||||
* be between startRange and endRange
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
NS_IMETHOD SetLineIncrement(PRUint32 aSize) = 0;
|
||||
|
||||
/**
|
||||
* Get the line increment.
|
||||
* @return size of the line increment. The value is
|
||||
* between startRange and endRange
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
NS_IMETHOD GetLineIncrement(PRUint32& aSize) = 0;
|
||||
|
||||
/**
|
||||
* Set all scrollbar parameters at once
|
||||
* @param aMaxRange set range for scrollbar from 0 to aMaxRange
|
||||
* @param aThumbSize size of the thumb. Must be a value between
|
||||
* startRange and endRange
|
||||
* @param aPosition a value between (startRange) and (endRange - thumbSize)
|
||||
* @param aLineIncrement size of the line increment. The value must
|
||||
* be between startRange and endRange
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize,
|
||||
PRUint32 aPosition, PRUint32 aLineIncrement) = 0;
|
||||
};
|
||||
|
||||
#endif // nsIScrollbar_h__
|
||||
@@ -1,43 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIFileSpec.idl"
|
||||
|
||||
[scriptable, uuid(B148EED1-236D-11d3-B35C-00A0CC3C1CDE)]
|
||||
interface nsISound : nsISupports
|
||||
{
|
||||
void Init();
|
||||
|
||||
void Play(in nsIFileSpec filespec);
|
||||
// void Stop();
|
||||
|
||||
void Beep();
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
|
||||
extern nsresult
|
||||
NS_NewSound(nsISound** aSound);
|
||||
|
||||
%}
|
||||
@@ -1,158 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsITextAreaWidget_h__
|
||||
#define nsITextAreaWidget_h__
|
||||
|
||||
#include "nsIWidget.h"
|
||||
#include "nsITextWidget.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// {F8030012-C342-11d1-97F0-00609703C14E}
|
||||
#define NS_ITEXTAREAWIDGET_IID \
|
||||
{ 0xf8030012, 0xc342, 0x11d1, { 0x97, 0xf0, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
/**
|
||||
* Multi-line text editor.
|
||||
* See nsITextWidget for capabilities.
|
||||
* Displays a scrollbar when the text content exceeds the number of lines
|
||||
* displayed.
|
||||
* Unlike a nsIWidget, The textarea must automatically clear
|
||||
* itself to the background color when paint messages are generated.
|
||||
*/
|
||||
|
||||
class nsITextAreaWidget : public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITEXTAREAWIDGET_IID)
|
||||
|
||||
/**
|
||||
* Get the text of this component.
|
||||
*
|
||||
* @param aTextBuffer on return contains the text of this component
|
||||
* @param aBufferSize the size of the buffer passed in
|
||||
* @param aActualSize the number of char copied
|
||||
* @result NS_Ok if no errors
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetText(nsString &aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize) = 0;
|
||||
|
||||
/**
|
||||
* Set the text of this component.
|
||||
*
|
||||
* @param aText -- an object containing a copy of the text
|
||||
* @return the number of chars in the text string
|
||||
* @result NS_Ok if no errors
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetText(const nsString &aText, PRUint32& aActualSize) = 0;
|
||||
|
||||
/**
|
||||
* Insert text into this component.
|
||||
* When aStartPos and aEndPos are a valid range this function performs a replace.
|
||||
* When aStartPos and aEndPos are equal this function performs an insert.
|
||||
* When aStartPos and aEndPos are both -1 (0xFFFFFFFF) this function performs an append.
|
||||
* If aStartPos and aEndPos are out of range they are rounded to the closest end.
|
||||
*
|
||||
* @param aText the text to set
|
||||
* @param aStartPos starting position for inserting text
|
||||
* @param aEndPos ending position for inserting text
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize) = 0;
|
||||
|
||||
/**
|
||||
* Remove any content from this text widget
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD RemoveText(void) = 0;
|
||||
|
||||
/**
|
||||
* Sets the maximum number of characters the widget can hold
|
||||
*
|
||||
* @param aChars maximum number of characters for this widget. if 0 then there isn't any limit
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetMaxTextLength(PRUint32 aChars) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Set the text widget to be read-only
|
||||
*
|
||||
* @param aReadOnlyFlag PR_TRUE the widget is read-only,
|
||||
* PR_FALSE indicates the widget is writable.
|
||||
* @param PR_TRUE if it was read only. PR_FALSE if it was writable
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetReadOnly(PRBool aNewReadOnlyFlag, PRBool& aOldReadOnlyFlag) = 0;
|
||||
|
||||
/**
|
||||
* Select all of the contents
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD SelectAll() = 0;
|
||||
|
||||
/**
|
||||
* Set the selection in this text component
|
||||
* @param aStartSel starting selection position in characters
|
||||
* @param aEndSel ending selection position in characters
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetSelection(PRUint32 aStartSel, PRUint32 aEndSel) = 0;
|
||||
|
||||
/**
|
||||
* Get the selection in this text component
|
||||
* @param aStartSel starting selection position in characters
|
||||
* @param aEndSel ending selection position in characters
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel) = 0;
|
||||
|
||||
/**
|
||||
* Set the caret position
|
||||
* @param aPosition caret position in characters
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetCaretPosition(PRUint32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Get the caret position
|
||||
* @return caret position in characters
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetCaretPosition(PRUint32& aPosition) = 0;
|
||||
};
|
||||
|
||||
#endif // nsITextAreaWidget_h__
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsITextWidget_h__
|
||||
#define nsITextWidget_h__
|
||||
|
||||
#include "nsIWidget.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// {F8030011-C342-11d1-97F0-00609703C14E}
|
||||
#define NS_ITEXTWIDGET_IID \
|
||||
{ 0xf8030011, 0xc342, 0x11d1, { 0x97, 0xf0, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
|
||||
struct nsTextWidgetInitData : public nsWidgetInitData {
|
||||
nsTextWidgetInitData()
|
||||
: mIsPassword(PR_FALSE),
|
||||
mIsReadOnly(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
PRBool mIsPassword;
|
||||
PRBool mIsReadOnly;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Single line text editor.
|
||||
* Unlike a nsIWidget, The text editor must automatically clear
|
||||
* itself to the background color when paint messages are generated.
|
||||
*
|
||||
*/
|
||||
|
||||
class nsITextWidget : public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITEXTWIDGET_IID)
|
||||
|
||||
/**
|
||||
* Get the text of this component.
|
||||
*
|
||||
* @param aTextBuffer on return contains the text of this component
|
||||
* @param aBufferSize the size of the buffer passed in
|
||||
* @param aActualSize the number of char copied
|
||||
* @result NS_Ok if no errors
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetText(nsString &aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize) = 0;
|
||||
|
||||
/**
|
||||
* Set the text of this component.
|
||||
*
|
||||
* @param aText -- an object containing a copy of the text
|
||||
* @return the number of chars in the text string
|
||||
* @result NS_Ok if no errors
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetText(const nsString &aText, PRUint32& aActualSize) = 0;
|
||||
|
||||
/**
|
||||
* Insert text into this component.
|
||||
* When aStartPos and aEndPos are a valid range this function performs a replace.
|
||||
* When aStartPos and aEndPos are equal this function performs an insert.
|
||||
* When aStartPos and aEndPos are both -1 (0xFFFFFFFF) this function performs an append.
|
||||
* If aStartPos and aEndPos are out of range they are rounded to the closest end.
|
||||
*
|
||||
* @param aText the text to set
|
||||
* @param aStartPos starting position for inserting text
|
||||
* @param aEndPos ending position for inserting text
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize) = 0;
|
||||
|
||||
/**
|
||||
* Remove any content from this text widget
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD RemoveText(void) = 0;
|
||||
|
||||
/**
|
||||
* Indicates a password will be entered.
|
||||
*
|
||||
* @param aIsPassword PR_TRUE shows contents as asterisks. PR_FALSE shows
|
||||
* contents as normal text.
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetPassword(PRBool aIsPassword) = 0;
|
||||
|
||||
/**
|
||||
* Sets the maximum number of characters the widget can hold
|
||||
*
|
||||
* @param aChars maximum number of characters for this widget. if 0 then there isn't any limit
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetMaxTextLength(PRUint32 aChars) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Set the text widget to be read-only
|
||||
*
|
||||
* @param aReadOnlyFlag PR_TRUE the widget is read-only,
|
||||
* PR_FALSE indicates the widget is writable.
|
||||
* @param PR_TRUE if it was read only. PR_FALSE if it was writable
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetReadOnly(PRBool aNewReadOnlyFlag, PRBool& aOldReadOnlyFlag) = 0;
|
||||
|
||||
/**
|
||||
* Select all of the contents
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD SelectAll() = 0;
|
||||
|
||||
/**
|
||||
* Set the selection in this text component
|
||||
* @param aStartSel starting selection position in characters
|
||||
* @param aEndSel ending selection position in characters
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetSelection(PRUint32 aStartSel, PRUint32 aEndSel) = 0;
|
||||
|
||||
/**
|
||||
* Get the selection in this text component
|
||||
* @param aStartSel starting selection position in characters
|
||||
* @param aEndSel ending selection position in characters
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel) = 0;
|
||||
|
||||
/**
|
||||
* Set the caret position
|
||||
* @param aPosition caret position in characters
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetCaretPosition(PRUint32 aPosition) = 0;
|
||||
|
||||
/**
|
||||
* Get the caret position
|
||||
* @return caret position in characters
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetCaretPosition(PRUint32& aPosition) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsITextWidget_h__
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{ C++
|
||||
#include "prthread.h"
|
||||
%}
|
||||
|
||||
[ptr] native PRThread(PRThread);
|
||||
|
||||
|
||||
[uuid(18032BD0-B265-11d1-AA2A-000000000000)]
|
||||
interface nsIToolkit : nsISupports
|
||||
{
|
||||
/**
|
||||
* Initialize this toolkit with aThread.
|
||||
* @param aThread The thread passed in runs the message pump.
|
||||
* NULL can be passed in, in which case a new thread gets created
|
||||
* and a message pump will run in that thread
|
||||
*
|
||||
*/
|
||||
void Init(in PRThread aThread);
|
||||
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
extern NS_METHOD NS_GetCurrentToolkit(nsIToolkit* *aResult);
|
||||
%}
|
||||
@@ -1,123 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
|
||||
* Communications Corp. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Pinkerton
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISupportsArray.idl"
|
||||
#include "nsIFormatConverter.idl"
|
||||
|
||||
|
||||
%{ C++
|
||||
|
||||
// these probably shouldn't live here, but in some central repository shared
|
||||
// by the entire app.
|
||||
#define kTextMime "text/plain"
|
||||
#define kXIFMime "text/xif"
|
||||
#define kUnicodeMime "text/unicode"
|
||||
#define kHTMLMime "text/html"
|
||||
#define kAOLMailMime "AOLMAIL"
|
||||
#define kPNGImageMime "image/png"
|
||||
#define kJPEGImageMime "image/jpg"
|
||||
#define kGIFImageMime "image/gif"
|
||||
#define kDropFilesMime "text/dropfiles"
|
||||
|
||||
%}
|
||||
|
||||
|
||||
[scriptable, uuid(8B5314BC-DB01-11d2-96CE-0060B0FB9956)]
|
||||
interface nsITransferable : nsISupports
|
||||
{
|
||||
/**
|
||||
* Computes a list of flavors (mime types as nsISupportsString) that the transferable
|
||||
* can export, either through intrinsic knowledge or output data converters.
|
||||
*
|
||||
* @param aDataFlavorList fills list with supported flavors. This is a copy of
|
||||
* the internal list, so it may be edited w/out affecting the transferable.
|
||||
*/
|
||||
nsISupportsArray flavorsTransferableCanExport ( ) ;
|
||||
|
||||
/**
|
||||
* Given a flavor retrieve the data.
|
||||
*
|
||||
* @param aFlavor (in parameter) the flavor of data to retrieve
|
||||
* @param aData the data. Some variant of class in nsISupportsPrimitives.idl
|
||||
* @param aDataLen the length of the data
|
||||
*/
|
||||
void getTransferData ( in string aFlavor, out nsISupports aData, out unsigned long aDataLen ) ;
|
||||
|
||||
/**
|
||||
* Returns the best flavor in the transferable, given those that have
|
||||
* been added to it with |AddFlavor()|
|
||||
*
|
||||
* @param aFlavor (out parameter) the flavor of data that was retrieved
|
||||
* @param aData the data. Some variant of class in nsISupportsPrimitives.idl
|
||||
* @param aDataLen the length of the data
|
||||
*/
|
||||
void getAnyTransferData ( out string aFlavor, out nsISupports aData, out unsigned long aDataLen ) ;
|
||||
|
||||
/**
|
||||
* Returns true if the data is large.
|
||||
*/
|
||||
boolean isLargeDataSet ( ) ;
|
||||
|
||||
///////////////////////////////
|
||||
// Setter part of interface
|
||||
///////////////////////////////
|
||||
|
||||
/**
|
||||
* Computes a list of flavors (mime types as nsISupportsString) that the transferable can
|
||||
* accept into it, either through intrinsic knowledge or input data converters.
|
||||
*
|
||||
* @param outFlavorList fills list with supported flavors. This is a copy of
|
||||
* the internal list, so it may be edited w/out affecting the transferable.
|
||||
*/
|
||||
nsISupportsArray flavorsTransferableCanImport ( ) ;
|
||||
|
||||
/**
|
||||
* Sets the data in the transferable with the specified flavor. The transferable
|
||||
* will maintain its own copy the data, so it is not necessary to do that beforehand.
|
||||
*
|
||||
* @param aFlavor the flavor of data that is being set
|
||||
* @param aData the data, some variant of class in nsISupportsPrimitives.idl
|
||||
* @param aDataLen the length of the data
|
||||
*/
|
||||
void setTransferData ( in string aFlavor, in nsISupports aData, in unsigned long aDataLen ) ;
|
||||
|
||||
/**
|
||||
* Add the data flavor, indicating that this transferable
|
||||
* can receive this type of flavor
|
||||
*
|
||||
* @param aDataFlavor a new data flavor to handle
|
||||
*/
|
||||
void addDataFlavor ( in string aDataFlavor ) ;
|
||||
|
||||
/**
|
||||
* Removes the data flavor matching the given one (string compare) and the data
|
||||
* that goes along with it.
|
||||
*
|
||||
* @param aDataFlavor a data flavor to remove
|
||||
*/
|
||||
void removeDataFlavor ( in string aDataFlavor ) ;
|
||||
|
||||
attribute nsIFormatConverter converter;
|
||||
|
||||
};
|
||||
|
||||
@@ -1,725 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIWidget_h__
|
||||
#define nsIWidget_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsIMouseListener.h"
|
||||
#include "nsIMenuListener.h"
|
||||
#include "nsIImage.h"
|
||||
|
||||
#include "prthread.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
// forward declarations
|
||||
class nsIAppShell;
|
||||
class nsIToolkit;
|
||||
class nsIFontMetrics;
|
||||
class nsIToolkit;
|
||||
class nsIRenderingContext;
|
||||
class nsIEnumerator;
|
||||
class nsIDeviceContext;
|
||||
struct nsRect;
|
||||
struct nsFont;
|
||||
class nsIMenuBar;
|
||||
class nsIEventListener;
|
||||
class nsIRollupListener;
|
||||
|
||||
/**
|
||||
* Callback function that processes events.
|
||||
* The argument is actually a subtype (subclass) of nsEvent which carries
|
||||
* platform specific information about the event. Platform specific code knows
|
||||
* how to deal with it.
|
||||
* The return value determines whether or not the default action should take place.
|
||||
*/
|
||||
|
||||
typedef nsEventStatus (*PR_CALLBACK EVENT_CALLBACK)(nsGUIEvent *event);
|
||||
|
||||
/**
|
||||
* Flags for the getNativeData function.
|
||||
* See getNativeData()
|
||||
*/
|
||||
#define NS_NATIVE_WINDOW 0
|
||||
#define NS_NATIVE_GRAPHIC 1
|
||||
#define NS_NATIVE_COLORMAP 2
|
||||
#define NS_NATIVE_WIDGET 3
|
||||
#define NS_NATIVE_DISPLAY 4
|
||||
#define NS_NATIVE_REGION 5
|
||||
#define NS_NATIVE_OFFSETX 6
|
||||
#define NS_NATIVE_OFFSETY 7
|
||||
#define NS_NATIVE_PLUGIN_PORT 8
|
||||
#define NS_NATIVE_SCREEN 9
|
||||
|
||||
// {18032AD5-B265-11d1-AA2A-000000000000}
|
||||
#define NS_IWIDGET_IID \
|
||||
{ 0x18032ad5, 0xb265, 0x11d1, \
|
||||
{ 0xaa, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
|
||||
// Hide the native window systems real window type so as to avoid
|
||||
// including native window system types and api's. This is necessary
|
||||
// to ensure cross-platform code.
|
||||
typedef void* nsNativeWidget;
|
||||
|
||||
/**
|
||||
* Border styles
|
||||
*/
|
||||
|
||||
enum nsWindowType {
|
||||
// default top level window
|
||||
eWindowType_toplevel,
|
||||
// top level window but usually handled differently by the OS
|
||||
eWindowType_dialog,
|
||||
// used for combo boxes, etc
|
||||
eWindowType_popup,
|
||||
// child windows (contained inside a window on the desktop (has no border))
|
||||
eWindowType_child
|
||||
};
|
||||
|
||||
|
||||
enum nsBorderStyle
|
||||
{
|
||||
// no border, titlebar, etc.. opposite of all
|
||||
eBorderStyle_none = 0,
|
||||
|
||||
// all window decorations
|
||||
eBorderStyle_all = 1 << 0,
|
||||
|
||||
// enables the border on the window. these are only for decoration and are not resize hadles
|
||||
eBorderStyle_border = 1 << 1,
|
||||
|
||||
// enables the resize handles for the window. if this is set, border is implied to also be set
|
||||
eBorderStyle_resizeh = 1 << 2,
|
||||
|
||||
// enables the titlebar for the window
|
||||
eBorderStyle_title = 1 << 3,
|
||||
|
||||
// enables the window menu button on the title bar. this being on should force the title bar to display
|
||||
eBorderStyle_menu = 1 << 4,
|
||||
|
||||
// enables the minimize button so the user can minimize the window.
|
||||
// turned off for tranient windows since they can not be minimized seperate from their parent
|
||||
eBorderStyle_minimize = 1 << 5,
|
||||
|
||||
// enables the maxmize button so the user can maximize the window
|
||||
eBorderStyle_maximize = 1 << 6,
|
||||
|
||||
// show the close button
|
||||
eBorderStyle_close = 1 << 7,
|
||||
|
||||
// whatever the OS wants... i.e. don't do anything
|
||||
eBorderStyle_default = -1
|
||||
};
|
||||
|
||||
/**
|
||||
* Cursor types.
|
||||
*/
|
||||
|
||||
enum nsCursor { ///(normal cursor, usually rendered as an arrow)
|
||||
eCursor_standard,
|
||||
///(system is busy, usually rendered as a hourglass or watch)
|
||||
eCursor_wait,
|
||||
///(Selecting something, usually rendered as an IBeam)
|
||||
eCursor_select,
|
||||
///(can hyper-link, usually rendered as a human hand)
|
||||
eCursor_hyperlink,
|
||||
///(west/east sizing, usually rendered as ->||<-)
|
||||
eCursor_sizeWE,
|
||||
///(north/south sizing, usually rendered as sizeWE rotated 90 degrees)
|
||||
eCursor_sizeNS,
|
||||
eCursor_arrow_north,
|
||||
eCursor_arrow_north_plus,
|
||||
eCursor_arrow_south,
|
||||
eCursor_arrow_south_plus,
|
||||
eCursor_arrow_west,
|
||||
eCursor_arrow_west_plus,
|
||||
eCursor_arrow_east,
|
||||
eCursor_arrow_east_plus,
|
||||
eCursor_crosshair,
|
||||
//Don't know what 'move' cursor should be. See CSS2.
|
||||
eCursor_move,
|
||||
eCursor_help
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Basic struct for widget initialization data.
|
||||
* @see Create member function of nsIWidget
|
||||
*/
|
||||
|
||||
struct nsWidgetInitData {
|
||||
nsWidgetInitData()
|
||||
: clipChildren(PR_FALSE), clipSiblings(PR_FALSE),
|
||||
mWindowType(eWindowType_child),
|
||||
mBorderStyle(eBorderStyle_default)
|
||||
{
|
||||
}
|
||||
|
||||
// when painting exclude area occupied by child windows and sibling windows
|
||||
PRPackedBool clipChildren, clipSiblings;
|
||||
nsWindowType mWindowType;
|
||||
nsBorderStyle mBorderStyle;
|
||||
};
|
||||
|
||||
/**
|
||||
* The base class for all the widgets. It provides the interface for
|
||||
* all basic and necessary functionality.
|
||||
*/
|
||||
class nsIWidget : public nsISupports {
|
||||
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID)
|
||||
|
||||
/**
|
||||
* Create and initialize a widget.
|
||||
*
|
||||
* The widget represents a window that can be drawn into. It also is the
|
||||
* base class for user-interface widgets such as buttons and text boxes.
|
||||
*
|
||||
* All the arguments can be NULL in which case a top level window
|
||||
* with size 0 is created. The event callback function has to be
|
||||
* provided only if the caller wants to deal with the events this
|
||||
* widget receives. The event callback is basically a preprocess
|
||||
* hook called synchronously. The return value determines whether
|
||||
* the event goes to the default window procedure or it is hidden
|
||||
* to the os. The assumption is that if the event handler returns
|
||||
* false the widget does not see the event. The widget should not
|
||||
* automatically clear the window to the background color. The
|
||||
* calling code must handle paint messages and clear the background
|
||||
* itself.
|
||||
*
|
||||
* @param parent or null if it's a top level window
|
||||
* @param aRect the widget dimension
|
||||
* @param aHandleEventFunction the event handler callback function
|
||||
* @param aContext
|
||||
* @param aAppShell the parent application shell. If nsnull,
|
||||
* the parent window's application shell will be used.
|
||||
* @param aToolkit
|
||||
* @param aInitData data that is used for widget initialization
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull) = 0;
|
||||
|
||||
/**
|
||||
* Create and initialize a widget with a native window parent
|
||||
*
|
||||
* The widget represents a window that can be drawn into. It also is the
|
||||
* base class for user-interface widgets such as buttons and text boxes.
|
||||
*
|
||||
* All the arguments can be NULL in which case a top level window
|
||||
* with size 0 is created. The event callback function has to be
|
||||
* provided only if the caller wants to deal with the events this
|
||||
* widget receives. The event callback is basically a preprocess
|
||||
* hook called synchronously. The return value determines whether
|
||||
* the event goes to the default window procedure or it is hidden
|
||||
* to the os. The assumption is that if the event handler returns
|
||||
* false the widget does not see the event.
|
||||
*
|
||||
* @param aParent native window.
|
||||
* @param aRect the widget dimension
|
||||
* @param aHandleEventFunction the event handler callback function
|
||||
*/
|
||||
NS_IMETHOD Create(nsNativeWidget aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Accessor functions to get and set the client data associated with the
|
||||
* widget.
|
||||
*/
|
||||
//@{
|
||||
NS_IMETHOD GetClientData(void*& aClientData) = 0;
|
||||
NS_IMETHOD SetClientData(void* aClientData) = 0;
|
||||
//@}
|
||||
|
||||
/**
|
||||
* Close and destroy the internal native window.
|
||||
* This method does not delete the widget.
|
||||
*/
|
||||
|
||||
NS_IMETHOD Destroy(void) = 0;
|
||||
|
||||
/**
|
||||
* Return the parent Widget of this Widget or nsnull if this is a
|
||||
* top level window
|
||||
*
|
||||
* @return the parent widget or nsnull if it does not have a parent
|
||||
*
|
||||
*/
|
||||
virtual nsIWidget* GetParent(void) = 0;
|
||||
|
||||
/**
|
||||
* Return an nsEnumerator over the children of this widget.
|
||||
*
|
||||
* @return an enumerator over the list of children or nsnull if it does not
|
||||
* have any children
|
||||
*
|
||||
*/
|
||||
virtual nsIEnumerator* GetChildren(void) = 0;
|
||||
|
||||
/**
|
||||
* Show or hide this widget
|
||||
*
|
||||
* @param aState PR_TRUE to show the Widget, PR_FALSE to hide it
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Show(PRBool aState) = 0;
|
||||
|
||||
/**
|
||||
* Make the window modal
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetModal(PRBool aModal) = 0;
|
||||
|
||||
/**
|
||||
* Returns whether the window is visible
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD IsVisible(PRBool & aState) = 0;
|
||||
|
||||
/**
|
||||
* Move this widget.
|
||||
*
|
||||
* @param aX the new x position expressed in the parent's coordinate system
|
||||
* @param aY the new y position expressed in the parent's coordinate system
|
||||
*
|
||||
**/
|
||||
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY) = 0;
|
||||
|
||||
/**
|
||||
* Resize this widget.
|
||||
*
|
||||
* @param aWidth the new width expressed in the parent's coordinate system
|
||||
* @param aHeight the new height expressed in the parent's coordinate system
|
||||
* @param aRepaint whether the widget should be repainted
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Resize(PRInt32 aWidth,
|
||||
PRInt32 aHeight,
|
||||
PRBool aRepaint) = 0;
|
||||
|
||||
/**
|
||||
* Move or resize this widget.
|
||||
*
|
||||
* @param aX the new x position expressed in the parent's coordinate system
|
||||
* @param aY the new y position expressed in the parent's coordinate system
|
||||
* @param aWidth the new width expressed in the parent's coordinate system
|
||||
* @param aHeight the new height expressed in the parent's coordinate system
|
||||
* @param aRepaint whether the widget should be repainted if the size changes
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Resize(PRInt32 aX,
|
||||
PRInt32 aY,
|
||||
PRInt32 aWidth,
|
||||
PRInt32 aHeight,
|
||||
PRBool aRepaint) = 0;
|
||||
|
||||
/**
|
||||
* Set's the widget's z-index.
|
||||
*/
|
||||
NS_IMETHOD SetZIndex(PRInt32 aZIndex) = 0;
|
||||
|
||||
/**
|
||||
* Get's the widget's z-index.
|
||||
*/
|
||||
NS_IMETHOD GetZIndex(PRInt32* aZIndex) = 0;
|
||||
|
||||
/**
|
||||
* Enable or disable this Widget
|
||||
*
|
||||
* @param aState PR_TRUE to enable the Widget, PR_FALSE to disable it.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Enable(PRBool aState) = 0;
|
||||
|
||||
/**
|
||||
* Give focus to this widget.
|
||||
*/
|
||||
NS_IMETHOD SetFocus(void) = 0;
|
||||
|
||||
/**
|
||||
* Get this widget's outside dimensions relative to it's parent widget
|
||||
*
|
||||
* @param aRect on return it holds the x. y, width and height of this widget
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetBounds(nsRect &aRect) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Get this widget's client area dimensions, if the window has a 3D border appearance
|
||||
* this returns the area inside the border, The x and y are always zero
|
||||
*
|
||||
* @param aRect on return it holds the x. y, width and height of the client area of this widget
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetClientBounds(nsRect &aRect) = 0;
|
||||
|
||||
/**
|
||||
* Gets the width and height of the borders
|
||||
* @param aWidth the width of the border
|
||||
* @param aHeight the height of the border
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Get the foreground color for this widget
|
||||
*
|
||||
* @return this widget's foreground color
|
||||
*
|
||||
*/
|
||||
virtual nscolor GetForegroundColor(void) = 0;
|
||||
|
||||
/**
|
||||
* Set the foreground color for this widget
|
||||
*
|
||||
* @param aColor the new foreground color
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetForegroundColor(const nscolor &aColor) = 0;
|
||||
|
||||
/**
|
||||
* Get the background color for this widget
|
||||
*
|
||||
* @return this widget's background color
|
||||
*
|
||||
*/
|
||||
|
||||
virtual nscolor GetBackgroundColor(void) = 0;
|
||||
|
||||
/**
|
||||
* Set the background color for this widget
|
||||
*
|
||||
* @param aColor the new background color
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetBackgroundColor(const nscolor &aColor) = 0;
|
||||
|
||||
/**
|
||||
* Get the font for this widget
|
||||
*
|
||||
* @return the font metrics
|
||||
*/
|
||||
|
||||
virtual nsIFontMetrics* GetFont(void) = 0;
|
||||
|
||||
/**
|
||||
* Set the font for this widget
|
||||
*
|
||||
* @param aFont font to display. See nsFont for allowable fonts
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetFont(const nsFont &aFont) = 0;
|
||||
|
||||
/**
|
||||
* Get the cursor for this widget.
|
||||
*
|
||||
* @return this widget's cursor.
|
||||
*/
|
||||
|
||||
virtual nsCursor GetCursor(void) = 0;
|
||||
|
||||
/**
|
||||
* Set the cursor for this widget
|
||||
*
|
||||
* @param aCursor the new cursor for this widget
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetCursor(nsCursor aCursor) = 0;
|
||||
|
||||
/**
|
||||
* Invalidate the widget and repaint it.
|
||||
*
|
||||
* @param aIsSynchronouse PR_TRUE then repaint synchronously. If PR_FALSE repaint later.
|
||||
* @see #Update()
|
||||
*/
|
||||
|
||||
NS_IMETHOD Invalidate(PRBool aIsSynchronous) = 0;
|
||||
|
||||
/**
|
||||
* Invalidate a specified rect for a widget and repaints it.
|
||||
*
|
||||
* @param aIsSynchronouse PR_TRUE then repaint synchronously. If PR_FALSE repaint later.
|
||||
* @see #Update()
|
||||
*/
|
||||
|
||||
NS_IMETHOD Invalidate(const nsRect & aRect, PRBool aIsSynchronous) = 0;
|
||||
|
||||
/**
|
||||
* Invalidate a specified region for a widget and repaints it.
|
||||
*
|
||||
* @param aIsSynchronouse PR_TRUE then repaint synchronously. If PR_FALSE repaint later.
|
||||
* @see #Update()
|
||||
*/
|
||||
|
||||
NS_IMETHOD InvalidateRegion(const nsIRegion* aRegion, PRBool aIsSynchronous) = 0;
|
||||
|
||||
/**
|
||||
* Force a synchronous repaint of the window if there are dirty rects.
|
||||
*
|
||||
* @see Invalidate()
|
||||
*/
|
||||
|
||||
NS_IMETHOD Update() = 0;
|
||||
|
||||
/**
|
||||
* Adds a mouse listener to this widget
|
||||
* Any existing mouse listener is replaced
|
||||
*
|
||||
* @param aListener mouse listener to add to this widget.
|
||||
*/
|
||||
|
||||
NS_IMETHOD AddMouseListener(nsIMouseListener * aListener) = 0;
|
||||
|
||||
/**
|
||||
* Adds an event listener to this widget
|
||||
* Any existing event listener is replaced
|
||||
*
|
||||
* @param aListener event listener to add to this widget.
|
||||
*/
|
||||
|
||||
NS_IMETHOD AddEventListener(nsIEventListener * aListener) = 0;
|
||||
|
||||
/**
|
||||
* Adds a menu listener to this widget
|
||||
* Any existing menu listener is replaced
|
||||
*
|
||||
* @param aListener menu listener to add to this widget.
|
||||
*/
|
||||
|
||||
NS_IMETHOD AddMenuListener(nsIMenuListener * aListener) = 0;
|
||||
|
||||
/**
|
||||
* Return the widget's toolkit
|
||||
*
|
||||
* @return the toolkit this widget was created in. See nsToolkit.
|
||||
*/
|
||||
|
||||
virtual nsIToolkit* GetToolkit() = 0;
|
||||
|
||||
/**
|
||||
* Set the color map for this widget
|
||||
*
|
||||
* @param aColorMap color map for displaying this widget
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetColorMap(nsColorMap *aColorMap) = 0;
|
||||
|
||||
/**
|
||||
* Scroll this widget.
|
||||
*
|
||||
* @param aDx amount to scroll along the x-axis
|
||||
* @param aDy amount to scroll along the y-axis.
|
||||
* @param aClipRect clipping rectangle to limit the scroll to.
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) = 0;
|
||||
|
||||
/**
|
||||
* Scroll an area of this widget.
|
||||
*
|
||||
* @param aRect source rectangle to scroll in the widget
|
||||
* @param aDx x offset from the source
|
||||
* @param aDy y offset from the source
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD ScrollRect(nsRect &aSrcRect, PRInt32 aDx, PRInt32 aDy) = 0;
|
||||
|
||||
/**
|
||||
* Internal methods
|
||||
*/
|
||||
|
||||
//@{
|
||||
virtual void AddChild(nsIWidget* aChild) = 0;
|
||||
virtual void RemoveChild(nsIWidget* aChild) = 0;
|
||||
virtual void* GetNativeData(PRUint32 aDataType) = 0;
|
||||
virtual void FreeNativeData(void * data, PRUint32 aDataType) = 0;//~~~
|
||||
virtual nsIRenderingContext* GetRenderingContext() = 0;
|
||||
virtual nsIDeviceContext* GetDeviceContext() = 0;
|
||||
virtual nsIAppShell *GetAppShell() = 0;
|
||||
//@}
|
||||
|
||||
/**
|
||||
* Set border style
|
||||
* Must be called before Create.
|
||||
* @param aBorderStyle @see nsBorderStyle
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle) = 0;
|
||||
|
||||
/**
|
||||
* Set the widget's title.
|
||||
* Must be called after Create.
|
||||
*
|
||||
* @param aTitle string displayed as the title of the widget
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetTitle(const nsString& aTitle) = 0;
|
||||
|
||||
/**
|
||||
* Set the widget's MenuBar.
|
||||
* Must be called after Create.
|
||||
*
|
||||
* @param aMenuBar the menubar
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar) = 0;
|
||||
|
||||
/**
|
||||
* Set the widget's MenuBar's visibility
|
||||
*
|
||||
* @param aShow PR_TRUE to show, PR_FALSE to hide
|
||||
*/
|
||||
|
||||
NS_IMETHOD ShowMenuBar(PRBool aShow) = 0;
|
||||
|
||||
/**
|
||||
* Convert from this widget coordinates to screen coordinates.
|
||||
*
|
||||
* @param aOldRect widget coordinates stored in the x,y members
|
||||
* @param aNewRect screen coordinates stored in the x,y members
|
||||
*/
|
||||
|
||||
NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) = 0;
|
||||
|
||||
/**
|
||||
* Convert from screen coordinates to this widget's coordinates.
|
||||
*
|
||||
* @param aOldRect screen coordinates stored in the x,y members
|
||||
* @param aNewRect widget's coordinates stored in the x,y members
|
||||
*/
|
||||
|
||||
NS_IMETHOD ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) = 0;
|
||||
|
||||
/**
|
||||
* When adjustments are to made to a whole set of child widgets, call this
|
||||
* before resizing/positioning the child windows to minimize repaints. Must
|
||||
* be followed by EndResizingChildren() after child windows have been
|
||||
* adjusted.
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD BeginResizingChildren(void) = 0;
|
||||
|
||||
/**
|
||||
* Call this when finished adjusting child windows. Must be preceded by
|
||||
* BeginResizingChildren().
|
||||
*
|
||||
*/
|
||||
|
||||
NS_IMETHOD EndResizingChildren(void) = 0;
|
||||
|
||||
/**
|
||||
* Returns the preferred width and height for the widget
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Set the preferred width and height for the widget
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Dispatches and event to the widget
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus) = 0;
|
||||
|
||||
|
||||
#ifdef LOSER
|
||||
/**
|
||||
* FSets the vertical scrollbar widget
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetVerticalScrollbar(nsIWidget * aScrollbar) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* For printing and lightweight widgets
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect) = 0;
|
||||
|
||||
/**
|
||||
* Enables the dropping of files to a widget (XXX this is temporary)
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD EnableDragDrop(PRBool aEnable) = 0;
|
||||
|
||||
virtual void ConvertToDeviceCoordinates(nscoord &aX,nscoord &aY) = 0;
|
||||
|
||||
/**
|
||||
* Enables/Disables system mouse capture.
|
||||
* @param aCapture PR_TRUE enables mouse capture, PR_FALSE disables mouse capture
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD CaptureMouse(PRBool aCapture) = 0;
|
||||
|
||||
/**
|
||||
* Enables/Disables system capture of any and all events that would cause a
|
||||
* dropdown to be rolled up, This method ignores the aConsumeRollupEvent
|
||||
* parameter when aDoCapture is FALSE
|
||||
* @param aCapture PR_TRUE enables capture, PR_FALSE disables capture
|
||||
* @param aConsumeRollupEvent PR_TRUE consumes the rollup event, PR_FALSE dispatches rollup event
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent) = 0;
|
||||
|
||||
/**
|
||||
* Determine whether a given event should be processed assuming we are
|
||||
* the currently active modal window.
|
||||
* Note that the exact semantics of this method are platform-dependent.
|
||||
* The Macintosh, for instance, cares deeply that this method do exactly
|
||||
* as advertised. Gtk, for instance, handles modality in a completely
|
||||
* different fashion and does little if anything with this method.
|
||||
* @param aRealEvent event is real or a null placeholder (Macintosh)
|
||||
* @param aEvent void pointer to native event structure
|
||||
* @param aForWindow return value. PR_TRUE iff event should be processed.
|
||||
*/
|
||||
NS_IMETHOD ModalEventFilter(PRBool aRealEvent, void *aEvent, PRBool *aForWindow) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsIWidget_h__
|
||||
@@ -1,556 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Rod Spears <rods@netscape.com>
|
||||
* Kevin McCluskey <kmcclusk@netscape.com>
|
||||
* Mike Pinkerton <pinkerton@netscape.com>
|
||||
* ... and other people
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIScriptableRegion.idl"
|
||||
#include "nsIRollupListener.idl"
|
||||
#include "nsIToolkit.idl"
|
||||
#include "nsIAppShell.idl"
|
||||
#include "nsIEnumerator.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsRect.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsIMouseListener.h"
|
||||
#include "nsIMenuListener.h"
|
||||
#include "nsIImage.h"
|
||||
|
||||
#include "prthread.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
// forward declarations
|
||||
class nsIAppShell;
|
||||
class nsIToolkit;
|
||||
class nsIRenderingContext;
|
||||
class nsIEnumerator;
|
||||
class nsIDeviceContext;
|
||||
struct nsRect;
|
||||
struct nsFont;
|
||||
class nsIEventListener;
|
||||
class nsIRollupListener;
|
||||
%}
|
||||
|
||||
[ptr] native nsGUIEvent(nsGUIEvent);
|
||||
[ptr] native nsIMouseListener(nsIMouseListener);
|
||||
[ptr] native nsIEventListener(nsIEventListener);
|
||||
[ptr] native nsIMenuListener(nsIMenuListener);
|
||||
[ptr] native nsIRegion(nsIRegion);
|
||||
[ptr] native nsRect(nsRect);
|
||||
[ref] native nsRectRef(nsRect);
|
||||
[ptr] native nsFont(nsFont);
|
||||
[ptr] native nsColorMap(nsColorMap);
|
||||
|
||||
[ptr] native nsIRenderingContext(nsIRenderingContext);
|
||||
[ptr] native nsIDeviceContext(nsIDeviceContext);
|
||||
|
||||
native nscolor(nscolor);
|
||||
native nscoord(nscoord);
|
||||
native nsEventStatus(nsEventStatus);
|
||||
[ref] native nsEventStatusRef(nsEventStatus);
|
||||
native PR_CALLBACK(PR_CALLBACKK);
|
||||
native EVENT_CALLBACK(EVENT_CALLBACK);
|
||||
|
||||
typedef long nsCursor;
|
||||
|
||||
|
||||
/*
|
||||
* Hide the native window systems real window type so as to avoid
|
||||
* including native window system types and api's. This is necessary
|
||||
* to ensure cross-platform code.
|
||||
*/
|
||||
typedef voidStar nsNativeWidget;
|
||||
|
||||
|
||||
%{ C++
|
||||
typedef nsEventStatus (*PR_CALLBACK EVENT_CALLBACK)(nsGUIEvent *event);
|
||||
|
||||
|
||||
/**
|
||||
* Basic struct for widget initialization data.
|
||||
* @see Create member function of nsIWidget
|
||||
*/
|
||||
|
||||
struct nsWidgetInitData {
|
||||
nsWidgetInitData()
|
||||
: clipChildren(PR_FALSE), clipSiblings(PR_FALSE)
|
||||
// mWindowType(eWindowType_child),
|
||||
// mBorderStyle(eBorderStyle_default)
|
||||
{
|
||||
}
|
||||
|
||||
// when painting exclude area occupied by child windows and sibling windows
|
||||
PRPackedBool clipChildren, clipSiblings;
|
||||
// nsWindowType mWindowType;
|
||||
// nsBorderStyle mBorderStyle;
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
[uuid(18032AD5-B265-11d1-AA2A-000000000000)]
|
||||
interface nsIWidget : nsISupports
|
||||
{
|
||||
|
||||
/*
|
||||
* Flags for GetNativeData()
|
||||
*/
|
||||
const short NS_NATIVE_WINDOW = 0;
|
||||
const short NS_NATIVE_GRAPHIC = 1;
|
||||
const short NS_NATIVE_COLORMAP = 2;
|
||||
const short NS_NATIVE_WIDGET = 3;
|
||||
const short NS_NATIVE_DISPLAY = 4;
|
||||
const short NS_NATIVE_REGION = 5;
|
||||
const short NS_NATIVE_OFFSETX = 6;
|
||||
const short NS_NATIVE_OFFSETY = 7;
|
||||
const short NS_NATIVE_PLUGIN_PORT = 8;
|
||||
const short NS_NATIVE_SCREEN = 9;
|
||||
|
||||
|
||||
/**
|
||||
* Cursor types.
|
||||
*/
|
||||
|
||||
//(normal cursor, usually rendered as an arrow)
|
||||
const long eCursor_standard = 0;
|
||||
//(system is busy, usually rendered as a hourglass or watch)
|
||||
const long eCursor_wait = 1;
|
||||
//(Selecting something, usually rendered as an IBeam)
|
||||
const long eCursor_select = 2;
|
||||
//(can hyper-link, usually rendered as a human hand)
|
||||
const long eCursor_hyperlink = 3;
|
||||
//(west/east sizing, usually rendered as ->||<-)
|
||||
const long eCursor_sizeWE = 4;
|
||||
//(north/south sizing, usually rendered as sizeWE rotated 90 degrees)
|
||||
const long eCursor_sizeNS = 5;
|
||||
const long eCursor_arrow_north = 6;
|
||||
const long eCursor_arrow_north_plus = 7;
|
||||
const long eCursor_arrow_south = 8;
|
||||
const long eCursor_arrow_south_plus = 9;
|
||||
const long eCursor_arrow_west = 10;
|
||||
const long eCursor_arrow_west_plus = 11;
|
||||
const long eCursor_arrow_east = 12;
|
||||
const long eCursor_arrow_east_plus = 13;
|
||||
const long eCursor_crosshair = 14;
|
||||
//Don't know what 'move' cursor should be. See CSS2.
|
||||
const long eCursor_move = 15;
|
||||
const long eCursor_help = 16;
|
||||
|
||||
|
||||
/**
|
||||
* initialize a widget
|
||||
*
|
||||
* The widget represents a window that can be drawn into. It also is the
|
||||
* base class for user-interface widgets such as buttons and text boxes.
|
||||
*
|
||||
* All the arguments can be NULL in which case a top level window
|
||||
* with size 0 is created. The event callback function has to be
|
||||
* provided only if the caller wants to deal with the events this
|
||||
* widget receives. The event callback is basically a preprocess
|
||||
* hook called synchronously. The return value determines whether
|
||||
* the event goes to the default window procedure or it is hidden
|
||||
* to the os. The assumption is that if the event handler returns
|
||||
* false the widget does not see the event. The widget should not
|
||||
* automatically clear the window to the background color. The
|
||||
* calling code must handle paint messages and clear the background
|
||||
* itself.
|
||||
*
|
||||
* @param aAppShell the parent application shell. If nsnull,
|
||||
* the parent window's application shell will be used.
|
||||
* @param aToolkit toolkit
|
||||
* @param aContext device context
|
||||
* @param aEventFunction the event handler callback function
|
||||
*
|
||||
*/
|
||||
void initWidget(in nsIAppShell aAppShell,
|
||||
in nsIToolkit aToolkit,
|
||||
in nsIDeviceContext aContext,
|
||||
in EVENT_CALLBACK aEventFunction);
|
||||
|
||||
/**
|
||||
* Get some kind of native data
|
||||
*/
|
||||
voidStar getNativeData(in PRUint32 aDataType);
|
||||
|
||||
/**
|
||||
* Move this widget.
|
||||
*
|
||||
* @param aX the new x position expressed in the parent's coordinate system
|
||||
* @param aY the new y position expressed in the parent's coordinate system
|
||||
*
|
||||
**/
|
||||
void move(in PRInt32 aX, in PRInt32 aY);
|
||||
|
||||
/**
|
||||
* Resize this widget.
|
||||
*
|
||||
* @param aWidth the new width expressed in the parent's coordinate system
|
||||
* @param aHeight the new height expressed in the parent's coordinate system
|
||||
* @param aRepaint whether the widget should be repainted
|
||||
*
|
||||
*/
|
||||
void resize(in PRInt32 aWidth,
|
||||
in PRInt32 aHeight,
|
||||
in PRBool aRepaint);
|
||||
|
||||
/**
|
||||
* Move and resize this widget.
|
||||
*
|
||||
* @param aX the new x position expressed in the parent's coordinate system
|
||||
* @param aY the new y position expressed in the parent's coordinate system
|
||||
* @param aWidth the new width expressed in the parent's coordinate system
|
||||
* @param aHeight the new height expressed in the parent's coordinate system
|
||||
* @param aRepaint whether the widget should be repainted if the size changes
|
||||
*
|
||||
*/
|
||||
void moveResize(in PRInt32 aX,
|
||||
in PRInt32 aY,
|
||||
in PRInt32 aWidth,
|
||||
in PRInt32 aHeight,
|
||||
in PRBool aRepaint);
|
||||
|
||||
/**
|
||||
* Enable or disable this Widget
|
||||
*
|
||||
* @param aState PR_TRUE to enable the Widget, PR_FALSE to disable it.
|
||||
*
|
||||
*/
|
||||
void enable(in PRBool aState);
|
||||
|
||||
|
||||
// XXX GO AWAY
|
||||
|
||||
/**
|
||||
* Get this widget's outside dimensions relative to it's parent widget
|
||||
*
|
||||
* @param aRect on return it holds the x. y, width and height of this widget
|
||||
*
|
||||
*/
|
||||
// readonly attribute nsRect Bounds;
|
||||
|
||||
// this is really out..
|
||||
void getBounds(in nsRectRef aRect);
|
||||
|
||||
|
||||
// XXX keep this, but make it ints
|
||||
/**
|
||||
* Get this widget's client area dimensions, if the window has a 3D border appearance
|
||||
* this returns the area inside the border, The x and y are always zero
|
||||
*
|
||||
* @param aRect on return it holds the x. y, width and height of the client area of this widget
|
||||
*
|
||||
*/
|
||||
// readonly attribute nsRect ClientBounds;
|
||||
|
||||
// this is really out..
|
||||
void getClientBounds(in nsRectRef aRect);
|
||||
|
||||
|
||||
|
||||
// Is this still used?
|
||||
/**
|
||||
* Returns the preferred width and height for the widget
|
||||
*
|
||||
*/
|
||||
void getPreferredSize(out PRInt32 aWidth,
|
||||
out PRInt32 aHeight);
|
||||
|
||||
/**
|
||||
* Set the preferred width and height for the widget
|
||||
*
|
||||
*/
|
||||
void setPreferredSize(in PRInt32 aWidth, in PRInt32 aHeight);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Invalidate the widget and repaint it.
|
||||
*
|
||||
* @param aIsSynchronouse PR_TRUE then repaint synchronously. If PR_FALSE repaint later.
|
||||
* @see #Update()
|
||||
*/
|
||||
void invalidate(in PRBool aIsSynchronous);
|
||||
|
||||
/**
|
||||
* Invalidate a specified rect for a widget and repaints it.
|
||||
*
|
||||
* @param aIsSynchronouse PR_TRUE then repaint synchronously. If PR_FALSE repaint later.
|
||||
* @see #Update()
|
||||
*/
|
||||
void invalidateRect([const] in nsRect aRect, in PRBool aIsSynchronous);
|
||||
|
||||
/**
|
||||
* Invalidate a specified rect for a widget and repaints it.
|
||||
*
|
||||
* @param aIsSynchronouse PR_TRUE then repaint synchronously. If PR_FALSE repaint later.
|
||||
* @see #Update()
|
||||
*/
|
||||
// void InvalidateRegion([const] in nsIScriptableRegion aRegion, in PRBool aIsSynchronous);
|
||||
void invalidateRegion([const] in nsIRegion aRegion, in PRBool aIsSynchronous);
|
||||
|
||||
/**
|
||||
* Force a synchronous repaint of the window if there are dirty rects.
|
||||
*
|
||||
* @see Invalidate()
|
||||
*/
|
||||
void update();
|
||||
|
||||
|
||||
/**
|
||||
* Convert from this widget coordinates to screen coordinates.
|
||||
*
|
||||
* @param aOldRect widget coordinates stored in the x,y members
|
||||
* @param aNewRect screen coordinates stored in the x,y members
|
||||
*/
|
||||
void widgetToScreen([const] in nsRect aOldRect, out nsRect aNewRect);
|
||||
|
||||
/**
|
||||
* Convert from screen coordinates to this widget's coordinates.
|
||||
*
|
||||
* @param aOldRect screen coordinates stored in the x,y members
|
||||
* @param aNewRect widget's coordinates stored in the x,y members
|
||||
*/
|
||||
void screenToWidget([const] in nsRect aOldRect, out nsRect aNewRect);
|
||||
|
||||
// is this used?
|
||||
void convertToDeviceCoordinates(inout nscoord aX, inout nscoord aY);
|
||||
|
||||
|
||||
// can this go away?
|
||||
/**
|
||||
* For printing and lightweight widgets
|
||||
*
|
||||
*/
|
||||
void paint(in nsIRenderingContext aRenderingContext,
|
||||
[const] in nsRect aDirtyRect);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Enables the dropping of files to a widget (XXX this is temporary)
|
||||
*
|
||||
*/
|
||||
void enableDragDrop(in PRBool aEnable);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Enables/Disables system mouse capture.
|
||||
* @param aCapture PR_TRUE enables mouse capture, PR_FALSE disables mouse capture
|
||||
*
|
||||
*/
|
||||
void captureMouse(in PRBool aCapture);
|
||||
|
||||
/**
|
||||
* Enables/Disables system capture of any and all events that would cause a
|
||||
* dropdown to be rolled up, This method ignores the aConsumeRollupEvent
|
||||
* parameter when aDoCapture is FALSE
|
||||
* @param aCapture PR_TRUE enables capture, PR_FALSE disables capture
|
||||
* @param aConsumeRollupEvent PR_TRUE consumes the rollup event, PR_FALSE dispatches rollup event
|
||||
*
|
||||
*/
|
||||
void captureRollupEvents(in nsIRollupListener aListener, in PRBool aDoCapture, in PRBool aConsumeRollupEvent);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds a mouse listener to this widget
|
||||
* Any existing mouse listener is replaced
|
||||
*
|
||||
* @param aListener mouse listener to add to this widget.
|
||||
*/
|
||||
void addMouseListener(in nsIMouseListener aListener);
|
||||
|
||||
/**
|
||||
* Adds an event listener to this widget
|
||||
* Any existing event listener is replaced
|
||||
*
|
||||
* @param aListener event listener to add to this widget.
|
||||
*/
|
||||
void addEventListener(in nsIEventListener aListener);
|
||||
|
||||
/**
|
||||
* Adds a menu listener to this widget
|
||||
* Any existing menu listener is replaced
|
||||
*
|
||||
* @param aListener menu listener to add to this widget.
|
||||
*/
|
||||
void addMenuListener(in nsIMenuListener aListener);
|
||||
|
||||
|
||||
// is this an internal method?
|
||||
/**
|
||||
* Dispatches and event to the widget
|
||||
*
|
||||
*/
|
||||
void dispatchEvent(in nsGUIEvent event, in nsEventStatusRef aStatus);
|
||||
|
||||
|
||||
/**
|
||||
* Internal methods
|
||||
*/
|
||||
void addChild(in nsIWidget aChild);
|
||||
void removeChild(in nsIWidget aChild);
|
||||
|
||||
/* ATTRIBUTES */
|
||||
|
||||
|
||||
/**
|
||||
* Device Context used to do printing... probably shouldn't be here
|
||||
*/
|
||||
readonly attribute nsIDeviceContext deviceContext;
|
||||
|
||||
/* attributes */
|
||||
|
||||
/**
|
||||
* Get the AppShell
|
||||
*/
|
||||
readonly attribute nsIAppShell appShell;
|
||||
|
||||
/**
|
||||
* Get the nsIToolkit
|
||||
*/
|
||||
readonly attribute nsIToolkit toolkit;
|
||||
|
||||
/**
|
||||
* callback for the event
|
||||
*/
|
||||
[noscript] readonly attribute EVENT_CALLBACK eventFunction;
|
||||
|
||||
|
||||
/* things that MUST be set AFTER the widget is created */
|
||||
|
||||
/**
|
||||
* Get and Set the widget's z-index.
|
||||
*/
|
||||
attribute PRInt32 zIndex;
|
||||
|
||||
/**
|
||||
* Set/Get the foreground color for this widget
|
||||
*
|
||||
* @param aColor the new foreground color
|
||||
*
|
||||
*/
|
||||
attribute nscolor foregroundColor;
|
||||
|
||||
/**
|
||||
* Set/Get the background color for this widget
|
||||
*
|
||||
* @param aColor the new background color
|
||||
*
|
||||
*/
|
||||
attribute nscolor backgroundColor;
|
||||
|
||||
/**
|
||||
* Set/Get the font for this widget
|
||||
*
|
||||
* @param aFont font to display. See nsFont for allowable fonts
|
||||
*/
|
||||
attribute nsFont font;
|
||||
|
||||
/**
|
||||
* Set/Get the cursor for this widget
|
||||
*
|
||||
* @param aCursor the new cursor for this widget
|
||||
*/
|
||||
|
||||
attribute nsCursor cursor;
|
||||
|
||||
/**
|
||||
* Set the color map for this widget
|
||||
*
|
||||
* @param aColorMap color map for displaying this widget
|
||||
*
|
||||
*/
|
||||
attribute nsColorMap colorMap;
|
||||
|
||||
/**
|
||||
* Accessor functions to get and set the client data associated with the
|
||||
* widget.
|
||||
*/
|
||||
attribute voidStar clientData;
|
||||
|
||||
/**
|
||||
* Return an nsEnumerator over the children of this widget.
|
||||
*
|
||||
* @return an enumerator over the list of children or nsnull if it does not
|
||||
* have any children
|
||||
*
|
||||
*/
|
||||
readonly attribute nsIEnumerator children;
|
||||
|
||||
%{ C++
|
||||
/* backwards compat stuff */
|
||||
NS_IMETHOD Show(PRBool aShow) = 0;
|
||||
|
||||
NS_IMETHOD IsVisible(PRBool & aState) = 0;
|
||||
NS_IMETHOD Resize(PRInt32 aX,
|
||||
PRInt32 aY,
|
||||
PRInt32 aWidth,
|
||||
PRInt32 aHeight,
|
||||
PRBool aRepaint) = 0;
|
||||
|
||||
virtual nscolor GetForegroundColor(void) = 0;
|
||||
virtual nscolor GetBackgroundColor(void) = 0;
|
||||
|
||||
NS_IMETHOD SetFont(const nsFont &aFont) = 0;
|
||||
virtual nsIFontMetrics* GetFont(void) = 0;
|
||||
|
||||
NS_IMETHOD Invalidate(const nsRect & aRect, PRBool aIsSynchronous) = 0;
|
||||
NS_IMETHOD SetTitle(const nsString& aTitle) = 0;
|
||||
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight) = 0;
|
||||
|
||||
virtual nsIWidget* GetParent(void) = 0;
|
||||
|
||||
virtual nsIEnumerator* GetChildren(void) = 0;
|
||||
|
||||
virtual void* GetNativeData(PRUint32 aDataType) = 0;
|
||||
virtual void FreeNativeData(void * data, PRUint32 aDataType) = 0;
|
||||
virtual nsIRenderingContext* GetRenderingContext() = 0;
|
||||
virtual nsIDeviceContext* GetDeviceContext() = 0;
|
||||
virtual nsIAppShell *GetAppShell() = 0;
|
||||
virtual nsIToolkit* GetToolkit() = 0;
|
||||
|
||||
/* the big ugly ones */
|
||||
NS_IMETHOD Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull) = 0;
|
||||
NS_IMETHOD Create(nsNativeWidget aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull) = 0;
|
||||
|
||||
%}
|
||||
|
||||
};
|
||||
|
||||
@@ -1,203 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Rod Spears <rods@netscape.com>
|
||||
* Kevin McCluskey <kmcclusk@netscape.com>
|
||||
* Mike Pinkerton <pinkerton@netscape.com>
|
||||
* ... and other people
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIWidget.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsRect.h"
|
||||
#include "nsIMouseListener.h"
|
||||
#include "nsIMenuListener.h"
|
||||
#include "nsIImage.h"
|
||||
|
||||
#include "prthread.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
// forward declarations
|
||||
struct nsRect;
|
||||
class nsIMenuBar;
|
||||
%}
|
||||
|
||||
[ptr] native nsIMenuBar(nsIMenuBar);
|
||||
|
||||
typedef long nsBorderStyle;
|
||||
typedef long nsWindowType;
|
||||
|
||||
|
||||
[uuid(491359ea-1dd2-11b2-af7c-bb0346efd9b6)]
|
||||
interface nsIWindow : nsIWidget
|
||||
{
|
||||
/*
|
||||
* types of windows
|
||||
*/
|
||||
const long eWindowType_toplevel = 0;
|
||||
const long eWindowType_dialog = 1;
|
||||
const long eWindowType_popup = 2;
|
||||
const long eWindowType_child = 3;
|
||||
|
||||
|
||||
/*
|
||||
* Border styles
|
||||
*/
|
||||
// no border, titlebar, etc.. opposite of all
|
||||
const long eBorderStyle_none = 0;
|
||||
|
||||
// all window decorations
|
||||
const long eBorderStyle_all = 1 << 0;
|
||||
|
||||
// enables the border on the window. these are only for decoration and are not resize hadles
|
||||
const long eBorderStyle_border = 1 << 1;
|
||||
|
||||
// enables the resize handles for the window. if this is set, border is implied to also be set
|
||||
const long eBorderStyle_resizeh = 1 << 2;
|
||||
|
||||
// enables the titlebar for the window
|
||||
const long eBorderStyle_title = 1 << 3;
|
||||
|
||||
// enables the window menu button on the title bar. this being on should force the title bar to display
|
||||
const long eBorderStyle_menu = 1 << 4;
|
||||
|
||||
// enables the minimize button so the user can minimize the window.
|
||||
// turned off for tranient windows since they can not be minimized seperate from their parent
|
||||
const long eBorderStyle_minimize = 1 << 5;
|
||||
|
||||
// enables the maxmize button so the user can maximize the window
|
||||
const long eBorderStyle_maximize = 1 << 6;
|
||||
|
||||
// show the close button
|
||||
const long eBorderStyle_close = 1 << 7;
|
||||
|
||||
// whatever the OS wants... i.e. don't do anything
|
||||
const long eBorderStyle_default = -1;
|
||||
|
||||
|
||||
/**
|
||||
* initialize a window
|
||||
*
|
||||
* The widget represents a window that can be drawn into. It also is the
|
||||
* base class for user-interface widgets such as buttons and text boxes.
|
||||
*
|
||||
* All the arguments can be NULL in which case a top level window
|
||||
* with size 0 is created. The event callback function has to be
|
||||
* provided only if the caller wants to deal with the events this
|
||||
* widget receives. The event callback is basically a preprocess
|
||||
* hook called synchronously. The return value determines whether
|
||||
* the event goes to the default window procedure or it is hidden
|
||||
* to the os. The assumption is that if the event handler returns
|
||||
* false the widget does not see the event. The widget should not
|
||||
* automatically clear the window to the background color. The
|
||||
* calling code must handle paint messages and clear the background
|
||||
* itself.
|
||||
*
|
||||
* @param aWindowType type of window to create
|
||||
* @param aBorderStyle border style of the window to create
|
||||
*
|
||||
*/
|
||||
void initWindowStyle(in nsWindowType aWindowType,
|
||||
in nsBorderStyle aBorderStyle);
|
||||
|
||||
/**
|
||||
* Make the window modal
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
void setModal(in boolean modal);
|
||||
|
||||
/**
|
||||
* Gets the width and height of the borders
|
||||
* @param aWidth the width of the border
|
||||
* @param aHeight the height of the border
|
||||
*
|
||||
*/
|
||||
void getBorderSize(out PRInt32 aWidth, out PRInt32 aHeight);
|
||||
|
||||
/**
|
||||
* Scroll this widget.
|
||||
*
|
||||
* @param aDx amount to scroll along the x-axis
|
||||
* @param aDy amount to scroll along the y-axis.
|
||||
* @param aClipRect clipping rectangle to limit the scroll to.
|
||||
*
|
||||
*/
|
||||
void scroll(in PRInt32 aDx, in PRInt32 aDy, in nsRect aClipRect);
|
||||
|
||||
/**
|
||||
* Scroll an area of this widget.
|
||||
*
|
||||
* @param aRect source rectangle to scroll in the widget
|
||||
* @param aDx x offset from the source
|
||||
* @param aDy y offset from the source
|
||||
*
|
||||
*/
|
||||
void scrollRect(in nsRectRef aSrcRect, in PRInt32 aDx, in PRInt32 aDy);
|
||||
|
||||
/**
|
||||
* Set the widget's MenuBar.
|
||||
* Must be called after Create.
|
||||
*
|
||||
* @param aMenuBar the menubar
|
||||
*/
|
||||
void setMenuBar(in nsIMenuBar aMenuBar);
|
||||
|
||||
/**
|
||||
* Set the widget's MenuBar's visibility
|
||||
*
|
||||
* @param aShow PR_TRUE to show, PR_FALSE to hide
|
||||
*/
|
||||
void showMenuBar(in PRBool aShow);
|
||||
|
||||
/**
|
||||
* When adjustments are to made to a whole set of child widgets, call this
|
||||
* before resizing/positioning the child windows to minimize repaints. Must
|
||||
* be followed by EndResizingChildren() after child windows have been
|
||||
* adjusted.
|
||||
*
|
||||
*/
|
||||
void beginResizingChildren();
|
||||
|
||||
/**
|
||||
* Call this when finished adjusting child windows. Must be preceded by
|
||||
* BeginResizingChildren().
|
||||
*
|
||||
*/
|
||||
void endResizingChildren();
|
||||
|
||||
/* ATTRIBUTES */
|
||||
|
||||
|
||||
/**
|
||||
* Window type
|
||||
*/
|
||||
readonly attribute nsWindowType windowType;
|
||||
|
||||
/**
|
||||
* Border style
|
||||
*/
|
||||
readonly attribute nsBorderStyle borderStyle;
|
||||
|
||||
};
|
||||
@@ -1,64 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsRepeater_h___
|
||||
#define nsRepeater_h___
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
class EventRecord;
|
||||
|
||||
class NS_BASE Repeater {
|
||||
public:
|
||||
|
||||
Repeater();
|
||||
virtual ~Repeater();
|
||||
|
||||
virtual void RepeatAction(const EventRecord &aMacEvent) = 0;
|
||||
|
||||
void StartRepeating();
|
||||
void StopRepeating();
|
||||
void StartIdling();
|
||||
void StopIdling();
|
||||
|
||||
static void DoRepeaters(const EventRecord &aMacEvent);
|
||||
static void DoIdlers(const EventRecord &aMacEvent);
|
||||
|
||||
protected:
|
||||
|
||||
void AddToRepeatList();
|
||||
void RemoveFromRepeatList();
|
||||
void AddToIdleList();
|
||||
void RemoveFromIdleList();
|
||||
|
||||
static Repeater* sRepeaters;
|
||||
static Repeater* sIdlers;
|
||||
|
||||
bool mRepeating;
|
||||
bool mIdling;
|
||||
Repeater* mPrevRptr;
|
||||
Repeater* mNextRptr;
|
||||
Repeater* mPrevIdlr;
|
||||
Repeater* mNextIdlr;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,54 +0,0 @@
|
||||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
// Convience macros for converting nsString's to chars +
|
||||
// creating temporary char[] bufs.
|
||||
|
||||
#ifndef NS_STR_UTIL_H
|
||||
#define NS_STR_UTIL_H
|
||||
|
||||
// nsString to temporary char[] macro
|
||||
|
||||
// Convience MACROS to convert an nsString to a char * which use a
|
||||
// static char array if possible to reduce memory fragmentation,
|
||||
// otherwise they allocate a char[] which must be freed.
|
||||
// REMEMBER to always use the NS_FREE_STR_BUF after using the
|
||||
// NS_ALLOC_STR_BUF. You can not nest NS_ALLOC_STR_BUF's.
|
||||
|
||||
#define NS_ALLOC_CHAR_BUF(aBuf, aSize, aActualSize) \
|
||||
int _ns_tmpActualSize = aActualSize; \
|
||||
char _ns_smallBuffer[aSize]; \
|
||||
char * const aBuf = _ns_tmpActualSize <= aSize ? _ns_smallBuffer : new char[_ns_tmpActualSize];
|
||||
|
||||
#define NS_FREE_CHAR_BUF(aBuf) \
|
||||
if (aBuf != _ns_smallBuffer) \
|
||||
delete[] aBuf;
|
||||
|
||||
#define NS_ALLOC_STR_BUF(aBuf, aStrName, aTempSize) \
|
||||
NS_ALLOC_CHAR_BUF(aBuf, aTempSize, aStrName.Length()+1); \
|
||||
aStrName.ToCString(aBuf, aStrName.Length()+1);
|
||||
|
||||
#define NS_FREE_STR_BUF(aBuf) \
|
||||
NS_FREE_CHAR_BUF(aBuf)
|
||||
|
||||
|
||||
#endif // NSStringUtil
|
||||
@@ -1,141 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsWidgetSupport_h__
|
||||
#define nsWidgetSupport_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
|
||||
struct nsRect;
|
||||
class nsITextAreaWidget;
|
||||
class nsIFileWidget;
|
||||
class nsIAppShell;
|
||||
class nsIButton;
|
||||
class nsIComboBox;
|
||||
class nsIEventListener;
|
||||
class nsILabel;
|
||||
class nsIListBox;
|
||||
class nsIListWidget;
|
||||
class nsILookAndFeel;
|
||||
class nsIMouseListener;
|
||||
class nsIToolkit;
|
||||
class nsIWidget;
|
||||
class nsICheckButton;
|
||||
class nsIScrollbar;
|
||||
class nsIRadioButton;
|
||||
class nsITextWidget;
|
||||
class nsIBrowserWindow;
|
||||
|
||||
// These are a series of support methods which help in the creation
|
||||
// of widgets. They are not needed, but are provided as a convenience
|
||||
// mechanism when creating widgets
|
||||
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_CreateButton( nsISupports* aParent,
|
||||
nsIButton* aButton,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont = nsnull);
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_CreateCheckButton( nsISupports* aParent,
|
||||
nsICheckButton* aCheckButton,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont = nsnull);
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_CreateRadioButton( nsISupports* aParent,
|
||||
nsIRadioButton* aButton,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont = nsnull);
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_CreateLabel( nsISupports* aParent,
|
||||
nsILabel* aLabel,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont = nsnull);
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_CreateTextWidget(nsISupports* aParent,
|
||||
nsITextWidget* aWidget,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont = nsnull);
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_CreateTextAreaWidget(nsISupports* aParent,
|
||||
nsITextAreaWidget* aWidget,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont = nsnull);
|
||||
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_CreateListBox(nsISupports* aParent,
|
||||
nsIListBox* aWidget,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont = nsnull);
|
||||
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_CreateComboBox(nsISupports* aParent,
|
||||
nsIComboBox* aWidget,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont = nsnull);
|
||||
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_CreateScrollBar(nsISupports* aParent,
|
||||
nsIScrollbar* aWidget,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction);
|
||||
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_ShowWidget(nsISupports* aWidget, PRBool aShow);
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_MoveWidget(nsISupports* aWidget, PRUint32 aX, PRUint32 aY);
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_EnableWidget(nsISupports* aWidget, PRBool aEnable);
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_SetFocusToWidget(nsISupports* aWidget);
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_GetWidgetNativeData(nsISupports* aWidget, void** aNativeData);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,200 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/* 2d96b3d0-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_WINDOW_CID \
|
||||
{ 0x2d96b3d0, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9}}
|
||||
|
||||
/* 2d96b3d1-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_CHILD_CID \
|
||||
{ 0x2d96b3d1, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
|
||||
/* BA7DE611-6088-11d3-A83E-00105A183419 */
|
||||
#define NS_POPUP_CID \
|
||||
{ 0xba7de611, 0x6088, 0x11d3, \
|
||||
{ 0xa8, 0x3e, 0x0, 0x10, 0x5a, 0x18, 0x34, 0x19 } }
|
||||
|
||||
|
||||
/* 2d96b3d2-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_BUTTON_CID \
|
||||
{ 0x2d96b3d2, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* 2d96b3d3-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_CHECKBUTTON_CID \
|
||||
{ 0x2d96b3d3, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* 2d96b3d4-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_COMBOBOX_CID \
|
||||
{ 0x2d96b3d4, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* 2d96b3d5-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_FILEWIDGET_CID \
|
||||
{ 0x2d96b3d5, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* 2d96b3d6-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_LISTBOX_CID \
|
||||
{ 0x2d96b3d6, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* 2d96b3d7-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_RADIOBUTTON_CID \
|
||||
{ 0x2d96b3d7, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* 2d96b3d9-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_HORZSCROLLBAR_CID \
|
||||
{ 0x2d96b3d9, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* 2d96b3da-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_VERTSCROLLBAR_CID \
|
||||
{ 0x2d96b3da, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* 2d96b3db-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_TEXTAREA_CID \
|
||||
{ 0x2d96b3db, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* 2d96b3dc-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_TEXTFIELD_CID \
|
||||
{ 0x2d96b3dc, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* 2d96b3df-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_APPSHELL_CID \
|
||||
{ 0x2d96b3df, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* 2d96b3e0-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_TOOLKIT_CID \
|
||||
{ 0x2d96b3e0, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* XXX the following CID's are not in order. This needs
|
||||
to be fixed. */
|
||||
|
||||
/* 21B51DE0-21A3-11d2-B6E0-00805F8A2676 */
|
||||
#define NS_LOOKANDFEEL_CID \
|
||||
{ 0x21b51de0, 0x21a3, 0x11d2, \
|
||||
{ 0xb6, 0xe0, 0x0, 0x80, 0x5f, 0x8a, 0x26, 0x76 } }
|
||||
|
||||
/* 4A781D61-3D28-11d2-8DB8-00609703C14E */
|
||||
#define NS_DIALOG_CID \
|
||||
{ 0x4a781d61, 0x3d28, 0x11d2, \
|
||||
{ 0x8d, 0xb8, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
/* F3131891-3DC7-11d2-8DB8-00609703C14E */
|
||||
#define NS_LABEL_CID \
|
||||
{ 0xf3131891, 0x3dc7, 0x11d2, \
|
||||
{ 0x8d, 0xb8, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Menus
|
||||
//-----------------------------------------------------------
|
||||
|
||||
// {BC658C81-4BEB-11d2-8DBB-00609703C14E}
|
||||
#define NS_MENUBAR_CID \
|
||||
{ 0xbc658c81, 0x4beb, 0x11d2, \
|
||||
{ 0x8d, 0xbb, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
// {35A3DEC1-4992-11d2-8DBA-00609703C14E}
|
||||
#define NS_MENU_CID \
|
||||
{ 0x35a3dec1, 0x4992, 0x11d2, \
|
||||
{ 0x8d, 0xba, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
// {7F045771-4BEB-11d2-8DBB-00609703C14E}
|
||||
#define NS_MENUITEM_CID \
|
||||
{ 0x7f045771, 0x4beb, 0x11d2, \
|
||||
{ 0x8d, 0xbb, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
// {1677DAE1-04E2-11d3-B35C-00A0CC3C1CDE}
|
||||
#define NS_CONTEXTMENU_CID \
|
||||
{ 0x1677dae1, 0x4e2, 0x11d3, \
|
||||
{ 0xb3, 0x5c, 0x0, 0xa0, 0xcc, 0x3c, 0x1c, 0xde } }
|
||||
|
||||
//f58c2550-4a7c-11d2-bee2-00805f8a8dbd
|
||||
#define NS_IMAGEBUTTON_CID \
|
||||
{ 0xf58c2550, 0x4a7c, 0x11d2, \
|
||||
{0xbe, 0xe2, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} }
|
||||
|
||||
// {F6CD4F21-53AF-11d2-8DC4-00609703C14E}
|
||||
#define NS_POPUPMENU_CID \
|
||||
{ 0xf6cd4f21, 0x53af, 0x11d2, \
|
||||
{ 0x8d, 0xc4, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
#define NS_MENUBUTTON_CID \
|
||||
{ 0x67b8e261, 0x53c3, 0x11d2, \
|
||||
{ 0x8d, 0xc4, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
// {D3C3B8B2-55B5-11d2-9A2A-000000000000}
|
||||
#define NS_IMAGEBUTTONLISTENER_CID \
|
||||
{ 0xd3c3b8b2, 0x55b5, 0x11d2, \
|
||||
{ 0x9a, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
// {285EF9B2-094A-11d3-9A87-0050046CDA96}
|
||||
#define NS_FONTRETRIEVERSERVICE_CID \
|
||||
{ 0x285ef9b2, 0x94a, 0x11d3, { 0x9a, 0x87, 0x0, 0x50, 0x4, 0x6c, 0xda, 0x96 } }
|
||||
|
||||
//-----------------------------------------------------------
|
||||
//Drag & Drop & Clipboard
|
||||
//-----------------------------------------------------------
|
||||
// {8B5314BB-DB01-11d2-96CE-0060B0FB9956}
|
||||
#define NS_DRAGSERVICE_CID \
|
||||
{ 0x8b5314bb, 0xdb01, 0x11d2, { 0x96, 0xce, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } }
|
||||
|
||||
// {8B5314BC-DB01-11d2-96CE-0060B0FB9956}
|
||||
#define NS_TRANSFERABLE_CID \
|
||||
{ 0x8b5314bc, 0xdb01, 0x11d2, { 0x96, 0xce, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } }
|
||||
|
||||
// {8B5314BA-DB01-11d2-96CE-0060B0FB9956}
|
||||
#define NS_CLIPBOARD_CID \
|
||||
{ 0x8b5314ba, 0xdb01, 0x11d2, { 0x96, 0xce, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } }
|
||||
|
||||
// {8B5314BD-DB01-11d2-96CE-0060B0FB9956}
|
||||
#define NS_DATAFLAVOR_CID \
|
||||
{ 0x8b5314bd, 0xdb01, 0x11d2, { 0x96, 0xce, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } }
|
||||
|
||||
// {948A0023-E3A7-11d2-96CF-0060B0FB9956}
|
||||
#define NS_XIFFORMATCONVERTER_CID \
|
||||
{ 0x948a0023, 0xe3a7, 0x11d2, { 0x96, 0xcf, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } }
|
||||
|
||||
#define NS_DATAOBJ_CID \
|
||||
{ 0x1bba7640, 0xdf52, 0x11cf, { 0x82, 0x7b, 0, 0xa0, 0x24, 0x3a, 0xe5, 0x05 } }
|
||||
|
||||
// {E93E73B1-0197-11d3-96D4-0060B0FB9956}
|
||||
#define NS_FILELISTTRANSFERABLE_CID \
|
||||
{ 0xe93e73b1, 0x197, 0x11d3, { 0x96, 0xd4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } }
|
||||
|
||||
//-----------------------------------------------------------
|
||||
//Other
|
||||
//-----------------------------------------------------------
|
||||
// {B148EED2-236D-11d3-B35C-00A0CC3C1CDE}
|
||||
#define NS_SOUND_CID \
|
||||
{ 0xb148eed2, 0x236d, 0x11d3, { 0xb3, 0x5c, 0x0, 0xa0, 0xcc, 0x3c, 0x1c, 0xde } }
|
||||
@@ -1,62 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = xpwidgets support
|
||||
|
||||
#
|
||||
# Dont build the DSO under the 'build' directory as windows does.
|
||||
#
|
||||
# The DSOs get built in the toolkit dir itself. Do this so that
|
||||
# multiple implementations of widget can be built on the same
|
||||
# source tree.
|
||||
#
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
|
||||
ifdef MOZ_ENABLE_GTK
|
||||
DIRS += gtk
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_MOTIF
|
||||
DIRS += motif
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_XLIB
|
||||
DIRS += xlib
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_QT
|
||||
DIRS += qt
|
||||
endif
|
||||
|
||||
else
|
||||
DIRS += $(MOZ_WIDGET_TOOLKIT)
|
||||
endif
|
||||
|
||||
# unix_services are only useful in unix, duh...
|
||||
ifeq (,$(filter beos os2 rhapsody photon,$(MOZ_WIDGET_TOOLKIT)))
|
||||
DIRS += unix_services
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME = widget_beos
|
||||
|
||||
REQUIRES = util img xpcom raptor netlib
|
||||
|
||||
CPPSRCS = \
|
||||
nsAppShell.cpp \
|
||||
nsButton.cpp \
|
||||
nsCheckButton.cpp \
|
||||
nsClipboard.cpp \
|
||||
nsComboBox.cpp \
|
||||
nsDragService.cpp \
|
||||
nsFileWidget.cpp \
|
||||
nsFontRetrieverService.cpp \
|
||||
nsFontSizeIterator.cpp \
|
||||
nsLabel.cpp \
|
||||
nsListBox.cpp \
|
||||
nsLookAndFeel.cpp \
|
||||
nsMenu.cpp \
|
||||
nsMenuBar.cpp \
|
||||
nsMenuItem.cpp \
|
||||
nsObject.cpp \
|
||||
nsPopUpMenu.cpp \
|
||||
nsRadioButton.cpp \
|
||||
nsScrollbar.cpp \
|
||||
nsSound.cpp \
|
||||
nsTextAreaWidget.cpp \
|
||||
nsTextHelper.cpp \
|
||||
nsTextWidget.cpp \
|
||||
nsToolkit.cpp \
|
||||
nsWidgetFactory.cpp \
|
||||
nsWindow.cpp \
|
||||
$(NULL)
|
||||
|
||||
SHARED_LIBRARY_LIBS = $(DIST)/lib/libraptorbasewidget_s.a
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(TOOLKIT_DSO_LDOPTS) \
|
||||
$(MKSHLIB_FORCE_ALL) \
|
||||
$(SHARED_LIBRARY_LIBS) \
|
||||
$(MKSHLIB_UNFORCE_ALL) \
|
||||
$(TK_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_WIDGET -I$(srcdir)/../xpwidgets -I$(srcdir)
|
||||
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
|
||||
$(LIBRARY) $(SHARED_LIBRARY): $(SHARED_LIBRARY_LIBS) Makefile
|
||||
|
||||
@@ -1,332 +0,0 @@
|
||||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsAppShell.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsSwitchToUIThread.h"
|
||||
#include "plevent.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <AppKit.h>
|
||||
#include <AppFileInfo.h>
|
||||
|
||||
struct ThreadInterfaceData
|
||||
{
|
||||
void *data;
|
||||
int32 sync;
|
||||
};
|
||||
|
||||
static sem_id my_find_sem(const char *name)
|
||||
{
|
||||
sem_id ret = B_ERROR;
|
||||
|
||||
/* Get the sem_info for every sempahore in this team. */
|
||||
sem_info info;
|
||||
int32 cookie = 0;
|
||||
|
||||
while(get_next_sem_info(0, &cookie, &info) == B_OK)
|
||||
if(strcmp(name, info.name) == 0)
|
||||
{
|
||||
ret = info.sem;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsISupports implementation macro
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID);
|
||||
NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
NS_IMPL_ISUPPORTS(nsAppShell,kIAppShellIID);
|
||||
|
||||
static bool GetAppSig(char *sig)
|
||||
{
|
||||
app_info appInfo;
|
||||
BFile file;
|
||||
BAppFileInfo appFileInfo;
|
||||
image_info info;
|
||||
int32 cookie = 0;
|
||||
*sig = 0;
|
||||
return get_next_image_info(0, &cookie, &info) == B_OK &&
|
||||
file.SetTo(info.name, B_READ_ONLY) == B_OK &&
|
||||
appFileInfo.SetTo(&file) == B_OK &&
|
||||
appFileInfo.GetSignature(sig) == B_OK;
|
||||
}
|
||||
|
||||
class nsBeOSApp : public BApplication
|
||||
{
|
||||
sem_id init;
|
||||
public:
|
||||
nsBeOSApp(const char *signature, sem_id initsem);
|
||||
virtual void ReadyToRun(void);
|
||||
};
|
||||
|
||||
nsBeOSApp::nsBeOSApp(const char *signature, sem_id initsem)
|
||||
: BApplication(signature), init(initsem)
|
||||
{
|
||||
}
|
||||
|
||||
void nsBeOSApp::ReadyToRun(void)
|
||||
{
|
||||
release_sem(init);
|
||||
}
|
||||
|
||||
int32 bapp_thread(void *arg)
|
||||
{
|
||||
// create and start BApplication
|
||||
char sig[B_MIME_TYPE_LENGTH + 1];
|
||||
GetAppSig(sig);
|
||||
nsBeOSApp *app = new nsBeOSApp(sig, (sem_id)arg);
|
||||
app->Run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsAppShell constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsAppShell::nsAppShell()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mDispatchListener = 0;
|
||||
|
||||
sem_id initsem = create_sem(0, "bapp init");
|
||||
resume_thread(spawn_thread(bapp_thread, "BApplication", B_NORMAL_PRIORITY, (void *)initsem));
|
||||
acquire_sem(initsem);
|
||||
delete_sem(initsem);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Create the application shell
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsAppShell::Create(int* argc, char ** argv)
|
||||
{
|
||||
// system wide unique names
|
||||
// NOTE: this needs to be run from within the main application thread
|
||||
char portname[64];
|
||||
char semname[64];
|
||||
sprintf(portname, "event%lx", PR_GetCurrentThread());
|
||||
sprintf(semname, "sync%lx", PR_GetCurrentThread());
|
||||
|
||||
if((eventport = find_port(portname)) < 0)
|
||||
{
|
||||
// we're here first
|
||||
eventport = create_port(100, portname);
|
||||
syncsem = create_sem(0, semname);
|
||||
}
|
||||
else
|
||||
{
|
||||
// the PLEventQueue stuff (in plevent.c) created the queue before we started
|
||||
syncsem = my_find_sem(semname);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
|
||||
{
|
||||
mDispatchListener = aDispatchListener;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Enter a message handler loop
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
nsresult nsAppShell::Run()
|
||||
{
|
||||
int32 code;
|
||||
ThreadInterfaceData id;
|
||||
|
||||
NS_ADDREF_THIS();
|
||||
|
||||
while(read_port(eventport, &code, &id, sizeof(id)) >= 0)
|
||||
{
|
||||
switch(code)
|
||||
{
|
||||
case 'WMti' :
|
||||
extern void nsTimerExpired(void *); // hack: this is in gfx
|
||||
nsTimerExpired(id.data);
|
||||
break;
|
||||
|
||||
case WM_CALLMETHOD :
|
||||
{
|
||||
MethodInfo *mInfo = (MethodInfo *)id.data;
|
||||
mInfo->Invoke();
|
||||
if(! id.sync)
|
||||
delete mInfo;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'natv' : // native queue PLEvent
|
||||
{
|
||||
PREventQueue *queue = (PREventQueue *)id.data;
|
||||
PR_ProcessPendingEvents(queue);
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
printf("nsAppShell::Run - UNKNOWN EVENT\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(mDispatchListener)
|
||||
mDispatchListener->AfterDispatch();
|
||||
|
||||
if(id.sync)
|
||||
release_sem(syncsem);
|
||||
}
|
||||
|
||||
Release();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Exit a message handler loop
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsAppShell::Exit()
|
||||
{
|
||||
// interrupt message flow
|
||||
close_port(eventport);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsAppShell destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsAppShell::~nsAppShell()
|
||||
{
|
||||
if(be_app->Lock())
|
||||
be_app->Quit();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// GetNativeData
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void* nsAppShell::GetNativeData(PRUint32 aDataType)
|
||||
{
|
||||
if (aDataType == NS_NATIVE_SHELL) {
|
||||
return NULL;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Spinup - do any preparation necessary for running a message loop
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsAppShell::Spinup()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Spindown - do any cleanup necessary for finishing a message loop
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsAppShell::Spindown()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// PushThreadEventQueue - begin processing events from a new queue
|
||||
// note this is the Windows implementation and may suffice, but
|
||||
// this is untested on beos.
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsAppShell::PushThreadEventQueue()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// push a nested event queue for event processing from netlib
|
||||
// onto our UI thread queue stack.
|
||||
NS_WITH_SERVICE(nsIEventQueueService, eQueueService, kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = eQueueService->PushThreadEventQueue();
|
||||
else
|
||||
NS_ERROR("Appshell unable to obtain eventqueue service.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// PopThreadEventQueue - stop processing on a previously pushed event queue
|
||||
// note this is the Windows implementation and may suffice, but
|
||||
// this is untested on beos.
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsAppShell::PopThreadEventQueue()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIEventQueueService, eQueueService, kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = eQueueService->PopThreadEventQueue();
|
||||
else
|
||||
NS_ERROR("Appshell unable to obtain eventqueue service.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_METHOD nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *&aEvent)
|
||||
{
|
||||
printf("nsAppShell::GetNativeEvent - FIXME: not implemented\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void *aEvent)
|
||||
{
|
||||
printf("nsAppShell::DispatchNativeEvent - FIXME: not implemented\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsAppShell::EventIsForModalWindow(PRBool aRealEvent, void *aEvent, nsIWidget *aWidget, PRBool *aForWindow)
|
||||
{
|
||||
printf("nsAppShell::EventIsForModalWindow - FIXME: not implemented\n");
|
||||
*aForWindow = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsAppShell_h__
|
||||
#define nsAppShell_h__
|
||||
|
||||
#include "nsObject.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include <OS.h>
|
||||
|
||||
/**
|
||||
* Native BeOS Application shell wrapper
|
||||
*/
|
||||
|
||||
class nsAppShell : public nsIAppShell
|
||||
{
|
||||
public:
|
||||
nsAppShell();
|
||||
virtual ~nsAppShell();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIAppShellInterface
|
||||
|
||||
NS_IMETHOD Create(int* argc, char ** argv);
|
||||
virtual nsresult Run();
|
||||
NS_IMETHOD Spinup();
|
||||
NS_IMETHOD Spindown();
|
||||
NS_IMETHOD PushThreadEventQueue();
|
||||
NS_IMETHOD PopThreadEventQueue();
|
||||
NS_IMETHOD GetNativeEvent(PRBool &aRealEvent, void *&aEvent);
|
||||
NS_IMETHOD DispatchNativeEvent(PRBool aRealEvent, void * aEvent);
|
||||
NS_IMETHOD EventIsForModalWindow(PRBool aRealEvent, void *aEvent,
|
||||
nsIWidget *aWidget, PRBool *aForWindow);
|
||||
NS_IMETHOD Exit();
|
||||
NS_IMETHOD SetDispatchListener(nsDispatchListener* aDispatchListener);
|
||||
virtual void* GetNativeData(PRUint32 aDataType);
|
||||
|
||||
private:
|
||||
nsDispatchListener *mDispatchListener;
|
||||
port_id eventport;
|
||||
sem_id syncsem;
|
||||
};
|
||||
|
||||
#endif // nsAppShell_h__
|
||||
@@ -1,282 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsButton.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringUtil.h"
|
||||
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
|
||||
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsButton)
|
||||
NS_IMPL_RELEASE(nsButton)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsButton constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsButton::nsButton() : nsWindow() , nsIButton()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsButton destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsButton::~nsButton()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID
|
||||
* @modify gpk 8/4/98
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*
|
||||
*/
|
||||
nsresult nsButton::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIButton, NS_IBUTTON_IID);
|
||||
if (aIID.Equals(kIButton)) {
|
||||
*aInstancePtr = (void*) ((nsIButton*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsWindow::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
mLabel = aText;
|
||||
if(NULL == mView) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ALLOC_STR_BUF(label, aText, 256);
|
||||
if(mButton)
|
||||
{
|
||||
if(mButton->Looper())
|
||||
mButton->LockLooper();
|
||||
|
||||
mButton->SetLabel(label);
|
||||
|
||||
if(mButton->Looper())
|
||||
mButton->UnlockLooper();
|
||||
}
|
||||
NS_FREE_STR_BUF(label);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
aBuffer = mLabel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// move, paint, resizes message - ignore
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsButton::OnMove(PRInt32, PRInt32)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsButton::OnPaint(nsRect &r)
|
||||
{
|
||||
//printf("** nsButton::OnPaint **\n");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsButton::OnResize(nsRect &aWindowRect)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the Button for Printing
|
||||
*
|
||||
**/
|
||||
NS_METHOD nsButton::Paint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
float appUnits;
|
||||
float devUnits;
|
||||
float scale;
|
||||
nsIDeviceContext * context;
|
||||
aRenderingContext.GetDeviceContext(context);
|
||||
|
||||
context->GetCanonicalPixelScale(scale);
|
||||
context->GetAppUnitsToDevUnits(devUnits);
|
||||
context->GetDevUnitsToAppUnits(appUnits);
|
||||
|
||||
nsRect rect;
|
||||
GetBoundsAppUnits(rect, appUnits);
|
||||
aRenderingContext.SetColor(NS_RGB(0,0,0));
|
||||
|
||||
nscolor bgColor = NS_RGB(255,255,255);
|
||||
nscolor fgColor = NS_RGB(0,0,0);
|
||||
nscolor hltColor = NS_RGB(240,240,240);
|
||||
nscolor sdwColor = NS_RGB(128,128,128);
|
||||
|
||||
nsILookAndFeel * lookAndFeel;
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) {
|
||||
lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, bgColor);
|
||||
lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetForeground, fgColor);
|
||||
lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DShadow, sdwColor);
|
||||
lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DHighlight, hltColor);
|
||||
}
|
||||
|
||||
aRenderingContext.SetColor(bgColor);
|
||||
aRenderingContext.FillRect(rect);
|
||||
|
||||
/*aRenderingContext.SetColor(bgColor);
|
||||
for (int i=0;i<int(scale);i++) {
|
||||
aRenderingContext.DrawRect(rect);
|
||||
rect.x += 3;
|
||||
rect.y += 3;
|
||||
rect.width -= 6;
|
||||
rect.height -= 6;
|
||||
}*/
|
||||
|
||||
nscoord onePixel = nscoord(scale);
|
||||
nscoord twoPixels = nscoord(scale*2);
|
||||
|
||||
rect.x += onePixel;
|
||||
rect.y += onePixel;
|
||||
rect.width -= twoPixels;
|
||||
rect.height -= twoPixels;
|
||||
|
||||
nscoord right = rect.x+rect.width;
|
||||
nscoord bottom = rect.y+rect.height;
|
||||
|
||||
|
||||
// Draw Left & Top
|
||||
aRenderingContext.SetColor(NS_RGB(225,225,225));
|
||||
DrawScaledLine(aRenderingContext, rect.x, rect.y, right, rect.y, scale, appUnits, PR_TRUE); // top
|
||||
DrawScaledLine(aRenderingContext, rect.x, rect.y, rect.x, bottom, scale, appUnits, PR_FALSE); // left
|
||||
|
||||
//DrawScaledLine(aRenderingContext, rect.x+onePixel, rect.y+onePixel, right-onePixel, rect.y+onePixel, scale, appUnits, PR_TRUE); // top + 1
|
||||
//DrawScaledLine(aRenderingContext, rect.x+onePixel, rect.y+onePixel, rect.x+onePixel, bottom-onePixel, scale, appUnits, PR_FALSE); // left + 1
|
||||
|
||||
// Draw Right & Bottom
|
||||
aRenderingContext.SetColor(NS_RGB(128,128,128));
|
||||
DrawScaledLine(aRenderingContext, right, rect.y+onePixel, right, bottom, scale, appUnits, PR_FALSE); // right
|
||||
DrawScaledLine(aRenderingContext, rect.x+onePixel, bottom, right, bottom, scale, appUnits, PR_TRUE); // bottom
|
||||
|
||||
//DrawScaledLine(aRenderingContext, right-onePixel, rect.y+twoPixels, right-onePixel, bottom, scale, appUnits, PR_FALSE); // right + 1
|
||||
//DrawScaledLine(aRenderingContext, rect.x+twoPixels, bottom-onePixel, right, bottom-onePixel, scale, appUnits, PR_TRUE); // bottom + 1
|
||||
|
||||
aRenderingContext.SetFont(*mFont);
|
||||
|
||||
nscoord textWidth;
|
||||
nscoord textHeight;
|
||||
aRenderingContext.GetWidth(mLabel, textWidth);
|
||||
|
||||
nsIFontMetrics* metrics;
|
||||
context->GetMetricsFor(*mFont, metrics);
|
||||
metrics->GetMaxAscent(textHeight);
|
||||
|
||||
nscoord x = ((rect.width - textWidth) / 2) + rect.x;
|
||||
nscoord y = ((rect.height - textHeight) / 2) + rect.y;
|
||||
aRenderingContext.DrawString(mLabel, x, y);
|
||||
|
||||
|
||||
NS_RELEASE(context);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
BView *nsButton::CreateBeOSView()
|
||||
{
|
||||
return mButton = new nsButtonBeOS(this, BRect(0, 0, 0, 0), "", "");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Sub-class of BeOS Button
|
||||
//-------------------------------------------------------------------------
|
||||
nsButtonBeOS::nsButtonBeOS( nsIWidget *aWidgetWindow, BRect aFrame,
|
||||
const char *aName, const char *aLabel, uint32 aResizingMode, uint32 aFlags )
|
||||
: BButton( aFrame, aName, aLabel, new BMessage('clik'), aResizingMode, aFlags ),
|
||||
nsIWidgetStore( aWidgetWindow )
|
||||
{
|
||||
}
|
||||
|
||||
void nsButtonBeOS::AttachedToWindow()
|
||||
{
|
||||
SetTarget(this);
|
||||
}
|
||||
|
||||
void nsButtonBeOS::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch(msg->what)
|
||||
{
|
||||
case 'clik' :
|
||||
{
|
||||
nsWindow *w = (nsWindow *)GetMozillaWidget();
|
||||
nsToolkit *t;
|
||||
if(w && (t = w->GetToolkit()) != 0)
|
||||
{
|
||||
uint32 args[5];
|
||||
args[0] = NS_MOUSE_LEFT_CLICK;
|
||||
args[1] = (uint32)0;
|
||||
args[2] = (uint32)0;
|
||||
args[3] = 1;
|
||||
args[4] = modifiers();
|
||||
MethodInfo *info = new MethodInfo(w, w, nsWindow::BTNCLICK, 5, args);
|
||||
t->CallMethodAsync(info);
|
||||
NS_RELEASE(t);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
BButton::MessageReceived(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsButton_h__
|
||||
#define nsButton_h__
|
||||
|
||||
#include "nsdefs.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsSwitchToUIThread.h"
|
||||
|
||||
#include "nsIButton.h"
|
||||
|
||||
#include <Button.h>
|
||||
|
||||
/**
|
||||
* Native Win32 button wrapper
|
||||
*/
|
||||
|
||||
class nsButton : public nsWindow,
|
||||
public nsIButton
|
||||
{
|
||||
|
||||
public:
|
||||
nsButton();
|
||||
virtual ~nsButton();
|
||||
|
||||
//nsISupports
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
// nsIButton part
|
||||
NS_IMETHOD SetLabel(const nsString& aText);
|
||||
NS_IMETHOD GetLabel(nsString& aBuffer);
|
||||
|
||||
// nsBaseWidget
|
||||
NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
||||
virtual PRBool OnPaint(nsRect &r);
|
||||
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||
|
||||
protected:
|
||||
nsString mLabel;
|
||||
virtual BView *CreateBeOSView();
|
||||
BButton *mButton;
|
||||
};
|
||||
|
||||
//
|
||||
// A BButton subclass
|
||||
//
|
||||
class nsButtonBeOS : public BButton, public nsIWidgetStore {
|
||||
public:
|
||||
nsButtonBeOS( nsIWidget *aWidgetWindow, BRect aFrame, const char *aName,
|
||||
const char *aLabel, uint32 aResizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 aFlags = B_WILL_DRAW | B_NAVIGABLE );
|
||||
void AttachedToWindow();
|
||||
void MessageReceived(BMessage *msg);
|
||||
};
|
||||
|
||||
#endif // nsButton_h__
|
||||
@@ -1,102 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef CLIST_H
|
||||
#define CLIST_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
//
|
||||
// Simple circular linked-list implementation...
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Foreward declarations...
|
||||
struct CList;
|
||||
|
||||
#define OBJECT_PTR_FROM_CLIST(className, listElement) \
|
||||
((char*)listElement - offsetof(className, m_link))
|
||||
|
||||
|
||||
struct CList {
|
||||
CList *next;
|
||||
CList *prev;
|
||||
|
||||
CList() {
|
||||
next = prev = this;
|
||||
}
|
||||
|
||||
~CList() {
|
||||
Remove();
|
||||
}
|
||||
|
||||
//
|
||||
// Append an element to the end of this list
|
||||
//
|
||||
void Append(CList &element) {
|
||||
element.next = this;
|
||||
element.prev = prev;
|
||||
prev->next = &element;
|
||||
prev = &element;
|
||||
}
|
||||
|
||||
//
|
||||
// Add an element to the beginning of this list
|
||||
//
|
||||
void Add(CList &element) {
|
||||
element.next = next;
|
||||
element.prev = this;
|
||||
next->prev = &element;
|
||||
next = &element;
|
||||
}
|
||||
|
||||
//
|
||||
// Append this element to the end of a list
|
||||
//
|
||||
void AppendToList(CList &list) {
|
||||
list.Append(*this);
|
||||
}
|
||||
|
||||
//
|
||||
// Add this element to the beginning of a list
|
||||
//
|
||||
void AddToList(CList &list) {
|
||||
list.Add(*this);
|
||||
}
|
||||
|
||||
//
|
||||
// Remove this element from the list and re-initialize
|
||||
//
|
||||
void Remove(void) {
|
||||
prev->next = next;
|
||||
next->prev = prev;
|
||||
|
||||
next = prev = this;
|
||||
}
|
||||
|
||||
//
|
||||
// Is this list empty ?
|
||||
//
|
||||
bool IsEmpty(void) {
|
||||
return (next == this);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CLIST_H
|
||||
|
||||
@@ -1,237 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsCheckButton.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringUtil.h"
|
||||
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#include "nsIDeviceContext.h"
|
||||
|
||||
NS_IMPL_ADDREF(nsCheckButton)
|
||||
NS_IMPL_RELEASE(nsCheckButton)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsCheckButton constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsCheckButton::nsCheckButton() : nsWindow() , nsICheckButton(),
|
||||
mState(PR_FALSE)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsCheckButton destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsCheckButton::~nsCheckButton()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID
|
||||
* @modify gpk 8/4/98
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*
|
||||
*/
|
||||
nsresult nsCheckButton::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
|
||||
if (aIID.Equals(kICheckButtonIID)) {
|
||||
*aInstancePtr = (void*) ((nsICheckButton*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return nsWindow::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsCheckButton::SetState(const PRBool aState)
|
||||
{
|
||||
mState = aState;
|
||||
if(mCheckBox && mCheckBox->LockLooper())
|
||||
{
|
||||
mCheckBox->SetValue(aState ? 1 : 0);
|
||||
mCheckBox->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsCheckButton::GetState(PRBool& aState)
|
||||
{
|
||||
aState = mState;
|
||||
if(mCheckBox && mCheckBox->LockLooper())
|
||||
{
|
||||
aState = mCheckBox->Value() ? PR_TRUE : PR_FALSE;
|
||||
mCheckBox->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsCheckButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
char label[256];
|
||||
aText.ToCString(label, 256);
|
||||
label[255] = '\0';
|
||||
if(mCheckBox && mCheckBox->LockLooper())
|
||||
{
|
||||
mCheckBox->SetLabel(label);
|
||||
mCheckBox->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsCheckButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
if(mCheckBox && mCheckBox->LockLooper())
|
||||
{
|
||||
aBuffer.SetLength(0);
|
||||
aBuffer.Append(mCheckBox->Label());
|
||||
mCheckBox->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// move, paint, resizes message - ignore
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsCheckButton::OnMove(PRInt32, PRInt32)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsCheckButton::OnPaint(nsRect &r)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsCheckButton::OnResize(nsRect &aWindowRect)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Renders the CheckButton for Printing
|
||||
*
|
||||
**/
|
||||
NS_METHOD nsCheckButton::Paint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
nsRect rect;
|
||||
float appUnits;
|
||||
float scale;
|
||||
nsIDeviceContext * context;
|
||||
aRenderingContext.GetDeviceContext(context);
|
||||
|
||||
context->GetCanonicalPixelScale(scale);
|
||||
context->GetDevUnitsToAppUnits(appUnits);
|
||||
|
||||
GetBoundsAppUnits(rect, appUnits);
|
||||
|
||||
nscoord one = nscoord(PRFloat64(rect.height) * 1.0/20.0);
|
||||
nscoord three = nscoord(PRFloat64(rect.width) * 3.0/20.0);
|
||||
nscoord five = nscoord(PRFloat64(rect.width) * 5.0/20.0);
|
||||
nscoord six = nscoord(PRFloat64(rect.height) * 5.0/20.0);
|
||||
nscoord eight = nscoord(PRFloat64(rect.height) * 7.0/20.0);
|
||||
nscoord nine = nscoord(PRFloat64(rect.width) * 9.0/20.0);
|
||||
nscoord ten = nscoord(PRFloat64(rect.height) * 9.0/20.0);
|
||||
|
||||
rect.x += three;
|
||||
rect.y += nscoord(PRFloat64(rect.height) * 3.5 /20.0);
|
||||
rect.width = nscoord(PRFloat64(rect.width) * 12.0/20.0);
|
||||
rect.height = nscoord(PRFloat64(rect.height) * 12.0/20.0);
|
||||
|
||||
aRenderingContext.SetColor(NS_RGB(0,0,0));
|
||||
|
||||
nscoord onePixel = nscoord((appUnits+0.6F));
|
||||
DrawScaledRect(aRenderingContext, rect, scale, appUnits);
|
||||
nscoord x = rect.x;
|
||||
nscoord y = rect.y;
|
||||
|
||||
if (mState) {
|
||||
nscoord inc = nscoord(PRFloat64(rect.height) * 0.75/20.0);
|
||||
nscoord yy = 0;
|
||||
for (nscoord i=0;i<4;i++) {
|
||||
DrawScaledLine(aRenderingContext, x+three, y+eight+yy, x+five, y+ten+yy, scale, appUnits, PR_FALSE); // top
|
||||
DrawScaledLine(aRenderingContext, x+five, y+ten+yy, x+nine, y+six+yy, scale, appUnits, PR_FALSE); // top
|
||||
//aRenderingContext.DrawLine(x+three, y+eight+yy, x+five, y+ten+yy);
|
||||
//aRenderingContext.DrawLine(x+five, y+ten+yy, x+nine, y+six+yy);
|
||||
yy += nscoord(scale);
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(context);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
BView *nsCheckButton::CreateBeOSView()
|
||||
{
|
||||
return mCheckBox = new nsCheckBoxBeOS(this, BRect(0, 0, 0, 0), "", "", NULL);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Sub-class of BeOS CheckBox
|
||||
//-------------------------------------------------------------------------
|
||||
nsCheckBoxBeOS::nsCheckBoxBeOS( nsIWidget *aWidgetWindow, BRect aFrame,
|
||||
const char *aName, const char *aLabel, BMessage *aMessage,
|
||||
uint32 aResizingMode, uint32 aFlags )
|
||||
: BCheckBox( aFrame, aName, aLabel, aMessage, aResizingMode, aFlags ),
|
||||
nsIWidgetStore( aWidgetWindow )
|
||||
{
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsCheckButton_h__
|
||||
#define nsCheckButton_h__
|
||||
|
||||
#include "nsdefs.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsSwitchToUIThread.h"
|
||||
|
||||
#include "nsICheckButton.h"
|
||||
|
||||
#include <CheckBox.h>
|
||||
|
||||
/**
|
||||
* Native Win32 Checkbox wrapper
|
||||
*/
|
||||
|
||||
class nsCheckButton : public nsWindow,
|
||||
public nsICheckButton
|
||||
{
|
||||
|
||||
public:
|
||||
nsCheckButton();
|
||||
virtual ~nsCheckButton();
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
// nsICheckButton part
|
||||
NS_IMETHOD SetLabel(const nsString &aText);
|
||||
NS_IMETHOD GetLabel(nsString &aBuffer);
|
||||
NS_IMETHOD SetState(const PRBool aState);
|
||||
NS_IMETHOD GetState(PRBool& aState);
|
||||
|
||||
NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
||||
virtual PRBool OnPaint(nsRect &r);
|
||||
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||
|
||||
|
||||
protected:
|
||||
PRBool mState;
|
||||
virtual BView *CreateBeOSView();
|
||||
BCheckBox *mCheckBox;
|
||||
};
|
||||
|
||||
//
|
||||
// A BCheckBox subclass
|
||||
//
|
||||
class nsCheckBoxBeOS : public BCheckBox, public nsIWidgetStore {
|
||||
public:
|
||||
nsCheckBoxBeOS( nsIWidget *aWidgetWindow, BRect aFrame, const char *aName,
|
||||
const char *aLabel, BMessage *aMessage, uint32 aResizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 aFlags = B_WILL_DRAW | B_NAVIGABLE );
|
||||
};
|
||||
|
||||
#endif // nsCheckButton_h__
|
||||
@@ -1,523 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsClipboard.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIClipboardOwner.h"
|
||||
#include "nsITransferable.h" // kTextMime
|
||||
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
#include <View.h>
|
||||
|
||||
// The class statics:
|
||||
BView *nsClipboard::sView = 0;
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsClipboard, nsBaseClipboard)
|
||||
NS_IMPL_RELEASE_INHERITED(nsClipboard, nsBaseClipboard)
|
||||
|
||||
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
|
||||
|
||||
#if defined(DEBUG_akkana) || defined(DEBUG_mcafee)
|
||||
#define DEBUG_CLIPBOARD
|
||||
#endif
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsClipboard constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsClipboard::nsClipboard() : nsBaseClipboard()
|
||||
{
|
||||
#ifdef DEBUG_CLIPBOARD
|
||||
printf(" nsClipboard::nsClipboard()\n");
|
||||
#endif /* DEBUG_CLIPBOARD */
|
||||
|
||||
//NS_INIT_REFCNT();
|
||||
mIgnoreEmptyNotification = PR_FALSE;
|
||||
mClipboardOwner = nsnull;
|
||||
mTransferable = nsnull;
|
||||
// mSelectionData.data = nsnull;
|
||||
// mSelectionData.length = 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsClipboard destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsClipboard::~nsClipboard()
|
||||
{
|
||||
#ifdef DEBUG_CLIPBOARD
|
||||
printf(" nsClipboard::~nsClipboard()\n");
|
||||
#endif /* DEBUG_CLIPBOARD */
|
||||
|
||||
// // Remove all our event handlers:
|
||||
// if (sView &&
|
||||
// gdk_selection_owner_get (GDK_SELECTION_PRIMARY) == sWidget->window)
|
||||
// gtk_selection_remove_all(sWidget);
|
||||
//
|
||||
// // free the selection data, if any
|
||||
// if (mSelectionData.data != nsnull)
|
||||
// g_free(mSelectionData.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*
|
||||
*/
|
||||
nsresult nsClipboard::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv = NS_NOINTERFACE;
|
||||
|
||||
if (aIID.Equals(nsIClipboard::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsIClipboard*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
void nsClipboard::SetTopLevelView(BView *v)
|
||||
{
|
||||
// Don't set up any more event handlers if we're being called twice
|
||||
// for the same toplevel widget
|
||||
if (sView == v)
|
||||
return;
|
||||
|
||||
if (sView != 0 && sView->Window() != 0)
|
||||
return;
|
||||
|
||||
if(v == 0 || v->Window() == 0)
|
||||
{
|
||||
#ifdef DEBUG_CLIPBOARD
|
||||
printf(" nsClipboard::SetTopLevelView: widget passed in is null or has no window!\n");
|
||||
#endif /* DEBUG_CLIPBOARD */
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_CLIPBOARD
|
||||
printf(" nsClipboard::SetTopLevelView\n");
|
||||
#endif /* DEBUG_CLIPBOARD */
|
||||
|
||||
// // If we're changing from one widget to another
|
||||
// // (shouldn't generally happen), clear the old event handlers:
|
||||
// if (sView &&
|
||||
// gdk_selection_owner_get (GDK_SELECTION_PRIMARY) == sWidget->window)
|
||||
// gtk_selection_remove_all(sWidget);
|
||||
//
|
||||
// sWidget = w;
|
||||
//
|
||||
// // Get the clipboard from the service manager.
|
||||
// nsresult rv;
|
||||
// NS_WITH_SERVICE(nsIClipboard, clipboard, kCClipboardCID, &rv);
|
||||
//
|
||||
// if (!NS_SUCCEEDED(rv)) {
|
||||
// printf("Couldn't get clipboard service!\n");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // Handle selection requests if we called gtk_selection_add_target:
|
||||
// gtk_signal_connect(GTK_OBJECT(sWidget), "selection_get",
|
||||
// GTK_SIGNAL_FUNC(nsClipboard::SelectionGetCB),
|
||||
// clipboard);
|
||||
//
|
||||
// // When someone else takes the selection away:
|
||||
// gtk_signal_connect(GTK_OBJECT(sWidget), "selection_clear_event",
|
||||
// GTK_SIGNAL_FUNC(nsClipboard::SelectionClearCB),
|
||||
// clipboard);
|
||||
//
|
||||
// // Set up the paste handler:
|
||||
// gtk_signal_connect(GTK_OBJECT(sWidget), "selection_received",
|
||||
// GTK_SIGNAL_FUNC(nsClipboard::SelectionReceivedCB),
|
||||
// clipboard);
|
||||
//
|
||||
//#if 0
|
||||
// // Handle selection requests if we called gtk_selection_add_targets:
|
||||
// gtk_signal_connect(GTK_OBJECT(sWidget), "selection_request_event",
|
||||
// GTK_SIGNAL_FUNC(nsClipboard::SelectionRequestCB),
|
||||
// clipboard);
|
||||
//
|
||||
// // Watch this, experimenting with Gtk :-)
|
||||
// gtk_signal_connect(GTK_OBJECT(sWidget), "selection_notify_event",
|
||||
// GTK_SIGNAL_FUNC(nsClipboard::SelectionNotifyCB),
|
||||
// clipboard);
|
||||
//#endif
|
||||
//
|
||||
// // Hmm, sometimes we need this, sometimes not. I'm not clear why.
|
||||
// // See also long comment above on why we don't register a whole target list.
|
||||
//
|
||||
// // Register all the target types we handle:
|
||||
// gtk_selection_add_target(sWidget,
|
||||
// GDK_SELECTION_PRIMARY,
|
||||
// GDK_SELECTION_TYPE_STRING,
|
||||
// GDK_SELECTION_TYPE_STRING);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsClipboard::SetNativeClipboardData()
|
||||
{
|
||||
mIgnoreEmptyNotification = PR_TRUE;
|
||||
|
||||
#ifdef DEBUG_CLIPBOARD
|
||||
printf(" nsClipboard::SetNativeClipboardData()\n");
|
||||
#endif /* DEBUG_CLIPBOARD */
|
||||
|
||||
// make sure we have a good transferable
|
||||
if (nsnull == mTransferable) {
|
||||
printf(" SetNativeClipboardData: no transferable!\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// // If we're already the selection owner, don't need to do anything,
|
||||
// // we'll already get the events:
|
||||
// if (gdk_selection_owner_get (GDK_SELECTION_PRIMARY) == sWidget->window)
|
||||
// return NS_OK;
|
||||
//
|
||||
// // Clear the native clipboard
|
||||
// if (sWidget &&
|
||||
// gdk_selection_owner_get (GDK_SELECTION_PRIMARY) == sWidget->window)
|
||||
// gtk_selection_remove_all(sWidget);
|
||||
//
|
||||
//
|
||||
// // register as the selection owner:
|
||||
// gint have_selection =
|
||||
// gtk_selection_owner_set(sWidget,
|
||||
// GDK_SELECTION_PRIMARY,
|
||||
// GDK_CURRENT_TIME);
|
||||
// if (have_selection == 0)
|
||||
// return NS_ERROR_FAILURE;
|
||||
|
||||
mIgnoreEmptyNotification = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// The blocking Paste routine
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
#ifdef DEBUG_CLIPBOARD
|
||||
printf(" nsClipboard::GetNativeClipboardData()\n");
|
||||
#endif /* DEBUG_CLIPBOARD */
|
||||
|
||||
// make sure we have a good transferable
|
||||
if (nsnull == aTransferable) {
|
||||
printf(" GetNativeClipboardData: Transferable is null!\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Dunno why we need to do this, copying the win32 code ...
|
||||
nsCOMPtr<nsITransferable> trans = do_QueryInterface(aTransferable);
|
||||
if (!trans)
|
||||
return rv;
|
||||
|
||||
// //
|
||||
// // We can't call the copy callback when we're blocking on the paste callback;
|
||||
// // so if this app is already the selection owner, we need to copy our own
|
||||
// // data without going through the X server.
|
||||
// //
|
||||
// if (gdk_selection_owner_get (GDK_SELECTION_PRIMARY) == sWidget->window)
|
||||
// {
|
||||
// // XXX only support text/plain for now
|
||||
// nsAutoString dataFlavor(kTextMime);
|
||||
//
|
||||
// // Get data out of our existing transferable.
|
||||
// void *clipboardData;
|
||||
// PRUint32 dataLength;
|
||||
// rv = mTransferable->GetTransferData(&dataFlavor,
|
||||
// &clipboardData,
|
||||
// &dataLength);
|
||||
// if (NS_SUCCEEDED(rv))
|
||||
// rv = trans->SetTransferData(&dataFlavor,
|
||||
// clipboardData, dataLength);
|
||||
// return rv;
|
||||
// }
|
||||
//
|
||||
//#define ONLY_SUPPORT_PLAIN_TEXT 1
|
||||
//#ifdef ONLY_SUPPORT_PLAIN_TEXT
|
||||
// gtk_selection_convert(sWidget, GDK_SELECTION_PRIMARY,
|
||||
// GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME);
|
||||
// // Tried to use straight Xlib call but this would need more work:
|
||||
// //XConvertSelection(GDK_WINDOW_XDISPLAY(sWidget->window),
|
||||
// // XA_PRIMARY, XA_STRING, gdk_selection_property,
|
||||
// // GDK_WINDOW_XWINDOW(sWidget->window), GDK_CURRENT_TIME);
|
||||
//
|
||||
//#else /* ONLY_SUPPORT_PLAIN_TEXT */
|
||||
// //
|
||||
// // XXX This code isn't implemented for Unix yet!
|
||||
// // Instead of SetTransferData it will have to call gtk_selection_convert.
|
||||
// //
|
||||
//
|
||||
// // Get the transferable list of data flavors
|
||||
// nsVoidArray * dfList;
|
||||
// aTransferable->GetTransferDataFlavors(&dfList);
|
||||
//
|
||||
// // Walk through flavors and see which flavor matches the one being pasted:
|
||||
// PRUint32 i;
|
||||
// PRUint32 cnt = 0;
|
||||
// nsresult rv = dfList->Count(&cnt);
|
||||
// NS_ASSERTION(NS_SUCCEEDED(rv), "Count failed");
|
||||
// for (i=0;i<cnt;i++) {
|
||||
// nsString * df = (nsString *)dfList->ElementAt(i);
|
||||
// if (nsnull != df) {
|
||||
// UINT format = GetFormat(*df);
|
||||
//
|
||||
// void * data;
|
||||
// PRUint32 dataLen;
|
||||
//
|
||||
// if (nsnull != aDataObject) {
|
||||
// res = GetNativeDataOffClipboard(aDataObject, format, &data, &dataLen);
|
||||
// if (NS_OK == res) {
|
||||
// trans->SetTransferData(df, data, dataLen);
|
||||
// }
|
||||
// } else if (nsnull != aWindow) {
|
||||
// res = GetNativeDataOffClipboard(aWindow, format, &data, &dataLen);
|
||||
// if (NS_OK == res) {
|
||||
// trans->SetTransferData(df, data, dataLen);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//#endif /* ONLY_SUPPORT_PLAIN_TEXT */
|
||||
//
|
||||
// //
|
||||
// // We've told X what type to send, and we just have to wait
|
||||
// // for the callback saying that the data have been transferred.
|
||||
// //
|
||||
//
|
||||
// // Set a flag saying that we're blocking waiting for the callback:
|
||||
// mBlocking = PR_TRUE;
|
||||
//#ifdef DEBUG_CLIPBOARD
|
||||
// printf("Waiting for the callback\n");
|
||||
//#endif /* DEBUG_CLIPBOARD */
|
||||
//
|
||||
// // Now we need to wait until the callback comes in ...
|
||||
// // i is in case we get a runaway (yuck).
|
||||
// for (int i=0; mBlocking == PR_TRUE && i < 10000; ++i)
|
||||
// {
|
||||
// gtk_main_iteration_do(PR_TRUE);
|
||||
// }
|
||||
//
|
||||
//#ifdef DEBUG_CLIPBOARD
|
||||
// printf("Got the callback: '%s', %d\n",
|
||||
// mSelectionData.data, mSelectionData.length);
|
||||
//#endif /* DEBUG_CLIPBOARD */
|
||||
//
|
||||
// // We're back from the callback, no longer blocking:
|
||||
// mBlocking = PR_FALSE;
|
||||
//
|
||||
// //
|
||||
// // Now we have data in mSelectionData.data.
|
||||
// // We just have to copy it to the transferable.
|
||||
// //
|
||||
// nsAutoString dataFlavor(kTextMime);
|
||||
// trans->SetTransferData(&dataFlavor, mSelectionData.data, mSelectionData.length);
|
||||
//
|
||||
// // Can't free the selection data -- the transferable just saves a pointer.
|
||||
// // But the transferable is responsible for freeing it, so we have to
|
||||
// // consider it freed now:
|
||||
// //g_free(mSelectionData.data);
|
||||
// mSelectionData.data = nsnull;
|
||||
// mSelectionData.length = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// Called when the data from a paste comes in:
|
||||
//
|
||||
//void
|
||||
//nsClipboard::SelectionReceivedCB (GtkWidget *aWidget,
|
||||
// GtkSelectionData *aSelectionData,
|
||||
// gpointer aData)
|
||||
//{
|
||||
//#ifdef DEBUG_CLIPBOARD
|
||||
// printf(" nsClipboard::SelectionReceivedCB\n");
|
||||
//#endif /* DEBUG_CLIPBOARD */
|
||||
//
|
||||
// // ARGHH! GTK doesn't pass the arg to the callback, so we can't
|
||||
// // get "this" back! Until we solve this, get it from the service mgr:
|
||||
// nsresult rv;
|
||||
// NS_WITH_SERVICE(nsIClipboard, iclipboard, kCClipboardCID, &rv);
|
||||
//
|
||||
// if (NS_FAILED(rv)) {
|
||||
// printf("Couldn't get clipboard service!\n");
|
||||
// return;
|
||||
// }
|
||||
// nsClipboard* clipboard = (nsClipboard*)iclipboard;
|
||||
// if (!clipboard) {
|
||||
// printf("couldn't convert nsIClipboard to nsClipboard\n");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// clipboard->SelectionReceiver(aWidget, aSelectionData);
|
||||
//}
|
||||
//
|
||||
//void
|
||||
//nsClipboard::SelectionReceiver (GtkWidget *aWidget,
|
||||
// GtkSelectionData *aSelectionData)
|
||||
//{
|
||||
// mBlocking = PR_FALSE;
|
||||
//
|
||||
// if (aSelectionData->length < 0)
|
||||
// {
|
||||
// printf("Error retrieving selection: length was %d\n",
|
||||
// aSelectionData->length);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// switch (aSelectionData->type)
|
||||
// {
|
||||
// case GDK_SELECTION_TYPE_STRING:
|
||||
// mSelectionData = *aSelectionData;
|
||||
// mSelectionData.data = g_new(guchar, aSelectionData->length + 1);
|
||||
// memcpy(mSelectionData.data,
|
||||
// aSelectionData->data, aSelectionData->length);
|
||||
// // Null terminate in case anyone cares,
|
||||
// // and so we can print the string for debugging:
|
||||
// mSelectionData.data[aSelectionData->length] = '\0';
|
||||
// mSelectionData.length = aSelectionData->length;
|
||||
// return;
|
||||
//
|
||||
// default:
|
||||
// printf("Can't convert type %s (%ld) to string\n",
|
||||
// gdk_atom_name (aSelectionData->type), aSelectionData->type);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
/**
|
||||
* No-op.
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsClipboard::ForceDataToClipboard()
|
||||
{
|
||||
#ifdef DEBUG_CLIPBOARD
|
||||
printf(" nsClipboard::ForceDataToClipboard()\n");
|
||||
#endif /* DEBUG_CLIPBOARD */
|
||||
|
||||
// make sure we have a good transferable
|
||||
if (nsnull == mTransferable) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
//// This is the callback which is called when another app
|
||||
//// requests the selection.
|
||||
////
|
||||
//void nsClipboard::SelectionGetCB(GtkWidget *widget,
|
||||
// GtkSelectionData *aSelectionData,
|
||||
// guint /*info*/,
|
||||
// guint /*time*/,
|
||||
// gpointer aData)
|
||||
//{
|
||||
//#ifdef DEBUG_CLIPBOARD
|
||||
// printf(" nsClipboard::SelectionGetCB\n");
|
||||
//#endif /* DEBUG_CLIPBOARD */
|
||||
//
|
||||
// nsClipboard *clipboard = (nsClipboard *)aData;
|
||||
//
|
||||
// void *clipboardData;
|
||||
// PRUint32 dataLength;
|
||||
// nsresult rv;
|
||||
//
|
||||
// // Make sure we have a transferable:
|
||||
// if (!clipboard->mTransferable) {
|
||||
// printf("Clipboard has no transferable!\n");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // XXX hack, string-only for now.
|
||||
// // Create string data-flavor.
|
||||
// nsString dataFlavor (kTextMime);
|
||||
//
|
||||
// // Get data out of transferable.
|
||||
// rv = clipboard->mTransferable->GetTransferData(&dataFlavor,
|
||||
// &clipboardData,
|
||||
// &dataLength);
|
||||
//
|
||||
// // Currently we only offer the data in GDK_SELECTION_TYPE_STRING format.
|
||||
// if (NS_SUCCEEDED(rv) && clipboardData && dataLength > 0) {
|
||||
// gtk_selection_data_set(aSelectionData,
|
||||
// GDK_SELECTION_TYPE_STRING, 8,
|
||||
// (unsigned char *)clipboardData,
|
||||
// dataLength);
|
||||
// }
|
||||
// else
|
||||
// printf("Transferable didn't support the data flavor\n");
|
||||
//}
|
||||
//
|
||||
//
|
||||
//
|
||||
//// Called when another app requests selection ownership:
|
||||
//void nsClipboard::SelectionClearCB(GtkWidget *widget,
|
||||
// GdkEventSelection *event,
|
||||
// gpointer data)
|
||||
//{
|
||||
//#ifdef DEBUG_CLIPBOARD
|
||||
// printf(" nsClipboard::SelectionClearCB\n");
|
||||
//#endif /* DEBUG_CLIPBOARD */
|
||||
//}
|
||||
//
|
||||
//
|
||||
//// The routine called when another app asks for the content of the selection
|
||||
//void
|
||||
//nsClipboard::SelectionRequestCB (GtkWidget *aWidget,
|
||||
// GtkSelectionData *aSelectionData,
|
||||
// gpointer aData)
|
||||
//{
|
||||
//#ifdef DEBUG_CLIPBOARD
|
||||
// printf(" nsClipboard::SelectionRequestCB\n");
|
||||
//#endif /* DEBUG_CLIPBOARD */
|
||||
//}
|
||||
//
|
||||
//void
|
||||
//nsClipboard::SelectionNotifyCB (GtkWidget *aWidget,
|
||||
// GtkSelectionData *aSelectionData,
|
||||
// gpointer aData)
|
||||
//{
|
||||
//#ifdef DEBUG_CLIPBOARD
|
||||
// printf(" nsClipboard::SelectionNotifyCB\n");
|
||||
//#endif /* DEBUG_CLIPBOARD */
|
||||
//}
|
||||
@@ -1,88 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsClipboard_h__
|
||||
#define nsClipboard_h__
|
||||
|
||||
#include "nsBaseClipboard.h"
|
||||
#include <Clipboard.h>
|
||||
|
||||
class nsITransferable;
|
||||
class nsIClipboardOwner;
|
||||
class nsIWidget;
|
||||
|
||||
/**
|
||||
* Native BeOS Clipboard wrapper
|
||||
*/
|
||||
|
||||
class nsClipboard : public nsBaseClipboard
|
||||
{
|
||||
|
||||
public:
|
||||
nsClipboard();
|
||||
virtual ~nsClipboard();
|
||||
|
||||
//nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIClipboard
|
||||
NS_IMETHOD ForceDataToClipboard();
|
||||
|
||||
static void SetTopLevelView(BView *v);
|
||||
|
||||
|
||||
protected:
|
||||
NS_IMETHOD SetNativeClipboardData();
|
||||
NS_IMETHOD GetNativeClipboardData(nsITransferable * aTransferable);
|
||||
|
||||
PRBool mIgnoreEmptyNotification;
|
||||
|
||||
static BView *sView;
|
||||
|
||||
// // Used for communicating pasted data
|
||||
// // from the asynchronous X routines back to a blocking paste:
|
||||
// GtkSelectionData mSelectionData;
|
||||
// PRBool mBlocking;
|
||||
//
|
||||
// void SelectionReceiver(GtkWidget *aWidget,
|
||||
// GtkSelectionData *aSelectionData);
|
||||
//
|
||||
// static void SelectionGetCB(GtkWidget *widget,
|
||||
// GtkSelectionData *selection_data,
|
||||
// guint /*info*/,
|
||||
// guint /*time*/,
|
||||
// gpointer data);
|
||||
//
|
||||
// static void SelectionClearCB(GtkWidget *widget,
|
||||
// GdkEventSelection *event,
|
||||
// gpointer data );
|
||||
//
|
||||
// static void SelectionRequestCB(GtkWidget *aWidget,
|
||||
// GtkSelectionData *aSelectionData,
|
||||
// gpointer aData);
|
||||
//
|
||||
// static void SelectionReceivedCB(GtkWidget *aWidget,
|
||||
// GtkSelectionData *aSelectionData,
|
||||
// gpointer aData);
|
||||
//
|
||||
// static void SelectionNotifyCB(GtkWidget *aWidget,
|
||||
// GtkSelectionData *aSelectionData,
|
||||
// gpointer aData);
|
||||
};
|
||||
|
||||
#endif // nsClipboard_h__
|
||||
@@ -1,380 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsComboBox.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringUtil.h"
|
||||
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
|
||||
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
NS_IMPL_ADDREF(nsComboBox)
|
||||
NS_IMPL_RELEASE(nsComboBox)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsComboBox constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsComboBox::nsComboBox() : nsWindow(), nsIListWidget(), nsIComboBox()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mBackground = NS_RGB(124, 124, 124);
|
||||
mDropDownHeight = 60; // Default to 60 pixels for drop-down list height
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsComboBox::AddItemAt(nsString &aItem, PRInt32 aPosition)
|
||||
{
|
||||
if(mMenuField && mMenuField->LockLooper())
|
||||
{
|
||||
NS_ALLOC_STR_BUF(val, aItem, 256);
|
||||
mMenuField->Menu()->AddItem(new BMenuItem(val, 0), aPosition);
|
||||
NS_FREE_STR_BUF(val);
|
||||
mMenuField->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Finds an item at a postion
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsComboBox::FindItem(nsString &aItem, PRInt32 aStartPos)
|
||||
{
|
||||
#if 0
|
||||
NS_ALLOC_STR_BUF(val, aItem, 256);
|
||||
int index = ::SendMessage(mWnd, CB_FINDSTRINGEXACT, (int)aStartPos, (LPARAM)(LPCTSTR)val);
|
||||
NS_FREE_STR_BUF(val);
|
||||
|
||||
return index;
|
||||
#endif
|
||||
printf("nsListBox::FindItem not implemented\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// CountItems - Get Item Count
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsComboBox::GetItemCount()
|
||||
{
|
||||
PRInt32 result = 0;
|
||||
if(mMenuField && mMenuField->LockLooper())
|
||||
{
|
||||
result = mMenuField->Menu()->CountItems();
|
||||
mMenuField->UnlockLooper();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Removes an Item at a specified location
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsComboBox::RemoveItemAt(PRInt32 aPosition)
|
||||
{
|
||||
if(mMenuField && mMenuField->LockLooper())
|
||||
{
|
||||
BMenuItem *it = mMenuField->Menu()->RemoveItem(aPosition);
|
||||
delete it;
|
||||
mMenuField->UnlockLooper();
|
||||
return it ? PR_TRUE : PR_FALSE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Removes an Item at a specified location
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsComboBox::GetItemAt(nsString& anItem, PRInt32 aPosition)
|
||||
{
|
||||
PRBool result = PR_FALSE;
|
||||
anItem.SetLength(0);
|
||||
if(mMenuField && mMenuField->LockLooper())
|
||||
{
|
||||
BMenuItem *it = mMenuField->Menu()->ItemAt(aPosition);
|
||||
anItem.Append(it->Label());
|
||||
mMenuField->UnlockLooper();
|
||||
result = PR_TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Gets the selected of selected item
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsComboBox::GetSelectedItem(nsString& aItem)
|
||||
{
|
||||
GetItemAt(aItem, GetSelectedIndex());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Gets the list of selected otems
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsComboBox::GetSelectedIndex()
|
||||
{
|
||||
PRInt32 index = -1;
|
||||
if(mMenuField && mMenuField->LockLooper())
|
||||
{
|
||||
BMenuItem *it = mMenuField->Menu()->FindMarked();
|
||||
index = it ? mMenuField->Menu()->IndexOf(it) : -1;
|
||||
mMenuField->UnlockLooper();
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// SelectItem
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsComboBox::SelectItem(PRInt32 aPosition)
|
||||
{
|
||||
if(mMenuField && mMenuField->LockLooper())
|
||||
{
|
||||
BMenuItem *it = mMenuField->Menu()->ItemAt(aPosition);
|
||||
if(it)
|
||||
it->SetMarked(true);
|
||||
mMenuField->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Deselect
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsComboBox::Deselect()
|
||||
{
|
||||
if(mMenuField && mMenuField->LockLooper())
|
||||
{
|
||||
BMenuItem *it = mMenuField->Menu()->FindMarked();
|
||||
if(it)
|
||||
it->SetMarked(false);
|
||||
mMenuField->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsComboBox::~nsComboBox()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsComboBox::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
static NS_DEFINE_IID(kInsComboBoxIID, NS_ICOMBOBOX_IID);
|
||||
static NS_DEFINE_IID(kInsListWidgetIID, NS_ILISTWIDGET_IID);
|
||||
|
||||
if (aIID.Equals(kInsComboBoxIID)) {
|
||||
*aInstancePtr = (void*) ((nsIComboBox*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kInsListWidgetIID)) {
|
||||
*aInstancePtr = (void*) ((nsIListWidget*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsWindow::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// move, paint, resizes message - ignore
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsComboBox::OnMove(PRInt32, PRInt32)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsComboBox::OnPaint(nsRect &r)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsComboBox::OnResize(nsRect &aWindowRect)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Cache the drop down list height in mDropDownHeight
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsComboBox::PreCreateWidget(nsWidgetInitData *aInitData)
|
||||
{
|
||||
nsComboBoxInitData* comboData = (nsComboBoxInitData*)aInitData;
|
||||
mDropDownHeight = comboData->mDropDownHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Modify the height passed to create and resize to be
|
||||
// the combo box drop down list height. (Note: Windows uses
|
||||
// the height of the window to specify the drop-down list size,
|
||||
// not the height of combobox text area.
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
PRInt32 nsComboBox::GetHeight(PRInt32 aProposedHeight)
|
||||
{
|
||||
return(mDropDownHeight);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// get position/dimensions
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsComboBox::GetBounds(nsRect &aRect)
|
||||
{
|
||||
#if 0
|
||||
nsWindow::GetNonClientBounds(aRect);
|
||||
#endif
|
||||
printf("nsListBox::GetBounds not wrong\n"); // the following is just a placeholder
|
||||
nsWindow::GetClientBounds(aRect);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the TextWidget for Printing
|
||||
*
|
||||
**/
|
||||
NS_METHOD nsComboBox::Paint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
nsBaseWidget::Paint(aRenderingContext, aDirtyRect);
|
||||
/*nsRect rect;
|
||||
GetBoundsAppUnits(rect, aTwipsConversion);
|
||||
aRenderingContext.SetColor(NS_RGB(0,0,0));
|
||||
|
||||
nscolor bgColor = NS_RGB(255,255,255);
|
||||
nscolor fgColor = NS_RGB(0,0,0);
|
||||
nscolor hltColor = NS_RGB(240,240,240);
|
||||
nscolor sdwColor = NS_RGB(128,128,128);
|
||||
nsILookAndFeel * lookAndFeel;
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) {
|
||||
lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, bgColor);
|
||||
lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetForeground, fgColor);
|
||||
lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DShadow, sdwColor);
|
||||
lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DHighlight, hltColor);
|
||||
}
|
||||
|
||||
nsIDeviceContext * context;
|
||||
//nsDrawingSurface surface;
|
||||
aRenderingContext.GetDeviceContext(context);
|
||||
//context->GetDrawingSurface(aRenderingContext, surface);
|
||||
|
||||
//HDC the_hdc = ((nsDrawingSurfaceWin *)&surface)->mDC;
|
||||
|
||||
//::SendMessage(mWnd, WM_PAINT, (WPARAM)the_hdc, NULL);
|
||||
|
||||
|
||||
// shrink by one pixel
|
||||
|
||||
nscoord onePixel = nscoord((aTwipsConversion+0.6F));
|
||||
nscoord twoPixels = onePixel*2;
|
||||
|
||||
nsString text("(ComboBox)");
|
||||
//GetSelectedItem(text);
|
||||
|
||||
|
||||
aRenderingContext.SetColor(bgColor);
|
||||
aRenderingContext.FillRect(rect);
|
||||
|
||||
aRenderingContext.SetColor(NS_RGB(0,0,0));
|
||||
aRenderingContext.DrawRect(rect);
|
||||
|
||||
|
||||
aRenderingContext.SetFont(*mFont);
|
||||
|
||||
nscoord textWidth;
|
||||
nscoord textHeight;
|
||||
aRenderingContext.GetWidth(text, textWidth);
|
||||
|
||||
nsIFontMetrics* metrics;
|
||||
context->GetMetricsFor(*mFont, metrics);
|
||||
metrics->GetMaxAscent(textHeight);
|
||||
|
||||
nscoord x = (twoPixels * 2) + rect.x;
|
||||
nscoord y = ((rect.height - textHeight) / 2) + rect.y;
|
||||
//aRenderingContext.DrawString(text, x, y);
|
||||
*/
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
BView *nsComboBox::CreateBeOSView()
|
||||
{
|
||||
return mMenuField = new nsMenuFieldBeOS((nsIWidget *)this, BRect(0, 0, 0, 0), "");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Sub-class of BeOS MenuField
|
||||
//-------------------------------------------------------------------------
|
||||
nsMenuFieldBeOS::nsMenuFieldBeOS( nsIWidget *aWidgetWindow, BRect aFrame,
|
||||
const char *aName, uint32 aResizingMode, uint32 aFlags )
|
||||
: BMenuField( aFrame, aName, "", new BPopUpMenu(""), aResizingMode, aFlags ),
|
||||
nsIWidgetStore( aWidgetWindow )
|
||||
{
|
||||
SetDivider(0);
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsComboBox_h__
|
||||
#define nsComboBox_h__
|
||||
|
||||
#include "nsdefs.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsSwitchToUIThread.h"
|
||||
#include "nsIComboBox.h"
|
||||
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <MenuField.h>
|
||||
|
||||
/**
|
||||
* Native Win32 Combobox wrapper
|
||||
*/
|
||||
|
||||
class nsComboBox : public nsWindow,
|
||||
public nsIListWidget,
|
||||
public nsIComboBox
|
||||
{
|
||||
|
||||
public:
|
||||
nsComboBox();
|
||||
~nsComboBox();
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
// nsIWidget overrides
|
||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
||||
virtual PRBool OnPaint(nsRect &r);
|
||||
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||
|
||||
// nsIWidget
|
||||
NS_IMETHOD GetBounds(nsRect &aRect);
|
||||
|
||||
// nsIComboBox interface
|
||||
NS_IMETHOD AddItemAt(nsString &aItem, PRInt32 aPosition);
|
||||
virtual PRInt32 FindItem(nsString &aItem, PRInt32 aStartPos);
|
||||
virtual PRInt32 GetItemCount();
|
||||
virtual PRBool RemoveItemAt(PRInt32 aPosition);
|
||||
virtual PRBool GetItemAt(nsString& anItem, PRInt32 aPosition);
|
||||
NS_IMETHOD GetSelectedItem(nsString& aItem);
|
||||
virtual PRInt32 GetSelectedIndex();
|
||||
NS_IMETHOD SelectItem(PRInt32 aPosition);
|
||||
NS_IMETHOD Deselect() ;
|
||||
|
||||
NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData);
|
||||
|
||||
protected:
|
||||
|
||||
// Modify the height passed to create and resize to be
|
||||
// the combo box drop down list height.
|
||||
PRInt32 GetHeight(PRInt32 aProposedHeight);
|
||||
PRInt32 mDropDownHeight;
|
||||
BView *CreateBeOSView();
|
||||
BMenuField *mMenuField;
|
||||
};
|
||||
|
||||
//
|
||||
// A BMenuField subclass
|
||||
//
|
||||
class nsMenuFieldBeOS : public BMenuField, public nsIWidgetStore {
|
||||
public:
|
||||
nsMenuFieldBeOS( nsIWidget *aWidgetWindow, BRect aFrame,
|
||||
const char *name, uint32 aResizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 aFlags = B_WILL_DRAW | B_NAVIGABLE );
|
||||
};
|
||||
|
||||
#endif // nsComboBox_h__
|
||||
@@ -1,165 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsDialog.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringUtil.h"
|
||||
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsTransform2D.h"
|
||||
#include "nsStringUtil.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "resource.h"
|
||||
|
||||
NS_IMPL_ADDREF(nsDialog)
|
||||
NS_IMPL_RELEASE(nsDialog)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsDialog constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsDialog::nsDialog() : nsWindow(), nsIDialog()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Create the proper widget
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsDialog::Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
return nsWindow::Create(aParent,aRect,aHandleEventFunction,aContext,aAppShell,aToolkit,aInitData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsDialog destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsDialog::~nsDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsDialog::SetLabel(const nsString& aText)
|
||||
{
|
||||
#if 0
|
||||
NS_ALLOC_STR_BUF(label, aText, 256);
|
||||
VERIFY(::SetWindowText(mWnd, label));
|
||||
NS_FREE_STR_BUF(label);
|
||||
#endif
|
||||
printf("nsDialog::SetLabel not implemented\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsDialog::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
#if 0
|
||||
int actualSize = ::GetWindowTextLength(mWnd)+1;
|
||||
NS_ALLOC_CHAR_BUF(label, 256, actualSize);
|
||||
::GetWindowText(mWnd, label, actualSize);
|
||||
aBuffer.SetLength(0);
|
||||
aBuffer.Append(label);
|
||||
NS_FREE_CHAR_BUF(label);
|
||||
#endif
|
||||
printf("nsDialog::SetLabel not implemented\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsDialog::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr);
|
||||
|
||||
static NS_DEFINE_IID(kInsDialogIID, NS_IDIALOG_IID);
|
||||
if (result == NS_NOINTERFACE && aIID.Equals(kInsDialogIID)) {
|
||||
*aInstancePtr = (void*) ((nsIDialog*)this);
|
||||
NS_ADDREF_THIS();
|
||||
result = NS_OK;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// move, paint, resizes message - ignore
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsDialog::OnMove(PRInt32, PRInt32)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsDialog::OnPaint(nsRect &r)
|
||||
{
|
||||
return nsWindow::OnPaint(r);
|
||||
}
|
||||
|
||||
PRBool nsDialog::OnResize(nsRect &aWindowRect)
|
||||
{
|
||||
return nsWindow::OnResize(aWindowRect);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// get position/dimensions
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsDialog::GetBounds(nsRect &aRect)
|
||||
{
|
||||
return nsWindow::GetBounds(aRect);
|
||||
}
|
||||
|
||||
@@ -1,230 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsDragService.h"
|
||||
#include "nsITransferable.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDragServiceIID, NS_IDRAGSERVICE_IID);
|
||||
static NS_DEFINE_CID(kCDragServiceCID, NS_DRAGSERVICE_CID);
|
||||
|
||||
// The class statics:
|
||||
BView *nsDragService::sView = 0;
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// static variables
|
||||
//-------------------------------------------------------------------------
|
||||
//static PRBool gHaveDrag = PR_FALSE;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// DragService constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsDragService::nsDragService()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// DragService destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsDragService::~nsDragService()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*
|
||||
*/
|
||||
nsresult nsDragService::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv = NS_NOINTERFACE;
|
||||
|
||||
if (aIID.Equals(nsIDragService::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsIDragService*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
NS_IMETHODIMP nsDragService::StartDragSession (nsITransferable * aTransferable, PRUint32 aActionType)
|
||||
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsDragService::GetData (nsITransferable * aTransferable,
|
||||
PRUint32 aItemIndex)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void nsDragService::SetTopLevelView(BView *v)
|
||||
{
|
||||
printf(" nsDragService::SetTopLevelWidget\n");
|
||||
|
||||
// Don't set up any more event handlers if we're being called twice
|
||||
// for the same toplevel widget
|
||||
if (sView == v)
|
||||
return;
|
||||
|
||||
sView = v;
|
||||
|
||||
// Get the DragService from the service manager.
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIDragService, dragService, kCDragServiceCID, &rv);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
gtk_signal_connect (GTK_OBJECT (pixmap), "drag_leave",
|
||||
GTK_SIGNAL_FUNC (nsDragService::DragLeave), dragService);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (pixmap), "drag_motion",
|
||||
GTK_SIGNAL_FUNC (nsDragService::DragMotion), dragService);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (pixmap), "drag_drop",
|
||||
GTK_SIGNAL_FUNC (nsDragService::DragDrop), dragService);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (pixmap), "drag_data_received",
|
||||
GTK_SIGNAL_FUNC (nsDragService::DragDataReceived), dragService);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//void
|
||||
//nsDragService::DragLeave (GtkWidget *widget,
|
||||
// GdkDragContext *context,
|
||||
// guint time)
|
||||
//{
|
||||
// g_print("leave\n");
|
||||
// //gHaveDrag = PR_FALSE;
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------
|
||||
//PRBool
|
||||
//nsDragService::DragMotion(GtkWidget *widget,
|
||||
// GdkDragContext *context,
|
||||
// gint x,
|
||||
// gint y,
|
||||
// guint time)
|
||||
//{
|
||||
// g_print("drag motion\n");
|
||||
// GtkWidget *source_widget;
|
||||
//
|
||||
//#if 0
|
||||
// if (!gHaveDrag) {
|
||||
// gHaveDrag = PR_TRUE;
|
||||
// }
|
||||
//#endif
|
||||
//
|
||||
// source_widget = gtk_drag_get_source_widget (context);
|
||||
// g_print("motion, source %s\n", source_widget ?
|
||||
// gtk_type_name (GTK_OBJECT (source_widget)->klass->type) :
|
||||
// "unknown");
|
||||
//
|
||||
// gdk_drag_status (context, context->suggested_action, time);
|
||||
//
|
||||
// return PR_TRUE;
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------
|
||||
//PRBool
|
||||
//nsDragService::DragDrop(GtkWidget *widget,
|
||||
// GdkDragContext *context,
|
||||
// gint x,
|
||||
// gint y,
|
||||
// guint time)
|
||||
//{
|
||||
// g_print("drop\n");
|
||||
// //gHaveDrag = PR_FALSE;
|
||||
//
|
||||
// if (context->targets){
|
||||
// gtk_drag_get_data (widget, context,
|
||||
// GPOINTER_TO_INT (context->targets->data),
|
||||
// time);
|
||||
// return PR_TRUE;
|
||||
// }
|
||||
//
|
||||
// return PR_FALSE;
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------
|
||||
//void
|
||||
//nsDragService::DragDataReceived (GtkWidget *widget,
|
||||
// GdkDragContext *context,
|
||||
// gint x,
|
||||
// gint y,
|
||||
// GtkSelectionData *data,
|
||||
// guint info,
|
||||
// guint time)
|
||||
//{
|
||||
// if ((data->length >= 0) && (data->format == 8)) {
|
||||
// g_print ("Received \"%s\"\n", (gchar *)data->data);
|
||||
// gtk_drag_finish (context, PR_TRUE, PR_FALSE, time);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// gtk_drag_finish (context, PR_FALSE, PR_FALSE, time);
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------
|
||||
//void
|
||||
//nsDragService::DragDataGet(GtkWidget *widget,
|
||||
// GdkDragContext *context,
|
||||
// GtkSelectionData *selection_data,
|
||||
// guint info,
|
||||
// guint time,
|
||||
// gpointer data)
|
||||
//{
|
||||
// gtk_selection_data_set (selection_data,
|
||||
// selection_data->target,
|
||||
// 8, (guchar *)"I'm Data!", 9);
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------
|
||||
//void
|
||||
//nsDragService::DragDataDelete(GtkWidget *widget,
|
||||
// GdkDragContext *context,
|
||||
// gpointer data)
|
||||
//{
|
||||
// g_print ("Delete the data!\n");
|
||||
//}
|
||||
@@ -1,91 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsDragService_h__
|
||||
#define nsDragService_h__
|
||||
|
||||
#include "nsBaseDragService.h"
|
||||
#include <View.h>
|
||||
|
||||
|
||||
/**
|
||||
* Native BeOS DragService wrapper
|
||||
*/
|
||||
|
||||
class nsDragService : public nsBaseDragService
|
||||
{
|
||||
|
||||
public:
|
||||
nsDragService();
|
||||
virtual ~nsDragService();
|
||||
|
||||
//nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
|
||||
//nsIDragService
|
||||
NS_IMETHOD StartDragSession (nsITransferable * aTransferable,
|
||||
PRUint32 aActionType);
|
||||
|
||||
// Native Impl.
|
||||
NS_IMETHOD GetData (nsITransferable * aTransferable, PRUint32 aItemIndex);
|
||||
|
||||
static void SetTopLevelView(BView *v);
|
||||
|
||||
static BView *sView;
|
||||
|
||||
protected:
|
||||
static PRBool gHaveDrag;
|
||||
|
||||
// static void DragLeave(GtkWidget *widget,
|
||||
// GdkDragContext *context,
|
||||
// guint time);
|
||||
//
|
||||
// static PRBool DragMotion(GtkWidget *widget,
|
||||
// GdkDragContext *context,
|
||||
// gint x,
|
||||
// gint y,
|
||||
// guint time);
|
||||
//
|
||||
// static PRBool DragDrop(GtkWidget *widget,
|
||||
// GdkDragContext *context,
|
||||
// gint x,
|
||||
// gint y,
|
||||
// guint time);
|
||||
//
|
||||
// static void DragDataReceived(GtkWidget *widget,
|
||||
// GdkDragContext *context,
|
||||
// gint x,
|
||||
// gint y,
|
||||
// GtkSelectionData *data,
|
||||
// guint info,
|
||||
// guint time);
|
||||
//
|
||||
// static void DragDataGet(GtkWidget *widget,
|
||||
// GdkDragContext *context,
|
||||
// GtkSelectionData *selection_data,
|
||||
// guint info,
|
||||
// guint time,
|
||||
// gpointer data);
|
||||
//
|
||||
// static void DragDataDelete(GtkWidget *widget,
|
||||
// GdkDragContext *context,
|
||||
// gpointer data);
|
||||
};
|
||||
|
||||
#endif // nsDragService_h__
|
||||
@@ -1,251 +0,0 @@
|
||||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*-
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
//#include "stdafx.h"
|
||||
//#include "olebase.h"
|
||||
//#include "idropsrc.h"
|
||||
#include "nsDropTarget.h"
|
||||
//#include "contndoc.h"
|
||||
#include "stdio.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
#include "nsWindow.h"
|
||||
//Don't forget to RegisterDragDrop and to
|
||||
//CoLockObjectExternal.
|
||||
//You must RevokeDragDrop before destroying this object
|
||||
//
|
||||
nsDropTarget::nsDropTarget(nsIWidget * aWindow)
|
||||
{
|
||||
printf("nsDropTarget::nsDropTarget\n");
|
||||
m_refs = 0;
|
||||
m_pWin = aWindow;
|
||||
NS_ADDREF(aWindow);
|
||||
}
|
||||
|
||||
//Destructor for nsDropTarget
|
||||
//Doesn't do a whole lot!
|
||||
//
|
||||
nsDropTarget::~nsDropTarget()
|
||||
{
|
||||
printf("nsDropTarget::Drop\n");
|
||||
;
|
||||
}
|
||||
|
||||
//QueryInterface for IDropTarget
|
||||
//Notice that this QueryInterface does not refer to another object's QueryInterface,
|
||||
//this is a totally stand-alone separate object
|
||||
//
|
||||
STDMETHODIMP nsDropTarget::QueryInterface(REFIID riid, LPVOID FAR* ppv)
|
||||
{
|
||||
printf("nsDropTarget::QueryInterface\n");
|
||||
if (riid == IID_IUnknown)
|
||||
*ppv = this;
|
||||
else if (riid == IID_IDropTarget)
|
||||
*ppv = this;
|
||||
else{
|
||||
*ppv = NULL;
|
||||
}
|
||||
if (*ppv != NULL){
|
||||
((LPUNKNOWN)(*ppv))->AddRef();
|
||||
return NOERROR;
|
||||
}
|
||||
|
||||
//If for some reason our constructor did not create the requested interface
|
||||
//don't pass the NULL interface without telling the caller that we don't support
|
||||
//the requested interface.
|
||||
return ResultFromScode(E_NOINTERFACE);
|
||||
}
|
||||
|
||||
//A private AddRef for IDropTarget
|
||||
//
|
||||
STDMETHODIMP_(ULONG) nsDropTarget::AddRef(void)
|
||||
{
|
||||
printf("nsDropTarget::AddRef\n");
|
||||
return ++m_refs;
|
||||
}
|
||||
|
||||
//A private Release for IDropTarget
|
||||
//
|
||||
STDMETHODIMP_(ULONG) nsDropTarget::Release(void)
|
||||
{
|
||||
printf("nsDropTarget::Release\n");
|
||||
if(--m_refs == 0){
|
||||
//And now we can delete this object
|
||||
delete this;
|
||||
}
|
||||
|
||||
return m_refs;
|
||||
}
|
||||
|
||||
//
|
||||
//This helper function tells us what the drag/drop effect would be at
|
||||
//the point pointl. Since our object accepts being a drop target anywhere
|
||||
//in the window, we will ignore pointl
|
||||
//
|
||||
DWORD nsDropTarget::FindDragDropEffect(DWORD grfKeyState, POINTL /* pointl */)
|
||||
{
|
||||
printf("nsDropTarget::FindDragDropEffect\n");
|
||||
DWORD dwRet;
|
||||
|
||||
// no modifier -- DROPEFFECT_MOVE or source default
|
||||
// SHIFT -- DROPEFFECT_MOVE
|
||||
// CTRL -- DROPEFFECT_COPY
|
||||
// CTRL-SHIFT -- DROPEFFECT_LINK
|
||||
|
||||
dwRet = 0;//OleStdGetDropEffect(grfKeyState);
|
||||
if (dwRet == 0)
|
||||
dwRet = DROPEFFECT_COPY;
|
||||
|
||||
return dwRet;
|
||||
}
|
||||
|
||||
|
||||
//Notification that a DropSource is over the current DropTarget
|
||||
//
|
||||
STDMETHODIMP nsDropTarget::DragEnter (LPDATAOBJECT pDataObj,
|
||||
DWORD grfKeyState,
|
||||
POINTL pointl,
|
||||
LPDWORD pdwEffect)
|
||||
{
|
||||
printf("nsDropTarget::DragEnter\n");
|
||||
*pdwEffect = FindDragDropEffect(grfKeyState, pointl);
|
||||
return NOERROR;
|
||||
}
|
||||
|
||||
//Provides user feedback when a DropSource is over a DropTarget
|
||||
//
|
||||
STDMETHODIMP nsDropTarget::DragOver (DWORD grfKeyState,
|
||||
POINTL pointl,
|
||||
LPDWORD pdwEffect)
|
||||
{
|
||||
printf("nsDropTarget::DragOver\n");
|
||||
*pdwEffect = FindDragDropEffect(grfKeyState, pointl);
|
||||
return NOERROR;
|
||||
}
|
||||
|
||||
|
||||
//The DropSource is leaving our target window
|
||||
//so its cleanup time!!!
|
||||
//
|
||||
STDMETHODIMP nsDropTarget::DragLeave (void)
|
||||
{
|
||||
printf("nsDropTarget::DragLeave\n");
|
||||
return NOERROR;
|
||||
}
|
||||
|
||||
//Drops the DropSource
|
||||
//
|
||||
STDMETHODIMP nsDropTarget::Drop (LPDATAOBJECT pIDataObject,
|
||||
DWORD grfKeyState,
|
||||
POINTL pointl,
|
||||
LPDWORD pdwEffect)
|
||||
{
|
||||
printf("nsDropTarget::Drop\n");
|
||||
printf("pIDataObject 0x%x\n", pIDataObject);
|
||||
pIDataObject->AddRef();
|
||||
if (nsnull != m_pWin) {
|
||||
nsEventStatus status;
|
||||
nsDragDropEvent event;
|
||||
((nsWindow *)m_pWin)->InitEvent(event, NS_DRAGDROP_EVENT);
|
||||
event.mType = nsDragDropEventStatus_eDrop;
|
||||
event.mIsFileURL = PR_FALSE;
|
||||
event.mURL = nsnull;
|
||||
m_pWin->DispatchEvent(&event, status);
|
||||
}
|
||||
|
||||
//pdwEffect = FindDragDropEffect(grfKeyState, pointl);
|
||||
|
||||
|
||||
if (pIDataObject != NULL) {
|
||||
IDataObject * presistStorage;
|
||||
//printf("QueryInterface for persist\n");
|
||||
pIDataObject->QueryInterface(IID_IDataObject,(LPVOID *)&presistStorage);
|
||||
//printf("Done QueryInterface for persist\n");
|
||||
if (presistStorage != NULL) {
|
||||
printf("$$$$$$$$$$$$$$$ Got it!\n");
|
||||
FORMATETC pFE;
|
||||
presistStorage->QueryGetData(&pFE);
|
||||
|
||||
pFE.tymed = TYMED_FILE;
|
||||
|
||||
STGMEDIUM pSTM;
|
||||
HRESULT st = presistStorage->GetDataHere(&pFE, &pSTM);
|
||||
printf("st 0x%X\n", st);
|
||||
if (NOERROR != st) {
|
||||
return FALSE;
|
||||
}
|
||||
//TYMED_STORAGE, TYMED_STREAM, TYMED_HGLOBAL, or TYMED_FILE
|
||||
//printf("%s\n", pSTM.lpszFileName);
|
||||
{
|
||||
|
||||
//HRESULT hr = pIDataObject->GetData(&pFE, &pSTM);
|
||||
//printf("hr 0x%X\n", hr);
|
||||
//if (NOERROR != hr) {
|
||||
// return FALSE;
|
||||
//}
|
||||
|
||||
const CLIPFORMAT format = pFE.cfFormat;
|
||||
switch(format) {
|
||||
case CF_BITMAP:
|
||||
//hr = SetBitmap(*pFE, stm);
|
||||
break;
|
||||
case CF_DIB:
|
||||
//hr = SetDib(*pFE, stm);
|
||||
break;
|
||||
case CF_TEXT:
|
||||
//hr = SetText(*pFE, stm);
|
||||
break;
|
||||
case CF_METAFILEPICT:
|
||||
//hr = SetMetafilePict(*pFE, stm);
|
||||
break;
|
||||
default:
|
||||
//if (format == GetRcfFormat()) {
|
||||
// hr = SetRcf(*pFE, stm);
|
||||
//}
|
||||
break;
|
||||
}
|
||||
|
||||
//return (SUCCEEDED(hr));
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
printf("^^^^^^^^^^^^^^^^^ Didn't!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* if (m_pContainDoc->m_pOleSiteObject)
|
||||
delete m_pContainDoc->m_pOleSiteObject;
|
||||
m_pContainDoc->m_pOleSiteObject = new COleSiteObject(m_pContainDoc);
|
||||
FORMATETC fmtetc;
|
||||
fmtetc.cfFormat = NULL;
|
||||
fmtetc.ptd = NULL;
|
||||
fmtetc.lindex = -1;
|
||||
fmtetc.dwAspect = DVASPECT_CONTENT;
|
||||
fmtetc.tymed = TYMED_NULL;
|
||||
m_pContainDoc->m_pOleSiteObject->AddSiteFromData(m_pContainDoc,
|
||||
pIDataObject,
|
||||
&fmtetc);
|
||||
*/
|
||||
pIDataObject->Release();
|
||||
|
||||
DragLeave();
|
||||
|
||||
return NOERROR;
|
||||
}
|
||||
@@ -1,277 +0,0 @@
|
||||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// Define so header files for openfilename are included
|
||||
#ifdef WIN32_LEAN_AND_MEAN
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include "nsFileWidget.h"
|
||||
|
||||
//NS_IMPL_ISUPPORTS(nsFileWidget, NS_IFILEWIDGET_IID)
|
||||
NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
|
||||
NS_IMPL_ISUPPORTS(nsFileWidget, kIFileWidgetIID);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsFileWidget constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsFileWidget::nsFileWidget() : nsIFileWidget()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
// mWnd = NULL;
|
||||
mNumberOfFilters = 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Show - Display the file dialog
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
PRBool nsFileWidget::Show()
|
||||
{
|
||||
printf("nsFileWidget::Show not implemented\n");
|
||||
#if 0
|
||||
char fileBuffer[MAX_PATH+1] = "";
|
||||
mDefault.ToCString(fileBuffer,MAX_PATH);
|
||||
|
||||
OPENFILENAME ofn;
|
||||
memset(&ofn, 0, sizeof(ofn));
|
||||
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
|
||||
nsString filterList;
|
||||
GetFilterListArray(filterList);
|
||||
char *filterBuffer = filterList.ToNewCString();
|
||||
char *title = mTitle.ToNewCString();
|
||||
char *initialDir = mDisplayDirectory.ToNewCString();
|
||||
if (mDisplayDirectory.Length() > 0) {
|
||||
ofn.lpstrInitialDir = initialDir;
|
||||
}
|
||||
|
||||
ofn.lpstrTitle = title;
|
||||
ofn.lpstrFilter = filterBuffer;
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.hwndOwner = mWnd;
|
||||
ofn.lpstrFile = fileBuffer;
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.Flags = OFN_SHAREAWARE | OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
|
||||
|
||||
PRBool result;
|
||||
|
||||
// Save current directory, so we can reset if it changes.
|
||||
char* currentDirectory = new char[MAX_PATH+1];
|
||||
VERIFY(::GetCurrentDirectory(MAX_PATH, currentDirectory) > 0);
|
||||
|
||||
if (mMode == eMode_load) {
|
||||
result = GetOpenFileName(&ofn);
|
||||
}
|
||||
else if (mMode == eMode_save) {
|
||||
result = GetSaveFileName(&ofn);
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(0, "Only load and save are supported modes");
|
||||
}
|
||||
|
||||
// Store the current directory in mDisplayDirectory
|
||||
char* newCurrentDirectory = new char[MAX_PATH+1];
|
||||
VERIFY(::GetCurrentDirectory(MAX_PATH, newCurrentDirectory) > 0);
|
||||
mDisplayDirectory.SetLength(0);
|
||||
mDisplayDirectory.Append(newCurrentDirectory);
|
||||
delete newCurrentDirectory;
|
||||
|
||||
|
||||
VERIFY(::SetCurrentDirectory(currentDirectory));
|
||||
delete currentDirectory;
|
||||
|
||||
// Clean up filter buffers
|
||||
delete filterBuffer;
|
||||
delete title;
|
||||
delete initialDir;
|
||||
|
||||
// Set user-selected location of file or directory
|
||||
mFile.SetLength(0);
|
||||
if (result == PR_TRUE) {
|
||||
mFile.Append(fileBuffer);
|
||||
}
|
||||
|
||||
return((PRBool)result);
|
||||
#endif
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Convert filter titles + filters into a Windows filter string
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void nsFileWidget::GetFilterListArray(nsString& aFilterList)
|
||||
{
|
||||
aFilterList.SetLength(0);
|
||||
for (PRUint32 i = 0; i < mNumberOfFilters; i++) {
|
||||
const nsString& title = mTitles[i];
|
||||
const nsString& filter = mFilters[i];
|
||||
|
||||
aFilterList.Append(title);
|
||||
aFilterList.Append('\0');
|
||||
aFilterList.Append(filter);
|
||||
aFilterList.Append('\0');
|
||||
}
|
||||
aFilterList.Append('\0');
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set the list of filters
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[])
|
||||
{
|
||||
mNumberOfFilters = aNumberOfFilters;
|
||||
mTitles = aTitles;
|
||||
mFilters = aFilters;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get the file + path
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsFileWidget::GetFile(nsFileSpec& aFile)
|
||||
{
|
||||
aFile = mFile;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get the file + path
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsFileWidget::SetDefaultString(const nsString& aString)
|
||||
{
|
||||
mDefault = aString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set the display directory
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory)
|
||||
{
|
||||
mDisplayDirectory = aDirectory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get the display directory
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory)
|
||||
{
|
||||
aDirectory = mDisplayDirectory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsFileWidget::Create(nsIWidget *aParent,
|
||||
const nsString& aTitle,
|
||||
nsFileDlgMode aMode,
|
||||
nsIDeviceContext *aContext = nsnull,
|
||||
nsIAppShell *aAppShell = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
void *aInitData = nsnull)
|
||||
{
|
||||
// mWnd = (HWND) ((aParent) ? aParent->GetNativeData(NS_NATIVE_WINDOW) : 0);
|
||||
mTitle.SetLength(0);
|
||||
mTitle.Append(aTitle);
|
||||
mMode = aMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsFileWidget destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsFileWidget::~nsFileWidget()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsFileDlgResults nsFileWidget::GetFile(nsIWidget *aParent,
|
||||
const nsString &promptString,
|
||||
nsFileSpec &theFileSpec)
|
||||
{
|
||||
Create(aParent, promptString, eMode_load, nsnull, nsnull);
|
||||
if (Show() == PR_TRUE)
|
||||
{
|
||||
GetFile(theFileSpec);
|
||||
return nsFileDlgResults_OK;
|
||||
}
|
||||
|
||||
return nsFileDlgResults_Cancel;
|
||||
}
|
||||
|
||||
nsFileDlgResults nsFileWidget::GetFolder(nsIWidget *aParent,
|
||||
const nsString &promptString,
|
||||
nsFileSpec &theFileSpec)
|
||||
{
|
||||
Create(aParent, promptString, eMode_getfolder, nsnull, nsnull);
|
||||
if (Show() == PR_TRUE)
|
||||
{
|
||||
GetFile(theFileSpec);
|
||||
return nsFileDlgResults_OK;
|
||||
}
|
||||
|
||||
return nsFileDlgResults_Cancel;
|
||||
}
|
||||
|
||||
nsFileDlgResults nsFileWidget::PutFile(nsIWidget *aParent,
|
||||
const nsString &promptString,
|
||||
nsFileSpec &theFileSpec)
|
||||
{
|
||||
Create(aParent, promptString, eMode_save, nsnull, nsnull);
|
||||
if (Show() == PR_TRUE)
|
||||
{
|
||||
GetFile(theFileSpec);
|
||||
return nsFileDlgResults_OK;
|
||||
}
|
||||
return nsFileDlgResults_Cancel;
|
||||
}
|
||||
|
||||
NS_METHOD nsFileWidget::GetSelectedType(PRInt16& theType)
|
||||
{
|
||||
theType = mSelectedType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsFileWidget_h__
|
||||
#define nsFileWidget_h__
|
||||
|
||||
#include "nsObject.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIFileWidget.h"
|
||||
|
||||
/**
|
||||
* Native Win32 FileSelector wrapper
|
||||
*/
|
||||
|
||||
class nsFileWidget : public nsIFileWidget
|
||||
{
|
||||
public:
|
||||
nsFileWidget();
|
||||
virtual ~nsFileWidget();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
PRBool OnPaint(nsRect &r);
|
||||
|
||||
// nsIWidget interface
|
||||
|
||||
NS_IMETHOD Create(nsIWidget *aParent,
|
||||
const nsString& aTitle,
|
||||
nsFileDlgMode aMode,
|
||||
nsIDeviceContext *aContext = nsnull,
|
||||
nsIAppShell *aAppShell = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
void *aInitData = nsnull);
|
||||
|
||||
// nsIFileWidget part
|
||||
virtual PRBool Show();
|
||||
NS_IMETHOD GetFile(nsFileSpec& aFile);
|
||||
NS_IMETHOD SetDefaultString(const nsString& aFile);
|
||||
NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters,
|
||||
const nsString aTitles[],
|
||||
const nsString aFilters[]);
|
||||
|
||||
NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory);
|
||||
NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory);
|
||||
|
||||
virtual nsFileDlgResults GetFile(nsIWidget *aParent,
|
||||
const nsString &promptString,
|
||||
nsFileSpec &theFileSpec);
|
||||
|
||||
virtual nsFileDlgResults GetFolder(nsIWidget *aParent,
|
||||
const nsString &promptString,
|
||||
nsFileSpec &theFileSpec);
|
||||
|
||||
virtual nsFileDlgResults PutFile(nsIWidget *aParent,
|
||||
const nsString &promptString,
|
||||
nsFileSpec &theFileSpec);
|
||||
|
||||
|
||||
NS_IMETHOD GetSelectedType(PRInt16& theType);
|
||||
|
||||
protected:
|
||||
|
||||
// HWND mWnd;
|
||||
nsString mTitle;
|
||||
nsFileDlgMode mMode;
|
||||
nsString mFile;
|
||||
PRUint32 mNumberOfFilters;
|
||||
const nsString* mTitles;
|
||||
const nsString* mFilters;
|
||||
nsString mDefault;
|
||||
nsFileSpec mDisplayDirectory;
|
||||
PRInt16 mSelectedType;
|
||||
|
||||
|
||||
void GetFilterListArray(nsString& aFilterList);
|
||||
};
|
||||
|
||||
#endif // nsFileWidget_h__
|
||||
@@ -1,418 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsFontRetrieverService.h"
|
||||
#include "nsIWidget.h"
|
||||
#include <ctype.h>
|
||||
|
||||
#include "nsFont.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsFontSizeIterator.h"
|
||||
|
||||
NS_IMPL_ADDREF(nsFontRetrieverService)
|
||||
NS_IMPL_RELEASE(nsFontRetrieverService)
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
nsFontRetrieverService::nsFontRetrieverService()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mFontList = nsnull;
|
||||
mSizeIter = nsnull;
|
||||
mNameIterInx = 0;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
nsFontRetrieverService::~nsFontRetrieverService()
|
||||
{
|
||||
if (nsnull != mFontList) {
|
||||
for (PRInt32 i=0;i<mFontList->Count();i++) {
|
||||
FontInfo * font = (FontInfo *)mFontList->ElementAt(i);
|
||||
if (font->mSizes) {
|
||||
delete font->mSizes;
|
||||
}
|
||||
delete font;
|
||||
}
|
||||
delete mFontList;
|
||||
}
|
||||
NS_IF_RELEASE(mSizeIter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*
|
||||
*/
|
||||
nsresult nsFontRetrieverService::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv = NS_NOINTERFACE;
|
||||
|
||||
if (aIID.Equals(nsIFontRetrieverService::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsIFontRetrieverService*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(nsIFontNameIterator::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsIFontNameIterator*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
//-- nsIFontRetrieverService
|
||||
//----------------------------------------------------------
|
||||
NS_IMETHODIMP nsFontRetrieverService::CreateFontNameIterator( nsIFontNameIterator** aIterator )
|
||||
{
|
||||
if (nsnull == aIterator) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (nsnull == mFontList) {
|
||||
LoadFontList();
|
||||
}
|
||||
*aIterator = this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
NS_IMETHODIMP nsFontRetrieverService::CreateFontSizeIterator( const nsString & aFontName,
|
||||
nsIFontSizeIterator** aIterator )
|
||||
{
|
||||
// save value in case someone externally is using it
|
||||
PRInt32 saveIterInx = mNameIterInx;
|
||||
|
||||
PRBool found = PR_FALSE;
|
||||
Reset();
|
||||
do {
|
||||
nsAutoString name;
|
||||
Get(&name);
|
||||
if (name.Equals(aFontName)) {
|
||||
found = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
} while (Advance() == NS_OK);
|
||||
|
||||
if (found) {
|
||||
if (nsnull == mSizeIter) {
|
||||
mSizeIter = new nsFontSizeIterator();
|
||||
}
|
||||
NS_ASSERTION( nsnull != mSizeIter, "nsFontSizeIterator instance pointer is null");
|
||||
|
||||
*aIterator = (nsIFontSizeIterator *)mSizeIter;
|
||||
NS_ADDREF(mSizeIter);
|
||||
|
||||
FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx);
|
||||
mSizeIter->SetFontInfo(fontInfo);
|
||||
mNameIterInx = saveIterInx;
|
||||
return NS_OK;
|
||||
}
|
||||
mNameIterInx = saveIterInx;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
//-- nsIFontNameIterator
|
||||
//----------------------------------------------------------
|
||||
NS_IMETHODIMP nsFontRetrieverService::Reset()
|
||||
{
|
||||
mNameIterInx = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
NS_IMETHODIMP nsFontRetrieverService::Get( nsString* aFontName )
|
||||
{
|
||||
if (mNameIterInx < mFontList->Count()) {
|
||||
FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx);
|
||||
*aFontName = fontInfo->mName;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
NS_IMETHODIMP nsFontRetrieverService::Advance()
|
||||
{
|
||||
if (mNameIterInx < mFontList->Count()-1) {
|
||||
mNameIterInx++;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//------------------------------
|
||||
static FontInfo * GetFontInfo(nsVoidArray * aFontList, char * aName)
|
||||
{
|
||||
nsAutoString name(aName);
|
||||
PRInt32 i;
|
||||
PRInt32 cnt = aFontList->Count();
|
||||
for (i=0;i<cnt;i++) {
|
||||
FontInfo * fontInfo = (FontInfo *)aFontList->ElementAt(i);
|
||||
if (fontInfo->mName.Equals(name)) {
|
||||
return fontInfo;
|
||||
}
|
||||
}
|
||||
|
||||
FontInfo * fontInfo = new FontInfo();
|
||||
fontInfo->mName = aName;
|
||||
//printf("Adding [%s]\n", aName);fflush(stdout);
|
||||
fontInfo->mIsScalable = PR_FALSE; // X fonts aren't scalable right??
|
||||
fontInfo->mSizes = nsnull;
|
||||
aFontList->AppendElement(fontInfo);
|
||||
return fontInfo;
|
||||
}
|
||||
|
||||
//------------------------------
|
||||
static void AddSizeToFontInfo(FontInfo * aFontInfo, PRInt32 aSize)
|
||||
{
|
||||
nsVoidArray * sizes;
|
||||
if (nsnull == aFontInfo->mSizes) {
|
||||
sizes = new nsVoidArray();
|
||||
aFontInfo->mSizes = sizes;
|
||||
} else {
|
||||
sizes = aFontInfo->mSizes;
|
||||
}
|
||||
PRInt32 i;
|
||||
PRInt32 cnt = sizes->Count();
|
||||
for (i=0;i<cnt;i++) {
|
||||
PRInt32 size = (int)sizes->ElementAt(i);
|
||||
if (size == aSize) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
sizes->AppendElement((void *)aSize);
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
// XXX - Hack - Parts of this will need to be reworked
|
||||
//
|
||||
// This method does brute force parcing for 4 different formats:
|
||||
//
|
||||
// 1) The format -*-*-*-*-*-* etc.
|
||||
// -misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-8
|
||||
//
|
||||
// 2) Name-size format
|
||||
// lucidasans-10
|
||||
//
|
||||
// 3) Name-style-size
|
||||
// lucidasans-bold-10
|
||||
//
|
||||
// 4) Name only (implicit size)
|
||||
// 6x13
|
||||
//
|
||||
//--------------------------------------------------
|
||||
NS_IMETHODIMP nsFontRetrieverService::LoadFontList()
|
||||
{
|
||||
// char * pattern = "*";
|
||||
// int nnames = 1024;
|
||||
//
|
||||
// int available = nnames+1;
|
||||
// int i;
|
||||
// char **fonts;
|
||||
// XFontStruct *info;
|
||||
//
|
||||
// if (nsnull == mFontList) {
|
||||
// mFontList = new nsVoidArray();
|
||||
// if (nsnull == mFontList) {
|
||||
// return NS_ERROR_FAILURE;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /* Get list of fonts matching pattern */
|
||||
// for (;;) {
|
||||
// // the following line is VERY slow to return
|
||||
// fonts = XListFontsWithInfo(GDK_DISPLAY(), pattern, nnames,
|
||||
// &available, &info);
|
||||
// if (fonts == NULL || available < nnames)
|
||||
// break;
|
||||
//
|
||||
// XFreeFontInfo(fonts, info, available);
|
||||
// nnames = available * 2;
|
||||
// }
|
||||
//
|
||||
// if (fonts == NULL) {
|
||||
// fprintf(stderr, "pattern \"%s\" unmatched\n", pattern);
|
||||
// return NS_ERROR_FAILURE;
|
||||
// }
|
||||
//
|
||||
//#if 0 // debug
|
||||
// // print out all the retrieved fonts
|
||||
// printf("-----------------------------\n");
|
||||
// for (i=0; i<available; i++) {
|
||||
// printf("[%s]i\n", fonts[i]);
|
||||
// }
|
||||
// printf("-----------------------------\n");
|
||||
//#endif
|
||||
//
|
||||
// // this code assumes all like fonts are grouped together
|
||||
// // currentName is the current name of the font we are gathering
|
||||
// // sizes for, when the name changes we create a new FontInfo object
|
||||
// // but it also takes into account fonts of similar names when it
|
||||
// // goes to add then and disregards duplicates
|
||||
// char buffer[1024];
|
||||
// char currentName[1024];
|
||||
// FontInfo * font = nsnull;
|
||||
//
|
||||
// currentName[0] = 0;
|
||||
// for (i=0; i<available; i++) {
|
||||
//
|
||||
// // This is kind of lame, but it will have to do for now
|
||||
// strcpy(buffer, fonts[i]);
|
||||
//
|
||||
// // Start by checking to see if the name begins with a dash
|
||||
// char * ptr = buffer;
|
||||
// if (buffer[0] == '-') { //Format #1
|
||||
//
|
||||
// PRInt32 cnt = 0;
|
||||
// // skip first two '-'
|
||||
// do {
|
||||
// if (*ptr == '-') cnt++;
|
||||
// ptr++;
|
||||
// } while (cnt < 2);
|
||||
//
|
||||
// // find the dash at the end of the name
|
||||
// char * end = strchr(ptr, '-');
|
||||
// if (end) {
|
||||
// *end = 0;
|
||||
//
|
||||
// // Check to see if we need to create a new FontInfo obj
|
||||
// // and set the currentName var to this guys font name
|
||||
// if (strcmp(currentName, ptr) || NULL == font) {
|
||||
// font = GetFontInfo(mFontList, ptr);
|
||||
// strcpy(currentName, ptr);
|
||||
// }
|
||||
// if (nsnull == font->mSizes) {
|
||||
// font->mSizes = new nsVoidArray();
|
||||
// }
|
||||
// ptr = end+1; // skip past the dash that was set to zero
|
||||
//
|
||||
// cnt = 0;
|
||||
// // now skip ahead 4 dashes
|
||||
// do {
|
||||
// if (*ptr == '-') cnt++;
|
||||
// ptr++;
|
||||
// } while (cnt < 4);
|
||||
//
|
||||
// // find the dash after the size
|
||||
// end = strchr(ptr, '-');
|
||||
//
|
||||
// if (end) {
|
||||
// *end = 0;
|
||||
// PRInt32 size;
|
||||
// sscanf(ptr, "%d", &size);
|
||||
// AddSizeToFontInfo(font, size);
|
||||
// }
|
||||
// }
|
||||
// } else { // formats 2,3,4
|
||||
//
|
||||
// // no leading dash means the start of the
|
||||
// // buffer is the start of the name
|
||||
// // this checks for a dash at the end of the font name
|
||||
// // which means there is a size at the end
|
||||
// char * end = strchr(buffer, '-');
|
||||
// if (end) { // Format 2,3
|
||||
// *end = 0;
|
||||
// // Check to see if we need to create a new FontInfo obj
|
||||
// // and set the currentName var to this guys font name
|
||||
// if (strcmp(currentName, buffer) || NULL == font) {
|
||||
// font = GetFontInfo(mFontList, buffer);
|
||||
// strcpy(currentName, buffer);
|
||||
// }
|
||||
// end++; // advance past the dash
|
||||
// // check to see if we have a number
|
||||
// ptr = end;
|
||||
// if (isalpha(*ptr)) { // Format 3
|
||||
// // skip until next dash
|
||||
// end = strchr(ptr, '-');
|
||||
// if (end) {
|
||||
// *end = 0;
|
||||
// ptr = end+1;
|
||||
// }
|
||||
// }
|
||||
// PRInt32 size;
|
||||
// // yes, it has a dash at the end so it must have the size
|
||||
// // check to see if the size is terminated by a dash
|
||||
// // it shouldn't be
|
||||
// char * end2 = strchr(ptr, '-');
|
||||
// if (end2) *end2 = 0; // put terminator at the dash
|
||||
// sscanf(end, "%d", &size);
|
||||
// AddSizeToFontInfo(font, size);
|
||||
//
|
||||
// } else { // Format #4
|
||||
// // The font has an implicit size,
|
||||
// // so there is nothing to parse for size
|
||||
// // so we can't really do much here
|
||||
// // Check to see if we need to create a new FontInfo obj
|
||||
// // and set the currentName var to this guys font name
|
||||
// if (strcmp(currentName, buffer) || NULL == font) {
|
||||
// font = GetFontInfo(mFontList, buffer);
|
||||
// strcpy(currentName, buffer);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// XFreeFontInfo(fonts, info, available);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
NS_IMETHODIMP nsFontRetrieverService::IsFontScalable(const nsString & aFontName,
|
||||
PRBool* aResult )
|
||||
{
|
||||
// save value in case someone externally is using it
|
||||
PRInt32 saveIterInx = mNameIterInx;
|
||||
|
||||
PRBool found = PR_FALSE;
|
||||
Reset();
|
||||
do {
|
||||
nsAutoString name;
|
||||
Get(&name);
|
||||
if (name.Equals(aFontName)) {
|
||||
found = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
} while (Advance() == NS_OK);
|
||||
|
||||
if (found) {
|
||||
FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx);
|
||||
*aResult = fontInfo->mIsScalable;
|
||||
mNameIterInx = saveIterInx;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mNameIterInx = saveIterInx;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef __nsFontRetrieverService
|
||||
#define __nsFontRetrieverService
|
||||
|
||||
#include "nsIFontRetrieverService.h"
|
||||
#include "nsIFontNameIterator.h"
|
||||
|
||||
class nsVoidArray;
|
||||
class nsFontSizeIterator;
|
||||
|
||||
class nsFontRetrieverService: public nsIFontRetrieverService,
|
||||
public nsIFontNameIterator {
|
||||
public:
|
||||
nsFontRetrieverService();
|
||||
virtual ~nsFontRetrieverService();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIFontRetrieverService
|
||||
NS_IMETHOD CreateFontNameIterator( nsIFontNameIterator** aIterator );
|
||||
|
||||
NS_IMETHOD CreateFontSizeIterator( const nsString & aFontName, nsIFontSizeIterator** aIterator );
|
||||
NS_IMETHOD IsFontScalable( const nsString & aFontName, PRBool* aResult );
|
||||
|
||||
// nsIFontNameIterator
|
||||
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD Get( nsString* aFontName );
|
||||
NS_IMETHOD Advance();
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
NS_IMETHOD LoadFontList();
|
||||
|
||||
nsVoidArray * mFontList;
|
||||
|
||||
PRInt32 mNameIterInx;
|
||||
|
||||
nsFontSizeIterator * mSizeIter;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,84 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsFontSizeIterator.h"
|
||||
|
||||
#include "nsFont.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsFontSizeIterator)
|
||||
NS_IMPL_RELEASE(nsFontSizeIterator)
|
||||
NS_IMPL_QUERY_INTERFACE(nsFontSizeIterator, nsIFontSizeIterator::GetIID())
|
||||
|
||||
//----------------------------------------------------------
|
||||
nsFontSizeIterator::nsFontSizeIterator()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mFontInfo = nsnull;
|
||||
mSizeIterInx = 0;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
nsFontSizeIterator::~nsFontSizeIterator()
|
||||
{
|
||||
}
|
||||
|
||||
///----------------------------------------------------------
|
||||
//-- nsIFontNameIterator
|
||||
//----------------------------------------------------------
|
||||
NS_IMETHODIMP nsFontSizeIterator::Reset()
|
||||
{
|
||||
mSizeIterInx = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
NS_IMETHODIMP nsFontSizeIterator::Get( double* aFontSize )
|
||||
{
|
||||
if (nsnull != mFontInfo->mSizes &&
|
||||
mFontInfo->mSizes->Count() > 0 &&
|
||||
mSizeIterInx < mFontInfo->mSizes->Count()) {
|
||||
PRUint32 size = (PRUint32)mFontInfo->mSizes->ElementAt(mSizeIterInx);
|
||||
*aFontSize = (double)size;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
NS_IMETHODIMP nsFontSizeIterator::Advance()
|
||||
{
|
||||
if (nsnull != mFontInfo->mSizes &&
|
||||
mFontInfo->mSizes->Count() > 0 &&
|
||||
mSizeIterInx < mFontInfo->mSizes->Count()-2) {
|
||||
mSizeIterInx++;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
NS_IMETHODIMP nsFontSizeIterator::SetFontInfo( FontInfo * aFontInfo )
|
||||
{
|
||||
mFontInfo = aFontInfo;
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef __nsFontSizeIterator
|
||||
#define __nsFontSizeIterator
|
||||
|
||||
#include "nsIFontSizeIterator.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsVoidArray;
|
||||
|
||||
typedef struct {
|
||||
nsString mName;
|
||||
PRBool mIsScalable;
|
||||
nsVoidArray * mSizes;
|
||||
} FontInfo;
|
||||
|
||||
|
||||
class nsFontSizeIterator: public nsIFontSizeIterator {
|
||||
public:
|
||||
nsFontSizeIterator();
|
||||
virtual ~nsFontSizeIterator();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIFontSizeIterator
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD Get( double* aFontSize );
|
||||
NS_IMETHOD Advance();
|
||||
|
||||
// Native impl
|
||||
NS_IMETHOD SetFontInfo( FontInfo * aFontInfo );
|
||||
|
||||
protected:
|
||||
|
||||
FontInfo * mFontInfo;
|
||||
PRInt32 mSizeIterInx; // current index of iter
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,222 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsLabel.h"
|
||||
#include "nsILabel.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringUtil.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
|
||||
NS_IMPL_ADDREF(nsLabel)
|
||||
NS_IMPL_RELEASE(nsLabel)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsLabel constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsLabel::nsLabel() : nsWindow(), nsILabel()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mAlignment = eAlign_Left;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsLabel::PreCreateWidget(nsWidgetInitData *aInitData)
|
||||
{
|
||||
if (nsnull != aInitData) {
|
||||
nsLabelInitData* data = (nsLabelInitData *) aInitData;
|
||||
mAlignment = data->mAlignment;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsLabel destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsLabel::~nsLabel()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsLabel::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr);
|
||||
|
||||
static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID);
|
||||
if (result == NS_NOINTERFACE && aIID.Equals(kILabelIID)) {
|
||||
*aInstancePtr = (void*) ((nsILabel*)this);
|
||||
NS_ADDREF_THIS();
|
||||
result = NS_OK;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsLabel::SetAlignment(nsLabelAlignment aAlignment)
|
||||
{
|
||||
mAlignment = aAlignment;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsLabel::SetLabel(const nsString& aText)
|
||||
{
|
||||
char label[256];
|
||||
aText.ToCString(label, 256);
|
||||
label[255] = '\0';
|
||||
if(mStringView && mStringView->LockLooper())
|
||||
{
|
||||
mStringView->SetText(label);
|
||||
mStringView->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsLabel::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
if(mStringView && mStringView->LockLooper())
|
||||
{
|
||||
aBuffer.SetLength(0);
|
||||
aBuffer.Append(mStringView->Text());
|
||||
mStringView->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// move, paint, resizes message - ignore
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsLabel::OnMove(PRInt32, PRInt32)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsLabel::OnPaint(nsRect &r)
|
||||
{
|
||||
//printf("** nsLabel::OnPaint **\n");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsLabel::OnResize(nsRect &aWindowRect)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// get position/dimensions
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsLabel::GetBounds(nsRect &aRect)
|
||||
{
|
||||
return nsWindow::GetBounds(aRect);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsLabel::GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight)
|
||||
{
|
||||
if (nsnull == mContext) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
//nsIFontMetrics * fm = GetFont();;
|
||||
// mDeviceContext->GetMetricsFor(mFont, &fm);
|
||||
|
||||
nsIFontMetrics* metrics;
|
||||
mContext->GetMetricsFor(*mFont, metrics);
|
||||
|
||||
nsString text;
|
||||
GetLabel(text);
|
||||
|
||||
nsIRenderingContext *cx;
|
||||
mContext->CreateRenderingContext(this, cx);
|
||||
cx->SetFont(metrics);
|
||||
nscoord string_height, string_width;
|
||||
metrics->GetHeight(string_height);
|
||||
cx->GetWidth(text, string_width);
|
||||
NS_RELEASE(cx);
|
||||
NS_RELEASE(metrics);
|
||||
|
||||
if (mPreferredWidth != 0) {
|
||||
aWidth = mPreferredWidth;
|
||||
} else {
|
||||
aWidth = string_width+8;
|
||||
}
|
||||
|
||||
if (mPreferredHeight != 0) {
|
||||
aHeight = mPreferredHeight;
|
||||
} else {
|
||||
aHeight = string_height+8;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsLabel::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
mPreferredWidth = aWidth;
|
||||
mPreferredHeight = aHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
BView *nsLabel::CreateBeOSView()
|
||||
{
|
||||
return mStringView = new nsStringViewBeOS(this, BRect(0, 0, 0, 0), "", "");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Sub-class of BeOS StringView
|
||||
//-------------------------------------------------------------------------
|
||||
nsStringViewBeOS::nsStringViewBeOS( nsIWidget *aWidgetWindow, BRect aFrame,
|
||||
const char *aName, const char *text, uint32 aResizingMode, uint32 aFlags )
|
||||
: BStringView( aFrame, aName, text, aResizingMode, aFlags ),
|
||||
nsIWidgetStore( aWidgetWindow )
|
||||
{
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsLabel_h__
|
||||
#define nsLabel_h__
|
||||
|
||||
#include "nsdefs.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsSwitchToUIThread.h"
|
||||
|
||||
#include "nsILabel.h"
|
||||
|
||||
#include <StringView.h>
|
||||
|
||||
/**
|
||||
* Native Win32 Label wrapper
|
||||
*/
|
||||
|
||||
class nsLabel : public nsWindow,
|
||||
public nsILabel
|
||||
{
|
||||
|
||||
public:
|
||||
nsLabel();
|
||||
virtual ~nsLabel();
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
// nsILabel part
|
||||
NS_IMETHOD SetLabel(const nsString &aText);
|
||||
NS_IMETHOD GetLabel(nsString &aBuffer);
|
||||
NS_IMETHOD SetAlignment(nsLabelAlignment aAlignment);
|
||||
|
||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
||||
virtual PRBool OnPaint(nsRect &r);
|
||||
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||
|
||||
NS_IMETHOD GetBounds(nsRect &aRect);
|
||||
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData);
|
||||
|
||||
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
|
||||
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
|
||||
|
||||
protected:
|
||||
nsLabelAlignment mAlignment;
|
||||
BStringView *mStringView;
|
||||
BView *CreateBeOSView();
|
||||
};
|
||||
|
||||
//
|
||||
// A BStringView subclass
|
||||
//
|
||||
class nsStringViewBeOS : public BStringView, public nsIWidgetStore {
|
||||
public:
|
||||
nsStringViewBeOS( nsIWidget *aWidgetWindow, BRect aFrame, const char *aName,
|
||||
const char *text, uint32 aResizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 aFlags = B_WILL_DRAW | B_NAVIGABLE );
|
||||
};
|
||||
|
||||
#endif // nsLabel_h__
|
||||
@@ -1,389 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsListBox.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringUtil.h"
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsListBox)
|
||||
NS_IMPL_RELEASE(nsListBox)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// initializer
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsListBox::SetMultipleSelection(PRBool aMultipleSelections)
|
||||
{
|
||||
mMultiSelect = aMultipleSelections;
|
||||
if(mListView && mListView->LockLooper())
|
||||
{
|
||||
mListView->SetListType(aMultipleSelections ? B_MULTIPLE_SELECTION_LIST : B_SINGLE_SELECTION_LIST);
|
||||
mListView->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsListBox::PreCreateWidget(nsWidgetInitData *aInitData)
|
||||
{
|
||||
if (nsnull != aInitData) {
|
||||
nsListBoxInitData* data = (nsListBoxInitData *) aInitData;
|
||||
mMultiSelect = data->mMultiSelect;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsListBox::AddItemAt(nsString &aItem, PRInt32 aPosition)
|
||||
{
|
||||
if(mListView && mListView->LockLooper())
|
||||
{
|
||||
NS_ALLOC_STR_BUF(val, aItem, 256);
|
||||
mListView->AddItem(new BStringItem(val), aPosition);
|
||||
NS_FREE_STR_BUF(val);
|
||||
mListView->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Finds an item at a postion
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsListBox::FindItem(nsString &aItem, PRInt32 aStartPos)
|
||||
{
|
||||
#if 0
|
||||
NS_ALLOC_STR_BUF(val, aItem, 256);
|
||||
int index = ::SendMessage(mWnd, LB_FINDSTRINGEXACT, (int)aStartPos, (LPARAM)(LPCTSTR)val);
|
||||
NS_FREE_STR_BUF(val);
|
||||
|
||||
return index;
|
||||
#endif
|
||||
printf("nsListBox::FindItem not implemented\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// CountItems - Get Item Count
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsListBox::GetItemCount()
|
||||
{
|
||||
PRInt32 result = 0;
|
||||
if(mListView && mListView->LockLooper())
|
||||
{
|
||||
result = mListView->CountItems();
|
||||
mListView->UnlockLooper();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Removes an Item at a specified location
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsListBox::RemoveItemAt(PRInt32 aPosition)
|
||||
{
|
||||
if(mListView && mListView->LockLooper())
|
||||
{
|
||||
BListItem *it = mListView->RemoveItem(aPosition);
|
||||
delete it;
|
||||
mListView->UnlockLooper();
|
||||
return it ? PR_TRUE : PR_FALSE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Removes an Item at a specified location
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsListBox::GetItemAt(nsString& anItem, PRInt32 aPosition)
|
||||
{
|
||||
PRBool result = PR_FALSE;
|
||||
anItem.SetLength(0);
|
||||
if(mListView && mListView->LockLooper())
|
||||
{
|
||||
BListItem *it = mListView->ItemAt(aPosition);
|
||||
BStringItem *str;
|
||||
if((str = dynamic_cast<BStringItem *>(it)) != 0)
|
||||
{
|
||||
anItem.Append(str->Text());
|
||||
result = PR_TRUE;
|
||||
}
|
||||
mListView->UnlockLooper();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Gets the selected of selected item
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsListBox::GetSelectedItem(nsString& aItem)
|
||||
{
|
||||
if (!mMultiSelect) {
|
||||
GetItemAt(aItem, GetSelectedIndex());
|
||||
} else {
|
||||
NS_ASSERTION(0, "Multi selection list box does not support GetSelectedItem()");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Gets the list of selected otems
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsListBox::GetSelectedIndex()
|
||||
{
|
||||
if (!mMultiSelect)
|
||||
{
|
||||
PRInt32 index = -1;
|
||||
if(mListView && mListView->LockLooper())
|
||||
{
|
||||
index = mListView->CurrentSelection();
|
||||
mListView->UnlockLooper();
|
||||
}
|
||||
return index;
|
||||
} else {
|
||||
NS_ASSERTION(0, "Multi selection list box does not support GetSelectedIndex()");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// SelectItem
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsListBox::SelectItem(PRInt32 aPosition)
|
||||
{
|
||||
if(mListView && mListView->LockLooper())
|
||||
{
|
||||
mListView->Select(aPosition);
|
||||
mListView->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// GetSelectedCount
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsListBox::GetSelectedCount()
|
||||
{
|
||||
if (!mMultiSelect) {
|
||||
PRInt32 inx = GetSelectedIndex();
|
||||
return (inx == -1? 0 : 1);
|
||||
} else {
|
||||
PRInt32 count = 0;
|
||||
if(mListView && mListView->LockLooper())
|
||||
{
|
||||
int index = 0;
|
||||
while((index = mListView->CurrentSelection(index)) != -1)
|
||||
count++;
|
||||
mListView->UnlockLooper();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// GetSelectedIndices
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsListBox::GetSelectedIndices(PRInt32 aIndices[], PRInt32 aSize)
|
||||
{
|
||||
if(mListView && mListView->LockLooper())
|
||||
{
|
||||
int index = 0;
|
||||
for(int i = 0; i < aSize; i++)
|
||||
{
|
||||
if(index != -1)
|
||||
index = mListView->CurrentSelection(index);
|
||||
aIndices[i] = index;
|
||||
}
|
||||
mListView->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// SetSelectedIndices
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsListBox::SetSelectedIndices(PRInt32 aIndices[], PRInt32 aSize)
|
||||
{
|
||||
if(mListView && mListView->LockLooper())
|
||||
{
|
||||
mListView->Select(aIndices[0], false);
|
||||
for(int i = 1; i < aSize; i++)
|
||||
mListView->Select(aIndices[i], true);
|
||||
mListView->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Deselect
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsListBox::Deselect()
|
||||
{
|
||||
if(mListView && mListView->LockLooper())
|
||||
{
|
||||
mListView->DeselectAll();
|
||||
mListView->UnlockLooper();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsListBox constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsListBox::nsListBox() : nsWindow(), nsIListWidget(), nsIListBox()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mMultiSelect = PR_FALSE;
|
||||
mBackground = NS_RGB(124, 124, 124);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsListBox:: destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsListBox::~nsListBox()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsListBox::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr);
|
||||
|
||||
static NS_DEFINE_IID(kInsListBoxIID, NS_ILISTBOX_IID);
|
||||
static NS_DEFINE_IID(kInsListWidgetIID, NS_ILISTWIDGET_IID);
|
||||
if (result == NS_NOINTERFACE) {
|
||||
if (aIID.Equals(kInsListBoxIID)) {
|
||||
*aInstancePtr = (void*) ((nsIListBox*)this);
|
||||
NS_ADDREF_THIS();
|
||||
result = NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kInsListWidgetIID)) {
|
||||
*aInstancePtr = (void*) ((nsIListWidget*)this);
|
||||
NS_ADDREF_THIS();
|
||||
result = NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// move, paint, resizes message - ignore
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsListBox::OnMove(PRInt32, PRInt32)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsListBox::OnPaint(nsRect &r)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsListBox::OnResize(nsRect &aWindowRect)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Clear window before paint
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
PRBool nsListBox::AutoErase()
|
||||
{
|
||||
return(PR_TRUE);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// get position/dimensions
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsListBox::GetBounds(nsRect &aRect)
|
||||
{
|
||||
#if 0
|
||||
nsWindow::GetNonClientBounds(aRect);
|
||||
#endif
|
||||
printf("nsListBox::GetBounds not wrong\n"); // the following is just a placeholder
|
||||
nsWindow::GetClientBounds(aRect);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
BView *nsListBox::CreateBeOSView()
|
||||
{
|
||||
return mListView = new nsListViewBeOS((nsIWidget *)this, BRect(0, 0, 0, 0), "");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Sub-class of BeOS ListView
|
||||
//-------------------------------------------------------------------------
|
||||
nsListViewBeOS::nsListViewBeOS( nsIWidget *aWidgetWindow, BRect aFrame,
|
||||
const char *aName, uint32 aResizingMode, uint32 aFlags )
|
||||
: BListView( aFrame, aName,
|
||||
((nsListBox *)aWidgetWindow)->mMultiSelect ? B_MULTIPLE_SELECTION_LIST : B_SINGLE_SELECTION_LIST,
|
||||
aResizingMode, aFlags ),
|
||||
nsIWidgetStore( aWidgetWindow )
|
||||
{
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user