Compare commits

..

174 Commits

Author SHA1 Message Date
sdv%sparc.spb.su
53866ece4f workaround for bug=30927
git-svn-id: svn://10.0.0.236/branches/M15-patch@72213 18797224-902f-48f8-a5cc-f745e15eee43
2000-06-14 11:34:36 +00:00
(no author)
350be55313 This commit was manufactured by cvs2svn to create branch 'M15-patch'.
git-svn-id: svn://10.0.0.236/branches/M15-patch@52901 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 02:47:16 +00:00
dmose%mozilla.org
ce50f7d151 updated license boilerplate to xPL 1.1, a=chofmann@netscape.com,r=endico@mozilla.org
git-svn-id: svn://10.0.0.236/trunk@52900 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 02:47:15 +00:00
dmose%mozilla.org
fe6a96903d updated license boilerplated to xPL 1.1, a=chofmann@netscape.com,r=endico@mozilla.org
git-svn-id: svn://10.0.0.236/trunk@52899 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 02:24:22 +00:00
endico%mozilla.org
33c31375b8 temporarily disabled this while dmose lands mpl licence change
git-svn-id: svn://10.0.0.236/trunk@52898 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 02:21:15 +00:00
dmose%mozilla.org
4136bb9b85 updated license boilerplated to xPL 1.1, a=chofmann@netscape.com,r=endico@mozilla.org
git-svn-id: svn://10.0.0.236/trunk@52897 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 02:11:51 +00:00
taek%netscape.com
502dbdb8c2 updated to use /share/builds/components
git-svn-id: svn://10.0.0.236/trunk@52895 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 02:11:18 +00:00
dmose%mozilla.org
fa6f75bbee updated license boilerplated to xPL 1.1, a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52894 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 02:06:26 +00:00
endico%mozilla.org
1f4659c914 temporarily turn off bonsai while dmose lands the mpl 1.1 licence
git-svn-id: svn://10.0.0.236/trunk@52893 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 02:03:13 +00:00
rpotts%netscape.com
6d25185793 bug #7428. Added support for connection timeout. Now if a connection cannot be made within 35 seconds, the transport times out.
git-svn-id: svn://10.0.0.236/trunk@52892 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 01:32:34 +00:00
sspitzer%netscape.com
cffac19a5f fix for #18064, r=alecf, a=choffman.
only create the local mail account if the user migrates from imap, or if the
user creates an imap server and they don't have a local mail account.


git-svn-id: svn://10.0.0.236/trunk@52891 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 01:22:28 +00:00
pollmann%netscape.com
63b5916e8b Bug 17995: Don't reset selection when adding an option to a combobox, as it caused reframing and a crash. r=harishd a=choffman
git-svn-id: svn://10.0.0.236/trunk@52890 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 00:54:54 +00:00
drapeau%eng.sun.com
c38feba394 r=fur@netscape.com, approval=chofmann@netscape.com. Fix for bug 5369
("[PP]Crash on startup because of Java Plug-in 1.3 for Netscape
Navigator.")  Make the code more bulletproof by checking for NULL
arguments to several methods.  If JVM isn't running, jEnv arg should
be NULL.

This doesn't entirely fix the problem of a JVM gone awry in all cases;
in the case of this particular bug, the Sun JDK 1.3 Beta HotSpot VM
caused an error, and there's no way for Mozilla code to detect this
failure mode.  The fix for that half of the problem is to use the new
JDK 1.3 Early Access VM, which does not exhibit the problem.


git-svn-id: svn://10.0.0.236/trunk@52888 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 00:24:42 +00:00
selmer%netscape.com
aa6d4da1fe Only put selected components in config's build
git-svn-id: svn://10.0.0.236/trunk@52887 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 00:04:08 +00:00
joki%netscape.com
acb57210c3 Fix for bug 17835. Free JS event listeners when the JS object they're registered on goes away. a:chofmann r:vidur
git-svn-id: svn://10.0.0.236/trunk@52886 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 23:37:40 +00:00
mscott%netscape.com
334b29cffa (not part of the build)
GetProtcocolHandler needs to pass in the uri we are trying to open so the
listener can pick an appropriate p.h. based on the protocol of the uri. (if
they so choose).


git-svn-id: svn://10.0.0.236/trunk@52885 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 23:26:16 +00:00
mscott%netscape.com
fb3eea6b4a (not part of the build)
1) add OpenURIVia support.
2) reimplent DispatchContent so we ask the listener if it can handle the content. Then when (if) we find
a content listener that can handle it, call DoContent.
3) if we can't find a content listener, go to the registry and try to find a registered content handler.
This part isn't finished as eventually i need to be going to the category manager instead of forming
the progid for the content handler myself.


git-svn-id: svn://10.0.0.236/trunk@52884 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 23:06:16 +00:00
mscott%netscape.com
4eb1a093e9 Add OpenURIVia which takes a static IP address.
(not part of the build)


git-svn-id: svn://10.0.0.236/trunk@52883 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 23:03:58 +00:00
mscott%netscape.com
cc6179325b (not part of build)
Add notion of CanHandleContent. This is supposed to be a light weight method for the implementor
such that the uri loader can ask right off the top if the listener can handle a particular content
type. If it can, then later on, the uir loader may call DoContent to actually handle it.


git-svn-id: svn://10.0.0.236/trunk@52882 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 22:54:53 +00:00
mscott%netscape.com
ab2f6ea0db add a new line at the end of the file
(not part of the seamonkey build)


git-svn-id: svn://10.0.0.236/trunk@52881 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 22:53:21 +00:00
mscott%netscape.com
53828293ef (not part of the seamonkey build!)
remove CanHandleConent. I don't think we need this. Also remove notion of getting a parent
content handler. This doesn't make sense anymore for how I'm defining a content handler.
Added progid prefix for content handler.


git-svn-id: svn://10.0.0.236/trunk@52880 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 22:52:35 +00:00
karnaze%netscape.com
49e55fa057 bugs 17138, 17168 and others - col allocation involving colspans honors constraints; pct colspans were allocating incorrectly if pct cols existed.
git-svn-id: svn://10.0.0.236/trunk@52879 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 22:36:59 +00:00
karnaze%netscape.com
c5c9738319 crash on abc - calls EnsureColumns upon entering reflow if appropriate
git-svn-id: svn://10.0.0.236/trunk@52878 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 22:33:04 +00:00
putterman%netscape.com
4ee15a0425 Workaround for 18088. make delete toolbar button work for thread pane. reviewed by
hangas approved by chofmann.


git-svn-id: svn://10.0.0.236/trunk@52877 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 22:21:41 +00:00
norris%netscape.com
1996d97ba3 Unify evaluation code to improve consistency and improve code size.
git-svn-id: svn://10.0.0.236/trunk@52875 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 22:18:24 +00:00
slamm%netscape.com
e5f4e7c849 Fix for bug 18017, "No sidebar panels in messenger." r=hangas a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52871 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 22:10:29 +00:00
mjudge%netscape.com
b476111e67 fix review by sfrasier, approved choffman. simple fix to get first letter style frames/paragraphs to show their selection. simply notifies children that the selection bit should be "on"
git-svn-id: svn://10.0.0.236/trunk@52870 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 22:09:16 +00:00
fur%netscape.com
c8cc3fe9b2 Checkpoint
git-svn-id: svn://10.0.0.236/trunk@52867 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 21:58:37 +00:00
alecf%netscape.com
be87817fb0 fix for #17763 - initialize cellFrame so that if it's not found, the null check succeeds
r=hyatt
a=chofmann


git-svn-id: svn://10.0.0.236/trunk@52866 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 21:51:42 +00:00
norris%netscape.com
bef3328b2f Remove JSuncaughtExceptionLine, use an error reporter to report line number info instead.
git-svn-id: svn://10.0.0.236/trunk@52865 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 21:48:05 +00:00
norris%netscape.com
aebde57816 Improve performance of the non-error call code.
git-svn-id: svn://10.0.0.236/trunk@52862 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 21:23:10 +00:00
rpotts%netscape.com
fba1c662d5 bug #17500 (r=warren). Added code to fire an OnStopNotification to the parent load group if an active group is canceled.
git-svn-id: svn://10.0.0.236/trunk@52861 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 20:51:11 +00:00
selmer%netscape.com
a4236232dc Fixups
git-svn-id: svn://10.0.0.236/trunk@52858 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 19:18:33 +00:00
kin%netscape.com
81ed65e99b Temporary Fix for dogfood blocker bugs #18002 and #18006. With kipp's
permission, I backed out his fix for bug #1413 from
layout/html/base/src/nsContainerFrame.cpp revision 1.68.
Will re-check in kipp's fix after M11 is branched.
r=buster@netscape.com  a=chofmann


git-svn-id: svn://10.0.0.236/trunk@52857 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 17:42:21 +00:00
rjc%netscape.com
b4795254b6 Fix bug # 17675. Review: waterson. Approval: chofmann.
git-svn-id: svn://10.0.0.236/trunk@52852 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 09:28:42 +00:00
tbogard%aol.net
5fe04f058d Implemented so pretty straight forward pass through methods.
git-svn-id: svn://10.0.0.236/trunk@52851 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 09:07:57 +00:00
mscott%netscape.com
b5afeda640 (not part of the seamonkey build)
define and implement nsDocumentOpenInfo. Implement uri loader::OpenURI. This is the first pass at
my implementation it isn't complete and it doesn't use the registry for getting
 protocol handlers and content handlers yet...but it's a start


git-svn-id: svn://10.0.0.236/trunk@52849 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 06:01:40 +00:00
mscott%netscape.com
cddea4bf18 (not part of the seamonkey build)
include nsISupportsUtils.h


git-svn-id: svn://10.0.0.236/trunk@52848 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 06:01:05 +00:00
mscott%netscape.com
e1c9ba38b3 (not part of the seamonkey build!)
expanded OpenURI interface to take all the required arguments we need in order to really open the uri.
This includes adding the command, window target, event sink getter, load group and channel context.
Added dispatchContent method which is used by the doc open info's to talk back to the uri loader.
DispatchContent takes an opened channel and the uri content listener.


git-svn-id: svn://10.0.0.236/trunk@52847 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 06:00:36 +00:00
mscott%netscape.com
586a405369 (not part of the seamonkey build!)
doContent now returns a boolean called abortProcess. if the listener wants to handle the content without
 returning a stream listener, i.e. it wants the uri loader to stop doing anything else with this content,
then it returns true for abort process.


git-svn-id: svn://10.0.0.236/trunk@52846 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 05:59:42 +00:00
waterson%netscape.com
3aed471de6 Bug 18058. Remove 'commandDispatcher' from interface; obsolete, and leaky. r=hyatt, a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52844 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 05:31:15 +00:00
waterson%netscape.com
ca247c028b Bug 18058. Remove 'commandDispatcher' from interface; obsolete. r=hyatt, a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52843 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 05:30:56 +00:00
jefft%netscape.com
2b02c816a3 fixed bug 17928 - undo is not working for thread pane; this is the backend fix of the problem; creating TransactionManager in nsMsgWindow instead of in nsMessenger; r=bienvenu,a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52842 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 05:23:15 +00:00
brendan%mozilla.org
77646a1480 Remove nsIFrameReflow.h deadwood (r=waterson).
git-svn-id: svn://10.0.0.236/trunk@52841 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 05:00:39 +00:00
dougt%netscape.com
1cf333f618 Backing out changes due to nsCOMPtr build problems.
git-svn-id: svn://10.0.0.236/trunk@52840 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 03:32:33 +00:00
dougt%netscape.com
fced92a57e backing out changes. looks like this stuff is untested in a full build.
git-svn-id: svn://10.0.0.236/trunk@52839 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 03:31:04 +00:00
cls%seawood.org
dc0901d830 Fix for the template variable change from <T> to <nsISupports>. r=dougt
git-svn-id: svn://10.0.0.236/trunk@52838 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 03:11:03 +00:00
hangas%netscape.com
b0cc23dd32 Command updating and dispatching changes for menu items. Fixes 17848. r=hyatt, a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52837 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 02:21:47 +00:00
dougt%netscape.com
8d74ce705f Changed ownership module inside xpcom/proxy to remove cached objects passed their owner's lifespan.
Removed out of band callback in xpcom/proxy
Fixed webshell leak due to xpcom/proxy. (17009)
Just about everything is now a comptr, god save us. :-)

r=jband, a=brendan.


git-svn-id: svn://10.0.0.236/trunk@52836 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 02:21:46 +00:00
dougt%netscape.com
d73bc37e66 Fix for 17842. Make nsCOMPtr<nsISupports> should not be weak typed. scc's
this change to me and since he is on vacation until monday and I need this
for an M11 bug, I am checking it in.   I am hoping it is the right
thing to do.

a=brendan.


git-svn-id: svn://10.0.0.236/trunk@52835 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 02:18:46 +00:00
alecf%netscape.com
a92195a3a9 implement EnsureRowIsVisible for bug #17763
r=scottip


git-svn-id: svn://10.0.0.236/trunk@52834 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 02:02:09 +00:00
sspitzer%netscape.com
0fdb0ed03c fix warning and fix bug #18036, r=bienvenu, a=chofmann.
prevent the infinite loop when applying filters to mail if a filter
rule uses an arbitrary header.


git-svn-id: svn://10.0.0.236/trunk@52833 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 01:58:03 +00:00
mcafee%netscape.com
5478f9dda3 Switching to use NS_WITH_SERVICE macro as specified in (5403); removing spurious clipboard service instance in nsEditorEventListeners.cpp. r=akkana, a=chofmann.
git-svn-id: svn://10.0.0.236/trunk@52832 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 01:29:49 +00:00
sdagley%netscape.com
e6b6878f91 Fix to larryh's earlier checkin to implement bug #17558. Previous fix from bad diff would always result in an error trying to create a file that already existed (should only be an error in certain cases). r=sfraser
git-svn-id: svn://10.0.0.236/trunk@52831 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 01:18:07 +00:00
waterson%netscape.com
808d64da48 Fix leak with nsCOMPtr. r=brendan, a=brendan
git-svn-id: svn://10.0.0.236/trunk@52830 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 00:52:23 +00:00
selmer%netscape.com
45c7e5cf11 Tweak prior checkin a little
git-svn-id: svn://10.0.0.236/trunk@52829 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 00:49:23 +00:00
jfrancis%netscape.com
6d48eccaa5 bug 17744; a=choffman; r=floppy moose
git-svn-id: svn://10.0.0.236/trunk@52828 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 00:46:06 +00:00
waterson%netscape.com
7335ede542 Fix leak with nsCOMPtr. r=brendan, a=brendan
git-svn-id: svn://10.0.0.236/trunk@52827 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 00:44:10 +00:00
selmer%netscape.com
c9b01acbd6 Fixups to generatelist & related handling of listbox type widgets
git-svn-id: svn://10.0.0.236/trunk@52826 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 00:36:17 +00:00
matt%netscape.com
34a8cb4799 fix for bug 18042 by adding close window tag r=mcafee
git-svn-id: svn://10.0.0.236/trunk@52825 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 00:34:48 +00:00
larryh%netscape.com
1f62cd6fa3 BugZilla 17558. PR_Open() gets PR_EXCL flag
git-svn-id: svn://10.0.0.236/trunk@52824 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 00:21:39 +00:00
despotdaemon%netscape.com
3189ded990 Pseudo-automatic update of changes made by vishy@netscape.com.
git-svn-id: svn://10.0.0.236/trunk@52823 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-05 00:09:17 +00:00
pollmann%netscape.com
b98eecf039 Bug 17431: Clean house in form and form control destructors to allow reframing r=harishd a=choffman
git-svn-id: svn://10.0.0.236/trunk@52822 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 23:16:47 +00:00
sfraser%netscape.com
d76ff386a5 Fixes for 16723 -- fix error returns from imglib. Remove and re-add files to project to fix the case of the filenames. r=pnunn, a=chofmann.
git-svn-id: svn://10.0.0.236/trunk@52820 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 23:11:48 +00:00
sfraser%netscape.com
c0ec1f713e Fixes for 16723 -- fix error returns from imglib. r=pnunn, a=chofmann.
git-svn-id: svn://10.0.0.236/trunk@52819 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 23:11:11 +00:00
sfraser%netscape.com
1fcc54491d Fixes for 16723 -- fix error handling so that errors from image allocation are propogated back to imglib.. r=pnunn, a=chofmann.
git-svn-id: svn://10.0.0.236/trunk@52818 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 22:47:24 +00:00
rods%netscape.com
e34b01ce89 Commented out the reset of the list when an option gets added
Fixes crashers 17836, 17852, 17965 r=kmcclusk


git-svn-id: svn://10.0.0.236/trunk@52817 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 22:45:10 +00:00
mcafee%netscape.com
451b1f9771 Fixing JS error when loading prefs; skipping assertion in nsPrefWindow::ChangePanel() that is not needed for prefs to function, left a comment there so we can fix that later. (14663) a=matt, r=chofmann.
git-svn-id: svn://10.0.0.236/trunk@52816 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 22:39:21 +00:00
sfraser%netscape.com
b5daf46f31 Fixes for 18029 and 16723 -- fix image drawing on Mac to use GWorlds, and put in api to lock and unlock pixels. Pass a real nsDrawingSurface to the image, instead oif a cast GrafPtr. r=pnunn, a=chofmann.
git-svn-id: svn://10.0.0.236/trunk@52815 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 22:36:21 +00:00
sfraser%netscape.com
db24ddd87b Fixes for 18029 and 16723 -- fix image drawing on Mac to use GWorlds, and put in api to lock and unlock pixels. r=pnunn, a=chofmann.
git-svn-id: svn://10.0.0.236/trunk@52814 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 22:32:22 +00:00
sfraser%netscape.com
28261a4ca0 Fixes for 18029 and 16723 -- fix image drawing on Mac to use GWorlds, and put in api to lock and unlock pixels. Leave more free space in the heap for image (GWorld) pixels. r=pnunn, a=chofmann.
git-svn-id: svn://10.0.0.236/trunk@52813 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 22:29:02 +00:00
sfraser%netscape.com
2d10f84704 Fixes for 18029 and 16723 -- fix image drawing on Mac to use GWorlds, and put in api to lock and unlock pixels. Adding new error module for libimg. r=pnunn, a=chofmann.
git-svn-id: svn://10.0.0.236/trunk@52812 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 22:27:36 +00:00
sfraser%netscape.com
1cf929984f Fixes for 18029 and 16723 -- fix image drawing on Mac to use GWorlds, and put in api to lock and unlock pixels. r=pnunn, a=chofmann.
git-svn-id: svn://10.0.0.236/trunk@52811 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 22:26:57 +00:00
nisheeth%netscape.com
59271d7e21 r=norris,warren,radha. a=chofmann. Fix for bug 1646. Javascript: URLS were not getting loaded properly because the webshell was changing its notion of the current document (by setting mURL and mReferrer) too eagerly. Now, it does so only after the nsDocLoader::LoadDocument() in DoLoadURL() returns successfully.
git-svn-id: svn://10.0.0.236/trunk@52809 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 22:09:46 +00:00
pinkerton%netscape.com
7f537da550 add "status" area to the bottom so that bottom scroll arrow on MacOS is visible (r=slamm, bug# 8266).
git-svn-id: svn://10.0.0.236/trunk@52808 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 22:04:17 +00:00
nisheeth%netscape.com
45eec85b6b r=norris,warren,radha. a=chofmann. Fix for 1646. Javascript: urls return NS_ERROR_DOM_RETVAL_UNDEFINED when the javascript: url evaluates into an undefined value. This error is propagated back up to nsWebShell::DoLoadURL().
git-svn-id: svn://10.0.0.236/trunk@52807 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 22:02:19 +00:00
varada%netscape.com
027697488c updating accountsetup.ini to deal with workspace
git-svn-id: svn://10.0.0.236/trunk@52805 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 21:48:32 +00:00
varada%netscape.com
fee0b89b42 updating makefile to create the WSTemplate
git-svn-id: svn://10.0.0.236/trunk@52804 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 21:47:27 +00:00
sfraser%netscape.com
df972eb658 Did a 'Remove object code and compact' on this project, and tidied up some access paths to try to eliminate the CodeWarrior hangs. a=leaf
git-svn-id: svn://10.0.0.236/trunk@52802 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 21:16:02 +00:00
valeski%netscape.com
8cf0748300 10736, r=andreas.otte@primus-online.de. Actually I'm more like the reviewer here. Andreas submitted this optimization to MakeAbsolute (it uses minimal memory routines and minimal parsing. this means performance increase by a factor of 10 for this method). I'm checking it in for him.
git-svn-id: svn://10.0.0.236/trunk@52800 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 20:31:36 +00:00
neeti%netscape.com
1fe4d7149a fix for MLK bug 15818, every ImageURLImpl leaks.r=pnunn, a=chofmann.
git-svn-id: svn://10.0.0.236/trunk@52799 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 20:24:25 +00:00
selmer%netscape.com
81e77a0f71 Dynamic component checkbox initialization
git-svn-id: svn://10.0.0.236/trunk@52798 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 20:19:27 +00:00
sspitzer%netscape.com
aa210a0654 better fix for #17597, r=mscott, a=chofmann.
instead of setting the action for the url, check if we have a channel listener.
this is a cleaner fix, and now the quoting back end doesn't need to know about
the nntp url.


git-svn-id: svn://10.0.0.236/trunk@52796 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 20:02:31 +00:00
jefft%netscape.com
f295b6af47 fixed bug 15069 && 12345 -- passing in file:/// instead of file:// as the file url spec; r=bienvenu, a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52795 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 19:47:21 +00:00
waterson%netscape.com
487d4b32af Bug 17953, 17959. Fix nsXULElement leaks by using nsCOMPtrs. r=warren, a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52794 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 19:44:38 +00:00
waterson%netscape.com
9530e8d060 Bug 17955. Don't unnecessarily add script event listeners to temporary nodes used for overlay hookup. r=hyatt, a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52793 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 19:43:43 +00:00
putterman%netscape.com
8b6bdd6f64 Fix for 17987. Approved by chofmann and reviewed by hangas.
git-svn-id: svn://10.0.0.236/trunk@52792 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 19:38:11 +00:00
kipp%netscape.com
b20b0d0a0e r=vidur; bug=17372; found a case where a trailing shy character on a line would trigger an infinite loop iff the shy character was the only piece of text after a text frame had been continued
git-svn-id: svn://10.0.0.236/trunk@52791 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 19:34:36 +00:00
waterson%netscape.com
143a89ffc8 Bug 17847. Fix 'commandupdater' hookup for master document. r=hyatt, a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52790 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 18:37:58 +00:00
jefft%netscape.com
d7f7734495 fixed bug 17925 -- pop3 get all message again; restore old behavior; always set leave message on server; r=rhp, a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52786 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 15:27:29 +00:00
rhp%netscape.com
2bd2bc6f06 Changes for String Bundle problem in forwarding - Bug #: 12345 - r: jefft - approved: chofmann
git-svn-id: svn://10.0.0.236/trunk@52785 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 13:59:26 +00:00
waterson%netscape.com
8c5481dd42 Bug 11501. Tree has regressed s.t. it is necessary to have a <treecol>; add it here. r=hyatt, a=jack
git-svn-id: svn://10.0.0.236/trunk@52784 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 08:57:52 +00:00
waterson%netscape.com
9f071c70b6 Bug 17946. Trees must be contained within a fixed div. r=hyatt, a=jack
git-svn-id: svn://10.0.0.236/trunk@52783 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 08:33:08 +00:00
sgehani%netscape.com
9c16ff2bfc No longer delete core file if it existed before running the installer: now only deleted if downloaded. Also, cleaned up the terminal window UI.
Only affects the standalone Install Wizard app, not the browser or mail.

[r=ssu, a=chofmann]


git-svn-id: svn://10.0.0.236/trunk@52782 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 08:23:55 +00:00
jefft%netscape.com
7ff57f52b5 partial fix for bug 12345 - unable to forward message; check for valid url before calling msg_pick_real_name() to prevent crashing; r=rhp, a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52781 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 06:25:36 +00:00
beard%netscape.com
7670b1d344 moved System.exit() to end of main.
git-svn-id: svn://10.0.0.236/trunk@52780 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 06:15:55 +00:00
beard%netscape.com
a669c996d6 moved System.exit() to end of main
git-svn-id: svn://10.0.0.236/trunk@52779 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 06:07:35 +00:00
beard%netscape.com
a297c877e2 JShell properties files.
git-svn-id: svn://10.0.0.236/trunk@52778 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 06:06:40 +00:00
beard%netscape.com
09e0a51db2 factored out common code to locate a source file on lxr or bonsai
git-svn-id: svn://10.0.0.236/trunk@52777 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 06:06:13 +00:00
beard%netscape.com
881e796d98 communicates with cvsblame.cgi to assign blame to lines of a source file.
git-svn-id: svn://10.0.0.236/trunk@52776 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 06:05:52 +00:00
troy%netscape.com
66ca226b8a b=#17315. Changed DeletingFrameSubtree() to also look at the continuing
frames.


git-svn-id: svn://10.0.0.236/trunk@52775 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 05:23:11 +00:00
ducarroz%netscape.com
d3ee736373 Fix for bug 17902. Fix various FCC problems as well error display. R=alecf, A=chofmann
git-svn-id: svn://10.0.0.236/trunk@52774 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 04:58:06 +00:00
sspitzer%netscape.com
baf56f68cb fix for #17597. reply to a news article doesn't quote the body.
the problem was when we ran the nntp url to get the message we weren't
calling OnDataAvailabe() on the channel listener.  the reason is the channel
listener only got poked when ActionDisplayArticle was set as the action on
the nntp url.  but this wouldn't be the case when we got run from the Quoting backend.  I added a new action, and made sure to set it when running the url from the quoting back end, and then made sure the nntp backend did the right thing.

r=alecf, a=chofmann


git-svn-id: svn://10.0.0.236/trunk@52773 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 04:31:09 +00:00
jj%netscape.com
f66e87957c set installer target directory to "Mozilla Folder" and changed "bin" to "viewer" to reflect the Mac tree structure.
git-svn-id: svn://10.0.0.236/trunk@52771 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 03:01:29 +00:00
jj%netscape.com
2efb8c65ad . moved 'Component Registry' from [browser] to [install]
. removed 'default_prefs.js' and 'chrome:registry.rdf'
. added 'viewer:' in front of _each_ line (parser root change)


git-svn-id: svn://10.0.0.236/trunk@52770 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 03:01:25 +00:00
jj%netscape.com
498764afb0 fixed components lists for [Easy install] and variable names for module sizes.
git-svn-id: svn://10.0.0.236/trunk@52769 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 03:01:24 +00:00
beard%netscape.com
48f9184ff1 bug #17847, fix clobbering of mSlots->mAttributes in GetAttributes(). r=waterson, a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52768 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 02:56:54 +00:00
slamm%netscape.com
a8fb89cee4 Do run-length encoding for the raw data option. End revision records with a period. Buffer the raw data output.
git-svn-id: svn://10.0.0.236/trunk@52767 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 02:14:56 +00:00
hyatt%netscape.com
4353fd2505 Partial fix for 17848. Part 1 of 2. 2nd part will be checked in by hangas. r=hangas, a=brendan
git-svn-id: svn://10.0.0.236/trunk@52766 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 01:59:04 +00:00
waterson%netscape.com
9d4795faed Bug 17024. Fix mClassList leak; add bloaty stats for nsClassList. r=hyatt a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52765 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 01:50:47 +00:00
waterson%netscape.com
a65db3660c Bug 15146. Don't eagerly create a <xul:menu>'s contents. r=hyatt a=brendan
git-svn-id: svn://10.0.0.236/trunk@52764 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 01:49:34 +00:00
waterson%netscape.com
744719ecdb Bug 15146. Fix charset overlay template; don't force menus to be open; r=hyatt a=brendan
git-svn-id: svn://10.0.0.236/trunk@52763 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 01:48:46 +00:00
mccabe%netscape.com
46ecd1ff3b Link fixes. Not part of the Mozilla build.
git-svn-id: svn://10.0.0.236/trunk@52762 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 00:35:31 +00:00
beard%netscape.com
396d175b3c can handle multiple inputs, now using common FileLocator class to generate blame/lxr URLs.
git-svn-id: svn://10.0.0.236/trunk@52761 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 00:24:26 +00:00
beard%netscape.com
9cc1992ed4 Uses CVS/Entries to determine the revision of a checked out file.
git-svn-id: svn://10.0.0.236/trunk@52760 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 00:10:12 +00:00
pinkerton%netscape.com
b2e6d58834 Fix bug 15276 by flushing the data to the clipboard right before app shuts down. (r=davidm).
git-svn-id: svn://10.0.0.236/trunk@52759 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 00:08:59 +00:00
rogerl%netscape.com
388bc22458 Removed - not an ECMA thing and supplanted by a different mechanism.
git-svn-id: svn://10.0.0.236/trunk@52758 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 00:01:00 +00:00
rogerl%netscape.com
859165ee97 Fix back-reference parsing from going too far in source string
git-svn-id: svn://10.0.0.236/trunk@52757 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-04 00:00:14 +00:00
rogerl%netscape.com
ec90446de8 Replaced Closure object with FunctionObject clone
git-svn-id: svn://10.0.0.236/trunk@52756 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 23:59:35 +00:00
rogerl%netscape.com
74b9419214 Removed NativeClosure
git-svn-id: svn://10.0.0.236/trunk@52755 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 23:58:51 +00:00
rogerl%netscape.com
830d037821 Fix nested finally endless loop.
Replaced Closure object with FunctionObject clone.


git-svn-id: svn://10.0.0.236/trunk@52754 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 23:57:56 +00:00
rogerl%netscape.com
ee745b4cbf Add closure support
git-svn-id: svn://10.0.0.236/trunk@52753 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 23:56:28 +00:00
rogerl%netscape.com
02ca74c760 Removing NativeClosure
git-svn-id: svn://10.0.0.236/trunk@52752 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 23:55:59 +00:00
mcafee%netscape.com
555440d16c ftp & http proxy settings got reversed in the UI (15165). r=slamm, a=chofmann.
git-svn-id: svn://10.0.0.236/trunk@52751 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 23:53:15 +00:00
nisheeth%netscape.com
e3cf2c3428 r=harishd, a=chofmann. Fix for bugs 11992, 10563. New lines get reported in the XML document prolog. Now, JS errors in XML report correct line numbers.
git-svn-id: svn://10.0.0.236/trunk@52750 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 23:50:16 +00:00
slamm%netscape.com
13a4379130 Add feature for beard and his leak soup tool. Return raw data if 'data=1' is added as a parameter. Cleaned up some code too.
git-svn-id: svn://10.0.0.236/trunk@52749 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 23:37:44 +00:00
mcafee%netscape.com
adc6cb1f75 We were using the wrong pref to enable JS (14660). r=slamm, a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52748 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 23:10:47 +00:00
hangas%netscape.com
99a452e913 Fix for bug 16189, which allows undo/redo to be used in the thread pane of mail/news. r-jefft a=chofmann
git-svn-id: svn://10.0.0.236/trunk@52746 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 23:03:12 +00:00
rogerl%netscape.com
aa1271a477 Not a part of SeaMonkey Build
- new LiveConnect AIX4.3 makefile for server builds


git-svn-id: svn://10.0.0.236/trunk@52745 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:55:03 +00:00
varada%netscape.com
5c09a71e2a getting rid of root variable in che file
git-svn-id: svn://10.0.0.236/trunk@52744 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:44:24 +00:00
rhp%netscape.com
8276a693be Fix for null pointer access - Bug #17597 - r: jefft - approved: chofmann
git-svn-id: svn://10.0.0.236/trunk@52743 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:35:04 +00:00
rhp%netscape.com
3f83ba7a62 Fix for null pointer access - Bug #17597 - r: jefft approved: chofmann
git-svn-id: svn://10.0.0.236/trunk@52742 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:34:30 +00:00
radha%netscape.com
8f70df6307 Fix for bug # 17893. Pass the url to nsISessionHistory::Add().Don't set
nsWebShell::mURL too early in the loading process.
r=law,nisheeth


git-svn-id: svn://10.0.0.236/trunk@52741 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:30:44 +00:00
varada%netscape.com
5908cc6076 getting rid of spaces in cck.ini
git-svn-id: svn://10.0.0.236/trunk@52740 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:27:29 +00:00
varada%netscape.com
777e334a14 getting rid of spaces in the inifiles and changing titles
git-svn-id: svn://10.0.0.236/trunk@52739 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:27:06 +00:00
varada%netscape.com
193096cba0 installing wizardmachine.ini inthe dist directory
git-svn-id: svn://10.0.0.236/trunk@52738 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:24:09 +00:00
varada%netscape.com
6663eb3602 This file will contain the nameof the application
git-svn-id: svn://10.0.0.236/trunk@52737 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:23:48 +00:00
varada%netscape.com
9d146034cd message box in interpret
git-svn-id: svn://10.0.0.236/trunk@52736 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:22:54 +00:00
varada%netscape.com
c2f62d838f getting rid of root variable from the che files
git-svn-id: svn://10.0.0.236/trunk@52735 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:22:31 +00:00
rods%netscape.com
c7fa28614d added two more tests
git-svn-id: svn://10.0.0.236/trunk@52734 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:14:42 +00:00
rods%netscape.com
17f32ce4ba Initial checkin of test
git-svn-id: svn://10.0.0.236/trunk@52733 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:14:25 +00:00
kipp%netscape.com
8fae81516b r=joki; fixed the ancient and venerable bug 1413 by noting that the code was using an optimization that wasn't always valid and that one that optimization wasn't valid, the slower path must be used...I commented the fix fairly solidly
git-svn-id: svn://10.0.0.236/trunk@52732 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:09:00 +00:00
akkana%netscape.com
7e907a0c91 Fix key event bustage: treat DOM_VK_RETURN and DOM_VK_ENTER equivalently. r=ftang,joki a=chofmann,leaf
git-svn-id: svn://10.0.0.236/trunk@52731 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 22:05:45 +00:00
kipp%netscape.com
44a7143485 updated document regardling block and line-layout operation; this is html documents that are not part of the build nor part of any install process, etc.
git-svn-id: svn://10.0.0.236/trunk@52730 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 21:11:37 +00:00
joki%netscape.com
68b221d555 Fixing dom event key set errors. bug 17887, a:chofmann
git-svn-id: svn://10.0.0.236/trunk@52729 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 20:53:13 +00:00
joki%netscape.com
e151377558 Reverting key set to previous version. Fixes 17887. a:chofmann r:brade.
git-svn-id: svn://10.0.0.236/trunk@52728 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 20:40:35 +00:00
endico%mozilla.org
0ee8ded981 fixed a bunch of typos. Also, handleCheckinMail.tc was replaced by handleCheckinMail.pl
git-svn-id: svn://10.0.0.236/trunk@52727 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 20:33:57 +00:00
blizzard%redhat.com
e72f94df90 patch to fix backspacing from quy@igelaus.com.au. a=choffman
git-svn-id: svn://10.0.0.236/trunk@52726 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 20:25:19 +00:00
alecf%netscape.com
b5de07e079 fix for blocker #17882
a=leaf


git-svn-id: svn://10.0.0.236/trunk@52723 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 19:47:17 +00:00
rogerl%netscape.com
9f777f2bad Added defn of AIX4_3 to help fix dup typedef int8,int16 etc
git-svn-id: svn://10.0.0.236/trunk@52720 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 18:56:17 +00:00
slamm%netscape.com
8fc0df1c8f Ignore a few more warnings caused by lame unix header files.
git-svn-id: svn://10.0.0.236/trunk@52719 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 18:52:13 +00:00
gagan%netscape.com
34d286f60f Last of the leftover files... that didn't include the API change.
git-svn-id: svn://10.0.0.236/trunk@52716 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 09:33:03 +00:00
gagan%netscape.com
8dc7bd557e Modified the call to match the new signature of CreateTransport. a=mcafee.
git-svn-id: svn://10.0.0.236/trunk@52715 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 08:52:04 +00:00
gagan%netscape.com
4ef759b3d4 Removed an extra free that cvs merge put in!
git-svn-id: svn://10.0.0.236/trunk@52714 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 08:21:37 +00:00
gagan%netscape.com
cb1a2aee98 Argh... speed kills. Removed this conflict that I accidently checked in.
git-svn-id: svn://10.0.0.236/trunk@52713 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 08:19:54 +00:00
gagan%netscape.com
8f3ae7048a Fixes 11708,15477 and partial 14610. r=warren. We now pass a print host for displaying in status messages that is different than the hostname connecting to. Also added Keep-Alive support (turned on by user_pref("network.http.keep-alive",1))We also honor the "network.proxy.type" preference to turn the proxy use on and off.
git-svn-id: svn://10.0.0.236/trunk@52712 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 08:17:59 +00:00
gagan%netscape.com
4ac72526b1 Fixes 11708,15477 and partial 14610. r=warren. We now pass a print host for displaying in status messages that is different than the hostname connecting to. Also added Keep-Alive support (turned on by user_pref("network.http.keep-alive",1))
git-svn-id: svn://10.0.0.236/trunk@52711 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 08:14:38 +00:00
gagan%netscape.com
e67319abec *** empty log message ***
git-svn-id: svn://10.0.0.236/trunk@52710 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 08:12:18 +00:00
gagan%netscape.com
6bf9a22c91 Added printHost parameter for use in status messages in cases where printHost is different than the connecting host (as in the case of proxies) Fixes bug 11708. r=warren.
git-svn-id: svn://10.0.0.236/trunk@52709 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 08:11:39 +00:00
sgehani%netscape.com
60ed9bf4bb Removing obsolete prefix files. (Replaced by nsInstallerPrefix* and mozInstallerPrefix*.)
git-svn-id: svn://10.0.0.236/trunk@52708 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 08:06:59 +00:00
pavlov%netscape.com
0f628926da work on nsIWidget r=alecf
git-svn-id: svn://10.0.0.236/trunk@52707 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 08:04:59 +00:00
sgehani%netscape.com
ee85b8ad76 Chnage MIW target name to Mozilla Installer [r=sfraser].
git-svn-id: svn://10.0.0.236/trunk@52706 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:54:28 +00:00
sgehani%netscape.com
9d8269b689 1> Extraction of all files rather than regexp core_*/* search.
2> Prepare installer to work off of local archives for CD scenario and Mozilla (no sdinst.dll).                                    
3> Fix build warnings.                                                    
4> Separated out Netscape and Mozilla specific targets.    
5> Separated out Netscape and Mozilla specfic resources.
                                                                                      
[r=sfraser]


git-svn-id: svn://10.0.0.236/trunk@52705 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:53:59 +00:00
mscott%netscape.com
6ade5969e3 work around for Bug 17065
for bienvenu
r=mscott


git-svn-id: svn://10.0.0.236/trunk@52704 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:53:44 +00:00
mscott%netscape.com
7b3899b763 Some work arounds to HIDE Bug #17065 which causes us to hang when parsing large imap folders on linux.
WE still have the problme where the ui thread is stealing events from the imap thread and processing them
on the ui thread.

We're just working around it so folks can use linux imap mail. This code was jointly written with bienvenu.

r=bienvenu/mscott


git-svn-id: svn://10.0.0.236/trunk@52703 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:52:45 +00:00
sgehani%netscape.com
dd18053d33 First Checked In.
git-svn-id: svn://10.0.0.236/trunk@52702 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:50:01 +00:00
dveditz%netscape.com
3f4468adf1 fixes 8271,6410,12694 and similar startup/registry problems
git-svn-id: svn://10.0.0.236/trunk@52701 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:46:38 +00:00
dveditz%netscape.com
3330477d88 shutting up copious warnings using /W4 on MSVC
git-svn-id: svn://10.0.0.236/trunk@52700 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:39:19 +00:00
dveditz%netscape.com
acf32d6fc2 Changing registry keys to a mozilla-centric name rather than netscape.
git-svn-id: svn://10.0.0.236/trunk@52699 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:36:03 +00:00
pavlov%netscape.com
c5f9102c78 work on scrolling, CSS2 native system colors, etc. r=mcafee
git-svn-id: svn://10.0.0.236/trunk@52697 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:34:50 +00:00
alecf%netscape.com
cb89931340 add open="true" to all the account
r=scottip
no bug, it's cosmetic/usability thing


git-svn-id: svn://10.0.0.236/trunk@52696 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:33:08 +00:00
mccabe%netscape.com
793e09ae44 Fix many nsInterfaceInfo leaks, thanks in part to patches provided by Patrick Beard. Fixes 15855. Some remain.
Clear up build warnings, and quiet nsInterfaceInfomanager debug output unless DEBUG_iim.  Makes startup a li'l less noisy.  Fixes 15628.

r=jband


git-svn-id: svn://10.0.0.236/trunk@52695 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:23:37 +00:00
alecf%netscape.com
e92bd577aa fix for #17214 - consolidate all username and hostname handling so that escaping/unescaping happens logically
git-svn-id: svn://10.0.0.236/trunk@52694 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:16:59 +00:00
joki%netscape.com
c6ca4a722e added files: mozilla/dom/src/events/nsJSKeyEvent.cpp
git-svn-id: svn://10.0.0.236/trunk@52693 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-03 07:12:13 +00:00
94 changed files with 105 additions and 22812 deletions

View File

@@ -1,129 +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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
/******
This file contains the list of all XUL nsIAtoms and their values
It is designed to be used as inline input to nsXULAtoms.cpp *only*
through the magic of C preprocessing.
All entires must be enclosed in the macro XUL_ATOM which will have cruel
and unusual things done to it
It is recommended (but not strictly necessary) to keep all entries
in alphabetical order
The first argument to XUL_ATOM is the C++ identifier of the atom
The second argument is the string value of the atom
******/
XUL_ATOM(button, "button")
XUL_ATOM(spinner, "spinner")
XUL_ATOM(scrollbar, "scrollbar")
XUL_ATOM(slider, "slider")
XUL_ATOM(colorpicker, "colorpicker")
XUL_ATOM(palettename, "palettename")
XUL_ATOM(fontpicker, "fontpicker")
XUL_ATOM(radio, "radio")
XUL_ATOM(text, "text")
XUL_ATOM(toolbar, "toolbar")
XUL_ATOM(toolbaritem, "toolbaritem")
XUL_ATOM(toolbox, "toolbox")
// The tree atoms
XUL_ATOM(tree, "tree") // The start of a tree view
XUL_ATOM(treecaption, "treecaption") // The caption of a tree view
XUL_ATOM(treehead, "treehead") // The header of the tree view
XUL_ATOM(treerow, "treerow") // A row in the tree view
XUL_ATOM(treecell, "treecell") // An item in the tree view
XUL_ATOM(treeitem, "treeitem") // A cell in the tree view
XUL_ATOM(treechildren, "treechildren") // The children of an item in the tree view
XUL_ATOM(treeindentation, "treeindentation") // Specifies that the indentation for the level should occur here.
XUL_ATOM(allowevents, "allowevents") // Lets events be handled on the cell contents or in menus.
XUL_ATOM(treecol, "treecol") // A column in the tree view
XUL_ATOM(treecolgroup, "treecolgroup") // A column group in the tree view
XUL_ATOM(treefoot, "treefoot") // The footer of the tree view
XUL_ATOM(treepusher, "treepusher") // A column pusher (left or right) for the tree view
XUL_ATOM(scrollbarlist, "scrollbarlist") // An atom for internal use by the tree view
XUL_ATOM(open, "open") // Whether or not a menu, tree, etc. is open
XUL_ATOM(menubar, "menubar") // An XP menu bar.
XUL_ATOM(menu, "menu") // Represents an XP menu
XUL_ATOM(menuitem, "menuitem") // Represents an XP menu item
XUL_ATOM(menupopup, "menupopup") // The XP menu's children.
XUL_ATOM(menuactive, "menuactive") // Whether or not a menu is active (without necessarily being open)
XUL_ATOM(accesskey, "accesskey") // The shortcut key for a menu or menu item
XUL_ATOM(acceltext, "acceltext") // Text to use for the accelerator
XUL_ATOM(popupset, "popupset") // Contains popup menus, context menus, and tooltips
XUL_ATOM(popup, "popup") // The popup for a context menu, popup menu, or tooltip
XUL_ATOM(menugenerated, "menugenerated") // Internal
XUL_ATOM(key, "key") // A key element
XUL_ATOM(broadcaster, "broadcaster") // A broadcaster
XUL_ATOM(observes, "observes") // The observes element
XUL_ATOM(templateAtom, "template") // A XUL template
XUL_ATOM(progressmeter, "progressmeter")
XUL_ATOM(titledbutton, "titledbutton")
XUL_ATOM(crop, "crop")
XUL_ATOM(mode, "mode")
XUL_ATOM(box, "box")
XUL_ATOM(flex, "flex")
XUL_ATOM(spring, "spring")
XUL_ATOM(deck, "deck")
XUL_ATOM(tabcontrol, "tabcontrol")
XUL_ATOM(tab, "tab")
XUL_ATOM(tabpanel, "tabpanel")
XUL_ATOM(tabpage, "tabpage")
XUL_ATOM(tabbox, "tabbox")
XUL_ATOM(index, "index")
XUL_ATOM(maxpos, "maxpos")
XUL_ATOM(curpos, "curpos")
XUL_ATOM(scrollbarbutton, "scrollbarbutton")
XUL_ATOM(increment, "increment")
XUL_ATOM(pageincrement, "pageincrement")
XUL_ATOM(thumb, "thumb")
XUL_ATOM(toggled, "toggled")
XUL_ATOM(grippy, "grippy")
XUL_ATOM(splitter, "splitter")
XUL_ATOM(collapse, "collapse")
XUL_ATOM(resizebefore, "resizebefore")
XUL_ATOM(resizeafter, "resizeafter")
XUL_ATOM(state, "state")
// toolbar & toolbar d&d atoms
XUL_ATOM(tbDropLocation, "tb-droplocation")
XUL_ATOM(tbDropLocationCoord, "tb-droplocationcoord")
XUL_ATOM(tbDropOn, "tb-dropon")
XUL_ATOM(tbTriggerRepaint, "tb-triggerrepaint")
XUL_ATOM(container, "container")
XUL_ATOM(widget, "widget")
XUL_ATOM(window, "window")
XUL_ATOM(iframe, "iframe")
XUL_ATOM(browser, "browser")
XUL_ATOM(editor, "editor")

View File

@@ -1,54 +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 nsXULAtoms_h___
#define nsXULAtoms_h___
#include "prtypes.h"
#include "nsIAtom.h"
class nsINameSpaceManager;
/**
* This class wraps up the creation and destruction of the standard
* set of xul atoms used during normal xul handling. This object
* is created when the first xul content object is created, and
* destroyed when the last such content object is destroyed.
*/
class nsXULAtoms {
public:
static void AddRefAtoms();
static void ReleaseAtoms();
// XUL namespace ID, good for the life of the nsXULAtoms object
static PRInt32 nameSpaceID;
/* Declare all atoms
The atom names and values are stored in nsCSSAtomList.h and
are brought to you by the magic of C preprocessing
Add new atoms to nsCSSAtomList and all support logic will be auto-generated
*/
#define XUL_ATOM(_name, _value) static nsIAtom* _name;
#include "nsXULAtomList.h"
#undef XUL_ATOM
};
#endif /* nsXULAtoms_h___ */

View File

@@ -1,68 +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 "nsString.h"
#include "nsINameSpaceManager.h"
#include "nsXULAtoms.h"
static const char kXULNameSpace[] = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
PRInt32 nsXULAtoms::nameSpaceID;
// define storage for all atoms
#define XUL_ATOM(_name, _value) nsIAtom* nsXULAtoms::_name;
#include "nsXULAtomList.h"
#undef XUL_ATOM
static nsrefcnt gRefCnt = 0;
static nsINameSpaceManager* gNameSpaceManager;
void nsXULAtoms::AddRefAtoms() {
if (gRefCnt == 0) {
/* XUL Atoms registers the XUL name space ID because it's a convenient
place to do this, if you don't want a permanent, "well-known" ID.
*/
if (NS_SUCCEEDED(NS_NewNameSpaceManager(&gNameSpaceManager))) {
// gNameSpaceManager->CreateRootNameSpace(namespace);
nsAutoString nameSpace(kXULNameSpace);
gNameSpaceManager->RegisterNameSpace(nameSpace, nameSpaceID);
} else {
NS_ASSERTION(0, "failed to create xul atoms namespace manager");
}
// now register the atoms
#define XUL_ATOM(_name, _value) _name = NS_NewAtom(_value);
#include "nsXULAtomList.h"
#undef XUL_ATOM
}
++gRefCnt;
}
void nsXULAtoms::ReleaseAtoms() {
NS_PRECONDITION(gRefCnt != 0, "bad release of xul atoms");
if (--gRefCnt == 0) {
#define XUL_ATOM(_name, _value) NS_RELEASE(_name);
#include "nsXULAtomList.h"
#undef XUL_ATOM
NS_IF_RELEASE(gNameSpaceManager);
}
}

View File

@@ -0,0 +1,105 @@
/*
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#ifndef __JavaDOMGlobals_h__
#define __JavaDOMGlobals_h__
#include "jni.h"
#include "prclist.h"
#include "nsError.h"
#ifdef ERROR
#undef ERROR
#endif
class nsISupports;
class nsIDOMNode;
struct PRLogModuleInfo;
struct PRLock;
class JavaDOMGlobals {
public:
static jclass attrClass;
static jclass cDataSectionClass;
static jclass commentClass;
static jclass documentClass;
static jclass documentFragmentClass;
static jclass documentTypeClass;
static jclass domImplementationClass;
static jclass elementClass;
static jclass entityClass;
static jclass entityReferenceClass;
static jclass namedNodeMapClass;
static jclass nodeClass;
static jclass nodeListClass;
static jclass notationClass;
static jclass processingInstructionClass;
static jclass textClass;
static jfieldID nodePtrFID;
static jfieldID nodeListPtrFID;
static jfieldID domImplementationPtrFID;
static jfieldID nodeTypeAttributeFID;
static jfieldID nodeTypeCDataSectionFID;
static jfieldID nodeTypeCommentFID;
static jfieldID nodeTypeDocumentFragmentFID;
static jfieldID nodeTypeDocumentFID;
static jfieldID nodeTypeDocumentTypeFID;
static jfieldID nodeTypeElementFID;
static jfieldID nodeTypeEntityFID;
static jfieldID nodeTypeEntityReferenceFID;
static jfieldID nodeTypeNotationFID;
static jfieldID nodeTypeProcessingInstructionFID;
static jfieldID nodeTypeTextFID;
static jclass domExceptionClass;
static jmethodID domExceptionInitMID;
static jclass runtimeExceptionClass;
static jmethodID runtimeExceptionInitMID;
static const char* const DOM_EXCEPTION_MESSAGE[];
typedef enum ExceptionType { EXCEPTION_RUNTIME,
EXCEPTION_DOM } ExceptionType;
static PRLogModuleInfo* log;
static PRCList garbage;
static PRLock* garbageLock;
static PRInt32 javaMaxInt;
static void Initialize(JNIEnv *env);
static void Destroy(JNIEnv *env);
static jobject CreateNodeSubtype(JNIEnv *env,
nsIDOMNode *node);
static void AddToGarbage(nsISupports* domObject);
static void TakeOutGarbage();
static void ThrowException(JNIEnv *env,
const char * message = NULL,
nsresult rv = NS_OK,
ExceptionType exceptionType = EXCEPTION_RUNTIME);
};
#endif /* __JavaDOMGlobals_h__ */

View File

@@ -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 = content base
include $(topsrcdir)/config/rules.mk

View File

@@ -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

View File

@@ -1,22 +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 src
include <$(DEPTH)\config\rules.mak>

View File

@@ -1,31 +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
MODULE = layout
EXPORTS = nsIPopupSetFrame.h
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk

View File

@@ -1,2 +0,0 @@
nsIPopupSetFrame.h

View File

@@ -1,26 +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=..\..\..\..
EXPORTS = \
nsIPopupSetFrame.h \
$(NULL)
MODULE=raptor
include <$(DEPTH)\config\rules.mak>

View File

@@ -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.0 (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 Communicator client 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.
*/
#ifndef nsIMenuParent_h___
#define nsIMenuParent_h___
// {D407BF61-3EFA-11d3-97FA-00400553EEF0}
#define NS_IMENUPARENT_IID \
{ 0xd407bf61, 0x3efa, 0x11d3, { 0x97, 0xfa, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
class nsIMenuFrame;
class nsIMenuParent : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IMENUPARENT_IID; return iid; }
NS_IMETHOD SetCurrentMenuItem(nsIMenuFrame* aMenuItem) = 0;
NS_IMETHOD GetNextMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult) = 0;
NS_IMETHOD GetPreviousMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult) = 0;
NS_IMETHOD SetActive(PRBool aActiveFlag) = 0;
NS_IMETHOD GetIsActive(PRBool& isActive) = 0;
NS_IMETHOD GetWidget(nsIWidget **aWidget) = 0;
NS_IMETHOD IsMenuBar(PRBool& isMenuBar) = 0;
NS_IMETHOD DismissChain() = 0;
NS_IMETHOD HideChain() = 0;
NS_IMETHOD CreateDismissalListener() = 0;
};
#endif

View File

@@ -1,47 +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 "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 Communicator client 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.
*/
#ifndef nsIPopupSetFrame_h___
#define nsIPopupSetFrame_h___
// {E2D804A1-50CA-11d3-BF87-00105A1B0627}
#define NS_IPOPUPSETFRAME_IID \
{ 0xe2d804a1, 0x50ca, 0x11d3, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
class nsIFrame;
class nsIContent;
#include "nsString.h"
class nsIPopupSetFrame : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IPOPUPSETFRAME_IID; return iid; }
NS_IMETHOD CreatePopup(nsIFrame* aElementFrame, nsIContent* aPopupContent,
PRInt32 aXPos, PRInt32 aYPos,
const nsString& aPopupType, const nsString& anAnchorAlignment,
const nsString& aPopupAlignment) = 0;
NS_IMETHOD HidePopup() = 0;
NS_IMETHOD DestroyPopup() = 0;
};
#endif

View File

@@ -1,85 +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
MODULE = layout
LIBRARY_NAME = raptorxulbase_s
CPPSRCS = \
nsFrameNavigator.cpp \
nsSplitterFrame.cpp \
nsGrippyFrame.cpp \
nsTabFrame.cpp \
nsDeckFrame.cpp \
nsBoxFrame.cpp \
nsProgressMeterFrame.cpp \
nsTitledButtonFrame.cpp \
nsToolbarFrame.cpp \
nsToolbarDragListener.cpp \
nsToolboxFrame.cpp \
nsTreeOuterFrame.cpp \
nsTreeFrame.cpp \
nsTreeRowGroupFrame.cpp \
nsTreeIndentationFrame.cpp \
nsTreeCellFrame.cpp \
nsTreeRowFrame.cpp \
nsTreeTwistyListener.cpp \
nsSpinnerFrame.cpp \
nsScrollbarFrame.cpp \
nsScrollbarButtonFrame.cpp \
nsSliderFrame.cpp \
nsColorPickerFrame.cpp \
nsStdColorPicker.cpp \
nsFontPickerFrame.cpp \
nsToolbarItemFrame.cpp \
nsMenuPopupFrame.cpp \
nsMenuFrame.cpp \
nsMenuBarFrame.cpp \
nsMenuBarListener.cpp \
nsMenuDismissalListener.cpp \
nsPopupSetFrame.cpp \
nsRepeatService.cpp \
$(NULL)
include $(topsrcdir)/config/config.mk
# we don't want the shared lib, but we want to force the creation of a static lib.
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk
DEFINES += -D_IMPL_NS_HTML
LOCAL_INCLUDES = \
-I$(srcdir)/../../../base/src \
-I$(srcdir)/../../../html/table/src \
-I$(srcdir)/../../../html/style/src \
-I$(srcdir)/../../../html/base/src \
-I$(srcdir)/../../../html/forms/src \
-I$(srcdir)/../../content/src \
-I$(srcdir)/../../../html/content/src \
-I$(srcdir)/../../../xml/content/src \
-I$(srcdir)/../../../base/public \
$(NULL)

View File

@@ -1,123 +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=..\..\..\..
LIBRARY_NAME=raptorxulbase_s
MODULE=raptor
REQUIRES=xpcom raptor pref
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
CPPSRCS= \
nsFrameNavigator.cpp \
nsRepeatService.cpp \
nsToolbarDragListener.cpp \
nsToolbarItemFrame.cpp \
nsSplitterFrame.cpp \
nsGrippyFrame.cpp \
nsTabFrame.cpp \
nsDeckFrame.cpp \
nsBoxFrame.cpp \
nsProgressMeterFrame.cpp \
nsTitledButtonFrame.cpp \
nsToolboxFrame.cpp \
nsToolbarFrame.cpp \
nsTreeOuterFrame.cpp \
nsTreeFrame.cpp \
nsTreeRowGroupFrame.cpp \
nsTreeRowFrame.cpp \
nsTreeIndentationFrame.cpp \
nsTreeCellFrame.cpp \
nsTreeTwistyListener.cpp \
nsSpinnerFrame.cpp \
nsScrollbarFrame.cpp \
nsScrollbarButtonFrame.cpp \
nsSliderFrame.cpp \
nsColorPickerFrame.cpp \
nsStdColorPicker.cpp \
nsFontPickerFrame.cpp \
nsMenuPopupFrame.cpp \
nsMenuFrame.cpp \
nsMenuBarFrame.cpp \
nsMenuBarListener.cpp \
nsMenuDismissalListener.cpp \
nsPopupSetFrame.cpp \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\nsFrameNavigator.obj \
.\$(OBJDIR)\nsRepeatService.obj \
.\$(OBJDIR)\nsToolbarDragListener.obj \
.\$(OBJDIR)\nsToolbarItemFrame.obj \
.\$(OBJDIR)\nsGrippyFrame.obj \
.\$(OBJDIR)\nsSplitterFrame.obj \
.\$(OBJDIR)\nsTabFrame.obj \
.\$(OBJDIR)\nsDeckFrame.obj \
.\$(OBJDIR)\nsBoxFrame.obj \
.\$(OBJDIR)\nsProgressMeterFrame.obj \
.\$(OBJDIR)\nsTitledButtonFrame.obj \
.\$(OBJDIR)\nsToolboxFrame.obj \
.\$(OBJDIR)\nsToolbarFrame.obj \
.\$(OBJDIR)\nsTreeOuterFrame.obj \
.\$(OBJDIR)\nsTreeFrame.obj \
.\$(OBJDIR)\nsTreeRowFrame.obj \
.\$(OBJDIR)\nsTreeRowGroupFrame.obj \
.\$(OBJDIR)\nsTreeIndentationFrame.obj \
.\$(OBJDIR)\nsTreeCellFrame.obj \
.\$(OBJDIR)\nsTreeTwistyListener.obj \
.\$(OBJDIR)\nsSpinnerFrame.obj \
.\$(OBJDIR)\nsScrollbarFrame.obj \
.\$(OBJDIR)\nsScrollbarButtonFrame.obj \
.\$(OBJDIR)\nsSliderFrame.obj \
.\$(OBJDIR)\nsColorPickerFrame.obj \
.\$(OBJDIR)\nsStdColorPicker.obj \
.\$(OBJDIR)\nsFontPickerFrame.obj \
.\$(OBJDIR)\nsMenuPopupFrame.obj \
.\$(OBJDIR)\nsMenuFrame.obj \
.\$(OBJDIR)\nsMenuBarFrame.obj \
.\$(OBJDIR)\nsMenuBarListener.obj \
.\$(OBJDIR)\nsMenuDismissalListener.obj \
.\$(OBJDIR)\nsPopupSetFrame.obj \
$(NULL)
EXPORTS = \
$(NULL)
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
-I..\..\..\html\style\src -I..\..\..\html\base\src -I$(PUBLIC)\dom \
-I..\..\..\html\document\src \
-I..\..\..\html\content\src \
-I..\..\..\html\table\src \
-I..\..\content\src \
-I..\..\..\html\forms\src \
-I$(PUBLIC)\netlib -I..\..\..\base\src -I$(PUBLIC)\pref \
-I..\..\..\xml\content\src \
-I..\..\..\base\public
LCFLAGS = \
$(LCFLAGS) \
$(DEFINES) \
$(NULL)
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib

File diff suppressed because it is too large Load Diff

View File

@@ -1,196 +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 "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 Communicator client 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.
*/
/**
Eric D Vaughan
nsBoxFrame is a frame that can lay its children out either vertically or horizontally.
It lays them out according to a min max or preferred size.
**/
#ifndef nsBoxFrame_h___
#define nsBoxFrame_h___
#include "nsCOMPtr.h"
#include "nsHTMLContainerFrame.h"
#include "nsIBox.h"
#include "nsISpaceManager.h"
class nsBoxFrameInner;
class nsBoxDebugInner;
class nsHTMLReflowCommand;
class nsCalculatedBoxInfo : public nsBoxInfo {
public:
nsSize calculatedSize;
PRBool prefWidthIntrinsic;
PRBool prefHeightIntrinsic;
PRBool sizeValid;
PRBool needsReflow;
PRBool needsRecalc;
PRBool collapsed;
PRBool isIncremental;
nsCalculatedBoxInfo();
nsCalculatedBoxInfo(const nsBoxInfo& aInfo);
virtual void clear();
};
class nsBoxFrame : public nsHTMLContainerFrame, public nsIBox
{
public:
friend nsresult NS_NewBoxFrame(nsIFrame** aNewFrame, PRUint32 aFlags = 0);
// gets the rect inside our border and debug border. If you wish to paint inside a box
// call this method to get the rect so you don't draw on the debug border or outer border.
virtual void GetInnerRect(nsRect& aInner);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIFrame** aFrame);
NS_IMETHOD GetCursor(nsIPresContext& aPresContext,
nsPoint& aPoint,
PRInt32& aCursor);
// nsIBox methods
NS_IMETHOD GetBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize);
NS_IMETHOD Dirty(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame*& aIncrementalChild);
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* asPrevInFlow);
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint);
NS_IMETHOD Paint ( nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD AppendFrames(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aFrameList);
NS_IMETHOD InsertFrames(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
NS_IMETHOD RemoveFrame(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame);
NS_IMETHOD GetFrameName(nsString& aResult) const;
virtual PRBool IsHorizontal() const { return mHorizontal; }
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
virtual ~nsBoxFrame();
virtual void GetChildBoxInfo(PRInt32 aIndex, nsBoxInfo& aSize);
virtual void SetChildNeedsRecalc(PRInt32 aIndex, PRBool aRecalc);
// Paint one child frame
virtual void PaintChild(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsIFrame* aFrame,
nsFramePaintLayer aWhichLayer);
protected:
nsBoxFrame(PRUint32 aFlags = 0);
virtual void GetRedefinedMinPrefMax(nsIPresContext& aPresContext, nsIFrame* aFrame, nsCalculatedBoxInfo& aSize);
virtual nsresult GetChildBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame* aFrame, nsCalculatedBoxInfo& aSize);
virtual nsresult FlowChildren(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsRect& availableSize);
virtual nsresult FlowChildAt(nsIFrame* frame,
nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsCalculatedBoxInfo& aInfo,
PRBool& needsRedraw,
nsString& aReason);
virtual nsresult PlaceChildren(nsIPresContext& aPresContext, nsRect& boxRect);
virtual void ChildResized(nsIFrame* aFrame, nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCalculatedBoxInfo& aInfo, PRBool* aResized, nscoord& aChangedIndex, PRBool& aFinished, nscoord aIndex, nsString& aReason);
virtual void LayoutChildrenInRect(nsRect& size);
virtual void AddChildSize(nsBoxInfo& aInfo, nsBoxInfo& aChildInfo);
virtual void BoundsCheck(const nsBoxInfo& aBoxInfo, nsRect& aRect);
virtual void InvalidateChildren();
virtual void AddSize(const nsSize& a, nsSize& b, PRBool largest);
virtual PRIntn GetSkipSides() const { return 0; }
virtual void GetInset(nsMargin& margin);
virtual void CollapseChild(nsIPresContext& aPresContext, nsIFrame* frame, PRBool hide);
nsresult GenerateDirtyReflowCommand(nsIPresContext& aPresContext,
nsIPresShell& aPresShell);
PRBool mHorizontal;
nsCalculatedBoxInfo mSprings[100];
nscoord mSpringCount;
private:
friend class nsBoxFrameInner;
friend class nsBoxDebugInner;
nsBoxFrameInner* mInner;
}; // class nsBoxFrame
#endif

View File

@@ -1,27 +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>
*/
// 1936f892-1dd2-11b2-aba4-bd254241f938
#define NS_DEFCOLORPICKER_CID \
{ 0x1936f892, 0x1dd2, 0x11b2, \
{0xab, 0xa4, 0xbd, 0x25, 0x42, 0x41, 0xf9, 0x38} }

View File

@@ -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 "nsColorPickerFrame.h"
#include "nsIDOMElement.h"
#include "nsIContent.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsHTMLAtoms.h"
#include "nsIPresContext.h"
#include "nsIStyleContext.h"
#include "nsCSSRendering.h"
#include "nsINameSpaceManager.h"
#include "nsColor.h"
#include "nsIServiceManager.h"
#include "nsStdColorPicker.h"
#include "nsColorPickerCID.h"
//
// NS_NewColorPickerFrame
//
// Wrapper for creating a new color picker
//
nsresult
NS_NewColorPickerFrame(nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsColorPickerFrame* it = new nsColorPickerFrame;
if ( !it )
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
}
// static NS_DEFINE_IID(kDefColorPickerCID, NS_DEFCOLORPICKER_CID);
//
// nsColorPickerFrame cntr
//
nsColorPickerFrame::nsColorPickerFrame()
{
}
nsColorPickerFrame::~nsColorPickerFrame()
{
delete mColorPicker;
}
NS_IMETHODIMP
nsColorPickerFrame::Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsLeafFrame::Init(aPresContext, aContent, aParent, aContext,
aPrevInFlow);
nsAutoString type;
mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, type);
if (type.EqualsIgnoreCase("swatch") || type.Equals(""))
{
mColorPicker = new nsStdColorPicker();
mColorPicker->Init(mContent);
}
return rv;
}
NS_IMETHODIMP
nsColorPickerFrame::HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
aEventStatus = nsEventStatus_eConsumeDoDefault;
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN)
HandleMouseDownEvent(aPresContext, aEvent, aEventStatus);
return NS_OK;
}
nsresult
nsColorPickerFrame::HandleMouseDownEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
int x,y;
char *color;
// figure out what color we just picked
#ifdef DEBUG_pavlov
printf("got mouse down.. x = %i, y = %i\n", aEvent->refPoint.x, aEvent->refPoint.y);
#endif
x = aEvent->refPoint.x;
y = aEvent->refPoint.y;
nsCOMPtr<nsIDOMElement> node( do_QueryInterface(mContent) );
nsresult rv = mColorPicker->GetColor(x, y, &color);
if (NS_FAILED(rv))
node->RemoveAttribute("color");
else
node->SetAttribute("color", color);
return NS_OK;
}
//
// Paint
//
//
NS_METHOD
nsColorPickerFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
{
float p2t;
aPresContext.GetScaledPixelsToTwips(&p2t);
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
// if we aren't visible then we are done.
if (!disp->mVisible)
return NS_OK;
// if we are visible then tell our superclass to paint
nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
aWhichLayer);
// get our border
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsMargin border(0,0,0,0);
spacing->CalcBorderFor(this, border);
/*
const nsStyleColor* colorStyle = (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
nscolor color = colorStyle->mColor;
*/
aRenderingContext.PushState();
// set the clip region
PRInt32 width, height;
mColorPicker->GetSize(&width, &height);
nsRect rect(0, 0, PRInt32(width*p2t), PRInt32(height*p2t));
PRBool clipState;
// Clip so we don't render outside the inner rect
aRenderingContext.SetClipRect(rect, nsClipCombine_kIntersect, clipState);
// call the color picker's paint method
mColorPicker->Paint(&aPresContext, &aRenderingContext);
aRenderingContext.PopState(clipState);
return NS_OK;
}
//
// GetDesiredSize
//
// For now, be as big as CSS wants us to be, or some small default size.
//
void
nsColorPickerFrame::GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredSize)
{
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
// if the width is set use it
if (NS_INTRINSICSIZE != aReflowState.mComputedWidth)
aDesiredSize.width = aReflowState.mComputedWidth;
else
aDesiredSize.width = -1;
// if the height is set use it
if (NS_INTRINSICSIZE != aReflowState.mComputedHeight)
aDesiredSize.height = aReflowState.mComputedHeight;
else
aDesiredSize.height = -1;
mColorPicker->SetSize((aDesiredSize.width == -1) ? -1 : PRInt32(aDesiredSize.width/p2t),
(aDesiredSize.height == -1) ? -1 : PRInt32(aDesiredSize.height/p2t));
int width, height;
mColorPicker->GetSize(&width, &height);
aDesiredSize.width = nscoord(width * p2t);
aDesiredSize.height = nscoord(height * p2t);
aDesiredSize.ascent = nscoord(height * p2t);
aDesiredSize.descent = 0;
} // GetDesiredSize

View File

@@ -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.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.
*/
//
// nsColorPickerFrame
//
#ifndef nsColorPickerFrame_h__
#define nsColorPickerFrame_h__
#include "nsLeafFrame.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsCOMPtr.h"
#include "nsIColorPicker.h"
class nsString;
nsresult NS_NewColorPickerFrame(nsIFrame** aResult) ;
class nsColorPickerFrame : public nsLeafFrame
{
public:
nsColorPickerFrame();
virtual ~nsColorPickerFrame();
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsString& aResult) const {
return MakeFrameName("ColorPickerFrame", aResult);
}
#endif
// nsIFrame overrides
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
nsresult HandleMouseDownEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
protected:
virtual void GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredSize) ;
private:
nsIColorPicker *mColorPicker;
}; // class nsColorPickerFrame
#endif

View File

@@ -1,363 +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 "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 Communicator client 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.
*/
//
// Eric Vaughan
// Netscape Communications
//
// See documentation in associated header file
//
#include "nsDeckFrame.h"
#include "nsIStyleContext.h"
#include "nsIPresContext.h"
#include "nsIContent.h"
#include "nsCOMPtr.h"
#include "nsHTMLIIDs.h"
#include "nsUnitConversion.h"
#include "nsINameSpaceManager.h"
#include "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsIReflowCommand.h"
#include "nsHTMLParts.h"
#include "nsIPresShell.h"
#include "nsStyleChangeList.h"
#include "nsCSSRendering.h"
#include "nsIViewManager.h"
nsresult
NS_NewDeckFrame ( nsIFrame** aNewFrame )
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsDeckFrame* it = new nsDeckFrame;
if (nsnull == it)
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
} // NS_NewDeckFrame
NS_IMETHODIMP
nsDeckFrame::Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
// Get the element's tag
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
//CreateViewForFrame(aPresContext,this,aContext,PR_TRUE);
return rv;
}
NS_IMETHODIMP
nsDeckFrame::AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint)
{
nsresult rv = nsBoxFrame::AttributeChanged(aPresContext, aChild,
aNameSpaceID, aAttribute, aHint);
// if the index changed hide the old element and make the now element visible
if (aAttribute == nsHTMLAtoms::index) {
/*
nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell));
nsCOMPtr<nsIReflowCommand> reflowCmd;
rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), this,
nsIReflowCommand::StyleChanged);
if (NS_SUCCEEDED(rv))
shell->AppendReflowCommand(reflowCmd);
*/
Invalidate(aPresContext, nsRect(0,0,mRect.width,mRect.height), PR_FALSE);
int index = 0;
// get the index attribute
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::index, value))
{
PRInt32 error;
// convert it to an integer
index = value.ToInteger(&error);
}
nsIFrame* childFrame = mFrames.FirstChild();
nscoord count = 0;
while (nsnull != childFrame)
{
// make collapsed children not show up
if (index != count)
CollapseChild(*aPresContext, childFrame, PR_TRUE);
else
CollapseChild(*aPresContext, childFrame, PR_FALSE);
rv = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(rv == NS_OK,"failed to get next child");
count++;
}
}
if (NS_OK != rv) {
return rv;
}
return NS_OK;
}
nsIFrame*
nsDeckFrame::GetSelectedFrame()
{
// ok we want to paint only the child that as at the given index
// default index is 0
int index = 0;
// get the index attribute
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::index, value))
{
PRInt32 error;
// convert it to an integer
index = value.ToInteger(&error);
}
// get the child at that index.
nsIFrame* childFrame = mFrames.FrameAt(index);
return childFrame;
}
NS_IMETHODIMP
nsDeckFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
{
// if a tab is hidden all its children are too.
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (!disp->mVisible)
return NS_OK;
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
if (disp->mVisible && mRect.width && mRect.height) {
// Paint our background and border
PRIntn skipSides = GetSkipSides();
const nsStyleColor* color = (const nsStyleColor*)
mStyleContext->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
}
}
nsIFrame* frame = GetSelectedFrame();
if (frame != nsnull)
PaintChild(aPresContext, aRenderingContext, aDirtyRect, frame, aWhichLayer);
return NS_OK;
}
NS_IMETHODIMP nsDeckFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIFrame** aFrame)
{
// if its not in our child just return us.
*aFrame = this;
// get the selected frame and see if the point is in it.
nsIFrame* selectedFrame = GetSelectedFrame();
if (nsnull != selectedFrame)
{
nsRect childRect;
selectedFrame->GetRect(childRect);
if (childRect.Contains(aPoint)) {
// adjust the point
nsPoint p = aPoint;
p.x -= childRect.x;
p.y -= childRect.y;
return selectedFrame->GetFrameForPoint(aPresContext, p, aFrame);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsDeckFrame::SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList)
{
nsresult r = nsBoxFrame::SetInitialChildList(aPresContext, aListName, aChildList);
return r;
}
void
nsDeckFrame::AddChildSize(nsBoxInfo& aInfo, nsBoxInfo& aChildInfo)
{
// largest preferred size
if (aChildInfo.prefSize.width > aInfo.prefSize.width)
aInfo.prefSize.width = aChildInfo.prefSize.width;
if (aChildInfo.prefSize.height > aInfo.prefSize.height)
aInfo.prefSize.height = aChildInfo.prefSize.height;
// largest min size
if (aChildInfo.minSize.width > aInfo.minSize.width)
aInfo.minSize.width = aChildInfo.minSize.width;
if (aChildInfo.minSize.height > aInfo.minSize.height)
aInfo.minSize.height = aChildInfo.minSize.height;
// smallest max size
if (aChildInfo.maxSize.width < aInfo.maxSize.width)
aInfo.maxSize.width = aChildInfo.maxSize.width;
if (aChildInfo.maxSize.height < aInfo.maxSize.height)
aInfo.maxSize.height = aChildInfo.maxSize.height;
}
nsresult
nsDeckFrame::PlaceChildren(nsIPresContext& aPresContext, nsRect& boxRect)
{
// ------- set the childs positions ---------
nsIFrame* childFrame = mFrames.FirstChild();
nscoord count = 0;
while (nsnull != childFrame)
{
nsresult rv;
// make collapsed children not show up
if (mSprings[count].collapsed) {
//nsRect rect(0,0,0,0);
//childFrame->GetRect(rect);
//if (rect.width > 0 || rect.height > 0) {
// childFrame->SizeTo(0,0);
CollapseChild(aPresContext, childFrame, PR_TRUE);
//}
} else {
childFrame->MoveTo(&aPresContext, boxRect.x, boxRect.y);
}
rv = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(rv == NS_OK,"failed to get next child");
count++;
}
return NS_OK;
}
NS_IMETHODIMP
nsDeckFrame::DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus)
{
int index = 0;
// get the index attribute
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::index, value))
{
PRInt32 error;
// convert it to an integer
index = value.ToInteger(&error);
}
nsresult rv = nsBoxFrame::DidReflow(aPresContext, aStatus);
NS_ASSERTION(rv == NS_OK,"DidReflow failed");
nsIFrame* childFrame = mFrames.FirstChild();
nscoord count = 0;
while (nsnull != childFrame)
{
// make collapsed children not show up
if (index != count)
CollapseChild(aPresContext, childFrame, PR_TRUE);
else
CollapseChild(aPresContext, childFrame, PR_FALSE);
rv = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(rv == NS_OK,"failed to get next child");
count++;
}
return rv;
}
void
nsDeckFrame::ChildResized(nsIFrame* aFrame, nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCalculatedBoxInfo& aInfo, PRBool* aResized, nscoord& aChangedIndex, PRBool& aFinished, nscoord aIndex, nsString& aReason)
{
if (aDesiredSize.width > aRect.width) {
aRect.width = aDesiredSize.width;
InvalidateChildren();
LayoutChildrenInRect(aRect);
aReason = "child's width got bigger";
aChangedIndex = aIndex;
aFinished = PR_FALSE;
} else if (aDesiredSize.height > aRect.height) {
aRect.height = aDesiredSize.height;
InvalidateChildren();
LayoutChildrenInRect(aRect);
aReason = "child's height got bigger";
aChangedIndex = aIndex;
aFinished = PR_FALSE;
}
}
void
nsDeckFrame::LayoutChildrenInRect(nsRect& size)
{
for (int i=0; i<mSpringCount; i++) {
mSprings[i].calculatedSize.width = size.width;
mSprings[i].calculatedSize.height = size.height;
mSprings[i].sizeValid = PR_TRUE;
}
}

View File

@@ -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 "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 Communicator client 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.
*/
/**
Eric D Vaughan
A frame that can have multiple children. Only one child may be displayed at one time. So the
can be flipped though like a deck of cards.
**/
#ifndef nsDeckFrame_h___
#define nsDeckFrame_h___
#include "nsBoxFrame.h"
class nsDeckFrame : public nsBoxFrame
{
public:
friend nsresult NS_NewDeckFrame(nsIFrame** aNewFrame);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* asPrevInFlow);
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint);
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus);
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIFrame** aFrame);
virtual PRIntn GetSkipSides() const { return 0; }
protected:
virtual nsIFrame* GetSelectedFrame();
virtual nsresult PlaceChildren(nsIPresContext& aPresContext, nsRect& boxRect);
virtual void ChildResized(nsIFrame* aFrame, nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCalculatedBoxInfo& aInfo, PRBool* aResized, nscoord& aChangedIndex, PRBool& aFinished, nscoord aIndex, nsString& aReason);
virtual void LayoutChildrenInRect(nsRect& size);
virtual void AddChildSize(nsBoxInfo& aInfo, nsBoxInfo& aChildInfo);
private:
nsIFrame* mSelected;
}; // class nsDeckFrame
#endif

View File

@@ -1,111 +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 "nsFontPickerFrame.h"
#include "nsIContent.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsIPresContext.h"
#include "nsIStyleContext.h"
#include "nsCSSRendering.h"
#include "nsINameSpaceManager.h"
//
// NS_NewFontPickerFrame
//
// Wrapper for creating a new font picker
//
nsresult
NS_NewFontPickerFrame(nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsFontPickerFrame* it = new nsFontPickerFrame;
if ( !it )
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
}
//
// nsFontPickerFrame cntr
//
nsFontPickerFrame::nsFontPickerFrame()
{
} // cntr
//
// Paint
//
// Overidden to handle ???
//
NS_METHOD
nsFontPickerFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
{
return nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
}
//
// GetDesiredSize
//
// For now, be as big as CSS wants us to be, or some small default size.
//
void
nsFontPickerFrame :: GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredLayoutSize)
{
const int CSS_NOTSET = -1;
nsSize styleSize;
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedWidth) {
styleSize.width = aReflowState.mComputedWidth;
}
else {
styleSize.width = CSS_NOTSET;
}
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) {
styleSize.height = aReflowState.mComputedHeight;
}
else {
styleSize.height = CSS_NOTSET;
}
// subclasses should always override this method, but if not and no css, make it small
aDesiredLayoutSize.width = (styleSize.width > CSS_NOTSET) ? styleSize.width : 200;
aDesiredLayoutSize.height = (styleSize.height > CSS_NOTSET) ? styleSize.height : 200;
aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;
aDesiredLayoutSize.descent = 0;
if (aDesiredLayoutSize.maxElementSize) {
aDesiredLayoutSize.maxElementSize->width = aDesiredLayoutSize.width;
aDesiredLayoutSize.maxElementSize->height = aDesiredLayoutSize.height;
}
} // GetDesiredSize

View File

@@ -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.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.
*/
//
// nsFontPickerFrame
//
#ifndef nsFontPickerFrame_h__
#define nsFontPickerFrame_h__
#include "nsLeafFrame.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsCOMPtr.h"
class nsString;
nsresult NS_NewFontPickerFrame(nsIFrame** aResult) ;
class nsFontPickerFrame : public nsLeafFrame
{
public:
nsFontPickerFrame();
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsString& aResult) const {
return MakeFrameName("FontPickerFrame", aResult);
}
#endif
// nsIFrame overrides
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
protected:
virtual void GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredSize) ;
}; // class nsFontPickerFrame
#endif

View File

@@ -1,127 +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 "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 Communicator client 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.
*/
//
// Eric Vaughan
// Netscape Communications
//
// See documentation in associated header file
//
#include "nsFrameNavigator.h"
#include "nsCOMPtr.h"
#include "nsIContent.h"
nsIAtom*
nsFrameNavigator::GetTag(nsIFrame* frame)
{
nsCOMPtr<nsIContent> content;
frame->GetContent(getter_AddRefs(content));
if (content) {
nsIAtom* atom = nsnull;
content->GetTag(atom);
return atom;
}
return nsnull;
}
nsIFrame*
nsFrameNavigator::GetChildBeforeAfter(nsIFrame* start, PRBool before)
{
nsIFrame* parent = nsnull;
start->GetParent(&parent);
PRInt32 index = IndexOf(parent,start);
PRInt32 count = CountFrames(parent);
if (index == -1)
return nsnull;
if (before) {
if (index == 0) {
return nsnull;
}
return GetChildAt(parent, index-1);
}
if (index == count-1)
return nsnull;
return GetChildAt(parent, index+1);
}
PRInt32
nsFrameNavigator::IndexOf(nsIFrame* parent, nsIFrame* child)
{
PRInt32 count = 0;
nsIFrame* childFrame;
parent->FirstChild(nsnull, &childFrame);
while (nsnull != childFrame)
{
if (childFrame == child)
return count;
nsresult rv = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(rv == NS_OK,"failed to get next child");
count++;
}
return -1;
}
PRInt32
nsFrameNavigator::CountFrames(nsIFrame* aFrame)
{
PRInt32 count = 0;
nsIFrame* childFrame;
aFrame->FirstChild(nsnull, &childFrame);
while (nsnull != childFrame)
{
nsresult rv = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(rv == NS_OK,"failed to get next child");
count++;
}
return count;
}
nsIFrame*
nsFrameNavigator::GetChildAt(nsIFrame* parent, PRInt32 index)
{
PRInt32 count = 0;
nsIFrame* childFrame;
parent->FirstChild(nsnull, &childFrame);
while (nsnull != childFrame)
{
if (count == index)
return childFrame;
nsresult rv = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(rv == NS_OK,"failed to get next child");
count++;
}
return nsnull;
}

View File

@@ -1,47 +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 "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 Communicator client 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.
*/
/**
Eric D Vaughan
This class lays out its children either vertically or horizontally
**/
#ifndef nsGrippyFrame_h___
#define nsGrippyFrame_h___
#include "nsIFrame.h"
class nsFrameNavigator
{
public:
static nsIFrame* GetChildBeforeAfter(nsIFrame* start, PRBool before);
static nsIFrame* GetChildAt(nsIFrame* parent, PRInt32 index);
static PRInt32 IndexOf(nsIFrame* parent, nsIFrame* child);
static PRInt32 CountFrames(nsIFrame* aFrame);
static nsIAtom* GetTag(nsIFrame* frame);
};
#endif

View File

@@ -1,240 +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 "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 Communicator client 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.
*/
//
// Eric Vaughan
// Netscape Communications
//
// See documentation in associated header file
//
#include "nsGrippyFrame.h"
#include "nsScrollbarButtonFrame.h"
#include "nsIStyleContext.h"
#include "nsIPresContext.h"
#include "nsIContent.h"
#include "nsCOMPtr.h"
#include "nsHTMLIIDs.h"
#include "nsUnitConversion.h"
#include "nsINameSpaceManager.h"
#include "nsHTMLAtoms.h"
#include "nsXULAtoms.h"
#include "nsIReflowCommand.h"
//#include "nsSliderFrame.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsDocument.h"
#include "nsHTMLParts.h"
#include "nsIPresShell.h"
#include "nsIView.h"
#include "nsIViewManager.h"
#include "nsHTMLContainerFrame.h"
//
// NS_NewToolbarFrame
//
// Creates a new Toolbar frame and returns it in |aNewFrame|
//
nsresult
NS_NewGrippyFrame ( nsIFrame** aNewFrame )
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsGrippyFrame* it = new nsGrippyFrame;
if (nsnull == it)
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
} // NS_NewGrippyFrame
nsGrippyFrame::nsGrippyFrame():mCollapsed(PR_FALSE)
{
}
void
nsGrippyFrame::MouseClicked(nsIPresContext& aPresContext)
{
nsIFrame* splitter;
nsScrollbarButtonFrame::GetParentWithTag(nsXULAtoms::splitter, this, splitter);
if (splitter == nsnull)
return;
// get the splitters content node
nsCOMPtr<nsIContent> content;
splitter->GetContent(getter_AddRefs(content));
nsString a = "collapsed";
nsString value;
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsXULAtoms::state, value))
{
if (value=="collapsed")
a = "open";
}
content->SetAttribute(kNameSpaceID_None, nsXULAtoms::state, a, PR_TRUE);
}
/*
void
nsGrippyFrame::MouseClicked(nsIPresContext& aPresContext)
{
nsString style;
if (mCollapsed) {
style = mCollapsedChildStyle;
} else {
// when clicked see if we are in a splitter.
nsIFrame* splitter;
nsScrollbarButtonFrame::GetParentWithTag(nsXULAtoms::splitter, this, splitter);
if (splitter == nsnull)
return;
// get the splitters content node
nsCOMPtr<nsIContent> content;
splitter->GetContent(getter_AddRefs(content));
// get the collapse attribute. If the attribute is not set collapse
// the child before otherwise collapse the child after
PRBool before = PR_TRUE;
nsString value;
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsXULAtoms::collapse, value))
{
if (value=="after")
before = PR_FALSE;
}
// find the child just in the box just before the splitter. If we are not currently collapsed then
// then get the childs style attribute and store it. Then set the child style attribute to be display none.
// if we are already collapsed then set the child's style back to our stored value.
nsIFrame* child = GetChildBeforeAfter(splitter,before);
if (child == nsnull)
return;
child->GetContent(getter_AddRefs(mCollapsedChild));
style = "visibility: collapse";
mCollapsedChildStyle = "";
mCollapsedChild->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::style, mCollapsedChildStyle);
}
mCollapsedChild->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::style, style, PR_TRUE);
mCollapsed = !mCollapsed;
}
*/
nsIFrame*
nsGrippyFrame::GetChildBeforeAfter(nsIFrame* start, PRBool before)
{
nsIFrame* parent = nsnull;
start->GetParent(&parent);
PRInt32 index = IndexOf(parent,start);
PRInt32 count = CountFrames(parent);
if (index == -1)
return nsnull;
if (before) {
if (index == 0) {
return nsnull;
}
return GetChildAt(parent, index-1);
}
if (index == count-1)
return nsnull;
return GetChildAt(parent, index+1);
}
PRInt32
nsGrippyFrame::IndexOf(nsIFrame* parent, nsIFrame* child)
{
PRInt32 count = 0;
nsIFrame* childFrame;
parent->FirstChild(nsnull, &childFrame);
while (nsnull != childFrame)
{
if (childFrame == child)
return count;
nsresult rv = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(rv == NS_OK,"failed to get next child");
count++;
}
return -1;
}
PRInt32
nsGrippyFrame::CountFrames(nsIFrame* aFrame)
{
PRInt32 count = 0;
nsIFrame* childFrame;
aFrame->FirstChild(nsnull, &childFrame);
while (nsnull != childFrame)
{
nsresult rv = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(rv == NS_OK,"failed to get next child");
count++;
}
return count;
}
nsIFrame*
nsGrippyFrame::GetChildAt(nsIFrame* parent, PRInt32 index)
{
PRInt32 count = 0;
nsIFrame* childFrame;
parent->FirstChild(nsnull, &childFrame);
while (nsnull != childFrame)
{
if (count == index)
return childFrame;
nsresult rv = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(rv == NS_OK,"failed to get next child");
count++;
}
return nsnull;
}
NS_IMETHODIMP
nsGrippyFrame::GetFrameName(nsString& aResult) const
{
aResult = "Grippy";
return NS_OK;
}

View File

@@ -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.0 (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 Communicator client 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.
*/
/**
Eric D Vaughan
This class lays out its children either vertically or horizontally
**/
#ifndef nsGrippyFrame_h___
#define nsGrippyFrame_h___
#include "nsTitledButtonFrame.h"
#include "nsCOMPtr.h"
#include "nsIContent.h"
class nsGrippyFrame : public nsTitledButtonFrame
{
public:
friend nsresult NS_NewGrippyFrame(nsIFrame** aNewFrame);
NS_IMETHOD GetFrameName(nsString& aResult) const;
static nsIFrame* GetChildBeforeAfter(nsIFrame* start, PRBool before);
static nsIFrame* GetChildAt(nsIFrame* parent, PRInt32 index);
static PRInt32 IndexOf(nsIFrame* parent, nsIFrame* child);
static PRInt32 CountFrames(nsIFrame* aFrame);
nsGrippyFrame();
protected:
virtual void MouseClicked(nsIPresContext& aPresContext);
private:
PRBool mCollapsed;
nsString mCollapsedChildStyle;
nsCOMPtr<nsIContent> mCollapsedChild;
PRBool mDidDrag;
}; // class nsTabFrame
#endif

View File

@@ -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 "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 Communicator client 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.
*/
/**
Eric D Vaughan
nsBoxFrame is a frame that can lay its children out either vertically or horizontally.
It lays them out according to a min max or preferred size.
**/
#ifndef nsIBox_h___
#define nsIBox_h___
class nsIPresContext;
class nsIFrame;
struct nsHTMLReflowState;
class nsBoxInfo;
// {02A560C0-01BF-11d3-B35C-00A0CC3C1CDE}
#define NS_IBOX_IID { 0x2a560c0, 0x1bf, 0x11d3, { 0xb3, 0x5c, 0x0, 0xa0, 0xcc, 0x3c, 0x1c, 0xde } }
static NS_DEFINE_IID(kIBoxIID, NS_IBOX_IID);
class nsBoxInfo {
public:
nsSize prefSize;
nsSize minSize;
nsSize maxSize;
float flex;
nsBoxInfo() { clear(); }
virtual void clear()
{
prefSize.width = 0;
prefSize.height = 0;
minSize.width = 0;
minSize.height = 0;
flex = 0.0;
maxSize.width = NS_INTRINSICSIZE;
maxSize.height = NS_INTRINSICSIZE;
}
};
class nsIBox : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IBOX_IID; return iid; }
NS_IMETHOD GetBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize)=0;
NS_IMETHOD Dirty(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame*& incrementalChild)=0;
};
#endif

View File

@@ -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 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>
*/
#ifndef __nsIColorPicker_h__
#define __nsIColorPicker_h__
#include "nsISupports.h"
#include "nsrootidl.h"
#include "nsIPresContext.h"
#include "nsIRenderingContext.h"
/* starting interface: nsIColorPicker */
#define NS_ICOLORPICKER_IID_STR "ed133d04-1dd1-11b2-957f-a04e70608d6e"
#define NS_ICOLORPICKER_IID \
{0xed133d04, 0x1dd1, 0x11b2, \
{ 0x95, 0x7f, 0xa0, 0x4e, 0x70, 0x60, 0x8d, 0x6e }}
class nsIColorPicker : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICOLORPICKER_IID)
/* void Init (in nsIContent aContent); */
NS_IMETHOD Init(nsIContent * aContent) = 0;
/* void Paint (in nsIPresContext aPresContext, in nsIRenderingContext aRenderingContext); */
NS_IMETHOD Paint(nsIPresContext * aPresContext, nsIRenderingContext * aRenderingContext) = 0;
/* void GetColor (in PRInt32 aX, in PRInt32 aY, out string aColor); */
NS_IMETHOD GetColor(PRInt32 aX, PRInt32 aY, char **aColor) = 0;
/* void SetColor (in PRInt32 aWidth, in PRInt32 aHeight); */
NS_IMETHOD SetSize(PRInt32 aWidth, PRInt32 aHeight) = 0;
/* void GetSize (out PRInt32 aWidth, out PRInt32 aHeight); */
NS_IMETHOD GetSize(PRInt32 *aWidth, PRInt32 *aHeight) = 0;
};
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSICOLORPICKER \
NS_IMETHOD Init(nsIContent * aContent); \
NS_IMETHOD Paint(nsIPresContext * aPresContext, nsIRenderingContext * aRenderingContext); \
NS_IMETHOD GetColor(PRInt32 aX, PRInt32 aY, char **aColor); \
NS_IMETHOD SetSize(PRInt32 aWidth, PRInt32 aHeight); \
NS_IMETHOD GetSize(PRInt32 *aWidth, PRInt32 *aHeight);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSICOLORPICKER(_to) \
NS_IMETHOD Init(nsIContent * aContent) { return _to ## Init(aContent); } \
NS_IMETHOD Paint(nsIPresContext * aPresContext, nsIRenderingContext * aRenderingContext) { return _to ## Paint(aPresContext, aRenderingContext); } \
NS_IMETHOD GetColor(PRInt32 aX, PRInt32 aY, char **aColor) { return _to ## GetColor(aX, aY, aColor); } \
NS_IMETHOD SetSize(PRInt32 aWidth, PRInt32 aHeight) { return _to ## SetSize(aWidth, aHeight); } \
NS_IMETHOD GetSize(PRInt32 *aWidth, PRInt32 *aHeight) { return _to ## GetSize(aWidth, aHeight); }
#endif /* __nsIColorPicker_h__ */

View File

@@ -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.0 (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 Communicator client 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.
*/
#ifndef nsIMenuFrame_h___
#define nsIMenuFrame_h___
// {6A4CDE51-6C05-11d3-BB50-00104B7B7DEB}
#define NS_IMENUFRAME_IID \
{ 0x6a4cde51, 0x6c05, 0x11d3, { 0xbb, 0x50, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } }
class nsIMenuParent;
enum nsMenuType {
eMenuType_Normal = 0,
eMenuType_Checkbox = 1,
eMenuType_Radio = 2
};
class nsIMenuFrame : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IMENUFRAME_IID; return iid; }
NS_IMETHOD ActivateMenu(PRBool aFlag) = 0;
NS_IMETHOD SelectMenu(PRBool aFlag) = 0;
NS_IMETHOD OpenMenu(PRBool aFlag) = 0;
NS_IMETHOD MenuIsOpen(PRBool& aResult) = 0;
NS_IMETHOD MenuIsContainer(PRBool& aResult) = 0;
NS_IMETHOD MenuIsChecked(PRBool& aResult) = 0;
NS_IMETHOD SelectFirstItem() = 0;
NS_IMETHOD Escape(PRBool& aHandledFlag) = 0;
NS_IMETHOD Enter() = 0;
NS_IMETHOD ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag) = 0;
NS_IMETHOD KeyboardNavigation(PRUint32 aDirection, PRBool& aHandledFlag) = 0;
NS_IMETHOD GetMenuParent(nsIMenuParent** aMenuParent) = 0;
NS_IMETHOD GetRadioGroupName(nsString &aName) = 0;
NS_IMETHOD GetMenuType(nsMenuType &aType) = 0;
NS_IMETHOD MarkAsGenerated() = 0;
};
#endif

View File

@@ -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.0 (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 Communicator client 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.
*/
#ifndef nsIMenuParent_h___
#define nsIMenuParent_h___
// {D407BF61-3EFA-11d3-97FA-00400553EEF0}
#define NS_IMENUPARENT_IID \
{ 0xd407bf61, 0x3efa, 0x11d3, { 0x97, 0xfa, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
class nsIMenuFrame;
class nsIMenuParent : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IMENUPARENT_IID; return iid; }
NS_IMETHOD SetCurrentMenuItem(nsIMenuFrame* aMenuItem) = 0;
NS_IMETHOD GetNextMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult) = 0;
NS_IMETHOD GetPreviousMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult) = 0;
NS_IMETHOD SetActive(PRBool aActiveFlag) = 0;
NS_IMETHOD GetIsActive(PRBool& isActive) = 0;
NS_IMETHOD GetWidget(nsIWidget **aWidget) = 0;
NS_IMETHOD IsMenuBar(PRBool& isMenuBar) = 0;
NS_IMETHOD DismissChain() = 0;
NS_IMETHOD HideChain() = 0;
NS_IMETHOD CreateDismissalListener() = 0;
};
#endif

View File

@@ -1,44 +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 "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 Communicator client 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.
*/
#ifndef nsIScrollbarListener_h___
#define nsIScrollbarListener_h___
// {A0ADBD81-2911-11d3-97FA-00400553EEF0}
#define NS_ISCROLLBARLISTENER_IID \
{ 0xa0adbd81, 0x2911, 0x11d3, { 0x97, 0xfa, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
static NS_DEFINE_IID(kIScrollbarListenerIID, NS_ISCROLLBARLISTENER_IID);
class nsIPresContext;
class nsIScrollbarListener : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_ISCROLLBARLISTENER_IID; return iid; }
NS_IMETHOD PositionChanged(nsIPresContext& aPresContext, PRInt32 aOldIndex, PRInt32 aNewIndex) = 0;
NS_IMETHOD PagedUpDown() = 0;
// NS_IMETHOD GoingAway() = 0;
};
#endif

View File

@@ -1,537 +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 "nsMenuBarFrame.h"
#include "nsIContent.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsIPresContext.h"
#include "nsIStyleContext.h"
#include "nsCSSRendering.h"
#include "nsINameSpaceManager.h"
#include "nsIDocument.h"
#include "nsIDOMEventReceiver.h"
#include "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsMenuFrame.h"
#include "nsIView.h"
#include "nsIViewManager.h"
#include "nsMenuPopupFrame.h"
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
//
// NS_NewMenuBarFrame
//
// Wrapper for creating a new menu Bar container
//
nsresult
NS_NewMenuBarFrame(nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsMenuBarFrame* it = new nsMenuBarFrame;
if ( !it )
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsMenuBarFrame::AddRef(void)
{
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsMenuBarFrame::Release(void)
{
return NS_OK;
}
NS_IMETHODIMP nsMenuBarFrame::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
if (aIID.Equals(nsIMenuParent::GetIID())) {
*aInstancePtr = (void*)(nsIMenuParent*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return nsToolbarFrame::QueryInterface(aIID, aInstancePtr);
}
//
// nsMenuBarFrame cntr
//
nsMenuBarFrame::nsMenuBarFrame()
:mIsActive(PR_FALSE), mTarget(nsnull)
{
} // cntr
nsMenuBarFrame::~nsMenuBarFrame()
{
}
NS_IMETHODIMP
nsMenuBarFrame::Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsToolbarFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
// XXX hack
mPresContext = &aPresContext;
// Create the menu bar listener.
mMenuBarListener = new nsMenuBarListener(this);
// Hook up the menu bar as a key listener (capturer) on the whole document. It will see every
// key press that occurs before anyone else does and will know when to take control.
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(*getter_AddRefs(doc));
nsCOMPtr<nsIDOMEventReceiver> target = do_QueryInterface(doc);
nsIDOMEventListener* domEventListener = (nsIDOMKeyListener*)mMenuBarListener;
mTarget = target;
target->AddEventListener("keypress", domEventListener, PR_TRUE);
target->AddEventListener("keydown", domEventListener, PR_TRUE);
target->AddEventListener("keyup", domEventListener, PR_TRUE);
return rv;
}
NS_IMETHODIMP
nsMenuBarFrame::SetActive(PRBool aActiveFlag)
{
mIsActive = aActiveFlag;
return NS_OK;
}
void
nsMenuBarFrame::ToggleMenuActiveState()
{
if (mIsActive) {
// Deactivate the menu bar
mIsActive = PR_FALSE;
if (mCurrentMenu) {
// Deactivate the menu.
mCurrentMenu->OpenMenu(PR_FALSE);
mCurrentMenu->SelectMenu(PR_FALSE);
mCurrentMenu = nsnull;
}
}
else {
// Activate the menu bar
SetActive(PR_TRUE);
// Set the active menu to be the top left item (e.g., the File menu).
// We use an attribute called "active" to track the current active menu.
nsCOMPtr<nsIContent> firstMenuItem;
nsIMenuFrame* firstFrame;
GetNextMenuItem(nsnull, &firstFrame);
if (firstFrame) {
firstFrame->SelectMenu(PR_TRUE);
// Track this item for keyboard navigation.
mCurrentMenu = firstFrame;
}
}
}
nsIMenuFrame*
nsMenuBarFrame::FindMenuWithShortcut(PRUint32 aLetter)
{
// Enumerate over our list of frames.
nsIFrame* currFrame = mFrames.FirstChild();
while (currFrame) {
nsCOMPtr<nsIContent> current;
currFrame->GetContent(getter_AddRefs(current));
// See if it's a menu item.
if (IsValidItem(current)) {
// Get the shortcut attribute.
nsString shortcutKey = "";
current->GetAttribute(kNameSpaceID_None, nsXULAtoms::accesskey, shortcutKey);
shortcutKey.ToUpperCase();
if (shortcutKey.Length() > 0) {
// We've got something.
PRUnichar shortcutChar = shortcutKey.CharAt(0);
if (shortcutChar == aLetter) {
// We match!
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(currFrame);
if (menuFrame)
return menuFrame.get();
return nsnull;
}
}
}
currFrame->GetNextSibling(&currFrame);
}
return nsnull;
}
void
nsMenuBarFrame::ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag)
{
if (mCurrentMenu) {
PRBool isOpen = PR_FALSE;
mCurrentMenu->MenuIsOpen(isOpen);
if (isOpen) {
// No way this applies to us. Give it to our child.
mCurrentMenu->ShortcutNavigation(aLetter, aHandledFlag);
return;
}
}
// This applies to us. Let's see if one of the shortcuts applies
nsIMenuFrame* result = FindMenuWithShortcut(aLetter);
if (result) {
// We got one!
aHandledFlag = PR_TRUE;
mIsActive = PR_TRUE;
SetCurrentMenuItem(result);
result->OpenMenu(PR_TRUE);
result->SelectFirstItem();
}
}
void
nsMenuBarFrame::KeyboardNavigation(PRUint32 aDirection)
{
if (!mCurrentMenu)
return;
PRBool isContainer = PR_FALSE;
PRBool isOpen = PR_FALSE;
mCurrentMenu->MenuIsContainer(isContainer);
mCurrentMenu->MenuIsOpen(isOpen);
PRBool handled = PR_FALSE;
if (isOpen) {
// Let the child menu try to handle it.
mCurrentMenu->KeyboardNavigation(aDirection, handled);
}
if (handled)
return;
if (aDirection == NS_VK_RIGHT || aDirection == NS_VK_LEFT) {
nsIMenuFrame* nextItem;
if (aDirection == NS_VK_RIGHT)
GetNextMenuItem(mCurrentMenu, &nextItem);
else GetPreviousMenuItem(mCurrentMenu, &nextItem);
SetCurrentMenuItem(nextItem);
if (nextItem) {
PRBool nextIsOpen;
nextItem->MenuIsOpen(nextIsOpen);
if (nextIsOpen) {
// Select the first item.
nextItem->SelectFirstItem();
}
}
}
else if (aDirection == NS_VK_UP || aDirection == NS_VK_DOWN) {
// Open the menu and select its first item.
mCurrentMenu->OpenMenu(PR_TRUE);
mCurrentMenu->SelectFirstItem();
}
}
NS_IMETHODIMP
nsMenuBarFrame::GetNextMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult)
{
nsIFrame* currFrame = nsnull;
nsIFrame* startFrame = nsnull;
if (aStart) {
aStart->QueryInterface(kIFrameIID, (void**)&currFrame);
if (currFrame) {
startFrame = currFrame;
currFrame->GetNextSibling(&currFrame);
}
}
else currFrame = mFrames.FirstChild();
while (currFrame) {
nsCOMPtr<nsIContent> current;
currFrame->GetContent(getter_AddRefs(current));
// See if it's a menu item.
if (IsValidItem(current)) {
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(currFrame);
*aResult = menuFrame.get();
NS_IF_ADDREF(*aResult);
return NS_OK;
}
currFrame->GetNextSibling(&currFrame);
}
currFrame = mFrames.FirstChild();
// Still don't have anything. Try cycling from the beginning.
while (currFrame && currFrame != startFrame) {
nsCOMPtr<nsIContent> current;
currFrame->GetContent(getter_AddRefs(current));
// See if it's a menu item.
if (IsValidItem(current)) {
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(currFrame);
*aResult = menuFrame.get();
NS_IF_ADDREF(*aResult);
return NS_OK;
}
currFrame->GetNextSibling(&currFrame);
}
// No luck. Just return our start value.
*aResult = aStart;
return NS_OK;
}
NS_IMETHODIMP
nsMenuBarFrame::GetPreviousMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult)
{
nsIFrame* currFrame = nsnull;
nsIFrame* startFrame = nsnull;
if (aStart) {
aStart->QueryInterface(kIFrameIID, (void**)&currFrame);
if (currFrame) {
startFrame = currFrame;
currFrame = mFrames.GetPrevSiblingFor(currFrame);
}
}
else currFrame = mFrames.LastChild();
while (currFrame) {
nsCOMPtr<nsIContent> current;
currFrame->GetContent(getter_AddRefs(current));
// See if it's a menu item.
if (IsValidItem(current)) {
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(currFrame);
*aResult = menuFrame.get();
NS_IF_ADDREF(*aResult);
return NS_OK;
}
currFrame = mFrames.GetPrevSiblingFor(currFrame);
}
currFrame = mFrames.LastChild();
// Still don't have anything. Try cycling from the end.
while (currFrame && currFrame != startFrame) {
nsCOMPtr<nsIContent> current;
currFrame->GetContent(getter_AddRefs(current));
// See if it's a menu item.
if (IsValidItem(current)) {
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(currFrame);
*aResult = menuFrame.get();
NS_IF_ADDREF(*aResult);
return NS_OK;
}
currFrame = mFrames.GetPrevSiblingFor(currFrame);
}
// No luck. Just return our start value.
*aResult = aStart;
return NS_OK;
}
NS_IMETHODIMP nsMenuBarFrame::SetCurrentMenuItem(nsIMenuFrame* aMenuItem)
{
if (mCurrentMenu == aMenuItem)
return NS_OK;
PRBool wasOpen = PR_FALSE;
// Unset the current child.
if (mCurrentMenu) {
mCurrentMenu->MenuIsOpen(wasOpen);
mCurrentMenu->SelectMenu(PR_FALSE);
if (wasOpen)
mCurrentMenu->OpenMenu(PR_FALSE);
}
// Set the new child.
if (aMenuItem) {
aMenuItem->SelectMenu(PR_TRUE);
aMenuItem->MarkAsGenerated(); // Have the menu building. Get it ready to be shown.
if (wasOpen)
aMenuItem->OpenMenu(PR_TRUE);
}
mCurrentMenu = aMenuItem;
return NS_OK;
}
void
nsMenuBarFrame::Escape()
{
if (!mCurrentMenu)
return;
// See if our menu is open.
PRBool isOpen = PR_FALSE;
mCurrentMenu->MenuIsOpen(isOpen);
if (isOpen) {
// Let the child menu handle this.
PRBool handled = PR_FALSE;
mCurrentMenu->Escape(handled);
if (!handled) {
// Close up this menu but keep our current menu item
// designation.
mCurrentMenu->OpenMenu(PR_FALSE);
}
return;
}
// It's us. Just set our active flag to false.
mIsActive = PR_FALSE;
// Clear our current menu item if we've got one.
SetCurrentMenuItem(nsnull);
// Clear out our dismissal listener
if (nsMenuFrame::mDismissalListener)
nsMenuFrame::mDismissalListener->Unregister();
}
void
nsMenuBarFrame::Enter()
{
if (!mCurrentMenu)
return;
// See if our menu is open.
PRBool isOpen = PR_FALSE;
mCurrentMenu->MenuIsOpen(isOpen);
if (isOpen) {
// Let the child menu handle this.
mCurrentMenu->Enter();
return;
}
// It's us. Open the current menu.
mCurrentMenu->OpenMenu(PR_TRUE);
mCurrentMenu->SelectFirstItem();
}
NS_IMETHODIMP
nsMenuBarFrame::HideChain()
{
// Stop capturing rollups
// (must do this during Hide, which happens before the menu item is executed,
// since this reinstates normal event handling.)
if (nsMenuFrame::mDismissalListener)
nsMenuFrame::mDismissalListener->Unregister();
if (mCurrentMenu) {
mCurrentMenu->ActivateMenu(PR_FALSE);
mCurrentMenu->SelectMenu(PR_FALSE);
}
return NS_OK;
}
NS_IMETHODIMP
nsMenuBarFrame::DismissChain()
{
// Stop capturing rollups
if (nsMenuFrame::mDismissalListener)
nsMenuFrame::mDismissalListener->Unregister();
SetCurrentMenuItem(nsnull);
SetActive(PR_FALSE);
return NS_OK;
}
NS_IMETHODIMP
nsMenuBarFrame::GetWidget(nsIWidget **aWidget)
{
// Get parent view
nsIView * view = nsnull;
nsMenuPopupFrame::GetNearestEnclosingView(mPresContext, this, &view);
if (!view)
return NS_OK;
view->GetWidget(*aWidget);
return NS_OK;
}
NS_IMETHODIMP
nsMenuBarFrame::CreateDismissalListener()
{
NS_ADDREF(nsMenuFrame::mDismissalListener = new nsMenuDismissalListener());
return NS_OK;
}
PRBool
nsMenuBarFrame::IsValidItem(nsIContent* aContent)
{
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(*getter_AddRefs(tag));
if (tag && (tag.get() == nsXULAtoms::menu ||
tag.get() == nsXULAtoms::menuitem) &&
!IsDisabled(aContent))
return PR_TRUE;
return PR_FALSE;
}
PRBool
nsMenuBarFrame::IsDisabled(nsIContent* aContent)
{
nsString disabled = "";
aContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::disabled, disabled);
if (disabled == "true")
return PR_TRUE;
return PR_FALSE;
}
NS_IMETHODIMP
nsMenuBarFrame::Destroy(nsIPresContext& aPresContext)
{
mTarget->RemoveEventListener("keypress", mMenuBarListener, PR_TRUE);
mTarget->RemoveEventListener("keydown", mMenuBarListener, PR_TRUE);
mTarget->RemoveEventListener("keyup", mMenuBarListener, PR_TRUE);
delete mMenuBarListener;
mMenuBarListener = nsnull;
return nsToolbarFrame::Destroy(aPresContext);
}

View File

@@ -1,108 +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.
*/
//
// nsMenuBarFrame
//
#ifndef nsMenuBarFrame_h__
#define nsMenuBarFrame_h__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsCOMPtr.h"
#include "nsToolbarFrame.h"
#include "nsMenuBarListener.h"
#include "nsIMenuParent.h"
#include "nsIWidget.h"
class nsIContent;
class nsIMenuFrame;
nsresult NS_NewMenuBarFrame(nsIFrame** aResult) ;
class nsMenuBarFrame : public nsToolbarFrame, public nsIMenuParent
{
public:
nsMenuBarFrame();
~nsMenuBarFrame();
NS_DECL_ISUPPORTS
// nsIMenuParentInterface
NS_IMETHOD SetCurrentMenuItem(nsIMenuFrame* aMenuItem);
NS_IMETHOD GetNextMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult);
NS_IMETHOD GetPreviousMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult);
NS_IMETHOD SetActive(PRBool aActiveFlag);
NS_IMETHOD GetIsActive(PRBool& isActive) { isActive = IsActive(); return NS_OK; };
NS_IMETHOD IsMenuBar(PRBool& isMenuBar) { isMenuBar = PR_TRUE; return NS_OK; };
NS_IMETHOD IsActive() { return mIsActive; };
// Closes up the chain of open cascaded menus.
NS_IMETHOD DismissChain();
// Hides the chain of cascaded menus without closing them up.
NS_IMETHOD HideChain();
NS_IMETHOD GetWidget(nsIWidget **aWidget);
// The dismissal listener gets created and attached to the window.
NS_IMETHOD CreateDismissalListener();
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
NS_IMETHOD Destroy(nsIPresContext& aPresContext);
// Non-interface helpers
// Called when a menu on the menu bar is clicked on.
void ToggleMenuActiveState();
// Used to move up, down, left, and right in menus.
void KeyboardNavigation(PRUint32 aDirection);
// Used to handle ALT+key combos
void ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag);
nsIMenuFrame* FindMenuWithShortcut(PRUint32 aLetter);
// Called when the ESC key is held down to close levels of menus.
void Escape();
// Called to execute a menu item.
void Enter();
PRBool IsValidItem(nsIContent* aContent);
PRBool IsDisabled(nsIContent* aContent);
protected:
nsMenuBarListener* mMenuBarListener; // The listener that tells us about key and mouse events.
PRBool mIsActive; // Whether or not the menu bar is active (a menu item is highlighted or shown).
nsIMenuFrame* mCurrentMenu; // The current menu that is active.
nsIDOMEventReceiver* mTarget;
// XXX Hack
nsIPresContext* mPresContext; // weak reference
}; // class nsMenuBarFrame
#endif

View File

@@ -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.0 (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 Communicator client 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.
*/
#include "nsMenuBarListener.h"
#include "nsMenuBarFrame.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMEventListener.h"
// Drag & Drop, Clipboard
#include "nsIServiceManager.h"
#include "nsWidgetsCID.h"
#include "nsCOMPtr.h"
#include "nsIDOMKeyEvent.h"
#include "nsIPresContext.h"
#include "nsIContent.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsXULAtoms.h"
#include "nsIEventStateManager.h"
#include "nsIViewManager.h"
#include "nsIView.h"
#include "nsISupportsArray.h"
/*
* nsMenuBarListener implementation
*/
NS_IMPL_ADDREF(nsMenuBarListener)
NS_IMPL_RELEASE(nsMenuBarListener)
////////////////////////////////////////////////////////////////////////
nsMenuBarListener::nsMenuBarListener(nsMenuBarFrame* aMenuBar)
:mAltKeyDown(PR_FALSE)
{
NS_INIT_REFCNT();
mMenuBarFrame = aMenuBar;
}
////////////////////////////////////////////////////////////////////////
nsMenuBarListener::~nsMenuBarListener()
{
}
////////////////////////////////////////////////////////////////////////
nsresult
nsMenuBarListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(nsCOMTypeInfo<nsIDOMEventReceiver>::GetIID())) {
*aInstancePtr = (void*)(nsIDOMEventListener*)(nsIDOMKeyListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsIDOMKeyListener>::GetIID())) {
*aInstancePtr = (void*)(nsIDOMKeyListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID())) {
*aInstancePtr = (void*)(nsISupports*)(nsIDOMKeyListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
////////////////////////////////////////////////////////////////////////
nsresult
nsMenuBarListener::KeyUp(nsIDOMEvent* aKeyEvent)
{
// On a press of the ALT key by itself, we toggle the menu's
// active/inactive state.
// Get the ascii key code.
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
PRUint32 theChar;
keyEvent->GetKeyCode(&theChar);
if (theChar == NS_VK_ALT && mAltKeyDown) {
// The ALT key was down and is now up.
mAltKeyDown = PR_FALSE;
mMenuBarFrame->ToggleMenuActiveState();
}
PRBool active = mMenuBarFrame->IsActive();
if (active)
return NS_ERROR_BASE; // I am consuming event
return NS_OK; // means I am NOT consuming event
}
////////////////////////////////////////////////////////////////////////
nsresult
nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent)
{
PRBool active = mMenuBarFrame->IsActive();
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
PRUint32 theChar;
keyEvent->GetKeyCode(&theChar);
if (theChar == NS_VK_ALT) {
// The ALT key just went down. Track this.
mAltKeyDown = PR_TRUE;
return NS_OK;
}
PRBool altKeyWasDown = mAltKeyDown;
mAltKeyDown = PR_FALSE;
if (theChar == NS_VK_LEFT ||
theChar == NS_VK_RIGHT ||
theChar == NS_VK_UP ||
theChar == NS_VK_DOWN) {
// The arrow keys were pressed. User is moving around within
// the menus.
if (active)
mMenuBarFrame->KeyboardNavigation(theChar);
}
else if (theChar == NS_VK_ESCAPE) {
// Close one level.
if (active)
mMenuBarFrame->Escape();
}
else if (theChar == NS_VK_ENTER ||
theChar == NS_VK_RETURN) {
// Open one level.
if (active)
mMenuBarFrame->Enter();
}
else if (active || altKeyWasDown) {
// Get the character code.
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
if (keyEvent) {
// See if a letter was pressed.
PRUint32 charCode;
keyEvent->GetKeyCode(&charCode);
// Do shortcut navigation.
// A letter was pressed. We want to see if a shortcut gets matched. If
// so, we'll know the menu got activated.
mMenuBarFrame->ShortcutNavigation(charCode, active);
}
}
if (active)
return NS_ERROR_BASE; // I am consuming event
return NS_OK; // means I am NOT consuming event
}
////////////////////////////////////////////////////////////////////////
nsresult
nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
{
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
PRBool active = mMenuBarFrame->IsActive();
if (active)
return NS_ERROR_BASE; // I am consuming event
return NS_OK; // means I am NOT consuming event
}
////////////////////////////////////////////////////////////////////////
nsresult
nsMenuBarListener::HandleEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}

View File

@@ -1,56 +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 "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 Communicator client 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.
*/
#ifndef nsMenuBarListener_h__
#define nsMenuBarListener_h__
#include "nsIDOMMouseMotionListener.h"
#include "nsIDOMMouseListener.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMEventReceiver.h"
class nsMenuBarFrame;
class nsIPresContext;
/** editor Implementation of the DragListener interface
*/
class nsMenuBarListener : public nsIDOMKeyListener
{
public:
/** default constructor
*/
nsMenuBarListener(nsMenuBarFrame* aMenuBar);
/** default destructor
*/
virtual ~nsMenuBarListener();
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);
virtual nsresult KeyUp(nsIDOMEvent* aMouseEvent);
virtual nsresult KeyDown(nsIDOMEvent* aMouseEvent);
virtual nsresult KeyPress(nsIDOMEvent* aMouseEvent);
NS_DECL_ISUPPORTS
protected:
nsMenuBarFrame* mMenuBarFrame; // The menu bar object.
PRBool mAltKeyDown; // Whether or not the ALT key is currently down.
};
#endif

View File

@@ -1,140 +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 "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 Communicator client 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.
*/
#include "nsMenuDismissalListener.h"
#include "nsIMenuParent.h"
#include "nsMenuFrame.h"
/*
* nsMenuDismissalListener implementation
*/
NS_IMPL_ADDREF(nsMenuDismissalListener)
NS_IMPL_RELEASE(nsMenuDismissalListener)
////////////////////////////////////////////////////////////////////////
nsMenuDismissalListener::nsMenuDismissalListener() :
mWidget(0), mEnabled(PR_TRUE)
{
NS_INIT_REFCNT();
mMenuParent = nsnull;
}
////////////////////////////////////////////////////////////////////////
nsMenuDismissalListener::~nsMenuDismissalListener()
{
}
////////////////////////////////////////////////////////////////////////
nsresult
nsMenuDismissalListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(nsCOMTypeInfo<nsIDOMEventReceiver>::GetIID())) {
*aInstancePtr = (void*)(nsIDOMEventListener*)(nsIDOMKeyListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsIDOMMouseListener>::GetIID())) {
*aInstancePtr = (void*)(nsIDOMMouseListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsIRollupListener>::GetIID())) {
*aInstancePtr = (void*)(nsIRollupListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID())) {
*aInstancePtr = (void*)(nsISupports*)(nsIDOMMouseListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
////////////////////////////////////////////////////////////////////////
nsresult
nsMenuDismissalListener::MouseDown(nsIDOMEvent* aMouseEvent)
{
return NS_OK;
}
void
nsMenuDismissalListener::SetCurrentMenuParent(nsIMenuParent* aMenuParent)
{
if (aMenuParent == mMenuParent)
return;
nsCOMPtr<nsIRollupListener> kungFuDeathGrip = this;
Unregister();
mMenuParent = aMenuParent;
if (!aMenuParent)
return;
nsCOMPtr<nsIWidget> widget;
aMenuParent->GetWidget(getter_AddRefs(widget));
if (!widget)
return;
widget->CaptureRollupEvents(this, PR_TRUE, PR_FALSE);
mWidget = widget;
NS_ADDREF(nsMenuFrame::mDismissalListener = this);
}
NS_IMETHODIMP
nsMenuDismissalListener::Rollup()
{
if (mEnabled) {
if (mMenuParent) {
AddRef();
mMenuParent->HideChain();
mMenuParent->DismissChain();
Release();
}
else
Unregister();
}
return NS_OK;
}
NS_IMETHODIMP
nsMenuDismissalListener::Unregister()
{
if (mWidget)
mWidget->CaptureRollupEvents(this, PR_FALSE, PR_FALSE);
NS_RELEASE(nsMenuFrame::mDismissalListener);
return NS_OK;
}
NS_IMETHODIMP
nsMenuDismissalListener::EnableListener(PRBool aEnabled)
{
mEnabled = aEnabled;
return NS_OK;
}

View File

@@ -1,67 +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 "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 Communicator client 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.
*/
#ifndef nsMenuDismissalListener_h__
#define nsMenuDismissalListener_h__
#include "nsIWidget.h"
#include "nsIDOMMouseListener.h"
#include "nsIRollupListener.h"
#include "nsIDOMEventReceiver.h"
class nsMenuPopupFrame;
class nsIPresContext;
class nsIMenuParent;
/** editor Implementation of the DragListener interface
*/
class nsMenuDismissalListener : public nsIDOMMouseListener, public nsIRollupListener
{
public:
/** default constructor
*/
nsMenuDismissalListener();
/** default destructor
*/
virtual ~nsMenuDismissalListener();
virtual nsresult HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; };
virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent);
virtual nsresult MouseUp(nsIDOMEvent* aMouseEvent) { return NS_OK; };
virtual nsresult MouseClick(nsIDOMEvent* aMouseEvent) { return NS_OK; };
virtual nsresult MouseDblClick(nsIDOMEvent* aMouseEvent) { return NS_OK; };
virtual nsresult MouseOver(nsIDOMEvent* aMouseEvent) { return NS_OK; };
virtual nsresult MouseOut(nsIDOMEvent* aMouseEvent) { return NS_OK; };
NS_IMETHOD Rollup();
NS_DECL_ISUPPORTS
NS_IMETHOD EnableListener(PRBool aEnabled);
void SetCurrentMenuParent(nsIMenuParent* aMenuParent);
NS_IMETHOD Unregister();
protected:
nsIMenuParent* mMenuParent;
nsIWidget* mWidget;
PRBool mEnabled;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,199 +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.
*/
//
// nsMenuFrame
//
#ifndef nsMenuFrame_h__
#define nsMenuFrame_h__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsCOMPtr.h"
#include "nsIAnonymousContentCreator.h"
#include "nsBoxFrame.h"
#include "nsFrameList.h"
#include "nsIMenuParent.h"
#include "nsIMenuFrame.h"
#include "nsMenuDismissalListener.h"
#include "nsITimer.h"
#include "nsITimerCallback.h"
#include "nsISupportsArray.h"
#include "nsIDOMText.h"
#include "nsIContent.h"
nsresult NS_NewMenuFrame(nsIFrame** aResult, PRUint32 aFlags) ;
class nsMenuBarFrame;
class nsMenuPopupFrame;
class nsMenuFrame : public nsBoxFrame,
public nsIMenuFrame,
public nsITimerCallback,
public nsIAnonymousContentCreator
{
public:
nsMenuFrame();
NS_DECL_ISUPPORTS
// The nsIAnonymousContentCreator interface
NS_IMETHOD CreateAnonymousContent(nsISupportsArray& aAnonymousItems);
// The nsITimerCallback interface
virtual void Notify(nsITimer *timer);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
NS_IMETHOD IsActive(PRBool& aResult) { aResult = PR_TRUE; return NS_OK; };
// The following four methods are all overridden so that the menu children
// can be stored in a separate list (so that they don't impact reflow of the
// actual menu item at all).
NS_IMETHOD FirstChild(nsIAtom* aListName,
nsIFrame** aFirstChild) const;
NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
NS_IMETHOD GetAdditionalChildListName(PRInt32 aIndex,
nsIAtom** aListName) const;
NS_IMETHOD Destroy(nsIPresContext& aPresContext);
// Overridden to prevent events from ever going to children of the menu.
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIFrame** aFrame);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
// Reflow methods
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus);
NS_IMETHOD Dirty(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame*& incrementalChild);
NS_IMETHOD AppendFrames(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aFrameList);
NS_IMETHOD InsertFrames(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
NS_IMETHOD RemoveFrame(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame);
// nsIMenuFrame Interface
NS_IMETHOD ActivateMenu(PRBool aActivateFlag);
NS_IMETHOD SelectMenu(PRBool aActivateFlag);
NS_IMETHOD OpenMenu(PRBool aActivateFlag);
NS_IMETHOD MenuIsOpen(PRBool& aResult) { aResult = IsOpen(); return NS_OK; };
NS_IMETHOD MenuIsContainer(PRBool& aResult) { aResult = IsMenu(); return NS_OK; };
NS_IMETHOD MenuIsChecked(PRBool& aResult) { aResult = mChecked; return NS_OK; };
NS_IMETHOD SelectFirstItem();
NS_IMETHOD Escape(PRBool& aHandledFlag);
NS_IMETHOD Enter();
NS_IMETHOD ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag);
NS_IMETHOD KeyboardNavigation(PRUint32 aDirection, PRBool& aHandledFlag);
NS_IMETHOD GetMenuParent(nsIMenuParent** aResult) { NS_IF_ADDREF(mMenuParent); *aResult = mMenuParent; return NS_OK; };
NS_IMETHOD GetRadioGroupName(nsString &aName) { aName = mGroupName; return NS_OK; };
NS_IMETHOD GetMenuType(nsMenuType &aType) { aType = mType; return NS_OK; };
NS_IMETHOD MarkAsGenerated();
// nsMenuFrame methods
PRBool IsOpen() { return mMenuOpen; };
PRBool IsMenu();
PRBool IsDisabled();
PRBool IsGenerated();
NS_IMETHOD ToggleMenuState();
void SetIsMenu(PRBool aIsMenu) { mIsMenu = aIsMenu; };
protected:
static void UpdateDismissalListener(nsIMenuParent* aMenuParent);
void UpdateMenuType();
void UpdateMenuSpecialState();
void OpenMenuInternal(PRBool aActivateFlag);
void GetMenuChildrenElement(nsIContent** aResult);
// Called to split the accesskey attribute up based on the specified string.
void SplitOnShortcut(nsString& aBeforeString, nsString& aAccessString, nsString& aAfterString);
// Examines the key node and builds the accelerator.
void BuildAcceleratorText(nsString& aAccelString);
// Called to execute our command handler.
void Execute();
// Called as a hook just before the menu gets opened.
PRBool OnCreate();
// Called as a hook just before the menu goes away.
PRBool OnDestroy();
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint);
protected:
nsFrameList mPopupFrames;
PRPackedBool mIsMenu; // Whether or not we can even have children or not.
PRPackedBool mMenuOpen;
PRPackedBool mHasAnonymousContent; // Do we have anonymous content frames?
PRPackedBool mChecked; // if so, are we checked?
nsMenuType mType;
nsCOMPtr<nsIContent> mMenuText;
nsCOMPtr<nsIContent> mAccelText;
nsIMenuParent* mMenuParent; // Our parent menu.
nsCOMPtr<nsITimer> mOpenTimer;
nsIPresContext* mPresContext; // Our pres context.
nsString mGroupName;
public:
static nsMenuDismissalListener* mDismissalListener; // The listener that dismisses menus.
}; // class nsMenuFrame
#endif

View File

@@ -1,757 +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 "nsMenuPopupFrame.h"
#include "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsIContent.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsIPresContext.h"
#include "nsIStyleContext.h"
#include "nsCSSRendering.h"
#include "nsINameSpaceManager.h"
#include "nsIViewManager.h"
#include "nsWidgetsCID.h"
#include "nsMenuFrame.h"
#include "nsIPopupSetFrame.h"
const PRInt32 kMaxZ = 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
// NS_NewMenuPopupFrame
//
// Wrapper for creating a new menu popup container
//
nsresult
NS_NewMenuPopupFrame(nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsMenuPopupFrame* it = new nsMenuPopupFrame;
if ( !it )
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsMenuPopupFrame::AddRef(void)
{
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsMenuPopupFrame::Release(void)
{
return NS_OK;
}
NS_IMETHODIMP nsMenuPopupFrame::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
if (aIID.Equals(nsIMenuParent::GetIID())) {
*aInstancePtr = (void*)(nsIMenuParent*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return nsBoxFrame::QueryInterface(aIID, aInstancePtr);
}
//
// nsMenuPopupFrame cntr
//
nsMenuPopupFrame::nsMenuPopupFrame()
:mCurrentMenu(nsnull)
{
} // cntr
NS_IMETHODIMP
nsMenuPopupFrame::Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
// XXX Hack
mPresContext = &aPresContext;
// We default to being vertical.
nsString value;
mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::align, value);
mHorizontal = PR_FALSE;
if (value.EqualsIgnoreCase("vertical"))
mHorizontal = PR_FALSE;
else if (value.EqualsIgnoreCase("horizontal"))
mHorizontal = PR_TRUE;
CreateViewForFrame(aPresContext, this, aContext, PR_TRUE);
// Now that we've made a view, remove it and insert it at the correct
// position in the view hierarchy (as the root view). We do this so that we
// can draw the menus outside the confines of the window.
nsIView* ourView;
GetView(&aPresContext, &ourView);
nsIFrame* parent;
aParent->GetParentWithView(&aPresContext, &parent);
nsIView* parentView;
parent->GetView(&aPresContext, &parentView);
nsCOMPtr<nsIViewManager> viewManager;
parentView->GetViewManager(*getter_AddRefs(viewManager));
// Remove the view from its old position.
viewManager->RemoveChild(parentView, ourView);
// Reinsert ourselves as the root view with a maximum z-index.
nsIView* rootView;
viewManager->GetRootView(rootView);
viewManager->InsertChild(rootView, ourView, kMaxZ);
// XXX Hack. Change our transparency to be non-transparent
// until the bug related to update of transparency on show/hide
// is fixed.
viewManager->SetViewContentTransparency(ourView, PR_FALSE);
// Create a widget for ourselves.
nsWidgetInitData widgetData;
ourView->SetZIndex(kMaxZ);
widgetData.mWindowType = eWindowType_popup;
widgetData.mBorderStyle = eBorderStyle_default;
// XXX make sure we are hidden (shouldn't this be done automatically?)
ourView->SetVisibility(nsViewVisibility_kHide);
#ifdef XP_MAC
printf("XP Popups: This is a nag to indicate that an inconsistent hack is being done on the Mac for popups.\n");
static NS_DEFINE_IID(kCPopupCID, NS_POPUP_CID);
ourView->CreateWidget(kCPopupCID, &widgetData, nsnull);
#else
static NS_DEFINE_IID(kCChildCID, NS_CHILD_CID);
ourView->CreateWidget(kCChildCID, &widgetData, nsnull);
#endif
return rv;
}
void
nsMenuPopupFrame::GetViewOffset(nsIViewManager* aManager, nsIView* aView,
nsPoint& aPoint)
{
aPoint.x = 0;
aPoint.y = 0;
nsIView *parent;
nsRect bounds;
parent = aView;
while (nsnull != parent) {
parent->GetBounds(bounds);
aPoint.x += bounds.x;
aPoint.y += bounds.y;
parent->GetParent(parent);
}
}
void
nsMenuPopupFrame::GetNearestEnclosingView(nsIPresContext* aPresContext, nsIFrame* aStartFrame, nsIView** aResult)
{
*aResult = nsnull;
aStartFrame->GetView(aPresContext, aResult);
if (!*aResult) {
nsIFrame* parent;
aStartFrame->GetParentWithView(aPresContext, &parent);
if (parent)
parent->GetView(aPresContext, aResult);
}
}
nsresult
nsMenuPopupFrame::SyncViewWithFrame(nsIPresContext& aPresContext,
PRBool aOnMenuBar,
nsIFrame* aFrame,
PRInt32 aXPos, PRInt32 aYPos)
{
nsPoint parentPos;
nsCOMPtr<nsIViewManager> viewManager;
//Get the nearest enclosing parent view to aFrame.
nsIView* parentView = nsnull;
GetNearestEnclosingView(&aPresContext, aFrame, &parentView);
if (!parentView)
return NS_OK;
parentView->GetViewManager(*getter_AddRefs(viewManager));
GetViewOffset(viewManager, parentView, parentPos);
nsIView* view = nsnull;
GetView(&aPresContext, &view);
nsIView* containingView = nsnull;
nsPoint offset;
aFrame->GetOffsetFromView(&aPresContext, offset, &containingView);
nsRect parentRect;
aFrame->GetRect(parentRect);
const nsStyleDisplay* disp;
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) disp);
PRBool viewIsVisible = (NS_STYLE_VISIBILITY_VISIBLE == disp->mVisible);
nsViewVisibility oldVisibility;
view->GetVisibility(oldVisibility);
PRBool viewWasVisible = (oldVisibility == nsViewVisibility_kShow);
if (viewWasVisible && (! viewIsVisible)) {
view->SetVisibility(nsViewVisibility_kHide);
}
viewManager->ResizeView(view, mRect.width, mRect.height);
if (aXPos != -1 || aYPos != -1) {
// Convert the screen coords to twips
float p2t;
aPresContext.GetScaledPixelsToTwips(&p2t);
PRInt32 xpos = NSIntPixelsToTwips(aXPos, p2t);
PRInt32 ypos = NSIntPixelsToTwips(aYPos, p2t);
viewManager->MoveViewTo(view, xpos, ypos);
}
else if (aOnMenuBar)
viewManager->MoveViewTo(view, parentPos.x + offset.x, parentPos.y + parentRect.height + offset.y );
else viewManager->MoveViewTo(view, parentPos.x + parentRect.width + offset.x, parentPos.y + offset.y );
if ((! viewWasVisible) && viewIsVisible) {
view->SetVisibility(nsViewVisibility_kShow);
}
return NS_OK;
}
NS_IMETHODIMP
nsMenuPopupFrame::DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus)
{
// Copied from nsContainerFrame reflow WITHOUT the call
// nsFrame::DidReflow(). nsFrame::DidReflow() will move us to the
// wrong place.
nsresult result = NS_OK; /* = nsFrame::DidReflow(aPresContext, aStatus) */
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
// Apply DidReflow to each and every list that this frame implements
nsIAtom* listName = nsnull;
PRInt32 listIndex = 0;
do {
nsIFrame* kid;
FirstChild(listName, &kid);
while (nsnull != kid) {
kid->DidReflow(aPresContext, aStatus);
kid->GetNextSibling(&kid);
}
NS_IF_RELEASE(listName);
GetAdditionalChildListName(listIndex++, &listName);
} while(nsnull != listName);
}
NS_FRAME_TRACE_OUT("nsContainerFrame::DidReflow");
return result;
}
NS_IMETHODIMP
nsMenuPopupFrame::GetNextMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult)
{
nsIFrame* currFrame = nsnull;
nsIFrame* startFrame = nsnull;
if (aStart) {
aStart->QueryInterface(kIFrameIID, (void**)&currFrame);
if (currFrame) {
startFrame = currFrame;
currFrame->GetNextSibling(&currFrame);
}
}
else currFrame = mFrames.FirstChild();
while (currFrame) {
nsCOMPtr<nsIContent> current;
currFrame->GetContent(getter_AddRefs(current));
// See if it's a menu item.
if (IsValidItem(current)) {
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(currFrame);
*aResult = menuFrame.get();
NS_IF_ADDREF(*aResult);
return NS_OK;
}
currFrame->GetNextSibling(&currFrame);
}
currFrame = mFrames.FirstChild();
// Still don't have anything. Try cycling from the beginning.
while (currFrame && currFrame != startFrame) {
nsCOMPtr<nsIContent> current;
currFrame->GetContent(getter_AddRefs(current));
// See if it's a menu item.
if (IsValidItem(current)) {
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(currFrame);
*aResult = menuFrame.get();
NS_IF_ADDREF(*aResult);
return NS_OK;
}
currFrame->GetNextSibling(&currFrame);
}
// No luck. Just return our start value.
*aResult = aStart;
return NS_OK;
}
NS_IMETHODIMP
nsMenuPopupFrame::GetPreviousMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult)
{
nsIFrame* currFrame = nsnull;
nsIFrame* startFrame = nsnull;
if (aStart) {
aStart->QueryInterface(kIFrameIID, (void**)&currFrame);
if (currFrame) {
startFrame = currFrame;
currFrame = mFrames.GetPrevSiblingFor(currFrame);
}
}
else currFrame = mFrames.LastChild();
while (currFrame) {
nsCOMPtr<nsIContent> current;
currFrame->GetContent(getter_AddRefs(current));
// See if it's a menu item.
if (IsValidItem(current)) {
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(currFrame);
*aResult = menuFrame.get();
NS_IF_ADDREF(*aResult);
return NS_OK;
}
currFrame = mFrames.GetPrevSiblingFor(currFrame);
}
currFrame = mFrames.LastChild();
// Still don't have anything. Try cycling from the end.
while (currFrame && currFrame != startFrame) {
nsCOMPtr<nsIContent> current;
currFrame->GetContent(getter_AddRefs(current));
// See if it's a menu item.
if (IsValidItem(current)) {
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(currFrame);
*aResult = menuFrame.get();
NS_IF_ADDREF(*aResult);
return NS_OK;
}
currFrame = mFrames.GetPrevSiblingFor(currFrame);
}
// No luck. Just return our start value.
*aResult = aStart;
return NS_OK;
}
NS_IMETHODIMP nsMenuPopupFrame::SetCurrentMenuItem(nsIMenuFrame* aMenuItem)
{
if (mCurrentMenu == aMenuItem)
return NS_OK;
// Unset the current child.
if (mCurrentMenu) {
PRBool isOpen = PR_FALSE;
mCurrentMenu->MenuIsOpen(isOpen);
mCurrentMenu->SelectMenu(PR_FALSE);
if (isOpen)
mCurrentMenu->OpenMenu(PR_FALSE);
}
// Set the new child.
if (aMenuItem) {
aMenuItem->SelectMenu(PR_TRUE);
}
mCurrentMenu = aMenuItem;
return NS_OK;
}
NS_IMETHODIMP
nsMenuPopupFrame::CaptureMouseEvents(nsIPresContext* aPresContext, PRBool aGrabMouseEvents)
{
// get its view
nsIView* view = nsnull;
GetView(aPresContext, &view);
nsCOMPtr<nsIViewManager> viewMan;
PRBool result;
nsCOMPtr<nsIWidget> widget;
if (view) {
view->GetViewManager(*getter_AddRefs(viewMan));
if (viewMan) {
view->GetWidget(*getter_AddRefs(widget));
if (aGrabMouseEvents) {
viewMan->GrabMouseEvents(view,result);
mIsCapturingMouseEvents = PR_TRUE;
//widget->CaptureMouse(PR_TRUE);
} else {
viewMan->GrabMouseEvents(nsnull,result);
mIsCapturingMouseEvents = PR_FALSE;
//widget->CaptureMouse(PR_FALSE);
}
}
}
return NS_OK;
}
void
nsMenuPopupFrame::Escape(PRBool& aHandledFlag)
{
if (!mCurrentMenu)
return;
// See if our menu is open.
PRBool isOpen = PR_FALSE;
mCurrentMenu->MenuIsOpen(isOpen);
if (isOpen) {
// Let the child menu handle this.
mCurrentMenu->Escape(aHandledFlag);
if (!aHandledFlag) {
// We should close up.
mCurrentMenu->OpenMenu(PR_FALSE);
aHandledFlag = PR_TRUE;
}
return;
}
}
void
nsMenuPopupFrame::Enter()
{
// Give it to the child.
if (mCurrentMenu)
mCurrentMenu->Enter();
}
nsIMenuFrame*
nsMenuPopupFrame::FindMenuWithShortcut(PRUint32 aLetter)
{
// Enumerate over our list of frames.
nsIFrame* currFrame = mFrames.FirstChild();
while (currFrame) {
nsCOMPtr<nsIContent> current;
currFrame->GetContent(getter_AddRefs(current));
// See if it's a menu item.
if (IsValidItem(current)) {
// Get the shortcut attribute.
nsString shortcutKey = "";
current->GetAttribute(kNameSpaceID_None, nsXULAtoms::accesskey, shortcutKey);
shortcutKey.ToUpperCase();
if (shortcutKey.Length() > 0) {
// We've got something.
PRUnichar shortcutChar = shortcutKey.CharAt(0);
if (shortcutChar == aLetter) {
// We match!
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(currFrame);
if (menuFrame)
return menuFrame.get();
return nsnull;
}
}
}
currFrame->GetNextSibling(&currFrame);
}
return nsnull;
}
void
nsMenuPopupFrame::ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag)
{
if (mCurrentMenu) {
PRBool isOpen = PR_FALSE;
mCurrentMenu->MenuIsOpen(isOpen);
if (isOpen) {
// No way this applies to us. Give it to our child.
mCurrentMenu->ShortcutNavigation(aLetter, aHandledFlag);
return;
}
}
// This applies to us. Let's see if one of the shortcuts applies
nsIMenuFrame* result = FindMenuWithShortcut(aLetter);
if (result) {
// We got one!
aHandledFlag = PR_TRUE;
SetCurrentMenuItem(result);
result->OpenMenu(PR_TRUE);
result->SelectFirstItem();
// XXX For menu items, do an execution of the oncommand handler!
// Still needed or did I do this already? I'm going senile. - Dave
}
}
void
nsMenuPopupFrame::KeyboardNavigation(PRUint32 aDirection, PRBool& aHandledFlag)
{
// This method only gets called if we're open.
if (!mCurrentMenu && (aDirection == NS_VK_RIGHT || aDirection == NS_VK_LEFT)) {
// We've been opened, but we haven't had anything selected.
// We can handle RIGHT, but our parent handles LEFT.
if (aDirection == NS_VK_RIGHT) {
nsIMenuFrame* nextItem;
GetNextMenuItem(nsnull, &nextItem);
if (nextItem) {
aHandledFlag = PR_TRUE;
SetCurrentMenuItem(nextItem);
}
}
return;
}
PRBool isContainer = PR_FALSE;
PRBool isOpen = PR_FALSE;
if (mCurrentMenu) {
mCurrentMenu->MenuIsContainer(isContainer);
mCurrentMenu->MenuIsOpen(isOpen);
if (isOpen) {
// Give our child a shot.
mCurrentMenu->KeyboardNavigation(aDirection, aHandledFlag);
}
else if (aDirection == NS_VK_RIGHT && isContainer) {
// The menu is not yet open. Open it and select the first item.
aHandledFlag = PR_TRUE;
mCurrentMenu->OpenMenu(PR_TRUE);
mCurrentMenu->SelectFirstItem();
}
}
if (aHandledFlag)
return; // The child menu took it for us.
// For the vertical direction, we can move up or down.
if (aDirection == NS_VK_UP || aDirection == NS_VK_DOWN) {
nsIMenuFrame* nextItem;
if (aDirection == NS_VK_DOWN)
GetNextMenuItem(mCurrentMenu, &nextItem);
else GetPreviousMenuItem(mCurrentMenu, &nextItem);
SetCurrentMenuItem(nextItem);
aHandledFlag = PR_TRUE;
}
else if (mCurrentMenu && isContainer && isOpen) {
if (aDirection == NS_VK_LEFT) {
// Close it up.
mCurrentMenu->OpenMenu(PR_FALSE);
aHandledFlag = PR_TRUE;
}
}
}
NS_IMETHODIMP
nsMenuPopupFrame::GetParentPopup(nsIMenuParent** aMenuParent)
{
*aMenuParent = nsnull;
nsIFrame* frame;
GetParent(&frame);
if (frame) {
nsIFrame* grandparent;
frame->GetParent(&grandparent);
if (grandparent) {
nsCOMPtr<nsIMenuParent> menuParent = do_QueryInterface(grandparent);
if (menuParent) {
*aMenuParent = menuParent.get();
NS_ADDREF(*aMenuParent);
}
}
}
return NS_OK;
}
NS_IMETHODIMP
nsMenuPopupFrame::HideChain()
{
// Stop capturing rollups
// (must do this during Hide, which happens before the menu item is executed,
// since this reinstates normal event handling.)
if (nsMenuFrame::mDismissalListener)
nsMenuFrame::mDismissalListener->Unregister();
nsIFrame* frame;
GetParent(&frame);
if (frame) {
nsCOMPtr<nsIPopupSetFrame> popupSetFrame = do_QueryInterface(frame);
if (popupSetFrame) {
// Destroy the popup.
popupSetFrame->HidePopup();
return NS_OK;
}
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(frame);
if (!menuFrame)
return NS_OK;
menuFrame->ActivateMenu(PR_FALSE);
menuFrame->SelectMenu(PR_FALSE);
// Get the parent.
nsCOMPtr<nsIMenuParent> menuParent;
menuFrame->GetMenuParent(getter_AddRefs(menuParent));
if (menuParent)
menuParent->HideChain();
}
return NS_OK;
}
NS_IMETHODIMP
nsMenuPopupFrame::DismissChain()
{
// Stop capturing rollups
if (nsMenuFrame::mDismissalListener)
nsMenuFrame::mDismissalListener->Unregister();
// Get our menu parent.
nsIFrame* frame;
GetParent(&frame);
if (frame) {
nsCOMPtr<nsIPopupSetFrame> popupSetFrame = do_QueryInterface(frame);
if (popupSetFrame) {
// Destroy the popup.
popupSetFrame->DestroyPopup();
return NS_OK;
}
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(frame);
if (!menuFrame)
return NS_OK;
menuFrame->OpenMenu(PR_FALSE);
// Get the parent.
nsCOMPtr<nsIMenuParent> menuParent;
menuFrame->GetMenuParent(getter_AddRefs(menuParent));
if (menuParent)
menuParent->DismissChain();
}
return NS_OK;
}
NS_IMETHODIMP
nsMenuPopupFrame::GetWidget(nsIWidget **aWidget)
{
// Get parent view
nsIView * view = nsnull;
nsMenuPopupFrame::GetNearestEnclosingView(mPresContext, this, &view);
if (!view)
return NS_OK;
view->GetWidget(*aWidget);
return NS_OK;
}
NS_IMETHODIMP
nsMenuPopupFrame::CreateDismissalListener()
{
nsMenuDismissalListener *listener = new nsMenuDismissalListener();
if (!listener) return NS_ERROR_OUT_OF_MEMORY;
nsMenuFrame::mDismissalListener = listener;
NS_ADDREF(listener);
return NS_OK;
}
PRBool
nsMenuPopupFrame::IsValidItem(nsIContent* aContent)
{
nsCOMPtr<nsIAtom> tag;
aContent->GetTag(*getter_AddRefs(tag));
if (tag && (tag.get() == nsXULAtoms::menu ||
tag.get() == nsXULAtoms::menuitem) &&
!IsDisabled(aContent))
return PR_TRUE;
return PR_FALSE;
}
PRBool
nsMenuPopupFrame::IsDisabled(nsIContent* aContent)
{
nsString disabled = "";
aContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::disabled, disabled);
if (disabled == "true")
return PR_TRUE;
return PR_FALSE;
}
NS_IMETHODIMP
nsMenuPopupFrame::HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
return nsBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
NS_IMETHODIMP
nsMenuPopupFrame::Destroy(nsIPresContext& aPresContext)
{
//nsCOMPtr<nsIDOMEventReceiver> target = do_QueryInterface(mContent);
//target->RemoveEventListener("mousemove", mMenuPopupEntryListener, PR_TRUE);
return nsBoxFrame::Destroy(aPresContext);
}
NS_IMETHODIMP
nsMenuPopupFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIFrame** aFrame)
{
nsRect rect;
GetRect(rect);
if (rect.Contains(aPoint)) {
return nsBoxFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
}
*aFrame = this;
return NS_OK;
}

View File

@@ -1,113 +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.
*/
//
// nsMenuPopupFrame
//
#ifndef nsMenuPopupFrame_h__
#define nsMenuPopupFrame_h__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsCOMPtr.h"
#include "nsBoxFrame.h"
#include "nsIMenuParent.h"
#include "nsIWidget.h"
nsresult NS_NewMenuPopupFrame(nsIFrame** aResult) ;
class nsIViewManager;
class nsIView;
class nsIMenuParent;
class nsIMenuFrame;
class nsMenuPopupFrame : public nsBoxFrame, public nsIMenuParent
{
public:
nsMenuPopupFrame();
NS_DECL_ISUPPORTS
// nsIMenuParentInterface
NS_IMETHOD SetCurrentMenuItem(nsIMenuFrame* aMenuItem);
NS_IMETHOD GetNextMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult);
NS_IMETHOD GetPreviousMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult);
NS_IMETHOD SetActive(PRBool aActiveFlag) { return NS_OK; }; // We don't care.
NS_IMETHOD GetIsActive(PRBool& isActive) { isActive = PR_FALSE; return NS_OK; };
NS_IMETHOD IsMenuBar(PRBool& isMenuBar) { isMenuBar = PR_FALSE; return NS_OK; };
NS_IMETHOD GetParentPopup(nsIMenuParent** aResult);
// Closes up the chain of open cascaded menus.
NS_IMETHOD DismissChain();
// Hides the chain of cascaded menus without closing them up.
NS_IMETHOD HideChain();
NS_IMETHOD GetWidget(nsIWidget **aWidget);
// The dismissal listener gets created and attached to the window.
NS_IMETHOD CreateDismissalListener();
// Overridden methods
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD Destroy(nsIPresContext& aPresContext);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
void GetViewOffset(nsIViewManager* aManager, nsIView* aView, nsPoint& aPoint);
static void GetNearestEnclosingView(nsIPresContext* aPresContext, nsIFrame* aStartFrame, nsIView** aResult);
nsresult SyncViewWithFrame(nsIPresContext& aPresContext, PRBool aOnMenuBar,
nsIFrame* aFrame, PRInt32 aXPos, PRInt32 aYPos);
NS_IMETHOD CaptureMouseEvents(nsIPresContext* aPresContext, PRBool aGrabMouseEvents);
void KeyboardNavigation(PRUint32 aDirection, PRBool& aHandledFlag);
void ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag);
nsIMenuFrame* FindMenuWithShortcut(PRUint32 aLetter);
void Escape(PRBool& aHandledFlag);
void Enter();
PRBool IsValidItem(nsIContent* aContent);
PRBool IsDisabled(nsIContent* aContent);
protected:
nsIMenuFrame* mCurrentMenu; // The current menu that is active.
PRBool mIsCapturingMouseEvents; // Whether or not we're grabbing the mouse events.
// XXX Hack
nsIPresContext* mPresContext; // weak reference
}; // class nsMenuPopupFrame
#endif

View File

@@ -1,547 +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 "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsPopupSetFrame.h"
#include "nsIMenuParent.h"
#include "nsMenuFrame.h"
#include "nsBoxFrame.h"
#include "nsIContent.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsIPresContext.h"
#include "nsIStyleContext.h"
#include "nsIReflowCommand.h"
#include "nsCSSRendering.h"
#include "nsINameSpaceManager.h"
#include "nsLayoutAtoms.h"
#include "nsMenuPopupFrame.h"
#include "nsMenuBarFrame.h"
#include "nsIView.h"
#include "nsIWidget.h"
#include "nsIDocument.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMXULDocument.h"
#include "nsIDOMElement.h"
#include "nsISupportsArray.h"
#include "nsIDOMText.h"
#define NS_MENU_POPUP_LIST_INDEX (NS_AREA_FRAME_ABSOLUTE_LIST_INDEX + 1)
//
// NS_NewPopupSetFrame
//
// Wrapper for creating a new menu popup container
//
nsresult
NS_NewPopupSetFrame(nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsPopupSetFrame* it = new nsPopupSetFrame;
if ( !it )
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsPopupSetFrame::AddRef(void)
{
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsPopupSetFrame::Release(void)
{
return NS_OK;
}
NS_IMETHODIMP nsPopupSetFrame::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
if (aIID.Equals(nsIPopupSetFrame::GetIID())) {
*aInstancePtr = (void*)(nsIPopupSetFrame*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return nsBoxFrame::QueryInterface(aIID, aInstancePtr);
}
//
// nsPopupSetFrame cntr
//
nsPopupSetFrame::nsPopupSetFrame()
:mPresContext(nsnull), mElementFrame(nsnull)
{
} // cntr
nsIFrame*
nsPopupSetFrame::GetActiveChild()
{
return mPopupFrames.FirstChild();
}
NS_IMETHODIMP
nsPopupSetFrame::Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
mPresContext = &aPresContext; // Don't addref it. Our lifetime is shorter.
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
return rv;
}
// The following methods are all overridden to ensure that the menupopup frames
// are placed in the appropriate list.
NS_IMETHODIMP
nsPopupSetFrame::FirstChild(nsIAtom* aListName,
nsIFrame** aFirstChild) const
{
if (nsLayoutAtoms::popupList == aListName) {
*aFirstChild = mPopupFrames.FirstChild();
} else {
nsBoxFrame::FirstChild(aListName, aFirstChild);
}
return NS_OK;
}
NS_IMETHODIMP
nsPopupSetFrame::SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList)
{
nsresult rv = NS_OK;
if (nsLayoutAtoms::popupList == aListName) {
mPopupFrames.SetFrames(aChildList);
} else {
nsFrameList frames(aChildList);
// We may have menupopups in here. Get them out, and move them into
// the popup frame list.
nsIFrame* frame = frames.FirstChild();
while (frame) {
nsCOMPtr<nsIContent> content;
frame->GetContent(getter_AddRefs(content));
nsCOMPtr<nsIAtom> tag;
content->GetTag(*getter_AddRefs(tag));
if (tag.get() == nsXULAtoms::popup) {
// Remove this frame from the list and place it in the other list.
frames.RemoveFrame(frame);
mPopupFrames.AppendFrame(this, frame);
nsIFrame* first = frames.FirstChild();
rv = nsBoxFrame::SetInitialChildList(aPresContext, aListName, first);
return rv;
}
frame->GetNextSibling(&frame);
}
// Didn't find it.
rv = nsBoxFrame::SetInitialChildList(aPresContext, aListName, aChildList);
}
return rv;
}
NS_IMETHODIMP
nsPopupSetFrame::GetAdditionalChildListName(PRInt32 aIndex,
nsIAtom** aListName) const
{
// Maintain a separate child list for the menu contents.
// This is necessary because we don't want the menu contents to be included in the layout
// of the menu's single item because it would take up space, when it is supposed to
// be floating above the display.
/*NS_PRECONDITION(nsnull != aListName, "null OUT parameter pointer");
*aListName = nsnull;
if (NS_MENU_POPUP_LIST_INDEX == aIndex) {
*aListName = nsLayoutAtoms::popupList;
NS_ADDREF(*aListName);
return NS_OK;
}*/
return nsBoxFrame::GetAdditionalChildListName(aIndex, aListName);
}
NS_IMETHODIMP
nsPopupSetFrame::Destroy(nsIPresContext& aPresContext)
{
// Cleanup frames in popup child list
mPopupFrames.DestroyFrames(aPresContext);
return nsBoxFrame::Destroy(aPresContext);
}
NS_IMETHODIMP
nsPopupSetFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
nsresult rv = nsBoxFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
nsIFrame* frame = GetActiveChild();
if (!frame || (rv != NS_OK))
return rv;
// Constrain the child's width and height to aAvailableWidth and aAvailableHeight
nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, frame,
availSize);
kidReflowState.mComputedWidth = NS_UNCONSTRAINEDSIZE;
kidReflowState.mComputedHeight = NS_UNCONSTRAINEDSIZE;
// Reflow child
nscoord w = aDesiredSize.width;
nscoord h = aDesiredSize.height;
rv = ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, aStatus);
// Set the child's width and height to its desired size
nsRect rect;
frame->GetRect(rect);
rect.width = aDesiredSize.width;
rect.height = aDesiredSize.height;
frame->SetRect(&aPresContext, rect);
// Don't let it affect our size.
aDesiredSize.width = w;
aDesiredSize.height = h;
return rv;
}
NS_IMETHODIMP
nsPopupSetFrame::DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus)
{
// Sync up the view.
nsIFrame* activeChild = GetActiveChild();
if (activeChild) {
((nsMenuPopupFrame*)activeChild)->SyncViewWithFrame(aPresContext, PR_TRUE, mElementFrame, mXPos, mYPos);
}
return nsBoxFrame::DidReflow(aPresContext, aStatus);
}
// Overridden Box method.
NS_IMETHODIMP
nsPopupSetFrame::Dirty(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame*& incrementalChild)
{
incrementalChild = nsnull;
nsresult rv = NS_OK;
// Dirty any children that need it.
nsIFrame* frame;
aReflowState.reflowCommand->GetNext(frame, PR_FALSE);
if (frame == nsnull) {
incrementalChild = this;
return rv;
}
// Now call our original box frame method
rv = nsBoxFrame::Dirty(aPresContext, aReflowState, incrementalChild);
if (rv != NS_OK || incrementalChild)
return rv;
nsIFrame* popup = GetActiveChild();
if (popup && (frame == popup)) {
// An incremental reflow command is targeting something inside our
// hidden popup view. We can't actually return the child, since it
// won't ever be found by box. Instead return ourselves, so that box
// will later send us an incremental reflow command.
incrementalChild = this;
// In order for the child box to know what it needs to reflow, we need
// to call its Dirty method...
nsIFrame* ignore;
nsIBox* ibox;
if (NS_SUCCEEDED(popup->QueryInterface(nsIBox::GetIID(), (void**)&ibox)) && ibox)
ibox->Dirty(aPresContext, aReflowState, ignore);
}
return rv;
}
NS_IMETHODIMP
nsPopupSetFrame::RemoveFrame(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame)
{
// need to rebuild all the springs.
for (int i=0; i < mSpringCount; i++)
mSprings[i].clear();
nsresult rv;
if (mPopupFrames.ContainsFrame(aOldFrame)) {
// Go ahead and remove this frame.
mPopupFrames.DestroyFrame(aPresContext, aOldFrame);
rv = GenerateDirtyReflowCommand(aPresContext, aPresShell);
} else {
rv = nsBoxFrame::RemoveFrame(aPresContext, aPresShell, aListName, aOldFrame);
}
return rv;
}
NS_IMETHODIMP
nsPopupSetFrame::InsertFrames(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
{
// need to rebuild all the springs.
for (int i=0; i < mSpringCount; i++)
mSprings[i].clear();
nsCOMPtr<nsIContent> frameChild;
aFrameList->GetContent(getter_AddRefs(frameChild));
nsCOMPtr<nsIAtom> tag;
nsresult rv;
frameChild->GetTag(*getter_AddRefs(tag));
if (tag && tag.get() == nsXULAtoms::popup) {
mPopupFrames.InsertFrames(nsnull, nsnull, aFrameList);
rv = GenerateDirtyReflowCommand(aPresContext, aPresShell);
} else {
rv = nsBoxFrame::InsertFrames(aPresContext, aPresShell, aListName, aPrevFrame, aFrameList);
}
return rv;
}
NS_IMETHODIMP
nsPopupSetFrame::AppendFrames(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aFrameList)
{
if (!aFrameList)
return NS_OK;
// need to rebuild all the springs.
for (int i=0; i < mSpringCount; i++)
mSprings[i].clear();
nsCOMPtr<nsIContent> frameChild;
aFrameList->GetContent(getter_AddRefs(frameChild));
nsCOMPtr<nsIAtom> tag;
nsresult rv;
frameChild->GetTag(*getter_AddRefs(tag));
if (tag && tag.get() == nsXULAtoms::popup) {
mPopupFrames.AppendFrames(nsnull, aFrameList);
rv = GenerateDirtyReflowCommand(aPresContext, aPresShell);
} else {
rv = nsBoxFrame::AppendFrames(aPresContext, aPresShell, aListName, aFrameList);
}
return rv;
}
NS_IMETHODIMP
nsPopupSetFrame::CreatePopup(nsIFrame* aElementFrame, nsIContent* aPopupContent,
PRInt32 aXPos, PRInt32 aYPos,
const nsString& aPopupType, const nsString& anAnchorAlignment,
const nsString& aPopupAlignment)
{
// Cache the element frame.
mElementFrame = aElementFrame;
// Show the popup at the specified position.
mXPos = aXPos;
mYPos = aYPos;
printf("X Pos: %d\n", mXPos);
printf("Y Pos: %d\n", mYPos);
if (!OnCreate(aPopupContent))
return NS_OK;
// Generate the popup.
MarkAsGenerated(aPopupContent);
// Now we'll have it in our child frame list.
// Now open the popup.
OpenPopup(PR_TRUE);
return NS_OK;
}
NS_IMETHODIMP
nsPopupSetFrame::HidePopup()
{
ActivatePopup(PR_FALSE);
return NS_OK;
}
NS_IMETHODIMP
nsPopupSetFrame::DestroyPopup()
{
OpenPopup(PR_FALSE);
return NS_OK;
}
void
nsPopupSetFrame::MarkAsGenerated(nsIContent* aPopupContent)
{
// Ungenerate all other popups in the set. No more than one can exist
// at any point in time.
PRInt32 childCount;
mContent->ChildCount(childCount);
for (PRInt32 i = 0; i < childCount; i++) {
nsCOMPtr<nsIContent> childContent;
mContent->ChildAt(i, *getter_AddRefs(childContent));
// Retrieve the menugenerated attribute.
nsAutoString value;
childContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::menugenerated,
value);
if (value == "true") {
// Ungenerate this element.
childContent->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menugenerated,
PR_TRUE);
}
}
// Set our attribute, but only if we aren't already generated.
// Retrieve the menugenerated attribute.
nsAutoString value;
aPopupContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::menugenerated,
value);
if (value != "true") {
// Generate this element.
aPopupContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::menugenerated, "true",
PR_TRUE);
}
}
void
nsPopupSetFrame::OpenPopup(PRBool aActivateFlag)
{
if (aActivateFlag) {
ActivatePopup(PR_TRUE);
nsIFrame* activeChild = GetActiveChild();
nsCOMPtr<nsIMenuParent> childPopup = do_QueryInterface(activeChild);
UpdateDismissalListener(childPopup);
}
else {
if (!OnDestroy())
return;
// Unregister.
if (nsMenuFrame::mDismissalListener) {
nsMenuFrame::mDismissalListener->Unregister();
}
ActivatePopup(PR_FALSE);
}
}
void
nsPopupSetFrame::ActivatePopup(PRBool aActivateFlag)
{
nsCOMPtr<nsIContent> content;
GetActiveChildElement(getter_AddRefs(content));
if (content) {
if (aActivateFlag)
content->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
else content->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
}
}
PRBool
nsPopupSetFrame::OnCreate(nsIContent* aPopupContent)
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_MENU_CREATE;
if (aPopupContent) {
nsresult rv = aPopupContent->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault )
return PR_FALSE;
}
return PR_TRUE;
}
PRBool
nsPopupSetFrame::OnDestroy()
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_MENU_DESTROY;
nsCOMPtr<nsIContent> content;
GetActiveChildElement(getter_AddRefs(content));
if (content) {
nsresult rv = content->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault )
return PR_FALSE;
}
return PR_TRUE;
}
void
nsPopupSetFrame::GetActiveChildElement(nsIContent** aResult)
{
*aResult = nsnull;
nsIFrame* child = GetActiveChild();
if (child) {
child->GetContent(aResult);
}
}
void
nsPopupSetFrame::UpdateDismissalListener(nsIMenuParent* aMenuParent)
{
if (!nsMenuFrame::mDismissalListener) {
if (!aMenuParent)
return;
// Create the listener and attach it to the outermost window.
aMenuParent->CreateDismissalListener();
}
// Make sure the menu dismissal listener knows what the current
// innermost menu popup frame is.
nsMenuFrame::mDismissalListener->SetCurrentMenuParent(aMenuParent);
}

View File

@@ -1,125 +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.
*/
//
// nsPopupSetFrame
//
#ifndef nsPopupSetFrame_h__
#define nsPopupSetFrame_h__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsCOMPtr.h"
#include "nsIPopupSetFrame.h"
#include "nsIAnonymousContentCreator.h"
#include "nsBoxFrame.h"
#include "nsFrameList.h"
#include "nsIMenuParent.h"
#include "nsITimer.h"
#include "nsITimerCallback.h"
#include "nsISupportsArray.h"
nsresult NS_NewPopupSetFrame(nsIFrame** aResult) ;
class nsPopupSetFrame : public nsBoxFrame, public nsIPopupSetFrame
{
public:
nsPopupSetFrame();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
// The following four methods are all overridden so that the menu children
// can be stored in a separate list (so that they don't impact reflow of the
// actual menu item at all).
NS_IMETHOD FirstChild(nsIAtom* aListName,
nsIFrame** aFirstChild) const;
NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
NS_IMETHOD GetAdditionalChildListName(PRInt32 aIndex,
nsIAtom** aListName) const;
NS_IMETHOD Destroy(nsIPresContext& aPresContext);
// Reflow methods
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus);
NS_IMETHOD Dirty(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame*& incrementalChild);
NS_IMETHOD AppendFrames(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aFrameList);
NS_IMETHOD InsertFrames(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
NS_IMETHOD RemoveFrame(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame);
NS_IMETHOD CreatePopup(nsIFrame* aElementFrame, nsIContent* aPopupContent,
PRInt32 aXPos, PRInt32 aYPos,
const nsString& aPopupType, const nsString& anAnchorAlignment,
const nsString& aPopupAlignment);
NS_IMETHOD HidePopup();
NS_IMETHOD DestroyPopup();
PRBool OnCreate(nsIContent* aPopupContent);
PRBool OnDestroy();
void ActivatePopup(PRBool aActivateFlag);
void OpenPopup(PRBool aOpenFlag);
nsIFrame* GetActiveChild();
void GetActiveChildElement(nsIContent** aResult);
protected:
void MarkAsGenerated(nsIContent* aPopupContent);
void UpdateDismissalListener(nsIMenuParent* aMenuParent);
protected:
nsFrameList mPopupFrames;
nsIPresContext* mPresContext; // Our pres context.
nsIFrame* mElementFrame; // The frame that is having something popped up over it.
PRInt32 mXPos; // Active child's x position
PRInt32 mYPos; // Active child's y position
}; // class nsPopupSetFrame
#endif

View File

@@ -1,813 +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 "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 Communicator client 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.
*/
//
// Eric Vaughan
// Netscape Communications
//
// See documentation in associated header file
//
static float STRIPE_SKEW = 1.0; // pixels
static int STRIPE_WIDTH = 20; // pixels
static int ANIMATION_INCREMENT = 4; // pixels
static int ANIMATION_SPEED = 50; // miliseconds
#include "nsINameSpaceManager.h"
#include "nsProgressMeterFrame.h"
#include "nsIStyleContext.h"
#include "nsCSSRendering.h"
#include "nsIContent.h"
#include "nsIPresContext.h"
#include "nsHTMLAtoms.h"
#include "nsXULAtoms.h"
#include "nsINameSpaceManager.h"
#include "nsITimerCallback.h"
#include "nsITimer.h"
#include "nsIView.h"
#include "nsIViewManager.h"
#include "nsIReflowCommand.h"
#include "nsHTMLParts.h"
#include "nsIPresShell.h"
class StripeTimer : public nsITimerCallback {
public:
StripeTimer();
virtual ~StripeTimer();
NS_DECL_ISUPPORTS
void AddFrame(nsIPresContext* aPresContext, nsProgressMeterFrame* aFrame);
PRBool RemoveFrame(nsProgressMeterFrame* aFrame);
PRInt32 FrameCount();
void Start();
void Stop();
virtual void Notify(nsITimer *timer);
PRInt32 GetFrameData(nsProgressMeterFrame* aFrame);
struct FrameData {
nsIPresContext* mPresContext; // pres context associated with the frame
nsProgressMeterFrame* mFrame;
FrameData(nsIPresContext* aPresContext,
nsProgressMeterFrame* aFrame)
: mPresContext(aPresContext), mFrame(aFrame) {}
};
nsITimer* mTimer;
nsVoidArray mFrames;
};
static StripeTimer* gStripeAnimator;
StripeTimer::StripeTimer()
{
NS_INIT_REFCNT();
mTimer = nsnull;
}
StripeTimer::~StripeTimer()
{
Stop();
}
void StripeTimer::Start()
{
nsresult rv = NS_NewTimer(&mTimer);
if (NS_OK == rv) {
mTimer->Init(this, ANIMATION_SPEED);
}
}
void StripeTimer::Stop()
{
if (nsnull != mTimer) {
mTimer->Cancel();
NS_RELEASE(mTimer);
}
}
static NS_DEFINE_IID(kITimerCallbackIID, NS_ITIMERCALLBACK_IID);
NS_IMPL_ISUPPORTS(StripeTimer, kITimerCallbackIID);
PRInt32 StripeTimer::GetFrameData(nsProgressMeterFrame* aFrame)
{
PRInt32 i, n = mFrames.Count();
for (i = 0; i < n; i++) {
FrameData* frameData = (FrameData*) mFrames.ElementAt(i);
if (frameData->mFrame == aFrame) {
return i;
}
}
return -1;
}
void StripeTimer::AddFrame(nsIPresContext* aPresContext, nsProgressMeterFrame* aFrame) {
// see if the frame is already here.
if (GetFrameData(aFrame) > -1)
return;
// if not add it.
FrameData* frameData = new FrameData(aPresContext, aFrame);
mFrames.AppendElement(frameData);
if (1 == mFrames.Count()) {
Start();
}
}
PRBool StripeTimer::RemoveFrame(nsProgressMeterFrame* aFrame) {
PRBool rv = PR_FALSE;
PRInt32 i = GetFrameData(aFrame);
if (i > -1) {
FrameData* frameData = (FrameData*)mFrames.ElementAt(i);
rv = mFrames.RemoveElementAt(i);
delete frameData;
}
if (0 == mFrames.Count()) {
Stop();
}
return rv;
}
PRInt32 StripeTimer::FrameCount() {
return mFrames.Count();
}
void StripeTimer::Notify(nsITimer *timer)
{
// XXX hack to get auto-repeating timers; restart before doing
// expensive work so that time between ticks is more even
Stop();
Start();
PRInt32 i, n = mFrames.Count();
for (i = 0; i < n; i++) {
FrameData* frameData = (FrameData*) mFrames.ElementAt(i);
frameData->mFrame->animate();
// Determine damaged area and tell view manager to redraw it
nsPoint offset;
nsRect bounds;
frameData->mFrame->GetRect(bounds);
nsIView* view;
frameData->mFrame->GetOffsetFromView(frameData->mPresContext, offset, &view);
nsIViewManager* vm;
view->GetViewManager(vm);
bounds.x = offset.x;
bounds.y = offset.y;
vm->UpdateView(view, bounds, 0);
NS_RELEASE(vm);
}
}
//
// NS_NewToolbarFrame
//
// Creates a new Toolbar frame and returns it in |aNewFrame|
//
nsresult
NS_NewProgressMeterFrame ( nsIFrame** aNewFrame )
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsProgressMeterFrame* it = new nsProgressMeterFrame;
if (nsnull == it)
return NS_ERROR_OUT_OF_MEMORY;
// it->SetFlags(aFlags);
*aNewFrame = it;
return NS_OK;
} // NS_NewProgressMeterFrame
//
// nsProgressMeterFrame cntr
//
// Init, if necessary
//
nsProgressMeterFrame :: nsProgressMeterFrame ( )
{
// if we haven't created the timer create it.
if (nsnull == gStripeAnimator) {
gStripeAnimator = new StripeTimer();
}
NS_ADDREF(gStripeAnimator);
mProgress = float(0.0);
mHorizontal = PR_TRUE;
mUndetermined = PR_FALSE;
mStripeOffset = STRIPE_WIDTH;
}
//
// nsProgressMeterFrame dstr
//
// Cleanup, if necessary
//
nsProgressMeterFrame :: ~nsProgressMeterFrame ( )
{
gStripeAnimator->RemoveFrame(this);
}
NS_IMETHODIMP
nsProgressMeterFrame::Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsLeafFrame::Init(aPresContext, aContent, aParent, aContext,
aPrevInFlow);
// get the value
nsAutoString value;
if ((NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value)) &&
(value.Length() > 0)) {
setProgress(value);
}
// get the alignment
nsAutoString align;
mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::align, align);
setAlignment(align);
// get the mode
nsAutoString mode;
mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::mode, mode);
setMode(mode);
nsCOMPtr<nsIAtom> barPseudo ( dont_AddRef(NS_NewAtom(":progressmeter-stripe")) );
nsIStyleContext* barStyle = nsnull;
aPresContext.ProbePseudoStyleContextFor(aContent, barPseudo, aContext,
PR_FALSE, &barStyle);
mBarStyle = barStyle;
return rv;
}
void
nsProgressMeterFrame::setProgress(nsAutoString progress)
{
// convert to and integer
PRInt32 error;
PRInt32 v = progress.ToInteger(&error);
// adjust to 0 and 100
if (v < 0)
v = 0;
else if (v > 100)
v = 100;
// printf("ProgressMeter value=%d\n", v);
mProgress = float(v)/float(100);
}
void
nsProgressMeterFrame::setSize(nsAutoString sizeString, int& size, PRBool& isPercent)
{
// -1 means unset
size = -1;
int length = sizeString.Length();
if (length == 0)
return;
char w[100];
sizeString.ToCString(w,100);
if (w[length-1] == '%')
isPercent = PR_TRUE;
else
isPercent = PR_FALSE;
// convert to and integer
PRInt32 error;
PRInt32 v = sizeString.ToInteger(&error);
// adjust to 0 and 100
if (isPercent) {
if (v < 0)
v = 0;
else if (v > 100)
v = 100;
}
printf("size=%d\n", v);
size = v;
}
void
nsProgressMeterFrame::setAlignment(nsAutoString progress)
{
if (progress.EqualsIgnoreCase("vertical"))
mHorizontal = PR_FALSE;
else
mHorizontal = PR_TRUE;
}
void
nsProgressMeterFrame::setMode(nsAutoString mode)
{
if (mode.EqualsIgnoreCase("undetermined"))
mUndetermined = PR_TRUE;
else
mUndetermined = PR_FALSE;
}
//
// Paint
//
// Paint our background and border like normal frames, but before we draw the
// children, draw our grippies for each toolbar.
//
NS_IMETHODIMP
nsProgressMeterFrame :: Paint ( nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
{
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
// if we aren't visible then we are done.
if (!disp->mVisible)
return NS_OK;
// if we are visible then tell our superclass to paint
nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
aWhichLayer);
// get our border
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsMargin border(0,0,0,0);
spacing->CalcBorderFor(this, border);
const nsStyleColor* colorStyle =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
nscolor color = colorStyle->mColor;
// figure our twips convertion ratio
// float p2t;
// aPresContext.GetScaledPixelsToTwips(p2t);
// nscoord onePixel = NSIntPixelsToTwips(1, p2t);
// figure out our rectangle
nsRect rect(0,0,mRect.width, mRect.height);
// if its vertical then transform the coords to the X coordinate system
// and do our calculations there.
if (!mHorizontal)
rect = TransformYtoX(rect);
//CalcSize(aPresContext,rect.width,rect.height);
rect.x = border.left;
rect.y = border.top;
rect.width -= border.left*2;
rect.height -= border.top*2;
// paint the current progress in blue
PaintBar(aPresContext, aRenderingContext, rect, mProgress, color);
return NS_OK;
} // Paint
void
nsProgressMeterFrame :: PaintBar ( nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& rect,
float progress,
nscolor color) {
// if the bar is undetermined then use the whole progress area.
// if the bar is determined then figure out the current progress and make
// the bar only that percent of the full progress meter.
nsRect bar(rect);
if (!mUndetermined)
{
int p = (int)(bar.width*progress);
bar.width = p;
}
// fill the bar first then we will do the shading over it.
aRenderingContext.SetColor(color);
if (mHorizontal)
aRenderingContext.FillRect(bar);
else { // if we are vert then transfrom to the y cood system.
nsRect nbar = TransformXtoY(bar);
aRenderingContext.FillRect(nbar);
}
// draw the stripped barber shop if undetermined.
if (mUndetermined)
PaintBarStripped(aPresContext,aRenderingContext,bar, color);
else
PaintBarSolid(aPresContext,aRenderingContext,bar, color, 0);
}
nsRect
nsProgressMeterFrame::TransformXtoY(const nsRect& rect)
{
return nsRect(rect.y, mRect.height - (rect.x + rect.width), rect.height, rect.width);
}
nsRect
nsProgressMeterFrame::TransformYtoX(const nsRect& rect)
{
return nsRect(mRect.width - (rect.y + rect.height), rect.x, rect.height, rect.width);
}
nscolor
nsProgressMeterFrame::BrightenBy(nscolor c, PRUint8 amount)
{
PRUint8 r = NS_GET_R(c);
PRUint8 g = NS_GET_G(c);
PRUint8 b = NS_GET_B(c);
return NS_RGB(r+amount, g+amount, b+amount);
}
PRUint8
nsProgressMeterFrame::GetBrightness(nscolor c)
{
// get the biggest rgb component;
PRUint8 r = NS_GET_R(c);
PRUint8 g = NS_GET_G(c);
PRUint8 b = NS_GET_B(c);
PRUint8 biggest = r;
if (r > g && r > b)
biggest = r;
else if (g > r && g > b)
biggest = g;
else if (b > r && b > g)
biggest = b;
return biggest;
}
void
nsProgressMeterFrame::PaintBarSolid(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext,
const nsRect& rect, nscolor color, float skew)
{
// figure out a pixel size
float p2t;
aPresContext.GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
// how many pixel lines will fit?
int segments = (rect.height/2) / onePixel;
// get the skew in pixels;
int skewedPixels = int(skew * onePixel);
// we will draw from the top to center and from the bottom to center at the same time
// so we need 2 rects one for the top and one for the bottom
// top.
nsRect tr(rect);
tr.height= onePixel;
// bottom
nsRect br(rect);
br.height = onePixel;
br.y = rect.y + 2*segments*onePixel;
br.x = rect.x + 2*segments*skewedPixels;
// get the brightness of the color
PRUint8 brightness = GetBrightness(color);
// we need to figure out how bright we can get.
PRUint8 units = (255 - brightness)/segments;
// get a color we can set
nscolor c(color);
for (int i=0; i <= segments; i++)
{
// set the color and fill the top and bottom lines
aRenderingContext.SetColor(c);
if (mHorizontal) {
aRenderingContext.FillRect(tr);
aRenderingContext.FillRect(br);
} else {
aRenderingContext.FillRect(TransformXtoY(tr));
aRenderingContext.FillRect(TransformXtoY(br));
}
// brighten the color
c = BrightenBy(c, units);
// move one line down
tr.x += skewedPixels;
tr.y += onePixel;
// move one line up
br.y -= onePixel;
br.x -= skewedPixels;
}
}
void
nsProgressMeterFrame::PaintBarStripped(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext,
const nsRect& r, nscolor color)
{
// get stripe color from the style system
nsCOMPtr<nsIStyleContext> style (mBarStyle) ;
nscolor altColor = NS_RGB(128,128,128);
// if we got a style then get the color from it
if (style != 0)
{
const nsStyleColor* barColor = (const nsStyleColor*)style->GetStyleData(eStyleStruct_Color);
altColor = barColor->mColor;
}
float skew = STRIPE_SKEW;
float stripeWidth = float(STRIPE_WIDTH);
nsRect rect(r);
PRBool clipState;
// Clip so we don't render outside the inner rect
aRenderingContext.PushState();
if (mHorizontal)
aRenderingContext.SetClipRect(rect, nsClipCombine_kIntersect, clipState);
else
aRenderingContext.SetClipRect(TransformXtoY(rect), nsClipCombine_kIntersect, clipState);
float p2t;
aPresContext.GetScaledPixelsToTwips(&p2t);
// nscoord onePixel = NSIntPixelsToTwips(1, p2t);
int stripeWidthInTwips = (int)(stripeWidth * p2t);
int offset = int(float(r.height) * skew);
//make things a little bigger and just clip them
rect.width += offset*2;
rect.x -= (offset + int(float(mStripeOffset)*p2t));
int stripes = rect.width / (stripeWidthInTwips/2) + 2;
nsRect sr(rect.x,rect.y,stripeWidthInTwips,rect.height);
PRBool onoff = PR_FALSE;
nscolor c;
for (int i=0; i < stripes; i++)
{
if (onoff)
c = color;
else
c = altColor;
PaintBarSolid(aPresContext,aRenderingContext,sr, c, skew);
sr.x += (stripeWidthInTwips/2);
onoff = !onoff;
}
aRenderingContext.PopState(clipState);
}
void
nsProgressMeterFrame::animate()
{
mStripeOffset -= ANIMATION_INCREMENT;
// printf("animate=%d\n", mStripeOffset);
if (mStripeOffset < 0)
mStripeOffset = STRIPE_WIDTH;
}
//
// Reflow
//
// Handle moving children around.
//
NS_IMETHODIMP
nsProgressMeterFrame :: Reflow ( nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
if (eReflowReason_Incremental == aReflowState.reason) {
nsIFrame* targetFrame;
// See if it's targeted at us
aReflowState.reflowCommand->GetTarget(targetFrame);
if (this == targetFrame) {
Invalidate(&aPresContext, nsRect(0,0,mRect.width,mRect.height), PR_FALSE);
}
}
if (mUndetermined)
gStripeAnimator->AddFrame(&aPresContext, this);
else
gStripeAnimator->RemoveFrame(this);
return nsLeafFrame::Reflow ( aPresContext, aDesiredSize, aReflowState, aStatus );
} // Reflow
void
nsProgressMeterFrame::GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredSize)
{
CalcSize(*aPresContext,aDesiredSize.width,aDesiredSize.height);
// if the width is set use it
if (NS_INTRINSICSIZE != aReflowState.mComputedWidth)
aDesiredSize.width = aReflowState.mComputedWidth;
// if the height is set use it
if (NS_INTRINSICSIZE != aReflowState.mComputedHeight)
aDesiredSize.height = aReflowState.mComputedHeight;
}
void
nsProgressMeterFrame::CalcSize(nsIPresContext& aPresContext, int& width, int& height)
{
// make sure we convert to twips.
float p2t;
aPresContext.GetScaledPixelsToTwips(&p2t);
if (mHorizontal) {
width = (int)(100 * p2t);
height = (int)(16 * p2t);
} else {
height = (int)(100 * p2t);
width = (int)(16 * p2t);
}
}
NS_IMETHODIMP
nsProgressMeterFrame::AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint)
{
nsresult rv = nsLeafFrame::AttributeChanged(aPresContext, aChild,
aNameSpaceID, aAttribute, aHint);
if (NS_OK != rv) {
return rv;
}
// did the progress change?
if (nsHTMLAtoms::value == aAttribute) {
nsAutoString newValue;
// get attribute and set it
aChild->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, newValue);
setProgress(newValue);
Redraw(aPresContext);
} else if (nsXULAtoms::mode == aAttribute) {
nsAutoString newValue;
aChild->GetAttribute(kNameSpaceID_None, nsXULAtoms::mode, newValue);
setMode(newValue);
// needs to reflow so we start the timer.
if (aHint != NS_STYLE_HINT_REFLOW)
Reflow(aPresContext);
} else if (nsHTMLAtoms::align == aAttribute) {
nsAutoString newValue;
// get attribute and set it
aChild->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::align, newValue);
setAlignment(newValue);
if (aHint != NS_STYLE_HINT_REFLOW)
Reflow(aPresContext);
}
return NS_OK;
}
void
nsProgressMeterFrame::Reflow(nsIPresContext* aPresContext)
{
// reflow
nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell));
nsCOMPtr<nsIReflowCommand> reflowCmd;
nsresult rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), this,
nsIReflowCommand::StyleChanged);
if (NS_SUCCEEDED(rv))
shell->AppendReflowCommand(reflowCmd);
}
void
nsProgressMeterFrame::Redraw(nsIPresContext* aPresContext)
{
nsRect frameRect;
GetRect(frameRect);
nsRect rect(0, 0, frameRect.width, frameRect.height);
Invalidate(aPresContext, rect, PR_TRUE);
}
NS_IMETHODIMP
nsProgressMeterFrame::GetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext** aStyleContext) const
{
NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer");
if (aIndex < 0) {
return NS_ERROR_INVALID_ARG;
}
*aStyleContext = nsnull;
switch (aIndex) {
case NS_PROGRESS_METER_STRIPE_CONTEXT_INDEX:
*aStyleContext = mBarStyle;
NS_IF_ADDREF(*aStyleContext);
break;
default:
return NS_ERROR_INVALID_ARG;
}
return NS_OK;
}
NS_IMETHODIMP
nsProgressMeterFrame::SetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext* aStyleContext)
{
if (aIndex < 0) {
return NS_ERROR_INVALID_ARG;
}
switch (aIndex) {
case NS_PROGRESS_METER_STRIPE_CONTEXT_INDEX:
mBarStyle = aStyleContext;
break;
}
return NS_OK;
}

View File

@@ -1,140 +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 "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 Communicator client 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.
*/
/**
Eric D Vaughan.
A simple progress meter.
Attributes:
value: A number between 0% adn 100%
align: horizontal, or vertical
mode: determined, undetermined (one shows progress other shows animated candy cane)
Style:
Bar gets its color from the color style
Alternating stripes can be set with the seudo style:
:PROGRESSMETER-STRIPE {
color: gray
}
**/
#include "nsLeafFrame.h"
#include "nsColor.h"
#include "nsCOMPtr.h"
#include "nsIStyleContext.h"
#include "nsIPresContext.h"
#include "prtypes.h"
class nsIPresContext;
class nsIStyleContext;
#define NS_PROGRESS_METER_STRIPE_CONTEXT_INDEX 1
class nsProgressMeterFrame : public nsLeafFrame
{
public:
friend nsresult NS_NewProgressMeterFrame(nsIFrame** aNewFrame);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
// nsIHTMLReflow overrides
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint);
NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext** aStyleContext) const;
NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext* aStyleContext);
virtual void animate();
virtual void Reflow(nsIPresContext* aPresContext);
virtual void Redraw(nsIPresContext* aPresContext);
protected:
nsProgressMeterFrame();
virtual ~nsProgressMeterFrame();
virtual void GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredSize);
virtual void CalcSize(nsIPresContext& aPresContext, int& width, int& height);
virtual void PaintBar ( nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& rect,
float progress,
nscolor color);
virtual void PaintBarStripped(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext,
const nsRect& rect, nscolor color);
virtual void PaintBarSolid(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext,
const nsRect& rect, nscolor color, float skew);
virtual nscolor BrightenBy(nscolor color, PRUint8 amount);
virtual PRUint8 GetBrightness(nscolor c);
virtual nsRect TransformXtoY(const nsRect& rect);
virtual nsRect TransformYtoX(const nsRect& rect);
// pass-by-value not allowed for a coordinator because it corresponds 1-to-1
// with an element in the UI.
nsProgressMeterFrame ( const nsProgressMeterFrame& aFrame ) ; // DO NOT IMPLEMENT
nsProgressMeterFrame& operator= ( const nsProgressMeterFrame& aFrame ) ; // DO NOT IMPLEMENT
private:
void setProgress(nsAutoString progress);
void setAlignment(nsAutoString alignment);
void setMode(nsAutoString mode);
void setSize(nsAutoString s, int& size, PRBool& isPercent);
nsCOMPtr<nsIStyleContext> mBarStyle;
float mProgress;
PRBool mHorizontal;
PRBool mUndetermined;
int mStripeOffset;
}; // class nsProgressMeterFrame

View File

@@ -1,90 +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 "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 Communicator client 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.
*/
//
// Eric Vaughan
// Netscape Communications
//
// See documentation in associated header file
//
#include "nsRepeatService.h"
#define INITAL_REPEAT_DELAY 250
#define REPEAT_DELAY 50
nsRepeatService* nsRepeatService::gInstance = nsnull;
nsRepeatService::nsRepeatService()
{
}
nsRepeatService::~nsRepeatService()
{
mCallback = nsnull;
Stop();
}
nsRepeatService*
nsRepeatService::GetInstance()
{
if (!gInstance) {
gInstance = new nsRepeatService();
gInstance->mRefCnt = 1;
}
return gInstance;
}
void nsRepeatService::Start(nsITimerCallback* aCallback)
{
mCallback = aCallback;
nsresult rv = NS_NewTimer(getter_AddRefs(mRepeatTimer));
if (NS_OK == rv) {
mRepeatTimer->Init(this, INITAL_REPEAT_DELAY);
}
}
void nsRepeatService::Stop()
{
//printf("Stopping repeat timer\n");
if (mRepeatTimer) {
mRepeatTimer->Cancel();
mRepeatTimer = nsnull;
mCallback = nsnull;
}
}
void nsRepeatService::Notify(nsITimer *timer)
{
// if the repeat delay is the initial one reset it.
if (mRepeatTimer) {
mRepeatTimer->Cancel();
NS_NewTimer(getter_AddRefs(mRepeatTimer));
mRepeatTimer->Init(this, REPEAT_DELAY);
}
mCallback->Notify(timer);
}
static NS_DEFINE_IID(kITimerCallbackIID, NS_ITIMERCALLBACK_IID);
NS_IMPL_ISUPPORTS(nsRepeatService, kITimerCallbackIID);

View File

@@ -1,55 +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.
*/
//
// nsRepeatService
//
#ifndef nsRepeatService_h__
#define nsRepeatService_h__
#include "nsCOMPtr.h"
#include "nsITimerCallback.h"
#include "nsITimer.h"
class nsITimer;
class nsRepeatService : public nsITimerCallback
{
public:
virtual void Notify(nsITimer *timer);
void Start(nsITimerCallback* aCallback);
void Stop();
static nsRepeatService* GetInstance();
NS_DECL_ISUPPORTS
virtual ~nsRepeatService();
protected:
nsRepeatService();
private:
nsCOMPtr<nsITimerCallback> mCallback;
nsCOMPtr<nsITimer> mRepeatTimer;
static nsRepeatService* gInstance;
}; // class nsRepeatService
#endif

View File

@@ -1,244 +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 "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 Communicator client 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.
*/
//
// Eric Vaughan
// Netscape Communications
//
// See documentation in associated header file
//
#include "nsScrollbarButtonFrame.h"
#include "nsIStyleContext.h"
#include "nsIPresContext.h"
#include "nsIContent.h"
#include "nsCOMPtr.h"
#include "nsHTMLIIDs.h"
#include "nsUnitConversion.h"
#include "nsINameSpaceManager.h"
#include "nsHTMLAtoms.h"
#include "nsXULAtoms.h"
#include "nsIReflowCommand.h"
#include "nsSliderFrame.h"
#include "nsRepeatService.h"
//
// NS_NewToolbarFrame
//
// Creates a new Toolbar frame and returns it in |aNewFrame|
//
nsresult
NS_NewScrollbarButtonFrame ( nsIFrame** aNewFrame )
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsScrollbarButtonFrame* it = new nsScrollbarButtonFrame;
if (nsnull == it)
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
} // NS_NewScrollBarButtonFrame
/*
nsScrollbarButtonFrame::nsScrollbarButtonFrame()
{
}*/
static NS_DEFINE_IID(kITimerCallbackIID, NS_ITIMERCALLBACK_IID);
NS_IMETHODIMP
nsScrollbarButtonFrame::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (aIID.Equals(kITimerCallbackIID)) {
*aInstancePtr = (void*)(nsITimerCallback*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return nsTitledButtonFrame::QueryInterface(aIID, aInstancePtr);
}
NS_IMETHODIMP
nsScrollbarButtonFrame::HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
// XXX hack until handle release is actually called in nsframe.
if (aEvent->message == NS_MOUSE_EXIT|| aEvent->message == NS_MOUSE_RIGHT_BUTTON_UP || aEvent->message == NS_MOUSE_LEFT_BUTTON_UP)
HandleRelease(aPresContext, aEvent, aEventStatus);
return nsTitledButtonFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
NS_IMETHODIMP
nsScrollbarButtonFrame::HandlePress(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
nsRepeatService::GetInstance()->Start(this);
return NS_OK;
}
NS_IMETHODIMP
nsScrollbarButtonFrame::HandleRelease(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
nsRepeatService::GetInstance()->Stop();
return NS_OK;
}
void nsScrollbarButtonFrame::Notify(nsITimer *timer)
{
MouseClicked();
}
void
nsScrollbarButtonFrame::MouseClicked(nsIPresContext& aPresContext)
{
MouseClicked();
}
void
nsScrollbarButtonFrame::MouseClicked()
{
// when we are clicked either increment or decrement the slider position.
// get the scrollbar control
nsIFrame* scrollbar;
GetParentWithTag(nsXULAtoms::scrollbar, this, scrollbar);
if (scrollbar == nsnull)
return;
// get the scrollbars content node
nsCOMPtr<nsIContent> content;
scrollbar->GetContent(getter_AddRefs(content));
// get the current pos
PRInt32 curpos = nsSliderFrame::GetCurrentPosition(content);
// get the max pos
PRInt32 maxpos = nsSliderFrame::GetMaxPosition(content);
// get the increment amount
PRInt32 increment = nsSliderFrame::GetIncrement(content);
nsString value;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, value))
{
// if our class is DecrementButton subtract the current pos by increment amount
// if our class is IncrementButton increment the current pos by the decrement amount
if (value.Equals("decrement"))
curpos -= increment;
else if (value.Equals("increment"))
curpos += increment;
// make sure the current positon is between the current and max positions
if (curpos < 0)
curpos = 0;
else if (curpos > maxpos)
curpos = maxpos;
// set the current position of the slider.
char v[100];
sprintf(v, "%d", curpos);
content->SetAttribute(kNameSpaceID_None, nsXULAtoms::curpos, v, PR_TRUE);
}
}
nsresult
nsScrollbarButtonFrame::GetChildWithTag(nsIAtom* atom, nsIFrame* start, nsIFrame*& result)
{
// recursively search our children
nsIFrame* childFrame;
start->FirstChild(nsnull, &childFrame);
while (nsnull != childFrame)
{
// get the content node
nsCOMPtr<nsIContent> child;
childFrame->GetContent(getter_AddRefs(child));
if (child) {
// see if it is the child
nsIAtom* tag = nsnull;
child->GetTag(tag);
if (tag == atom)
{
result = childFrame;
return NS_OK;
}
}
// recursive search the child
GetChildWithTag(atom, childFrame, result);
if (result != nsnull)
return NS_OK;
nsresult rv = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(rv == NS_OK,"failed to get next child");
}
result = nsnull;
return NS_OK;
}
nsresult
nsScrollbarButtonFrame::GetParentWithTag(nsIAtom* toFind, nsIFrame* start, nsIFrame*& result)
{
while(nsnull != start)
{
start->GetParent(&start);
if (start) {
// get the content node
nsCOMPtr<nsIContent> child;
start->GetContent(getter_AddRefs(child));
nsIAtom* atom;
if (child && child->GetTag(atom) == NS_OK && atom == toFind) {
result = start;
return NS_OK;
}
}
}
result = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsScrollbarButtonFrame::Destroy(nsIPresContext& aPresContext)
{
// Ensure our repeat service isn't going... it's possible that a scrollbar can disappear out
// from under you while you're in the process of scrolling.
nsRepeatService::GetInstance()->Stop();
return nsTitledButtonFrame::Destroy(aPresContext);
}

View File

@@ -1,86 +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 "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 Communicator client 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.
*/
/**
Eric D Vaughan
This class lays out its children either vertically or horizontally
**/
#ifndef nsScrollbarButtonFrame_h___
#define nsScrollbarButtonFrame_h___
#include "nsTitledButtonFrame.h"
#include "nsITimerCallback.h"
class nsSliderFrame;
class nsScrollbarButtonFrame : public nsTitledButtonFrame,
public nsITimerCallback
{
public:
// Overrides
NS_IMETHOD Destroy(nsIPresContext& aPresContext);
friend nsresult NS_NewScrollBarButtonFrame(nsIFrame** aNewFrame);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
static nsresult GetChildWithTag(nsIAtom* atom, nsIFrame* start, nsIFrame*& result);
static nsresult GetParentWithTag(nsIAtom* atom, nsIFrame* start, nsIFrame*& result);
NS_IMETHOD HandlePress(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD HandleMultiplePress(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus) { return NS_OK; }
NS_IMETHOD HandleDrag(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus) { return NS_OK; }
NS_IMETHOD HandleRelease(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
virtual void Notify(nsITimer *timer);
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void) { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release(void) { return NS_OK; }
protected:
virtual void MouseClicked(nsIPresContext& aPresContext);
virtual void MouseClicked();
}; // class nsTabFrame
#endif

View File

@@ -1,390 +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 "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 Communicator client 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.
*/
//
// Eric Vaughan
// Netscape Communications
//
// See documentation in associated header file
//
#include "nsScrollbarFrame.h"
#include "nsScrollbarButtonFrame.h"
#include "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsISupportsArray.h"
#include "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsINameSpaceManager.h"
#include "nsIXMLContent.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsIDOMElement.h"
#include "nsXMLElement.h"
#include "nsIStyledContent.h"
#include "nsGenericElement.h"
#include "nsIStyleRule.h"
#include "nsHTMLValue.h"
#include "nsIAnonymousContent.h"
#include "nsIView.h"
static NS_DEFINE_IID(kIAnonymousContentCreatorIID, NS_IANONYMOUS_CONTENT_CREATOR_IID);
static NS_DEFINE_IID(kIStyledContentIID, NS_ISTYLEDCONTENT_IID);
static NS_DEFINE_IID(kIAnonymousContentIID, NS_IANONYMOUS_CONTENT_IID);
class AnonymousElement : public nsXMLElement, nsIStyledContent, nsIAnonymousContent
{
public:
AnonymousElement(nsIAtom *aTag):nsXMLElement(aTag) {}
// nsIStyledContent
NS_IMETHOD GetID(nsIAtom*& aResult) const;
NS_IMETHOD GetClasses(nsVoidArray& aArray) const;
NS_IMETHOD HasClass(nsIAtom* aClass) const;
NS_IMETHOD GetContentStyleRules(nsISupportsArray* aRules);
NS_IMETHOD GetInlineStyleRules(nsISupportsArray* aRules);
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute,
PRInt32& aHint) const;
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
// NS_IMPL_ICONTENT_USING_GENERIC_DOM_DATA(mInner)
};
NS_IMETHODIMP
AnonymousElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
return this->nsXMLElement::SizeOf(aSizer, aResult);
}
/*
NS_IMETHODIMP
AnonymousElement::GetTag(nsIAtom*& aResult) const
{
return mInner.GetTag(aResult);
}
NS_IMETHODIMP
AnonymousElement::List(FILE* out, PRInt32 aIndent) const
{
NS_PRECONDITION(nsnull != mInner.mDocument, "bad content");
PRInt32 indx;
for (indx = aIndent; --indx >= 0; ) fputs(" ", out);
fprintf(out, "Comment refcount=%d<", mRefCnt);
nsAutoString tmp;
mInner.ToCString(tmp, 0, mInner.mText.GetLength());
fputs(tmp, out);
fputs(">\n", out);
return mInner.List(out, aIndent);
}
*/
NS_IMETHODIMP
AnonymousElement::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus& aEventStatus)
{
/*
// if our parent is not anonymous then we don't want to bubble the event
// so lets set our parent in nsnull to prevent it. Then we will set it
// back.
nsIContent* parent = nsnull;
GetParent(parent);
nsCOMPtr<nsIAnonymousContent> anonymousParent(do_QueryInterface(parent));
if (!anonymousParent)
SetParent(nsnull);
*/
nsresult rv = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
/*
if (!anonymousParent)
SetParent(parent);
*/
return rv;
}
// nsIStyledContent Implementation
NS_IMETHODIMP
AnonymousElement::GetID(nsIAtom*& aResult) const
{
/*
nsAutoString value;
GetAttribute(kNameSpaceID_None, kIdAtom, value);
aResult = NS_NewAtom(value); // The NewAtom call does the AddRef.
*/
aResult = nsnull;
return NS_OK;
}
NS_IMETHODIMP
AnonymousElement::GetClasses(nsVoidArray& aArray) const
{
return NS_OK;
}
NS_IMETHODIMP
AnonymousElement::HasClass(nsIAtom* aClass) const
{
return NS_COMFALSE;
}
NS_IMETHODIMP
AnonymousElement::GetContentStyleRules(nsISupportsArray* aRules)
{
return NS_OK;
}
NS_IMETHODIMP
AnonymousElement::GetInlineStyleRules(nsISupportsArray* aRules)
{
// we don't currently support the style attribute
return NS_OK;
}
NS_IMETHODIMP
AnonymousElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
PRInt32& aHint) const
{
aHint = NS_STYLE_HINT_CONTENT; // we never map attribtes to style
return NS_OK;
}
NS_IMETHODIMP
AnonymousElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (aIID.Equals(kIStyledContentIID)) {
nsIStyledContent* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
} else if (aIID.Equals(kIAnonymousContentIID)) {
nsIAnonymousContent* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
return nsXMLElement::QueryInterface(aIID, aInstancePtr);
}
NS_IMPL_ADDREF_INHERITED(AnonymousElement, nsXMLElement)
NS_IMPL_RELEASE_INHERITED(AnonymousElement, nsXMLElement)
nsresult NS_CreateAnonymousNode(nsIContent* aParent, nsIAtom* aTag, PRInt32 aNameSpaceId, nsCOMPtr<nsIContent>& aNewNode)
{
// create the xml element
nsCOMPtr<nsIXMLContent> content;
//NS_NewXMLElement(getter_AddRefs(content), aTag);
content = new AnonymousElement(aTag);
content->SetNameSpaceID(aNameSpaceId);
aNewNode = content;
/*
nsCOMPtr<nsIDocument> document;
aParent->GetDocument(*getter_AddRefs(document));
nsCOMPtr<nsIDOMDocument> domDocument(do_QueryInterface(document));
nsCOMPtr<nsIDOMElement> element;
nsString name;
aTag->ToString(name);
domDocument->CreateElement(name, getter_AddRefs(element));
aNewNode = do_QueryInterface(element);
*/
return NS_OK;
}
//
// NS_NewToolbarFrame
//
// Creates a new Toolbar frame and returns it in |aNewFrame|
//
nsresult
NS_NewScrollbarFrame ( nsIFrame** aNewFrame )
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsScrollbarFrame* it = new nsScrollbarFrame;
if (nsnull == it)
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
} // NS_NewScrollbarFrame
/**
* Anonymous interface
*/
NS_IMETHODIMP
nsScrollbarFrame::CreateAnonymousContent(nsISupportsArray& aAnonymousChildren)
{
// if not content the create some anonymous content
PRInt32 count = 0;
mContent->ChildCount(count);
if (count == 0) {
nsCOMPtr<nsIContent> content;
NS_CreateAnonymousNode(mContent, nsXULAtoms::scrollbarbutton, nsXULAtoms::nameSpaceID, content);
content->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, "decrement", PR_FALSE);
aAnonymousChildren.AppendElement(content);
NS_CreateAnonymousNode(mContent, nsXULAtoms::slider, nsXULAtoms::nameSpaceID, content);
content->SetAttribute(kNameSpaceID_None, nsXULAtoms::flex, "1", PR_FALSE);
aAnonymousChildren.AppendElement(content);
NS_CreateAnonymousNode(mContent, nsXULAtoms::scrollbarbutton, nsXULAtoms::nameSpaceID, content);
content->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, "increment", PR_FALSE);
aAnonymousChildren.AppendElement(content);
}
return NS_OK;
}
NS_IMETHODIMP
nsScrollbarFrame::Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
CreateViewForFrame(aPresContext,this,aContext,PR_TRUE);
nsIView* view;
GetView(&aPresContext, &view);
view->SetContentTransparency(PR_TRUE);
return rv;
}
NS_IMETHODIMP
nsScrollbarFrame::AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint)
{
nsresult rv = nsBoxFrame::AttributeChanged(aPresContext, aChild,
aNameSpaceID, aAttribute, aHint);
// if the current position changes
if ( aAttribute == nsXULAtoms::curpos ||
aAttribute == nsXULAtoms::maxpos ||
aAttribute == nsXULAtoms::pageincrement ||
aAttribute == nsXULAtoms::increment) {
// tell the slider its attribute changed so it can
// update itself
nsIFrame* slider;
nsScrollbarButtonFrame::GetChildWithTag(nsXULAtoms::slider, this, slider);
if (slider)
slider->AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aHint);
}
return rv;
}
NS_IMETHODIMP
nsScrollbarFrame::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
if (aIID.Equals(kIAnonymousContentCreatorIID)) {
*aInstancePtr = (void*)(nsIAnonymousContentCreator*) this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIStyledContentIID)) {
*aInstancePtr = (void*)(nsIStyledContent*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return nsBoxFrame::QueryInterface(aIID, aInstancePtr);
}
NS_IMETHODIMP
nsScrollbarFrame::HandlePress(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
return NS_OK;
}
NS_IMETHODIMP
nsScrollbarFrame::HandleMultiplePress(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
return NS_OK;
}
NS_IMETHODIMP
nsScrollbarFrame::HandleDrag(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
return NS_OK;
}
NS_IMETHODIMP
nsScrollbarFrame::HandleRelease(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
return NS_OK;
}

View File

@@ -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.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.
*/
//
// nsScrollbarFrame
//
#ifndef nsScrollbarFrame_h__
#define nsScrollbarFrame_h__
#include "nsBoxFrame.h"
#include "nsIAnonymousContentCreator.h"
class nsISupportsArray;
nsresult NS_NewScrollbarFrame(nsIFrame** aResult) ;
class nsScrollbarFrame : public nsBoxFrame,
public nsIAnonymousContentCreator
{
public:
nsScrollbarFrame() {}
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsString& aResult) const {
return MakeFrameName("ScrollbarFrame", aResult);
}
#endif
// nsIFrame overrides
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint);
// nsIAnonymousConentCreator
NS_IMETHOD CreateAnonymousContent(nsISupportsArray& aAnonymousItems);
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
NS_IMETHOD HandlePress(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD HandleMultiplePress(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD HandleDrag(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD HandleRelease(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
}; // class nsScrollbarFrame
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,234 +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.
*/
//
// nsSliderFrame
//
#ifndef nsSliderFrame_h__
#define nsSliderFrame_h__
#include "nsHTMLContainerFrame.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsCOMPtr.h"
#include "nsIDOMMouseListener.h"
#include "nsIAnonymousContentCreator.h"
#include "nsITimerCallback.h"
class nsString;
class nsIScrollbarListener;
class nsISupportsArray;
class nsITimer;
#define INITAL_REPEAT_DELAY 500
#define REPEAT_DELAY 50
nsresult NS_NewSliderFrame(nsIFrame** aResult) ;
class nsSliderFrame : public nsHTMLContainerFrame,
nsIDOMMouseListener,
nsIAnonymousContentCreator,
nsITimerCallback
{
public:
nsSliderFrame();
virtual ~nsSliderFrame();
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsString& aResult) const {
return MakeFrameName("SliderFrame", aResult);
}
#endif
// nsIFrame overrides
NS_IMETHOD Destroy(nsIPresContext& aPresContext);
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint);
virtual nsresult CurrentPositionChanged(nsIPresContext* aPresContext);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* asPrevInFlow);
NS_IMETHOD CreateAnonymousContent(nsISupportsArray& aAnonymousItems);
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD AppendFrames(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aFrameList);
NS_IMETHOD InsertFrames(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
NS_IMETHOD RemoveFrame(nsIPresContext& aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint, nsIFrame** aFrame);
NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
/**
* Processes a mouse down event
* @param aMouseEvent @see nsIDOMEvent.h
* @returns whether the event was consumed or ignored. @see nsresult
*/
virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent);
/**
* Processes a mouse up event
* @param aMouseEvent @see nsIDOMEvent.h
* @returns whether the event was consumed or ignored. @see nsresult
*/
virtual nsresult MouseUp(nsIDOMEvent* aMouseEvent);
/**
* Processes a mouse click event
* @param aMouseEvent @see nsIDOMEvent.h
* @returns whether the event was consumed or ignored. @see nsresult
*
*/
virtual nsresult MouseClick(nsIDOMEvent* aMouseEvent) { return NS_OK; }
/**
* Processes a mouse click event
* @param aMouseEvent @see nsIDOMEvent.h
* @returns whether the event was consumed or ignored. @see nsresult
*
*/
virtual nsresult MouseDblClick(nsIDOMEvent* aMouseEvent) { return NS_OK; }
/**
* Processes a mouse enter event
* @param aMouseEvent @see nsIDOMEvent.h
* @returns whether the event was consumed or ignored. @see nsresult
*/
virtual nsresult MouseOver(nsIDOMEvent* aMouseEvent) { return NS_OK; }
/**
* Processes a mouse leave event
* @param aMouseEvent @see nsIDOMEvent.h
* @returns whether the event was consumed or ignored. @see nsresult
*/
virtual nsresult MouseOut(nsIDOMEvent* aMouseEvent) { return NS_OK; }
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
virtual nsresult HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
static PRInt32 GetCurrentPosition(nsIContent* content);
static PRInt32 GetMaxPosition(nsIContent* content);
static PRInt32 GetIncrement(nsIContent* content);
static PRInt32 GetPageIncrement(nsIContent* content);
static PRInt32 GetIntegerAttribute(nsIContent* content, nsIAtom* atom, PRInt32 defaultValue);
static PRInt32 IsHorizontal(nsIContent* content);
void SetScrollbarListener(nsIScrollbarListener* aListener);
NS_IMETHOD HandlePress(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD HandleMultiplePress(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus) { return NS_OK; }
NS_IMETHOD HandleDrag(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus) { return NS_OK; }
NS_IMETHOD HandleRelease(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
virtual void Notify(nsITimer *timer);
protected:
virtual nsresult ReflowThumb(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame* thumbFrame,
nsSize available,
nsSize computed);
virtual PRIntn GetSkipSides() const { return 0; }
private:
nsIContent* GetScrollBar();
void PageUpDown(nsIFrame* aThumbFrame, nscoord change);
void SetCurrentPosition(nsIContent* scrollbar, nsIFrame* aThumbFrame, nscoord pos);
NS_IMETHOD DragThumb(nsIPresContext* aPresContext, PRBool aGrabMouseEvents);
void AddListener();
void RemoveListener();
PRBool isDraggingThumb(nsIPresContext* aPresContext);
float mRatio;
nscoord mDragStartPx;
nscoord mThumbStart;
PRInt32 mCurPos;
nsIScrollbarListener* mScrollbarListener;
// XXX Hack
nsIPresContext* mPresContext; // weak reference
static nscoord gChange;
}; // class nsSliderFrame
#endif

View File

@@ -1,111 +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 "nsSpinnerFrame.h"
#include "nsIContent.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsIPresContext.h"
#include "nsIStyleContext.h"
#include "nsCSSRendering.h"
#include "nsINameSpaceManager.h"
//
// NS_NewSpinnerFrame
//
// Wrapper for creating a new spinner
//
nsresult
NS_NewSpinnerFrame(nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsSpinnerFrame* it = new nsSpinnerFrame;
if ( !it )
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
}
//
// nsSpinnerFrame cntr
//
nsSpinnerFrame::nsSpinnerFrame()
{
} // cntr
//
// Paint
//
// Overidden to handle ???
//
NS_METHOD
nsSpinnerFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
{
return nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
}
//
// GetDesiredSize
//
// For now, be as big as CSS wants us to be, or some small default size.
//
void
nsSpinnerFrame :: GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredLayoutSize)
{
const int CSS_NOTSET = -1;
nsSize styleSize;
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedWidth) {
styleSize.width = aReflowState.mComputedWidth;
}
else {
styleSize.width = CSS_NOTSET;
}
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) {
styleSize.height = aReflowState.mComputedHeight;
}
else {
styleSize.height = CSS_NOTSET;
}
// subclasses should always override this method, but if not and no css, make it small
aDesiredLayoutSize.width = (styleSize.width > CSS_NOTSET) ? styleSize.width : 200;
aDesiredLayoutSize.height = (styleSize.height > CSS_NOTSET) ? styleSize.height : 200;
aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;
aDesiredLayoutSize.descent = 0;
if (aDesiredLayoutSize.maxElementSize) {
aDesiredLayoutSize.maxElementSize->width = aDesiredLayoutSize.width;
aDesiredLayoutSize.maxElementSize->height = aDesiredLayoutSize.height;
}
} // GetDesiredSize

View File

@@ -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.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.
*/
//
// nsSpinnerFrame
//
#ifndef nsSpinnerFrame_h__
#define nsSpinnerFrame_h__
#include "nsLeafFrame.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsCOMPtr.h"
class nsString;
nsresult NS_NewSpinnerFrame(nsIFrame** aResult) ;
class nsSpinnerFrame : public nsLeafFrame
{
public:
nsSpinnerFrame();
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsString& aResult) const {
return MakeFrameName("SpinnerFrame", aResult);
}
#endif
// nsIFrame overrides
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
protected:
virtual void GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredSize) ;
}; // class nsSpinnerFrame
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,103 +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.
*/
//
// nsSplitterFrame
//
#ifndef nsSplitterFrame_h__
#define nsSplitterFrame_h__
#include "nsBoxFrame.h"
#include "nsIAnonymousContentCreator.h"
class nsISupportsArray;
class nsSplitterFrameImpl;
nsresult NS_NewSplitterFrame(nsIFrame** aResult) ;
class nsSplitterFrame : public nsBoxFrame, public nsIAnonymousContentCreator
{
public:
nsSplitterFrame();
~nsSplitterFrame();
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsString& aResult) const {
return MakeFrameName("SplitterFrame", aResult);
}
#endif
// nsIFrame overrides
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
NS_IMETHOD GetCursor(nsIPresContext& aPresContext,
nsPoint& aPoint,
PRInt32& aCursor);
// nsIAnonymousContentCreator
NS_IMETHOD CreateAnonymousContent(nsISupportsArray& aAnonymousItems);
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void) { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release(void) { return NS_OK; }
NS_IMETHOD HandlePress(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD HandleMultiplePress(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD HandleDrag(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD HandleRelease(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
private:
friend class nsSplitterFrameImpl;
nsSplitterFrameImpl* mImpl;
// XXX Hack
nsIPresContext* mPresContext; // weak reference
}; // class nsSplitterFrame
#endif

View File

@@ -1,256 +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 "nsStdColorPicker.h"
#include "nsColor.h"
#include "nsCRT.h"
#include "nsXULAtoms.h"
#include "nsIDOMElement.h"
#include "nsIContent.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsIPresContext.h"
#include "nsIStyleContext.h"
#include "nsCSSRendering.h"
#include "nsINameSpaceManager.h"
static char *NosePalette[] = {
"#00FF00","#00ED00","#00DB00","#00C900","#00B700","#00A500","#009300","#008100","#006F00","#005D00",
"#FFFF00","#EDED00","#DBDB00","#C9C900","#B7B700","#A5A500","#939300","#818100","#6F6F00","#5D5D00",
"#FFFF00","#F5ED00","#EBDB00","#E1C900","#D7B700","#CDA500","#C39300","#B98100","#AF6F00","#A55D00"
};
static char* StandardPalette[] = {
"#FFFFFF","#FFCCCC","#FFCC99","#FFFF99","#FFFFCC","#99FF99","#99FFFF","#CCFFFF","#CCCCFF","#FFCCFF",
"#CCCCCC","#FF6666","#FFCC33","#FFFF66","#FFFF99","#66FF99","#33FFFF","#66FFFF","#9999FF","#FF99FF",
"#C0C0C0","#FF0000","#FF9900","#FFCC66","#FFFF00","#33FF33","#66CCCC","#33CCFF","#6666CC","#CC66CC",
"#999999","#CC0000","#FF6600","#FFCC33","#FFCC00","#33CC00","#00CCCC","#3366FF","#6633FF","#CC33CC",
"#666666","#990000","#CC6600","#CC9933","#999900","#009900","#339999","#3333FF","#6600CC","#993399",
"#333333","#660000","#993300","#996633","#666600","#006600","#336666","#000099","#333399","#663366",
"#000000","#330000","#663300","#663333","#333300","#003300","#003333","#000066","#330099","#330033"
};
static char *WebPalette[] = {
"#FFFFFF", "#FFFFCC", "#FFFF99", "#FFFF66", "#FFFF33", "#FFFF00", "#FFCCFF", "#FFCCCC",
"#FFCC99", "#FFCC66", "#FFCC33", "#FFCC00", "#FF99FF", "#FF99CC", "#FF9999", "#FF9966",
"#FF9933", "#FF9900", "#FF66FF", "#FF66CC", "#FF6699", "#FF6666", "#FF6633", "#FF6600",
"#FF33FF", "#FF33CC", "#FF3399", "#FF3366", "#FF3333", "#FF3300", "#FF00FF", "#FF00CC",
"#FF0099", "#FF0066", "#FF0033", "#FF0000", "#CCFFFF", "#CCFFCC", "#CCFF99", "#CCFF66",
"#CCFF33", "#CCFF00", "#CCCCFF", "#CCCCCC", "#CCCC99", "#CCCC66", "#CCCC33", "#CCCC00",
"#CC99FF", "#CC99CC", "#CC9999", "#CC9966", "#CC9933", "#CC9900", "#CC66FF", "#CC66CC",
"#CC6699", "#CC6666", "#CC6633", "#CC6600", "#CC33FF", "#CC33CC", "#CC3399", "#CC3366",
"#CC3333", "#CC3300", "#CC00FF", "#CC00CC", "#CC0099", "#CC0066", "#CC0033", "#CC0000",
"#99FFFF", "#99FFCC", "#99FF99", "#99FF66", "#99FF33", "#99FF00", "#99CCFF", "#99CCCC",
"#99CC99", "#99CC66", "#99CC33", "#99CC00", "#9999FF", "#9999CC", "#999999", "#999966",
"#999933", "#999900", "#9966FF", "#9966CC", "#996699", "#996666", "#996633", "#996600",
"#9933FF", "#9933CC", "#993399", "#993366", "#993333", "#993300", "#9900FF", "#9900CC",
"#990099", "#990066", "#990033", "#990000", "#66FFFF", "#66FFCC", "#66FF99", "#66FF66",
"#66FF33", "#66FF00", "#66CCFF", "#66CCCC", "#66CC99", "#66CC66", "#66CC33", "#66CC00",
"#6699FF", "#6699CC", "#669999", "#669966", "#669933", "#669900", "#6666FF", "#6666CC",
"#666699", "#666666", "#666633", "#666600", "#6633FF", "#6633CC", "#663399", "#663366",
"#663333", "#663300", "#6600FF", "#6600CC", "#660099", "#660066", "#660033", "#660000",
"#33FFFF", "#33FFCC", "#33FF99", "#33FF66", "#33FF33", "#33FF00", "#33CCFF", "#33CCCC",
"#33CC99", "#33CC66", "#33CC33", "#33CC00", "#3399FF", "#3399CC", "#339999", "#339966",
"#339933", "#339900", "#3366FF", "#3366CC", "#336699", "#336666", "#336633", "#336600",
"#3333FF", "#3333CC", "#333399", "#333366", "#333333", "#333300", "#3300FF", "#3300CC",
"#330099", "#330066", "#330033", "#330000", "#00FFFF", "#00FFCC", "#00FF99", "#00FF66",
"#00FF33", "#00FF00", "#00CCFF", "#00CCCC", "#00CC99", "#00CC66", "#00CC33", "#00CC00",
"#0099FF", "#0099CC", "#009999", "#009966", "#009933", "#009900", "#0066FF", "#0066CC",
"#006699", "#006666", "#006633", "#006600", "#0033FF", "#0033CC", "#003399", "#003366",
"#003333", "#003300", "#0000FF", "#0000CC", "#000099", "#000066", "#000033", "#000000"
};
static char *GrayPalette[] = {
"#000000", "#010101", "#020202", "#030303", "#040404", "#050505", "#060606", "#070707",
"#080808", "#090909", "#0A0A0A", "#0B0B0B", "#0C0C0C", "#0D0D0D", "#0E0E0E", "#0F0F0F",
"#101010", "#111111", "#121212", "#131313", "#141414", "#151515", "#161616", "#171717",
"#181818", "#191919", "#1A1A1A", "#1B1B1B", "#1C1C1C", "#1D1D1D", "#1E1E1E", "#1F1F1F",
"#202020", "#212121", "#222222", "#232323", "#242424", "#252525", "#262626", "#272727",
"#282828", "#292929", "#2A2A2A", "#2B2B2B", "#2C2C2C", "#2D2D2D", "#2E2E2E", "#2F2F2F",
"#303030", "#313131", "#323232", "#333333", "#343434", "#353535", "#363636", "#373737",
"#383838", "#393939", "#3A3A3A", "#3B3B3B", "#3C3C3C", "#3D3D3D", "#3E3E3E", "#3F3F3F",
"#404040", "#414141", "#424242", "#434343", "#444444", "#454545", "#464646", "#474747",
"#484848", "#494949", "#4A4A4A", "#4B4B4B", "#4C4C4C", "#4D4D4D", "#4E3E3E", "#4F4F4F",
"#505050", "#515151", "#525252", "#534343", "#545454", "#555555", "#565656", "#575757",
"#585858", "#595959", "#5A5A5A", "#5B5B5B", "#5C5C5C", "#5D5D5D", "#5E5E5E", "#5F5F5F",
"#606060", "#616161", "#626262", "#636363", "#646464", "#656565", "#666666", "#676767",
"#686868", "#696969", "#6A6A6A", "#6B6B6B", "#6C6C6C", "#6D6D6D", "#6E6E6E", "#6F6F6F",
"#707070", "#717171", "#727272", "#737373", "#747474", "#757575", "#767676", "#777777",
"#787878", "#797979", "#7A7A7A", "#7B7B7B", "#7C7C7C", "#7D7D7D", "#7E7E7E", "#7F7F7F",
"#808080", "#818181", "#828282", "#838383", "#848484", "#858585", "#868686", "#878787",
"#888888", "#898989", "#8A8A8A", "#8B8B8B", "#8C8C8C", "#8D8D8D", "#8E8E8E", "#8F8F8F",
"#909090", "#919191", "#929292", "#939393", "#949494", "#959595", "#969696", "#979797",
"#989898", "#999999", "#9A9A9A", "#9B9B9B", "#9C9C9C", "#9D9D9D", "#9E9E9E", "#9F9F9F",
"#A0A0A0", "#A1A1A1", "#A2A2A2", "#A3A3A3", "#A4A4A4", "#A5A5A5", "#A6A6A6", "#A7A7A7",
"#A8A8A8", "#A9A9A9", "#AAAAAA", "#ABABAB", "#ACACAC", "#ADADAD", "#AEAEAE", "#AFAFAF",
"#B0B0B0", "#B1B1B1", "#B2B2B2", "#B3B3B3", "#B4B4B4", "#B5B5B5", "#B6B6B6", "#B7B7B7",
"#B8B8B8", "#B9B9B9", "#BABABA", "#BBBBBB", "#BCBCBC", "#BDBDBD", "#BEBEBE", "#BFBFBF",
"#C0C0C0", "#C1C1C1", "#C2C2C2", "#C3C3C3", "#C4C4C4", "#C5C5C5", "#C6C6C6", "#C7C7C7",
"#C8C8C8", "#C9C9C9", "#CACACA", "#CBCBCB", "#CCCCCC", "#CDCDCD", "#CECECE", "#CFCFCF",
"#D0D0D0", "#D1D1D1", "#D2D2D2", "#D3D3D3", "#D4D4D4", "#D5D5D5", "#D6D6D6", "#D7D7D7",
"#D8D8D8", "#D9D9D9", "#DADADA", "#DBDBDB", "#DCDCDC", "#DDDDDD", "#DEDEDE", "#DFDFDF",
"#E0E0E0", "#E1E1E1", "#E2E2E2", "#E3E3E3", "#E4E4E4", "#E5E5E5", "#E6E6E6", "#E7E7E7",
"#E8E8E8", "#E9E9E9", "#EAEAEA", "#EBEBEB", "#ECECEC", "#EDEDED", "#EEEEEE", "#EFEFEF",
"#F0F0F0", "#F1F1F1", "#F2F2F2", "#F3F3F3", "#F4F4F4", "#F5F5F5", "#F6F6F6", "#F7F7F7",
"#F8F8F8", "#F9F9F9", "#FAFAFA", "#FBFBFB", "#FCFCFC", "#FDFDFD", "#FEFEFE", "#FFFFFF"
};
NS_IMPL_ISUPPORTS1(nsStdColorPicker, nsIColorPicker)
nsStdColorPicker::nsStdColorPicker()
{
mColors = 0;
mNumCols = 0;
mNumRows = 0;
mFrameWidth = 0;
mFrameHeight = 0;
mBlockWidth = 20;
mBlockHeight = 20;
}
nsStdColorPicker::~nsStdColorPicker()
{
}
NS_IMETHODIMP nsStdColorPicker::Init(nsIContent *aContent)
{
nsAutoString palette;
aContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::palettename, palette);
if (palette.EqualsIgnoreCase("web"))
{
printf("web picked\n");
mPalette = WebPalette;
mNumCols = 12;
mColors = sizeof(WebPalette) / sizeof(char *);
}
else if (palette.EqualsIgnoreCase("nose"))
{
printf("nose picked\n");
mPalette = NosePalette;
mNumCols = 10;
mColors = sizeof(NosePalette) / sizeof(char *);
}
else if (palette.EqualsIgnoreCase("gray") || palette.EqualsIgnoreCase("grey"))
{
printf("gray picked\n");
mPalette = GrayPalette;
mNumCols = 10;
mColors = sizeof(GrayPalette) / sizeof(char *);
}
else
{
printf("standard picked\n");
mPalette = StandardPalette;
mNumCols = 10;
mColors = sizeof(StandardPalette) / sizeof(char *);
}
mNumRows = NSToIntCeil(nscoord(mColors/mNumCols)) - 1;
return NS_OK;
}
NS_IMETHODIMP nsStdColorPicker::Paint(nsIPresContext * aPresContext, nsIRenderingContext * aRenderingContext)
{
int i = 0;
int row = 0;
int col = 0;
nscolor color = 0;
float p2t;
PRInt32 width, height;
aPresContext->GetScaledPixelsToTwips(&p2t);
width = NSToIntRound(mBlockWidth * p2t);
height = NSToIntRound(mBlockHeight * p2t);
// aRenderingContext->SetColor(0);
// aRenderingContext->FillRect(0, 0, (mNumCols)*width, mNumRows*height);
for (i=0;i<mColors;i++)
{
NS_LooseHexToRGB(mPalette[i], &color);
aRenderingContext->SetColor(color);
aRenderingContext->FillRect(col*width, row*height, width, height);
if (col+1 == mNumCols)
{
col = 0;
row++;
}
else
col++;
}
return NS_OK;
}
NS_IMETHODIMP nsStdColorPicker::GetColor(PRInt32 aX, PRInt32 aY, char **aColor)
{
int cur_col = aX / mBlockWidth;
int cur_row = aY / mBlockHeight;
int f = mNumCols * cur_row + cur_col;
if (f >= mColors)
{
return NS_ERROR_FAILURE;
}
*aColor = nsCRT::strdup(mPalette[f]);
return NS_OK;
}
NS_IMETHODIMP nsStdColorPicker::SetSize(PRInt32 aWidth, PRInt32 aHeight)
{
mFrameWidth = aWidth;
mFrameHeight = aHeight;
if (aWidth != -1)
mBlockWidth = NSToIntRound(nscoord(aWidth / mNumCols));
if (aWidth != -1)
mBlockHeight = NSToIntRound(nscoord(aHeight / mNumRows));
mFrameWidth = NSToIntRound(nscoord((mNumCols) * mBlockWidth));
mFrameHeight = NSToIntRound(nscoord((mNumRows) * mBlockHeight));
return NS_OK;
}
NS_IMETHODIMP nsStdColorPicker::GetSize(PRInt32 *aWidth, PRInt32 *aHeight)
{
*aWidth = mFrameWidth;
*aHeight = mFrameHeight;
return NS_OK;
}

View File

@@ -1,55 +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>
*/
#ifndef __nsStdColorPicker_h__
#define __nsStdColorPicker_h__
#include "nsISupports.h"
#include "nsrootidl.h"
#include "nsIPresContext.h"
#include "nsIRenderingContext.h"
#include "nsIColorPicker.h"
class nsStdColorPicker : public nsIColorPicker {
public:
nsStdColorPicker();
virtual ~nsStdColorPicker();
NS_DECL_ISUPPORTS
NS_DECL_NSICOLORPICKER
private:
char **mPalette;
PRInt32 mColors;
PRInt32 mNumCols;
PRInt32 mNumRows;
PRInt32 mBlockWidth;
PRInt32 mBlockHeight;
PRInt32 mFrameWidth;
PRInt32 mFrameHeight;
};
#endif /* __nsStdColorPicker_h__ */

View File

@@ -1,173 +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 "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 Communicator client 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.
*/
//
// Eric Vaughan
// Netscape Communications
//
// See documentation in associated header file
//
#include "nsTabFrame.h"
#include "nsIStyleContext.h"
#include "nsIPresContext.h"
#include "nsIContent.h"
#include "nsCOMPtr.h"
#include "nsHTMLIIDs.h"
#include "nsUnitConversion.h"
#include "nsINameSpaceManager.h"
#include "nsHTMLAtoms.h"
#include "nsXULAtoms.h"
#include "nsIReflowCommand.h"
#include <stdio.h>
//
// NS_NewToolbarFrame
//
// Creates a new Toolbar frame and returns it in |aNewFrame|
//
nsresult
NS_NewTabFrame ( nsIFrame** aNewFrame )
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsTabFrame* it = new nsTabFrame;
if (nsnull == it)
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
} // NS_NewTabFrame
void
nsTabFrame::MouseClicked(nsIPresContext* aPresContext)
{
// get our index
PRInt32 index = 0;
GetIndexInParent(mContent, index);
// get the tab control
nsIContent* tabcontrol = nsnull;
GetTabControl(mContent, tabcontrol);
// get the tab panel
nsIContent* tabpanel = nsnull;
GetChildWithTag(nsXULAtoms::tabpanel, tabcontrol, tabpanel);
if (!tabpanel) {
return;
}
// unselect the old tab
// get the current index
nsAutoString v;
PRInt32 error;
tabpanel->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::index, v);
PRInt32 oldIndex = v.ToInteger(&error);
if (oldIndex != index)
{
// get the tab box
nsIContent* parent;
mContent->GetParent(parent);
// get child
nsIContent* child;
parent->ChildAt(oldIndex, child);
// set the old tab to be unselected
child->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::selected, "false", PR_TRUE);
// set the new tab to be selected
mContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::selected, "true", PR_TRUE);
}
// set the panels index
char value[100];
sprintf(value, "%d", index);
tabpanel->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::index, value, PR_TRUE);
}
nsresult
nsTabFrame::GetChildWithTag(nsIAtom* atom, nsIContent* start, nsIContent*& tabpanel)
{
// recursively search our children
PRInt32 count = 0;
start->ChildCount(count);
for (PRInt32 i = 0; i < count; i++)
{
nsIContent* child = nsnull;
start->ChildAt(i,child);
// see if it is the child
nsCOMPtr<nsIAtom> tag;
child->GetTag(*getter_AddRefs(tag));
if (tag.get() == atom)
{
tabpanel = child;
return NS_OK;
}
// recursive search the child
nsIContent* found = nsnull;
GetChildWithTag(atom, child, found);
if (found != nsnull) {
tabpanel = found;
return NS_OK;
}
}
tabpanel = nsnull;
return NS_OK;
}
nsresult
nsTabFrame::GetTabControl(nsIContent* content, nsIContent*& tabcontrol)
{
while(nsnull != content)
{
content->GetParent(content);
if (content) {
nsCOMPtr<nsIAtom> atom;
if (content->GetTag(*getter_AddRefs(atom)) == NS_OK && atom.get() == nsXULAtoms::tabcontrol) {
tabcontrol = content;
return NS_OK;
}
}
}
tabcontrol = nsnull;
return NS_OK;
}
nsresult
nsTabFrame::GetIndexInParent(nsIContent* content, PRInt32& index)
{
nsIContent* parent;
content->GetParent(parent);
return parent->IndexOf(content, index);
}

View File

@@ -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 "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 Communicator client 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.
*/
/**
Eric D Vaughan
This class lays out its children either vertically or horizontally
**/
#ifndef nsTabFrame_h___
#define nsTabFrame_h___
#include "nsHTMLButtonControlFrame.h"
class nsTabControlFrame;
class nsTabFrame : public nsHTMLButtonControlFrame
{
public:
friend nsresult NS_NewTabFrame(nsIFrame** aNewFrame);
virtual void MouseClicked(nsIPresContext* aPresContext);
protected:
virtual nsresult GetChildWithTag(nsIAtom* atom, nsIContent* start, nsIContent*& tabpanel);
virtual nsresult GetTabControl(nsIContent* content, nsIContent*& tabcontrol);
virtual nsresult GetIndexInParent(nsIContent* content, PRInt32& index);
// Selection Methods
// XXX Doc me... (in nsIFrame.h puhleeze)
// XXX If these are selection specific, then the name should imply selection
// rather than generic event processing, e.g., SelectionHandlePress...
NS_IMETHOD HandlePress(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus) { return NS_OK; }
NS_IMETHOD HandleMultiplePress(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus) { return NS_OK; }
NS_IMETHOD HandleDrag(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus) { return NS_OK; }
NS_IMETHOD HandleRelease(nsIPresContext& aPresContext,
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus) { return NS_OK; }
private:
nsTabControlFrame* mTabControlFrame;
}; // class nsTabFrame
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,180 +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 "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 Communicator client 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.
*/
#ifndef nsTitledButtonFrame_h___
#define nsTitledButtonFrame_h___
#include "nsHTMLImageLoader.h"
#include "nsLeafFrame.h"
#include "nsIBox.h"
class nsIPopUpMenu;
class nsTitledButtonRenderer;
class nsTitledButtonFrame : public nsLeafFrame, public nsIBox
{
public:
enum CroppingStyle { CropNone, CropLeft, CropRight, CropCenter };
friend nsresult NS_NewTitledButtonFrame(nsIFrame** aNewFrame);
// nsIBox frame interface
NS_IMETHOD GetBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize);
NS_IMETHOD Dirty(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame*& incrementalChild);
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* asPrevInFlow);
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint);
NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext** aStyleContext) const;
NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext* aStyleContext);
NS_IMETHOD DidSetStyleContext (nsIPresContext* aPresContext);
NS_IMETHOD Destroy(nsIPresContext& aPresContext);
NS_IMETHOD GetFrameName(nsString& aResult) const;
virtual void UpdateAttributes(nsIPresContext& aPresContext);
virtual void UpdateImage(nsIPresContext& aPresContext);
// nsIHTMLReflow overrides
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
~nsTitledButtonFrame();
protected:
enum CheckState { eUnset, eOff, eOn, eMixed } ;
CheckState GetCurrentCheckState();
void SetCurrentCheckState(CheckState aState);
void UpdateAccessUnderline();
virtual void MouseClicked(nsIPresContext & aPresContext);
NS_IMETHOD PaintTitle(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD PaintImage(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
virtual void LayoutTitleAndImage(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
virtual void GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredSize);
void DisplayAltFeedback(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
PRInt32 aIconId);
void DisplayAltText(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsString& aAltText,
const nsRect& aRect);
void MeasureString(const PRUnichar* aString,
PRInt32 aLength,
nscoord aMaxWidth,
PRUint32& aMaxFit,
nsIRenderingContext& aContext);
nsTitledButtonFrame();
virtual void CalculateTitleForWidth(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, nscoord aWidth);
virtual void GetTextSize(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsString& aString, nsSize& aSize);
virtual void SetDisabled(nsAutoString aDisabled);
static nsresult UpdateImageFrame(nsIPresContext* aPresContext,
nsHTMLImageLoader* aLoader,
nsIFrame* aFrame,
void* aClosure,
PRUint32 aStatus);
void GetImageSource(nsString& aResult);
virtual void GetImageSize(nsIPresContext* aPresContext);
private:
// tri state methods
void CheckStateToString ( CheckState inState, nsString& outStateAsString ) ;
CheckState StringToCheckState ( const nsString & aStateAsString ) ;
PRBool mHasOnceBeenInMixedState;
CroppingStyle mCropType;
PRIntn mAlign;
nsString mTitle;
nsString mCroppedTitle;
nsHTMLImageLoader mImageLoader;
PRBool mSizeFrozen;
nsMargin mBorderPadding;
nsRect mImageRect;
nsRect mTitleRect;
PRBool mNeedsLayout;
nscoord mSpacing;
nsTitledButtonRenderer* mRenderer;
PRBool mHasImage;
// accesskey highlighting
PRBool mNeedsAccessUpdate;
PRInt32 mAccesskeyIndex;
nscoord mBeforeWidth, mAccessWidth, mAccessUnderlineSize, mAccessOffset;
// nsIPopUpMenu * mPopUpMenu;
// PRBool mMenuIsPoppedUp;
}; // class nsTitledButtonFrame
#endif /* nsTitledButtonFrame_h___ */

View File

@@ -1,457 +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 "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 Communicator client 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.
*/
#include "nsToolbarDragListener.h"
#include "nsToolbarFrame.h"
#include "nsCOMPtr.h"
#include "nsIDOMMouseEvent.h"
#include "nsIPresContext.h"
#include "nsIContent.h"
#include "nsIDOMElement.h"
#include "nsXULAtoms.h"
#include "nsIEventStateManager.h"
#include "nsISupportsPrimitives.h"
#include "nsINameSpaceManager.h"
#include "nsIDOMXULDocument.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
NS_IMPL_ADDREF(nsToolbarDragListener)
NS_IMPL_RELEASE(nsToolbarDragListener)
//
// nsToolbarDragListener ctor
//
// Init member variables. We can't really do much of anything important here because
// any subframes might not be totally intialized yet, or in the hash table
//
nsToolbarDragListener :: nsToolbarDragListener ( nsToolbarFrame* inToolbar, nsIPresContext* inPresContext )
: mToolbar(inToolbar), mPresContext(inPresContext), mCurrentDropLoc(-1)
{
NS_INIT_REFCNT();
// we really need this all over the place. just be safe that we have it.
NS_ASSERTION ( mPresContext, "no pres context set on toolbar drag listener" );
} // nsToolbarDragListener ctor
//
// nsToolbarDragListener dtor
//
// Cleanup.
//
nsToolbarDragListener::~nsToolbarDragListener()
{
}
//
// QueryInterface
//
// Modeled after scc's reference implementation
// http://www.mozilla.org/projects/xpcom/QI.html
//
nsresult
nsToolbarDragListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if ( !aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(nsCOMTypeInfo<nsIDOMEventListener>::GetIID()))
*aInstancePtr = NS_STATIC_CAST(nsIDOMEventListener*, NS_STATIC_CAST(nsIDOMDragListener*, this));
else if (aIID.Equals(nsCOMTypeInfo<nsIDOMDragListener>::GetIID()))
*aInstancePtr = NS_STATIC_CAST(nsIDOMDragListener*, this);
else if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID()))
*aInstancePtr = NS_STATIC_CAST(nsISupports*, NS_STATIC_CAST(nsIDOMDragListener*, this));
else
*aInstancePtr = 0;
nsresult status;
if ( !*aInstancePtr )
status = NS_NOINTERFACE;
else {
NS_ADDREF( NS_REINTERPRET_CAST(nsISupports*, *aInstancePtr) );
status = NS_OK;
}
return status;
}
////////////////////////////////////////////////////////////////////////
nsresult
nsToolbarDragListener::HandleEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
nsresult
nsToolbarDragListener::DragGesture(nsIDOMEvent* aDragEvent)
{
// this code should all be in JS.
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
nsresult
nsToolbarDragListener::DragEnter(nsIDOMEvent* aDragEvent)
{
// We don't need to do anything special here. If anything does need to be done,
// the code should all be in JS.
return NS_OK;
}
//
// ItemMouseIsOver
//
// Figure out which child item mouse is over. |outIndex| is the index of the item the object
// should be dropped _before_. Therefore if the item should be dropped at the end, the index
// will be greater than the number of items in the list. |outOnChild| is true if the item
// is a container and the drop would be "on" that item.
//
void
nsToolbarDragListener :: ItemMouseIsOver ( nsIDOMEvent* aDragEvent, nscoord* outXLoc,
PRUint32* outIndex, PRBool* outOnChild )
{
*outOnChild = PR_FALSE;
// figure out which frame is the right one for determining the drop feedback. Do we
// want to do this every time? We certainly can't do it upon toolbar creation (hash
// tables not setup at that time), so we're forced to do it now. What happens if while
// we're dragging some rule gets fired that causes the frame to go away?
nsIFrame* dropAreaFrame = LocateDropAreaFrame();
if ( !dropAreaFrame ) {
// gaaak, we're doomed.
outIndex = 0;
outXLoc = 0;
return;
}
//
// Get the mouse coordinates from the DOM event, but they will be in the
// window/widget coordinate system. We must first get them into the frame-relative
// coordinate system. Yuck.
//
// get mouse coordinates and translate them into twips
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aDragEvent));
PRInt32 x,y = 0;
mouseEvent->GetClientX(&x);
mouseEvent->GetClientY(&y);
float p2t;
mPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord xp = NSIntPixelsToTwips(x, p2t);
nscoord yp = NSIntPixelsToTwips(y, p2t);
// compute the offset to top level in twips
PRInt32 frameOffsetX = 0, frameOffsetY = 0;
nsIFrame* curr = dropAreaFrame;
curr->GetParent(&curr);
float t2p;
mPresContext->GetTwipsToPixels(&t2p);
while ( curr ) {
nsPoint origin;
curr->GetOrigin(origin); // in twips
frameOffsetX += origin.x; // build the offset incrementally
frameOffsetY += origin.y;
curr->GetParent(&curr); // moving up the chain
} // until we reach the top
// subtract the offset from the x,y coord to put into frame relative coordinates.
xp -= frameOffsetX;
yp -= frameOffsetY;
nsPoint pnt(xp, yp);
// get the toolbar's rect
nsRect tbRect;
dropAreaFrame->GetRect(tbRect);
PRUint32 count = 0;
PRBool found = PR_FALSE;
nsIFrame* childFrame;
nsRect rect; // child frame's rect
nsRect prevRect(-1, -1, 0, 0);
//
// Now loop through the child and see if the mouse is over a child
//
dropAreaFrame->FirstChild(nsnull, &childFrame);
while ( childFrame ) {
// The mouse coords are in the toolbar's domain
// Get child's rect and adjust to the toolbar's domain
childFrame->GetRect(rect);
rect.MoveBy(tbRect.x, tbRect.y);
// remember the previous child x location
if (pnt.x < rect.x && prevRect.x == -1)
prevRect = rect;
// now check to see if the mouse inside an items bounds
if (rect.Contains(pnt)) {
nsCOMPtr<nsIContent> content;
childFrame->GetContent(getter_AddRefs(content));
if ( content ) {
nsCOMPtr<nsIAtom> tag;
content->GetTag(*getter_AddRefs(tag));
// for now I am checking for both titlebutton and toolbar items
// XXX but the check for titlebutton should be removed in the future
if (tag.get() == nsXULAtoms::titledbutton || tag.get() == nsXULAtoms::toolbaritem) {
// now check if item is a container
PRBool isContainer = PR_FALSE;
nsCOMPtr<nsIDOMElement> domElement ( do_QueryInterface(content) );
if ( domElement ) {
nsAutoString value;
domElement->GetAttribute(nsAutoString("container"), value); // can't use an atom here =(
isContainer = value.Equals("true");
}
else
NS_WARNING("Not a DOM element");
// if we have a container, the area is broken up into 3 pieces (left, middle, right). If
// it isn't it's only broken up into two (left and right)
PRInt32 xc = -1;
if ( isContainer ) {
if (pnt.x <= (rect.x + (rect.width / 4))) {
*outIndex = count;
xc = rect.x - tbRect.x;
}
else if (pnt.x >= (rect.x + PRInt32(float(rect.width) *0.75))) {
*outIndex = count + 1;
xc = rect.x - tbRect.x + rect.width - onePixel;
}
else {
// we're on a container, don't draw anything so xc shouldn't get set.
*outIndex = count;
*outOnChild = PR_TRUE;
}
} else {
if (pnt.x <= (rect.x + (rect.width / 2))) {
*outIndex = count;
xc = rect.x - tbRect.x;
}
else {
*outIndex = count + 1;
xc = rect.x - tbRect.x + rect.width + onePixel;
}
}
*outXLoc = xc;
}
else {
// mouse is over something (probably a spacer) so return the left side of
// the spacer.
*outXLoc = rect.x - tbRect.x;
*outIndex = count;
}
// found something, break out of the loop
found = PR_TRUE;
break;
}
} // if mouse is in an item
nsresult rv = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(rv == NS_OK,"failed to get next child");
count++;
} // foreach child
if (!found) {
*outIndex = count; // already incremented past last item
if ( count )
*outXLoc = prevRect.x - tbRect.x + rect.width + onePixel;
else
*outXLoc = onePixel;
}
}
//
// DragOver
//
// The mouse has moved over the toolbar while a drag is happening. We really just want to
// "annotate" the toolbar with the current drop location. We don't want to make any judgement
// as this stage as to whether or not the drag should be accepted or draw any feedback.
//
nsresult
nsToolbarDragListener::DragOver(nsIDOMEvent* aDragEvent)
{
#if 0
nsCOMPtr<nsIContent> c;
mToolbar->GetContent ( getter_AddRefs(c) );
nsCOMPtr<nsIDOMNode> d ( do_QueryInterface(c) );
nsCOMPtr<nsIDOMNode> t;
aDragEvent->GetTarget ( getter_AddRefs(t) );
printf ( "DRAGOVER:: toolbar content is %ld, as DOMNode %ld, target is %ld\n", c, d, t );
#endif
// Check to see if the mouse is over an item and which one it is.
nscoord xLoc = 0;
PRBool onChild;
PRUint32 beforeIndex = 0;
ItemMouseIsOver(aDragEvent, &xLoc, &beforeIndex, &onChild);
if ( xLoc != mCurrentDropLoc ) {
// stash the new location in the toolbar's content model. Note that the toolbar code doesn't
// care at all about "tb-droplocation", only the coordinate so there is no need to send the
// AttributeChanged() about that attribute.
nsCOMPtr<nsIContent> content;
mToolbar->GetContent ( getter_AddRefs(content) );
if ( content ) {
char buffer[10];
// need the cast, because on some platforms, PR[U]int32 != long, but we're using "%ld"
sprintf(buffer, "%ld", NS_STATIC_CAST(long, xLoc));
content->SetAttribute ( kNameSpaceID_None, nsXULAtoms::tbDropLocationCoord, buffer, PR_TRUE );
sprintf(buffer, "%ld", NS_STATIC_CAST(long, beforeIndex));
content->SetAttribute ( kNameSpaceID_None, nsXULAtoms::tbDropLocation, "1", PR_FALSE );
content->SetAttribute ( kNameSpaceID_None, nsXULAtoms::tbDropOn, onChild ? "true" : "false", PR_FALSE );
}
// cache the current drop location
mCurrentDropLoc = xLoc;
}
// NS_OK means event is NOT consumed. We want to make sure JS gets this so it
// can determine if the drag is allowed.
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
nsresult
nsToolbarDragListener::DragExit(nsIDOMEvent* aDragEvent)
{
// there are some bugs that cause us to not be able to correctly track dragExit events
// so until then we just get on our knees and pray we don't get fooled again.
#if 0
nsCOMPtr<nsIContent> c;
mToolbar->GetContent ( getter_AddRefs(c) );
nsCOMPtr<nsIDOMNode> d ( do_QueryInterface(c) );
nsCOMPtr<nsIDOMNode> t;
aDragEvent->GetTarget ( getter_AddRefs(t) );
printf ( "DRAGEXIT:: toolbar DOMNode %ld, target is %ld\n", d, t );
nsCOMPtr<nsIContent> content;
mToolbar->GetContent ( getter_AddRefs(content) );
// we will get a drag exit event on sub items because we catch the event on the way down. If
// the target is not our toolbar, then ignore it.
nsCOMPtr<nsIDOMNode> toolbarDOMNode ( do_QueryInterface(content) );
nsCOMPtr<nsIDOMNode> eventTarget;
aDragEvent->GetTarget ( getter_AddRefs(eventTarget) );
if ( eventTarget != toolbarDOMNode )
return NS_OK;
printf("***REAL EXIT EVENT\n");
// tell the toolbar to not do any more drop feedback. Note that the toolbar code doesn't
// care at all about "tb-droplocation", only the coordinate so there is no need to send the
// AttributeChanged() about that attribute.
char buffer[10];
sprintf(buffer, "%ld", -1);
content->SetAttribute ( kNameSpaceID_None, nsXULAtoms::tbDropLocationCoord, buffer, PR_TRUE );
content->SetAttribute ( kNameSpaceID_None, nsXULAtoms::tbDropLocation, buffer, PR_FALSE );
// cache the current drop location
mCurrentDropLoc = -1;
#endif
return NS_OK; // don't consume event
}
////////////////////////////////////////////////////////////////////////
nsresult
nsToolbarDragListener::DragDrop(nsIDOMEvent* aMouseEvent)
{
// this code should all be in JS.
return NS_OK;
}
//
// LocateDropAreaFrame
//
// Returns the frame (or subframe) that contains the buttons that can be dragged.
// Either it will be the toolbar frame as a whole, or it will be some subframe of the bar id'd by
// the |dragdroparea| attribute.
//
nsIFrame*
nsToolbarDragListener :: LocateDropAreaFrame ( )
{
nsIFrame* retVal = nsnull;
// is a subframe the drag/drop area? determine if the attribute is set.
nsString dropAreaID;
PRBool dropAreaIsSubframe = PR_FALSE;
nsCOMPtr<nsIContent> toolbarContent;
mToolbar->GetContent ( getter_AddRefs(toolbarContent) );
if ( toolbarContent ) {
if ( toolbarContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::tbDragDropArea, dropAreaID) == NS_CONTENT_ATTR_HAS_VALUE )
dropAreaIsSubframe = PR_TRUE;
}
// if there is a named subframe, go find it, otherwise use the entire toolbar
if ( dropAreaIsSubframe ) {
// get the presShell so we can call GetPrimaryFrameFor later.
nsCOMPtr<nsIPresShell> presShell;
mPresContext->GetShell ( getter_AddRefs(presShell) );
// get the document so we can get do a GetElementByID.
nsCOMPtr<nsIDocument> document;
toolbarContent->GetDocument ( *getter_AddRefs(document) );
if ( document ) {
nsCOMPtr<nsIDOMXULDocument> xulDoc ( do_QueryInterface(document) );
if ( xulDoc ) {
nsCOMPtr<nsIDOMElement> domElementOfSubframe;
xulDoc->GetElementById ( dropAreaID, getter_AddRefs(domElementOfSubframe) );
// finally get the frame associated with that dom node
nsCOMPtr<nsIContent> contentOfSubframe ( do_QueryInterface(domElementOfSubframe) );
if ( contentOfSubframe && presShell )
presShell->GetPrimaryFrameFor ( contentOfSubframe, &retVal );
}
}
} // if named subframe
else
retVal = mToolbar;
NS_ASSERTION ( retVal, "toolbar drag listener couldn't figure out the drag area." );
return retVal;
} // LocateDropAreaFrame

View File

@@ -1,70 +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 "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 Communicator client 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.
*/
#ifndef nsToolbarDragListener_h__
#define nsToolbarDragListener_h__
#include "nsIDOMDragListener.h"
#include "nsCoord.h"
class nsToolbarFrame;
class nsIPresContext;
class nsIDOMEvent;
class nsIFrame;
class nsToolbarDragListener : public nsIDOMDragListener
{
public:
// default ctor and dtor
nsToolbarDragListener ( nsToolbarFrame* inToolbar, nsIPresContext* inPresContext );
virtual ~nsToolbarDragListener();
// interfaces for addref and release and queryinterface
NS_DECL_ISUPPORTS
// nsIDOMDragListener
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);
virtual nsresult DragEnter(nsIDOMEvent* aDragEvent);
virtual nsresult DragOver(nsIDOMEvent* aDragEvent);
virtual nsresult DragExit(nsIDOMEvent* aDragEvent);
virtual nsresult DragDrop(nsIDOMEvent* aDragEvent);
virtual nsresult DragGesture(nsIDOMEvent* aDragEvent);
protected:
// Figure out which child item mouse is over. |outIndex| is the index of the item the object
// should be dropped _before_. Therefore if the item should be dropped at the end, the index
// will be greater than the number of items in the list. |outOnChild| is true if the item
// is a container and the drop would be "on" that item.
void ItemMouseIsOver(nsIDOMEvent* aDragEvent, nscoord* outXLoc, PRUint32* outIndex, PRBool* outOnChild);
// Find the frame (or subframe) that contains the buttons that can be dragged.
nsIFrame* LocateDropAreaFrame ( ) ;
nsToolbarFrame * mToolbar; // toolbar owns me, don't be circular
nsIPresContext * mPresContext; // weak reference
PRInt32 mCurrentDropLoc;
}; // class nsToolbarDragListener
#endif

View File

@@ -1,449 +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 "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 Communicator client 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.
*/
//
// Mike Pinkerton
// Netscape Communications
//
// See documentation in associated header file
//
#include "nsToolbarFrame.h"
#include "nsCSSRendering.h"
#include "nsToolbarDragListener.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMDragListener.h"
#include "nsIContent.h"
#include "nsIPresContext.h"
#include "nsIStyleContext.h"
#include "nsIViewManager.h"
#include "nsXULAtoms.h"
#include "nsINameSpaceManager.h"
#define TEMP_HACK_FOR_BUG_11291 1
#if TEMP_HACK_FOR_BUG_11291
// for temp fix of bug 11291. This should really be in JavaScript, I think.
#include "nsIDOMNodeList.h"
#include "nsIDOMElement.h"
class nsTEMPDragGestureEater : public nsIDOMDragListener
{
public:
// default ctor and dtor
nsTEMPDragGestureEater ( ) ;
virtual ~nsTEMPDragGestureEater() { };
// interfaces for addref and release and queryinterface
NS_DECL_ISUPPORTS
// nsIDOMMouseListener
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);
virtual nsresult DragEnter(nsIDOMEvent* aMouseEvent);
virtual nsresult DragOver(nsIDOMEvent* aMouseEvent);
virtual nsresult DragExit(nsIDOMEvent* aMouseEvent);
virtual nsresult DragDrop(nsIDOMEvent* aMouseEvent);
virtual nsresult DragGesture(nsIDOMEvent* aMouseEvent);
}; // class nsTEMPDragGestureEater
NS_IMPL_ADDREF(nsTEMPDragGestureEater)
NS_IMPL_RELEASE(nsTEMPDragGestureEater)
nsTEMPDragGestureEater :: nsTEMPDragGestureEater ( )
{
NS_INIT_REFCNT();
}
//
// QueryInterface
//
// Modeled after scc's reference implementation
// http://www.mozilla.org/projects/xpcom/QI.html
//
nsresult
nsTEMPDragGestureEater::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if ( !aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(nsCOMTypeInfo<nsIDOMEventListener>::GetIID()))
*aInstancePtr = NS_STATIC_CAST(nsIDOMEventListener*, this);
else if (aIID.Equals(nsCOMTypeInfo<nsIDOMDragListener>::GetIID()))
*aInstancePtr = NS_STATIC_CAST(nsIDOMDragListener*, this);
else if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID()))
*aInstancePtr = NS_STATIC_CAST(nsISupports*, NS_STATIC_CAST(nsIDOMDragListener*, this));
else
*aInstancePtr = 0;
nsresult status;
if ( !*aInstancePtr )
status = NS_NOINTERFACE;
else {
NS_ADDREF( NS_REINTERPRET_CAST(nsISupports*, *aInstancePtr) );
status = NS_OK;
}
return status;
}
nsresult
nsTEMPDragGestureEater :: HandleEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}
nsresult
nsTEMPDragGestureEater::DragGesture(nsIDOMEvent* aMouseEvent)
{
// we want the text widget to see this event, but not anyone above us that
// might be registered as a listener for drags. Therefore, don't
// allow this event to bubble.
aMouseEvent->PreventBubble();
return NS_ERROR_BASE; // means I AM consuming event
}
nsresult
nsTEMPDragGestureEater::DragEnter(nsIDOMEvent* aMouseEvent)
{
return NS_OK; // means I am NOT consuming event
}
nsresult
nsTEMPDragGestureEater::DragOver(nsIDOMEvent* aMouseEvent)
{
return NS_OK; // means I am NOT consuming event
}
nsresult
nsTEMPDragGestureEater::DragExit(nsIDOMEvent* aMouseEvent)
{
return NS_OK; // means I am NOT consuming event
}
nsresult
nsTEMPDragGestureEater::DragDrop(nsIDOMEvent* aMouseEvent)
{
return NS_OK; // means I am NOT consuming event
}
#endif /* TEMP_HACK_FOR_BUG_11291 */
#ifdef XP_MAC
#pragma mark -
#endif
//
// NS_NewToolbarFrame
//
// Creates a new Toolbar frame and returns it in |aNewFrame|
//
nsresult
NS_NewToolbarFrame ( nsIFrame** aNewFrame )
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsToolbarFrame* it = new nsToolbarFrame;
if (nsnull == it)
return NS_ERROR_OUT_OF_MEMORY;
// it->SetFlags(aFlags);
* aNewFrame = it;
return NS_OK;
} // NS_NewToolbarFrame
//
// nsToolbarFrame ctor
//
// Most of the work need to be delayed until Init(). Lame!
//
nsToolbarFrame :: nsToolbarFrame ( )
: mXDropLoc ( -1 )
{
}
//
// nsToolbarFrame dtor
//
// Cleanup. Remove our registered event listener from the content model.
//
nsToolbarFrame :: ~nsToolbarFrame ( )
{
nsCOMPtr<nsIContent> content;
GetContent(getter_AddRefs(content));
nsCOMPtr<nsIDOMEventReceiver> reciever(do_QueryInterface(content));
// NOTE: the Remove will delete the drag listener
reciever->RemoveEventListenerByIID((nsIDOMDragListener *)mDragListener, nsIDOMDragListener::GetIID());
}
//
// Init
//
// Setup event listeners for drag and drop. Our frame's lifetime is bounded by the
// lifetime of the content model, so we're guaranteed that the content node won't go away on us. As
// a result, our drag listener can't go away before the frame is deleted. Since the content
// node holds owning references to our drag listener, which we tear down in the dtor, there is no
// need to hold an owning ref to it ourselves.
//
NS_IMETHODIMP
nsToolbarFrame::Init ( nsIPresContext& aPresContext, nsIContent* aContent,
nsIFrame* aParent, nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
nsCOMPtr<nsIContent> content;
GetContent(getter_AddRefs(content));
nsCOMPtr<nsIDOMEventReceiver> receiver(do_QueryInterface(content));
// register our drag over and exit capturers. These annotate the content object
// with enough info to determine where the drop would happen so that JS can
// do the right thing.
mDragListener = new nsToolbarDragListener(this, &aPresContext);
receiver->AddEventListener("dragover", mDragListener, PR_TRUE);
receiver->AddEventListener("dragexit", mDragListener, PR_TRUE);
#if 0 //TEMP_HACK_FOR_BUG_11291
// Ok, this is a hack until Ender lands. We need to have a mouse listener on text widgets
// in order to make sure that mouseDowns within the text widget don't bubble up to the toolbar
// listener. This would cause problems where selecting text and moving the mouse outside the text
// widget and into the toolbar would start a drag (bug #11291)
nsCOMPtr<nsIDOMElement> element ( do_QueryInterface(content) );
if ( element ) {
nsCOMPtr<nsIDOMNodeList> inputList;
element->GetElementsByTagName("INPUT", getter_AddRefs(inputList));
if ( inputList ) {
PRUint32 length = 0;
inputList->GetLength(&length);
for ( PRUint32 i = 0; i < length; ++i ) {
nsCOMPtr<nsIDOMNode> node;
inputList->Item(i, getter_AddRefs(node));
receiver = do_QueryInterface(node);
if ( receiver )
receiver->AddEventListenerByIID(new nsTEMPDragGestureEater, nsIDOMDragListener::GetIID());
// yes, i know this will leak. That's ok, i don't care because this code will go away
}
}
}
#endif
return rv;
}
//
// Paint
//
// Paint our background and border like normal frames, but before we draw the
// children, draw our grippies for each toolbar.
//
NS_IMETHODIMP
nsToolbarFrame :: Paint ( nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
{
nsresult res = nsBoxFrame::Paint ( aPresContext, aRenderingContext, aDirtyRect, aWhichLayer );
if (mXDropLoc != -1) {
// XXX this is temporary
if (!mMarkerStyle) {
nsCOMPtr<nsIAtom> atom ( getter_AddRefs(NS_NewAtom(":-moz-drop-marker")) );
aPresContext.ProbePseudoStyleContextFor(mContent, atom, mStyleContext,
PR_FALSE, getter_AddRefs(mMarkerStyle));
}
nscolor color;
if (mMarkerStyle) {
const nsStyleColor* styleColor = (const nsStyleColor*)mMarkerStyle->GetStyleData(eStyleStruct_Color);
color = styleColor->mColor;
} else {
color = NS_RGB(0,0,0);
}
// draw different drop feedback depending on if we have subitems or not
int numChildren = 0;
mContent->ChildCount(numChildren);
if ( numChildren ) {
aRenderingContext.SetColor(color);
nsRect dividingLine ( mXDropLoc, 0, 40, mRect.height );
aRenderingContext.FillRect(dividingLine);
}
else
aRenderingContext.DrawRect ( mRect );
}
return res;
} // Paint
//
// GetFrameForPoint
//
// Override to process events in our own frame
//
NS_IMETHODIMP
nsToolbarFrame :: GetFrameForPoint ( nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIFrame** aFrame)
{
nsresult retVal = nsHTMLContainerFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
// returning NS_OK means that we tell the frame finding code that we have something
// and to stop looking elsewhere for a frame.
if ( aFrame && *aFrame == this )
retVal = NS_OK;
else if ( retVal != NS_OK ) {
*aFrame = this;
retVal = NS_OK;
}
return retVal;
} // GetFrameForPoint
//
// HandleEvent
//
// Process events that come to this frame. If they end up here, they are
// almost certainly drag and drop events.
//
NS_IMETHODIMP
nsToolbarFrame :: HandleEvent ( nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
if ( !aEvent )
return nsEventStatus_eIgnore;
switch (aEvent->message) {
case NS_DRAGDROP_ENTER:
if (!mMarkerStyle) {
nsCOMPtr<nsIAtom> atom ( getter_AddRefs(NS_NewAtom(":-moz-drop-marker")) );
aPresContext.ProbePseudoStyleContextFor(mContent, atom, mStyleContext,
PR_FALSE,
getter_AddRefs(mMarkerStyle));
}
break;
}
//XXX this needs to change when I am really handling the D&D events
return nsBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
} // HandleEvent
#if NOT_YET_NEEDED
/**
* Call this when styles change
*/
void
nsToolbarFrame::ReResolveStyles(nsIPresContext& aPresContext,
PRInt32 aParentChange,
nsStyleChangeList* aChangeList,
PRInt32* aLocalChange)
{
// style that draw an Marker around the button
// see if the Marker has changed.
/*nsCOMPtr<nsIStyleContext> oldMarker = mMarkerStyle;
nsCOMPtr<nsIAtom> atom ( getter_AddRefs(NS_NewAtom(":-moz-marker")) );
aPresContext.ProbePseudoStyleContextFor(mContent, atom, mStyleContext,
PR_FALSE,
getter_AddRefs(mMarkerStyle));
if ((mMarkerStyle && oldMarker) && (mMarkerStyle != oldMarker)) {
nsFrame::CaptureStyleChangeFor(this, oldMarker, mMarkerStyle,
aParentChange, aChangeList, aLocalChange);
}*/
}
#endif
////////////////////////////////////////////////////////////////////////
// This is temporary until the bubling of event for CSS actions work
////////////////////////////////////////////////////////////////////////
static void ForceDrawFrame(nsIPresContext* aPresContext, nsIFrame * aFrame);
static void ForceDrawFrame(nsIPresContext* aPresContext, nsIFrame * aFrame)
{
if (aFrame == nsnull) {
return;
}
nsRect rect;
nsIView * view;
nsPoint pnt;
aFrame->GetOffsetFromView(aPresContext, pnt, &view);
aFrame->GetRect(rect);
rect.x = pnt.x;
rect.y = pnt.y;
if (view) {
nsCOMPtr<nsIViewManager> viewMgr;
view->GetViewManager(*getter_AddRefs(viewMgr));
if (viewMgr)
viewMgr->UpdateView(view, rect, NS_VMREFRESH_AUTO_DOUBLE_BUFFER | NS_VMREFRESH_IMMEDIATE);
}
}
//
// AttributeChanged
//
// Track several attributes set by the d&d drop feedback tracking mechanism. The first
// is the "tb-triggerrepaint" attribute so JS can trigger a repaint when it
// needs up update the drop feedback. The second is the x (or y, if bar is vertical)
// coordinate of where the drop feedback bar should be drawn.
//
NS_IMETHODIMP
nsToolbarFrame :: AttributeChanged ( nsIPresContext* aPresContext, nsIContent* aChild,
PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aHint)
{
nsresult rv = NS_OK;
if ( aAttribute == nsXULAtoms::tbTriggerRepaint )
ForceDrawFrame ( aPresContext, this );
else if ( aAttribute == nsXULAtoms::tbDropLocationCoord ) {
nsAutoString attribute;
aChild->GetAttribute ( kNameSpaceID_None, aAttribute, attribute );
char* iHateNSString = attribute.ToNewCString();
mXDropLoc = atoi( iHateNSString );
nsAllocator::Free ( iHateNSString );
}
else
rv = nsBoxFrame::AttributeChanged ( aPresContext, aChild, aNameSpaceID, aAttribute, aHint );
return rv;
} // AttributeChanged

View File

@@ -1,119 +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 "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 Communicator client 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.
*/
//
// Mike Pinkerton
// Netscape Communications
//
// nsToolbarFrame is a layout object that contains items (specified as
// children in the DOM). The layout for toolbars is a little complicated, but
// it basically just lays out its children in as a box. Toolbars themselves
// don't know anything about grippies (as in 4.x) but are associated with them
// through toolboxes. This allows a developer to create a standalone toolbar
// (for inclusion in a webpage), which obviously doesn't need to have a grippy.
//
// As mentioned above, the Toolbar expects its toolbars to be its children in
// the DOM. The exact structure of the children is documented on:
// http://www.mozilla.org/xpfe/DMWSpecNew.html
//
// This implementation of toolbars now uses evaughan's box code for layout
// of its children and to determine its size.
//
#ifndef nsToolbarFrame_h__
#define nsToolbarFrame_h__
#define TOOLBARITEM_MIME "moz/toolbaritem"
#define TOOLBAR_MIME "moz/toolbar"
#include "nsCOMPtr.h"
#include "nsBoxFrame.h"
#include "nsIStyleContext.h"
class nsIContent;
class nsIPresContext;
class nsIFrame;
class nsToolbarDragListener;
class nsToolbarFrame : public nsBoxFrame
{
public:
friend nsresult NS_NewToolbarFrame(nsIFrame** aNewFrame);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* asPrevInFlow);
// nsIHTMLReflow overrides
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
// nsFrame overrides
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint, // Overridden to capture events
nsIFrame** aFrame);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint) ;
#if WTF_IS_THIS
//¥¥¥ not sure at all where this comes from. I asked rods, no reply yet.
virtual void ReResolveStyles(nsIPresContext& aPresContext,
PRInt32 aParentChange,
nsStyleChangeList* aChangeList,
PRInt32* aLocalChange);
#endif
#if 0
void SetDropfeedbackLocation(nscoord aX) { mXDropLoc = aX; }
#endif
protected:
nsToolbarFrame();
virtual ~nsToolbarFrame();
// pass-by-value not allowed for a coordinator because it corresponds 1-to-1
// with an element in the UI.
nsToolbarFrame ( const nsToolbarFrame& aFrame ) ; // DO NOT IMPLEMENT
nsToolbarFrame& operator= ( const nsToolbarFrame& aFrame ) ; // DO NOT IMPLEMENT
// our event handler registered with the content model. See the discussion
// in Init() for why this is a weak ref.
nsToolbarDragListener* mDragListener;
// only used during drag and drop for drop feedback. These are not
// guaranteed to be meaningful when no drop is underway.
PRInt32 mXDropLoc;
nsCOMPtr<nsIStyleContext> mMarkerStyle;
}; // class nsToolbarFrame
#endif

View File

@@ -1,172 +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 "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 Communicator client 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.
*/
#include "nsToolbarItemFrame.h"
#include "nsCOMPtr.h"
#include "nsWidgetsCID.h"
// Drag & Drop, Clipboard Support
static NS_DEFINE_CID(kCDragServiceCID, NS_DRAGSERVICE_CID);
static NS_DEFINE_CID(kCTransferableCID, NS_TRANSFERABLE_CID);
static NS_DEFINE_IID(kCDataFlavorCID, NS_DATAFLAVOR_CID);
//
// NS_NewToolbarItemFrame (friend)
//
// Creates a new toolbar item frame and returns it in |aNewFrame|
//
nsresult
NS_NewToolbarItemFrame ( nsIFrame** aNewFrame )
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if ( !aNewFrame )
return NS_ERROR_NULL_POINTER;
nsToolbarItemFrame* it = new nsToolbarItemFrame;
if ( !it )
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
} // NS_NewToolbarItemFrame
//
// nsToolbarItemFrame ctor and dtor
//
nsToolbarItemFrame::nsToolbarItemFrame()
{
}
nsToolbarItemFrame::~nsToolbarItemFrame()
{
}
//
// Init
//
// Ummm, just forwards for now.
//
NS_IMETHODIMP
nsToolbarItemFrame::Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
return rv;
}
//
// Init
//
// Ummm, just forwards for now. Most of this code is now in the drag listener's
// mouseMoved event.
//
// ¥¥¥ remove all this.
//
NS_IMETHODIMP
nsToolbarItemFrame::HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
// if disabled do nothing
/*if (PR_TRUE == mRenderer.isDisabled()) {
return NS_OK;
}
switch (aEvent->message) {
case NS_KEY_PRESS:
if (NS_KEY_EVENT == aEvent->eventStructType) {
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
if (NS_VK_SPACE == keyEvent->keyCode || NS_VK_RETURN == keyEvent->keyCode) {
MouseClicked(aPresContext);
}
}
break;
case NS_MOUSE_LEFT_CLICK:
MouseClicked(aPresContext);
break;
}
*/
/* // Start Drag
nsIDragService* dragService;
nsresult rv = nsServiceManager::GetService(kCDragServiceCID,
nsIDragService::GetIID(),
(nsISupports **)&dragService);
if (NS_OK == rv) {
nsCOMPtr<nsITransferable> trans;
rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull,
nsITransferable::GetIID(), getter_AddRefs(trans));
nsCOMPtr<nsITransferable> trans2;
rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull,
nsITransferable::GetIID(), getter_AddRefs(trans2));
if ( trans && trans2 ) {
nsString textPlainFlavor ( "text/plain" );
trans->AddDataFlavor(&textPlainFlavor);
nsString dragText = "Drag Text";
PRUint32 len = 9;
trans->SetTransferData(&textPlainFlavor, dragText.ToNewCString(), len); // transferable consumes the data
trans2->AddDataFlavor(&textPlainFlavor);
nsString dragText2 = "More Drag Text";
len = 14;
trans2->SetTransferData(&textPlainFlavor, dragText2.ToNewCString(), len); // transferable consumes the data
nsCOMPtr<nsISupportsArray> items;
NS_NewISupportsArray(getter_AddRefs(items));
if ( items ) {
items->AppendElement(trans);
items->AppendElement(trans2);
dragService->InvokeDragSession(items, nsnull, nsIDragService::DRAGDROP_ACTION_COPY | nsIDragService::DRAGDROP_ACTION_MOVE);
}
}
nsServiceManager::ReleaseService(kCDragServiceCID, dragService);
} */
printf("ToolbarItem %d\n", aEvent->message);
return nsBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
/*
* We are a frame and we do not maintain a ref count
*/
NS_IMETHODIMP_(nsrefcnt)
nsToolbarItemFrame::AddRef(void)
{
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsToolbarItemFrame::Release(void)
{
return NS_OK;
}

View File

@@ -1,56 +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 "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 Communicator client 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.
*/
#ifndef nsToolbarItemFrame_h___
#define nsToolbarItemFrame_h___
#include "nsBoxFrame.h"
class nsIFrame;
class nsIPresContext;
class nsIStyleContext;
class nsToolbarItemFrame : public nsBoxFrame
{
public:
nsToolbarItemFrame();
~nsToolbarItemFrame();
friend nsresult NS_NewToolbarItemFrame(nsIFrame** aNewFrame);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* asPrevInFlow);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
}; // class nsToolbarItemFrame
#endif /* nsToolbarItemFrame_h___ */

View File

@@ -1,932 +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 "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 Communicator client 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.
*/
//
// Mike Pinkerton
// Netscape Communications
//
// Significant portions of the collapse/expanding code donated by Chris Lattner
// (sabre@skylab.org). Thanks Chris!
//
// See documentation in associated header file
//
#include "nsToolboxFrame.h"
#include "nsToolbarFrame.h" // needed for MIME definitions
#include "nsIStyleContext.h"
#include "nsCSSRendering.h"
#include "nsIReflowCommand.h"
#include "nsHTMLIIDs.h"
#include "nsIPresContext.h"
#include "nsIWidget.h"
#include "nsINameSpaceManager.h"
#include "nsIServiceManager.h"
#include "nsWidgetsCID.h"
#include "nsIDragService.h"
#include "nsIDragSession.h"
#include "nsITransferable.h"
#include "nsIFormatConverter.h"
#include "nsCOMPtr.h"
#include "nsIDOMUIEvent.h"
#include "nsIDOMDragListener.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMEventListener.h"
#include "nsISupportsPrimitives.h"
#include "nsISupportsArray.h"
// Drag & Drop, Clipboard Support
static NS_DEFINE_CID(kCDragServiceCID, NS_DRAGSERVICE_CID);
static NS_DEFINE_CID(kCTransferableCID, NS_TRANSFERABLE_CID);
static NS_DEFINE_IID(kCDataFlavorCID, NS_DATAFLAVOR_CID);
static NS_DEFINE_IID(kCXIFFormatConverterCID, NS_XIFFORMATCONVERTER_CID);
NS_IMPL_ADDREF(nsToolboxFrame::DragListenerDelegate);
NS_IMPL_RELEASE(nsToolboxFrame::DragListenerDelegate);
NS_IMETHODIMP
nsToolboxFrame::DragListenerDelegate::QueryInterface(REFNSIID aIID, void** aResult)
{
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(nsCOMTypeInfo<nsIDOMDragListener>::GetIID()) ||
aIID.Equals(nsCOMTypeInfo<nsIDOMEventListener>::GetIID()) ||
aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID())) {
*aResult = NS_STATIC_CAST(nsIDOMDragListener*, this);
NS_ADDREF_THIS();
return NS_OK;
}
else {
*aResult = nsnull;
return NS_NOINTERFACE;
}
}
//
// NS_NewToolboxFrame
//
// Creates a new toolbox frame and returns it in |aNewFrame|
//
nsresult
NS_NewToolboxFrame ( nsIFrame** aNewFrame )
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsToolboxFrame* it = new nsToolboxFrame;
if (nsnull == it)
return NS_ERROR_OUT_OF_MEMORY;
//it->SetFlags(aFlags);
*aNewFrame = it;
return NS_OK;
} // NS_NewToolboxFrame
//
// nsToolboxFrame cntr
//
// Init, if necessary
//
nsToolboxFrame :: nsToolboxFrame ( )
: mSumOfToolbarHeights(0), mNumToolbars(0),
mGrippyHilighted(kNoGrippyHilighted),
kCollapsedAtom(dont_AddRef( NS_NewAtom("collapsed"))),
kHiddenAtom(dont_AddRef( NS_NewAtom("hidden"))),
mDragListenerDelegate(nsnull)
{
// we start off vertical
mHorizontal = PR_FALSE;
}
//
// nsToolboxFrame dstr
//
// Cleanup, as necessary
//
nsToolboxFrame :: ~nsToolboxFrame ( )
{
if (mDragListenerDelegate) {
mDragListenerDelegate->NotifyFrameDestroyed();
NS_RELEASE(mDragListenerDelegate);
}
ClearGrippyList ( mGrippies );
}
//
// RefreshStyleContext
//
// Not exactly sure what this does ;)
//
void
nsToolboxFrame :: RefreshStyleContext(nsIPresContext* aPresContext,
nsIAtom * aNewContentPseudo,
nsCOMPtr<nsIStyleContext>* aCurrentStyle,
nsIContent * aContent,
nsIStyleContext* aParentStyle)
{
nsIStyleContext* newStyleContext;
aPresContext->ProbePseudoStyleContextFor(aContent,
aNewContentPseudo,
aParentStyle,
PR_FALSE,
&newStyleContext);
if (newStyleContext != aCurrentStyle->get())
*aCurrentStyle = dont_QueryInterface(newStyleContext);
} // RefreshStyleContext
NS_IMETHODIMP
nsToolboxFrame::GetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext** aStyleContext) const
{
NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer");
if (aIndex < 0) {
return NS_ERROR_INVALID_ARG;
}
*aStyleContext = nsnull;
switch (aIndex) {
case NS_TOOLBOX_GRIPPY_NORMAL_CONTEXT_INDEX:
*aStyleContext = mGrippyNormalStyle;
NS_IF_ADDREF(*aStyleContext);
break;
case NS_TOOLBOX_GRIPPY_ROLLOVER_CONTEXT_INDEX:
*aStyleContext = mGrippyRolloverStyle;
NS_IF_ADDREF(*aStyleContext);
break;
default:
return NS_ERROR_INVALID_ARG;
}
return NS_OK;
}
NS_IMETHODIMP
nsToolboxFrame::SetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext* aStyleContext)
{
if (aIndex < 0) {
return NS_ERROR_INVALID_ARG;
}
switch (aIndex) {
case NS_TOOLBOX_GRIPPY_NORMAL_CONTEXT_INDEX:
mGrippyNormalStyle = aStyleContext;
break;
case NS_TOOLBOX_GRIPPY_ROLLOVER_CONTEXT_INDEX:
mGrippyRolloverStyle = aStyleContext;
break;
}
return NS_OK;
}
NS_IMETHODIMP
nsToolboxFrame::Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
UpdateStyles(&aPresContext);
// Register the delegate as a drag listener.
mDragListenerDelegate = new DragListenerDelegate(this);
if (! mDragListenerDelegate)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mDragListenerDelegate);
nsCOMPtr<nsIContent> content;
rv = GetContent(getter_AddRefs(content));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMEventReceiver> reciever(do_QueryInterface(content));
reciever->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMDragListener*, mDragListenerDelegate), nsIDOMDragListener::GetIID());
return rv;
}
void
nsToolboxFrame::UpdateStyles(nsIPresContext* aPresContext)
{
nsCOMPtr<nsIAtom> grippyRolloverPseudo ( dont_AddRef(NS_NewAtom(":toolbox-rollover")) );
RefreshStyleContext(aPresContext, grippyRolloverPseudo, &mGrippyRolloverStyle, mContent, mStyleContext);
nsCOMPtr<nsIAtom> grippyNormalPseudo ( dont_AddRef(NS_NewAtom(":toolbox-normal")) );
RefreshStyleContext(aPresContext, grippyNormalPseudo, &mGrippyNormalStyle, mContent, mStyleContext);
}
//
// Paint
//
// Paint our background and border like normal frames, but before we draw the
// children, draw our grippies for each toolbar.
//
NS_IMETHODIMP
nsToolboxFrame :: Paint ( nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
{
// if we aren't visible then we are done.
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
if (!disp->mVisible)
return NS_OK;
// take care of bg painting, borders and children
nsresult retVal = nsBoxFrame::Paint ( aPresContext, aRenderingContext, aDirtyRect, aWhichLayer );
// now draw what makes us special
DrawGrippies ( aPresContext, aRenderingContext );
return retVal;
} // Paint
//
// DrawGrippies
//
// Redraws all the grippies in the toolbox by iterating over each toolbar in the DOM
// and figuring out how to draw the grippies based on size/visibility information
//
void
nsToolboxFrame :: DrawGrippies ( nsIPresContext& aPresContext, nsIRenderingContext & aRenderingContext ) const
{
for ( PRInt32 i = 0; i < mGrippies.Count(); ++i ) {
TabInfo* currGrippy = NS_STATIC_CAST(TabInfo*, mGrippies[i]);
PRBool hilight = (mGrippyHilighted == i) ? PR_TRUE : PR_FALSE;
DrawGrippy ( aPresContext, aRenderingContext, currGrippy->mBoundingRect, hilight );
} // for each child
} // DrawGrippies
//
// DrawGrippy
//
// Draw a single grippy in the given rectangle, either with or without rollover feedback.
//
void
nsToolboxFrame :: DrawGrippy ( nsIPresContext& aPresContext, nsIRenderingContext & aRenderingContext,
const nsRect & aBoundingRect, PRBool aDrawHilighted ) const
{
nsCOMPtr<nsIStyleContext> style ( aDrawHilighted ? mGrippyRolloverStyle : mGrippyNormalStyle ) ;
if ( !mGrippyRolloverStyle ) {
#ifdef NS_DEBUG
printf("nsToolboxFrame::DrawGrippy() -- style context null, css file not loaded correctly??\n");
#endif
return; // something must be seriously wrong
}
const nsStyleColor* grippyColor = (const nsStyleColor*)style->GetStyleData(eStyleStruct_Color);
const nsStyleSpacing* grippySpacing = (const nsStyleSpacing*)style->GetStyleData(eStyleStruct_Spacing);
// const nsStyleFont* grippyFont = (const nsStyleFont*)style->GetStyleData(eStyleStruct_Font);
nsToolboxFrame* nonConstSelf = NS_CONST_CAST(nsToolboxFrame*, this);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, nonConstSelf,
aBoundingRect, aBoundingRect, *grippyColor, *grippySpacing, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, nonConstSelf,
aBoundingRect, aBoundingRect, *grippySpacing, style, 0);
} // DrawGrippy
NS_IMETHODIMP
nsToolboxFrame::GetBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize)
{
CalculateGrippies(aPresContext);
return nsBoxFrame::GetBoxInfo(aPresContext, aReflowState, aSize);
}
NS_IMETHODIMP
nsToolboxFrame :: Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
nsresult errCode = nsBoxFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
errCode = ReflowGrippies(aPresContext, aDesiredSize, aReflowState, aStatus);
return errCode;
} // Reflow
// After we have been flowed this should be flowed to place the grippies at there
// physical locations.
nsresult
nsToolboxFrame::ReflowGrippies(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// get the rect we can place the grippies in. This is inside our borders and debug rect.
nsRect innerRect(0,0,0,0);
GetInnerRect(innerRect);
float p2t;
aPresContext.GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord grippyWidth = kGrippyWidthInPixels * onePixel; // remember to leave room for the grippy on the right
nscoord collapsedGrippyHeight = kCollapsedGrippyHeightInPixels * onePixel;
nsresult errCode = NS_OK;
const PRBool isHorz = IsHorizontal();
// iterate over all visible toolbar frames, moving the associated grippy
// next to the toolbar
mNumToolbars = 0;
nsIFrame* childFrame = mFrames.FirstChild();
while ( childFrame ) {
// get the childs rect and figure out the grippy size
nsCOMPtr<nsIContent> childContent;
childFrame->GetContent(getter_AddRefs(childContent));
nsRect grippyRect;
childFrame->GetRect(grippyRect);
if ( isHorz ) {
grippyRect.y = innerRect.y;
grippyRect.height = grippyWidth;
} else {
grippyRect.x = innerRect.x;
grippyRect.width = grippyWidth;
}
TabInfo *grippyInfo = FindGrippyForToolbar(mGrippies, childContent);
NS_ASSERTION(grippyInfo != 0, "Grippy Info Struct dissapeared!");
NS_ASSERTION(grippyInfo->mCollapsed == 0, "Collapsed toolbar has frame!");
// Set the location of the grippy to the left...
grippyInfo->SetBounds(grippyRect);
errCode = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(errCode == NS_OK, "failed to get next child");
mNumToolbars++;
}
// now move collapsed grippies to the bottom
for ( PRInt32 i = 0; i < mGrippies.Count(); ++i ) {
TabInfo* currGrippy = NS_STATIC_CAST(TabInfo*, mGrippies[i]);
if (currGrippy->mCollapsed) {
// remember we are just inverting the coord system here so in a
// horzontal toolbox our height is our width. Thats why we just use
// height here on both x and y coords.
if ( isHorz )
currGrippy->mBoundingRect.x = aDesiredSize.width - collapsedGrippyHeight;
else
currGrippy->mBoundingRect.y = aDesiredSize.height - collapsedGrippyHeight;
}
}
return errCode;
}
// called to figure out how big our grippies are and how many we have
// this will be called by boxes reflow method.
void
nsToolboxFrame::CalculateGrippies(nsIPresContext& aPresContext)
{
// compute amount (in twips) each toolbar will be offset from the right because of
// the grippy
float p2t;
aPresContext.GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord collapsedGrippyHeight = kCollapsedGrippyHeightInPixels * onePixel;
nscoord collapsedGrippyWidth = kCollapsedGrippyWidthInPixels * onePixel;
const PRBool isHorz = IsHorizontal();
{
nscoord grippyWidth = kGrippyWidthInPixels * onePixel; // remember to leave room for the grippy on the right
// Leave room at the side for the grippies of visible toolbars. Make a margin
// of the appropriate dimensions.
mInset = nsMargin(0,0,0,0);
if ( isHorz ) // Set margins so we have a place for uncollapsed grippies
mInset.top = grippyWidth;
else
mInset.left = grippyWidth;
}
// Save old tabs so we can make newly collapsed bars as wide as they WERE tall. We will
// release the grippies in mGrippies at the very end when we dispose of |oldGrippies|
nsVoidArray oldGrippies, emptyList;
oldGrippies = mGrippies;
mGrippies = emptyList;
// ----- Calculate a new set of grippy states...
// iterate over each content node to see if we can find one with the "collapsed"
// attribute set. If so, we have a collapsed toolbar.
nsAutoString value;
int numCollapsedGrippies = 0;
nscoord grippyPos = 0;
// Get the first child of the toolbox content node
unsigned int contentCounter = 0;
nsCOMPtr<nsIContent> childContent;
nsresult errCode = mContent->ChildAt(contentCounter, *getter_AddRefs(childContent));
NS_ASSERTION(errCode == NS_OK,"failed to get first child");
// iterate over each content node to see if we can find one with the "collapsed"
// attribute set. If so, we have a collapsed toolbar.
while ( childContent ) {
// is this bar collapsed?
value = "";
childContent->GetAttribute(kNameSpaceID_None, kCollapsedAtom, value);
if (value == "true") { // The bar is collapsed!
nscoord grippyWidth;
nscoord grippyHeight;
if ( isHorz ) {
grippyWidth = collapsedGrippyHeight;
grippyHeight = collapsedGrippyWidth;
} else {
grippyWidth = collapsedGrippyWidth;
grippyHeight = collapsedGrippyHeight;
}
TabInfo* oldGrippy = FindGrippyForToolbar ( oldGrippies, childContent );
if ( oldGrippy ) { // Inherit the old size...
if ( isHorz ) { // If laying out children horizontally...
if ( oldGrippy->mCollapsed) // Did it used to be collapsed?
grippyHeight = oldGrippy->mBoundingRect.height; // Copy old width
else
grippyHeight = oldGrippy->mBoundingRect.width; // Else copy old height
} else { // If laying out children vertically...
if ( oldGrippy->mCollapsed ) // Did it used to be collapsed?
grippyWidth = oldGrippy->mBoundingRect.width; // Copy old width
else
grippyWidth = oldGrippy->mBoundingRect.height; // Else copy old height
}
}
if ( isHorz ) {
mGrippies.AppendElement( new TabInfo(childContent, PR_TRUE,
nsRect(0, grippyPos, grippyWidth, grippyHeight)) );
grippyPos += grippyHeight;
} else {
mGrippies.AppendElement( new TabInfo(childContent, PR_TRUE,
nsRect(grippyPos, 0, grippyWidth, grippyHeight)) );
grippyPos += grippyWidth;
}
++numCollapsedGrippies;
} else { // The bar is NOT collapsed!!
mGrippies.AppendElement( new TabInfo(childContent, PR_FALSE) );
}
// next!
++contentCounter;
errCode = mContent->ChildAt(contentCounter, *getter_AddRefs(childContent));
NS_ASSERTION(errCode == NS_OK,"failed to get next child");
}
// if there are any collapsed bars, we need to leave room at the bottom of
// the box for the grippies. Adjust the margins before we reflow the box.
if ( numCollapsedGrippies ) {
if ( isHorz )
mInset.left = collapsedGrippyHeight;
else
mInset.bottom = collapsedGrippyHeight;
}
// make sure we now dispose of the old grippies since we have allocated
// new ones.
ClearGrippyList ( oldGrippies );
}
//
// FindGrippyForToolbar
//
// Utility routine to scan through the grippy list looking for one in the list
// associated with the given content object (which is the toolbar's content object).
//
// Will return nsnull if it cannot find the toolbar.
//
nsToolboxFrame::TabInfo*
nsToolboxFrame :: FindGrippyForToolbar ( nsVoidArray & inList, const nsIContent* inContent ) const
{
for ( PRInt32 i = 0; i < inList.Count(); ++i ) {
TabInfo* currGrippy = NS_STATIC_CAST(TabInfo*, inList[i]);
if ( currGrippy->mToolbar == inContent )
return currGrippy;
}
return nsnull;
} // FindGrippyForToolbar
//
// ClearGrippyList
//
// Since we are assuming the array "owns" the grippies once they go in there,
// we need to make sure that when the list goes away that they are cleaned up. The
// nsVoidArray does not know how to do this, so we need to do it ourselves.
//
void
nsToolboxFrame :: ClearGrippyList ( nsVoidArray & inList )
{
for ( PRInt32 i = 0; i < inList.Count(); ++i ) {
TabInfo* currGrippy = NS_STATIC_CAST(TabInfo*, inList[i]);
delete currGrippy;
}
} // ClearGrippyList
//
// GetInset
//
// Our Reflow() method computes a margin for the grippies and for collased grippies (if
// any). Return this pre-computed margin when asked by the box.
//
void
nsToolboxFrame::GetInset(nsMargin& margin)
{
margin = mInset;
}
//
// GetFrameForPoint
//
// Override to process events in our own frame
//
NS_IMETHODIMP
nsToolboxFrame :: GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIFrame** aFrame)
{
nsresult retVal = nsHTMLContainerFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
// returning NS_OK means that we tell the frame finding code that we have something
// and to stop looking elsewhere for a frame.
if ( aFrame && *aFrame == this )
retVal = NS_OK;
else if ( retVal != NS_OK ) {
*aFrame = this;
retVal = NS_OK;
}
return retVal;
} // GetFrameForPoint
//
// HandleEvent
//
//
NS_IMETHODIMP
nsToolboxFrame :: HandleEvent ( nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
if ( !aEvent )
return nsEventStatus_eIgnore;
switch ( aEvent->message ) {
case NS_MOUSE_LEFT_CLICK:
// BUG 3752 aEvent->point is invalid here.
break;
case NS_MOUSE_LEFT_BUTTON_UP:
OnMouseLeftClick ( &aPresContext, aEvent->point );
break;
case NS_MOUSE_MOVE:
OnMouseMove ( &aPresContext, aEvent->point );
break;
case NS_MOUSE_EXIT:
OnMouseExit ( &aPresContext);
break;
default:
break;
} // case of which event
return nsEventStatus_eIgnore;
} // HandleEvent
//
// ConvertToLocalPoint
//
// Given a point in the coordinate system of the parent view, convert to a point in the
// frame's local coordinate system.
//
void
nsToolboxFrame :: ConvertToLocalPoint ( nsIPresContext* aPresContext, nsPoint & ioPoint )
{
nsIView* view = nsnull; // note: |view| not AddRef'd
nsPoint offset;
if ( GetOffsetFromView(aPresContext, offset, &view) == NS_OK )
ioPoint -= offset;
} // ConvertToLocalPoint
//
// OnMouseMove
//
// Handle mouse move events for hilighting and unhilighting the grippies. |aMouseLoc|
// is not in local frame coordinates.
//
void
nsToolboxFrame :: OnMouseMove ( nsIPresContext* aPresContext, nsPoint & aMouseLoc )
{
nsPoint localMouseLoc = aMouseLoc;
ConvertToLocalPoint ( aPresContext, localMouseLoc );
for ( int i = 0; i < mGrippies.Count(); ++i ) {
TabInfo* currGrippy = NS_STATIC_CAST(TabInfo*, mGrippies[i]);
if ( currGrippy->mBoundingRect.Contains(localMouseLoc) ) {
if ( i != mGrippyHilighted ) {
// unhilight the old one
if ( mGrippyHilighted != kNoGrippyHilighted ) {
TabInfo* hilightedGrippy = NS_STATIC_CAST(TabInfo*, mGrippies[mGrippyHilighted]);
Invalidate ( aPresContext, hilightedGrippy->mBoundingRect, PR_FALSE );
}
// hilight the new one and remember it
mGrippyHilighted = i;
Invalidate ( aPresContext, currGrippy->mBoundingRect, PR_FALSE );
} // if in a new tab
}
} // for each toolbar
} // OnMouseMove
//
// OnMouseLeftClick
//
// Check if a click is in a grippy and expand/collapse appropriately. |aMouseLoc|
// is not in local frame coordinates.
//
void
nsToolboxFrame :: OnMouseLeftClick ( nsIPresContext* aPresContext, nsPoint & aMouseLoc )
{
nsPoint localMouseLoc = aMouseLoc;
ConvertToLocalPoint ( aPresContext, localMouseLoc );
for ( int i = 0; i < mGrippies.Count(); ++i ) {
TabInfo* currGrippy = NS_STATIC_CAST(TabInfo*, mGrippies[i]);
if ( currGrippy->mBoundingRect.Contains(localMouseLoc) ) {
if ( currGrippy->mCollapsed )
ExpandToolbar ( *currGrippy );
else
CollapseToolbar ( *currGrippy );
// don't keep repeating this process since toolbars have now be
// relaid out and a new toolbar may be under the current mouse
// location!
break;
}
}
} // OnMouseLeftClick
//
// OnMouseExit
//
// Update the grippies that may have been hilighted while the mouse was within the
// manager.
//
void
nsToolboxFrame :: OnMouseExit (nsIPresContext* aPresContext)
{
if ( mGrippyHilighted != kNoGrippyHilighted ) {
TabInfo* hilightedGrippy = NS_STATIC_CAST(TabInfo*, mGrippies[mGrippyHilighted]);
Invalidate ( aPresContext, hilightedGrippy->mBoundingRect, PR_FALSE );
mGrippyHilighted = kNoGrippyHilighted;
}
} // OnMouseExit
//
// CollapseToolbar
//
// Given the tab that was clicked on, collapse its corresponding toolbar. This
// assumes that the tab is expanded.
//
void
nsToolboxFrame :: CollapseToolbar ( TabInfo & inTab )
{
if ( inTab.mToolbar ) {
#ifdef NS_DEBUG
printf("CollapseToolbar:: collapsing\n");
#endif
nsresult errCode = inTab.mToolbar->SetAttribute ( kNameSpaceID_None, kCollapsedAtom, "true", PR_TRUE );
#ifdef NS_DEBUG
if ( errCode )
printf("Problem setting collapsed attribute while collapsing toolbar\n");
#endif
}
} // CollapseToolbar
//
// ExpandToolbar
//
// Given the collapsed (horizontal) tab that was clicked on, expand its
// corresponding toolbar. This assumes the tab is collapsed.
//
void
nsToolboxFrame :: ExpandToolbar ( TabInfo & inTab )
{
// nsresult errCode = mContent->UnsetAttribute ( kNameSpaceID_None, kCollapsedAtom, PR_TRUE );
nsresult errCode = inTab.mToolbar->SetAttribute ( kNameSpaceID_None, kCollapsedAtom, "false", PR_TRUE );
#ifdef NS_DEBUG
if ( errCode )
printf("Problem clearing collapsed attribute while expanding toolbar\n");
#endif
} // ExpandToolbar
////////////////////////////////////////////////////////////////////////
nsresult
nsToolboxFrame::HandleEvent(nsIDOMEvent* aEvent)
{
//printf("nsToolbarDragListener::HandleEvent\n");
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
nsresult
nsToolboxFrame::DragEnter(nsIDOMEvent* aDragEvent)
{
nsIDragService* dragService;
nsresult rv = nsServiceManager::GetService(kCDragServiceCID,
nsIDragService::GetIID(),
(nsISupports **)&dragService);
if ( NS_SUCCEEDED(rv) ) {
nsCOMPtr<nsIDragSession> dragSession(do_QueryInterface(dragService));
if ( dragSession ) {
PRBool flavorSupported = PR_FALSE;
dragSession->IsDataFlavorSupported(TOOLBAR_MIME, &flavorSupported);
if ( flavorSupported ) {
dragSession->SetCanDrop(PR_TRUE);
rv = NS_ERROR_BASE; // consume event
}
}
nsServiceManager::ReleaseService(kCDragServiceCID, dragService);
} else {
rv = NS_OK;
}
return rv;
}
////////////////////////////////////////////////////////////////////////
nsresult
nsToolboxFrame::DragOver(nsIDOMEvent* aDragEvent)
{
// now tell the drag session whether we can drop here
nsIDragService* dragService;
nsresult rv = nsServiceManager::GetService(kCDragServiceCID, nsIDragService::GetIID(),
(nsISupports **)&dragService);
if ( NS_SUCCEEDED(rv) ) {
nsCOMPtr<nsIDragSession> dragSession(do_QueryInterface(dragService));
if ( dragSession ) {
PRBool flavorSupported = PR_FALSE;
dragSession->IsDataFlavorSupported(TOOLBAR_MIME, &flavorSupported);
if ( flavorSupported ) {
// Right here you need to figure out where the mouse is
// and whether you can drop here
dragSession->SetCanDrop(PR_TRUE);
rv = NS_ERROR_BASE; // consume event
}
}
nsServiceManager::ReleaseService(kCDragServiceCID, dragService);
}
// NS_OK means event is NOT consumed
return rv;
}
////////////////////////////////////////////////////////////////////////
nsresult
nsToolboxFrame::DragExit(nsIDOMEvent* aDragEvent)
{
return NS_ERROR_BASE; // consumes event
}
////////////////////////////////////////////////////////////////////////
nsresult
nsToolboxFrame::DragDrop(nsIDOMEvent* aMouseEvent)
{
// Create drag service for getting state of drag
nsIDragService* dragService;
nsresult rv = nsServiceManager::GetService(kCDragServiceCID,
nsIDragService::GetIID(),
(nsISupports **)&dragService);
if (NS_OK == rv) {
nsCOMPtr<nsIDragSession> dragSession(do_QueryInterface(dragService));
if (dragSession) {
// Create transferable for getting the drag data
nsCOMPtr<nsITransferable> trans;
rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull,
nsITransferable::GetIID(),
(void**) getter_AddRefs(trans));
if ( NS_SUCCEEDED(rv) && trans ) {
// Add the toolbar Flavor to the transferable, because that is the only type of data we are
// looking for at the moment.
trans->AddDataFlavor(TOOLBAR_MIME);
// Fill the transferable with data for each drag item in succession
PRUint32 numItems = 0;
if (NS_SUCCEEDED(dragSession->GetNumDropItems(&numItems))) {
//printf("Num Drop Items %d\n", numItems);
PRUint32 i;
for (i=0;i<numItems;++i) {
if (NS_SUCCEEDED(dragSession->GetData(trans, i))) {
// Get the string data out of the transferable as a nsISupportsString.
nsCOMPtr<nsISupports> data;
PRUint32 len;
char* whichFlavor = nsnull;
trans->GetAnyTransferData(&whichFlavor, getter_AddRefs(data), &len);
nsCOMPtr<nsISupportsString> dataAsString ( do_QueryInterface(data) );
// If the string was not empty then make it so.
if ( dataAsString ) {
char* stuffToPaste;
dataAsString->ToString ( &stuffToPaste );
printf("Dropped: %s\n", stuffToPaste);
dragSession->SetCanDrop(PR_TRUE);
}
nsAllocator::Free ( whichFlavor );
}
} // foreach drag item
}
} // if valid transferable
} // if valid drag session
nsServiceManager::ReleaseService(kCDragServiceCID, dragService);
} // if valid drag service
return NS_ERROR_BASE; // consume the event;
}

View File

@@ -1,226 +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 "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 Communicator client 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.
*/
//
// Mike Pinkerton
// Netscape Communications
//
// nsToolboxFrame is a layout object that contains one or more toolbar frames
// (specified as children in the DOM). These toolbars are laid out one on top
// of the other, and can be of varying heights but are all of the same width
// (the full width of the toolbox). Each toolbar is associated with a "grippy"
// which can be used to either collapse a particular toolbar or as a handle to
// pick up and move a toolbar to a new position within the toolbox. When toolbars
// are collapsed, it's grippy is moved to the bottom of the box and laid on
// its side. Clicking again on the grippy will reinstate the toolbar to its previous
// position in the toolbox.
//
// As mentioned above, the toolbox expects its toolbars to be its children in
// the DOM. The exact structure of the children is documented on:
// http://www.mozilla.org/xpfe/DMWSpecNew.html
//
#ifndef nsToolBoxFrame_h___
#define nsToolBoxFrame_h___
#include "nsIDOMDragListener.h"
#include "nsHTMLContainerFrame.h"
#include "nsIStyleContext.h"
#include "nsIContent.h"
#include "nsXULAtoms.h"
#include "nsCOMPtr.h"
#include "nsBoxFrame.h"
#define NS_TOOLBOX_GRIPPY_NORMAL_CONTEXT_INDEX 0
#define NS_TOOLBOX_GRIPPY_ROLLOVER_CONTEXT_INDEX 1
class nsToolboxFrame : public nsBoxFrame
{
public:
friend nsresult NS_NewToolboxFrame(nsIFrame** aNewFrame);
// nsIHTMLReflow overrides
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD GetBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize);
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext** aStyleContext) const;
NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext* aStyleContext);
// Overridden to capture events
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIFrame** aFrame);
/*BEGIN implementations of dragevent handler interface*/
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);
virtual nsresult DragEnter(nsIDOMEvent* aDragEvent);
virtual nsresult DragOver(nsIDOMEvent* aDragEvent);
virtual nsresult DragExit(nsIDOMEvent* aDragEvent);
virtual nsresult DragDrop(nsIDOMEvent* aDragEvent);
virtual nsresult DragGesture(nsIDOMEvent* aDragEvent) { return NS_OK; }
/*END implementations of dragevent handler interface*/
protected:
enum { kGrippyWidthInPixels = 10, kCollapsedGrippyHeightInPixels = 10, kCollapsedGrippyWidthInPixels = 50 } ;
enum { kNoGrippyHilighted = -1 } ;
struct TabInfo {
TabInfo( nsIContent * inContent, PRBool inCollapsed,
const nsRect &inBounds = nsRect(0,0,0,0))
: mToolbar(inContent),
mBoundingRect(inBounds),
mCollapsed(inCollapsed)
{
}
void SetBounds(const nsRect &inBounds) { mBoundingRect = inBounds; }
nsIContent* mToolbar; // content object associated w/ toolbar frame. We don't own it.
nsRect mBoundingRect;
PRBool mCollapsed;
};
nsToolboxFrame();
virtual ~nsToolboxFrame();
virtual void UpdateStyles(nsIPresContext* aPresContext);
virtual void CalculateGrippies(nsIPresContext& aPresContext);
virtual nsresult ReflowGrippies(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
void RefreshStyleContext(nsIPresContext* aPresContext,
nsIAtom * aNewContentPseudo,
nsCOMPtr<nsIStyleContext>* aCurrentStyle,
nsIContent * aContent,
nsIStyleContext* aParentStyle) ;
void DrawGrippies ( nsIPresContext& aPresContext, nsIRenderingContext & aContext ) const ;
void DrawGrippy ( nsIPresContext& aPresContext, nsIRenderingContext & aContext,
const nsRect & aBoundingRect, PRBool aDrawHilighted ) const ;
void CollapseToolbar ( TabInfo & inTab ) ;
void ExpandToolbar ( TabInfo & inTab ) ;
void ConvertToLocalPoint ( nsIPresContext* aPresContext, nsPoint & ioPoint ) ;
void OnMouseMove ( nsIPresContext* aPresContext, nsPoint & aMouseLoc ) ;
void OnMouseExit ( nsIPresContext* aPresContext ) ;
void OnMouseLeftClick ( nsIPresContext* aPresContext, nsPoint & aMouseLoc ) ;
// utility routines
TabInfo* FindGrippyForToolbar ( nsVoidArray & inList, const nsIContent* inContent ) const ;
void ClearGrippyList ( nsVoidArray & inList ) ;
// style context for the normal state and rollover state of grippies
nsCOMPtr<nsIStyleContext> mGrippyNormalStyle;
nsCOMPtr<nsIStyleContext> mGrippyRolloverStyle;
nsMargin mInset;
virtual void GetInset(nsMargin& margin);
unsigned long mSumOfToolbarHeights;
nsVoidArray mGrippies; // list of all active grippies
unsigned short mNumToolbars;
short mGrippyHilighted; // used to indicate which grippy the mouse is inside
const nsCOMPtr<nsIAtom> kCollapsedAtom ;
const nsCOMPtr<nsIAtom> kHiddenAtom ;
class DragListenerDelegate : public nsIDOMDragListener
{
protected:
nsToolboxFrame* mFrame;
public:
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIDOMEventListener interface
virtual nsresult HandleEvent(nsIDOMEvent* aEvent)
{
return mFrame ? mFrame->HandleEvent(aEvent) : NS_OK;
}
virtual nsresult DragGesture(nsIDOMEvent* aEvent)
{
return mFrame ? mFrame->DragGesture(aEvent) : NS_OK;
}
// nsIDOMDragListener interface
virtual nsresult DragEnter(nsIDOMEvent* aMouseEvent)
{
return mFrame ? mFrame->DragEnter(aMouseEvent) : NS_OK;
}
virtual nsresult DragOver(nsIDOMEvent* aMouseEvent)
{
return mFrame ? mFrame->DragOver(aMouseEvent) : NS_OK;
}
virtual nsresult DragExit(nsIDOMEvent* aMouseEvent)
{
return mFrame ? mFrame->DragExit(aMouseEvent) : NS_OK;
}
virtual nsresult DragDrop(nsIDOMEvent* aMouseEvent)
{
return mFrame ? mFrame->DragDrop(aMouseEvent) : NS_OK;
}
// Implementation methods
DragListenerDelegate(nsToolboxFrame* aFrame) : mFrame(aFrame)
{
NS_INIT_REFCNT();
}
virtual ~DragListenerDelegate() {}
void NotifyFrameDestroyed() { mFrame = nsnull; }
};
DragListenerDelegate* mDragListenerDelegate;
// pass-by-value not allowed for a toolbox because it corresponds 1-to-1
// with an element in the UI.
nsToolboxFrame ( const nsToolboxFrame& aFrame ) ; // DO NOT IMPLEMENT
nsToolboxFrame& operator= ( const nsToolboxFrame& aFrame ) ; // DO NOT IMPLEMENT
}; // class nsToolboxFrame
#endif

View File

@@ -1,458 +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 "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 Communicator client 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.
*/
#include "nsIDOMElement.h"
#include "nsINameSpaceManager.h"
#include "nsHTMLAtoms.h"
#include "nsTreeCellFrame.h"
#include "nsTreeFrame.h"
#include "nsTreeRowFrame.h"
#include "nsIStyleContext.h"
#include "nsIPresContext.h"
#include "nsIPresShell.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIStyleSet.h"
#include "nsIViewManager.h"
#include "nsCSSRendering.h"
#include "nsXULAtoms.h"
#include "nsCOMPtr.h"
#include "nsINameSpaceManager.h"
//
// NS_NewTreeCellFrame
//
// Creates a new tree cell frame
//
nsresult
NS_NewTreeCellFrame (nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsTreeCellFrame* theFrame = new nsTreeCellFrame();
if (theFrame == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = theFrame;
return NS_OK;
} // NS_NewTreeCellFrame
// Constructor
nsTreeCellFrame::nsTreeCellFrame()
:nsTableCellFrame() { mAllowEvents = PR_FALSE; mIsHeader = PR_FALSE; mAnonymousContent = nsnull; }
// Destructor
nsTreeCellFrame::~nsTreeCellFrame()
{
}
NS_IMETHODIMP
nsTreeCellFrame::Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsTableCellFrame::Init(aPresContext, aContent, aParent, aContext,
aPrevInFlow);
// Figure out if we allow events.
nsAutoString attrValue;
nsresult result = aContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::allowevents, attrValue);
attrValue.ToLowerCase();
PRBool allowEvents = (result == NS_CONTENT_ATTR_NO_VALUE ||
(result == NS_CONTENT_ATTR_HAS_VALUE && attrValue=="true"));
SetAllowEvents(allowEvents);
// Determine if we're a column header or not.
// Get row group frame
nsIFrame* rowGroupFrame = nsnull;
aParent->GetParent(&rowGroupFrame);
if (rowGroupFrame != nsnull)
{
// Get the display type of the row group frame and see if it's a header or body
nsCOMPtr<nsIStyleContext> parentContext;
rowGroupFrame->GetStyleContext(getter_AddRefs(parentContext));
if (parentContext)
{
const nsStyleDisplay* display = (const nsStyleDisplay*)
parentContext->GetStyleData(eStyleStruct_Display);
if (display->mDisplay == NS_STYLE_DISPLAY_TABLE_HEADER_GROUP)
{
mIsHeader = PR_TRUE;
}
else mIsHeader = PR_FALSE;
// Get the table frame.
nsTableFrame* tableFrame = nsnull;
rv = nsTableFrame::GetTableFrame(rowGroupFrame, tableFrame);
if (NS_FAILED(rv) || (nsnull == tableFrame)) {
return rv;
}
mTreeFrame = (nsTreeFrame*)tableFrame;
}
}
return rv;
}
NS_IMETHODIMP nsTreeCellFrame::AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint)
{
nsresult rv = nsTableCellFrame::AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aHint);
if (mAnonymousContent && (aAttribute == nsHTMLAtoms::align || aAttribute == nsXULAtoms::crop
|| aAttribute == nsHTMLAtoms::value))
{
nsAutoString value;
// XXX should check if attribute has been removed
mContent->GetAttribute(kNameSpaceID_None, aAttribute, value);
mAnonymousContent->SetAttribute(kNameSpaceID_None, aAttribute, value, PR_TRUE);
}
return rv;
}
nsTableFrame* nsTreeCellFrame::GetTreeFrame()
{
return mTreeFrame;
}
NS_METHOD nsTreeCellFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
nsresult rv = nsTableCellFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
return rv;
}
NS_IMETHODIMP
nsTreeCellFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIFrame** aFrame)
{
if (mAllowEvents)
{
return nsTableCellFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
}
else
{
nsresult result = nsTableCellFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
nsCOMPtr<nsIContent> content;
if (*aFrame) {
(*aFrame)->GetContent(getter_AddRefs(content));
if (content) {
// This allows selective overriding for subcontent.
nsAutoString value;
content->GetAttribute(kNameSpaceID_None, nsXULAtoms::allowevents, value);
if (value == "true")
return result;
}
}
*aFrame = this; // Capture all events so that we can perform selection and expand/collapse.
return NS_OK;
}
}
NS_IMETHODIMP
nsTreeCellFrame::HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
aEventStatus = nsEventStatus_eConsumeDoDefault;
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
if (((nsMouseEvent*)aEvent)->clickCount == 2)
HandleDoubleClickEvent(aPresContext, aEvent, aEventStatus);
else
HandleMouseDownEvent(aPresContext, aEvent, aEventStatus);
}
else if (aEvent->message == NS_MOUSE_ENTER)
HandleMouseEnterEvent(aPresContext, aEvent, aEventStatus);
else if (aEvent->message == NS_MOUSE_EXIT)
HandleMouseExitEvent(aPresContext, aEvent, aEventStatus);
else if (aEvent->message == NS_MOUSE_LEFT_DOUBLECLICK)
HandleDoubleClickEvent(aPresContext, aEvent, aEventStatus);
return NS_OK;
}
nsresult
nsTreeCellFrame::HandleMouseDownEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
if (mIsHeader) {
nsTableColFrame* leftFlex = nsnull;
nsPoint point = ((nsMouseEvent*)aEvent)->point;
if (CanResize(point, &leftFlex))
{
// Begin capturing events.
nsIFrame* frame;
GetParent(&frame);
nsTreeRowFrame* treeRow = (nsTreeRowFrame*)frame;
treeRow->HeaderDrag(&aPresContext, PR_TRUE);
// Inform the tree row of the flexing column
treeRow->SetFlexingColumn(leftFlex);
nsRect rect;
GetRect(rect);
treeRow->SetHeaderPosition(point.x);
}
}
else
{
// Perform a selection
if (((nsMouseEvent *)aEvent)->isShift)
mTreeFrame->RangedSelection(aPresContext, this); // Applying a ranged selection.
#ifdef XP_MAC
else if (((nsMouseEvent *)aEvent)->isMeta)
mTreeFrame->ToggleSelection(aPresContext, this);
#else
else if (((nsMouseEvent *)aEvent)->isControl)
mTreeFrame->ToggleSelection(aPresContext, this); // Applying a toggle selection.
#endif
else mTreeFrame->SetSelection(aPresContext, this); // Doing a single selection only.
}
return NS_OK;
}
nsresult
nsTreeCellFrame::HandleMouseEnterEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
if (mIsHeader)
{
// Nothing to do?
}
else
{
// Set our hover to true
Hover(aPresContext, PR_TRUE);
}
return NS_OK;
}
nsresult
nsTreeCellFrame::HandleMouseExitEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
if (mIsHeader)
{
}
else
{
// Set our hover to false
Hover(aPresContext, PR_FALSE);
}
return NS_OK;
}
PRBool
nsTreeCellFrame::CanResize(nsPoint& aPoint, nsTableColFrame** aResult) {
nsRect rect;
GetRect(rect);
PRInt32 diff = (rect.x + rect.width) - aPoint.x;
nsCOMPtr<nsIContent> parent;
mContent->GetParent(*getter_AddRefs(parent));
PRInt32 index;
parent->IndexOf(mContent, index);
PRInt32 count;
parent->ChildCount(count);
PRBool onLeftEdge = (index > 0 && (rect.width - diff) <= 90);
PRBool onRightEdge = (index < (count-1) && diff <= 90);
if (onLeftEdge || onRightEdge) {
// We're over the right place.
// Ensure that we have flexible columns to the left and to the right.
nsTableFrame* tableFrame = nsnull;
nsTableFrame::GetTableFrame(this, tableFrame);
nsTreeFrame* treeFrame = (nsTreeFrame*)tableFrame;
if (onLeftEdge)
index--;
return (treeFrame->ContainsFlexibleColumn(0, index, aResult) &&
treeFrame->ContainsFlexibleColumn(index+1, count-1, nsnull));
}
return PR_FALSE;
}
NS_IMETHODIMP
nsTreeCellFrame::GetCursor(nsIPresContext& aPresContext,
nsPoint& aPoint,
PRInt32& aCursor)
{
if (mIsHeader) {
// Figure out if the point is over the resize stuff.
nsTableColFrame* dummy = nsnull;
if (CanResize(aPoint, &dummy)) {
aCursor = NS_STYLE_CURSOR_W_RESIZE;
}
else {
aCursor = NS_STYLE_CURSOR_DEFAULT;
}
}
else aCursor = NS_STYLE_CURSOR_DEFAULT;
return NS_OK;
}
void
nsTreeCellFrame::ToggleOpenClose()
{
if (!mIsHeader)
{
// Perform an expand/collapse
// Iterate up the chain to the row and then to the item.
nsCOMPtr<nsIContent> treeItemContent;
nsCOMPtr<nsIContent> treeRowContent;
mContent->GetParent(*getter_AddRefs(treeRowContent));
treeRowContent->GetParent(*getter_AddRefs(treeItemContent));
nsCOMPtr<nsIDOMElement> treeItem( do_QueryInterface(treeItemContent) );
NS_ASSERTION(treeItem, "not a DOM element");
if (! treeItem)
return;
// Take the tree item content and toggle the value of its open attribute.
nsAutoString attrValue;
treeItem->GetAttribute("open", attrValue);
attrValue.ToLowerCase();
PRBool isExpanded = (attrValue=="true");
if (isExpanded)
{
// We're collapsing and need to remove frames from the flow.
treeItem->RemoveAttribute("open");
}
else
{
// We're expanding and need to add frames to the flow.
treeItem->SetAttribute("open", "true");
}
}
}
void
nsTreeCellFrame::Open()
{
if (!mIsHeader)
{
// Perform an expand/collapse
// Iterate up the chain to the row and then to the item.
nsCOMPtr<nsIContent> treeItemContent;
nsCOMPtr<nsIContent> treeRowContent;
mContent->GetParent(*getter_AddRefs(treeRowContent));
treeRowContent->GetParent(*getter_AddRefs(treeItemContent));
nsCOMPtr<nsIDOMElement> treeItem( do_QueryInterface(treeItemContent) );
NS_ASSERTION(treeItem, "not a DOM element");
if (! treeItem)
return;
// Take the tree item content and toggle the value of its open attribute.
nsAutoString attrValue;
treeItem->GetAttribute("open", attrValue);
attrValue.ToLowerCase();
PRBool isExpanded = (attrValue=="true");
if (!isExpanded) {
// We're expanding and need to add frames to the flow.
treeItem->SetAttribute("open", "true");
}
}
}
void
nsTreeCellFrame::Close()
{
if (!mIsHeader)
{
// Perform an expand/collapse
// Iterate up the chain to the row and then to the item.
nsCOMPtr<nsIContent> treeItemContent;
nsCOMPtr<nsIContent> treeRowContent;
mContent->GetParent(*getter_AddRefs(treeRowContent));
treeRowContent->GetParent(*getter_AddRefs(treeItemContent));
nsCOMPtr<nsIDOMElement> treeItem( do_QueryInterface(treeItemContent) );
NS_ASSERTION(treeItem, "not a DOM element");
if (! treeItem)
return;
// Take the tree item content and toggle the value of its open attribute.
nsAutoString attrValue;
treeItem->GetAttribute("open", attrValue);
attrValue.ToLowerCase();
PRBool isExpanded = (attrValue=="true");
if (isExpanded) {
// We're expanding and need to add frames to the flow.
treeItem->RemoveAttribute("open");
}
}
}
nsresult
nsTreeCellFrame::HandleDoubleClickEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
ToggleOpenClose();
return NS_OK;
}
void nsTreeCellFrame::Hover(nsIPresContext& aPresContext, PRBool isHover, PRBool notifyForReflow)
{
nsCOMPtr<nsIAtom> kHoverAtom(dont_AddRef(NS_NewAtom("hover")));
nsCOMPtr<nsIContent> rowContent;
nsCOMPtr<nsIContent> itemContent;
mContent->GetParent(*getter_AddRefs(rowContent));
rowContent->GetParent(*getter_AddRefs(itemContent));
if (isHover)
{
// We're selecting the node.
mContent->SetAttribute(kNameSpaceID_None, kHoverAtom, "true", notifyForReflow);
rowContent->SetAttribute(kNameSpaceID_None, kHoverAtom, "true", notifyForReflow);
itemContent->SetAttribute(kNameSpaceID_None, kHoverAtom, "true", notifyForReflow);
}
else
{
// We're deselecting the node.
mContent->UnsetAttribute(kNameSpaceID_None, kHoverAtom, notifyForReflow);
rowContent->UnsetAttribute(kNameSpaceID_None, kHoverAtom, notifyForReflow);
itemContent->UnsetAttribute(kNameSpaceID_None, kHoverAtom, notifyForReflow);
}
}
NS_IMETHODIMP
nsTreeCellFrame::Destroy(nsIPresContext& aPresContext)
{
return nsTableCellFrame::Destroy(aPresContext);
}

View File

@@ -1,100 +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 "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 Communicator client 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.
*/
#include "nsTableCellFrame.h"
class nsTableColFrame;
class nsTreeFrame;
class nsTreeCellFrame : public nsTableCellFrame
{
public:
friend nsresult NS_NewTreeCellFrame(nsIFrame** aNewFrame);
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint, // Overridden to capture events
nsIFrame** aFrame);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow); // Overridden to set whether we're a column header
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD Destroy(nsIPresContext& aPresContext);
NS_IMETHOD GetCursor(nsIPresContext& aPresContext,
nsPoint& aPoint,
PRInt32& aCursor);
void Hover(nsIPresContext& presContext, PRBool isHover, PRBool notifyForReflow = PR_TRUE);
nsTableFrame* GetTreeFrame();
void SetAllowEvents(PRBool allowEvents) { mAllowEvents = allowEvents; };
void SetAnonymousContent(nsIContent* aAnonymousContent) { mAnonymousContent = aAnonymousContent; };
void ToggleOpenClose();
void Open();
void Close();
protected:
nsTreeCellFrame();
virtual ~nsTreeCellFrame();
nsresult HandleMouseDownEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
nsresult HandleMouseEnterEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
nsresult HandleMouseExitEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
nsresult HandleDoubleClickEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
PRBool CanResize(nsPoint& aPoint, nsTableColFrame** aResult);
NS_IMETHOD DidSetStyleContext(nsIPresContext* aPresContext) { return NS_OK; };
protected:
// Data members
PRBool mIsHeader; // Whether or not we're a column header
nsTreeFrame* mTreeFrame; // Our parent tree frame.
PRBool mAllowEvents; // Whether we let events go through.
nsIContent* mAnonymousContent; // Our anonymous titledbutton [WEAK ref]
}; // class nsTableCellFrame

View File

@@ -1,430 +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 "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 Communicator client 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.
*/
#include "nsCOMPtr.h"
#include "nsTreeFrame.h"
#include "nsIStyleContext.h"
#include "nsIContent.h"
#include "nsCSSRendering.h"
#include "nsTreeCellFrame.h"
#include "nsTableColFrame.h"
#include "nsCellMap.h"
#include "nsIDOMXULTreeElement.h"
#include "nsINameSpaceManager.h"
#include "nsTreeRowGroupFrame.h"
#include "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMXULTreeElement.h"
#include "nsTreeTwistyListener.h"
#include "nsIPresContext.h"
#include "nsIPresShell.h"
#include "nsIReflowCommand.h"
#include "nsHTMLParts.h"
//
// NS_NewTreeFrame
//
// Creates a new tree frame
//
nsresult
NS_NewTreeFrame (nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsTreeFrame* it = new nsTreeFrame;
if (!it)
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
} // NS_NewTreeFrame
// Constructor
nsTreeFrame::nsTreeFrame()
:nsTableFrame(),mSlatedForReflow(PR_FALSE), mTwistyListener(nsnull), mGeneration(0), mUseGeneration(PR_TRUE) { }
// Destructor
nsTreeFrame::~nsTreeFrame()
{
}
void nsTreeFrame::SetSelection(nsIPresContext& aPresContext, nsTreeCellFrame* aFrame)
{
nsCOMPtr<nsIContent> cellContent;
aFrame->GetContent(getter_AddRefs(cellContent));
if (!cellContent) return;
nsCOMPtr<nsIContent> rowContent;
cellContent->GetParent(*getter_AddRefs(rowContent));
nsCOMPtr<nsIContent> itemContent;
rowContent->GetParent(*getter_AddRefs(itemContent));
nsCOMPtr<nsIDOMXULTreeElement> treeElement = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMXULElement> cellElement = do_QueryInterface(cellContent);
nsCOMPtr<nsIDOMXULElement> itemElement = do_QueryInterface(itemContent);
nsCOMPtr<nsIAtom> kSuppressSelectChange = dont_AddRef(NS_NewAtom("suppressonselect"));
mContent->SetAttribute(kNameSpaceID_None, kSuppressSelectChange, "true", PR_FALSE);
treeElement->SelectItem(itemElement);
mContent->UnsetAttribute(kNameSpaceID_None, kSuppressSelectChange, PR_FALSE);
treeElement->SelectCell(cellElement);
}
void nsTreeFrame::ToggleSelection(nsIPresContext& aPresContext, nsTreeCellFrame* aFrame)
{
nsCOMPtr<nsIContent> cellContent;
aFrame->GetContent(getter_AddRefs(cellContent));
nsCOMPtr<nsIContent> rowContent;
cellContent->GetParent(*getter_AddRefs(rowContent));
nsCOMPtr<nsIContent> itemContent;
rowContent->GetParent(*getter_AddRefs(itemContent));
nsCOMPtr<nsIDOMXULTreeElement> treeElement = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMXULElement> cellElement = do_QueryInterface(cellContent);
nsCOMPtr<nsIDOMXULElement> itemElement = do_QueryInterface(itemContent);
nsCOMPtr<nsIAtom> kSuppressSelectChange = dont_AddRef(NS_NewAtom("suppressonselect"));
mContent->SetAttribute(kNameSpaceID_None, kSuppressSelectChange, "true", PR_FALSE);
treeElement->ToggleItemSelection(itemElement);
mContent->UnsetAttribute(kNameSpaceID_None, kSuppressSelectChange, PR_FALSE);
treeElement->ToggleCellSelection(cellElement);
}
void nsTreeFrame::RangedSelection(nsIPresContext& aPresContext, nsTreeCellFrame* pEndFrame)
{
// XXX Re-implement!
}
void
nsTreeFrame::GetTreeBody(nsTreeRowGroupFrame** aResult)
{
nsIFrame* curr = mFrames.FirstChild();
while (curr) {
nsCOMPtr<nsIContent> content;
curr->GetContent(getter_AddRefs(content));
if (content) {
nsCOMPtr<nsIAtom> tag;
content->GetTag(*getter_AddRefs(tag));
if (tag && tag.get() == nsXULAtoms::treechildren) {
// This is our actual treechildren frame.
nsTreeRowGroupFrame* rowGroup = (nsTreeRowGroupFrame*)curr; // XXX I am evil.
*aResult = rowGroup;
return;
}
}
curr->GetNextSibling(&curr);
}
}
NS_IMETHODIMP
nsTreeFrame::HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
aEventStatus = nsEventStatus_eConsumeDoDefault;
if (aEvent->message == NS_KEY_DOWN) {
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
PRUint32 keyCode = keyEvent->keyCode;
if (keyCode == NS_VK_UP ||
keyCode == NS_VK_DOWN ||
keyCode == NS_VK_LEFT ||
keyCode == NS_VK_RIGHT ||
keyCode == NS_VK_ENTER) {
// Get our treechildren child frame.
nsTreeRowGroupFrame* treeRowGroup = nsnull;
GetTreeBody(&treeRowGroup);
if (!treeRowGroup)
return NS_OK; // No tree body. Just bail.
nsCOMPtr<nsIDOMXULTreeElement> treeElement = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMNodeList> itemNodeList;
nsCOMPtr<nsIDOMNodeList> cellNodeList;
treeElement->GetSelectedItems(getter_AddRefs(itemNodeList));
treeElement->GetSelectedCells(getter_AddRefs(cellNodeList));
PRUint32 itemLength;
PRUint32 cellLength;
itemNodeList->GetLength(&itemLength);
cellNodeList->GetLength(&cellLength);
PRInt32 rowIndex = -1;
PRInt32 cellIndex = 0;
if (cellLength != 0 && itemLength == 0) {
nsCOMPtr<nsIDOMNode> node;
cellNodeList->Item(0, getter_AddRefs(node));
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
treeRowGroup->IndexOfCell(aPresContext, content, rowIndex, cellIndex);
}
else if (cellLength == 0 && itemLength != 0) {
nsCOMPtr<nsIDOMNode> node;
itemNodeList->Item(0, getter_AddRefs(node));
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
treeRowGroup->IndexOfRow(aPresContext, content, rowIndex);
}
else if (cellLength != 0 && itemLength != 0) {
nsCOMPtr<nsIDOMNode> node;
cellNodeList->Item(0, getter_AddRefs(node));
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
treeRowGroup->IndexOfCell(aPresContext, content, rowIndex, cellIndex);
}
// We now have a valid row and cell index for the current selection. Based on the
// direction, let's adjust the row and column index.
if (rowIndex == -1)
rowIndex = 0;
else if (keyCode == NS_VK_DOWN)
rowIndex++;
else if (keyCode == NS_VK_UP)
rowIndex--;
// Ensure that the required index is visible.
treeRowGroup->EnsureRowIsVisible(rowIndex);
// now that it's (probably) been brought into view, is it valid?
// if (!treeRowGroup->IsValidRow(rowIndex))
// return NS_OK;
// Now that the row is scrolled into view, we have a frame created. We can retrieve the cell.
nsTreeCellFrame* cellFrame=nsnull;
treeRowGroup->GetCellFrameAtIndex(rowIndex, cellIndex, &cellFrame);
if (!cellFrame)
return NS_OK; // No cell. Whatever. Bail.
// We got it! Perform the selection on an up/down.
if (keyCode == NS_VK_UP || keyCode == NS_VK_DOWN)
SetSelection(aPresContext, cellFrame);
else if (keyCode == NS_VK_ENTER || keyCode == NS_VK_RETURN)
cellFrame->ToggleOpenClose();
else if (keyCode == NS_VK_LEFT)
cellFrame->Close();
else if (keyCode == NS_VK_RIGHT)
cellFrame->Open();
}
}
return NS_OK;
}
void nsTreeFrame::MoveUp(nsIPresContext& aPresContext, nsTreeCellFrame* pFrame)
{
PRInt32 rowIndex;
pFrame->GetRowIndex(rowIndex);
PRInt32 colIndex;
pFrame->GetColIndex(colIndex);
if (rowIndex > 0)
{
MoveToRowCol(aPresContext, rowIndex-1, colIndex);
}
}
void nsTreeFrame::MoveDown(nsIPresContext& aPresContext, nsTreeCellFrame* pFrame)
{
PRInt32 rowIndex;
pFrame->GetRowIndex(rowIndex);
PRInt32 colIndex;
pFrame->GetColIndex(colIndex);
PRInt32 totalRows = mCellMap->GetRowCount();
if (rowIndex < totalRows-1)
{
MoveToRowCol(aPresContext, rowIndex+1, colIndex);
}
}
void nsTreeFrame::MoveLeft(nsIPresContext& aPresContext, nsTreeCellFrame* pFrame)
{
PRInt32 rowIndex;
pFrame->GetRowIndex(rowIndex);
PRInt32 colIndex;
pFrame->GetColIndex(colIndex);
if (colIndex > 0)
{
MoveToRowCol(aPresContext, rowIndex, colIndex-1);
}
}
void nsTreeFrame::MoveRight(nsIPresContext& aPresContext, nsTreeCellFrame* aFrame)
{
PRInt32 rowIndex;
aFrame->GetRowIndex(rowIndex);
PRInt32 colIndex;
aFrame->GetColIndex(colIndex);
PRInt32 totalCols = mCellMap->GetColCount();
if (colIndex < totalCols-1)
{
MoveToRowCol(aPresContext, rowIndex, colIndex+1);
}
}
void nsTreeFrame::MoveToRowCol(nsIPresContext& aPresContext, PRInt32 aRow, PRInt32 aCol)
{
nsTableCellFrame* cellFrame = mCellMap->GetCellInfoAt(aRow, aCol);
// We now have the cell that should be selected.
nsTreeCellFrame* treeCell = NS_STATIC_CAST(nsTreeCellFrame*, cellFrame);
SetSelection(aPresContext, treeCell);
}
NS_IMETHODIMP
nsTreeFrame::Destroy(nsIPresContext& aPresContext)
{
nsCOMPtr<nsIDOMEventReceiver> target = do_QueryInterface(mContent);
target->RemoveEventListener("mousedown", mTwistyListener, PR_TRUE);
mTwistyListener = nsnull;
return nsTableFrame::Destroy(aPresContext);
}
NS_IMETHODIMP
nsTreeFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
nsresult rv = NS_OK;
mSlatedForReflow = PR_FALSE;
if (!mSuppressReflow) {
nsRect rect;
GetRect(rect);
if (rect.width != aReflowState.mComputedWidth && aReflowState.reason == eReflowReason_Resize) {
// We're doing a resize and changing the width of the table. All rows must
// reflow. Reset our generation.
SetUseGeneration(PR_FALSE);
}
if (UseGeneration()) {
++mGeneration;
}
rv = nsTableFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
}
else
{
aStatus = NS_FRAME_COMPLETE;
}
if (aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE)
aDesiredSize.width = aReflowState.mComputedWidth +
aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
if (aReflowState.mComputedHeight != NS_UNCONSTRAINEDSIZE)
aDesiredSize.height = aReflowState.mComputedHeight +
aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
aDesiredSize.ascent = aDesiredSize.height;
if (!UseGeneration())
SetUseGeneration(PR_TRUE);
return rv;
}
NS_IMETHODIMP
nsTreeFrame::DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus)
{
nsresult rv = nsTableFrame::DidReflow(aPresContext, aStatus);
return rv;
}
NS_IMETHODIMP
nsTreeFrame::MarkForDirtyReflow(nsIPresContext& aPresContext)
{
mSuppressReflow = PR_FALSE;
InvalidateCellMap();
InvalidateColumnCache();
InvalidateFirstPassCache();
nsCOMPtr<nsIPresShell> shell;
aPresContext.GetShell(getter_AddRefs(shell));
nsFrameState frameState;
nsIFrame* tableParentFrame;
nsIReflowCommand* reflowCmd;
// Mark the table frame as dirty
GetFrameState(&frameState);
frameState |= NS_FRAME_IS_DIRTY;
SetFrameState(frameState);
// Target the reflow comamnd at its parent frame
GetParent(&tableParentFrame);
nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, tableParentFrame,
nsIReflowCommand::ReflowDirty);
if (NS_SUCCEEDED(rv)) {
// Add the reflow command
rv = shell->AppendReflowCommand(reflowCmd);
NS_RELEASE(reflowCmd);
}
return rv;
}
NS_IMETHODIMP
nsTreeFrame::Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsTableFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
// Create the menu bar listener.
mTwistyListener = new nsTreeTwistyListener();
nsCOMPtr<nsIDOMEventReceiver> target = do_QueryInterface(mContent);
target->AddEventListener("mousedown", mTwistyListener, PR_TRUE);
return rv;
}
PRBool
nsTreeFrame::ContainsFlexibleColumn(PRInt32 aStartIndex, PRInt32 aEndIndex,
nsTableColFrame** aResult)
{
for (PRInt32 i = aEndIndex; i >= aStartIndex; i--) {
nsTableColFrame* result = GetColFrame(i);
nsCOMPtr<nsIContent> colContent;
result->GetContent(getter_AddRefs(colContent));
nsCOMPtr<nsIAtom> fixedAtom = dont_AddRef(NS_NewAtom("fixed"));
if (colContent) {
nsAutoString fixedValue;
colContent->GetAttribute(kNameSpaceID_None, fixedAtom, fixedValue);
if (fixedValue != "true") {
// We are a proportional column.
if (aResult)
*aResult = result;
return PR_TRUE;
}
}
}
return PR_FALSE;
}

View File

@@ -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 "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 Communicator client 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.
*/
#include "nsTableFrame.h"
#include "nsVoidArray.h"
class nsTreeCellFrame;
class nsTreeRowGroupFrame;
class nsTreeTwistyListener;
class nsTreeFrame : public nsTableFrame
{
public:
friend nsresult NS_NewTreeFrame(nsIFrame** aNewFrame);
void SetSelection(nsIPresContext& presContext, nsTreeCellFrame* pFrame);
void ToggleSelection(nsIPresContext& presContext, nsTreeCellFrame* pFrame);
void RangedSelection(nsIPresContext& aPresContext, nsTreeCellFrame* pEndFrame);
void MoveUp(nsIPresContext& aPresContext, nsTreeCellFrame* pFrame);
void MoveDown(nsIPresContext& aPresContext, nsTreeCellFrame* pFrame);
void MoveLeft(nsIPresContext& aPresContext, nsTreeCellFrame* pFrame);
void MoveRight(nsIPresContext& aPresContext, nsTreeCellFrame* pFrame);
void MoveToRowCol(nsIPresContext& aPresContext, PRInt32 row, PRInt32 col);
PRBool IsSlatedForReflow() { return mSlatedForReflow; };
void SlateForReflow() { mSlatedForReflow = PR_TRUE; };
void GetTreeBody(nsTreeRowGroupFrame** aResult);
// Overridden methods
NS_IMETHOD Destroy(nsIPresContext& aPresContext);
PRBool RowGroupsShouldBeConstrained() { return PR_TRUE; }
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aMetrics,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
nsDidReflowStatus aStatus);
PRInt32 GetCurrentGeneration() { return mGeneration; };
void SetCurrentGeneration(PRInt32 aGeneration) { mGeneration = aGeneration; };
PRBool UseGeneration() { return mUseGeneration; };
void SetUseGeneration(PRBool aUse) { mUseGeneration = aUse; };
PRBool ContainsFlexibleColumn(PRInt32 aStartIndex, PRInt32 aEndIndex, nsTableColFrame** aResult);
NS_IMETHOD MarkForDirtyReflow(nsIPresContext& aPresContext);
void SuppressReflow() { mSuppressReflow = PR_TRUE; };
void UnsuppressReflow() { mSuppressReflow = PR_FALSE; };
protected:
nsTreeFrame();
virtual ~nsTreeFrame();
protected: // Data Members
PRBool mSlatedForReflow; // If set, don't waste time scheduling excess reflows.
nsTreeTwistyListener* mTwistyListener;
PRInt32 mGeneration;
PRBool mUseGeneration;
PRBool mSuppressReflow;
}; // class nsTreeFrame

View File

@@ -1,128 +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 "nsFrame.h"
#include "nsLineLayout.h"
#include "nsHTMLIIDs.h"
#include "nsIPresContext.h"
#include "nsIPresShell.h"
#include "nsXULAtoms.h"
#include "nsUnitConversion.h"
#include "nsIStyleContext.h"
#include "nsIContent.h"
#include "nsStyleConsts.h"
#include "nsINameSpaceManager.h"
#include "nsTreeIndentationFrame.h"
#include "nsCOMPtr.h"
nsTreeIndentationFrame::nsTreeIndentationFrame()
{
mWidth = 0;
mHaveComputedWidth = PR_FALSE;
}
nsresult
NS_NewTreeIndentationFrame(nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsTreeIndentationFrame* it = new nsTreeIndentationFrame();
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
}
*aNewFrame = it;
return NS_OK;
}
nsTreeIndentationFrame::~nsTreeIndentationFrame()
{
}
NS_IMETHODIMP
nsTreeIndentationFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aMetrics,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
aStatus = NS_FRAME_COMPLETE;
// By default, we have no area
aMetrics.width = 0;
aMetrics.height = 0;
aMetrics.ascent = 0;
aMetrics.descent = 0;
// Compute our width based on the depth of our node within the content model
if (!mHaveComputedWidth)
{
mWidth = 0;
nscoord level = 0;
// First climb out to the tree item level.
nsIFrame* aFrame = this;
nsCOMPtr<nsIContent> pContent;
aFrame->GetContent(getter_AddRefs(pContent));
nsCOMPtr<nsIAtom> pTag;
pContent->GetTag(*getter_AddRefs(pTag));
if (pTag)
{
while (aFrame && pTag && pTag.get() != nsXULAtoms::treeitem)
{
aFrame->GetParent(&aFrame);
// nsCOMPtr correctly handles releasing the old |pContent| and |pTag|
aFrame->GetContent(getter_AddRefs(pContent));
pContent->GetTag(*getter_AddRefs(pTag));
}
// We now have a tree row content node. Start counting our level of nesting.
nsCOMPtr<nsIContent> pParentContent;
while (pTag.get() != nsXULAtoms::tree && pTag.get() != nsXULAtoms::treehead)
{
pContent->GetParent(*getter_AddRefs(pParentContent));
pParentContent->GetTag(*getter_AddRefs(pTag));
pContent = pParentContent;
++level;
}
level = (level/2) - 1;
if (level < 0) level = 0;
mWidth = level*16; // Hardcode an indentation of 16 pixels for now. TODO: Make this a parameter or something
}
}
float p2t;
aPresContext.GetScaledPixelsToTwips(&p2t);
if (0 != mWidth) {
aMetrics.width = NSIntPixelsToTwips(mWidth, p2t);
}
if (nsnull != aMetrics.maxElementSize) {
aMetrics.maxElementSize->width = aMetrics.width;
aMetrics.maxElementSize->height = aMetrics.height;
}
return NS_OK;
}

View File

@@ -1,37 +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 "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 Communicator client 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.
*/
class nsTreeIndentationFrame : public nsFrame {
public:
friend nsresult NS_NewTreeIndentationFrame(nsIFrame** aNewFrame);
// nsIHTMLReflow
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
nsTreeIndentationFrame();
protected:
virtual ~nsTreeIndentationFrame();
nscoord mWidth;
PRBool mHaveComputedWidth;
};

View File

@@ -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 "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 Communicator client 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.
*/
#include "nsCOMPtr.h"
#include "nsTreeOuterFrame.h"
#include "nsIStyleContext.h"
#include "nsIContent.h"
#include "nsCSSRendering.h"
#include "nsTreeCellFrame.h"
#include "nsCellMap.h"
#include "nsIDOMXULTreeElement.h"
#include "nsINameSpaceManager.h"
#include "nsXULAtoms.h"
//
// NS_NewTreeOuterFrame
//
// Creates a new tree frame
//
nsresult
NS_NewTreeOuterFrame (nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsTreeOuterFrame* it = new nsTreeOuterFrame;
if (!it)
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
} // NS_NewTreeOuterFrame
// Constructor
nsTreeOuterFrame::nsTreeOuterFrame()
:nsTableOuterFrame() { }
// Destructor
nsTreeOuterFrame::~nsTreeOuterFrame()
{
}
NS_IMETHODIMP
nsTreeOuterFrame::HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
aEventStatus = nsEventStatus_eConsumeDoDefault;
if (aEvent->message == NS_KEY_DOWN) {
// Retrieve the tree frame.
nsIFrame* curr = mFrames.FirstChild();
while (curr) {
nsCOMPtr<nsIContent> content;
curr->GetContent(getter_AddRefs(content));
if (content) {
nsCOMPtr<nsIAtom> tag;
content->GetTag(*getter_AddRefs(tag));
if (tag && tag.get() == nsXULAtoms::tree) {
// This is our actual tree frame.
return curr->HandleEvent(aPresContext, aEvent, aEventStatus);
}
}
curr->GetNextSibling(&curr);
}
}
return NS_OK;
}

View File

@@ -1,37 +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 "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 Communicator client 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.
*/
#include "nsTableOuterFrame.h"
class nsTreeOuterFrame : public nsTableOuterFrame
{
public:
friend nsresult NS_NewTreeOuterFrame(nsIFrame** aNewFrame);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
protected:
nsTreeOuterFrame();
virtual ~nsTreeOuterFrame();
protected: // Data Members
}; // class nsTreeOuterFrame

View File

@@ -1,405 +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 "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 Communicator client 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.
*/
#include "nsCOMPtr.h"
#include "nsTreeFrame.h"
#include "nsTreeRowFrame.h"
#include "nsIStyleContext.h"
#include "nsIContent.h"
#include "nsCSSRendering.h"
#include "nsTreeCellFrame.h"
#include "nsCellMap.h"
#include "nsIDOMXULTreeElement.h"
#include "nsINameSpaceManager.h"
#include "nsTreeRowGroupFrame.h"
#include "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsTableColFrame.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMXULTreeElement.h"
#include "nsTreeTwistyListener.h"
#include "nsIViewManager.h"
#include "nsIView.h"
#include "nsIPresContext.h"
//
// NS_NewTreeFrame
//
// Creates a new tree frame
//
nsresult
NS_NewTreeRowFrame (nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsTreeRowFrame* it = new nsTreeRowFrame;
if (!it)
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
} // NS_NewTreeRowFrame
// Constructor
nsTreeRowFrame::nsTreeRowFrame()
:nsTableRowFrame(), mIsHeader(PR_FALSE), mGeneration(0), mDraggingHeader(PR_FALSE),
mHitFrame(nsnull), mFlexingCol(nsnull), mHeaderPosition(0)
{ }
// Destructor
nsTreeRowFrame::~nsTreeRowFrame()
{
}
NS_METHOD nsTreeRowFrame::IR_TargetIsChild(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame * aNextFrame)
{
nsRect rect;
GetRect(rect);
nsresult rv = nsTableRowFrame::IR_TargetIsChild(aPresContext, aDesiredSize, aReflowState, aStatus, aNextFrame);
if (rv == NS_OK) {
// Find out if our height changed. With the tree widget, changing the height of a row is a
// big deal, since it may force us to dynamically isntantiate newly exposed frames.
if (rect.height != aDesiredSize.height) {
// Retrieve the table frame and invalidate the cell map.
nsTableFrame* tableFrame = nsnull;
nsTableFrame::GetTableFrame(this, tableFrame);
tableFrame->InvalidateCellMap();
}
}
return rv;
}
NS_IMETHODIMP
nsTreeRowFrame::Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsTableRowFrame::Init(aPresContext, aContent, aParent, aContext,
aPrevInFlow);
// Determine if we're a column header or not.
// Get row group frame
if (aParent != nsnull)
{
// Get the display type of the row group frame and see if it's a header or body
nsCOMPtr<nsIStyleContext> parentContext;
aParent->GetStyleContext(getter_AddRefs(parentContext));
if (parentContext)
{
const nsStyleDisplay* display = (const nsStyleDisplay*)
parentContext->GetStyleData(eStyleStruct_Display);
if (display->mDisplay == NS_STYLE_DISPLAY_TABLE_HEADER_GROUP)
{
mIsHeader = PR_TRUE;
// headers get their own views, so that they can capture events
CreateViewForFrame(aPresContext,this,aContext,PR_TRUE);
nsIView* view;
GetView(&aPresContext, &view);
view->SetContentTransparency(PR_TRUE);
}
else
{
mIsHeader = PR_FALSE;
// Determine the row's generation.
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(aParent, tableFrame);
nsTreeFrame* treeFrame = (nsTreeFrame*)tableFrame;
mGeneration = treeFrame->GetCurrentGeneration();
}
}
}
return rv;
}
NS_IMETHODIMP
nsTreeRowFrame::HeaderDrag(nsIPresContext* aPresContext, PRBool aGrabMouseEvents)
{
// get its view
nsIView* view = nsnull;
GetView(aPresContext, &view);
nsCOMPtr<nsIViewManager> viewMan;
PRBool result;
if (view) {
view->GetViewManager(*getter_AddRefs(viewMan));
if (viewMan) {
if (aGrabMouseEvents) {
viewMan->GrabMouseEvents(view,result);
mDraggingHeader = PR_TRUE;
} else {
viewMan->GrabMouseEvents(nsnull,result);
mDraggingHeader = PR_FALSE;
}
}
}
return NS_OK;
}
NS_IMETHODIMP
nsTreeRowFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
/*
if (aReflowState.reason != eReflowReason_Incremental) {
// Determine the row's generation.
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame);
nsTreeFrame* treeFrame = (nsTreeFrame*)tableFrame;
if (treeFrame->UseGeneration()) {
PRInt32 currGeneration = treeFrame->GetCurrentGeneration();
if (currGeneration > mGeneration) {
nsRect rect;
GetRect(rect);
aDesiredSize.width = rect.width;
aDesiredSize.height = rect.height;
aStatus = NS_FRAME_COMPLETE;
return NS_OK;
}
}
}
*/
/* static int i = 0;
i++;
printf("Full row reflow! Number %d\n", i);
*/
return nsTableRowFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
}
nsresult
nsTreeRowFrame::HandleMouseUpEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
if (DraggingHeader()) {
HeaderDrag(&aPresContext, PR_FALSE);
}
return NS_OK;
}
NS_IMETHODIMP
nsTreeRowFrame::HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
aEventStatus = nsEventStatus_eConsumeDoDefault;
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP)
HandleMouseUpEvent(aPresContext, aEvent, aEventStatus);
else if (aEvent->message == NS_MOUSE_MOVE && mDraggingHeader && mHitFrame)
HandleHeaderDragEvent(aPresContext, aEvent, aEventStatus);
return NS_OK;
}
NS_IMETHODIMP
nsTreeRowFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint, // Overridden to capture events
nsIFrame** aFrame)
{
nsresult rv = nsTableRowFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
if (mDraggingHeader) {
mHitFrame = *aFrame;
*aFrame = this;
nsRect rect;
GetRect(rect);
if (rect.x > aPoint.x || (rect.x+rect.width < aPoint.x)) {
mHitFrame = nsnull;
}
}
return rv;
}
NS_IMETHODIMP
nsTreeRowFrame::GetCursor(nsIPresContext& aPresContext,
nsPoint& aPoint,
PRInt32& aCursor)
{
if (mDraggingHeader) {
nsRect rect;
GetRect(rect);
if (rect.x > aPoint.x || (rect.x+rect.width < aPoint.x)) {
aCursor = NS_STYLE_CURSOR_DEFAULT;
}
else {
aCursor = NS_STYLE_CURSOR_W_RESIZE;
}
}
else aCursor = NS_STYLE_CURSOR_DEFAULT;
return NS_OK;
}
nsresult
nsTreeRowFrame::HandleHeaderDragEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
// Grab our tree frame.
nsTableFrame* tableFrame = nsnull;
nsTableFrame::GetTableFrame(this, tableFrame);
nsTreeFrame* treeFrame = (nsTreeFrame*)tableFrame;
// Until we finish all of our batched operations, suppress all reflow.
treeFrame->SuppressReflow();
PRInt32 columnCount = treeFrame->GetColCount();
PRInt32* colWidths = new PRInt32[columnCount];
nsCRT::memset(colWidths, 0, columnCount*sizeof(PRInt32));
// Retrieve our column widths.
PRInt32 i;
for (i = 0; i < columnCount; i++) {
nsTableColFrame* result = treeFrame->GetColFrame(i);
nsCOMPtr<nsIContent> colContent;
result->GetContent(getter_AddRefs(colContent));
nsCOMPtr<nsIAtom> fixedAtom = dont_AddRef(NS_NewAtom("fixed"));
if (colContent) {
nsAutoString fixedValue;
colContent->GetAttribute(kNameSpaceID_None, fixedAtom, fixedValue);
if (fixedValue != "true") {
// We are a proportional column and should be annotated with our current
// width.
PRInt32 colWidth = treeFrame->GetColumnWidth(i);
colWidths[i] = colWidth;
}
}
}
// Annotate with the current proportions
for (i = 0; i < columnCount; i++) {
if (colWidths[i] > 0) {
nsTableColFrame* result = treeFrame->GetColFrame(i);
nsCOMPtr<nsIContent> colContent;
result->GetContent(getter_AddRefs(colContent));
if (colContent) {
PRInt32 colWidth = colWidths[i];
char ch[100];
sprintf(ch,"%d*", colWidth);
nsAutoString propColWidth(ch);
colContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::width, propColWidth,
PR_TRUE);
}
}
}
// Figure out how much we shifted the mouse.
char ch[100];
nsPoint point = ((nsMouseEvent*)aEvent)->point;
PRInt32 delta = mHeaderPosition - point.x;
mHeaderPosition = point.x;
// The proportional columns to the right will gain or lose space
// according to the percentages they currently consume.
nscoord propTotal = 0;
// Find our flexing col and note its index and width.
PRInt32 colX;
PRInt32 flexWidth = 0;
PRInt32 flexIndex = 0;
for (colX = 0; colX < columnCount; colX++) {
// Get column information
nsTableColFrame* colFrame = tableFrame->GetColFrame(colX);
if (colFrame == mFlexingCol) {
flexWidth = colWidths[colX];
flexIndex = colX;
break;
}
}
for (colX = flexIndex+1; colX < columnCount; colX++) {
// Retrieve the current widths for these columns and compute
// the total amount of space they occupy.
propTotal += colWidths[colX];
}
// Iterate over the columns to the right of the flexing column,
// and give them a percentage of the delta based off their proportions.
nsCOMPtr<nsIContent> colContent;
nsTableColFrame* colFrame;
PRInt32 colWidth = 0;
PRInt32 remaining = delta;
for (colX = flexIndex+1; colX < columnCount; colX++) {
if (colWidths[colX] > 0) {
colFrame = tableFrame->GetColFrame(colX);
float percentage = ((float)colWidths[colX])/((float)propTotal);
PRInt32 mod = (PRInt32)(percentage * (float)delta);
colWidth = colWidths[colX] + mod;
sprintf(ch,"%d*", colWidth);
nsAutoString propColWidth(ch);
colFrame->GetContent(getter_AddRefs(colContent));
if (colContent) {
colContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::width, propColWidth,
PR_TRUE);
}
remaining -= mod;
}
}
// Fix the spillover. We'll probably be off by a little.
if (remaining != 0 && colContent) {
colWidth += remaining;
sprintf(ch,"%d*", colWidth);
nsAutoString propColWidth(ch);
colContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::width, propColWidth,
PR_TRUE);
}
// Delete the colWidths array.
delete []colWidths;
// Modify the flexing column by the delta.
nsCOMPtr<nsIContent> flexContent;
mFlexingCol->GetContent(getter_AddRefs(flexContent));
if (flexContent) {
treeFrame->SetUseGeneration(PR_FALSE); // Cached rows have to reflow.
treeFrame->UnsuppressReflow();
colWidth = flexWidth - delta;
sprintf(ch,"%d*", colWidth);
nsAutoString propColWidth(ch);
flexContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::width, propColWidth,
PR_TRUE); // NOW we send the notification that causes the reflow.
// Do a dirty table reflow.
//treeFrame->MarkForDirtyReflow(aPresContext);
}
return NS_OK;
}

View File

@@ -1,87 +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 "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 Communicator client 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.
*/
#include "nsTableRowFrame.h"
#include "nsVoidArray.h"
class nsTreeCellFrame;
class nsTreeRowGroupFrame;
class nsTableColFrame;
class nsTreeRowFrame : public nsTableRowFrame
{
public:
friend nsresult NS_NewTreeRowFrame(nsIFrame** aNewFrame);
// Overridden methods
NS_IMETHOD IR_TargetIsChild(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame * aNextFrame);
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow); // Overridden to set whether we're a column header
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint, // Overridden to capture events
nsIFrame** aFrame);
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD HandleMouseUpEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD HandleHeaderDragEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD GetCursor(nsIPresContext& aPresContext,
nsPoint& aPoint,
PRInt32& aCursor);
NS_IMETHOD HeaderDrag(nsIPresContext* aPresContext, PRBool aGrabber);
PRBool DraggingHeader() { return mDraggingHeader; };
void SetFlexingColumn(nsTableColFrame* aTableColFrame) { mFlexingCol = aTableColFrame; };
void SetHeaderPosition(PRInt32 aHeaderPos) { mHeaderPosition = aHeaderPos; };
protected:
nsTreeRowFrame();
virtual ~nsTreeRowFrame();
protected: // Data Members
PRBool mIsHeader;
PRInt32 mGeneration;
PRBool mDraggingHeader;
nsIFrame* mHitFrame;
nsTableColFrame* mFlexingCol;
PRInt32 mHeaderPosition;
}; // class nsTreeRowFrame

File diff suppressed because it is too large Load Diff

View File

@@ -1,193 +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 "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 Communicator client 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.
*/
#include "nsTableRowGroupFrame.h"
#include "nsVoidArray.h"
#include "nsIScrollbarListener.h"
class nsTreeFrame;
class nsCSSFrameConstructor;
class nsISupportsArray;
class nsTreeRowGroupFrame : public nsTableRowGroupFrame, public nsIScrollbarListener
{
public:
friend nsresult NS_NewTreeRowGroupFrame(nsIFrame** aNewFrame);
NS_IMETHOD GetAdditionalChildListName(PRInt32 aIndex,
nsIAtom** aListName) const;
NS_IMETHOD FirstChild(nsIAtom* aListName, nsIFrame** aFirstChild) const;
void SetScrollbarFrame(nsIFrame* aFrame);
void SetFrameConstructor(nsCSSFrameConstructor* aFrameConstructor) { mFrameConstructor = aFrameConstructor; };
void SetShouldHaveScrollbar();
void CreateScrollbar(nsIPresContext& aPresContext);
void MakeLazy() { mIsLazy = PR_TRUE; };
PRBool IsLazy() { return mIsLazy; };
NS_IMETHOD TreeAppendFrames(nsIFrame* aFrameList);
NS_IMETHOD TreeInsertFrames(nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsIFrame** aFrame);
void PaintChildren(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
NS_IMETHOD Destroy(nsIPresContext& aPresContext);
PRBool ContinueReflow(nsIPresContext& aPresContext, nscoord y, nscoord height);
PRBool IsFull() { return mIsFull; };
// Responses to changes
void OnContentAdded(nsIPresContext& aPresContext);
void OnContentInserted(nsIPresContext& aPresContext, nsIFrame* aNextSibling);
void OnContentRemoved(nsIPresContext& aPresContext, nsIFrame* aChildFrame);
virtual nsIFrame* GetFirstFrame();
virtual nsIFrame* GetLastFrame();
virtual void GetNextFrame(nsIFrame* aFrame, nsIFrame** aResult);
virtual PRBool RowsDesireExcessSpace() { return PR_FALSE; };
virtual PRBool RowGroupDesiresExcessSpace();
NS_DECL_ISUPPORTS
NS_IMETHOD PositionChanged(nsIPresContext& aPresContext, PRInt32 aOldIndex, PRInt32 aNewIndex);
NS_IMETHOD PagedUpDown();
protected:
nsTreeRowGroupFrame();
virtual ~nsTreeRowGroupFrame();
virtual PRBool RowGroupReceivesExcessSpace();
void DestroyRows(nsTableFrame* aTableFrame, nsIPresContext& aPresContext, PRInt32& rowsToLose);
void ReverseDestroyRows(nsTableFrame* aTableFrame, nsIPresContext& aPresContext, PRInt32& rowsToLose);
NS_IMETHOD ReflowBeforeRowLayout(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,
nsReflowStatus& aStatus,
nsReflowReason aReason);
NS_IMETHOD ReflowAfterRowLayout(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,
nsReflowStatus& aStatus,
nsReflowReason aReason);
NS_IMETHOD IR_TargetIsChild(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame * aNextFrame);
virtual nsIFrame* GetFirstFrameForReflow(nsIPresContext& aPresContext);
virtual void GetNextFrameForReflow(nsIPresContext& aPresContext, nsIFrame* aFrame, nsIFrame** aResult);
void LocateFrame(nsIFrame* aStartFrame, nsIFrame** aResult);
void SetContentChain(nsISupportsArray* aContentChain);
void InitSubContentChain(nsTreeRowGroupFrame* aRowGroupFrame);
void ConstructContentChain(nsIContent* aRowContent);
void ConstructOldContentChain(nsIPresContext& aPresContext, nsIContent* aOldRowContent);
void CreateOldContentChain(nsIPresContext& aPresContext, nsIContent* aOldRowContent, nsIContent* topOfChain);
void FindChildOfCommonContentChainAncestor(nsIContent *startContent, nsIContent **child);
PRBool IsAncestor(nsIContent *aRowContent, nsIContent *aOldRowContent, nsIContent **firstDescendant);
void FindPreviousRowContent(PRInt32& aDelta, nsIContent* aUpwardHint,
nsIContent* aDownwardHint, nsIContent** aResult);
static void FindRowContentAtIndex(PRInt32& aIndex, nsIContent* aParent,
nsIContent** aResult);
void MarkTreeAsDirty(nsIPresContext& aPresContext, nsTreeFrame* aTreeFrame);
void GetFirstRowContent(nsIContent** aRowContent);
void ComputeVisibleRowCount(PRInt32& rowCount, nsIContent* aParent);
void PostAppendRow(nsIFrame* aRowFrame, nsIPresContext& aPresContext);
public:
// Helpers that allow access to info. The tree is the primary consumer of this
// info.
// Tells you the row and index of a cell (given only the content node).
// This method is expensive.
void IndexOfCell(nsIPresContext& aPresContext, nsIContent* aCellContent,
PRInt32& aRowIndex, PRInt32& aColIndex);
// Tells you the row index of a row (given only the content node).
// This method is expensive.
void IndexOfRow(nsIPresContext& aPresContext, nsIContent* aRowContent, PRInt32& aRowIndex);
// Whether or not the row is valid. This is a cheap method, since the total row count
// is cached.
PRBool IsValidRow(PRInt32 aRowIndex);
// This method ensures that a row is onscreen. It will scroll the tree widget such
// that the row is at the top of the screen (if the row was offscreen to start with).
void EnsureRowIsVisible(PRInt32 aRowIndex);
// This method retrieves a cell at a given index. The intent of this method is that it be
// cheap. It should not cause frames to be built, so this should only be called when the
// cell is onscreen (use EnsureRowIsVisible to guarantee this).
void GetCellFrameAtIndex(PRInt32 aRowIndex, PRInt32 aColIndex, nsTreeCellFrame** aResult);
PRInt32 GetVisibleRowCount() { return mRowCount; };
#if 0
static PRInt32 ChildrenAbove(nsIContent *parent, nsIContent *item);
static PRInt32 RecursiveTagCount(nsIContent *node, nsIAtom *tag);
static nsresult FindParentWithTag(nsIContent *node, nsIAtom *tag,
nsIContent **node);
#endif
static PRBool IsTableRowGroupFrame(nsIFrame*);
static PRBool IsTableRowFrame(nsIFrame*);
protected: // Data Members
nsIFrame* mTopFrame; // The current topmost frame in the view.
nsIFrame* mBottomFrame; // The current bottom frame in the view.
nsIFrame* mLinkupFrame; // An old top frame that we're trying to link up with.
PRBool mIsLazy; // Whether or not we're a lazily instantiated beast
PRBool mIsFull; // Whether or not we have any more room.
nsIFrame* mScrollbar; // Our scrollbar.
nsFrameList mScrollbarList; // A frame list that holds our scrollbar.
PRBool mShouldHaveScrollbar; // Whether or not we could potentially have a scrollbar.
nsISupportsArray* mContentChain; // Our content chain
nsCSSFrameConstructor* mFrameConstructor; // We don't own this. (No addref/release allowed, punk.)
nscoord mRowGroupHeight; // The height of the row group.
PRInt32 mCurrentIndex; // Our current scrolled index.
PRInt32 mRowCount; // The current number of visible rows.
}; // class nsTreeRowGroupFrame

View File

@@ -1,137 +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 "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 Communicator client 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.
*/
#include "nsTreeTwistyListener.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMEventListener.h"
#include "nsCOMPtr.h"
#include "nsIDOMUIEvent.h"
#include "nsIPresContext.h"
#include "nsIContent.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsXULAtoms.h"
/*
* nsTreeTwistyListener implementation
*/
NS_IMPL_ADDREF(nsTreeTwistyListener)
NS_IMPL_RELEASE(nsTreeTwistyListener)
////////////////////////////////////////////////////////////////////////
nsTreeTwistyListener::nsTreeTwistyListener()
{
NS_INIT_REFCNT();
}
////////////////////////////////////////////////////////////////////////
nsTreeTwistyListener::~nsTreeTwistyListener()
{
}
////////////////////////////////////////////////////////////////////////
nsresult
nsTreeTwistyListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(nsCOMTypeInfo<nsIDOMEventReceiver>::GetIID())) {
*aInstancePtr = (void*)(nsIDOMEventListener*)(nsIDOMKeyListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsIDOMMouseListener>::GetIID())) {
*aInstancePtr = (void*)(nsIDOMMouseListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID())) {
*aInstancePtr = (void*)(nsISupports*)(nsIDOMKeyListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
////////////////////////////////////////////////////////////////////////
static void GetTreeItem(nsIDOMElement* aElement, nsIDOMElement** aResult)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
while (content) {
nsCOMPtr<nsIAtom> tag;
content->GetTag(*getter_AddRefs(tag));
if (tag.get() == nsXULAtoms::treeitem) {
nsCOMPtr<nsIDOMElement> result = do_QueryInterface(content);
*aResult = result.get();
NS_IF_ADDREF(*aResult);
return;
}
nsCOMPtr<nsIContent> parent;
content->GetParent(*getter_AddRefs(parent));
content = parent;
}
}
nsresult
nsTreeTwistyListener::MouseDown(nsIDOMEvent* aEvent)
{
// Get the target of the event. If it's a titledbutton, we care.
nsCOMPtr<nsIDOMNode> target;
aEvent->GetTarget(getter_AddRefs(target));
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
if (!element)
return NS_OK;
nsAutoString tagName;
element->GetTagName(tagName);
if (tagName == "titledbutton") {
// Find out if we're the twisty.
nsAutoString classAttr;
element->GetAttribute("class", classAttr);
if (classAttr == "twisty") {
// Retrieve the parent treeitem.
nsCOMPtr<nsIDOMElement> treeItem;
GetTreeItem(element, getter_AddRefs(treeItem));
if (!treeItem)
return NS_OK;
// Eat the event.
aEvent->PreventCapture();
aEvent->PreventBubble();
nsAutoString open;
treeItem->GetAttribute("open", open);
if (open == "true")
treeItem->RemoveAttribute("open");
else treeItem->SetAttribute("open", "true");
}
}
return NS_OK;
}

View File

@@ -1,54 +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 "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 Communicator client 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.
*/
#ifndef nsTreeTwistyListener_h__
#define nsTreeTwistyListener_h__
#include "nsIDOMMouseListener.h"
#include "nsIDOMEventReceiver.h"
class nsIPresContext;
/** editor Implementation of the DragListener interface
*/
class nsTreeTwistyListener : public nsIDOMMouseListener
{
public:
/** default constructor
*/
nsTreeTwistyListener();
/** default destructor
*/
virtual ~nsTreeTwistyListener();
virtual nsresult HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; };
virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent);
virtual nsresult MouseUp(nsIDOMEvent* aMouseEvent) { return NS_OK; };
virtual nsresult MouseClick(nsIDOMEvent* aMouseEvent) { return NS_OK; };
virtual nsresult MouseDblClick(nsIDOMEvent* aMouseEvent) { return NS_OK; };
virtual nsresult MouseOver(nsIDOMEvent* aMouseEvent) { return NS_OK; };
virtual nsresult MouseOut(nsIDOMEvent* aMouseEvent) { return NS_OK; };
NS_DECL_ISUPPORTS
protected:
};
#endif

View File

@@ -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 = src
include $(topsrcdir)/config/rules.mk

View File

@@ -1,22 +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=src
include <$(DEPTH)\config\rules.mak>

View File

@@ -1,41 +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
MODULE = layout
LIBRARY_NAME = raptorxulcontent_s
REQUIRES = xpcom raptor dom
CPPSRCS = nsXULAtoms.cpp
# we don't want the shared lib, but we want to force the creation of a static lib.
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk
DEFINES += -D_IMPL_NS_HTML
INCLUDES += -I$(srcdir)/../../../base/src -I$(DIST)/public/raptor

View File

@@ -1,53 +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=..\..\..\..
LIBRARY_NAME=raptorxulcontent_s
MODULE=raptor
REQUIRES=xpcom raptor pref
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
CPPSRCS= \
nsXULAtoms.cpp \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\nsXULAtoms.obj \
$(NULL)
EXPORTS = \
$(NULL)
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
-I..\..\..\html\style\src -I..\..\..\html\base\src -I$(PUBLIC)\dom \
-I..\..\..\html\document\src \
-I$(PUBLIC)\netlib -I..\..\..\base\src -I$(PUBLIC)\pref
LCFLAGS = \
$(LCFLAGS) \
$(DEFINES) \
$(NULL)
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib

View File

@@ -1,129 +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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
/******
This file contains the list of all XUL nsIAtoms and their values
It is designed to be used as inline input to nsXULAtoms.cpp *only*
through the magic of C preprocessing.
All entires must be enclosed in the macro XUL_ATOM which will have cruel
and unusual things done to it
It is recommended (but not strictly necessary) to keep all entries
in alphabetical order
The first argument to XUL_ATOM is the C++ identifier of the atom
The second argument is the string value of the atom
******/
XUL_ATOM(button, "button")
XUL_ATOM(spinner, "spinner")
XUL_ATOM(scrollbar, "scrollbar")
XUL_ATOM(slider, "slider")
XUL_ATOM(colorpicker, "colorpicker")
XUL_ATOM(palettename, "palettename")
XUL_ATOM(fontpicker, "fontpicker")
XUL_ATOM(radio, "radio")
XUL_ATOM(text, "text")
XUL_ATOM(toolbar, "toolbar")
XUL_ATOM(toolbaritem, "toolbaritem")
XUL_ATOM(toolbox, "toolbox")
// The tree atoms
XUL_ATOM(tree, "tree") // The start of a tree view
XUL_ATOM(treecaption, "treecaption") // The caption of a tree view
XUL_ATOM(treehead, "treehead") // The header of the tree view
XUL_ATOM(treerow, "treerow") // A row in the tree view
XUL_ATOM(treecell, "treecell") // An item in the tree view
XUL_ATOM(treeitem, "treeitem") // A cell in the tree view
XUL_ATOM(treechildren, "treechildren") // The children of an item in the tree view
XUL_ATOM(treeindentation, "treeindentation") // Specifies that the indentation for the level should occur here.
XUL_ATOM(allowevents, "allowevents") // Lets events be handled on the cell contents or in menus.
XUL_ATOM(treecol, "treecol") // A column in the tree view
XUL_ATOM(treecolgroup, "treecolgroup") // A column group in the tree view
XUL_ATOM(treefoot, "treefoot") // The footer of the tree view
XUL_ATOM(treepusher, "treepusher") // A column pusher (left or right) for the tree view
XUL_ATOM(scrollbarlist, "scrollbarlist") // An atom for internal use by the tree view
XUL_ATOM(open, "open") // Whether or not a menu, tree, etc. is open
XUL_ATOM(menubar, "menubar") // An XP menu bar.
XUL_ATOM(menu, "menu") // Represents an XP menu
XUL_ATOM(menuitem, "menuitem") // Represents an XP menu item
XUL_ATOM(menupopup, "menupopup") // The XP menu's children.
XUL_ATOM(menuactive, "menuactive") // Whether or not a menu is active (without necessarily being open)
XUL_ATOM(accesskey, "accesskey") // The shortcut key for a menu or menu item
XUL_ATOM(acceltext, "acceltext") // Text to use for the accelerator
XUL_ATOM(popupset, "popupset") // Contains popup menus, context menus, and tooltips
XUL_ATOM(popup, "popup") // The popup for a context menu, popup menu, or tooltip
XUL_ATOM(menugenerated, "menugenerated") // Internal
XUL_ATOM(key, "key") // A key element
XUL_ATOM(broadcaster, "broadcaster") // A broadcaster
XUL_ATOM(observes, "observes") // The observes element
XUL_ATOM(templateAtom, "template") // A XUL template
XUL_ATOM(progressmeter, "progressmeter")
XUL_ATOM(titledbutton, "titledbutton")
XUL_ATOM(crop, "crop")
XUL_ATOM(mode, "mode")
XUL_ATOM(box, "box")
XUL_ATOM(flex, "flex")
XUL_ATOM(spring, "spring")
XUL_ATOM(deck, "deck")
XUL_ATOM(tabcontrol, "tabcontrol")
XUL_ATOM(tab, "tab")
XUL_ATOM(tabpanel, "tabpanel")
XUL_ATOM(tabpage, "tabpage")
XUL_ATOM(tabbox, "tabbox")
XUL_ATOM(index, "index")
XUL_ATOM(maxpos, "maxpos")
XUL_ATOM(curpos, "curpos")
XUL_ATOM(scrollbarbutton, "scrollbarbutton")
XUL_ATOM(increment, "increment")
XUL_ATOM(pageincrement, "pageincrement")
XUL_ATOM(thumb, "thumb")
XUL_ATOM(toggled, "toggled")
XUL_ATOM(grippy, "grippy")
XUL_ATOM(splitter, "splitter")
XUL_ATOM(collapse, "collapse")
XUL_ATOM(resizebefore, "resizebefore")
XUL_ATOM(resizeafter, "resizeafter")
XUL_ATOM(state, "state")
// toolbar & toolbar d&d atoms
XUL_ATOM(tbDropLocation, "tb-droplocation")
XUL_ATOM(tbDropLocationCoord, "tb-droplocationcoord")
XUL_ATOM(tbDropOn, "tb-dropon")
XUL_ATOM(tbTriggerRepaint, "tb-triggerrepaint")
XUL_ATOM(container, "container")
XUL_ATOM(widget, "widget")
XUL_ATOM(window, "window")
XUL_ATOM(iframe, "iframe")
XUL_ATOM(browser, "browser")
XUL_ATOM(editor, "editor")

View File

@@ -1,68 +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 "nsString.h"
#include "nsINameSpaceManager.h"
#include "nsXULAtoms.h"
static const char kXULNameSpace[] = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
PRInt32 nsXULAtoms::nameSpaceID;
// define storage for all atoms
#define XUL_ATOM(_name, _value) nsIAtom* nsXULAtoms::_name;
#include "nsXULAtomList.h"
#undef XUL_ATOM
static nsrefcnt gRefCnt = 0;
static nsINameSpaceManager* gNameSpaceManager;
void nsXULAtoms::AddRefAtoms() {
if (gRefCnt == 0) {
/* XUL Atoms registers the XUL name space ID because it's a convenient
place to do this, if you don't want a permanent, "well-known" ID.
*/
if (NS_SUCCEEDED(NS_NewNameSpaceManager(&gNameSpaceManager))) {
// gNameSpaceManager->CreateRootNameSpace(namespace);
nsAutoString nameSpace(kXULNameSpace);
gNameSpaceManager->RegisterNameSpace(nameSpace, nameSpaceID);
} else {
NS_ASSERTION(0, "failed to create xul atoms namespace manager");
}
// now register the atoms
#define XUL_ATOM(_name, _value) _name = NS_NewAtom(_value);
#include "nsXULAtomList.h"
#undef XUL_ATOM
}
++gRefCnt;
}
void nsXULAtoms::ReleaseAtoms() {
NS_PRECONDITION(gRefCnt != 0, "bad release of xul atoms");
if (--gRefCnt == 0) {
#define XUL_ATOM(_name, _value) NS_RELEASE(_name);
#include "nsXULAtomList.h"
#undef XUL_ATOM
NS_IF_RELEASE(gNameSpaceManager);
}
}

View File

@@ -1,54 +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 nsXULAtoms_h___
#define nsXULAtoms_h___
#include "prtypes.h"
#include "nsIAtom.h"
class nsINameSpaceManager;
/**
* This class wraps up the creation and destruction of the standard
* set of xul atoms used during normal xul handling. This object
* is created when the first xul content object is created, and
* destroyed when the last such content object is destroyed.
*/
class nsXULAtoms {
public:
static void AddRefAtoms();
static void ReleaseAtoms();
// XUL namespace ID, good for the life of the nsXULAtoms object
static PRInt32 nameSpaceID;
/* Declare all atoms
The atom names and values are stored in nsCSSAtomList.h and
are brought to you by the magic of C preprocessing
Add new atoms to nsCSSAtomList and all support logic will be auto-generated
*/
#define XUL_ATOM(_name, _value) static nsIAtom* _name;
#include "nsXULAtomList.h"
#undef XUL_ATOM
};
#endif /* nsXULAtoms_h___ */

View File

@@ -1,22 +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 = base content
include <$(DEPTH)\config\rules.mak>