Compare commits

..

10 Commits

Author SHA1 Message Date
waterson%netscape.com
6885efc198 Added more tracing calls.
git-svn-id: svn://10.0.0.236/branches/PERFORMANCE_19980724_BRANCH@6630 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-28 17:20:36 +00:00
waterson%netscape.com
7a7762c0b1 Added logging to HTTP protocol handler.
git-svn-id: svn://10.0.0.236/branches/PERFORMANCE_19980724_BRANCH@6629 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-28 17:19:52 +00:00
waterson%netscape.com
2cc5a84d4c Added performance tracing hooks.
git-svn-id: svn://10.0.0.236/branches/PERFORMANCE_19980724_BRANCH@6491 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-25 05:59:53 +00:00
waterson%netscape.com
1634d0ca5e Fixed Unix build.
git-svn-id: svn://10.0.0.236/branches/PERFORMANCE_19980724_BRANCH@6490 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-25 05:57:23 +00:00
waterson%netscape.com
a481a5c07f Fixed synchronous DNS lookup tracing.
git-svn-id: svn://10.0.0.236/branches/PERFORMANCE_19980724_BRANCH@6489 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-25 05:57:03 +00:00
waterson%netscape.com
efb3836cea Added pref directory to build.
git-svn-id: svn://10.0.0.236/branches/PERFORMANCE_19980724_BRANCH@6488 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-25 05:52:12 +00:00
waterson%netscape.com
3fb0c42547 Changes to trace netlib activity.
git-svn-id: svn://10.0.0.236/branches/PERFORMANCE_19980724_BRANCH@6486 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-25 04:55:33 +00:00
waterson%netscape.com
b835523159 Changes to support performance hooks.
git-svn-id: svn://10.0.0.236/branches/PERFORMANCE_19980724_BRANCH@6485 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-25 04:53:43 +00:00
waterson%netscape.com
b5223226de Changes to support performance hooks & Ctrl+Alt+P.
git-svn-id: svn://10.0.0.236/branches/PERFORMANCE_19980724_BRANCH@6484 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-25 04:50:57 +00:00
(no author)
4b061f6a26 This commit was manufactured by cvs2svn to create branch
'PERFORMANCE_19980724_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/PERFORMANCE_19980724_BRANCH@6461 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-25 00:32:34 +00:00
1604 changed files with 584387 additions and 104276 deletions

36279
mozilla/CHANGES.html Normal file

File diff suppressed because it is too large Load Diff

40
mozilla/LEGAL Normal file
View File

@@ -0,0 +1,40 @@
Please be apprised of the following Legal Notices:
A) The U.S. District Court for the Eastern District of Virginia has
ruled that the Netscape Navigator code does not infringe Wang's U.S.
Patent No. 4,751,669 ("the '669 Patent") because: 1) HTML is not
Videotex as defined by the '669 patent; 2) web servers are not central
suppliers; and 3) Navigator does not "connect," as defined by the '669
Patent, to web servers on the Internet. Wang may appeal this decision to
the Federal Circuit. Wang contended that its Patent disclosing a
"Videotext" system, is infringed by the following functionality in the
Netscape Navigator code: 1) the animated logo and status line indicators
--See Claims 1,8 and 9; 2) the "File Save As" function --See Claims
23-27; 3) Bookmarks and Rename Bookmarks in the Properties window --See
Claims 20-22; 4) storing HTML, GIF, and JPEG files and adding filename
extensions --See Claim 38
B) Intermind owns pending U.S. patent applications on communications
systems which employ metadata ("channel objects") to define a control
structure for information transfer. The Netscape code does not infringe
as released; however, modifications which utilize channel objects as
described by Intermind should be considered carefully. The following is
a statement from Intermind: "Intermind's claims fundamentally involve
the use of a control structure to automate communications. ...The
essence of Intermind's top claim is that two devices sender and
receiver have persistent storage, communicate over a network,
and exchange a control structure including metadata which describes: 1)
what information is to be updated, 2) when to update this information,
and 3) how to transfer the updated information. In addition, at least
the receiving device must be able to process the metadata in order to
perform the update determination and transfer. Any digital
communications system which incorporates all of these elements will be
covered by Intermind's patents." See Intermind.com.
C) Stac, Inc., and its licensing agent Hi/fn, own several patents which
disclose data compression methods implementing an LZS compression
algorithm, including U.S. Patent Nos. 4,701,745 and 5,016, 009 ("the
Stac Patents"). The Netscape Communicator code does not perform
compression. If you modify the Netscape source code to perform
compression, please take notice of the Stac Patents.

421
mozilla/LICENSE Normal file
View File

@@ -0,0 +1,421 @@
NETSCAPE PUBLIC LICENSE
Version 1.0
----------------
1. Definitions.
1.1. ``Contributor'' means each entity that creates or contributes to
the creation of Modifications.
1.2. ``Contributor Version'' means the combination of the Original
Code, prior Modifications used by a Contributor, and the Modifications
made by that particular Contributor.
1.3. ``Covered Code'' means the Original Code or Modifications or the
combination of the Original Code and Modifications, in each case
including portions thereof.
1.4. ``Electronic Distribution Mechanism'' means a mechanism generally
accepted in the software development community for the electronic
transfer of data.
1.5. ``Executable'' means Covered Code in any form other than Source
Code.
1.6. ``Initial Developer'' means the individual or entity identified as
the Initial Developer in the Source Code notice required by Exhibit A.
1.7. ``Larger Work'' means a work which combines Covered Code or
portions thereof with code not governed by the terms of this License.
1.8. ``License'' means this document.
1.9. ``Modifications'' means any addition to or deletion from the
substance or structure of either the Original Code or any previous
Modifications. When Covered Code is released as a series of files, a
Modification is:
A. Any addition to or deletion from the contents of a file
containing Original Code or previous Modifications.
B. Any new file that contains any part of the Original Code or
previous Modifications.
1.10. ``Original Code'' means Source Code of computer software code
which is described in the Source Code notice required by Exhibit A as
Original Code, and which, at the time of its release under this License
is not already Covered Code governed by this License.
1.11. ``Source Code'' means the preferred form of the Covered Code for
making modifications to it, including all modules it contains, plus any
associated interface definition files, scripts used to control
compilation and installation of an Executable, or a list of source code
differential comparisons against either the Original Code or another
well known, available Covered Code of the Contributor's choice. The
Source Code can be in a compressed or archival form, provided the
appropriate decompression or de-archiving software is widely available
for no charge.
1.12. ``You'' means an individual or a legal entity exercising rights
under, and complying with all of the terms of, this License or a future
version of this License issued under Section 6.1. For legal entities,
``You'' includes any entity which controls, is controlled by, or is
under common control with You. For purposes of this definition,
``control'' means (a) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (b) ownership of fifty percent (50%) or more of the
outstanding shares or beneficial ownership of such entity.
2. Source Code License.
2.1. The Initial Developer Grant.
The Initial Developer hereby grants You a world-wide, royalty-free,
non-exclusive license, subject to third party intellectual property
claims:
(a) to use, reproduce, modify, display, perform, sublicense and
distribute the Original Code (or portions thereof) with or without
Modifications, or as part of a Larger Work; and
(b) under patents now or hereafter owned or controlled by Initial
Developer, to make, have made, use and sell (``Utilize'') the
Original Code (or portions thereof), but solely to the extent that
any such patent is reasonably necessary to enable You to Utilize
the Original Code (or portions thereof) and not to any greater
extent that may be necessary to Utilize further Modifications or
combinations.
2.2. Contributor Grant.
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license, subject to third party intellectual property
claims:
(a) to use, reproduce, modify, display, perform, sublicense and
distribute the Modifications created by such Contributor (or
portions thereof) either on an unmodified basis, with other
Modifications, as Covered Code or as part of a Larger Work; and
(b) under patents now or hereafter owned or controlled by
Contributor, to Utilize the Contributor Version (or portions
thereof), but solely to the extent that any such patent is
reasonably necessary to enable You to Utilize the Contributor
Version (or portions thereof), and not to any greater extent that
may be necessary to Utilize further Modifications or combinations.
3. Distribution Obligations.
3.1. Application of License.
The Modifications which You create or to which You contribute are
governed by the terms of this License, including without limitation
Section 2.2. The Source Code version of Covered Code may be distributed
only under the terms of this License or a future version of this
License released under Section 6.1, and You must include a copy of this
License with every copy of the Source Code You distribute. You may not
offer or impose any terms on any Source Code version that alters or
restricts the applicable version of this License or the recipients'
rights hereunder. However, You may include an additional document
offering the additional rights described in Section 3.5.
3.2. Availability of Source Code.
Any Modification which You create or to which You contribute must be
made available in Source Code form under the terms of this License
either on the same media as an Executable version or via an accepted
Electronic Distribution Mechanism to anyone to whom you made an
Executable version available; and if made available via Electronic
Distribution Mechanism, must remain available for at least twelve (12)
months after the date it initially became available, or at least six
(6) months after a subsequent version of that particular Modification
has been made available to such recipients. You are responsible for
ensuring that the Source Code version remains available even if the
Electronic Distribution Mechanism is maintained by a third party.
3.3. Description of Modifications.
You must cause all Covered Code to which you contribute to contain a
file documenting the changes You made to create that Covered Code and
the date of any change. You must include a prominent statement that the
Modification is derived, directly or indirectly, from Original Code
provided by the Initial Developer and including the name of the Initial
Developer in (a) the Source Code, and (b) in any notice in an
Executable version or related documentation in which You describe the
origin or ownership of the Covered Code.
3.4. Intellectual Property Matters
(a) Third Party Claims.
If You have knowledge that a party claims an intellectual property
right in particular functionality or code (or its utilization
under this License), you must include a text file with the source
code distribution titled ``LEGAL'' which describes the claim and
the party making the claim in sufficient detail that a recipient
will know whom to contact. If you obtain such knowledge after You
make Your Modification available as described in Section 3.2, You
shall promptly modify the LEGAL file in all copies You make
available thereafter and shall take other steps (such as notifying
appropriate mailing lists or newsgroups) reasonably calculated to
inform those who received the Covered Code that new knowledge has
been obtained.
(b) Contributor APIs.
If Your Modification is an application programming interface and
You own or control patents which are reasonably necessary to
implement that API, you must also include this information in the
LEGAL file.
3.5. Required Notices.
You must duplicate the notice in Exhibit A in each file of the Source
Code, and this License in any documentation for the Source Code, where
You describe recipients' rights relating to Covered Code. If You
created one or more Modification(s), You may add your name as a
Contributor to the notice described in Exhibit A. If it is not possible
to put such notice in a particular Source Code file due to its
structure, then you must include such notice in a location (such as a
relevant directory file) where a user would be likely to look for such
a notice. You may choose to offer, and to charge a fee for, warranty,
support, indemnity or liability obligations to one or more recipients
of Covered Code. However, You may do so only on Your own behalf, and
not on behalf of the Initial Developer or any Contributor. You must
make it absolutely clear than any such warranty, support, indemnity or
liability obligation is offered by You alone, and You hereby agree to
indemnify the Initial Developer and every Contributor for any liability
incurred by the Initial Developer or such Contributor as a result of
warranty, support, indemnity or liability terms You offer.
3.6. Distribution of Executable Versions.
You may distribute Covered Code in Executable form only if the
requirements of Section 3.1-3.5 have been met for that Covered Code,
and if You include a notice stating that the Source Code version of the
Covered Code is available under the terms of this License, including a
description of how and where You have fulfilled the obligations of
Section 3.2. The notice must be conspicuously included in any notice in
an Executable version, related documentation or collateral in which You
describe recipients' rights relating to the Covered Code. You may
distribute the Executable version of Covered Code under a license of
Your choice, which may contain terms different from this License,
provided that You are in compliance with the terms of this License and
that the license for the Executable version does not attempt to limit
or alter the recipient's rights in the Source Code version from the
rights set forth in this License. If You distribute the Executable
version under a different license You must make it absolutely clear
that any terms which differ from this License are offered by You alone,
not by the Initial Developer or any Contributor. You hereby agree to
indemnify the Initial Developer and every Contributor for any liability
incurred by the Initial Developer or such Contributor as a result of
any such terms You offer.
3.7. Larger Works.
You may create a Larger Work by combining Covered Code with other code
not governed by the terms of this License and distribute the Larger
Work as a single product. In such a case, You must make sure the
requirements of this License are fulfilled for the Covered Code.
4. Inability to Comply Due to Statute or Regulation.
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Code due to statute
or regulation then You must: (a) comply with the terms of this License
to the maximum extent possible; and (b) describe the limitations and
the code they affect. Such description must be included in the LEGAL
file described in Section 3.4 and must be included with all
distributions of the Source Code. Except to the extent prohibited by
statute or regulation, such description must be sufficiently detailed
for a recipient of ordinary skill to be able to understand it.
5. Application of this License.
This License applies to code to which the Initial Developer has
attached the notice in Exhibit A, and to related Covered Code.
6. Versions of the License.
6.1. New Versions.
Netscape Communications Corporation (``Netscape'') may publish revised
and/or new versions of the License from time to time. Each version will
be given a distinguishing version number.
6.2. Effect of New Versions.
Once Covered Code has been published under a particular version of the
License, You may always continue to use it under the terms of that
version. You may also choose to use such Covered Code under the terms
of any subsequent version of the License published by Netscape. No one
other than Netscape has the right to modify the terms applicable to
Covered Code created under this License.
6.3. Derivative Works.
If you create or use a modified version of this License (which you may
only do in order to apply it to code which is not already Covered Code
governed by this License), you must (a) rename Your license so that the
phrases ``Mozilla'', ``MOZILLAPL'', ``MOZPL'', ``Netscape'', ``NPL'' or
any confusingly similar phrase do not appear anywhere in your license
and (b) otherwise make it clear that your version of the license
contains terms which differ from the Mozilla Public License and
Netscape Public License. (Filling in the name of the Initial Developer,
Original Code or Contributor in the notice described in Exhibit A shall
not of themselves be deemed to be modifications of this License.)
7. DISCLAIMER OF WARRANTY.
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN ``AS IS'' BASIS,
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
8. TERMINATION.
This License and the rights granted hereunder will terminate
automatically if You fail to comply with terms herein and fail to cure
such breach within 30 days of becoming aware of the breach. All
sublicenses to the Covered Code which are properly granted shall
survive any termination of this License. Provisions which, by their
nature, must remain in effect beyond the termination of this License
shall survive.
9. LIMITATION OF LIABILITY.
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE INITIAL
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO YOU OR ANY OTHER
PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF
GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND
ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE
BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THAT
EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
10. U.S. GOVERNMENT END USERS.
The Covered Code is a ``commercial item,'' as that term is defined in
48 C.F.R. 2.101 (Oct. 1995), consisting of ``commercial computer
software'' and ``commercial computer software documentation,'' as such
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
all U.S. Government End Users acquire Covered Code with only those
rights set forth herein.
11. MISCELLANEOUS.
This License represents the complete agreement concerning subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. This License shall be governed by
California law provisions (except to the extent applicable law, if any,
provides otherwise), excluding its conflict-of-law provisions. With
respect to disputes in which at least one party is a citizen of, or an
entity chartered or registered to do business in, the United States of
America: (a) unless otherwise agreed in writing, all disputes relating
to this License (excepting any dispute relating to intellectual
property rights) shall be subject to final and binding arbitration,
with the losing party paying all costs of arbitration; (b) any
arbitration relating to this Agreement shall be held in Santa Clara
County, California, under the auspices of JAMS/EndDispute; and (c) any
litigation relating to this Agreement shall be subject to the
jurisdiction of the Federal Courts of the Northern District of
California, with venue lying in Santa Clara County, California, with
the losing party responsible for costs, including without limitation,
court costs and reasonable attorneys fees and expenses. The application
of the United Nations Convention on Contracts for the International
Sale of Goods is expressly excluded. Any law or regulation which
provides that the language of a contract shall be construed against the
drafter shall not apply to this License.
12. RESPONSIBILITY FOR CLAIMS.
Except in cases where another Contributor has failed to comply with
Section 3.4, You are responsible for damages arising, directly or
indirectly, out of Your utilization of rights under this License, based
on the number of copies of Covered Code you made available, the
revenues you received from utilizing such rights, and other relevant
factors. You agree to work with affected parties to distribute
responsibility on an equitable basis.
AMENDMENTS
Additional Terms applicable to the Netscape Public License.
I. Effect.
These additional terms described in this Netscape Public License --
Amendments shall apply to the Mozilla Communicator client code and to
all Covered Code under this License.
II. ``Netscape's Branded Code'' means Covered Code that Netscape
distributes and/or permits others to distribute under one or more
trademark(s) which are controlled by Netscape but which are not
licensed for use under this License.
III. Netscape and logo.
This License does not grant any rights to use the trademark
``Netscape'', the ``Netscape N and horizon'' logo or the Netscape
lighthouse logo, even if such marks are included in the Original Code.
IV. Inability to Comply Due to Contractual Obligation.
Prior to licensing the Original Code under this License, Netscape has
licensed third party code for use in Netscape's Branded Code. To the
extent that Netscape is limited contractually from making such third
party code available under this License, Netscape may choose to
reintegrate such code into Covered Code without being required to
distribute such code in Source Code form, even if such code would
otherwise be considered ``Modifications'' under this License.
V. Use of Modifications and Covered Code by Initial Developer.
V.1. In General.
The obligations of Section 3 apply to Netscape, except to the
extent specified in this Amendment, Section V.2 and V.3.
V.2. Other Products.
Netscape may include Covered Code in products other than the
Netscape's Branded Code which are released by Netscape during the
two (2) years following the release date of the Original Code,
without such additional products becoming subject to the terms of
this License, and may license such additional products on
different terms from those contained in this License.
V.3. Alternative Licensing.
Netscape may license the Source Code of Netscape's Branded Code,
including Modifications incorporated therein, without such
additional products becoming subject to the terms of this License,
and may license such additional products on different terms from
those contained in this License.
VI. Arbitration and Litigation.
Notwithstanding the limitations of Section 11 above, the provisions
regarding arbitration and litigation in Section 11(a), (b) and (c) of
the License shall apply to all disputes relating to this License.
EXHIBIT A.
``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, released March
31, 1998.
The Initial Developer of the Original Code is Netscape Communications
Corporation. Portions created by Netscape are Copyright (C) 1998
Netscape Communications Corporation. All Rights Reserved.
Contributor(s): ______________________________________.''
[NOTE: The text of this Exhibit A may differ slightly from the text of
the notices in the Source Code files of the Original Code. This is due
to time constraints encountered in simultaneously finalizing the
License and in preparing the Original Code for release. You should use
the text of this Exhibit A rather than the text found in the Original
Code Source Code for Your Modifications.]

89
mozilla/Makefile Normal file
View File

@@ -0,0 +1,89 @@
#
# 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 = .
NSPRDIR = nsprpub
NSPR20 = 1
MOZILLA_CLIENT = 1
ifndef NO_MOCHA
DIRS_JS = js
endif
DIRS = config coreconf $(NSPRDIR) jpeg dbm xpcom network
ifdef MOZ_NETCAST
DIRS += netcast
endif
ifdef MOZ_JAVA
DIRS += sun-java ldap ifc $(DIRS_JS) nav-java ifc/tools js/jsd
else
DIRS += sun-java nav-java $(DIRS_JS)
endif
ifndef NO_SECURITY
DIRS += security
endif
DIRS += perf
ifdef MOZ_PRIVACY
DIRS += privacy
endif
DIRS += modules lib l10n cmd
ifeq ($(STAND_ALONE_JAVA),1)
DIRS = config lib/xp $(NSPRDIR) jpeg modules/zlib sun-java ifc js ifc/tools sun-java/java
endif
include $(DEPTH)/config/rules.mk
export:: $(OBJS)
# Running this rule assembles all the SDK source pieces into dist/sdk.
# You'll need to run this rule on every platform to get all the
# binaries (e.g. javah) copied there. You'll also have to do special
# magic on a Mac.
sdk-src::
$(SDKINSTALL) include/npapi.h $(SDK)/include/
$(SDKINSTALL) include/jri_md.h $(SDK)/include/
$(SDKINSTALL) include/jritypes.h $(SDK)/include/
$(SDKINSTALL) include/jri.h $(SDK)/include/
$(SDKINSTALL) lib/plugin/npupp.h $(SDK)/include/
$(SDKINSTALL) sdk/common/*.c* $(SDK)/common/
$(SDKINSTALL) sun-java/classsrc/$(ZIP_NAME).x $(SDK)/classes/$(ZIP_NAME)
$(SDKINSTALL) sdk/examples/simple/Source/*.c $(SDK)/examples/simple/Source/
$(SDKINSTALL) sdk/examples/simple/Source/*.java $(SDK)/examples/simple/Source/
$(SDKINSTALL) sdk/examples/simple/Source/*.class $(SDK)/examples/simple/Source/
$(SDKINSTALL) sdk/examples/simple/Source/_gen/*.h $(SDK)/examples/simple/Source/_gen/
$(SDKINSTALL) sdk/examples/simple/Source/_stubs/*.c $(SDK)/examples/simple/Source/_stubs/
$(SDKINSTALL) sdk/examples/simple/Unix/makefile.* $(SDK)/examples/simple/Unix/
$(SDKINSTALL) sdk/examples/simple/Testing/SimpleExample.html $(SDK)/examples/simple/Testing/
$(SDKINSTALL) sdk/examples/simple/readme.html $(SDK)/examples/simple/
$(SDKINSTALL) sdk/examples/UnixTemplate/Source/*.c $(SDK)/examples/UnixTemplate/Source/
$(SDKINSTALL) sdk/examples/UnixTemplate/Testing/Test.html $(SDK)/examples/UnixTemplate/Testing/
$(SDKINSTALL) sdk/examples/UnixTemplate/Unix/makefile.* $(SDK)/examples/UnixTemplate/Unix/
$(SDKINSTALL) sdk/examples/UnixTemplate/readme.html $(SDK)/examples/UnixTemplate/
sdk-bin::
cd sdk; $(MAKE); cd ..
$(SDKINSTALL) $(DIST)/bin/javah$(BIN_SUFFIX) $(SDK)/bin/$(OS_CONFIG)/
$(SDKINSTALL) sdk/examples/simple/Source/$(OBJDIR)/npsimple.$(DLL_SUFFIX) $(SDK)/bin/$(OS_CONFIG)/
$(SDKINSTALL) sdk/examples/UnixTemplate/Source/$(OBJDIR)/nptemplate.$(DLL_SUFFIX) $(SDK)/bin/$(OS_CONFIG)/

268
mozilla/client.mak Normal file
View File

@@ -0,0 +1,268 @@
# 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.
# Enable builds on any drive if defined.
!if !defined(MOZ_SRC)
MOZ_SRC=y:
!endif
# Enable builds from user defined top level directory.
!if !defined(MOZ_TOP)
MOZ_TOP=mozilla
!endif
#//------------------------------------------------------------------------
#// Defines specific to MOZ_NGLAYOUT
#//------------------------------------------------------------------------
!if defined(MOZ_NGLAYOUT)
NGLAYOUT_MAKEFILE=nglayout.mak
NGLAYOUT_ENV_VARS=STANDALONE_IMAGE_LIB=1 MODULAR_NETLIB=1 NGLAYOUT_BUILD_PREFIX=1
MOZNGLAYOUT_BRANCH=RAPTOR_INTEGRATION0_BRANCH
CVSCO = cvs -q co -P
!endif
#//------------------------------------------------------------------------
#// Figure out how to do the pull.
#//------------------------------------------------------------------------
!if "$(MOZ_BRANCH)" != ""
CVS_BRANCH=-r $(MOZ_BRANCH)
HAVE_BRANCH=1
!else
HAVE_BRANCH=0
!endif
!if "$(MOZ_DATE)" != ""
CVS_BRANCH=-D "$(MOZ_DATE)"
HAVE_DATE=1
!else
HAVE_DATE=0
!endif
!if $(HAVE_DATE) && $(HAVE_BRANCH)
ERR_MESSAGE=$(ERR_MESSAGE)^
Cannot specify both MOZ_BRANCH and MOZ_DATE
!endif
NMAKE=@nmake -nologo -$(MAKEFLAGS)
#//------------------------------------------------------------------------
#//
#// Stuff a do complete pull and build
#//
#//------------------------------------------------------------------------
default:: build_all
pull_and_build_all:: pull_all \
build_all
#// Do this when you pull a new tree, or else you will often get bugs
#// when replaceing an old dist with a new dist.
pull_clobber_build_all:: pull_all \
clobber_all \
build_all
clobber_build_all:: clobber_all \
build_all
!if defined(MOZ_NGLAYOUT)
# The MOZ_NGLAYOUT pull is complicated, be very careful choosing which files are on
# the tip and which are on the branches.
pull_all:: pull_client_source_product pull_nglayout pull_netlib repull_ngl_integration pull_imglib repull_include
!else
pull_all:: pull_client_source_product
!endif
!if defined(MOZ_NGLAYOUT)
pull_nglayout:
@cd $(MOZ_SRC)
$(CVSCO) $(MOZ_TOP)/$(NGLAYOUT_MAKEFILE)
@cd $(MOZ_SRC)/$(MOZ_TOP)
$(NMAKE) -f $(NGLAYOUT_MAKEFILE) pull_nglayout $(NGLAYOUT_ENV_VARS)
pull_netlib:
@cd $(MOZ_SRC)/$(MOZ_TOP)
$(NMAKE) -f $(NGLAYOUT_MAKEFILE) pull_netlib $(NGLAYOUT_ENV_VARS)
# Here is where we pull everything on the layout integration branch
repull_ngl_integration:
@cd $(MOZ_SRC)
$(CVSCO) -r $(MOZNGLAYOUT_BRANCH) $(MOZ_TOP)/include $(MOZ_TOP)/cmd $(MOZ_TOP)/lib $(MOZ_TOP)/modules
@cd $(MOZ_SRC)/$(MOZ_TOP)
# Careful to put this after repull_ngl_integration, want modules/libutil and
# modules/libimg to be on imglib branch
pull_imglib:
@cd $(MOZ_SRC)/$(MOZ_TOP)
$(NMAKE) -f $(NGLAYOUT_MAKEFILE) pull_imglib $(NGLAYOUT_ENV_VARS)
# Want certain files in the include directory to be on the tip
repull_include:
@cd $(MOZ_SRC)
$(CVSCO) -A $(MOZ_TOP)/include/net.h
!endif
pull_client_source_product:
@echo +++ client.mak: checking out the client with "$(CVS_BRANCH)"
cd $(MOZ_SRC)\.
-cvs -q co $(CVS_BRANCH) MozillaSourceWin
!if defined(MOZ_NGLAYOUT)
# Build NGLayout first.
build_all: build_nglayout \
build_dist \
build_client
!else
build_all: build_dist \
build_client
!endif
!if defined(MOZ_NGLAYOUT)
build_nglayout:
cd $(MOZ_SRC)\$(MOZ_TOP)
$(NMAKE) -f $(NGLAYOUT_MAKEFILE) $(NGLAYOUT_ENV_VARS)
!endif
build_dist:
@echo +++ client.mak: building dist
cd $(MOZ_SRC)\$(MOZ_TOP)
$(NMAKE) -f makefile.win
build_client:
@echo +++ client.mak: building client
cd $(MOZ_SRC)\$(MOZ_TOP)\cmd\winfe\mkfiles32
!if "$(MOZ_BITS)" == "16"
$(NMAKE) -f mozilla.mak exports
!endif
$(NMAKE) -f mozilla.mak DEPEND=1
$(NMAKE) -f mozilla.mak
#
# remove all source files from the tree and print a report of what was missed
#
!if defined(MOZ_NGLAYOUT)
clobber_all:: clobber_moz clobber_nglayout
!else
clobber_all:: clobber_moz
!endif
clobber_moz:
cd $(MOZ_SRC)\$(MOZ_TOP)
$(NMAKE) -f makefile.win clobber_all
cd $(MOZ_SRC)\$(MOZ_TOP)\cmd\winfe\mkfiles32
$(NMAKE) -f mozilla.mak clobber_all
!if !defined(MOZ_MEDIUM)
cd $(MOZ_SRC)\$(MOZ_TOP)\netsite\ldap\libraries\msdos\winsock
$(NMAKE) -f nsldap.mak clobber_all
!endif
!if defined(MOZ_NGLAYOUT)
clobber_nglayout:
cd $(MOZ_SRC)\$(MOZ_TOP)
$(NMAKE) -f $(NGLAYOUT_MAKEFILE) clobber $(NGLAYOUT_ENV_VARS)
!endif
depend:
-del /s /q make.dep
$(NMAKE) -f makefile.win depend
#//------------------------------------------------------------------------
#// Utility stuff...
#//------------------------------------------------------------------------
#//------------------------------------------------------------------------
# Verify that MOZ_SRC is set correctly
#//------------------------------------------------------------------------
# Check to see if it is set at all
!if "$(MOZ_SRC)"!=""
#
# create a temp file at the root and make sure it is visible from MOZ_SRC
#
!if [copy $(MAKEDIR)\client.mak $(MAKEDIR)\xyzzy.tmp > NUL] == 0
!endif
!if !EXIST( $(MOZ_SRC)\$(MOZ_TOP)\xyzzy.tmp )
ERR_MESSAGE=$(ERR_MESSAGE)^
MOZ_SRC isn't set correctly: [$(MOZ_SRC)\$(MOZ_TOP)]!=[$(MAKEDIR)]
!endif
!if [del $(MAKEDIR)\xyzzy.tmp]
!endif
!else
# MOZ_SRC isn't set at all
ERR_MESSAGE=$(ERR_MESSAGE)^
Environment variable MOZ_SRC isn't set.
!endif
#//------------------------------------------------------------------------
# Verify that MOZ_BITS is set
#//------------------------------------------------------------------------
!if !defined(MOZ_BITS)
ERR_MESSAGE=$(ERR_MESSAGE)^
Environment variable MOZ_BITS isn't set.
!endif
!if !defined(MOZ_TOOLS)
ERR_MESSAGE=$(ERR_MESSAGE)^
Environment variable MOZ_TOOLS isn't set.
!endif
#//------------------------------------------------------------------------
#// Display error
#//------------------------------------------------------------------------
!if "$(ERR_MESSAGE)" != ""
ERR_MESSAGE = ^
client.mak: ^
$(ERR_MESSAGE) ^
^
client.mak: usage^
^
nmake -f client.mak [MOZ_BRANCH=<cvs_branch_name>] ^
[MOZ_DATE=<cvs_date>]^
[pull_and_build_all]^
[pull_all]^
[pull_dist]^
[pull_client]^
[build_all]^
[build_dist]^
[build_ldap]^
[build_client]^
^
Environment variables:^
^
MOZ_BITS set to either 32 or 16 ^
MOZ_SRC set to the directory above $(MOZ_TOP) or "$(MAKEDIR)\.."^
MOZ_TOOLS set to the directory containing the java compiler see ^
http://warp/tools/nt^
JAVA_HOME set to the same thing as MOZ_TOOLS^
CVSROOT set to the public mozilla cvs server^
!ERROR $(ERR_MESSAGE)
!endif

View File

@@ -0,0 +1,18 @@
#!gmake
#
# 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.
#

View File

@@ -0,0 +1,305 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// TestCaseManager.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
//#include "TestCaseManager.h"
#include "testcase.h"
#include "qa.h"
#include <stdlib.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// To be used by Par's code
CTestCase QA_TestCase;
IMPLEMENT_SERIAL(CTCData, CObject, 0)
IMPLEMENT_SERIAL(CTestCaseManager, CObject, 0)
CTCData::CTCData()
{
m_strName = "";
m_strDesc = "";
m_nID = 0;
}
void CTCData::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar << m_strName;
ar << m_strDesc;
ar << (WORD)m_nID;
}
else
{
ar >> m_strName;
ar >> m_strDesc;
ar >> (WORD&)m_nID;
}
}
CTestCaseManager::CTestCaseManager()
{
m_iNumTestCases = 0;
m_iNumTestCasesToRun = 0;
m_sDataFile = CString("");
m_sDataPath = CString("");
m_sLogFile = CString("");
}
CTestCaseManager::~CTestCaseManager()
{
DeleteData();
}
void CTestCaseManager::Serialize(CArchive& ar)
{
CTCData* pTestCase;
int nI;
CObject::Serialize(ar);
if ( ar.IsStoring() )
{
ar << (WORD)m_TCData.GetSize();
for (nI = 0;nI < m_TCData.GetSize();nI++)
{
pTestCase = (CTCData*)m_TCData[nI];
ar << pTestCase;
}
}
else
{
WORD wSize;
ar >> wSize;
m_TCData.SetSize(wSize);
for (nI = 0;nI < m_TCData.GetSize();nI++)
{
ar >> pTestCase;
m_TCData.SetAt(nI,pTestCase);
}
}
}
void CTestCaseManager::AddTestCase(CTCData* pTestCase)
{
CTCData *pTCData;
int nI;
// put it in its place (acsending sorted order)
for (nI = 0;nI < m_TCData.GetSize();nI++)
{
pTCData = (CTCData*)m_TCData[nI];
if (pTCData->m_strName.Compare(pTestCase->m_strName) > 0)
break;
}
m_TCData.InsertAt(nI,pTestCase);
}
void CTestCaseManager::InitRun()
{
CFile fFile;
m_iNumPassed = 0;
m_iNumFailed = 0;
m_sLogFile = (CString)(m_sDataPath + "results.all");
// Delete the .all file
if (FileExists(m_sLogFile))
fFile.Remove(m_sLogFile);
fFile.Open(m_sLogFile,CFile::modeCreate | CFile::shareDenyNone);
fFile.Close();
}
// appends [str] to the Log File
void CTestCaseManager::PrintToFile(CString& str)
{
CStdioFile fFile;
if (fFile.Open(m_sLogFile,CFile::modeWrite | CFile::shareDenyNone))
{ // write to Testcase Log File
fFile.Seek(0, CFile::end);
fFile.WriteString(str + "\n");
fFile.Flush();
fFile.Close();
}
}
void CTestCaseManager::RemoveTestCases(LPINT m_TestCasesToRemove, int nNum)
{
CTCData* pTCData;
for (int nI = nNum-1 ; nI >= 0 ; nI--)
{
pTCData = (CTCData*)m_TCData[m_TestCasesToRemove[nI]];
delete pTCData;
m_TCData.RemoveAt(m_TestCasesToRemove[nI]);
}
}
void CTestCaseManager::DeleteData()
{
CTCData* pTCData;
int nI;
for (nI = 0;nI < m_TCData.GetSize();nI++)
{
pTCData = (CTCData*)m_TCData[nI];
delete pTCData;
}
m_TCData.RemoveAll();
}
void CTestCaseManager::SaveData()
{
CFile file;
if ( m_sDataFile == "" )
{
CFileDialog dlg(FALSE, NULL, NULL, NULL, "Testcase Data Files (*.dat)|*.dat|All Files (*.*)|*.*||");
if ( dlg.DoModal() == IDOK )
{
m_sDataFile = dlg.GetPathName();
if ( !FileExists(m_sDataFile) )
return;
}
}
if ( file.Open(m_sDataFile,CFile::modeCreate | CFile::modeWrite | CFile::shareDenyNone) )
{
CArchive saveArchive(&file, CArchive::store | CArchive::bNoFlushOnDelete);
Serialize(saveArchive);
saveArchive.Close();
file.Close();
}
}
void CTestCaseManager::LoadData()
{
CFileDialog dlg(TRUE, NULL, NULL, NULL, "Testcase Data Files (*.dat)|*.dat|All Files (*.*)|*.*||");
CString sFile;
CFile file;
if ( dlg.DoModal() == IDOK )
{
m_sDataFile = dlg.GetPathName();
if ( !FileExists(m_sDataFile) )
return;
// Save the path
int iSlantPos = m_sDataFile.ReverseFind('\\');
m_sDataPath = m_sDataFile.Left(iSlantPos+1); // get the slant too!
if ( file.Open(m_sDataFile,CFile::modeRead | CFile::shareDenyNone) )
{
DeleteData(); // delete data first
CArchive loadArchive(&file,CArchive::load | CArchive::bNoFlushOnDelete);
Serialize(loadArchive);
loadArchive.Close();
file.Close();
}
}
}
void CTestCaseManager::ExecuteTestCases(LPINT m_TestCasesToRun)
{
int index;
CTCData* pTCData;
CTestCaseManager *tc;
tc = this;
InitRun();
while (*m_TestCasesToRun != -1)
{
index = *m_TestCasesToRun;
pTCData = (CTCData*)m_TCData[index];
m_strName = pTCData->m_strName;
// Examine the following very closely - not a cast but a constructor
QA_TestCase = (CTestCase)(this); // formerly tc
switch (pTCData->m_nID)
{
case TEST1 : WhiteBox_DeleteMessage1(this); // formerly tc
break;
case TEST2 : TrialTestCase2(tc);
break;
}
while (QATestCaseDone == FALSE) {
FEU_StayingAlive();
}
Wrapup();
m_TestCasesToRun++;
}
DeleteData();
}
void CTestCaseManager::Wrapup()
{
CFile fFile;
// create the runflag file to talk to QAP
fFile.Open(m_sDataPath + "runflag.txt",CFile::modeCreate | CFile::shareDenyNone);
fFile.Close();
QA_TestCase.WrapUp();
}
BOOL CTestCaseManager::FileExists(CString& strPath)
{
CFileStatus status;
BOOL bFileExists = TRUE;
if ( !CFile::GetStatus(strPath,status) ) // static member
bFileExists = FALSE;
return bFileExists;
}

View File

@@ -0,0 +1,75 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
class CTCData : public CObject
{
public:
CTCData();
DECLARE_SERIAL(CTCData);
virtual void Serialize(CArchive& ar);
// testcase Data
CString m_strName;
CString m_strDesc;
int m_nID;
};
class CTestCaseManager : public CObject
{
public:
CTestCaseManager();
~CTestCaseManager();
DECLARE_SERIAL(CTestCaseManager);
virtual void Serialize(CArchive& ar);
void ExecuteTestCases(LPINT m_TestCasesToRun);
void RemoveTestCases(LPINT m_TestCasesToRemove, int nNum);
void AddTestCase(CTCData *pTestCase);
void SaveData();
void LoadData();
void DeleteData();
void Wrapup();
void InitRun();
void PrintToFile(CString& str);
BOOL FileExists(CString& strPath);
CString m_sDataFile;
CString m_sDataPath;
CPtrArray m_TCData;
UINT m_iNumTestCasesToRun;
UINT m_iNumPassed;
UINT m_iNumFailed;
CString GetTestCaseName() { return m_strName; }
private:
UINT m_iNumTestCases;
CString m_strName;
CString m_sLogFile;
};

View File

@@ -0,0 +1,227 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// TestcaseDlg.cpp : implementation file
//
#include "stdafx.h"
#include "genframe.h"
#include "TestcaseDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWhiteBoxDlg dialog
CWhiteBoxDlg::CWhiteBoxDlg(CWnd* pParent /*=NULL*/)
: CDialog(CWhiteBoxDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CWhiteBoxDlg)
//}}AFX_DATA_INIT
}
CWhiteBoxDlg::~CWhiteBoxDlg()
{
}
void CWhiteBoxDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWhiteBoxDlg)
DDX_Control(pDX, IDC_LIST, m_list);
DDX_Control(pDX, IDC_DELETE, m_delete);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CWhiteBoxDlg, CDialog)
//{{AFX_MSG_MAP(CWhiteBoxDlg)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_BN_CLICKED(IDC_RUN, OnRun)
ON_BN_CLICKED(IDC_SAVE, OnSave)
ON_BN_CLICKED(IDC_IMPORT, OnImport)
ON_LBN_SELCHANGE(IDC_LIST, OnSelChangeList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWhiteBoxDlg message handlers
BOOL CWhiteBoxDlg::OnInitDialog()
{
CString text;
CDialog::OnInitDialog();
ListTestCases();
return TRUE; // return TRUE unless you set the focus to a control
}
void CWhiteBoxDlg::OnAdd()
{
CTCData* pTestCase = new CTCData;
CString str;
GetDlgItem(IDC_NAME)->GetWindowText(pTestCase->m_strName);
GetDlgItem(IDC_DESC)->GetWindowText(pTestCase->m_strDesc);
GetDlgItem(IDC_ID)->GetWindowText(str);
//convert!
pTestCase->m_nID = atoi((LPCSTR)str);
m_tcManager.AddTestCase(pTestCase);
ListTestCases();
// Reset the text boxes
GetDlgItem(IDC_NAME)->SetWindowText("");
GetDlgItem(IDC_DESC)->SetWindowText("");
GetDlgItem(IDC_ID)->SetWindowText("0");
//GetDlgItem(IDC_NAME)->SetFocus();
UpdateData(FALSE);
}
void CWhiteBoxDlg::OnDelete()
{
LPINT m_TestCasesToRemove;
int nWhich, nNumSelected;
nNumSelected = m_list.GetSelCount();
if (nNumSelected != 0)
{
m_TestCasesToRemove = (LPINT)calloc(sizeof(int),nNumSelected);
m_list.GetSelItems(nNumSelected,m_TestCasesToRemove);
// append -1 to the end
//m_TestCasesToRemove[nNumSelected] = -1;
m_tcManager.RemoveTestCases(m_TestCasesToRemove, nNumSelected);
free(m_TestCasesToRemove);
}
ListTestCases();
/* if ( (nWhich = m_list.GetCurSel()) != LB_ERR )
{
nTestCase = m_list.GetItemData(nWhich);
pTCData = (CTCData*)m_tcManager.m_TCData[nTestCase];
delete pTCData;
m_tcManager.RemoveTestCase(nTestCase);
}
*/
// Set cursor
if (nWhich+1 <= m_list.GetCount())
m_list.SetAnchorIndex(nWhich+1);
else
if (nWhich != 0)
m_list.SetAnchorIndex(nWhich);
else
m_delete.EnableWindow(FALSE);
}
void CWhiteBoxDlg::OnRun()
{
LPINT m_TestCasesToRun;
int nNumSelected = m_list.GetSelCount();
if (nNumSelected != 0)
{
m_TestCasesToRun = (LPINT)calloc(sizeof(int),nNumSelected + 1);
m_tcManager.m_iNumTestCasesToRun = m_list.GetSelItems(nNumSelected,m_TestCasesToRun);
// append -1 to the end
m_TestCasesToRun[m_tcManager.m_iNumTestCasesToRun] = -1;
CDialog::OnOK();
m_tcManager.ExecuteTestCases(m_TestCasesToRun);
free(m_TestCasesToRun);
}
}
void CWhiteBoxDlg::OnImport()
{
m_tcManager.LoadData();
ListTestCases();
}
void CWhiteBoxDlg::OnSelChangeList()
{
// enable the delete button now that an item has been selected
m_delete.EnableWindow(TRUE);
}
// Saves Data And Exits
void CWhiteBoxDlg::OnSave()
{
// TODO: Add extra validation here
m_tcManager.SaveData();
}
void CWhiteBoxDlg::ListTestCases()
{
CTCData* pTCData;
CString tmpstr, strTestCase;
int nI;
CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST);
pListBox->ResetContent();
for (nI = 0;nI < m_tcManager.m_TCData.GetSize();nI++)
{
pTCData = (CTCData*)m_tcManager.m_TCData[nI];
tmpstr.Format("%d",pTCData->m_nID);
strTestCase = pTCData->m_strName + "\t" + pTCData->m_strDesc + "\t" + tmpstr;
m_list.AddString(strTestCase);
//nWhich = pListBox->AddString(strTestCase);
//pListBox->SetItemData(nWhich,nI);
/*
bSelect = FALSE;
for (nJ = 0;nJ < m_pCourse->m_Students.GetSize();nJ++)
{
if ( m_pCourse->m_Students[nJ] == (DWORD)nI )
{
bSelect = TRUE;
break;
}
}
if ( bSelect )
pListBox->SetSel(nWhich,TRUE);
*/
}
}

View File

@@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// TabStopDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CWhiteBoxDlg dialog
#include "tclist.h"
#include "TestCaseManager.h"
class CWhiteBoxDlg : public CDialog
{
// Construction
public:
CWhiteBoxDlg(CWnd* pParent = NULL); // standard constructor
~CWhiteBoxDlg();
// Dialog Data
//{{AFX_DATA(CWhiteBoxDlg)
enum { IDD = IDD_QA_DIALOG };
CTCList m_list;
CButton m_delete;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWhiteBoxDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
CTestCaseManager m_tcManager;
void ListTestCases();
protected:
// Generated message map functions
//{{AFX_MSG(CWhiteBoxDlg)
virtual BOOL OnInitDialog();
afx_msg void OnAdd();
afx_msg void OnDelete();
afx_msg void OnRun();
afx_msg void OnSelChangeList();
afx_msg void OnSave();
afx_msg void OnImport();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

297
mozilla/cmd/winfe/abapi.h Normal file
View File

@@ -0,0 +1,297 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
//
// This is a header file for the Address Book API support within
// Communicator.
//
// Written by: Rich Pizzarro (rhp@netscape.com)
//
#ifndef __ABAPI
#define __ABAPI
#include "nabapi.h" // for all address book defines
// These are very important for compatibility going forward...
#define NAB_VERSION_MAJOR 1 /* Major version number; changes with major code release number */
#define NAB_VERSION_MINOR 0 /* Minor version number; changes with point release number. */
#ifdef WIN16
typedef unsigned char UCHAR;
#endif
#define MAX_NAME_LEN 256
#define MAX_ADDRBOOK_NAME_LEN 512
#define MAX_CON 4 // Maximum NABAPI sessions supported
#define MAX_POINTERS 32
#define MAX_LDIF_SIZE 16000 // Max size for address book LDIF allocation stuff
#define MAX_LDIFSEARCH_SIZE 4096 // Max size for address book LDIF allocation stuff
#ifndef NABAPIDLL
#include "abcom.h" // For MSG_ & AB_ stuff...
#include "msgcom.h"
//
// The Address Book class that will act as the internal mechanism for
// Communicator to control multiple Address Book sessions.
//
class CNABConnection
{
protected:
LONG m_ID;
BOOL m_defaultConnection;
LONG m_sessionCount;
LONG m_nameIndex;
LONG m_nameTotalCount;
// Methods
public:
MSG_Pane *m_ContainerPane; // Container Pane...
AB_ContainerInfo **m_ContainerArray; // The array of container info pointers...
LONG m_ContainerArrayCount; // The count of the number of
// m_ContainerArray entries
MSG_Pane *m_AddressBookPane; // Container info for a particular addr book
CNABConnection ( LONG );
~CNABConnection ( );
// ID related methods
LONG GetID( ) { return m_ID; } ;
// Dealing with the default session...
BOOL IsDefault( ) { return m_defaultConnection; } ;
void SetDefault( BOOL flag ) { m_defaultConnection = flag; } ;
// For handling multiple sessions on a profile name...
LONG GetSessionCount( ) { return m_sessionCount; } ;
void IncrementSessionCount() { ++m_sessionCount; } ;
void DecrementSessionCount() { --m_sessionCount; } ;
// For enumerating names...
void SetNameIndex( LONG mIndex ) { m_nameIndex = mIndex; } ;
void IncrementNameIndex( ) { ++m_nameIndex; } ;
LONG GetNameIndex( ) { return m_nameIndex; };
void SetNameTotalCount( LONG mTotal ) { m_nameTotalCount = mTotal; } ;
LONG GetNameTotalCount( ) { return m_nameTotalCount; };
// For AB Calls...
BOOL RefreshABContainerList ( void );
AB_ContainerInfo *FindContainerInfo( LPSTR, LPSTR );
};
#endif // NABAPIDLL
//
// Defines needed for requests being made with the WM_COPYDATA call...
//
typedef enum {
NSCP_NABStartRequestID = 200,
NSCP_NAB_Open,
NSCP_NAB_Close,
NSCP_NAB_GetAddressBookList,
NSCP_NAB_GetDefaultAddressBook,
NSCP_NAB_CreatePersonalAddressBook,
NSCP_NAB_FreeMemory,
NSCP_NAB_SaveAddressBookToHTML,
NSCP_NAB_ImportLDIFFile,
NSCP_NAB_ExportLDIFFile,
NSCP_NAB_GetFirstAddressBookEntry,
NSCP_NAB_GetNextAddressBookEntry,
NSCP_NAB_FindAddressBookEntry,
NSCP_NAB_InsertAddressBookEntry,
NSCP_NAB_UpdateAddressBookEntry,
NSCP_NAB_DeleteAddressBookEntry,
NSCP_NABEndRequestID // Note: this is a marker for NAB IPC requests
} NSCP_NAB_IPC_REQUEST;
//
// This is to keep track of the pointers allocated in the MAPI DLL
// and deal with them correctly.
//
#define NAB_FLAT_MEMORY 0
#define NAB_ADDRBOOK_STRUCT 1
typedef struct {
LPVOID lpMem;
char memType;
} nabMemTrackerType;
//
// This is the generic message that WM_COPYDATA will send to the
// Communicator product to allow it to attach to shared memory.
// NOTE: On Win16, this will simply reference a pointer.
//
typedef struct {
char smemName[64]; // Name of shared memory
DWORD smemSize; // Size of shared memory
LPVOID lpsmem; // Will be really used in Win16 only
} NABIPCType;
//
// These are message specific structures that will be used for
// the various Address Book operations.
//
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
UINT_16 majorVerNumber;
UINT_16 minorVerNumber;
} NAB_OpenType;
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
} NAB_CloseType;
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
UINT_32 abookCount;
char blobFileName[_MAX_PATH]; // file name N abooks on disk
} NAB_GetAddressBookListType;
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
BOOL defaultFound;
// NABAddrBookDescType flattened
char reserved[16]; // future use
char abookDesc[MAX_ADDRBOOK_NAME_LEN]; // description of address book
char abookFileName[_MAX_PATH]; // file name of abooks on disk
} NAB_GetDefaultAddressBookType;
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
// NABAddrBookDescType flattened
char reserved[16]; // future use
char abookName[MAX_ADDRBOOK_NAME_LEN]; // description of address book
char abookFileName[_MAX_PATH]; // file name of abooks on disk
} NAB_CreatePersonalAddressBookType;
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
// NABAddrBookDescType flattened
char reserved[16]; // future use
char abookName[MAX_ADDRBOOK_NAME_LEN]; // description of address book
char abookFileName[_MAX_PATH]; // file name of abooks on disk
// Return stuff
char HTMLFileName[_MAX_PATH]; // saved HTML file name
} NAB_SaveAddressBookToHTMLType;
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
BOOL deleteImportFile;
char LDIFFileName[_MAX_PATH]; // LDIF file to import
// NABAddrBookDescType flattened
char reserved[16]; // future use
char abookName[MAX_ADDRBOOK_NAME_LEN]; // description of address book
char abookFileName[_MAX_PATH]; // file name of abooks on disk
} NAB_ImportLDIFFileType;
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
char LDIFFileName[_MAX_PATH]; // LDIF file to export
// NABAddrBookDescType flattened
char reserved[16]; // future use
char abookName[MAX_ADDRBOOK_NAME_LEN]; // description of address book
char abookFileName[_MAX_PATH]; // file name of abooks on disk
} NAB_ExportLDIFFileType;
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
// NABAddrBookDescType flattened
char reserved[16]; // future use
char abookName[MAX_ADDRBOOK_NAME_LEN]; // description of address book
char abookFileName[_MAX_PATH]; // file name of abooks on disk
// Returned Values
NABUserID userID;
NABUpdateTime updateTime;
char userInfo[MAX_LDIF_SIZE];
} NAB_GetFirstAddressBookEntryType;
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
// NABAddrBookDescType flattened
char reserved[16]; // future use
// Returned Values
NABUserID userID;
NABUpdateTime updateTime;
char userInfo[MAX_LDIF_SIZE];
} NAB_GetNextAddressBookEntryType;
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
// NABAddrBookDescType flattened
char reserved[16]; // future use
char abookName[MAX_ADDRBOOK_NAME_LEN]; // description of address book
char abookFileName[_MAX_PATH]; // file name of abooks on disk
// Input Values
char ldifSearchAttribute[MAX_LDIFSEARCH_SIZE];
// Output values
NABUserID userID;
NABUpdateTime updateTime;
char userInfo[MAX_LDIF_SIZE];
} NAB_FindAddressBookEntryType;
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
// NABAddrBookDescType flattened
char reserved[16]; // future use
char abookName[MAX_ADDRBOOK_NAME_LEN]; // description of address book
char abookFileName[_MAX_PATH]; // file name of abooks on disk
// Insert Value
char userInfo[MAX_LDIF_SIZE];
// Update Value
NABUserID userID;
} NAB_InsertAddressBookEntryType;
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
// NABAddrBookDescType flattened
char reserved[16]; // future use
char abookName[MAX_ADDRBOOK_NAME_LEN]; // description of address book
char abookFileName[_MAX_PATH]; // file name of abooks on disk
// Update Value
NABUserID userID;
char userInfo[MAX_LDIF_SIZE];
} NAB_UpdateAddressBookEntryType;
typedef struct {
DWORD ipcWorked; // Necessary for IPC check with Communicator
NABConnectionID abConnection;
// NABAddrBookDescType flattened
char reserved[16]; // future use
char abookName[MAX_ADDRBOOK_NAME_LEN]; // description of address book
char abookFileName[_MAX_PATH]; // file name of abooks on disk
// Delete user Value
NABUserID userID;
} NAB_DeleteAddressBookEntryType;
#endif // __ABAPI

1874
mozilla/cmd/winfe/abhook.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 _NAB_HOOK_H_
#define _NAB_HOOK_H_
//#include <structs.h> // for MWContext
//
// This is the entry point to the MAPI session manager that lives
// inside of Communicator.
//
LONG ProcessNetscapeNABHook(WPARAM wParam, LPARAM lParam);
#endif // _NAB_HOOK_H_

2220
mozilla/cmd/winfe/abmldlg.cpp Executable file

File diff suppressed because it is too large Load Diff

336
mozilla/cmd/winfe/abmldlg.h Executable file
View File

@@ -0,0 +1,336 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 "addrfrm.h"
#ifdef MOZ_NEWADDR
#ifndef _abmldlg_h_
#define _abmldlg_h_
// ABMLDLG.H
//
// DESCRIPTION:
// This file contains the declarations of the for the mailing list
// dialog
//
#include "apimsg.h"
#include "xp_core.h"
#include "addrbook.h"
#include "property.h"
#include "apiaddr.h"
#include "mnrccln.h"
#include "statbar.h"
class CNSAddressList;
class CABMLDialog;
class CABMLDialogEntryList;
class CMailListDropTarget : public COleDropTarget
{
public:
CABMLDialog* m_pOwner;
//Construction
CMailListDropTarget(CABMLDialog* pOwner) { m_pOwner = pOwner; }
BOOL OnDrop(CWnd *, COleDataObject *, DROPEFFECT, CPoint);
DROPEFFECT OnDragOver(CWnd *, COleDataObject *, DWORD, CPoint);
};
/****************************************************************************
*
* Class: CABMLDialog
*
* DESCRIPTION:
* This class is the address picker from the compose window
*
****************************************************************************/
class CABMLDialog : public CDialog,
public IAddressParent {
// Attributes
public:
friend class CABMLDialogEntryList;
// Dialog Data
//{{AFX_DATA(CABMLDialog)
enum { IDD = IDD_ADDRESS_LIST };
CString m_description;
CString m_name;
CString m_nickname;
//}}AFX_DATA
protected:
CNetscapeStatusBar m_barStatus;
LPADDRESSCONTROL m_pIAddressList;
LPUNKNOWN m_pUnkAddress;
int m_iMysticPlane;
HFONT m_pFont;
LPMSGLIST m_pIAddrList;
MLPane *m_addrBookPane;
DIR_Server *m_dir;
ABID m_entryID;
BOOL m_addingEntries;
BOOL m_saved;
int m_errorCode;
BOOL m_changingEntry;
BOOL m_addingEntry;
BOOL m_deletingEntry;
MSG_Pane *m_pPane;
CMailListDropTarget *m_pDropTarget;
// Support loading resources from dll
CMailNewsResourceSwitcher m_MailNewsResourceSwitcher;
// Support for IMsgList Interface (Called by CABMLDialogEntryList)
virtual void ListChangeStarting( MSG_Pane* pane, XP_Bool asynchronous,
MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
int32 num);
virtual void ListChangeFinished( MSG_Pane* pane, XP_Bool asynchronous,
MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
int32 num);
void CleanupOnClose();
void AddEntriesToList(int index, int num);
// IAddressParent stuff
virtual void AddedItem (HWND hwnd, LONG id,int index);
virtual int ChangedItem (char * pString, int index, HWND hwnd, char** ppFullName, unsigned long* entryID, UINT* bitmapID);
virtual void DeletedItem (HWND hwnd, LONG id,int index);
void PrintItems(LPSTR comment);
virtual char * NameCompletion (char *);
virtual void StartNameCompletionSearch();
virtual void StopNameCompletionSearch();
virtual void SetProgressBarPercent(int32 lPercent);
virtual void SetStatusText(const char* pMessage );
virtual CWnd *GetOwnerWindow();
// Operations
public:
CABMLDialog(CWnd* pParent = NULL, MSG_Pane *pane = NULL, MWContext* context = NULL);
~CABMLDialog();
BOOL Create( LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL );
BOOL Create( UINT nIDTemplate, CWnd* pParentWnd = NULL );
BOOL Create( CWnd *pParent );
enum { ToolInvalid = -1, ToolText = 0, ToolPictures = 1, ToolBoth = 2 };
static void HandleErrorReturn(int errorID, CWnd* parent = NULL);
MLPane* GetPane() { return m_addrBookPane; }
ABID GetEntryID() { return m_entryID; }
CNSAddressList * GetAddressWidget();
void DoUpdateAddressBook( CCmdUI* pCmdUI, AB_CommandType cmd, BOOL bUseCheck = TRUE );
// Drop
BOOL IsDragInListBox(CPoint *pPoint);
BOOL ProcessVCardData(COleDataObject * pDataObject,CPoint &point);
BOOL ProcessAddressBookIndexFormat(COleDataObject *pDataObject, DROPEFFECT effect);
DROPEFFECT GetAddressBookIndexFormatDropEffect(COleDataObject *pDataObject);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CABMLDialog)
public:
virtual BOOL OnInitDialog( );
BOOL PreTranslateMessage( MSG* pMsg );
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void PostNcDestroy( );
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CABMLDialog)
afx_msg int OnCreate( LPCREATESTRUCT );
afx_msg void OnDestroy( );
afx_msg void OnOK();
afx_msg void OnCancel();
afx_msg void OnRemoveEntry();
afx_msg void OnHelp();
afx_msg void OnUpdateOnlineStatus(CCmdUI *pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif
#else // MOZ_NEWADDR
#ifndef _abmldlg_h_
#define _abmldlg_h_
// ABMLDLG.H
//
// DESCRIPTION:
// This file contains the declarations of the for the mailing list
// dialog
//
#include "apimsg.h"
#include "xp_core.h"
#include "addrbook.h"
#include "property.h"
#include "apiaddr.h"
#include "mnrccln.h"
class CNSAddressList;
class CABMLDialog;
class CABMLDialogEntryList;
class CMailListDropTarget : public COleDropTarget
{
public:
CABMLDialog* m_pOwner;
//Construction
CMailListDropTarget(CABMLDialog* pOwner) { m_pOwner = pOwner; }
BOOL OnDrop(CWnd *, COleDataObject *, DROPEFFECT, CPoint);
DROPEFFECT OnDragOver(CWnd *, COleDataObject *, DWORD, CPoint);
};
/****************************************************************************
*
* Class: CABMLDialog
*
* DESCRIPTION:
* This class is the address picker from the compose window
*
****************************************************************************/
class CABMLDialog : public CDialog,
public IAddressParent {
// Attributes
public:
friend class CABMLDialogEntryList;
// Dialog Data
//{{AFX_DATA(CABMLDialog)
enum { IDD = IDD_ADDRESS_LIST };
CString m_description;
CString m_name;
CString m_nickname;
//}}AFX_DATA
protected:
LPADDRESSCONTROL m_pIAddressList;
LPUNKNOWN m_pUnkAddress;
int m_iMysticPlane;
HFONT m_pFont;
LPMSGLIST m_pIAddrList;
MLPane *m_addrBookPane;
DIR_Server *m_dir;
ABID m_entryID;
BOOL m_addingEntries;
BOOL m_saved;
int m_errorCode;
BOOL m_changingEntry;
CMailListDropTarget *m_pDropTarget;
// Support loading resources from dll
CMailNewsResourceSwitcher m_MailNewsResourceSwitcher;
// Support for IMsgList Interface (Called by CABMLDialogEntryList)
virtual void ListChangeStarting( MSG_Pane* pane, XP_Bool asynchronous,
MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
int32 num);
virtual void ListChangeFinished( MSG_Pane* pane, XP_Bool asynchronous,
MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
int32 num);
void CleanupOnClose();
void AddEntriesToList(int index, int num);
// IAddressParent stuff
virtual void AddedItem (HWND hwnd, LONG id,int index);
virtual int ChangedItem (char * pString, int index, HWND hwnd, char** ppFullName, unsigned long* entryID, UINT* bitmapID);
virtual void DeletedItem (HWND hwnd, LONG id,int index);
virtual char * NameCompletion (char *);
virtual void StartNameCompletionSearch(){;}
virtual void StopNameCompletionSearch(){;}
virtual void SetProgressBarPercent(int32 lPercent){;}
virtual void SetStatusText(const char* pMessage ){;}
virtual CWnd *GetOwnerWindow(){return NULL;}
// Operations
public:
CABMLDialog(DIR_Server* dir, CWnd* pParent = NULL, ABID listID = NULL, MWContext* context = NULL);
~CABMLDialog();
BOOL Create( LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL );
BOOL Create( UINT nIDTemplate, CWnd* pParentWnd = NULL );
BOOL Create( CWnd *pParent );
enum { ToolInvalid = -1, ToolText = 0, ToolPictures = 1, ToolBoth = 2 };
static void HandleErrorReturn(int errorID, CWnd* parent = NULL);
MLPane* GetPane() { return m_addrBookPane; }
ABID GetEntryID() { return m_entryID; }
CNSAddressList * GetAddressWidget();
void DoUpdateAddressBook( CCmdUI* pCmdUI, AB_CommandType cmd, BOOL bUseCheck = TRUE );
// Drop
BOOL IsDragInListBox(CPoint *pPoint);
BOOL ProcessVCardData(COleDataObject * pDataObject,CPoint &point);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CABMLDialog)
public:
virtual BOOL OnInitDialog( );
BOOL PreTranslateMessage( MSG* pMsg );
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void PostNcDestroy( );
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CABMLDialog)
afx_msg int OnCreate( LPCREATESTRUCT );
afx_msg void OnDestroy( );
afx_msg void OnOK();
afx_msg void OnCancel();
afx_msg void OnRemoveEntry();
afx_msg void OnHelp();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif
#endif // MOZ_NEWADDR

View File

@@ -0,0 +1,700 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
//
// Address Book API Utility Functions
// Written by: Rich Pizzarro (rhp@netscape.com)
// March 1998
#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "wfemsg.h" // for WFE_MSGGetMaster()
#include "nsstrseq.h"
#include "abapi.h"
#include "abhook.h"
#include "nabapi.h"
#include "mapismem.h"
#include "hiddenfr.h"
#include "msgcom.h"
#include "abutils.h"
#include "abcom.h"
extern CNetscapeApp theApp;
typedef struct {
BOOL foundInSearch;
int attribType;
AB_AttribID attribID;
char *ldifName;
} attribPairsType;
// I18N: Please don't touch these strings!
#define ATTRIB_COUNT 19
attribPairsType attribArray[] = {
// FALSE, dn: cn=first last,mail=email
FALSE, CHAR_VALUE, AB_attribDisplayName, /*AB_attribFullName,*/ "cn: ",
FALSE, CHAR_VALUE, AB_attribFamilyName, "sn: ",
FALSE, CHAR_VALUE, AB_attribGivenName, "givenname: ",
// FALSE, CHAR_VALUE, "top", "objectclass: ",
// FALSE, CHAR_VALUE, "person", "objectclass: ",
FALSE, CHAR_VALUE, AB_attribInfo, "description: ",
FALSE, CHAR_VALUE, AB_attribLocality, "locality: ",
FALSE, CHAR_VALUE, AB_attribRegion, "st: ",
FALSE, CHAR_VALUE, AB_attribEmailAddress, "mail: ",
FALSE, CHAR_VALUE, AB_attribTitle, "title: ",
FALSE, CHAR_VALUE, AB_attribPOAddress, "postOfficeBox: ",
FALSE, CHAR_VALUE, AB_attribStreetAddress, "streetaddress: ",
FALSE, CHAR_VALUE, AB_attribZipCode, "postalcode: ",
FALSE, CHAR_VALUE, AB_attribCountry, "countryname: ",
FALSE, CHAR_VALUE, AB_attribWorkPhone, "telephonenumber: ",
FALSE, CHAR_VALUE, AB_attribFaxPhone, "facsimiletelephonenumber: ",
FALSE, CHAR_VALUE, AB_attribHomePhone, "homephone: ",
FALSE, CHAR_VALUE, AB_attribCompanyName, "o: ",
FALSE, CHAR_VALUE, AB_attribNickName, "xmozillanickname: ",
FALSE, BOOL_VALUE, AB_attribHTMLMail, "xmozillausehtmlmail: ",
FALSE, INT_VALUE, AB_attribUseServer, "xmozillauseconferenceserver: "};
BOOL
TackOnAttributeValuePair(MSG_Pane *abPane, LONG userIndex,
LPSTR outString, AB_AttribID attribID, LPSTR stringKey,
DWORD typeOfValue, LPSTR concatString)
{
int result;
AB_AttributeValue *value;
if (!outString)
return FALSE;
result = AB_GetEntryAttributeForPane(abPane, userIndex, attribID, &value);
if (result != 0)
return FALSE;
if (typeOfValue == CHAR_VALUE)
{
// Do the key name first...
if ( (value->u.string != NULL) && (value->u.string[0] != '\0') )
{
lstrcat(outString, stringKey);
lstrcat(outString, (char *)value->u.string);
if (concatString)
lstrcat(outString, concatString);
}
}
else if (typeOfValue == BOOL_VALUE)
{
// Do the key name first...
lstrcat(outString, stringKey);
if (value->u.boolValue)
lstrcat(outString, "TRUE");
else
lstrcat(outString, "FALSE");
if (concatString)
lstrcat(outString, concatString);
}
else if (typeOfValue == INT_VALUE)
{
char tval[16];
// Do the key name first...
lstrcat(outString, stringKey);
wsprintf(tval, "%d", value->u.shortValue);
lstrcat(outString, tval);
if (concatString)
lstrcat(outString, concatString);
}
AB_FreeEntryAttributeValue(value);
return(TRUE);
}
BOOL
GetLDIFLineForUser(MSG_Pane *abPane, LONG userIndex, LPSTR outString,
NABUserID *userID, NABUpdateTime *updtTime)
{
ABID id;
int i;
BOOL rc;
if (!outString)
return FALSE;
outString[0] = '\0';
lstrcpy(outString, "dn: ");
rc = TackOnAttributeValuePair(abPane, userIndex, outString, AB_attribFullName,
"cn: ", CHAR_VALUE, ",");
if (!rc)
return FALSE;
rc = TackOnAttributeValuePair(abPane, userIndex, outString, AB_attribEmailAddress, "mail: ",
CHAR_VALUE, NAB_CRLF);
if (!rc)
return FALSE;
for (i=0; i<ATTRIB_COUNT; i++)
{
(void) TackOnAttributeValuePair(abPane, userIndex, outString,
attribArray[i].attribID,
attribArray[i].ldifName,
attribArray[i].attribType, NAB_CRLF);
}
// Get the ABID...
int result = AB_GetABIDForIndex(abPane, userIndex, &id);
if (result != 0)
return FALSE;
*userID = id;
*updtTime = 0;
return TRUE;
}
static HFILE hHTMLFile = NULL;
BOOL
OpenNABAPIHTMLFile(LPSTR fName, LPSTR title)
{
hHTMLFile = _lcreat(fName, 0);
if (hHTMLFile == HFILE_ERROR)
return FALSE;
if ( _lwrite(hHTMLFile, HTML_HEAD1, lstrlen(HTML_HEAD1)) == HFILE_ERROR)
{
_lclose(hHTMLFile);
return FALSE;
}
if ( _lwrite(hHTMLFile, title, lstrlen(title)) == HFILE_ERROR)
{
_lclose(hHTMLFile);
return FALSE;
}
if ( _lwrite(hHTMLFile, HMTL_HEAD2, lstrlen(HMTL_HEAD2)) == HFILE_ERROR)
{
_lclose(hHTMLFile);
return FALSE;
}
return TRUE;
}
BOOL
CloseNABAPIHTMLFile(void)
{
if ( _lwrite(hHTMLFile, HTML_TAIL, lstrlen(HTML_TAIL)) == HFILE_ERROR)
{
_lclose(hHTMLFile);
return FALSE;
}
_lclose(hHTMLFile);
hHTMLFile = NULL;
return TRUE;
}
#define HTMLSTART 1
#define HTMLEND 2
#define HTMLBREAK 3
#define HTMLSPACE 4
#define HTMLCOMMA 5
#define HTMLNEWROW 6
#define HTMLENDROW 7
BOOL
DumpHTMLForTable(BOOL hType)
{
LPSTR cstart = "<TD>";
LPSTR cend = "</TD>\n";
LPSTR cbreak = "<BR>";
LPSTR cspace = " ";
LPSTR ccomma = ", ";
LPSTR cnewrow = "<TR>\n";
LPSTR cendrow = "</TR>\n";
LPSTR ptr;
if (hType == HTMLSTART)
ptr = cstart;
else if (hType == HTMLEND)
ptr = cend;
else if (hType == HTMLSPACE)
ptr = cspace;
else if (hType == HTMLCOMMA)
ptr = ccomma;
else if (hType == HTMLNEWROW)
ptr = cnewrow;
else if (hType == HTMLENDROW)
ptr = cendrow;
else
ptr = cbreak;
if ( _lwrite(hHTMLFile, ptr, lstrlen(ptr)) == HFILE_ERROR)
return FALSE;
else
return TRUE;
}
BOOL
DumpHTMLValue(MSG_Pane *abPane, LONG userIndex, AB_AttribID attribID)
{
int result;
AB_AttributeValue *value;
result = AB_GetEntryAttributeForPane(abPane, userIndex, attribID, &value);
if (result != 0)
return FALSE;
if ( (value->u.string != NULL) && (value->u.string[0] != '\0') )
{
if ( _lwrite(hHTMLFile, value->u.string, lstrlen(value->u.string)) == HFILE_ERROR)
return FALSE;
else
return TRUE;
}
else
return FALSE;
}
BOOL
DumpHTMLTableLineForUser(MSG_Pane *abPane, LONG userIndex)
{
DumpHTMLForTable(HTMLNEWROW);
DumpHTMLForTable(HTMLSTART);
DumpHTMLValue(abPane, userIndex, AB_attribFamilyName);
DumpHTMLForTable(HTMLEND);
DumpHTMLForTable(HTMLSTART);
DumpHTMLValue(abPane, userIndex, AB_attribGivenName);
DumpHTMLForTable(HTMLEND);
DumpHTMLForTable(HTMLSTART);
DumpHTMLValue(abPane, userIndex, AB_attribEmailAddress);
DumpHTMLForTable(HTMLEND);
DumpHTMLForTable(HTMLSTART);
if (DumpHTMLValue(abPane, userIndex, AB_attribCompanyName))
DumpHTMLForTable(HTMLBREAK);
DumpHTMLValue(abPane, userIndex, AB_attribTitle);
DumpHTMLForTable(HTMLEND);
DumpHTMLForTable(HTMLSTART);
DumpHTMLValue(abPane, userIndex, AB_attribWorkPhone);
DumpHTMLForTable(HTMLEND);
DumpHTMLForTable(HTMLSTART);
DumpHTMLValue(abPane, userIndex, AB_attribFaxPhone);
DumpHTMLForTable(HTMLEND);
DumpHTMLForTable(HTMLSTART);
DumpHTMLValue(abPane, userIndex, AB_attribHomePhone);
DumpHTMLForTable(HTMLEND);
DumpHTMLForTable(HTMLSTART);
if (DumpHTMLValue(abPane, userIndex, AB_attribPOAddress))
DumpHTMLForTable(HTMLBREAK);
if (DumpHTMLValue(abPane, userIndex, AB_attribStreetAddress))
DumpHTMLForTable(HTMLBREAK);
if (DumpHTMLValue(abPane, userIndex, AB_attribLocality))
DumpHTMLForTable(HTMLCOMMA);
DumpHTMLValue(abPane, userIndex, AB_attribRegion);
if (DumpHTMLValue(abPane, userIndex, AB_attribZipCode))
DumpHTMLForTable(HTMLBREAK);
DumpHTMLValue(abPane, userIndex, AB_attribCountry);
DumpHTMLForTable(HTMLEND);
DumpHTMLForTable(HTMLENDROW);
return TRUE;
}
BOOL
FindAttributeInLine(LPSTR attribName, LPSTR addLine)
{
DWORD totlen, complen, i;
if ( (!attribName) || !(*attribName) )
return FALSE;
if ( (!addLine) || !(*addLine) )
return FALSE;
i = 0;
totlen = strlen(addLine);
complen = strlen(attribName);
while ( (i + complen) <= totlen )
{
if (strncmp( attribName, addLine+i, complen ) == 0)
{
return TRUE;
}
i++;
}
return FALSE;
}
LPSTR
ExtractAttribValue(LPSTR attribName, LPSTR searchLine)
{
DWORD totlen, complen, i;
if ( (!attribName) || !(*searchLine) )
return NULL;
if ( (!searchLine) || !(*searchLine) )
return NULL;
i = 0;
totlen = strlen(searchLine);
complen = strlen(attribName);
while ( (i + complen) <= totlen )
{
if (strncmp( attribName, searchLine+i, complen ) == 0)
{
if (i+complen == totlen) // Check if we are at the end...
return NULL;
LPSTR newPtr;
LPSTR startPtr;
LPSTR endPtr;
DWORD totalSize;
// Have to add this hack for the fact we have an attribute that
// is a subset of another (i.e. "mail: " and "xmozillausehtmlmail: ")
if (
(strcmp(attribName, "mail: ") == 0) && (i > 0) &&
(*(searchLine+i-1) == 'l' )
)
{
i++;
continue;
}
// end of hack
startPtr = searchLine + (i + complen);
endPtr = startPtr;
while ( ((*endPtr) != '\0') && ((*endPtr) != '\r') )
{
endPtr = (endPtr + 1);
}
totalSize = (endPtr - startPtr) + 1;
newPtr = (LPSTR) malloc(totalSize);
if (!newPtr)
return NULL;
memset(newPtr, 0, totalSize);
strncpy(newPtr, startPtr, (totalSize - 1));
return newPtr;
}
i++;
}
return NULL;
}
BOOL
ThisIsAStringAttrib(AB_AttribID attrib)
{
int i;
for (i=0; i<ATTRIB_COUNT; i++)
{
if (attribArray[i].attribID == attrib)
{
if (attribArray[i].attribType == CHAR_VALUE)
return TRUE;
else
return FALSE;
}
}
return FALSE;
}
// Inserting Address Book Entires...
NABError
InsertEntryToAB(AB_ContainerInfo *abContainer, LPSTR newLine,
BOOL updateOnly, ABID *updateID)
{
ULONG i;
DWORD numItems = 0;
ABID tempEntryID;
AB_AttributeValue *values;
BOOL found;
USHORT currentAttribLoc;
// Build the entries to add for the address book...
for (i=0; i<ATTRIB_COUNT; i++)
{
attribArray[i].foundInSearch = FindAttributeInLine(attribArray[i].ldifName, newLine);
if (found)
numItems++;
}
if (numItems == 0)
return(NAB_FAILURE);
++numItems; // add one for the type...
// Now that we have this information, malloc the memory needed and
// move on...
values = (AB_AttributeValue *) malloc(sizeof(AB_AttributeValue) * numItems);
if (!values)
return(NAB_MEMORY_FAILURE);
memset(values, 0, (sizeof(AB_AttributeValue) * numItems));
// First should be the type of entry...
values[0].attrib = AB_attribEntryType;
values[0].u.entryType = AB_Person;
LPSTR ptr;
currentAttribLoc = 1;
for (i=0; i<ATTRIB_COUNT; i++)
{
if (attribArray[i].foundInSearch)
{
if ( (ptr = ExtractAttribValue(attribArray[i].ldifName, newLine)) == NULL)
continue;
// Here?...then we found it!
values[currentAttribLoc].attrib = attribArray[i].attribID;
if (attribArray[i].attribType == CHAR_VALUE)
{
values[currentAttribLoc].u.string = ptr;
}
else if (attribArray[i].attribType == BOOL_VALUE)
{
if (strcmp(ptr, "TRUE") == 0)
values[currentAttribLoc].u.boolValue = TRUE;
else
values[currentAttribLoc].u.boolValue = FALSE;
free(ptr);
}
else if (attribArray[i].attribType == INT_VALUE)
{
values[currentAttribLoc].u.shortValue = atoi(ptr);
free(ptr);
}
currentAttribLoc++;
}
}
int result;
if (updateOnly)
{
result = AB_SetEntryAttributes(abContainer, *updateID, values, currentAttribLoc);
}
else
{
result = AB_AddUserAB2(abContainer, values, currentAttribLoc, &tempEntryID);
*updateID = tempEntryID;
}
// Now free all allocated memory...
for (i=1; i<currentAttribLoc; i++) // start from 1 - 0 is AB_attribEntryType
{
if (ThisIsAStringAttrib(values[i].attrib))
{
if (values[i].u.string != NULL)
free(values[i].u.string);
}
}
free(values);
if (result)
return NAB_FAILURE;
else
return NAB_SUCCESS;
}
BOOL
GetIDSearchField(LPSTR ldifInfo, DWORD *id, LPSTR *searchValue)
{
LPSTR ptr;
DWORD i;
for (i=0; i<ATTRIB_COUNT; i++)
{
if (attribArray[i].attribType != CHAR_VALUE)
continue;
ptr = ExtractAttribValue(attribArray[i].ldifName, ldifInfo);
if (ptr != NULL)
{
*id = attribArray[i].attribID;
break;
}
}
if (!ptr)
return FALSE;
else
{
*searchValue = ptr;
return TRUE;
}
}
BOOL
FindValueForIDInLine(MSG_Pane *addressBookPane, LONG userIndex,
AB_AttribID id, LPSTR searchValue)
{
int result;
AB_AttributeValue *value;
BOOL found = FALSE;
if ((!searchValue) || (!*searchValue))
return FALSE;
result = AB_GetEntryAttributeForPane(addressBookPane, userIndex, id, &value);
if (result != 0)
return FALSE;
// Do the key name first...
if ( (value->u.string != NULL) && (value->u.string[0] != '\0') )
{
if ( strlen(value->u.string) >= strlen(searchValue) )
{
if (_strnicmp(value->u.string, searchValue, strlen(searchValue)) == 0)
{
found = TRUE;
}
}
}
AB_FreeEntryAttributeValue(value);
return(found);
}
BOOL
SearchABForAttrib(AB_ContainerInfo *abContainer,
LPSTR searchAttrib,
LPSTR ldifInfo,
NABUserID *userID,
NABUpdateTime *updtTime)
{
int result;
MSG_Pane *addressBookPane; // Container info for a particular addr book
result = AB_CreateABPane(&addressBookPane, theApp.m_pAddressContext, WFE_MSGGetMaster());
if (result)
{
return FALSE;
}
result = AB_InitializeABPane(addressBookPane, abContainer);
if (result)
{
AB_ClosePane(addressBookPane);
return(FALSE);
}
DWORD id;
int currentLocation = 0;
LONG lineCount = MSG_GetNumLines(addressBookPane);
LPSTR searchValue = NULL;
BOOL found = FALSE;
//
// Support lookups by ABID's...
if ((searchAttrib == NULL) || (searchAttrib[0] == '\0'))
{
while ( currentLocation < lineCount )
{
ABID id;
// Get the ABID...
int result = AB_GetABIDForIndex(addressBookPane, currentLocation, &id);
if (result != 0)
{
++currentLocation;
continue;
}
if (id == *userID)
{
found = TRUE;
if (!GetLDIFLineForUser(addressBookPane, currentLocation, ldifInfo, userID, updtTime))
{
found = FALSE;
currentLocation++;
continue;
}
break;
}
// Increment for next call...
currentLocation++;
}
AB_ClosePane(addressBookPane);
return found;
}
// Support lookups by ABID's...
//
if (!GetIDSearchField(searchAttrib, &id, &searchValue))
{
AB_ClosePane(addressBookPane);
return(FALSE);
}
while ( currentLocation < lineCount )
{
found = FindValueForIDInLine(addressBookPane, currentLocation,
(AB_AttribID)id, searchValue);
if (found)
{
if (!GetLDIFLineForUser(addressBookPane, currentLocation, ldifInfo, userID, updtTime))
{
found = FALSE;
currentLocation++;
continue;
}
break;
}
// Increment for next call...
currentLocation++;
}
if (searchValue != NULL)
free(searchValue);
AB_ClosePane(addressBookPane);
return found;
}

View File

@@ -0,0 +1,85 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 _NAB_UTILS_H_
#define _NAB_UTILS_H_
#define CHAR_VALUE 0
#define BOOL_VALUE 1
#define INT_VALUE 2
BOOL GetLDIFLineForUser(MSG_Pane *abPane, LONG userIndex,
LPSTR outString, NABUserID *userID,
NABUpdateTime *updtTime);
// For creating HTML output file...
BOOL OpenNABAPIHTMLFile(LPSTR fName, LPSTR title);
BOOL CloseNABAPIHTMLFile(void);
BOOL DumpHTMLTableLineForUser(MSG_Pane *abPane, LONG userIndex);
BOOL SearchABForAttrib(AB_ContainerInfo *abContainer,
LPSTR searchAttrib,
LPSTR ldifInfo,
NABUserID *userID,
NABUpdateTime *updtTime);
// For insert entries...
NABError InsertEntryToAB(AB_ContainerInfo *abContainer, LPSTR newLine,
BOOL updateOnly, ABID *updateID);
#define HTML_HEAD1 \
"<HTML>\n\
<HEAD>\n\
<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n\
<TITLE>"
#define HMTL_HEAD2 \
"</TITLE>\n\
</HEAD>\n\
&nbsp;\n\
<TABLE BORDER >\n"
#define HTML_TAIL "\
</TABLE>\n\
&nbsp;\n\
</BODY>\n\
</HTML>\n"
#endif // _NAB_UTILS_H_
/*
stuff...
<TD>AB_attribFamilyName</TD>
<TD>AB_attribGivenName</TD>
<TD>AB_attribEmailAddress</TD>
<TD>AB_attribCompanyName
<BR>AB_attribTitle</TD>
<TD>AB_attribWorkPhone</TD>
<TD>AB_attribFaxPhone</TD>
<TD>AB_attribHomePhone</TD>
<TD>AB_attribPOAddress
<BR>AB_attribStreetAddress
<BR>AB_attribLocality, AB_attribRegion AB_attribZipCode
<BR>AB_attribCountry</TD>
...end of stuff....
*/

5152
mozilla/cmd/winfe/addrdlg.cpp Executable file

File diff suppressed because it is too large Load Diff

1015
mozilla/cmd/winfe/addrdlg.h Executable file

File diff suppressed because it is too large Load Diff

7341
mozilla/cmd/winfe/addrfrm.cpp Executable file

File diff suppressed because it is too large Load Diff

1165
mozilla/cmd/winfe/addrfrm.h Executable file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,873 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 "addrfrm.h"
#ifdef MOZ_NEWADDR
#ifndef _addrprop_h_
#define _addrprop_h_
// ADDRFRM.H
//
// DESCRIPTION:
// This file contains the declarations of the various address book related
// classes.
//
#include "rosetta.h"
#include "outliner.h"
#include "apimsg.h"
#include "xp_core.h"
#include "abcom.h"
#include "property.h"
#include "abmldlg.h"
#include "mailfrm.h"
#include "mnrccln.h"
// above the range for normal EN_ messages
#define PEN_ILLEGALCHAR 0x8000
// sent to parent when illegal character hit
// return 0 if you want parsed edit to beep
/****************************************************************************
*
* Class: CAddrEditProperties
*
* DESCRIPTION:
* This class is the property sheet window for editing all the attributes
* of the people types in the address book
*
****************************************************************************/
class CAddrEditProperties : public CNetscapePropertySheet
{
protected:
ABID m_entryID;
CPropertyPage * m_pUserProperties;
CPropertyPage * m_pContact;
HG91827
CPropertyPage * m_pCooltalk;
CMailNewsResourceSwitcher m_MailNewsResourceSwitcher;
MSG_Pane * m_pPane;
//is this a new card
BOOL m_bNew;
public:
MWContext* m_context;
HFONT m_pFont;
public:
CAddrEditProperties ( CAddrFrame* frameref, LPCTSTR lpszCaption,
CWnd * parent = NULL, MSG_Pane * pane = NULL,
MWContext* context = NULL, BOOL bNew = FALSE);
virtual ~CAddrEditProperties ( );
virtual void OnHelp();
virtual int DoModal();
virtual BOOL Create( CWnd* pParentWnd = NULL, DWORD dwStyle = (DWORD)1, DWORD dwExStyle = 0 );
void SetAttributes(MSG_Pane *pane);
HFONT GetHFont() { return (m_pFont); }
void CloseWindow ();
protected:
CAddrFrame* m_frame;
// virtual ~CAddrEditProperties ( );
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CAddrEditProperties)
public:
virtual void OnOK();
afx_msg void OnDestroy( );
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAddrEditProperties)
// NOTE: the ClassWizard will add member functions here
afx_msg int OnCreate( LPCREATESTRUCT );
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/****************************************************************************
*
* Class: CAddressUser
*
* DESCRIPTION:
* This class is the property page for editing the most common attributes
* of the people types in the address book
*
****************************************************************************/
class CAddressUser : public CNetscapePropertyPage
{
// Construction
public:
CAddressUser(CWnd *pParent, BOOL bNew);
virtual ~CAddressUser();
BOOL m_bActivated;
BOOL m_bNew;
BOOL m_bUserChangedDisplay;
// Dialog Data
//{{AFX_DATA(CAddressUser)
enum { IDD = IDD_ADDRESS_USER };
CString m_address;
CString m_description;
CString m_firstname;
CString m_lastname;
CString m_nickname;
int m_useHTML;
CString m_company;
CString m_title;
CString m_displayname;
CString m_department;
//}}AFX_DATA
void SetAttributes(MSG_Pane *pane);
BOOL PerformOnOK(MSG_Pane *pane);
void SetFonts( HFONT pFont );
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CAddressUser)
public:
virtual BOOL OnInitDialog();
virtual BOOL OnSetActive();
virtual BOOL OnKillActive();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAddressUser)
// NOTE: the ClassWizard will add member functions here
afx_msg void OnCloseWindow();
afx_msg void OnNameTextChange();
afx_msg void OnDisplayNameTextChange();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/****************************************************************************
*
* Class: CAddressContact
*
* DESCRIPTION:
* This class is the property page for editing the contact info
* of the people types in the address book
*
****************************************************************************/
class CAddressContact : public CNetscapePropertyPage
{
// Construction
public:
CAddressContact(CWnd *pParent);
virtual ~CAddressContact();
BOOL m_bActivated;
// Dialog Data
//{{AFX_DATA(CAddressContact)
enum { IDD = IDD_ADDRESS_CONTACT };
CString m_poaddress;
CString m_address;
CString m_locality;
CString m_region;
CString m_zip;
CString m_country;
CString m_work;
CString m_fax;
CString m_home;
CString m_pager;
CString m_cellular;
//}}AFX_DATA
void SetAttributes(MSG_Pane *pane);
BOOL PerformOnOK(MSG_Pane *pane);
void SetFonts( HFONT pFont );
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CAddressContact)
public:
virtual BOOL OnInitDialog();
virtual BOOL OnSetActive();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAddressContact)
// NOTE: the ClassWizard will add member functions here
afx_msg void OnCloseWindow();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/****************************************************************************
*
* Class: CAddressCooltalk
*
* DESCRIPTION:
* This class is the property page for editing and accessing the cool
* talk attributes for a person object.
*
****************************************************************************/
class CAddressCooltalk : public CNetscapePropertyPage
{
// Construction
public:
CAddressCooltalk(CWnd *pParent);
virtual ~CAddressCooltalk();
BOOL m_bActivated;
void SetAttributes(MSG_Pane *pane);
BOOL PerformOnOK(MSG_Pane *pane);
void SetExplanationText();
void SetFonts( HFONT pFont );
// Dialog Data
//{{AFX_DATA(CAddressCooltalk)
enum { IDD = IDD_ADDRESS_COOLTALK };
CString m_ipaddress;
CString m_specificDLS;
CString m_hostorIP;
int m_iUseServer;
//}}AFX_DATA
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CAddressCooltalk)
public:
virtual BOOL OnInitDialog();
virtual BOOL OnSetActive();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAddressCooltalk)
afx_msg void OnCloseWindow();
afx_msg void OnSelendokServer();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/****************************************************************************
*
* Class: CAddressX
*
* DESCRIPTION:
* This class is the property page for editing and accessing the x
* attributes for a person object.
*
****************************************************************************/
class CAddressX : public CNetscapePropertyPage
{
// Construction
public:
CAddressX(CWnd *pParent); // standard constructor
virtual ~CAddressX();
BOOL m_bActivated;
void SetAttributes(MSG_Pane *pane);
BOOL PerformOnOK(MSG_Pane *pane);
// Dialog Data
//{{AFX_DATA(CAddressX)
enum { IDD = IDD_ADDRESS_X };
CString m_explain1;
CString m_explain2;
CString m_explain3;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAddressX)
public:
virtual BOOL OnInitDialog();
virtual BOOL OnSetActive();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAddressX)
// NOTE: the ClassWizard will add member functions here
afx_msg void OnCloseWindow();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/****************************************************************************
*
* Class: CAddrLDAPProperties
*
* DESCRIPTION:
* This class is the property sheet window for editing all the attributes
* of the people types in the address book
*
****************************************************************************/
class CAddrLDAPProperties : public CNetscapePropertySheet
{
protected:
CPropertyPage * m_pLDAPProperties;
CPropertyPage * m_pOfflineProperties;
CMailNewsResourceSwitcher m_MailNewsResourceSwitcher;
public:
DIR_Server* m_pExistServer;
DIR_Server m_serverInfo;
HFONT m_pFont;
MWContext* m_context;
public:
CAddrLDAPProperties (CWnd * parent,
MWContext* context,
DIR_Server* dir = NULL,
LPCTSTR lpszCaption = NULL);
virtual ~CAddrLDAPProperties ( );
virtual void OnHelp();
virtual int DoModal();
HFONT GetHFont() { return (m_pFont); }
protected:
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CAddrLDAPProperties)
public:
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAddrLDAPProperties)
// NOTE: the ClassWizard will add member functions here
afx_msg int OnCreate( LPCREATESTRUCT );
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CServerDialog : public CNetscapePropertyPage
{
// Attributes
public:
CServerDialog(CWnd* pParent = NULL, DIR_Server *pExistServer = NULL, DIR_Server *pNewServer = NULL);
enum { IDD = IDD_PREF_LDAP_SERVER};
DIR_Server *m_pExistServer;
DIR_Server *m_serverInfo;
BOOL m_bActivated;
//{{AFX_VIRTUAL(CServerDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
BOOL ValidDataInput();
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CServerDialog)
public:
virtual void OnOK();
virtual BOOL OnSetActive();
virtual BOOL OnKillActive();
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
afx_msg void OnCheckX();
afx_msg void OnEnableLoginLDAP();
afx_msg void OnHelp();
DECLARE_MESSAGE_MAP()
};
class CServerOfflineDialog : public CNetscapePropertyPage
{
// Attributes
public:
CServerOfflineDialog(CWnd* pParent = NULL, DIR_Server *pServer = NULL, DIR_Server *pNewServer = NULL);
enum { IDD = IDD_PREF_LDAP_OFFLINE_SETTINGS};
DIR_Server *m_pExistServer;
DIR_Server *m_serverInfo;
BOOL m_bActivated;
//{{AFX_VIRTUAL(CServerOfflineDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CServerOfflineDialog)
public:
virtual void OnOK();
virtual BOOL OnSetActive();
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
afx_msg void OnUpdateNow();
afx_msg void OnHelp();
DECLARE_MESSAGE_MAP()
};
#endif
#else //MOZ_NEWADDR
#ifndef _addrprop_h_
#define _addrprop_h_
// ADDRFRM.H
//
// DESCRIPTION:
// This file contains the declarations of the various address book related
// classes.
//
#include "rosetta.h"
#include "outliner.h"
#include "apimsg.h"
#include "xp_core.h"
#include "addrbook.h"
#include "property.h"
#include "abmldlg.h"
#include "mailfrm.h"
#include "mnrccln.h"
// above the range for normal EN_ messages
#define PEN_ILLEGALCHAR 0x8000
// sent to parent when illegal character hit
// return 0 if you want parsed edit to beep
/****************************************************************************
*
* Class: CAddrEditProperties
*
* DESCRIPTION:
* This class is the property sheet window for editing all the attributes
* of the people types in the address book
*
****************************************************************************/
class CAddrEditProperties : public CNetscapePropertySheet
{
protected:
ABID m_entryID;
CPropertyPage * m_pUserProperties;
CPropertyPage * m_pContact;
HG91827
CPropertyPage * m_pCooltalk;
CMailNewsResourceSwitcher m_MailNewsResourceSwitcher;
public:
DIR_Server* m_dir;
MWContext* m_context;
HFONT m_pFont;
PersonEntry* m_pPerson;
public:
CAddrEditProperties ( CAddrFrame* frameref, DIR_Server* dir,
LPCTSTR lpszCaption,
CWnd * parent = NULL, ABID entryID = NULL,
PersonEntry* person = NULL,
MWContext* context = NULL);
virtual ~CAddrEditProperties ( );
virtual void OnHelp();
virtual int DoModal();
virtual BOOL Create( CWnd* pParentWnd = NULL, DWORD dwStyle = (DWORD)1, DWORD dwExStyle = 0 );
void SetEntryID(DIR_Server* dir, ABID entryID = NULL, PersonEntry* person = NULL);
ABID GetEntryID() { return (m_entryID); }
DIR_Server* GetDirectoryServer() { return (m_dir); }
HFONT GetHFont() { return (m_pFont); }
void CloseWindow ();
protected:
CAddrFrame* m_frame;
// virtual ~CAddrEditProperties ( );
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CAddrEditProperties)
public:
virtual void OnOK();
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAddrEditProperties)
// NOTE: the ClassWizard will add member functions here
afx_msg int OnCreate( LPCREATESTRUCT );
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/****************************************************************************
*
* Class: CAddressUser
*
* DESCRIPTION:
* This class is the property page for editing the most common attributes
* of the people types in the address book
*
****************************************************************************/
class CAddressUser : public CNetscapePropertyPage
{
// Construction
public:
CAddressUser(CWnd *pParent);
virtual ~CAddressUser();
BOOL m_bActivated;
DIR_Server* m_dir;
// Dialog Data
//{{AFX_DATA(CAddressUser)
enum { IDD = IDD_ADDRESS_USER };
CString m_address;
CString m_description;
CString m_firstname;
CString m_lastname;
CString m_nickname;
int m_useHTML;
CString m_company;
CString m_title;
CString m_department;
CString m_displayname;
//}}AFX_DATA
void SetEntryID(DIR_Server* dir, ABID entryID = NULL, PersonEntry* person = NULL);
BOOL PerformOnOK(PersonEntry* person);
void SetFonts( HFONT pFont );
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CAddressUser)
public:
virtual BOOL OnInitDialog();
virtual BOOL OnSetActive();
virtual BOOL OnKillActive();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAddressUser)
// NOTE: the ClassWizard will add member functions here
afx_msg void OnCloseWindow();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/****************************************************************************
*
* Class: CAddressContact
*
* DESCRIPTION:
* This class is the property page for editing the contact info
* of the people types in the address book
*
****************************************************************************/
class CAddressContact : public CNetscapePropertyPage
{
// Construction
public:
CAddressContact(CWnd *pParent);
virtual ~CAddressContact();
BOOL m_bActivated;
DIR_Server* m_dir;
// Dialog Data
//{{AFX_DATA(CAddressContact)
enum { IDD = IDD_ADDRESS_CONTACT };
CString m_poaddress;
CString m_address;
CString m_locality;
CString m_region;
CString m_zip;
CString m_country;
CString m_work;
CString m_fax;
CString m_home;
CString m_pager;
CString m_cellular;
//}}AFX_DATA
void SetEntryID(DIR_Server* dir, ABID entryID = NULL, PersonEntry* person = NULL);
BOOL PerformOnOK(PersonEntry* person);
void SetFonts( HFONT pFont );
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CAddressContact)
public:
virtual BOOL OnInitDialog();
virtual BOOL OnSetActive();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAddressContact)
// NOTE: the ClassWizard will add member functions here
afx_msg void OnCloseWindow();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/****************************************************************************
*
* Class: CAddressCooltalk
*
* DESCRIPTION:
* This class is the property page for editing and accessing the cool
* talk attributes for a person object.
*
****************************************************************************/
class CAddressCooltalk : public CNetscapePropertyPage
{
// Construction
public:
CAddressCooltalk(CWnd *pParent);
virtual ~CAddressCooltalk();
BOOL m_bActivated;
DIR_Server* m_dir;
void SetEntryID(DIR_Server* dir, ABID entryID = NULL, PersonEntry* person = NULL);
BOOL PerformOnOK(PersonEntry* person);
void SetExplanationText();
void SetFonts( HFONT pFont );
// Dialog Data
//{{AFX_DATA(CAddressCooltalk)
enum { IDD = IDD_ADDRESS_COOLTALK };
CString m_ipaddress;
CString m_specificDLS;
CString m_hostorIP;
int m_iUseServer;
//}}AFX_DATA
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CAddressCooltalk)
public:
virtual BOOL OnInitDialog();
virtual BOOL OnSetActive();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAddressCooltalk)
afx_msg void OnCloseWindow();
afx_msg void OnSelendokServer();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/****************************************************************************
*
* Class: CAddrLDAPProperties
*
* DESCRIPTION:
* This class is the property sheet window for editing all the attributes
* of the people types in the address book
*
****************************************************************************/
class CAddrLDAPProperties : public CNetscapePropertySheet
{
protected:
CPropertyPage * m_pLDAPProperties;
CPropertyPage * m_pOfflineProperties;
CMailNewsResourceSwitcher m_MailNewsResourceSwitcher;
public:
DIR_Server* m_pExistServer;
DIR_Server m_serverInfo;
HFONT m_pFont;
MWContext* m_context;
public:
CAddrLDAPProperties (CWnd * parent,
MWContext* context,
DIR_Server* dir = NULL,
LPCTSTR lpszCaption = NULL);
virtual ~CAddrLDAPProperties ( );
virtual void OnHelp();
virtual int DoModal();
HFONT GetHFont() { return (m_pFont); }
protected:
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CAddrLDAPProperties)
public:
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAddrLDAPProperties)
// NOTE: the ClassWizard will add member functions here
afx_msg int OnCreate( LPCREATESTRUCT );
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CServerDialog : public CNetscapePropertyPage
{
// Attributes
public:
CServerDialog(CWnd* pParent = NULL, DIR_Server *pExistServer = NULL, DIR_Server *pNewServer = NULL);
enum { IDD = IDD_PREF_LDAP_SERVER};
DIR_Server *m_pExistServer;
DIR_Server *m_serverInfo;
BOOL m_bActivated;
//{{AFX_VIRTUAL(CServerDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
BOOL ValidDataInput();
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CServerDialog)
public:
virtual void OnOK();
virtual BOOL OnKillActive();
virtual BOOL OnSetActive();
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
afx_msg void OnCheckX();
afx_msg void OnEnableLoginLDAP();
afx_msg void OnHelp();
DECLARE_MESSAGE_MAP()
};
class CServerOfflineDialog : public CNetscapePropertyPage
{
// Attributes
public:
CServerOfflineDialog(CWnd* pParent = NULL, DIR_Server *pServer = NULL, DIR_Server *pNewServer = NULL);
enum { IDD = IDD_PREF_LDAP_OFFLINE_SETTINGS};
DIR_Server *m_pExistServer;
DIR_Server *m_serverInfo;
BOOL m_bActivated;
//{{AFX_VIRTUAL(CServerOfflineDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CServerOfflineDialog)
public:
virtual void OnOK();
virtual BOOL OnSetActive();
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
afx_msg void OnUpdateNow();
afx_msg void OnHelp();
DECLARE_MESSAGE_MAP()
};
#endif
#endif // MOZ_NEWADDR

View File

@@ -0,0 +1,125 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// AdvOpDlg.cpp : implementation file
// Called from srchfrm.cpp and used to customize search for the search messages dialog.
#include "stdafx.h"
#include "AdvOpDlg.h"
#include "prefapi.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAdvSearchOptionsDlg dialog
CAdvSearchOptionsDlg::CAdvSearchOptionsDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAdvSearchOptionsDlg::IDD, pParent)
{
m_pParent = pParent;
if (!CDialog::Create(CAdvSearchOptionsDlg::IDD, pParent))
{
TRACE0("Warning: creation of CAdvSearchOptionsDlg dialog failed\n");
return;
}
if( m_pParent && ::IsWindow(m_pParent->m_hWnd) ){
m_pParent->EnableWindow(FALSE);
}
this->EnableWindow(TRUE);
//{{AFX_DATA_INIT(CAdvSearchOptionsDlg)
m_bIncludeSubfolders = FALSE;
m_iSearchArea = 0;
//}}AFX_DATA_INIT
m_bChanges= FALSE;
}
void CAdvSearchOptionsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAdvSearchOptionsDlg)
DDX_Check(pDX, IDC_CHECK_SUBFOLDERS, m_bIncludeSubfolders);
DDX_Radio(pDX, IDC_RADIO_SEARCH_LOCAL, m_iSearchArea);
//}}AFX_DATA_MAP
}
BOOL CAdvSearchOptionsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
XP_Bool bSubFolders = FALSE;
XP_Bool bSearchServer = FALSE;
PREF_GetBoolPref("mailnews.searchSubFolders",&bSubFolders);
m_bIncludeSubfolders = bSubFolders;
PREF_GetBoolPref("mailnews.searchServer",&bSearchServer);
m_iSearchArea = !bSearchServer ? 0 : 1;
UpdateData(FALSE);
return TRUE;
}
void CAdvSearchOptionsDlg::OnOK()
{
UpdateData();
PREF_SetBoolPref("mailnews.searchSubFolders",(XP_Bool)m_bIncludeSubfolders);
XP_Bool bSearchServer = m_iSearchArea ? 1 : 0;
PREF_SetBoolPref("mailnews.searchServer", bSearchServer);
m_bChanges = TRUE;
GetParent()->PostMessage(WM_ADVANCED_OPTIONS_DONE);
OnClose();
}
void CAdvSearchOptionsDlg::OnHelp()
{
//!!TODO add NetHelp(..) call here.
}
void CAdvSearchOptionsDlg::PostNcDestroy()
{
CDialog::PostNcDestroy();
if( m_pParent && ::IsWindow(m_pParent->m_hWnd) ){
m_pParent->EnableWindow(TRUE);
// Return focus to parent window
m_pParent->SetActiveWindow();
m_pParent->SetFocus();
}
delete this;
}
void CAdvSearchOptionsDlg::OnClose()
{
DestroyWindow();
}
BEGIN_MESSAGE_MAP(CAdvSearchOptionsDlg, CDialog)
//{{AFX_MSG_MAP(CAdvSearchOptionsDlg)
ON_BN_CLICKED( IDOK, OnOK)
ON_BN_CLICKED( IDC_ADVANCED_SEARCH_HELP, OnHelp)
ON_COMMAND(IDCANCEL, OnClose)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAdvSearchOptionsDlg message handlers

View File

@@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// AdvOpDlg.h : header file
//
#ifndef _ADVOPDLG__H_
#define _ADVOPDLG__H_
#include <afxwin.h>
#define WM_ADVANCED_OPTIONS_DONE (WM_USER + 1555)
/////////////////////////////////////////////////////////////////////////////
// CAdvSearchOptionsDlg dialog
class CAdvSearchOptionsDlg : public CDialog
{
// Construction
public:
CAdvSearchOptionsDlg(CWnd* pParent = NULL); // standard constructor
void PostNcDestroy();
// Dialog Data
//{{AFX_DATA(CAdvSearchOptionsDlg)
enum { IDD = IDD_ADVANCED_SEARCH };
BOOL m_bIncludeSubfolders;
int m_iSearchArea;
//}}AFX_DATA
BOOL m_bChanges;
CWnd *m_pParent;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAdvSearchOptionsDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAdvSearchOptionsDlg)
afx_msg void OnOK();
afx_msg BOOL OnInitDialog();
afx_msg void OnHelp();
afx_msg void OnClose();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif

View File

@@ -0,0 +1,532 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "windowsx.h"
#include "wfemsg.h"
#include "prefapi.h"
#include "nethelp.h"
#include "advprosh.h"
/*-----------------------------------------------------------------*/
/* */
/* Search options page */
/* */
/*-----------------------------------------------------------------*/
CSearchOptionsPage::CSearchOptionsPage(CWnd *pParent, UINT nID)
: CNetscapePropertyPage(nID)
{
m_pParent = pParent;
m_bHasBeenViewed = FALSE;
}
CSearchOptionsPage::~CSearchOptionsPage()
{
}
void CSearchOptionsPage::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAdvSearchOptionsDlg)
DDX_Check(pDX, IDC_CHECK_SUBFOLDERS, m_bIncludeSubfolders);
DDX_Check(pDX, IDC_CHECK_SEARCH_LOCALLY, m_iSearchArea);
//}}AFX_DATA_MAP
}
BOOL CSearchOptionsPage::OnInitDialog()
{
XP_Bool bSubFolders = FALSE;
XP_Bool bSearchServer = FALSE;
PREF_GetBoolPref("mailnews.searchSubFolders",&bSubFolders);
m_bIncludeSubfolders = bSubFolders;
m_bOffline = NET_IsOffline();
if(!m_bOffline)
PREF_GetBoolPref("mailnews.searchServer",&bSearchServer);
else
{
CWnd * pCheck = GetDlgItem(IDC_CHECK_SEARCH_LOCALLY);
if(pCheck != NULL)
pCheck->EnableWindow(FALSE);
}
m_iSearchArea = bSearchServer ? 0 : 1;
UpdateData(FALSE);
m_bHasBeenViewed = TRUE;
BOOL ret = CNetscapePropertyPage::OnInitDialog();
return ret;
}
void CSearchOptionsPage::OnOK()
{
if(!m_bHasBeenViewed)
return;
UpdateData();
PREF_SetBoolPref("mailnews.searchSubFolders",(XP_Bool)m_bIncludeSubfolders);
if(!m_bOffline)
{
XP_Bool bSearchServer = m_iSearchArea ? 0 : 1;
PREF_SetBoolPref("mailnews.searchServer", bSearchServer);
}
}
void CSearchOptionsPage::OnCancel()
{
CNetscapePropertyPage::OnCancel();
}
BOOL CSearchOptionsPage::OnSetActive()
{
if(!CNetscapePropertyPage::OnSetActive())
return FALSE;
return TRUE ;
}
BOOL CSearchOptionsPage::OnKillActive()
{
return CNetscapePropertyPage::OnKillActive();
}
BEGIN_MESSAGE_MAP(CSearchOptionsPage, CNetscapePropertyPage)
END_MESSAGE_MAP()
/*-----------------------------------------------------------------*/
/* */
/* Edit headers page */
/* */
/*-----------------------------------------------------------------*/
CCustomHeadersPage::CCustomHeadersPage(CWnd *pParent, UINT nID)
: CNetscapePropertyPage(nID)
{
m_pParent = pParent;
m_bHasBeenViewed = FALSE;
}
CCustomHeadersPage::~CCustomHeadersPage()
{
}
void CCustomHeadersPage::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BOOL CCustomHeadersPage::OnInitDialog()
{
MSG_FolderInfo *pInbox = NULL;
MSG_GetFoldersWithFlag (WFE_MSGGetMaster(), MSG_FOLDER_FLAG_INBOX, &pInbox, 1);
uint16 numItems;
MSG_GetNumAttributesForFilterScopes (WFE_MSGGetMaster(), scopeMailFolder, (void**)&pInbox, 1, &numItems);
MSG_SearchMenuItem * pHeaderItems = new MSG_SearchMenuItem [numItems];
if (!pHeaderItems)
return FALSE;
MSG_GetAttributesForFilterScopes (WFE_MSGGetMaster(), scopeMailFolder, (void**)&pInbox, 1, pHeaderItems, &numItems);
CListBox * pList = (CListBox *)GetDlgItem(IDC_HEADER_LIST);
for (int i=0; i < numItems; i++)
{
if ( (pHeaderItems[i].attrib == attribOtherHeader) && pHeaderItems[i].isEnabled )
pList->AddString(pHeaderItems[i].name);
}
delete pHeaderItems;
updateUI();
m_bHasBeenViewed = TRUE;
return CNetscapePropertyPage::OnInitDialog();
}
void CCustomHeadersPage::OnAddHeader()
{
CEdit * pEdit = (CEdit *)GetDlgItem(IDC_EDIT_NEW_HEADER);
CListBox * pList = (CListBox *)GetDlgItem(IDC_HEADER_LIST);
char szString[256] = {'\0'};
pEdit->GetWindowText(szString, sizeof(szString));
if(strlen(szString) == 0)
return;
pList->AddString(szString);
pEdit->SetWindowText("");
pEdit->SetFocus();
}
void CCustomHeadersPage::OnRemoveHeader()
{
CListBox * pList = (CListBox *)GetDlgItem(IDC_HEADER_LIST);
int iSel = pList->GetCurSel();
if(iSel < 0)
return;
pList->DeleteString(iSel);
int iNewCount = pList->GetCount();
if(iNewCount > 0)
pList->SetCurSel((iSel >= iNewCount) ? iNewCount - 1 : iSel);
OnSelChangeHeaderList();
if(iNewCount == 0)
{
CEdit * pEdit = (CEdit *)GetDlgItem(IDC_EDIT_NEW_HEADER);
pEdit->SetFocus();
}
}
void CCustomHeadersPage::OnReplaceHeader()
{
CEdit * pEdit = (CEdit *)GetDlgItem(IDC_EDIT_NEW_HEADER);
CListBox * pList = (CListBox *)GetDlgItem(IDC_HEADER_LIST);
char szString[256] = {'\0'};
pEdit->GetWindowText(szString, sizeof(szString));
if(strlen(szString) == 0)
return;
int iSel = pList->GetCurSel();
if(iSel != LB_ERR)
{
pList->DeleteString(iSel);
pList->InsertString(iSel, szString);
}
else
pList->AddString(szString);
updateUI();
pEdit->SetFocus();
}
void CCustomHeadersPage::OnChangeEditHeader()
{
updateUI();
char szString[256];
GetDlgItemText(IDC_EDIT_NEW_HEADER, szString, sizeof(szString));
if(strlen(szString) > 0)
SetDefID(IDC_ADD_HEADER);
}
void CCustomHeadersPage::OnSelChangeHeaderList()
{
CEdit * pEdit = (CEdit *)GetDlgItem(IDC_EDIT_NEW_HEADER);
CListBox * pList = (CListBox *)GetDlgItem(IDC_HEADER_LIST);
char szString[256] = {'\0'};
int iSel = pList->GetCurSel();
if(iSel >= 0)
{
pList->GetText(iSel, szString);
pEdit->SetWindowText(szString);
}
else
pEdit->SetWindowText("");
updateUI();
}
BOOL CCustomHeadersPage::OnSetActive()
{
if(!CNetscapePropertyPage::OnSetActive())
return FALSE;
return TRUE ;
}
BOOL CCustomHeadersPage::OnKillActive()
{
return CNetscapePropertyPage::OnKillActive();
}
void CCustomHeadersPage::OnOK()
{
if(!m_bHasBeenViewed)
return;
CEdit * pEdit = (CEdit *)GetDlgItem(IDC_EDIT_NEW_HEADER);
CListBox * pList = (CListBox *)GetDlgItem(IDC_HEADER_LIST);
int iCount = pList->GetCount();
if(iCount != 0)
{
CString strTemp;
pList->GetText(0, strTemp);
CString strHeaderPrefList = strTemp;
for (int i = 1; i < iCount; i++)
{
pList->GetText(i,strTemp);
strHeaderPrefList += ": " + strTemp;
}
PREF_SetCharPref("mailnews.customHeaders", strHeaderPrefList);
}
else
{
PREF_SetCharPref("mailnews.customHeaders","");
}
CPropertyPage::OnOK();
}
void CCustomHeadersPage::OnCancel()
{
CNetscapePropertyPage::OnCancel();
}
void CCustomHeadersPage::enableDlgItem(int iId, BOOL bEnable)
{
CWnd * pItem = GetDlgItem(iId);
if(pItem == NULL)
return;
pItem->EnableWindow(bEnable);
}
void CCustomHeadersPage::updateUI()
{
CListBox * pList = (CListBox *)GetDlgItem(IDC_HEADER_LIST);
char szString[256] = {'\0'};
int iSel = pList->GetCurSel();
GetDlgItemText(IDC_EDIT_NEW_HEADER, szString, sizeof(szString));
enableDlgItem(IDC_ADD_HEADER, (strlen(szString) > 0));
enableDlgItem(IDC_REMOVE_HEADER, (iSel >= 0));
char szToReplace[256] = {'\0'};
pList->GetText(iSel, szToReplace);
enableDlgItem(IDC_REPLACE_HEADER, ((strlen(szString) > 0) && (iSel >= 0) && (0 != strcmp(szString, szToReplace))));
}
BEGIN_MESSAGE_MAP(CCustomHeadersPage, CNetscapePropertyPage)
ON_BN_CLICKED(IDC_ADD_HEADER, OnAddHeader)
ON_BN_CLICKED(IDC_REMOVE_HEADER, OnRemoveHeader)
ON_BN_CLICKED(IDC_REPLACE_HEADER, OnReplaceHeader)
ON_EN_CHANGE(IDC_EDIT_NEW_HEADER, OnChangeEditHeader)
ON_LBN_SELCHANGE(IDC_HEADER_LIST, OnSelChangeHeaderList)
END_MESSAGE_MAP()
/*-----------------------------------------------------------------*/
/* */
/* Advanced search property sheet */
/* */
/*-----------------------------------------------------------------*/
CAdvancedOptionsPropertySheet::CAdvancedOptionsPropertySheet(CWnd *pParent,
const char* pName,
DWORD dwPagesBitFlag)
: CNetscapePropertySheet(pName, pParent, 0, NULL),
m_pParent(pParent),
m_iReturnCode(IDCANCEL),
m_dwPagesBitFlag(dwPagesBitFlag),
m_OptionsPage(NULL),
m_HeadersPage(NULL)
{
assert(m_dwPagesBitFlag != AOP_NOPAGES);
if(m_dwPagesBitFlag & AOP_SEARCH_OPTIONS)
{
m_OptionsPage = new CSearchOptionsPage(pParent, IDD_ADVANCED_SEARCH);
AddPage(m_OptionsPage);
}
if(m_dwPagesBitFlag & AOP_CUSTOM_HEADERS)
{
m_HeadersPage = new CCustomHeadersPage(pParent, IDD_HEADER_LIST);
AddPage(m_HeadersPage);
}
}
CAdvancedOptionsPropertySheet::~CAdvancedOptionsPropertySheet()
{
if(m_OptionsPage!= NULL)
delete m_OptionsPage;
if(m_HeadersPage!= NULL)
delete m_HeadersPage;
}
CNetscapePropertyPage * CAdvancedOptionsPropertySheet::GetCurrentPage()
{
return (CNetscapePropertyPage *)GetActivePage();
}
BOOL CAdvancedOptionsPropertySheet::OnCommand(WPARAM wParam, LPARAM lParam)
{
#ifdef _WIN32
int id = LOWORD(wParam);
#else
int id = (int)wParam;
#endif
if((id == IDOK) || (id == IDCANCEL))
{
m_iReturnCode = id;
OnClose();
return TRUE;
}
return CNetscapePropertySheet::OnCommand(wParam, lParam);
}
#define BUTTON_CONTAINER 33
#define BUTTON_WIDTH 75
#define BUTTON_HEIGHT 23
#define BUTTON_TO_RIGHT 9
#define BUTTON_TO_BOTTOM 10
#define BUTTON_TO_BUTTON 6
#define X_ADJUSTMENT 9
#define Y_ADJUSTMENT 3
#define SetWinFont(hwnd, hfont, fRedraw) FORWARD_WM_SETFONT((hwnd), (hfont), (fRedraw), ::SendMessage)
#define GetWinFont(hwnd) FORWARD_WM_GETFONT((hwnd), ::SendMessage)
#ifdef _WIN32
BOOL CAdvancedOptionsPropertySheet::OnInitDialog()
{
BOOL ret = CNetscapePropertySheet::OnInitDialog();
#else
int CAdvancedOptionsPropertySheet::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
int ret = CNetscapePropertySheet::OnCreate(lpCreateStruct);
#endif
if(m_pParent && ::IsWindow(m_pParent->m_hWnd))
m_pParent->EnableWindow(FALSE);
EnableWindow(TRUE);
RECT rc;
GetWindowRect(&rc);
int iWidth = rc.right - rc.left;
int iHeight = rc.bottom - rc.top + BUTTON_CONTAINER;
SetWindowPos(NULL,0,0, iWidth, iHeight, SWP_NOZORDER | SWP_NOMOVE);
DWORD dwStyle = WS_VISIBLE | WS_CHILD;
HINSTANCE hInst = AfxGetInstanceHandle();
GetClientRect(&rc);
HFONT hFont = GetWinFont(m_hWnd);
int y = rc.bottom - rc.top - BUTTON_TO_BOTTOM - BUTTON_HEIGHT + Y_ADJUSTMENT;
int w = BUTTON_WIDTH;
int h = BUTTON_HEIGHT;
int x;
HWND hWnd;
x = rc.right - rc.left - BUTTON_TO_RIGHT - (BUTTON_TO_BUTTON + BUTTON_WIDTH) + X_ADJUSTMENT;
hWnd = CreateWindow("button", "Help", dwStyle, x,y, w, h, m_hWnd, (HMENU)IDHELP, hInst, NULL);
SetWinFont(hWnd, hFont, TRUE);
x -= BUTTON_TO_BUTTON + BUTTON_WIDTH;
hWnd = CreateWindow("button", "Cancel", dwStyle, x,y, w, h, m_hWnd, (HMENU)IDCANCEL, hInst, NULL);
SetWinFont(hWnd, hFont, TRUE);
x -= BUTTON_TO_BUTTON + BUTTON_WIDTH;
hWnd = CreateWindow("button", "OK", dwStyle, x,y, w, h, m_hWnd, (HMENU)IDOK, hInst, NULL);
SetWinFont(hWnd, hFont, TRUE);
return ret;
}
void CAdvancedOptionsPropertySheet::OnDestroy()
{
CNetscapePropertySheet::OnDestroy();
}
void CAdvancedOptionsPropertySheet::OnClose()
{
if(m_dwPagesBitFlag & AOP_SEARCH_OPTIONS)
{
if(m_iReturnCode == IDOK)
m_OptionsPage->OnOK();
m_pParent->PostMessage(WM_ADVANCED_OPTIONS_DONE, 0, m_iReturnCode);
}
if(m_dwPagesBitFlag & AOP_CUSTOM_HEADERS)
{
if(m_iReturnCode == IDOK)
m_HeadersPage->OnOK();
m_pParent->PostMessage(WM_EDIT_CUSTOM_DONE, 0, m_iReturnCode);
}
if(m_pParent && ::IsWindow(m_pParent->m_hWnd))
m_pParent->EnableWindow(TRUE);
DestroyWindow();
}
void CAdvancedOptionsPropertySheet::OnNcDestroy()
{
delete this;
}
void CAdvancedOptionsPropertySheet::OnHelp()
{
if(GetActivePage() == m_OptionsPage)
NetHelp(HELP_SEARCH_MAILNEWS_OPTIONS);
if(GetActivePage() == m_HeadersPage)
NetHelp(HELP_SEARCH_MAILNEWS_HEADERS);
}
BOOL CAdvancedOptionsPropertySheet::PreTranslateMessage(MSG * pMsg)
{
if(pMsg->message == WM_KEYDOWN)
{
switch ((int)pMsg->wParam)
{
case VK_ESCAPE:
OnClose();
break;
default:
return CNetscapePropertySheet::PreTranslateMessage(pMsg);
break;
}
return TRUE;
}
return CNetscapePropertySheet::PreTranslateMessage(pMsg);
}
BEGIN_MESSAGE_MAP(CAdvancedOptionsPropertySheet, CNetscapePropertySheet)
#ifndef _WIN32
ON_WM_CREATE()
#endif
ON_WM_CLOSE()
ON_WM_DESTROY()
END_MESSAGE_MAP()

View File

@@ -0,0 +1,137 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 ADVPROPSHEET_H
#define ADVPROPSHEET_H
#include "property.h"
#include "msg_filt.h"
#define WM_ADVANCED_OPTIONS_DONE (WM_USER + 1555)
#define WM_EDIT_CUSTOM_DONE (WM_USER + 1556)
class CAdvancedOptionsPropertySheet;
class CSearchOptionsPage : public CNetscapePropertyPage
{
public:
CSearchOptionsPage(CWnd *pParent, UINT nID);
~CSearchOptionsPage();
virtual BOOL OnInitDialog();
virtual BOOL OnSetActive();
virtual BOOL OnKillActive( );
virtual void OnOK();
virtual void OnCancel();
//{{AFX_DATA(CSearchOptionsPage)
enum { IDD = IDD_ADVANCED_SEARCH };
BOOL m_bIncludeSubfolders;
int m_iSearchArea;
//}}AFX_DATA
//{{AFX_VIRTUAL(CSearchOptionsPage)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
protected:
CWnd * m_pParent;
BOOL m_bHasBeenViewed;
BOOL m_bOffline;
DECLARE_MESSAGE_MAP()
};
class CCustomHeadersPage : public CNetscapePropertyPage
{
public:
CCustomHeadersPage(CWnd *pParent, UINT nID);
~CCustomHeadersPage();
virtual BOOL OnInitDialog();
virtual BOOL OnSetActive();
virtual BOOL OnKillActive();
virtual void OnAddHeader();
virtual void OnRemoveHeader();
virtual void OnReplaceHeader();
virtual void OnChangeEditHeader();
virtual void OnSelChangeHeaderList();
virtual void OnOK();
virtual void OnCancel();
void updateUI();
void enableDlgItem(int iId, BOOL bEnable);
//{{AFX_DATA(CCustomHeadersPage)
enum { IDD = IDD_HEADER_LIST };
//}}AFX_DATA
//{{AFX_VIRTUAL(CCustomHeadersPage)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
protected:
CWnd * m_pParent;
BOOL m_bHasBeenViewed;
DECLARE_MESSAGE_MAP()
};
class CAdvancedOptionsPropertySheet : public CNetscapePropertySheet
{
public:
CAdvancedOptionsPropertySheet(CWnd *pParent, const char* pName, DWORD dwPagesBitFlag = 0L);
~CAdvancedOptionsPropertySheet();
CNetscapePropertyPage * GetCurrentPage();
virtual void OnHelp();
protected:
CWnd * m_pParent;
int m_iReturnCode;
DWORD m_dwPagesBitFlag;
CSearchOptionsPage * m_OptionsPage;
CCustomHeadersPage * m_HeadersPage;
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
virtual void OnNcDestroy();
virtual void OnClose();
virtual BOOL PreTranslateMessage(MSG * pMsg);
#ifdef _WIN32
virtual BOOL OnInitDialog();
#else
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
#endif
virtual void OnDestroy();
DECLARE_MESSAGE_MAP()
};
// Advanced Options pages (bitflags)
#define AOP_NOPAGES 0x00000000
#define AOP_SEARCH_OPTIONS 0x00000001
#define AOP_CUSTOM_HEADERS 0x00000002
#endif // ADVPROPSHEET_H

322
mozilla/cmd/winfe/animbar.cpp Executable file
View File

@@ -0,0 +1,322 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "animbar.h"
#define ANIMATION_WIDTH 20
#define ANIMATION_HEIGHT 20
#undef ANIMATION_PERIOD
#define ANIMATION_PERIOD (4000)
CAnimation::CAnimation(CWnd *pParent ): CWnd()
{
m_uAnimationClock = 0;
m_bInited = FALSE;
m_bCaptured = FALSE;
m_bDepressed = FALSE;
m_hAnimBitmap = NULL;
m_iAnimationCount = 0;
m_iconSize.cx = ANIMATION_WIDTH;
m_iconSize.cy = ANIMATION_HEIGHT;
CreateEx(0, NULL, _T("NSAnimation"),
WS_CHILD|WS_VISIBLE,
0, 0,
m_iconSize.cx + 4,
m_iconSize.cy + 4,
pParent->GetSafeHwnd(), (HMENU) 101);
//Changed AfxGetInstanceHandle to AfxGetResourceHandle to insure loading bitmaps
//from the LANG DLL and not netscape.exe benito
if (!m_bInited) {
CDC *pDC = GetDC();
m_hAnimBitmap = wfe_LoadBitmap(AfxGetResourceHandle(), pDC->m_hDC, MAKEINTRESOURCE(IDB_ANIMSMALL_0));
BITMAP bm;
GetObject( m_hAnimBitmap, sizeof(BITMAP), &bm );
m_iFrameCount = bm.bmWidth / m_iconSize.cx;
ReleaseDC( pDC );
m_bInited = TRUE;
}
}
BEGIN_MESSAGE_MAP(CAnimation, CWnd)
ON_WM_PAINT()
ON_WM_TIMER()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_DESTROY()
END_MESSAGE_MAP()
void CAnimation::OnPaint()
{
CPaintDC dc(this);
RECT rect;
GetClientRect(&rect);
WFE_Draw3DButtonRect( dc.m_hDC, &rect, m_bDepressed );
AnimateIcon();
}
void CAnimation::OnTimer(UINT nID)
{
CWnd::OnTimer(nID);
if (nID == WIN_ANIMATE_ICON_TIMER) {
if(m_bInited)
{
m_iAnimationCount = ( m_iAnimationCount % m_iFrameCount ) + 1;
AnimateIcon();
}
}
}
void CAnimation::OnLButtonDown( UINT nFlags, CPoint point )
{
RECT rect;
GetClientRect(&rect);
m_bDepressed = ::PtInRect(&rect, point);
if (m_bDepressed) {
SetCapture();
m_bCaptured = TRUE;
Invalidate();
UpdateWindow();
}
}
void CAnimation::OnMouseMove( UINT nFlags, CPoint point )
{
if (m_bCaptured) {
RECT rect;
GetClientRect(&rect);
BOOL bDepressed = ::PtInRect(&rect, point);
if (bDepressed != m_bDepressed) {
m_bDepressed = bDepressed;
Invalidate();
UpdateWindow();
}
}
}
void CAnimation::OnLButtonUp( UINT nFlags, CPoint point )
{
if (m_bCaptured) {
ReleaseCapture();
m_bCaptured = FALSE;
RECT rect;
GetClientRect(&rect);
BOOL bDepressed = ::PtInRect(&rect, point);
GetParentFrame()->SendMessage( WM_COMMAND, (WPARAM) ID_ANIMATION_BONK, (LPARAM) 0 );
}
m_bDepressed = FALSE;
Invalidate();
UpdateWindow();
}
void CAnimation::OnDestroy()
{
if (m_hAnimBitmap)
VERIFY(DeleteObject( m_hAnimBitmap ));
// Right now, the context has already been deleted, since
// it's not a true COM object.
// m_pIMWContext->Release();
}
void CAnimation::StopAnimation()
{
m_iAnimationCount = 0;
if (m_uAnimationClock)
KillTimer(m_uAnimationClock);
m_uAnimationClock = 0;
AnimateIcon();
}
void CAnimation::StartAnimation()
{
m_iAnimationCount = 1;
m_uAnimationClock = SetTimer(WIN_ANIMATE_ICON_TIMER, ANIMATION_PERIOD/m_iFrameCount, NULL);
}
void CAnimation::AnimateIcon()
{
CClientDC dc(this);
CRect rect;
GetClientRect(&rect);
// check if our application level CDC exists
if(!theApp.pIconDC) {
theApp.pIconDC = new CDC;
theApp.pIconDC->CreateCompatibleDC(&dc);
}
HBITMAP hOldBitmap = (HBITMAP) theApp.pIconDC->SelectObject( m_hAnimBitmap );
dc.BitBlt( 2, 2,
m_iconSize.cx, m_iconSize.cy,
theApp.pIconDC,
m_iconSize.cx * m_iAnimationCount, // X offset into the strip
0,
SRCCOPY);
// Reselect the old object
theApp.pIconDC->SelectObject( hOldBitmap );
}
/////////////////////////////////////////////////////////////////////////////
// CAnimationBar toolbar derived class
CAnimationBar::CAnimationBar( ): CAnimationBarParent ()
{
m_iconPt.x = 0;
m_iconPt.y = 0;
m_wndAnimation = NULL;
}
CAnimationBar::~CAnimationBar()
{
if ( m_wndAnimation ) {
m_wndAnimation->DestroyWindow();
}
}
void CAnimationBar::StartAnimation()
{
if (m_wndAnimation)
m_wndAnimation->StartAnimation();
}
void CAnimationBar::StopAnimation()
{
if (m_wndAnimation)
m_wndAnimation->StopAnimation();
}
#ifdef XP_WIN32
CSize CAnimationBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
{
CSize size = CAnimationBarParent::CalcFixedLayout(bStretch, bHorz);
if (m_wndAnimation) {
CRect rectAnimation;
m_wndAnimation->GetWindowRect(&rectAnimation);
int cy = rectAnimation.Height() + m_cyTopBorder + m_cyBottomBorder + 4;
if (size.cy < cy )
size.cy = cy;
}
return size;
}
CSize CAnimationBar::CalcDynamicLayout(int nLength, DWORD dwMode )
{
int nToolbarHeight = 0;
int nAnimationHeight = 0;
CRect animationRect;
if(m_wndAnimation)
{
m_wndAnimation->GetWindowRect(animationRect);
nAnimationHeight = animationRect.Height() + 4;
}
if(m_pToolbar)
{
nToolbarHeight = m_pToolbar->GetHeight() + 4;
}
return CSize(32767,
(nToolbarHeight > nAnimationHeight) ? nToolbarHeight : nAnimationHeight);
}
#endif
void CAnimationBar::PlaceToolbar(void)
{
CRect rectAnimation;
if ( m_wndAnimation ) {
m_wndAnimation->GetWindowRect(&rectAnimation);
CRect rectBar;
GetClientRect(&rectBar);
m_iconPt.x = rectBar.Width() - rectAnimation.Width() - GetSystemMetrics(SM_CXBORDER) - 1;
m_iconPt.y = rectBar.Height() / 2 - rectAnimation.Height() / 2 + 2;
if(m_pToolbar)
{
int nHeight = m_pToolbar->GetHeight();
// m_pToolbar->MoveWindow(0, (rectBar.Height() - nHeight) / 2 + 1, cx - rectAnimation.Width(), nHeight, FALSE);
m_pToolbar->SetWindowPos(NULL, 0, (rectBar.Height() - nHeight) / 2 + 1, m_iconPt.x, nHeight,
/*SWP_NOMOVE|*/ SWP_NOREDRAW);
}
}
}
BEGIN_MESSAGE_MAP(CAnimationBar, CAnimationBarParent)
ON_WM_CREATE()
ON_WM_SIZE()
END_MESSAGE_MAP()
int CAnimationBar::OnCreate( LPCREATESTRUCT lpCreateStruct )
{
int res = CAnimationBarParent::OnCreate( lpCreateStruct );
if ( res != -1 ) {
m_wndAnimation = new CAnimation( this );
res = m_wndAnimation ? 0 : -1;
}
return res;
}
void CAnimationBar::OnSize( UINT nType, int cx, int cy )
{
CRect rectAnimation;
if ( nType != SIZE_MINIMIZED && m_wndAnimation ) {
m_wndAnimation->GetWindowRect(&rectAnimation);
CRect rectBar;
GetClientRect(&rectBar);
CClientDC dc( this );
m_iconPt.x = rectBar.Width() - rectAnimation.Width() - GetSystemMetrics(SM_CXBORDER) - 1;
m_iconPt.y = rectBar.Height() / 2 - rectAnimation.Height() / 2 + 2;
m_wndAnimation->SetWindowPos(NULL, m_iconPt.x, m_iconPt.y, 0, 0,
SWP_NOZORDER|SWP_NOSIZE);
if(m_pToolbar)
{
int nHeight = m_pToolbar->GetHeight();
// m_pToolbar->MoveWindow(0, (rectBar.Height() - nHeight) / 2 + 1, cx - rectAnimation.Width(), nHeight, FALSE);
m_pToolbar->SetWindowPos(NULL, 0, (rectBar.Height() - nHeight) / 2 + 1, m_iconPt.x, nHeight,
/*SWP_NOMOVE|*/ SWP_NOREDRAW);
}
}
}

83
mozilla/cmd/winfe/animbar.h Executable file
View File

@@ -0,0 +1,83 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 _ANIMBAR_H
#define _ANIMBAR_H
#include "toolbar2.h"
class CAnimation: public CWnd
{
protected:
SIZE m_iconSize;
int m_iFrameCount;
HBITMAP m_hAnimBitmap;
int m_iAnimationCount;
UINT m_uAnimationClock;
BOOL m_bInited;
BOOL m_bCaptured, m_bDepressed;
void AnimateIcon();
public:
CAnimation( CWnd *pParent );
void StopAnimation();
void StartAnimation();
protected:
afx_msg void OnPaint();
afx_msg void OnTimer(UINT);
afx_msg void OnLButtonDown( UINT nFlags, CPoint point );
afx_msg void OnMouseMove( UINT nFlags, CPoint point );
afx_msg void OnLButtonUp( UINT nFlags, CPoint point );
afx_msg void OnDestroy();
DECLARE_MESSAGE_MAP()
};
#define CAnimationBarParent CToolbarControlBar
class CAnimationBar: public CAnimationBarParent
{
protected:
POINT m_iconPt;
CAnimation *m_wndAnimation;
public:
CAnimationBar();
~CAnimationBar();
void StopAnimation();
void StartAnimation();
void PlaceToolbar(void);
protected:
#ifdef XP_WIN32
// Attributes
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
virtual CSize CalcDynamicLayout(int nLength, DWORD dwMode );
#endif
afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
afx_msg void OnSize( UINT nType, int cx, int cy );
DECLARE_MESSAGE_MAP()
};
#endif

View File

@@ -0,0 +1,621 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "tooltip.h"
#include "animbar2.h"
#include "statbar.h"
#include "prefapi.h"
#include "custom.h"
#include "sysinfo.h"
#include "animecho.h"
#define ANIMATION_WIDTH 16
#define ANIMATION_HEIGHT 16
#define ANIMATION_WIDTH_L 32
#define ANIMATION_HEIGHT_L 32
#undef ANIMATION_PERIOD
#define ANIMATION_PERIOD (8000)
#define IDT_BUTTONFOCUS 16411
#define BUTTONFOCUS_DELAY_MS 10
#define BUTTON_WIDTH 2
// We cache the animation bitmaps for speed
HBITMAP CAnimation2::m_hSmall = NULL;
HBITMAP CAnimation2::m_hBig = NULL;
ULONG CAnimation2::m_uRefCount = 0L;
void DrawUpButton(HDC hDC, CRect & rect)
{
// Highlight (the white color)
HBRUSH br = ::CreateSolidBrush(sysInfo.m_clrBtnHilite);
CRect rc(rect.left, rect.top, rect.right-1, rect.top+1);
::FillRect(hDC, rc, br);
rc.SetRect(rect.left, rect.top, rect.left+1, rect.bottom-1);
::FillRect(hDC, rc, br);
#ifdef _WIN32
::DeleteObject(br);
// Light shadow (the light gray color)
br = ::CreateSolidBrush(::GetSysColor(COLOR_3DLIGHT));
#endif // _WIN32
rc.SetRect(rect.left+1, rect.top+1, rect.right - 2 , rect.top+2);
::FillRect(hDC, rc, br);
rc.SetRect(rect.left+1, rect.top+1, rect.left+2, rect.bottom - 2);
::FillRect(hDC, rc, br);
::DeleteObject(br);
// Shadow (the dark grey color)
br = ::CreateSolidBrush(sysInfo.m_clrBtnShadow);
rc.SetRect(rect.left+1, rect.bottom - 2, rect.right-1, rect.bottom-1);
::FillRect(hDC, rc, br);
rc.SetRect(rect.right - 2, rect.top+1, rect.right-1, rect.bottom-1);
::FillRect(hDC, rc, br);
#ifdef _WIN32
::DeleteObject(br);
// Dark Shadow (the black color)
br = ::CreateSolidBrush(::GetSysColor(COLOR_3DDKSHADOW));
#endif // _WIN32
rc.SetRect(rect.left, rect.bottom - 1, rect.right, rect.bottom);
::FillRect(hDC, rc, br);
rc.SetRect(rect.right - 1, rect.top, rect.right, rect.bottom);
::FillRect(hDC, rc, br);
::DeleteObject(br);
}
void DrawDownButton(HDC hDC, CRect & rect)
{
// Highlight (the white color)
#ifdef XP_WIN16
HBRUSH br = ::CreateSolidBrush(sysInfo.m_clrBtnShadow);
#else // _WIN32
HBRUSH br = ::CreateSolidBrush(::GetSysColor(COLOR_3DDKSHADOW));
#endif
CRect rc(rect.left, rect.top, rect.right-1, rect.top+1);
::FillRect(hDC, rc, br);
rc.SetRect(rect.left, rect.top, rect.left+1, rect.bottom-1);
::FillRect(hDC, rc, br);
#ifdef _WIN32
::DeleteObject(br);
// Light shadow (the light gray color)
br = ::CreateSolidBrush(sysInfo.m_clrBtnShadow);
#endif
rc.SetRect(rect.left+1, rect.top+1, rect.right - 2 , rect.top+2);
::FillRect(hDC, rc, br);
rc.SetRect(rect.left+1, rect.top+1, rect.left+2, rect.bottom - 2);
::FillRect(hDC, rc, br);
::DeleteObject(br);
// Shadow (the dark grey color)
#ifdef XP_WIN16
br = ::CreateSolidBrush(sysInfo.m_clrBtnHilite);
#else
br = ::CreateSolidBrush(::GetSysColor(COLOR_3DLIGHT));
#endif // _WIN16
rc.SetRect(rect.left+1, rect.bottom - 2, rect.right-1, rect.bottom-1);
::FillRect(hDC, rc, br);
rc.SetRect(rect.right - 2, rect.top+1, rect.right-1, rect.bottom-1);
::FillRect(hDC, rc, br);
#ifdef _WIN32
::DeleteObject(br);
// Dark Shadow (the black color)
br = ::CreateSolidBrush(sysInfo.m_clrBtnHilite);
#endif // _WIN32
rc.SetRect(rect.left, rect.bottom - 1, rect.right, rect.bottom);
::FillRect(hDC, rc, br);
rc.SetRect(rect.right - 1, rect.top, rect.right, rect.bottom);
::FillRect(hDC, rc, br);
::DeleteObject(br);
}
CAnimation2::CAnimation2( CWnd *pParent, LPUNKNOWN pUnk ): CWnd()
{
m_uAnimationClock = 0;
m_bInited = FALSE;
m_bCaptured = FALSE;
m_bDepressed = FALSE;
m_hAnimBitmap = NULL;
m_iAnimationCount = 0;
m_iconSize.cx = 0;
m_iconSize.cy = 0;
CreateEx(0, NULL, _T("NSAnimation"),
WS_CHILD|WS_VISIBLE,
0, 0, 0, 0,
pParent->GetSafeHwnd(), (HMENU) 101);
if( !m_bInited )
{
SetBitmap();
m_bInited = TRUE;
}
#ifdef WIN32
m_ToolTip.Create(this, TTS_ALWAYSTIP);
#else
m_ToolTip.Create(this);
#endif
if( !CUST_IsCustomAnimation( &m_iFrameCount ) )
{
m_ToolTip.AddTool(this, szLoadString(IDS_NETSCAPE_TIP));
m_ToolTip.Activate(TRUE);
m_ToolTip.SetDelayTime(250);
}
m_hFocusTimer = 0;
m_bHaveFocus = FALSE;
m_pIMWContext = NULL;
if (pUnk)
pUnk->QueryInterface( IID_IMWContext, (LPVOID *) &m_pIMWContext );
CAnimation2::m_uRefCount++;
}
CAnimation2::~CAnimation2()
{
CAnimation2::m_uRefCount--;
ASSERT( CAnimation2::m_uRefCount >= 0 );
if( !CAnimation2::m_uRefCount )
{
if( CAnimation2::m_hSmall )
{
DeleteObject( CAnimation2::m_hSmall );
CAnimation2::m_hSmall = NULL;
}
if( CAnimation2::m_hBig )
{
DeleteObject( CAnimation2::m_hBig );
CAnimation2::m_hBig = NULL;
}
}
}
BEGIN_MESSAGE_MAP(CAnimation2, CWnd)
ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_TIMER()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_DESTROY()
ON_WM_SETCURSOR()
END_MESSAGE_MAP()
BOOL CAnimation2::OnEraseBkgnd( CDC* pDC )
{
return TRUE;
}
void CAnimation2::OnPaint()
{
// Do not remove next useless line, somehow needed or
// painting will hang.
CPaintDC dc(this);
AnimateIcon();
}
void CAnimation2::OnTimer(UINT nID)
{
CWnd::OnTimer(nID);
if (nID == WIN_ANIMATE_ICON_TIMER) {
if(m_bInited)
{
m_iAnimationCount = ( m_iAnimationCount % m_iFrameCount ) + 1;
AnimateIcon();
}
}
else if(nID == IDT_BUTTONFOCUS)
{
RemoveButtonFocus();
}
}
BOOL CAnimation2::OnSetCursor( CWnd *, UINT, UINT )
{
SetCursor( theApp.LoadCursor( IDC_SELECTANCHOR ) );
return TRUE;
}
void CAnimation2::OnLButtonDown( UINT nFlags, CPoint point )
{
RECT rect;
GetClientRect(&rect);
m_bDepressed = ::PtInRect(&rect, point);
if (m_bDepressed) {
SetCapture();
m_bCaptured = TRUE;
Invalidate();
UpdateWindow();
}
MSG msg = *(GetCurrentMessage());
m_ToolTip.RelayEvent(&msg);
}
void CAnimation2::OnMouseMove( UINT nFlags, CPoint point )
{
RECT rect;
GetClientRect(&rect);
if (m_bCaptured)
{
BOOL bDepressed = ::PtInRect(&rect, point);
if (bDepressed != m_bDepressed)
{
m_bDepressed = bDepressed;
Invalidate();
UpdateWindow();
}
}
if (!m_bHaveFocus)
{
if(GetParentFrame() == GetActiveWindow() || GetParentFrame() == AfxGetMainWnd())
{
m_bHaveFocus = TRUE;
if( !CUST_IsCustomAnimation( &m_iFrameCount ) && m_hFocusTimer == 0)
{
m_hFocusTimer = SetTimer(IDT_BUTTONFOCUS, BUTTONFOCUS_DELAY_MS, NULL);
WFE_GetOwnerFrame(this)->SendMessage( WM_SETMESSAGESTRING,
(WPARAM)0, (LPARAM)szLoadString(IDS_NETSCAPE_TIP));
}
m_ToolTip.Activate(TRUE);
}
}
if(GetParentFrame() == GetActiveWindow() || GetParentFrame() == AfxGetMainWnd())
{
MSG msg = *(GetCurrentMessage());
m_ToolTip.RelayEvent(&msg);
}
}
void CAnimation2::RemoveButtonFocus()
{
POINT point;
KillTimer(IDT_BUTTONFOCUS);
m_hFocusTimer = 0;
GetCursorPos(&point);
CRect rcClient;
GetWindowRect(&rcClient);
if (!rcClient.PtInRect(point))
{
m_bHaveFocus = FALSE;
if ( WFE_GetOwnerFrame(this) != NULL) {
WFE_GetOwnerFrame(this)->SendMessage( WM_SETMESSAGESTRING,
(WPARAM) 0, (LPARAM) "" );
}
m_bDepressed = FALSE;
Invalidate();
UpdateWindow();
}
else
m_hFocusTimer = SetTimer(IDT_BUTTONFOCUS, BUTTONFOCUS_DELAY_MS, NULL);
}
void CAnimation2::OnLButtonUp( UINT nFlags, CPoint point )
{
if (m_bCaptured) {
ReleaseCapture();
m_bCaptured = FALSE;
RECT rect;
GetClientRect(&rect);
BOOL bDepressed = ::PtInRect(&rect, point);
if ( bDepressed) {
CAbstractCX * pCX = FEU_GetLastActiveFrameContext();
ASSERT(pCX != NULL);
if (pCX != NULL)
{
char *pURL = NULL;
int iError = PREF_CopyConfigString("toolbar.logo.url",&pURL);
if (PREF_ERROR != iError && pURL && *pURL) {
pCX->NormalGetUrl(pURL);
XP_FREE(pURL);
}
}
}
}
m_bDepressed = FALSE;
Invalidate();
UpdateWindow();
}
void CAnimation2::OnDestroy()
{
}
void CAnimation2::StopAnimation()
{
m_iAnimationCount = 0;
if (m_uAnimationClock)
KillTimer(m_uAnimationClock);
m_uAnimationClock = 0;
AnimateIcon();
}
void CAnimation2::StartAnimation()
{
m_iAnimationCount = 1;
if (m_uAnimationClock == 0)
{
// The animation is not currently running.
m_uAnimationClock = SetTimer(WIN_ANIMATE_ICON_TIMER, ANIMATION_PERIOD/m_iFrameCount, NULL);
// Added by Dave (4/98). DDE Hook to listen to animation.
CFrameWnd* pFrame = GetTopLevelFrame();
if (pFrame->IsKindOf(RUNTIME_CLASS(CGenericFrame)))
{
CGenericFrame* pGenFrame = (CGenericFrame*)pFrame;
CWinCX* pWinContext = pGenFrame->GetMainWinContext();
if (pWinContext)
{
DWORD dwWindowID = pWinContext->GetContextID();
CDDEAnimationEcho::Echo(dwWindowID, (DWORD)1);
}
}
}
}
void CAnimation2::AnimateIcon()
{
CClientDC dc(this);
CRect rect;
GetClientRect(&rect);
// check if our application level CDC exists
if(!theApp.pIconDC) {
theApp.pIconDC = new CDC;
theApp.pIconDC->CreateCompatibleDC(&dc);
}
HBITMAP hOldBitmap = (HBITMAP) theApp.pIconDC->SelectObject( m_hAnimBitmap );
dc.BitBlt( 2, 2,
m_iconSize.cx, m_iconSize.cy,
theApp.pIconDC,
m_iconSize.cx * m_iAnimationCount, // X offset into the strip
0,
SRCCOPY);
if (m_bDepressed)
DrawDownButton(dc.m_hDC, rect);
else DrawUpButton(dc.m_hDC, rect);
// Reselect the old object
theApp.pIconDC->SelectObject( hOldBitmap );
}
void CAnimation2::Initialize( LPUNKNOWN pUnk )
{
ASSERT(pUnk);
if (m_pIMWContext) {
m_pIMWContext->Release();
m_pIMWContext = NULL;
}
if (pUnk) {
pUnk->QueryInterface( IID_IMWContext, (LPVOID *) &m_pIMWContext );
}
}
void CAnimation2::SetBitmap( BOOL bSmall /*=TRUE*/ )
{
CDC *pDC = GetDC();
if( !CAnimation2::m_hSmall )
{
CAnimation2::m_hSmall = wfe_LoadBitmap( AfxGetResourceHandle(), pDC->m_hDC, MAKEINTRESOURCE(IDB_ANIMSMALL_0) );
ASSERT( CAnimation2::m_hSmall );
CAnimation2::m_hBig = wfe_LoadBitmap( AfxGetResourceHandle(), pDC->m_hDC, MAKEINTRESOURCE(IDB_ANIM_0) );
ASSERT( CAnimation2::m_hBig );
}
if( CUST_IsCustomAnimation( &m_iFrameCount ) )
{
ASSERT( m_iFrameCount > 0 );
m_hAnimBitmap = bSmall ? CAnimation2::m_hSmall : CAnimation2::m_hBig;
BITMAP bm;
GetObject( m_hAnimBitmap, sizeof(BITMAP), &bm );
m_iconSize.cx = bm.bmWidth / m_iFrameCount;
m_iconSize.cy = bm.bmHeight;
}
else
{
if( bSmall )
{
m_iconSize.cx = ANIMATION_WIDTH;
m_iconSize.cy = ANIMATION_HEIGHT;
m_hAnimBitmap = CAnimation2::m_hSmall;
}
else
{
m_iconSize.cx = ANIMATION_WIDTH_L;
m_iconSize.cy = ANIMATION_HEIGHT_L;
m_hAnimBitmap = CAnimation2::m_hBig;
}
BITMAP bm;
GetObject( m_hAnimBitmap, sizeof(BITMAP), &bm );
m_iFrameCount = bm.bmWidth / m_iconSize.cx;
}
ReleaseDC( pDC );
SetWindowPos( NULL, 0, 0, m_iconSize.cx+4, m_iconSize.cy+4, SWP_NOMOVE | SWP_NOZORDER );
GetParent()->SetWindowPos( NULL, 0, 0, m_iconSize.cx+4, m_iconSize.cy+4, SWP_NOMOVE | SWP_NOZORDER );
}
HBITMAP CAnimation2::GetBitmap( BOOL bSmall /*=TRUE*/ )
{
return bSmall ? CAnimation2::m_hSmall : CAnimation2::m_hBig;
}
void CAnimation2::GetSize( CSize &size )
{
size = m_iconSize;
}
/////////////////////////////////////////////////////////////////////////////
// CAnimationBar2 toolbar derived class
CAnimationBar2::CAnimationBar2( LPUNKNOWN pUnk ): CAnimationBar2Parent ()
{
m_iconPt.x = 0;
m_iconPt.y = 0;
m_wndAnimation = NULL;
m_pUnk = pUnk;
}
CAnimationBar2::~CAnimationBar2()
{
if ( m_wndAnimation ) {
m_wndAnimation->DestroyWindow();
delete m_wndAnimation;
}
}
void CAnimationBar2::StartAnimation()
{
if( !m_wndAnimation )
{
return;
}
m_wndAnimation->StartAnimation();
}
void CAnimationBar2::StopAnimation()
{
if( !m_wndAnimation )
{
return;
}
m_wndAnimation->StopAnimation();
}
void CAnimationBar2::Initialize( LPUNKNOWN pUnk )
{
m_pUnk = pUnk;
if (m_wndAnimation)
m_wndAnimation->Initialize( pUnk );
}
BEGIN_MESSAGE_MAP(CAnimationBar2, CAnimationBar2Parent)
ON_WM_CREATE()
ON_WM_SIZE()
END_MESSAGE_MAP()
int CAnimationBar2::OnCreate( LPCREATESTRUCT lpCreateStruct )
{
int res = CAnimationBar2Parent::OnCreate( lpCreateStruct );
if ( res != -1 ) {
m_wndAnimation = new CAnimation2( this, m_pUnk );
res = m_wndAnimation ? 0 : -1;
}
return res;
}
void CAnimationBar2::OnSize( UINT nType, int cx, int cy )
{
}
BOOL CAnimationBar2::OnEraseBkgnd( CDC* pDC )
{
return TRUE;
}
void CAnimationBar2::GetSize( CSize &size, BOOL bSmall /*=TRUE*/ )
{
if( !m_wndAnimation )
{
return;
}
int iFrameCount = 0;
if( CUST_IsCustomAnimation( &iFrameCount ) )
{
ASSERT( iFrameCount > 0 );
BITMAP bm;
GetObject( m_wndAnimation->GetBitmap( bSmall ), sizeof(BITMAP), &bm );
size.cx = bm.bmWidth / iFrameCount;
size.cy = bm.bmHeight;
}
else
{
size.cx = (bSmall ? ANIMATION_WIDTH : ANIMATION_WIDTH_L);
size.cy = (bSmall ? ANIMATION_HEIGHT : ANIMATION_HEIGHT_L);
}
size.cx += 4;
size.cy += 4;
}

View File

@@ -0,0 +1,112 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 _ANIMBAR2_H
#define _ANIMBAR2_H
#include "apicx.h"
class CAnimation2: public CWnd
{
protected:
LPMWCONTEXT m_pIMWContext;
SIZE m_iconSize;
int m_iFrameCount;
HBITMAP m_hAnimBitmap;
int m_iAnimationCount;
UINT m_uAnimationClock;
BOOL m_bInited;
BOOL m_bCaptured, m_bDepressed;
static HBITMAP m_hSmall;
static HBITMAP m_hBig;
static ULONG m_uRefCount;
CNSToolTip2 m_ToolTip;
BOOL m_bHaveFocus;
UINT m_hFocusTimer;
protected:
void AnimateIcon();
public:
CAnimation2( CWnd *pParent, LPUNKNOWN pUnk = NULL);
~CAnimation2();
void StopAnimation();
void StartAnimation();
void Initialize( LPUNKNOWN pUnk);
void SetBitmap( BOOL bSmall = TRUE );
HBITMAP GetBitmap( BOOL bSmall = TRUE );
void GetSize( CSize &size );
void RemoveButtonFocus();
protected:
afx_msg BOOL OnEraseBkgnd( CDC* pDC );
afx_msg void OnPaint();
afx_msg void OnTimer(UINT);
afx_msg void OnLButtonDown( UINT nFlags, CPoint point );
afx_msg void OnMouseMove( UINT nFlags, CPoint point );
afx_msg void OnLButtonUp( UINT nFlags, CPoint point );
afx_msg void OnDestroy();
afx_msg BOOL OnSetCursor( CWnd *, UINT, UINT );
DECLARE_MESSAGE_MAP()
};
#define CAnimationBar2Parent CWnd
class CAnimationBar2: public CAnimationBar2Parent
{
protected:
LPUNKNOWN m_pUnk;
POINT m_iconPt;
CAnimation2 *m_wndAnimation;
public:
CAnimationBar2(LPUNKNOWN pUnk = NULL);
~CAnimationBar2();
void StopAnimation();
void StartAnimation();
void Initialize( LPUNKNOWN pUnk);
void SetBitmap( BOOL bSmall = TRUE ) { m_wndAnimation->SetBitmap( bSmall ); }
void GetSize( CSize &size, BOOL bSmall = TRUE );
protected:
#ifdef XP_WIN32
// Attributes
// virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
#endif
afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
afx_msg void OnSize( UINT nType, int cx, int cy );
afx_msg BOOL OnEraseBkgnd( CDC* pDC );
DECLARE_MESSAGE_MAP()
};
#endif

View File

@@ -0,0 +1,72 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 "stdafx.h"
#include "animecho.h"
#include "wfedde.h"
// Static property.
CPtrList CDDEAnimationEcho::m_Registry;
void CDDEAnimationEcho::Echo(DWORD dwWindowID, DWORD dwState)
{
// Go through the registry.
CDDEAnimationEcho *pItem;
POSITION rIndex = m_Registry.GetHeadPosition();
while(rIndex != NULL)
{
pItem = (CDDEAnimationEcho*)m_Registry.GetNext(rIndex);
pItem->EchoAnimation(dwWindowID, dwState);
}
}
void CDDEAnimationEcho::DDERegister(CString &csServiceName)
{
// Just create the item. Our job's done.
CDDEAnimationEcho *pDontCare = new CDDEAnimationEcho(csServiceName);
}
BOOL CDDEAnimationEcho::DDEUnRegister(CString &csServiceName)
{
// Go through all registered items.
POSITION rIndex = m_Registry.GetHeadPosition();
CDDEAnimationEcho *pDelMe;
while (rIndex != NULL)
{
pDelMe = (CDDEAnimationEcho*)m_Registry.GetNext(rIndex);
if(pDelMe->GetServiceName() == csServiceName)
{
delete pDelMe;
return TRUE;
}
}
return FALSE;
}
void CDDEAnimationEcho::EchoAnimation(DWORD dwWindowID, DWORD dwState)
{
CDDEWrapper::AnimationEcho(this, dwWindowID, dwState);
}

View File

@@ -0,0 +1,62 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __ANIMECHO_H
// Avoid include redundancy
//
#define __ANIMECHO_H
class CDDEAnimationEcho
{
protected:
static CPtrList m_Registry;
POSITION m_rIndex;
CString m_csServiceName;
CDDEAnimationEcho(CString& csServiceName)
{
m_rIndex = m_Registry.AddTail(this);
m_csServiceName = csServiceName;
}
~CDDEAnimationEcho()
{
m_Registry.RemoveAt(m_rIndex);
}
// Must override.
void EchoAnimation(DWORD dwWindowID, DWORD dwAnimationState);
public:
CString GetServiceName() {
return(m_csServiceName);
}
// Consider these the constructor, destructor.
static void DDERegister(CString &csServiceName);
static BOOL DDEUnRegister(CString &csServiceName);
static void Echo(DWORD dwWindowID, DWORD dwAnimationState);
};
#endif // __URLECHO_H

305
mozilla/cmd/winfe/apiaddr.h Normal file
View File

@@ -0,0 +1,305 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __APIADDR_H
#define __APIADDR_H
#ifndef __APIAPI_H
#include "apiapi.h"
#endif
#ifndef __NSGUIDS_H
#include "nsguids.h"
#endif
#include "abcom.h"
typedef enum {NC_NameComplete, NC_Expand, NC_RFC822, NC_None} NameCompletionEnum;
class IAddressParent
{
public:
virtual void AddedItem (
HWND hwnd,
LONG id,
int index
) = 0;
virtual int ChangedItem (
char * pString,
int index,
HWND hwnd,
char ** ppFullName,
unsigned long* entryID,
UINT* bitmapID
) = 0;
virtual void DeletedItem (
HWND hwnd,
LONG id,
int index
) = 0;
virtual char * NameCompletion (
char * pString
) = 0;
virtual void StartNameCompletionSearch(
void
)=0;
virtual void StopNameCompletionSearch(
void
)=0;
virtual void SetProgressBarPercent(
int32 lPercent
)=0;
virtual void SetStatusText(
const char* pMessage
)=0;
virtual CWnd *GetOwnerWindow(
void
)=0;
};
typedef IAddressParent * LPADDRESSPARENT;
// Address control API
#define APICLASS_ADDRESSCONTROL "AddressControl"
typedef struct {
ULONG ulHeaderType;
char * szAddress;
UINT idBitmap;
ULONG idEntry;
} NSADDRESSLIST;
typedef NSADDRESSLIST * LPNSADDRESSLIST;
#define WM_CHILDLOSTFOCUS WM_USER+600
#define WM_LEAVINGLASTFIELD WM_USER+601
#define WM_UPDATEHEADERTYPE WM_USER+602
#define WM_UPDATEHEADERCONTENTS WM_USER+603
#define WM_NOTIFYSELECTIONCHANGE WM_USER+604
#define WM_DISPLAYTYPELIST WM_USER+605
class CNSAddressList;
class CNSAddressTypeControl;
class IAddressControl
{
public:
virtual BOOL AddAddressType (
char * pszChoice,
UINT pidBitmap = 0,
BOOL bExpand = TRUE,
BOOL bHidden = FALSE,
BOOL bExclusive = FALSE,
DWORD dwUserData = 0
) = 0;
virtual void SetDefaultBitmapId (
int id = 0
) = 0;
virtual int GetDefaultBitmapId (
void
) = 0;
virtual BOOL RemoveSelection (
int nIndex = -1
) = 0;
virtual int AppendEntry (
BOOL expandName = TRUE,
LPCTSTR szType = 0,
LPCTSTR szName = 0,
UINT idBitmap = 0,
unsigned long idEntry = 0
) = 0;
virtual int InsertEntry(
int nIndex,
BOOL expandName = TRUE,
LPCTSTR szType = 0,
LPCTSTR szName = 0,
UINT idBitmap = 0,
unsigned long idEntry = 0
) = 0;
virtual BOOL SetEntry (
int nIndex,
LPCTSTR szType = 0,
LPCTSTR szName = 0,
UINT idBitmap = 0,
unsigned long idEntry = 0
) = 0;
virtual BOOL GetEntry (
int nIndex,
char ** szType = 0,
char ** szName = 0,
UINT * idBitmap = 0,
unsigned long * idEntry = 0
) = 0;
virtual int GetItemFromPoint(
LPPOINT point
) = 0;
virtual BOOL DeleteEntry (
int nIndex
) = 0;
virtual int FindEntry (
int nStart,
LPCTSTR lpszName
) = 0;
virtual BOOL Create (
CWnd *pParent,
int id = 1000
) = 0;
virtual CListBox * GetAddressTypeComboBox (
void
) = 0;
virtual CEdit * GetAddressNameField (
void
) = 0;
virtual void SetItemName (
int nIndex,
char * text
) = 0;
virtual void SetItemBitmap (
int nIndex,
UINT id
) = 0;
virtual void SetItemEntryID (
int nIndex,
unsigned long id
) = 0;
virtual void SetControlParent (
LPADDRESSPARENT pIAddressParent
) = 0;
virtual int GetAddressList (
LPNSADDRESSLIST * ppAdressList
) = 0;
virtual int SetAddressList (
LPNSADDRESSLIST pAddressList,
int count
) = 0;
virtual CListBox * GetListBox(
void
) = 0;
virtual BOOL IsCreated(
void
) = 0;
virtual int SetSel(
int nIndex,
BOOL bSelected
) = 0;
virtual void SetContext(
MWContext *pContext
) = 0;
virtual MWContext *GetContext(
void
) = 0;
#define ADDRESS_TYPE_FLAG UINT
#define ADDRESS_TYPE_FLAG_VALUE 0x1
#define ADDRESS_TYPE_FLAG_HIDDEN 0x2
#define ADDRESS_TYPE_FLAG_EXCLUSIVE 0x4
#define ADDRESS_TYPE_FLAG_BITMAP 0x8
#define ADDRESS_TYPE_FLAG_USER 0x10
virtual void GetTypeInfo(
int nIndex,
ADDRESS_TYPE_FLAG flag,
void ** value
) = 0;
virtual void EnableParsing(
BOOL bParse = TRUE
) = 0;
virtual BOOL GetEnableParsing(
void
)=0;
virtual void EnableExpansion(
BOOL bExpand = TRUE
)=0;
virtual BOOL GetEnableExpansion(
void
)=0;
virtual void SetCSID (
int16 csid = 0
) = 0;
virtual void ShowNameCompletionPicker(
CWnd *pParent = NULL
)=0;
virtual void StartNameCompletion(
int nIndex = -1
)=0;
virtual void StopNameCompletion(
int nIndex = -1,
BOOL bEraseCookie = TRUE
)=0;
virtual void SetEntryHasNameCompletion(
BOOL bHasNameCompletion = TRUE,
int nIndex = -1
)=0;
virtual BOOL GetEntryHasNameCompletion(
int nIndex = -1
)=0;
virtual void SetNameCompletionCookieInfo(
AB_NameCompletionCookie *pCookie,
int nNumResults,
NameCompletionEnum ncEnum,
int nIndex = -1)=0;
virtual void GetNameCompletionCookieInfo(
AB_NameCompletionCookie **pCookie,
int *pNumResults,
int nIndex = -1)=0;
};
typedef IAddressControl * LPADDRESSCONTROL;
#define ApiAddressControl(v,unk) APIPTRDEF(IID_IAddressControl,IAddressControl,v,unk)
#endif

View File

@@ -0,0 +1,610 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "apiapi.h" // get all global interfaces
class CAPIList {
protected:
CAPIList * m_pNext;
CAPIList * m_pPrevious;
void * m_pData;
public:
CAPIList(void * pData = NULL);
~CAPIList();
long elements(void);
CAPIList * Add(void * element);
CAPIList * Remove(void * element);
void * GetAt (int element);
inline CAPIList * GetNext(void) {
return m_pNext;
}
inline CAPIList * GetPrevious(void) {
return m_pPrevious;
}
inline CAPIList * SetNext(CAPIList * pElement) {
CAPIList * pNext = m_pNext;
m_pNext = pElement;
return pNext;
}
inline CAPIList * SetPrevious(CAPIList * pElement) {
CAPIList * pPrevious = m_pPrevious;
m_pPrevious = pElement;
return pPrevious;
}
inline void * GetData(void) { return m_pData; }
};
CAPIList::CAPIList(void * pData)
{
m_pNext = NULL;
m_pPrevious = NULL;
SetNext(this);
SetPrevious(this);
m_pData = pData;
}
CAPIList::~CAPIList()
{
assert(m_pNext);
assert(m_pPrevious);
GetPrevious()->SetNext(GetNext());
GetNext()->SetPrevious(GetPrevious());
}
CAPIList * CAPIList::Add(void * element)
{
CAPIList * pNode = new CAPIList(element);
CAPIList * pOld = SetNext(pNode);
pNode->SetNext(pOld);
pOld->SetPrevious(pNode);
pNode->SetPrevious(this);
return pNode;
}
long CAPIList::elements(void)
{
CAPIList * pNode = this;
long lcount = 0;
do {
lcount++;
pNode = pNode->GetNext();
} while (pNode != this);
return lcount;
}
CAPIList * CAPIList::Remove(void * element)
{
BOOL found = FALSE;
CAPIList * pNode = this;
do {
if (pNode->GetData() == element) {
found = TRUE;
break;
}
pNode = pNode->GetNext();
} while (pNode != this);
if (found) {
if (GetNext() == this) {
delete this;
return NULL;
}
else {
CAPIList * ptr = pNode->GetPrevious();
delete pNode;
return ptr;
}
}
return this;
}
void * CAPIList::GetAt ( int element )
{
CAPIList * pNode = this;
do {
if (!element)
return pNode->GetData();
element--;
pNode = pNode->GetNext();
} while (pNode != this);
return NULL;
}
// the API repository implements the APIAPI interface and maintains
// the list of APIs, their IDs, and reference counts.
class ApiEntry {
protected:
LPUNKNOWN m_pUnk;
APISIGNATURE m_apiSig;
public:
ApiEntry(LPUNKNOWN pUnk = NULL, APISIGNATURE apiSig = NULL ) {
m_pUnk =pUnk;
m_apiSig = apiSig;
}
inline LPUNKNOWN GetUnk() { return m_pUnk; }
inline APISIGNATURE GetSig() { return m_apiSig; }
inline void SetSig(APISIGNATURE apiSig) { m_apiSig = apiSig; }
inline void SetUnk(LPUNKNOWN pUnk) { m_pUnk = pUnk; }
};
class ClassFactory { // class factory entries
public:
LPCLASSFACTORY m_pClassFactory; // class instance creation factory
char * m_pszClassName; // name of class
BOOL m_bIsLoaded; // is class factory loaded?
char * m_pszModuleName; // module containing class factory
HMODULE m_hModule; // factory dll instance
CAPIList * m_ApiList; // list of api instances
ClassFactory (char * pszClassName, LPCLASSFACTORY pFactory, char * pszModule = 0 );
~ClassFactory();
LPUNKNOWN CreateClassInstance(LPUNKNOWN pUnkOuter, APISIGNATURE apiSig = NULL);
LPUNKNOWN GetFirst(void);
LPUNKNOWN GetNext(LPUNKNOWN);
void Insert(LPUNKNOWN pUnk,APISIGNATURE apiSig = NULL);
void Remove(LPUNKNOWN);
LPUNKNOWN LocateBySignature(APISIGNATURE);
BOOL AttemptToLoad(void);
};
void ClassFactory::Insert(
LPUNKNOWN pUnk,
APISIGNATURE apiSig
)
{
if (!m_ApiList) {
m_ApiList = new CAPIList((void*)(new ApiEntry(pUnk,apiSig)));
}
else {
m_ApiList = m_ApiList->Add((void*)(new ApiEntry(pUnk,apiSig)));
}
}
void ClassFactory::Remove(LPUNKNOWN pUnk)
{
if (m_ApiList) {
ApiEntry * pEntry;
for (int i = 0; i < m_ApiList->elements(); i++) {
pEntry = (ApiEntry *)m_ApiList->GetAt(i);
assert(pEntry);
if (pEntry->GetUnk() == pUnk) {
m_ApiList = m_ApiList->Remove((void*)pEntry);
delete pEntry;
return;
}
}
}
}
LPUNKNOWN ClassFactory::GetFirst(void)
{
if (!m_ApiList)
return 0;
if (!m_ApiList->elements())
return 0;
return ((ApiEntry *)(m_ApiList->GetAt(0)))->GetUnk();
}
LPUNKNOWN ClassFactory::GetNext(LPUNKNOWN pUnk)
{
if (m_ApiList) {
for (int i = 0; i < m_ApiList->elements() - 1; i++)
if (((ApiEntry*)m_ApiList->GetAt(i))->GetUnk() == (void*)pUnk)
return ((ApiEntry*)m_ApiList->GetAt(i+1))->GetUnk();
}
return 0;
}
LPUNKNOWN ClassFactory::LocateBySignature(APISIGNATURE apiSig)
{
if (!apiSig || !m_ApiList)
return NULL;
ApiEntry * pEntry;
for (int i = 0; i < m_ApiList->elements(); i++) {
pEntry = (ApiEntry*)m_ApiList->GetAt(i);
if (APISIGCMP(pEntry->GetSig(),apiSig))
return pEntry->GetUnk();
}
return NULL;
}
ClassFactory::ClassFactory(char * pszClassName, LPCLASSFACTORY pFactory, char * pszModule)
{
assert(pszClassName);
m_pClassFactory = pFactory;
m_pszClassName = strdup(pszClassName);
m_hModule = NULL;
m_ApiList = NULL;
if (pszModule != 0) {
m_pszModuleName = strdup(pszModule);
m_bIsLoaded = FALSE;
}
else {
m_bIsLoaded = TRUE;
m_pszModuleName = NULL;
}
}
ClassFactory::~ClassFactory()
{
if (m_pszClassName != NULL)
free (m_pszClassName);
if (m_pszModuleName != NULL)
free (m_pszModuleName);
if (m_hModule != NULL)
FreeLibrary(m_hModule);
int elements;
elements = m_ApiList ? (int)m_ApiList->elements( ): 0;
while ( elements ) {
ApiEntry * pEntry = (ApiEntry *)m_ApiList->GetAt(elements - 1);
assert(pEntry);
LPUNKNOWN entry = (LPUNKNOWN)pEntry->GetUnk();
// FIXME release objects here!
if (entry)
while (entry->Release())
;
delete pEntry;
elements--;
}
}
LPUNKNOWN ClassFactory::CreateClassInstance(
LPUNKNOWN pUnkOuter,
APISIGNATURE apiSig)
{
assert(m_pClassFactory);
LPUNKNOWN pUnknown;
if (m_pClassFactory->CreateInstance(
pUnkOuter, IID_IUnknown, (LPVOID*)&pUnknown) == NOERROR)
Insert(pUnknown,apiSig);
return pUnknown;
}
class ClassRepository : public CGenericFactory,
public IApiapi {
protected:
ULONG m_ulRefCount;
CAPIList * m_ClassList;
// lookup attempts to find an API entry based on id
ClassFactory * Lookup (char * pszClassName);
ClassFactory * GetFirst(void);
ClassFactory * GetNext(ClassFactory *);
void Remove(ClassFactory*);
public:
ClassRepository ( );
~ClassRepository ( );
// IClassFactory Interface
STDMETHODIMP CreateInstance(LPUNKNOWN,REFIID,LPVOID*);
// IApiapi interface
LPUNKNOWN GetFirstInstance(APICLASS lpszClassName);
LPUNKNOWN GetNextInstance(APICLASS lpszClassName, LPUNKNOWN pUnk );
void * GetFirstApiInstance( REFIID refiid, LPUNKNOWN * ppUnk);
int RemoveInstance( LPUNKNOWN pUnk );
LPUNKNOWN CreateClassInstance (
APICLASS lpszClassName,LPUNKNOWN pUnkOuter,APISIGNATURE apiSig);
int RegisterClassFactory (
APICLASS lpszClassName, LPCLASSFACTORY pClassFactory, char * szModuleName = 0);
};
ClassRepository::ClassRepository ( )
{
m_ClassList = NULL;
RegisterClassFactory(APICLASS_APIAPI,(LPCLASSFACTORY)this);
}
ClassRepository::~ClassRepository ( )
{
if (m_ClassList) {
int elements = (int)m_ClassList->elements( );
while ( elements ) {
elements--;
}
}
}
STDMETHODIMP ClassRepository::CreateInstance(
LPUNKNOWN pUnkOuter,REFIID refiid, LPVOID * ppvObj)
{
*ppvObj = NULL;
ClassRepository * pRepository = new ClassRepository;
return pRepository->QueryInterface(refiid,ppvObj);
}
int ClassRepository::RemoveInstance( LPUNKNOWN pUnk )
{
if (m_ClassList) {
int elements = (int) m_ClassList->elements();
int i;
for ( i = 0; i < elements; i++ ) {
ClassFactory * entry = (ClassFactory *)m_ClassList->GetAt(i);
entry->Remove(pUnk);
}
}
return 0;
}
ClassFactory * ClassRepository::GetFirst(void)
{
if (!m_ClassList)
return 0;
if (!m_ClassList->elements())
return 0;
return (ClassFactory *)m_ClassList->GetAt(0);
}
ClassFactory * ClassRepository::GetNext(ClassFactory * pFactory)
{
if (m_ClassList) {
for (int i = 0; i < m_ClassList->elements() - 1; i++)
if (m_ClassList->GetAt(i) == (void*)pFactory)
return (ClassFactory *)m_ClassList->GetAt(i+1);
}
return 0;
}
void ClassRepository::Remove(ClassFactory * pFactory)
{
if (m_ClassList)
m_ClassList = m_ClassList->Remove((void*)pFactory);
}
LPUNKNOWN ClassRepository::CreateClassInstance(
APICLASS lpszClassName,
LPUNKNOWN pUnkOuter,
APISIGNATURE apiSig )
{
ClassFactory * pFactory = Lookup(lpszClassName);
if (pFactory) {
if (apiSig) {
LPUNKNOWN pUnk;
if ((pUnk = pFactory->LocateBySignature(apiSig)) != NULL)
return pUnk;
}
return pFactory->CreateClassInstance(pUnkOuter,apiSig);
}
return NULL;
}
BOOL ClassFactory::AttemptToLoad(void)
{
if ((!m_pszModuleName) || m_bIsLoaded)
return FALSE;
// attempt to load the interface module (DLL)
m_hModule = LoadLibrary (m_pszModuleName);
if (m_hModule > (HMODULE)32) {
// The class factory initializer is the first routine in the DLL.
APIBOOTER fpApiInitialize =
(APIBOOTER)GetProcAddress(m_hModule,MAKEINTRESOURCE(1));
// if we got a valid initializer, then call it with the
// class name. This was the module can initialize one at
// a time if it likes.
if (fpApiInitialize != NULL ) {
m_bIsLoaded = TRUE;
if ((*fpApiInitialize)(m_pszClassName))
return TRUE;
}
else
m_bIsLoaded = FALSE;
}
else {
// couldn't load the module
char szMessage[1024];
sprintf ( szMessage, "Cannot load module: %.800s\nClass factory %800s",
m_pszModuleName, m_pszClassName);
MessageBox ( 0, szMessage, "Interface Error", MB_OK | MB_ICONEXCLAMATION );
}
return FALSE;
}
ClassFactory * ClassRepository::Lookup ( char * pszClassName )
{
// get the number of stored elements
if (m_ClassList) {
int elements = (int) m_ClassList->elements();
int i;
// look up the api
for ( i = 0; i < elements; i++ ) {
ClassFactory * entry = (ClassFactory *)m_ClassList->GetAt(i);
if (!stricmp(entry->m_pszClassName, pszClassName)) {
if (!entry->m_bIsLoaded)
if (entry->AttemptToLoad())
return entry;
else
return 0;
return entry;
}
}
}
return 0;
}
int ClassRepository::RegisterClassFactory (
char * pszClassName,
LPCLASSFACTORY pClassFactory,
char * szModuleName )
{
ClassFactory * pClassEntry;
if ((pClassEntry = Lookup (pszClassName)) != 0) {
pClassEntry->m_pClassFactory = pClassFactory;
return 1;
}
else {
pClassEntry = new ClassFactory ( pszClassName, pClassFactory, szModuleName);
if (!m_ClassList)
m_ClassList = new CAPIList((void*)pClassEntry);
else
m_ClassList = m_ClassList->Add ((void*)pClassEntry );
}
return 0;
}
void * ClassRepository::GetFirstApiInstance( REFIID refiid, LPUNKNOWN * ppUnk)
{
void * pSomeInterface;
*ppUnk = 0;
ClassFactory * pClass = GetFirst();
while (pClass) {
LPUNKNOWN pUnk = pClass->GetFirst();
while (pUnk) {
if (pUnk->QueryInterface(refiid,(LPVOID*)&pSomeInterface) == NOERROR) {
*ppUnk = pUnk;
return pSomeInterface;
}
pUnk = pClass->GetNext(pUnk);
}
pClass = GetNext(pClass);
}
return NULL;
}
// function looks up an API by id and returns a void pointer which in
// turn can be cast to the requested interface type. This is done
// for you by the Api<id,interf> template.
LPUNKNOWN ClassRepository::GetFirstInstance ( char * pszClassName )
{
if (m_ClassList) {
for (int i = 0; i < m_ClassList->elements(); i++) {
ClassFactory * pClassFactory = (ClassFactory *)m_ClassList->GetAt(i);
if (!stricmp(pClassFactory->m_pszClassName, pszClassName)) {
if (pClassFactory->m_ApiList)
return ((ApiEntry*)pClassFactory->m_ApiList->GetAt(0))->GetUnk();
return NULL;
}
}
}
return NULL;
}
LPUNKNOWN ClassRepository::GetNextInstance ( char * pszClassName, LPUNKNOWN pUnk )
{
if (m_ClassList) {
for (int i = 0; i < m_ClassList->elements(); i++) {
ClassFactory * pClassFactory = (ClassFactory *)m_ClassList->GetAt(i);
if (!stricmp(pClassFactory->m_pszClassName, pszClassName)) {
CAPIList * pList = pClassFactory->m_ApiList;
if (pList)
for (int j = 0; j<pList->elements()-1; j++)
if (((ApiEntry*)pList->GetAt(j))->GetUnk() == pUnk)
return ((ApiEntry*) pClassFactory->m_ApiList->GetAt(j+1))->GetUnk();
return NULL;
}
}
}
return NULL;
}
// The apiapi object MUST be constructed first, this pragma ensures that
// the static constructor will occur before any other static construction
// happens.
#pragma warning( disable : 4074 )
#pragma init_seg(compiler)
static ClassRepository classRepository;
// global function gets the ApiApi from the static repository
// From here, all registered APIs can be retrieved and set
API_PUBLIC(LPAPIAPI) GetAPIAPI()
{
return (LPAPIAPI) &classRepository;
}
// Generic Objects
// Generic Factory
STDMETHODIMP CGenericFactory::QueryInterface(REFIID refiid, LPVOID * ppv)
{
*ppv = NULL;
if (IsEqualIID(refiid,IID_IUnknown))
*ppv = (LPUNKNOWN) this;
else if (IsEqualIID(refiid,IID_IClassFactory))
*ppv = (LPCLASSFACTORY) this;
if (*ppv != NULL) {
AddRef();
return NOERROR;
}
return ResultFromScode(E_NOINTERFACE);
}
STDMETHODIMP_(ULONG) CGenericFactory::AddRef(void)
{
return ++m_ulRefCount;
}
STDMETHODIMP_(ULONG) CGenericFactory::Release(void)
{
ULONG ulRef;
ulRef = --m_ulRefCount;
if (m_ulRefCount == 0) ;
// delete this;
return ulRef;
}
STDMETHODIMP CGenericFactory::CreateInstance(
LPUNKNOWN pUnkOuter,REFIID refiid, LPVOID * ppvObj)
{
return NULL;
// User Implemented
}
STDMETHODIMP CGenericFactory::LockServer(BOOL fLock)
{
return NOERROR;
}
// Generic Object
STDMETHODIMP CGenericObject::QueryInterface(REFIID refiid, LPVOID * ppv)
{
return ResultFromScode(E_NOINTERFACE);
}
STDMETHODIMP_(ULONG) CGenericObject::AddRef(void)
{
return ++m_ulRefCount;
}
STDMETHODIMP_(ULONG) CGenericObject::Release(void)
{
ULONG ulRef;
ulRef = --m_ulRefCount;
if (m_ulRefCount == 0) {
classRepository.RemoveInstance(this);
delete this;
}
return ulRef;
}

191
mozilla/cmd/winfe/apiapi.h Normal file
View File

@@ -0,0 +1,191 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// APIAPI.H This header file containes the main api repository
// interface. Use the APIAPI to register interfaces and retrieve
// registered interfaces.
#ifndef __APIAPI_H
#define __APIAPI_H
#ifdef _WIN32
#include "objbase.h"
#else
#include <memory.h>
#include "compobj.h"
#endif
#include "assert.h"
#define APIID(id,x) DEFINE_GUID(id,0x30611040 + x,0x8c7a,0x11cf,0xac,0x4c,0x44,0x45,0x53,0x54,0x00,0x00);
APIID(IID_IApiapi,0); // base id
typedef enum {
ApiPrivate = 0x0,
ApiPublic
} APIEXPORT;
typedef int (*APIBOOTER)(char *);
typedef char * APICLASS;
typedef void * APISIGNATURE;
#define APISIGCMP(a,b) ((a)==(b))
#define APICLASS_APIAPI "APIAPI"
class IApiapi {
public:
virtual LPUNKNOWN GetFirstInstance (
APICLASS lpszClassName
) = 0;
virtual LPUNKNOWN GetNextInstance (
APICLASS lpszClassName,
LPUNKNOWN pUnk
) = 0;
virtual void * GetFirstApiInstance (
REFIID refiid,
LPUNKNOWN * ppUnk
) = 0;
virtual int RemoveInstance(
LPUNKNOWN pUnk
) = 0;
virtual LPUNKNOWN CreateClassInstance (
APICLASS lpszClassName,
LPUNKNOWN pUnkOuter = NULL,
APISIGNATURE apiSig = 0
) = 0;
virtual int RegisterClassFactory (
APICLASS lpszClassName,
LPCLASSFACTORY pUnknown,
char * szModuleName = 0
) = 0;
};
typedef IApiapi * LPAPIAPI;
#ifdef WIN32
#ifdef __BORLANDC__
#define API_PUBLIC(__x) __x
#else
#define API_PUBLIC(__x) _declspec(dllexport) __x
#endif
#else
#define API_PUBLIC(__x) __x _cdecl _export _loadds
#endif
extern "C" {
API_PUBLIC(LPAPIAPI) GetAPIAPI(void);
}
class ApiApi {
public:
IApiapi * m_Apiapi;
ApiApi ( )
{
m_Apiapi = GetAPIAPI();
assert(m_Apiapi);
}
IApiapi * operator -> ( )
{
return m_Apiapi;
}
};
class ApiPtr {
protected:
LPUNKNOWN m_pUnknown;
void * m_pSomeInterface;
public:
ApiPtr ( REFIID apiid, LPUNKNOWN pUnknown = 0 )
{
if (!pUnknown) {
LPAPIAPI pApiapi = GetAPIAPI();
assert(pApiapi);
m_pSomeInterface = pApiapi->GetFirstApiInstance(apiid,&m_pUnknown);
m_pUnknown = NULL;
}
else {
m_pUnknown = pUnknown;
assert(pUnknown->QueryInterface(apiid,(LPVOID*)&m_pSomeInterface)==NOERROR);
}
}
~ApiPtr ( )
{
if (m_pUnknown)
m_pUnknown->Release();
}
void * GetAPI ( )
{
return m_pSomeInterface;
}
};
#define APIPTRDEF(apiid,i,v,unk) ApiPtr v##_ptr(apiid,unk); \
i * v = (i *)v##_ptr.GetAPI();
#define ApiApiPtr(v) LPAPIAPI v = GetAPIAPI()
#define DECLARE_FACTORY(f) static f __##f
// Generic Classes
class CGenericObject : public IUnknown
{
protected:
ULONG m_ulRefCount;
public:
CGenericObject ( ) {
m_ulRefCount = 0;
}
virtual ~CGenericObject() {}
// IUnknown Interface
STDMETHODIMP QueryInterface(REFIID,LPVOID *);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
};
class CGenericFactory : public IClassFactory
{
protected:
ULONG m_ulRefCount;
public:
CGenericFactory ( ) {
m_ulRefCount = 0;
}
// IUnknown Interface
STDMETHODIMP QueryInterface(REFIID,LPVOID *);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
// IClassFactory Interface
STDMETHODIMP CreateInstance(LPUNKNOWN,REFIID,LPVOID*);
STDMETHODIMP LockServer(BOOL);
};
#endif

176
mozilla/cmd/winfe/apichrom.h Executable file
View File

@@ -0,0 +1,176 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 APICHROM_H
#define APICHROM_H
#ifndef __APIAPI_H
#include "apiapi.h"
#endif
#ifndef __NSGUIDS_H
#include "nsguids.h"
#endif
#define APICLASS_CHROME "Chrome"
#define APICLASS_NSTOOLBAR "NSToolBar"
class CToolbarButton;
class CCustToolbar;
class INSToolBar: public IUnknown {
public:
// Initialization
virtual int Create( CFrameWnd *pParent,
DWORD dwStyle = WS_CHILD|WS_VISIBLE|CBRS_TOP,
UINT nID = AFX_IDW_TOOLBAR ) = 0;
virtual void SetSizes( SIZE sizeButton,
SIZE sizeImage ) = 0;
virtual void SetButtons( const UINT *lpIDArray,
int nIDCount, UINT nBitmapID = 0 ) = 0;
virtual void SetButtonStyle( UINT nIDButtonCommand, DWORD dwButtonStyle ) = 0;
virtual void GetButtonRect( UINT nIDButtonCommand, RECT * pRect ) = 0;
virtual void AddButton( CToolbarButton *pButton, int index = -1 ) = 0;
virtual void RemoveAllButtons() = 0;
virtual CToolbarButton *RemoveButton( int index ) = 0;
virtual CToolbarButton *GetButtonByIndex(int index) = 0;
virtual CToolbarButton *GetButtonByID(int nCmd) = 0;
virtual BOOL LoadBitmap( LPCSTR lpszResourceName ) = 0;
// State
virtual void SetToolbarStyle( int nToolbarStyle ) = 0;
virtual void Show( BOOL bShow = TRUE ) = 0;
// should the buttons be the same width or their own size
virtual void SetButtonsSameWidth(BOOL bSameWidth) = 0;
// Data Access
virtual HWND GetHWnd() = 0;
};
typedef INSToolBar *LPNSTOOLBAR;
class CNetscapeStatusBar;
class INSStatusBar: public IUnknown {
public:
virtual int Create( CWnd* pParentWnd,
DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_BOTTOM,
UINT nID = AFX_IDW_STATUS_BAR,
BOOL bxxx = TRUE, BOOL bTaskbar = TRUE ) = 0;
virtual void Attach( CNetscapeStatusBar *pBar ) = 0;
// Messages
virtual void SetStatusText(const char * = NULL) = 0;
virtual const char *GetStatusText() = 0;
// Progress
virtual void SetProgress(int = 0) = 0;
virtual int GetProgress() = 0;
virtual void ProgressComplete() = 0;
// Create/Remove a modal status window
virtual void ModalStatus( BOOL bModal, UINT uDelay, char * szTitle = NULL ) = 0;
virtual void Show( BOOL bShow = TRUE ) = 0;
virtual HWND GetHWnd() = 0;
// status mode cues
virtual void StartAnimation() = 0;
virtual void StopAnimation() = 0;
};
typedef INSStatusBar *LPNSSTATUSBAR;
#define ApiToolBar(v,unk) APIPTRDEF(IID_INSToolBar,INSToolBar,v,unk)
class INSAnimation: public IUnknown {
public:
virtual void StartAnimation() = 0;
virtual void StopAnimation() = 0;
};
typedef INSAnimation *LPNSANIMATION;
#define ApiAnimation(v,unk) APIPTRDEF(IID_INSAnimation,INSAnimation,v,unk)
class IChrome: public IUnknown {
public:
// Initialization
virtual void Initialize(CFrameWnd *pWnd) = 0;
virtual BOOL procTabNavigation( UINT nChar, UINT forward, UINT controlKey ) = 0;
// Menu bar stuff
virtual void SetMenu( UINT ) = 0;
// General Toolbar functionality
virtual void UpdateURLBars(char* url) = 0;
virtual void ShowToolbar(UINT nToolbarID, BOOL bShow = TRUE) = 0;
virtual BOOL GetToolbarVisible(UINT nToolbarID) = 0;
virtual CWnd *GetToolbar(UINT nToolbarID) = 0;
virtual void SetToolbarFocus(UINT nToolbarID) = 0;
// nPos, bOpen, and bShowing are IN/OUT parameters. Values going in are default values and values
// coming out are the values from the registry or default if not in the registry.
virtual void LoadToolbarConfiguration(UINT nToolbarID, CString &csToolbarName, int32 & nPos, BOOL & bOpen, BOOL & bShowing) = 0;
virtual void SaveToolbarConfiguration(UINT nToolbarID, CString &csToolbarName) = 0;
virtual void SetSaveToolbarInfo(BOOL bSaveToolbarInfo) = 0;
// Animation Stuff
virtual void StartAnimation() = 0;
virtual void StopAnimation() = 0;
// Configurable Toolbar Manager stuff
virtual int CreateRDFToolbar(CString toolbarName, int nMaxToolbars, BOOL bHasAnimation)=0;
virtual int CreateCustomizableToolbar(CString toolbarName, int nMaxToolbars, BOOL bHasAnimation)=0;
virtual int CreateCustomizableToolbar(UINT nStringID, int nMaxToolbars, BOOL bHasAnimation) = 0;
virtual CString GetCustToolbarString() = 0;
virtual void RenameCustomizableToolbar(UINT nStringID) = 0;
virtual void FinishedAddingBrowserToolbars()=0;
virtual void SetToolbarStyle( int nToolbarStyle )=0;
virtual BOOL CustToolbarShowing()=0;
virtual void ViewCustToolbar(BOOL bShow) = 0;
virtual void Customize()=0;
virtual CCustToolbar * GetCustomizableToolbar() = 0;
// MainFrame's Toolbar Stuff
virtual void ImagesButton(BOOL) = 0;
// Window Title Stuff
virtual void SetWindowTitle(const char *) = 0;
virtual void SetDocumentTitle(const char *) = 0;
};
typedef IChrome * LPCHROME;
#define ApiChrome(v,unk) APIPTRDEF(IID_IChrome,IChrome,v,unk)
#endif

80
mozilla/cmd/winfe/apicx.h Executable file
View File

@@ -0,0 +1,80 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 _APICX_H
#define _APICX_H
#ifndef __APIAPI_H
#include "apiapi.h"
#endif
#ifndef __NSGUIDS_H
#include "nsguids.h"
#endif
// Define these for graceful type coping
typedef struct MWContext_ MWContext;
typedef struct URLStruct_ URLStruct;
typedef struct PrintSetup_ PrintSetup;
class IMWContext: public IUnknown
{
public:
// The context functions of the class, all pure virtual at this level.
// This is a special hack to autogenerate the functions as pure virtual.
// See the header mk_cx_fn.h for more insight.
// This more or less must be the first thing done in the class, to get all the
// virtual tables correct in classes to come.
#define FE_DEFINE(funkage, returns, args) virtual returns funkage args = 0;
#include "mk_cx_fn.h"
// The URL exit routine.
// This is called by CFE_GetUrlExitRoutine, which should be passed as the exit routine
// in any calls to NET_GetURL....
virtual void GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext) = 0;
// The text translation exit routine.
// This is called by CFE_TextTranslationExitRoutine, which should be passed as the exit
// routine in any calls to XL_TranslateText....
virtual void TextTranslationExitRoutine(PrintSetup *pTextFE) = 0;
// XP Context accessor
virtual MWContext *GetContext() const = 0;
// This function is very important.
// It allows you to write code which can detect when a context
// is actually in the process of being destroyed.
// In many cases, you will receive callbacks from the XP libraries
// while the context is being destroyed. If you GPF, then use
// this function to better detect your course of action.
virtual BOOL IsDestroyed() const = 0;
// Function to load a URL with this context, with the custom exit routing handler.
// Use this to NET_GetURL instead or XL_TranslateText instead.
virtual int GetUrl(URL_Struct *pUrl, FO_Present_Types iFormatOut, BOOL bReallyLoad = TRUE, BOOL bForceNew = FALSE) = 0;
// Generic brain dead interface to load a URL.
// This used to be known as OnNormalLoad.
virtual int NormalGetUrl(const char *pUrl, const char *pReferrer = NULL, const char *pTarget = NULL, BOOL bForceNew = FALSE) = 0;
};
typedef IMWContext *LPMWCONTEXT;
#endif

109
mozilla/cmd/winfe/apiimg.h Executable file
View File

@@ -0,0 +1,109 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __APIIMG_H
#define __APIIMG_H
#ifndef __APIAPI_H
#include "apiapi.h"
#endif
#ifndef __NSGUIDS_H
#include "nsguids.h"
#endif
#define APICLASS_IMAGEMAP "ImageMap"
class IImageMap
{
public:
virtual int Initialize (
unsigned int rcid,
int width,
int height
) = 0;
// Please use these draw functions instead of the MFC ones below
virtual void DrawImage (
int index,
int x,
int y,
HDC hDestDC,
BOOL bButton
) = 0;
virtual void DrawTransImage (
int index,
int x,
int y,
HDC hDestDC
) = 0;
// Please don't use these functions, they are obsolete
// and provided only for compatibility
virtual void DrawImage (
int index,
int x,
int y,
CDC * hDestDC,
BOOL bButton
) = 0;
virtual void DrawTransImage (
int index,
int x,
int y,
CDC * hDestDC
) = 0;
virtual void ReInitialize (
void
) = 0;
virtual void UseNormal (
void
) = 0;
virtual void UseHighlight (
void
) = 0;
virtual int GetImageHeight (
void
) = 0;
virtual int GetImageWidth (
void
) = 0;
virtual int GetImageCount (
void
) = 0;
virtual unsigned int GetResourceID (
void
) = 0;
};
typedef IImageMap * LPIMAGEMAP;
#define ApiImageMap(v,unk) APIPTRDEF(IID_IImageMap,IImageMap,v,unk)
#endif

101
mozilla/cmd/winfe/apimsg.h Executable file
View File

@@ -0,0 +1,101 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 _APIMSG_H
#define _APIMSG_H
#ifndef __APIAPI_H
#include "apiapi.h"
#endif
#ifndef __NSGUIDS_H
#include "nsguids.h"
#endif
#include "msgcom.h"
/////////////////////////////////////////////////////////////////////
// This interface applies to those MSG_Panes that are compose windows
class IMsgCompose: public IUnknown {
public:
// Initialization/Demolition
virtual void InitializeMailCompositionContext( MSG_Pane* comppane,
const char *from,
const char *reply_to,
const char *to,
const char *cc,
const char *bcc,
const char *fcc,
const char *newsgroups,
const char *followup_to,
const char *subject,
const char *attachment ) = 0;
virtual void RaiseMailCompositionWindow( MSG_Pane* comppane ) = 0;
virtual void DestroyMailCompositionContext( MWContext* context ) = 0;
// Misc Operations
virtual void UpdateToolbar ( MSG_Pane* comppane ) = 0;
virtual void MsgShowHeaders ( MSG_Pane* comppane, MSG_HEADER_SET headers ) = 0;
virtual char *PromptMessageSubject( MSG_Pane* comppane ) = 0;
// Message Operations
virtual void InsertMessageCompositionText( MSG_Pane* comppane,
const char *text,
XP_Bool leaveCursorAtBeginning) = 0;
virtual int GetMessageBody( MSG_Pane* comppane,
char **body,
uint32 *body_size,
MSG_FontCode **font_changes ) = 0;
virtual void DoneWithMessageBody(MSG_Pane* comppane, char* body,
uint32 body_size) = 0;
};
typedef IMsgCompose *LPMSGCOMPOSE;
///////////////////////////////////////////////////////////
// This interface applies to those MSG_Panes that are lists
class IMsgList: public IUnknown {
public:
// Operations
virtual void ListChangeStarting( MSG_Pane* pane, XP_Bool asynchronous,
MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
int32 num) = 0;
virtual void ListChangeFinished( MSG_Pane* pane, XP_Bool asynchronous,
MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
int32 num) = 0;
virtual void GetSelection( MSG_Pane* pane, MSG_ViewIndex **indices, int *count,
int *focus) = 0;
virtual void SelectItem( MSG_Pane* pane, int item ) = 0;
virtual void CopyMessagesInto( MSG_Pane *pane, MSG_ViewIndex *indices, int count,
MSG_FolderInfo *folderInfo) = 0;
virtual void MoveMessagesInto( MSG_Pane *pane, MSG_ViewIndex *indices, int count,
MSG_FolderInfo *folderInfo) = 0;
};
typedef IMsgList *LPMSGLIST;
/* Unfiled:
MSG_Pane* FE_CreateCompositionPane( MWContext *context);
char* FE_GetTempFileFor( MWContext *context, const char *fname,
XP_FileType ftype, XP_FileType *rettype);
void FE_UpdateBiff( MSG_BIFF_STATE state );
uint32 FE_DiskSpaceAvailable (MWContext *context, const char *dir);
*/
#endif

View File

@@ -0,0 +1,213 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __APIOUTLN_H
#define __APIOUTLN_H
#ifndef __APIAPI_H
#include "apiapi.h"
#endif
#ifndef __NSGUIDS_H
#include "nsguids.h"
#endif
#define APICLASS_OUTLINERPARENT "OutlinerParent"
#define APICLASS_OUTLINER "Outliner"
typedef enum {
ColumnFixed,
ColumnVariable
} Column_t;
typedef enum {
CropNone = 0,
CropCenter,
CropRight,
CropLeft
} CropType_t;
typedef enum {
AlignLeft,
AlignRight,
AlignCenter
} AlignType_t;
#define OUTLINER_RETURN 1
#define OUTLINER_LBUTTONDOWN 2
#define OUTLINER_LBUTTONUP 3
#define OUTLINER_RBUTTONDOWN 4
#define OUTLINER_RBUTTON 4 // For compatibility
#define OUTLINER_RBUTTONUP 5
#define OUTLINER_LBUTTONDBLCLK 6
#define OUTLINER_KEYDOWN 7
#define OUTLINER_PROPERTIES 8
#define OUTLINER_TIMER 9
#define OUTLINER_SET 10
class COutliner; // temporary hack
class IOutliner {
public:
virtual void EnableTips (
BOOL = TRUE
) = 0;
virtual BOOL GetTipsEnabled (
void
) = 0;
virtual void SetCSID (
int csid
) = 0;
virtual int GetCSID (
void
) = 0;
virtual int AddColumn (
LPCTSTR header,
UINT idCol,
int iMinCol,
int iMaxCol = 10000,
Column_t cType = ColumnFixed,
int iPercent = 50,
BOOL bIsButton = TRUE,
CropType_t ct = CropRight,
AlignType_t at = AlignLeft
) = 0;
virtual int GetColumnSize (
UINT idCol
) = 0;
virtual void SetColumnSize (
UINT idCol,
int iSize
) = 0;
virtual int GetColumnPercent (
UINT idCol
) = 0;
virtual void SetColumnPercent (
UINT idCol,
int iPercent
) = 0;
virtual int GetColumnPos(
UINT idCol
) = 0;
virtual void SetColumnPos(
UINT idCol,
int iColumn
) = 0;
virtual void SetColumnName (
UINT idCol,
LPCTSTR pName
) = 0;
virtual LPCTSTR GetColumnName (
UINT idCol
) = 0;
virtual void SetImageColumn(
UINT idCol
) = 0;
virtual void SetHasPipes(
BOOL bPipes
) = 0;
virtual void SetVisibleColumns(
UINT iVisCol
) = 0;
virtual UINT GetVisibleColumns(
void
) = 0;
virtual void SelectItem (
int iSel,
int mode = OUTLINER_SET,
UINT flags = 0
) = 0;
virtual BOOL DeleteItem (
int iLine
) = 0;
virtual void ScrollIntoView(
int iVisibleLine
) = 0;
virtual int GetFocusLine(
void
) = 0;
virtual void SetTotalLines(
int
) = 0;
virtual int GetTotalLines(
void
) = 0;
};
typedef IOutliner * LPIOUTLINER;
#define ApiOutliner(v,unk) APIPTRDEF(IID_IOutliner,IOutliner,v,unk)
class IOutlinerParent {
public:
virtual void EnableBorder (
BOOL = TRUE
) = 0;
virtual void EnableHeaders (
BOOL = TRUE
) = 0;
virtual void SetOutliner (
COutliner * pIOutliner
) = 0;
virtual COutliner * GetOutliner (
void
) = 0;
virtual void CreateColumns (
void
) = 0;
virtual BOOL ColumnCommand (
int idColumn
) = 0;
virtual BOOL RenderData (
int idColumn,
CRect & rect,
CDC & dc,
LPCTSTR lpsz = NULL
) = 0;
};
typedef IOutlinerParent * LPIOUTLINERPARENT;
#define ApiOutlinerParent(v,unk) APIPTRDEF(IID_IOutlinerParent,IOutlinerParent,v,unk)
#endif

118
mozilla/cmd/winfe/apipage.h Normal file
View File

@@ -0,0 +1,118 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// apiprint.h contains the page setup api
#ifndef __APIPAGE_H
#define __APIPAGE_H
#ifndef __APIAPI_H
#include "apiapi.h"
#endif
#ifndef __NSGUIDS_H
#include "nsguids.h"
#endif
// APIID_Printer (IPrinter interface)
// this interface is used to retrieve and set information from
// the page setup object. The functions are pretty self
// explanatory. A -1 gets the current value in the single
// argument function calls.
class IPageSetup {
public:
virtual void GetMargins (
long * plLeft,
long * plRight,
long * plTop,
long * plBottom
) = 0;
virtual void SetMargins (
long lLeft,
long lRight,
long lTop,
long lBottom
) = 0;
virtual void GetPageSize (
long * lWidth,
long * lHeight
) = 0;
virtual void SetPageSize (
long lWidth,
long lHeight
) = 0;
virtual void SetPrintingBkImage (BOOL flag) = 0;
virtual BOOL IsPrintingBkImage (void) = 0;
#define PRINT_TITLE 1
#define PRINT_URL 2
// -1 = Get state
// 0 = disable
//
// 1 (01) = title
// 2 (10) = location (URL)
// combinable with OR
virtual int Header (
int flag = -1
) = 0;
#define PRINT_PAGENO 1
#define PRINT_PAGECOUNT 2
#define PRINT_DATE 4
// -1 = Get state
// 0 = disable
//
// 1 (001) = page #
// 2 (010) = total page count
// 4 (100) = date printed
// combinable with OR
virtual int Footer (
int flag = -1
) = 0;
virtual int SolidLines (
int flag = -1
) = 0;
virtual int BlackText (
int flag = -1
) = 0;
virtual int BlackLines (
int flag = -1
) = 0;
virtual int ReverseOrder (
int flag = -1
) = 0;
};
typedef IPageSetup * LPPAGESETUP;
#define APICLASS_PAGESETUP "PageSetup"
#define ApiPageSetup(v,unk) APIPTRDEF(IID_IPageSetup,IPageSetup,v,unk)
#endif

99
mozilla/cmd/winfe/apitab.h Executable file
View File

@@ -0,0 +1,99 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 _APITAB_H
#define _APITAB_H
#ifndef __APIAPI_H
#include "apiapi.h"
#endif
#ifndef __NSGUIDS_H
#include "nsguids.h"
#endif
#define APICLASS_TABCONTROL "TabControl"
//
// Message send to parent
//
// Notify that a tab is about the change. The message handler
// can return non-zero to prevent the user from changing
// the tab.
#ifndef TCM_TABCHANGING
#define TCM_TABCHANGING (WM_USER + 200)
#endif
// Notify tab changed. The message handler can use
// GetCurSel to determine the new page.
#ifndef TCM_TABCHANGED
#define TCM_TABCHANGED (WM_USER + 201)
#endif
#undef INTERFACE
#define INTERFACE ITabControl
DECLARE_INTERFACE_(ITabControl, IUnknown)
{
// Attributes
// Returns the height of the tab control
STDMETHOD_(int, GetHeight) (THIS) const PURE;
// Returns the currently selected tag (0 based index)
STDMETHOD_(int, GetCurSel) (THIS) const PURE;
// Returns the number of tabs
STDMETHOD_(int, GetItemCount) (THIS) const PURE;
// Returns the HWND of the tab control
STDMETHOD_(HWND, GetHWnd) (THIS) const PURE;
// Returns the tab under a given point (in client coords)
STDMETHOD_(int, TabFromPoint) (const POINT *pt) PURE;
// Operations
// Creates a TabControl. Takes normal window styles.
STDMETHOD(Create) (THIS_ DWORD dwStyle, const RECT *rect, HWND hParent, UINT nID) PURE;
// Adds a tab with caption and image with index iImage (-1 for no image)
STDMETHOD(AddTab) (THIS_ LPCTSTR lpszCaption, int iImage) PURE;
// Removed tab nTab (0 based index)
STDMETHOD(RemoveTab) (THIS_ int nTab) PURE;
// Show/Hide tab nTab (0 based index)
STDMETHOD(ShowTab) (THIS_ int nTab, BOOL bShow = TRUE) PURE;
// Select tab nTab (0 based index)
STDMETHOD(SetCurSel) (THIS_ int nTab) PURE;
// Sets the bitmap for the tab images
STDMETHOD(LoadBitmap) (THIS_ UINT id) PURE;
// Set the size of each tab image
STDMETHOD(SetSizes) (THIS_ const SIZE *size) PURE;
// Change the text of a tab
STDMETHOD(SetText) (THIS_ int idx, LPCSTR lpszCaption) PURE;
};
typedef ITabControl * LPTABCONTROL;
#define ApiTabControl(v,unk) APIPTRDEF(IID_ITabControl,ITabControl,v,unk)
#endif

View File

@@ -0,0 +1,139 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// AskMeDlg.cpp : implementation file
//
#include "stdafx.h"
#include "askmedlg.h"
#include "prefapi.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
void AskMeDlg(void)
{
int32 nPromptAskMe = FALSE;
PREF_GetIntPref("offline.startup_state", &nPromptAskMe);
if(nPromptAskMe == 0) //old setting (note, network.online gets initialized before
//user prefs read in so we have to reset this now
{
XP_Bool boolPref = FALSE;
PREF_GetBoolPref("network.online", &boolPref);
PREF_SetBoolPref("network.online", !boolPref);
PREF_SetBoolPref("network.online", boolPref);
}
else if (nPromptAskMe==1) //askme
{
CAskMeDlg rAskMeDlg(nPromptAskMe);
rAskMeDlg.DoModal();
}
}
/////////////////////////////////////////////////////////////////////////////
// CAskMeDlg dialog
CAskMeDlg::CAskMeDlg(BOOL bDefault/*FALSE*/, int nOnOffLine/*0-the default*/,
CWnd* pParent /*=NULL*/)
: CDialog(CAskMeDlg::IDD, pParent)
{
XP_Bool bOnline = TRUE;
PREF_GetBoolPref("network.online", &bOnline);
//{{AFX_DATA_INIT(CAskMeDlg)
m_nStartupSelection = (bOnline == 1 ? 0 : 1);
m_bAskMeDefault = 0;
//}}AFX_DATA_INIT
}
void CAskMeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAskMeDlg)
DDX_Radio(pDX, IDC_RADIO_ONLINE, m_nStartupSelection);
DDX_Check(pDX, IDC_CHECK_ASKME_DEFAULT, m_bAskMeDefault);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAskMeDlg, CDialog)
//{{AFX_MSG_MAP(CAskMeDlg)
ON_BN_CLICKED(IDC_CHECK_ASKME_DEFAULT, OnCheckAskMeDefault)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAskMeDlg message handlers
void CAskMeDlg::OnOK()
{
//Save any preference settings that may have been chosen
CDialog::OnOK();
UpdateData();
if (IsDlgButtonChecked(IDC_CHECK_ASKME_DEFAULT))
{
//remember previous setting the next time we exit.
PREF_SetIntPref("offline.startup_state",0);
}
if (IsDlgButtonChecked(IDC_RADIO_ONLINE))
PREF_SetBoolPref("network.online", TRUE);
else
PREF_SetBoolPref("network.online", FALSE);
}
void CAskMeDlg::OnCheckAskMeDefault()
{
}
void CAskMeDlg::EnableDisableItem(BOOL bState, UINT nIDC)
{
CWnd *pWnd = GetDlgItem(nIDC);
if (pWnd)
{
pWnd->EnableWindow(bState);
}
}
BOOL CAskMeDlg::OnInitDialog()
{
BOOL bReturn = CDialog::OnInitDialog();
CWnd *pWnd = NULL;
HFONT hFont = (HFONT)this->SendMessage(WM_GETFONT);
if (hFont != NULL)
{ //make the title bold
VERIFY(::GetObject(hFont, sizeof(LOGFONT), &m_LogFont));
m_LogFont.lfWeight=FW_BOLD;
m_hFont = theApp.CreateAppFont( m_LogFont );
::SendMessage(::GetDlgItem(m_hWnd, IDC_STATIC_TITLE), WM_SETFONT, (WPARAM)m_hFont, FALSE);
::SendMessage(::GetDlgItem(m_hWnd, IDC_RADIO_ONLINE), WM_SETFONT, (WPARAM)m_hFont, FALSE);
::SendMessage(::GetDlgItem(m_hWnd, IDC_RADIO_OFFLINE), WM_SETFONT, (WPARAM)m_hFont, FALSE);
::SendMessage(::GetDlgItem(m_hWnd, IDC_CHECK_ASKME_DEFAULT), WM_SETFONT, (WPARAM)m_hFont, FALSE);
}
return bReturn;
}

View File

@@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// AskMeDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CAskMeDlg dialog
class CAskMeDlg : public CDialog
{
// Construction
public:
CAskMeDlg(BOOL bDefault = FALSE, int nOnOffLine = 0, CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CAskMeDlg)
enum { IDD = IDD_ASKME_DIALOG };
int m_nStartupSelection;
BOOL m_bAskMeDefault;
//}}AFX_DATA
LOGFONT m_LogFont;
HFONT m_hFont;
public:
BOOL GetDefaultMode() const {return m_bAskMeDefault;};
BOOL GetStartupSelection() const {return m_nStartupSelection;};
void SetDefaultMode(BOOL bDefaultMode) {m_bAskMeDefault = bDefaultMode;};
void SetStartupSelection(int nStartupSelection) {m_nStartupSelection = nStartupSelection;};
void EnableDisableItem(BOOL bState, UINT nIDC);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAskMeDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAskMeDlg)
virtual void OnOK();
afx_msg void OnCheckAskMeDefault();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

109
mozilla/cmd/winfe/attachdl.h Executable file
View File

@@ -0,0 +1,109 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// attachdl.h : header file
//
#include "msgctype.h"
#include "mmnmsg.h"
/////////////////////////////////////////////////////////////////////////////
// CAttachDlg dialog
class CAttachDlg : public CDialog
{
// Construction
public:
CAttachDlg( MSG_Pane * pPane = NULL,
char * pUrl = NULL, CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CAttachDlg)
enum { IDD = IDD_MULTIATTACH };
CButton m_DeleteButton;
CButton m_AsIsButton;
CButton m_ConvertButton;
CListBox m_AttachmentList;
int m_bAsIs;
//}}AFX_DATA
char * m_pUrl;
MSG_Pane * m_pPane;
MSG_Pane * GetMsgPane() { return m_pPane; }
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAttachDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
void CleanupAttachList(void);
// Generated message map functions
//{{AFX_MSG(CAttachDlg)
afx_msg void OnAttachfile();
afx_msg void OnAttachurl();
afx_msg void OnConvert();
afx_msg void OnDelete();
afx_msg void OnAsis();
virtual void OnOK();
virtual void OnCancel();
virtual BOOL OnInitDialog();
afx_msg void OnSelchangeAttachments();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// CLocationDlg dialog
class CLocationDlg : public CDialog
{
// Construction
public:
CLocationDlg(char * pUrl = NULL, CWnd* pParent = NULL); // standard constructor
char * m_pUrl;
// Dialog Data
//{{AFX_DATA(CLocationDlg)
enum { IDD = IDD_ATTACHLOCATION };
CEdit m_LocationBox;
CString m_Location;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLocationDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CLocationDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

552
mozilla/cmd/winfe/authdll.cpp Executable file
View File

@@ -0,0 +1,552 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* ****************************************************************************
*
*/
#include "stdafx.h"
#include <windows.h>
#include <ole2.h>
#include "DAIntf.h"
#include "xp.h"
#include <initguid.h>
#include "DAIntf.h"
/* ****************************************************************************
*
*/
class CDALoader
{
IDAProcess *m_pIDAProcess;
public:
CDALoader(void);
~CDALoader(void);
IDAProcess *Load(void);
IDAProcess *Interface(void) { return m_pIDAProcess; }
};
/* ****************************************************************************
*
*/
CDALoader::CDALoader(void)
: m_pIDAProcess(NULL)
{
}
/* ****************************************************************************
*
*/
CDALoader::~CDALoader(void)
{
if (m_pIDAProcess)
{
m_pIDAProcess->Release();
CoUninitialize();
}
}
/* ****************************************************************************
*
*/
IDAProcess * CDALoader::Load(void)
{
static tried_once = FALSE;
if (m_pIDAProcess)
{
return m_pIDAProcess;
}
if(tried_once)
return NULL;
else
tried_once = TRUE;
if (SUCCEEDED(CoInitialize(NULL)))
{
if (SUCCEEDED(CoCreateInstance(CLSID_DA,
NULL,
CLSCTX_INPROC_SERVER,
IID_IDAProcess,
(LPVOID *)&m_pIDAProcess)))
{
return m_pIDAProcess;
}
CoUninitialize();
}
return NULL;
}
/* ****************************************************************************
*
*/
PRIVATE XP_List * address_auth_list = 0;
static CDALoader g_DA;
/* ****************************************************************************
*
*/
class CDAPacket : public IDAPacket
{
LONG m_cRef;
char * m_pPassedInHeader;
public:
CDAPacket(char *pHeader);
~CDAPacket(void);
char * m_pNewHeaders;
// IUnknown methods.
STDMETHOD_(ULONG, AddRef)(THIS);
STDMETHOD_(ULONG, Release)(THIS);
STDMETHOD(QueryInterface)(THIS_
REFIID riid,
LPVOID *ppvObject);
// IDAPacket methods.
STDMETHOD(AddNameValue)(THIS_
const TCHAR *pszName,
const TCHAR *pszValue);
STDMETHOD(FindValue)(THIS_
const TCHAR *pszName,
const TCHAR *pszSubName,
TCHAR * pszValue,
DWORD cbValue) const;
STDMETHOD(ReplaceNameValue)(THIS_
const TCHAR *pszName,
const TCHAR *pszValue);
};
/* ****************************************************************************
*
*/
struct address_auth_assoc {
char *address;
CDAPacket *auth;
};
/* ****************************************************************************
*
*/
CDAPacket::CDAPacket(char *pPassedInHeader)
: m_cRef(1),
m_pNewHeaders(NULL)
{
m_pPassedInHeader = pPassedInHeader;
}
/* ****************************************************************************
*
*/
CDAPacket::~CDAPacket(void)
{
if(m_pNewHeaders)
XP_FREE(m_pNewHeaders);
}
/* ****************************************************************************
*
*/
STDMETHODIMP_(ULONG) CDAPacket::AddRef(void)
{
#ifdef WIN32
return InterlockedIncrement(&m_cRef);
#else
return ++m_cRef;
#endif
}
/* ****************************************************************************
*
*/
STDMETHODIMP_(ULONG) CDAPacket::Release(void)
{
#ifdef WIN32
return InterlockedDecrement(&m_cRef);
#else
return --m_cRef;
#endif
}
/* ****************************************************************************
*
*/
STDMETHODIMP CDAPacket::QueryInterface
(
REFIID riid,
LPVOID * ppvObject
)
{
if (!ppvObject)
{
return ResultFromScode(E_INVALIDARG);
}
*ppvObject = NULL;
if (riid == IID_IDAPacket)
{
*ppvObject = (IDAPacket *)this;
} else if (riid == IID_IUnknown)
{
*ppvObject = (IUnknown *)this;
}
else
{
return ResultFromScode(E_NOINTERFACE);
}
AddRef();
return NOERROR;
}
/* ****************************************************************************
*
*/
STDMETHODIMP CDAPacket::AddNameValue
(
const TCHAR *pszName,
const TCHAR *pszValue
)
{
if (!pszName || !pszValue)
{
return ResultFromScode(E_FAIL);
}
if(m_pNewHeaders)
{
char * tmp = m_pNewHeaders;
m_pNewHeaders = PR_smprintf("%s%s: %s"CRLF,
tmp ? tmp : "",
pszName,
pszValue);
XP_FREE(tmp);
}
else
{
m_pNewHeaders = PR_smprintf("%s: %s"CRLF,
pszName,
pszValue);
}
return NOERROR;
}
/* ****************************************************************************
*
*/
STDMETHODIMP CDAPacket::FindValue
(
const TCHAR *pszName,
const TCHAR *pszSubName,
TCHAR * pszValue,
DWORD cbValue
) const
{
#define WWW_AUTHENTICATE "WWW-Authenticate"
if(strncasecomp(pszName, WWW_AUTHENTICATE, sizeof(WWW_AUTHENTICATE) - 1))
return ResultFromScode(E_FAIL); /* not a valid name */
if(pszSubName == NULL)
{
strncpy(pszValue, "Remote-Passphrase", CASTSIZE_T(cbValue));
pszValue[cbValue-1] = '\0';
return (NOERROR);
}
char *token;
while((token = strcasestr(m_pPassedInHeader, pszSubName)))
{
/* look for an immediate equal and then a quote
*/
char *cp = token;
char *end_of_value;
cp += XP_STRLEN(pszSubName);
while(isspace(*cp)) cp++;
if(*cp != '=')
continue;
while(isspace(*cp)) cp++;
if(*++cp != '"')
continue;
end_of_value = strchr(++cp, '"');
if(!end_of_value)
return ResultFromScode(E_FAIL);
*end_of_value = '\0';
if(end_of_value - cp > (ptrdiff_t)cbValue)
{
*end_of_value = '"';
return ResultFromScode(E_FAIL);
}
XP_STRCPY(pszValue, cp);
*end_of_value = '"';
return (NOERROR);
}
return ResultFromScode(E_FAIL);
}
/* ****************************************************************************
*
*/
STDMETHODIMP CDAPacket::ReplaceNameValue
(
const TCHAR *pszName,
const TCHAR *pszValue
)
{
return ResultFromScode(E_NOTIMPL);
}
/* ****************************************************************************
*
*/
PRIVATE char *GetMethod(URL_Struct *URL_s)
{
if(URL_s->method == URL_POST_METHOD)
return XP_STRDUP("POST");
else if(URL_s->method == URL_HEAD_METHOD)
return XP_STRDUP("HEAD");
else
return XP_STRDUP("GET");
}
/* ****************************************************************************
*
*/
extern "C" int
WFE_DoCompuserveAuthenticate(MWContext *context,
URL_Struct *URL_s,
char *authenticate_header_value)
{
struct address_auth_assoc * assoc_obj = 0;
struct address_auth_assoc * cur_assoc_ptr;
CDAPacket *auth;
XP_List *list_ptr;
char *host;
HRESULT status;
// Load the DA OLE server if it hasn't already been loaded.
IDAProcess *pIDAProcess = g_DA.Interface();
if (!pIDAProcess)
{
return NET_AUTH_FAILED_DISPLAY_DOCUMENT;
}
if(!address_auth_list)
{
address_auth_list = XP_ListNew();
if(!address_auth_list)
return NET_AUTH_FAILED_DISPLAY_DOCUMENT;
}
/* search for an existing association */
list_ptr = address_auth_list;
while((cur_assoc_ptr = (address_auth_assoc *)XP_ListNextObject(list_ptr)))
{
if(!XP_STRCMP(cur_assoc_ptr->address, URL_s->address))
{
assoc_obj = cur_assoc_ptr;
break;
}
}
if(assoc_obj)
{
XP_ListRemoveObject(address_auth_list, assoc_obj);
delete assoc_obj->auth;
XP_FREE(assoc_obj->address);
XP_FREE(assoc_obj);
}
if(URL_s->server_status != 200
&& URL_s->server_status != 401)
return(FALSE);
auth = new CDAPacket(authenticate_header_value);
auth->m_pNewHeaders = XP_STRDUP("Extension: Security/Remote-Passphrase"CRLF);
host = NET_ParseURL(URL_s->address, GET_HOST_PART);
if(URL_s->server_status == 401)
{
struct SDAAuthData auth_data_struct;
char username[256] = "";
char password[256] = "";
char realm[256] = "";
char * path = NET_ParseURL(URL_s->address, GET_PATH_PART | GET_SEARCH_PART);
auth_data_struct.pIDAPacketIn = auth;
auth_data_struct.pszHost = host;
auth_data_struct.pszURI = path;
auth_data_struct.pszMethod = GetMethod(URL_s);
auth_data_struct.pIDAPacketOut = auth;
auth_data_struct.bShowDialog = 1;
auth_data_struct.hParent = NULL;
auth_data_struct.pszUsername = username;
auth_data_struct.wMaxUsername = sizeof(username) - 1;
auth_data_struct.pszRealmname = realm;
auth_data_struct.pszPassword = password;
auth_data_struct.wMaxPassword = sizeof(password) - 1;
auth_data_struct.pIDAPassword = NULL;
status = pIDAProcess->On401Authenticate(&auth_data_struct);
if(status == NOERROR)
{
assoc_obj = XP_NEW(struct address_auth_assoc);
if(!assoc_obj)
return NET_AUTH_FAILED_DISPLAY_DOCUMENT;
assoc_obj->auth = auth;
assoc_obj->address = XP_STRDUP(URL_s->address);
XP_ListAddObject(address_auth_list, assoc_obj);
XP_FREE(host);
return(NET_RETRY_WITH_AUTH);
}
}
else
{
status = pIDAProcess->On200Authenticate(host, auth);
}
XP_FREE(host);
delete(auth);
if(status != NOERROR)
return(NET_AUTH_FAILED_DONT_DISPLAY);
else
return(NET_AUTH_SUCCEEDED);
}
/* ****************************************************************************
*
*/
extern "C" char *
WFE_BuildCompuserveAuthString(URL_Struct *URL_s)
{
XP_List * list_ptr;
struct address_auth_assoc *cur_assoc_ptr;
struct address_auth_assoc *assoc_obj = NULL;
static char *rv=NULL; /* malloc and free on successive calls */
IDAProcess *pIDAProcess = g_DA.Load();
if(pIDAProcess)
{
/* search for an existing association */
list_ptr = address_auth_list;
while((cur_assoc_ptr = (address_auth_assoc *)XP_ListNextObject(list_ptr)))
{
if(!XP_STRCMP(cur_assoc_ptr->address, URL_s->address))
assoc_obj = cur_assoc_ptr;
}
if(assoc_obj)
{
/* since we found it in the assoc list then
* we have gotten a 401 and are about to
* send another request. Send the
* header.
*/
return(assoc_obj->auth->m_pNewHeaders);
}
/* if we didn't find it in the assoc list then
* call the cheat routine to see if we need
* to send any headers
*/
if(rv)
{
XP_FREE(rv);
rv = NULL;
}
HRESULT status = ResultFromScode(E_FAIL);
char * host = NET_ParseURL(URL_s->address, GET_HOST_PART);
char * path = NET_ParseURL(URL_s->address, GET_PATH_PART | GET_SEARCH_PART);
char * method = GetMethod(URL_s);
if(host && path && method)
{
CDAPacket daPacket("");
status = pIDAProcess->Cheat(host, path, method, &daPacket);
rv = XP_STRDUP(daPacket.m_pNewHeaders);
}
if(host)
XP_FREE(host);
if(path)
XP_FREE(path);
if(method)
XP_FREE(method);
}
return(rv);
}

684
mozilla/cmd/winfe/button.cpp Executable file
View File

@@ -0,0 +1,684 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// button.cpp : implementation file
//
#include "stdafx.h"
#include "fmabstra.h"
#include "button.h"
#include "libevent.h"
#include <windowsx.h>
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
#ifndef _AFXDLL
#define new DEBUG_NEW // MSVC Debugging new...goes to regular new in release mode
#endif
#ifndef _WIN32
#define GET_WM_COMMAND_CMD(wp, lp) ((UINT)HIWORD(lp))
#endif
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CNetscapeButton dialog
IMPLEMENT_DYNAMIC(CNetscapeButton, CButton)
CNetscapeButton::CNetscapeButton(MWContext * context, LO_FormElementStruct * form, CWnd* pParent)
{
m_Context = context;
m_Form = form;
m_bDepressed = FALSE;
m_pwndEdit = NULL;
m_pPaneCX = PANECX(m_Context);
m_callBase = FALSE;
}
BEGIN_MESSAGE_MAP(CNetscapeButton, CButton)
ON_WM_CHAR()
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
ON_WM_LBUTTONDBLCLK()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_RBUTTONDBLCLK()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNetscapeButton message handlers
/////////////////////////////////////////////////////////////////////////////
//
// Called when the 'submit' event has been processed
//
static void
button_submit_closure(MWContext * pContext, LO_Element * pEle, int32 event,
void * pObj, ETEventStatus status)
{
if(status != EVENT_OK || !pEle || !pContext)
return;
FE_SubmitInputElement(pContext, pEle);
}
//
// Called when the 'click' event has been processed
//
static void
button_click_closure(MWContext * pContext, LO_Element * pEle, int32 event,
void * pObj, ETEventStatus status)
{
// make sure every thing is OK
if(status == EVENT_PANIC || !pEle || !pContext)
return;
CNetscapeButton * pButton = (CNetscapeButton *) pObj;
LO_FormElementStruct * pForm = (LO_FormElementStruct *) pEle;
lo_FormElementMinimalData * min_data;
lo_FormElementToggleData * tog_data;
min_data = (lo_FormElementMinimalData *) pForm->element_data;
if(!min_data)
return;
if(status == EVENT_OK) {
switch(min_data->type) {
case FORM_TYPE_SUBMIT:
// send the event to libmocha --- do any further processing
// in our closure routine
JSEvent *event;
event = XP_NEW_ZAP(JSEvent);
event->type = EVENT_SUBMIT;
event->layer_id = pForm->layer_id;
ET_SendEvent(pContext, pEle, event,
button_submit_closure, pObj);
break;
case FORM_TYPE_RESET:
// libmocha has said it was OK to allow the reset to happen
// tell layout to go forward with the operation
// the world may not be safe after this so return
LO_ResetForm(pContext, pForm);
return;
default:
break;
}
}
else {
// Undo state operations.
switch(min_data->type) {
case FORM_TYPE_RADIO:
if(pButton->m_pLastSelectedRadio) {
tog_data = (lo_FormElementToggleData *)
pButton->m_pLastSelectedRadio->element_data;
if(!tog_data->toggled)
LO_FormRadioSet(ABSTRACTCX(pContext)->GetDocumentContext(),
pButton->m_pLastSelectedRadio);
CFormElement *pRadioButton = CFormElement::GetFormElement(ABSTRACTCX(pContext),
pButton->m_pLastSelectedRadio);
if(pRadioButton) {
pRadioButton->SetFormElementToggle(tog_data->toggled);
}
}
break;
case FORM_TYPE_CHECKBOX:
tog_data = (lo_FormElementToggleData *) pForm->element_data;
if(tog_data->toggled)
tog_data->toggled = FALSE;
else
tog_data->toggled = TRUE;
if((pButton->GetCheck() ? TRUE : FALSE) != tog_data->toggled)
pButton->SetCheck(tog_data->toggled);
break;
default:
break;
}
}
}
// NFlags as per OnLButtonUp
//
//
// for FORM_TYPE_CHECKBOX, there are 3 places in this file call Click().
// 1. OnChar for space-key
// 2. OnButtonEvent, initiated by java script?
// 3. OnChildNotify maybe not necesary to handle this msg.
//
// We taggled state for 1 and 2.We do NOT taggle for 3. It always comes
// with 1 or 2. It is not clear whether item 3 is redundent, so it is
// not removed.
//
// Click() function is still called for all 3 cases.
//
// Messages interfare with debug, Trace statements are left for debuging.
//
// When change this code, please make sure radio-button and check-box
// work for both Tab-Space keys and mouse click(with out debug).
//
// Arthur 3/12/97, fix for #49682
//
void CNetscapeButton::Click(UINT nFlags, BOOL bNotify, BOOL &bReturnImmediately)
{
if(!m_Form || !m_Context)
return;
lo_FormElementMinimalData * min_data;
lo_FormElementToggleData * tog_data;
min_data = (lo_FormElementMinimalData *) m_Form->element_data;
char * pFileName;
if(!min_data)
return;
m_pLastSelectedRadio = NULL;
switch(min_data->type) {
case FORM_TYPE_RADIO:
tog_data = (lo_FormElementToggleData *) m_Form->element_data;
if(!tog_data->toggled) {
#ifdef MOZ_NGLAYOUT
XP_ASSERT(0);
#else
m_pLastSelectedRadio = LO_FormRadioSet(ABSTRACTCX(m_Context)->GetDocumentContext(), m_Form); // Turn off everyone else
#endif
}
if(GetCheck() != tog_data->toggled) {
SetCheck(tog_data->toggled);
#ifdef DEBUG_aliu
TRACE0("Set\n");
#endif // DEBUG_aliu
}
break;
case FORM_TYPE_CHECKBOX:
// Make sure we don't already reflect that state, and don't do this
// if via OnChar, as MFC/Windows will do it for us.
if(bNotify == FALSE) {
tog_data = (lo_FormElementToggleData *) m_Form->element_data;
if(tog_data->toggled) {
#ifdef DEBUG_aliu
TRACE0("Off ");
#endif // DEBUG_aliu
tog_data->toggled = FALSE;
} else {
tog_data->toggled = TRUE;
#ifdef DEBUG_aliu
TRACE0("On ");
#endif // DEBUG_aliu
}
if((GetCheck() ? TRUE : FALSE) != tog_data->toggled) {
#ifdef DEBUG_aliu
TRACE0("Set\n");
#endif // DEBUG_aliu
SetCheck(tog_data->toggled);
}
}
break;
case FORM_TYPE_BUTTON:
break;
case FORM_TYPE_RESET:
case FORM_TYPE_SUBMIT:
// don't do anything yet --- send the OnClick to libmocha first
// Sigh don't make double submits
if (bNotify == TRUE) return;
break;
case FORM_TYPE_FILE:
pFileName = wfe_GetExistingFileName(m_hWnd,
szLoadString(IDS_FILE_UPLOAD),
HTM,
TRUE);
/* update both the widget display and the lo-datastructure */
if(pFileName && m_pwndEdit) {
m_pwndEdit->SetWindowText(pFileName);
if (m_Form->element_data->ele_text.current_text)
XP_FREE(m_Form->element_data->ele_text.current_text);
m_Form->element_data->ele_text.current_text = (PA_Block) pFileName;
}
break;
default:
break;
}
// send the event to libmocha --- do any further processing
// in our closure routine
JSEvent *event;
event = XP_NEW_ZAP(JSEvent);
event->type = EVENT_CLICK;
event->layer_id = m_Form->layer_id;
event->which = 1;
event->modifiers = (nFlags & MK_SHIFT ? EVENT_SHIFT_MASK : 0)
| (nFlags & MK_CONTROL ? EVENT_CONTROL_MASK : 0)
| (GetKeyState(VK_MENU) < 0 ? EVENT_ALT_MASK : 0);
ET_SendEvent(m_Context, (LO_Element *)m_Form, event,
button_click_closure, this);
}
void CNetscapeButton::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// CButton::OnChar( nChar, nRepCnt, nFlags);
if(( nChar == VK_SPACE || nChar == VK_RETURN) && !(nFlags>>14 & 1)) {
// buttons need a push.
BOOL bReturnImmediately = FALSE;
#ifdef DEBUG_aliu
TRACE0("onCharClick ");
#endif // DEBUG_aliu
Click(0, FALSE, bReturnImmediately); //#49682 TRUE
if(bReturnImmediately) {
return;
}
}
}
void CNetscapeButton::OnSetFocus(CWnd * pWnd)
{
CButton::OnSetFocus(pWnd); //must have this for fixing #51086, ref. #49682
if(m_Context && m_Form) {
// set tab focus to this element
CWinCX *pWinCX = WINCX(m_Context);
// if ((LO_Element *)m_Form == pWinCX->getLastTabFocusElement())
// return;
pWinCX->setFormElementTabFocus( (LO_Element *)m_Form );
// send the event to libmocha --- do any further processing
// in our closure routine
JSEvent *event;
event = XP_NEW_ZAP(JSEvent);
event->type = EVENT_FOCUS;
event->layer_id = m_Form->layer_id;
ET_SendEvent(m_Context, (LO_Element *)m_Form, event,
NULL, this);
}
}
void CNetscapeButton::OnKillFocus(CWnd * pWnd)
{
CButton::OnKillFocus(pWnd);
if(m_Context && m_Form) {
// send the event to libmocha --- do any further processing
// in our closure routine
JSEvent *event;
event = XP_NEW_ZAP(JSEvent);
event->type = EVENT_BLUR;
event->layer_id = m_Form->layer_id;
ET_SendEvent(m_Context, (LO_Element *)m_Form, event, NULL, this);
}
}
void CNetscapeButton::OnLButtonDblClk(UINT uFlags, CPoint cpPoint) {
if (m_callBase) {
CButton::OnLButtonDblClk(uFlags, cpPoint);
return;
}
// Don't continue if this context is destroyed.
if(!m_Context || ABSTRACTCX(m_Context)->IsDestroyed()) {
return;
}
MapWindowPoints(GetParent(), &cpPoint, 1);
// Convert the point to something we understand.
XY Point;
m_pPaneCX->ResolvePoint(Point, cpPoint);
if (m_Context->compositor) {
CL_Event event;
fe_EventStruct fe_event;
fe_event.uFlags = uFlags;
fe_event.x = cpPoint.x;
fe_event.y = cpPoint.y;
event.type = CL_EVENT_MOUSE_BUTTON_MULTI_CLICK;
event.fe_event = (void *)&fe_event;
event.fe_event_size = sizeof(fe_EventStruct);
event.x = Point.x;
event.y = Point.y;
event.which = 1;
event.data = 2;
event.modifiers = (uFlags & MK_SHIFT ? EVENT_SHIFT_MASK : 0)
| (uFlags & MK_CONTROL ? EVENT_CONTROL_MASK : 0)
| (GetKeyState(VK_MENU) < 0 ? EVENT_ALT_MASK : 0);
CL_DispatchEvent(m_Context->compositor,
&event);
}
else
CButton::OnLButtonDblClk(uFlags, cpPoint);
return;
}
void CNetscapeButton::OnLButtonDown(UINT uFlags, CPoint cpPoint) {
if (m_callBase) {
CButton::OnLButtonDown(uFlags, cpPoint);
return;
}
// Don't continue if this context is destroyed.
if(!m_Context) {
return;
}
// Start capturing all mouse events.
if(m_hWnd) {
::SetCapture(m_hWnd);
}
MapWindowPoints(GetParent(), &cpPoint, 1);
XY Point;
m_pPaneCX->ResolvePoint(Point, cpPoint);
if (m_Context->compositor) {
CL_Event event;
fe_EventStruct fe_event;
fe_event.uFlags = uFlags;
fe_event.x = cpPoint.x;
fe_event.y = cpPoint.y;
event.type = CL_EVENT_MOUSE_BUTTON_DOWN;
event.fe_event = (void *)&fe_event;
event.fe_event_size = sizeof(fe_EventStruct);
event.x = Point.x;
event.y = Point.y;
event.which = 1;
event.modifiers = (uFlags & MK_SHIFT ? EVENT_SHIFT_MASK : 0)
| (uFlags & MK_CONTROL ? EVENT_CONTROL_MASK : 0)
| (GetKeyState(VK_MENU) < 0 ? EVENT_ALT_MASK : 0);
CL_DispatchEvent(m_Context->compositor,
&event);
}
else
CButton::OnLButtonDown(uFlags, cpPoint);
return;
}
void CNetscapeButton::OnLButtonUp(UINT uFlags, CPoint cpPoint) {
if (m_callBase) {
CButton::OnLButtonUp(uFlags, cpPoint);
return;
}
// Don't continue if this context is destroyed.
if(!m_Context) {
return;
}
// Start capturing all mouse events.
if(m_hWnd) {
::ReleaseCapture();
}
// translate mouse position to screen
CPoint cpScreenPoint(cpPoint);
ClientToScreen(&cpScreenPoint);
// Don't send the event on to JS if we're out of the button area.
if (::WindowFromPoint(cpScreenPoint) != m_hWnd) {
CButton::OnLButtonUp(uFlags, cpPoint);
m_bDepressed = FALSE;
return;
}
MapWindowPoints(GetParent(), &cpPoint, 1);
XY Point;
m_pPaneCX->ResolvePoint(Point, cpPoint);
if (m_Context->compositor) {
CL_Event event;
fe_EventStruct fe_event;
fe_event.uFlags = uFlags;
fe_event.x = cpPoint.x;
fe_event.y = cpPoint.y;
event.type = CL_EVENT_MOUSE_BUTTON_UP;
event.fe_event = (void *)&fe_event;
event.fe_event_size = sizeof(fe_EventStruct);
event.x = Point.x;
event.y = Point.y;
event.which = 1;
event.modifiers = (uFlags & MK_SHIFT ? EVENT_SHIFT_MASK : 0)
| (uFlags & MK_CONTROL ? EVENT_CONTROL_MASK : 0)
| (GetKeyState(VK_MENU) < 0 ? EVENT_ALT_MASK : 0);
CL_DispatchEvent(m_Context->compositor,
&event);
}
else
CButton::OnLButtonUp(uFlags, cpPoint);
return;
}
void CNetscapeButton::OnRButtonDblClk(UINT uFlags, CPoint cpPoint) {
if (m_callBase) {
CButton::OnRButtonDblClk(uFlags, cpPoint);
return;
}
// Don't continue if this context is destroyed.
if(!m_Context) {
return;
}
MapWindowPoints(GetParent(), &cpPoint, 1);
XY Point;
m_pPaneCX->ResolvePoint(Point, cpPoint);
if (m_Context->compositor) {
CL_Event event;
fe_EventStruct fe_event;
fe_event.uFlags = uFlags;
fe_event.x = cpPoint.x;
fe_event.y = cpPoint.y;
event.type = CL_EVENT_MOUSE_BUTTON_MULTI_CLICK;
event.fe_event = (void *)&fe_event;
event.fe_event_size = sizeof(fe_EventStruct);
event.x = Point.x;
event.y = Point.y;
event.which = 3;
event.data = 2;
event.modifiers = (uFlags & MK_SHIFT ? EVENT_SHIFT_MASK : 0)
| (uFlags & MK_CONTROL ? EVENT_CONTROL_MASK : 0)
| (GetKeyState(VK_MENU) < 0 ? EVENT_ALT_MASK : 0);
CL_DispatchEvent(m_Context->compositor,
&event);
}
else
CButton::OnRButtonDblClk(uFlags, cpPoint);
return;
}
void CNetscapeButton::OnRButtonDown(UINT uFlags, CPoint cpPoint) {
if (m_callBase) {
CButton::OnRButtonDown(uFlags, cpPoint);
return;
}
// Don't continue if this context is destroyed.
if(!m_Context) {
return;
}
// Start capturing all mouse events.
if(m_hWnd) {
::SetCapture(m_hWnd);
}
MapWindowPoints(GetParent(), &cpPoint, 1);
XY Point;
m_pPaneCX->ResolvePoint(Point, cpPoint);
if (m_Context->compositor) {
CL_Event event;
fe_EventStruct fe_event;
fe_event.uFlags = uFlags;
fe_event.x = cpPoint.x;
fe_event.y = cpPoint.y;
event.type = CL_EVENT_MOUSE_BUTTON_DOWN;
event.fe_event = (void *)&fe_event;
event.fe_event_size = sizeof(fe_EventStruct);
event.x = Point.x;
event.y = Point.y;
event.which = 3;
event.modifiers = (uFlags & MK_SHIFT ? EVENT_SHIFT_MASK : 0)
| (uFlags & MK_CONTROL ? EVENT_CONTROL_MASK : 0)
| (GetKeyState(VK_MENU) < 0 ? EVENT_ALT_MASK : 0);
CL_DispatchEvent(m_Context->compositor,
&event);
}
else
CButton::OnRButtonDown(uFlags, cpPoint);
return;
}
void CNetscapeButton::OnRButtonUp(UINT uFlags, CPoint cpPoint) {
if (m_callBase) {
CButton::OnRButtonUp(uFlags, cpPoint);
return;
}
// Don't continue if this context is destroyed.
if(!m_Context) {
return;
}
// Start capturing all mouse events.
if(m_hWnd) {
::ReleaseCapture();
}
MapWindowPoints(GetParent(), &cpPoint, 1);
XY Point;
m_pPaneCX->ResolvePoint(Point, cpPoint);
if (m_Context->compositor) {
CL_Event event;
fe_EventStruct fe_event;
fe_event.uFlags = uFlags;
fe_event.x = cpPoint.x;
fe_event.y = cpPoint.y;
event.type = CL_EVENT_MOUSE_BUTTON_UP;
event.fe_event = (void *)&fe_event;
event.fe_event_size = sizeof(fe_EventStruct);
event.x = Point.x;
event.y = Point.y;
event.which = 3;
event.modifiers = (uFlags & MK_SHIFT ? EVENT_SHIFT_MASK : 0)
| (uFlags & MK_CONTROL ? EVENT_CONTROL_MASK : 0)
| (GetKeyState(VK_MENU) < 0 ? EVENT_ALT_MASK : 0);
CL_DispatchEvent(m_Context->compositor,
&event);
}
else
CButton::OnRButtonUp(uFlags, cpPoint);
return;
}
void
CNetscapeButton::OnButtonEvent(CL_EventType type, UINT nFlags, CPoint point) {
BOOL bReturnImmediately;
m_callBase = TRUE;
switch (type) {
case CL_EVENT_MOUSE_BUTTON_DOWN:
SendMessage(WM_LBUTTONDOWN, nFlags, MAKELONG(point.x, point.y));
// Hack since Windows stubbornly refuses to accept current state.
SetState(FALSE);
SetState(TRUE);
m_bDepressed = TRUE;
break;
case CL_EVENT_MOUSE_BUTTON_UP:
// Only send click event if button is already down.
if (m_bDepressed) {
SendMessage(WM_LBUTTONUP, nFlags, MAKELONG(point.x, point.y));
#ifdef DEBUG_aliu
TRACE0("ButtonEventClick ");
#endif // DEBUG_aliu
Click(nFlags, FALSE, bReturnImmediately);
m_bDepressed = FALSE;
}
break;
case CL_EVENT_MOUSE_BUTTON_MULTI_CLICK:
SendMessage(WM_LBUTTONDBLCLK, nFlags, MAKELONG(point.x, point.y));
break;
}
m_callBase = FALSE;
}

76
mozilla/cmd/winfe/button.h Executable file
View File

@@ -0,0 +1,76 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// button.h : header file
//
#ifndef _BUTTON_H_
#define _BUTTON_H_
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CNetscapeButton Class
class CNetscapeButton: public CButton
{
DECLARE_DYNAMIC(CNetscapeButton)
protected:
MWContext * m_Context;
LO_FormElementStruct * m_Form;
XP_Bool m_bDepressed;
CEdit * m_pwndEdit;
XP_Bool m_callBase;
CPaneCX * m_pPaneCX;
// Construction
public:
CNetscapeButton(MWContext * context, LO_FormElementStruct * form, CWnd* pParent = NULL); // standard constructor
inline void RegisterForm(LO_FormElementStruct * form) { m_Form = form; }
inline void RegisterEdit(CEdit * pEdit) { m_pwndEdit = pEdit; }
inline void RegisterContext(MWContext * context) { m_Context = context; }
// Attributes
LO_FormElementStruct* GetElement() const {return m_Form;}
// needs to be seen by closure
LO_FormElementStruct *m_pLastSelectedRadio;
// Implementation
protected:
CWnd * m_Parent;
// Generated message map functions
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnSetFocus(CWnd * pOldWnd);
afx_msg void OnKillFocus(CWnd * pNewWnd);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
DECLARE_MESSAGE_MAP()
public:
void Click(UINT nFlags, BOOL bOnChar /*= FALSE*/, BOOL &bReturnImmediately);
void OnButtonEvent(CL_EventType type, UINT nFlags, CPoint point);
};
#endif /* _BUTTON_H_ */

138
mozilla/cmd/winfe/cast.h Normal file
View File

@@ -0,0 +1,138 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __CAST_H
#define __CAST_H
// To handle casts between the various windows
// platforms.
// We use these macros/inline functions instead of just
// casting directly so that we can manipulate their
// behaviour on a broad scale, and very customized
// behaviour can be achieved if you need to range
// check values in debug mode, etc.
// PAY ATTENTION, OR WE'RE ALL DEAD:
// The use of inline functions is to avoid the over evaluation
// problem (common to macros) when repeating parameters
// in doing a computation.
// i.e.
// #define EVAL(a) ((a) + (a))
//
// EVAL(a *= a + a);
// However, by using inline function, it is not possible
// to provide every possible cast operation that macros
// do cover. This is a known shortfall. Templates were
// the solution, but it's not clear that we'll ever have
// a 16 bit compiler which supports templates. You will
// have to implement each needed cast seperately. You
// can mostly avoid the problem by using the largest possible
// data type.
// To turn off all casting in the front end which
// utilizes these macros, define NO_CAST, and get
// ready for a boatload of warnings.
//#define NO_CAST
// Now onto the show.
// GAB 09-13-95
// Native integer cast, good for use in WinAPI calls.
// In debug, we camp on you if we actually lose bits, as it
// is ambiguous if we should hold the top limit to MAXINT
// or if we should just take the lower sizeof(int) bytes
// and ignore the rest.
#ifndef NO_CAST
#ifndef _DEBUG
#define CASTINT(a) ((int)(a))
#else
inline int CASTINT(long a) {
int b = (int)a;
ASSERT(a == (long)b);
return(b);
}
#endif
#else
#define CASTINT(a) (a)
#endif
// Native unsigned cast.
// In debug, we camp on you if we actually lose bits.
#ifndef NO_CAST
#ifndef _DEBUG
#define CASTUINT(a) ((unsigned)(a))
#else
inline unsigned CASTUINT(long a) {
unsigned b = (unsigned)a;
ASSERT(a == (long)b);
return(b);
}
#endif
#else
#define CASTUINT(a) (a)
#endif
#ifndef NO_CAST
#ifndef _DEBUG
#define CASTSIZE_T(a) ((size_t)(a))
#else
inline size_t CASTSIZE_T(long a) {
size_t b = (size_t)a;
ASSERT(a == (long)b);
return(b);
}
#endif
#else
#define CASTSIZE_T(a) (a)
#endif
#ifndef NO_CAST
#ifndef _DEBUG
#define CASTDWORD(a) ((DWORD)(a))
#else
inline DWORD CASTDWORD(long a) {
DWORD b = (DWORD)a;
ASSERT(a == (long)b);
return(b);
}
#endif
#else
#define CASTDWORD(a) (a)
#endif
// NCAPI data from URL_Struct
#define NCAPIDATA(pUrl) ((CNcapiUrlData *)(pUrl)->ncapi_data)
// Context casts
#define CX2VOID(pContext, CastFromClassCX) ((void *)((CAbstractCX *)((CastFromClassCX *)(pContext))))
#define VOID2CX(pVoid, CastToClassCX) ((CastToClassCX *)((CAbstractCX *)((void *)(pVoid))))
#define ABSTRACTCX(pXPCX) ((pXPCX)->fe.cx)
#define BOOKMARKCX(pXPCX) ((CNewBookmarkWnd *)((pXPCX)->fe.cx))
#define WINCX(pXPCX) ((CWinCX *)((pXPCX)->fe.cx))
#define CXDC(pXPCX) ((CDCCX *)((pXPCX)->fe.cx))
#define PANECX(pXPCX) ((CPaneCX *)((pXPCX)->fe.cx))
#endif // __CAST_H

1547
mozilla/cmd/winfe/cfe.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,267 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
//Designed specifically for pulling out command line arugments
//used in the command line startup routine. This class knows
//about two kinds of delimeters, spaces and quotes. Quotes
//when placed in front and in back of characters delimit spaces and
//any combination of any other characters. Spaces delimit quoted
//strings and other non quoted strings. Error checking is flaged
//on quoted string groups and non quoted string which are
//not separated by a space. There is no failure continue mode.
//When an error is flaged, the routine exits and signals false.
//Command line parsing implementation file.
#include "stdafx.h"
#include "cmdparse.h"
#include <ctype.h>
/************************************************************************/
//Purpose: Contructor takes two arguments to initialize the class.
//Args: pszStringToParse: a pointer to the command line to parse
// lStringList: A reference to the list to hold the arguments
/************************************************************************/
CCmdParse::CCmdParse(char *pszStringToParse,CStringList &lStringList)
{
strcpy(m_szParseString,pszStringToParse);
m_pStringList = &lStringList;
m_nIndex = 0;
}
CCmdParse::CCmdParse()
{
m_pStringList = NULL;
m_nIndex = 0;
}
/************************************************************************/
//Purpose: Destructor removes any objects still on the list
/************************************************************************/
CCmdParse::~CCmdParse()
{
if(m_pStringList)
{
POSITION pos1,pos2;
char *pTemp = NULL;
if (m_pStringList->GetCount() > 0)
{
for( pos1 = m_pStringList->GetHeadPosition(); ( pos2 = pos1 ) != NULL; )
{
m_pStringList->GetNext( pos1 );
// Save the old pointer for
//deletion.
m_pStringList->RemoveAt( pos2 );
}
}
}
}
/************************************************************************/
//Purpose: Initialize class members and construction has taken place
/************************************************************************/
void CCmdParse::Init(char *pszStringToParse,CStringList &lStringList)
{
strcpy(m_szParseString,pszStringToParse);
m_pStringList = &lStringList;
m_nIndex = 0;
}
/************************************************************************/
//Purpose: Places the accumulated character in m_Token on the list in
// the order they were seen, and resets m_Token.
/************************************************************************/
void CCmdParse::AddNewToken()
{
CString strNew = m_Token;
m_pStringList->AddTail(strNew);
memset(m_Token,'\0',sizeof(m_Token));
m_nIndex = 0;
}
/************************************************************************/
//Purpose: State machine and token builder. This optionally could have
// been broken down into separate modules for each state; however
// due to the limited number of states and delimeters it seemed
// resonable to bundle it in this function. Additional
// functionality would require breaking this up into constituent
// subroutines.
//Called by: ProcessCmdLine();
/************************************************************************/
void CCmdParse::AddChar()
{
if (*m_pCurrent == '\0')
{ //check to see if we were in the middle of building something,
//otherwise quit.
if (strlen(m_Token) > 0)
AddNewToken();
State = e_end;
return;
}
if (State == e_start && (*m_pCurrent == '"'))
{ //we are handling a quoted string
State = e_quote;
Previous = e_start;
++m_pCurrent;
return;
}
if (State == e_start && ((*m_pCurrent != '"') && (!isspace(*m_pCurrent))) )
{ //we are handling a non quoted string
State = e_other;
Previous = e_start;
return;
}
if (State == e_start && (isspace(*m_pCurrent)))
{
State = e_space;
Previous = e_start;
return;
}
if (State == e_quote && (*m_pCurrent != '"'))
{ //add it to the token builder
m_Token[m_nIndex++] = *m_pCurrent++;
return;
}
if (State == e_quote && (*m_pCurrent == '"'))
{ //we found another quote.
if (*(m_pCurrent -1) == '"')
{ //look back and see if quotes are wrong
//path names must be separated by quotes!!!!
State = e_error;
return;
}
if( !isspace(*(m_pCurrent +1)) && (*(m_pCurrent +1) != '\0') )
{
//look ahead and make sure they delimeted the quoted argument
State = e_error;
return;
}
Previous = State;//not used
//set the state so we know what we last saw and can expect
State = e_end_quote;
//add the quoted string minus the quotes
AddNewToken();
return;
}
if (State == e_end_quote && (*m_pCurrent != '"'))
{ //we are expecting a space or a non quote
if(isspace(*m_pCurrent))
{
++m_pCurrent;
State = e_space;
Previous = e_end_quote;
}
else
{
State = e_other;
Previous = e_end_quote;
}
return;
}
if (State == e_end_quote && (*m_pCurrent == '"'))
{ //suscpicious
++m_pCurrent;
return;
}
if (State == e_other && ((!isspace(*m_pCurrent)) && (*m_pCurrent != '"')) )
{ //add it to the token builder
m_Token[m_nIndex++] = *m_pCurrent++;
return;
}
else if(State == e_other && (isspace(*m_pCurrent)) )
{ //add the non quoted token
AddNewToken();
Previous = e_other;
if ( isspace(*m_pCurrent) )
State = e_space;
else
State = e_start;
return;
}
else if(State == e_other && (*m_pCurrent == '"'))
{
State = e_error;
return;
}
if (State == e_space && (!isspace(*m_pCurrent) ) )
{
State = e_start;
Previous = e_space;
return;
}
if (State == e_space && (isspace(*m_pCurrent)) )
{ //eat up spaces.
while (isspace(*m_pCurrent))
++m_pCurrent;
return;
}
}
/*************************************************************************/
//Purpose: Called to start command line processing.
// This function is used in a very minimal sense. However, it
// is prepared to grow such that more detailed errors and
// potentially more states may be added to compensate for
// additional delimiters. Currently it simply calls AddChar()
// and waits for an error or state end.
//RETURNS: True on success and False on failure.
/*************************************************************************/
BOOL CCmdParse::ProcessCmdLine()
{
State = e_start;
Previous = State; //may be used in the future
m_pCurrent = &m_szParseString[0];
memset(m_Token,'\0',512);
while(State != e_end)
{
switch(State)
{
//
case e_error:
return FALSE;
default:
AddChar();
}
}
return TRUE;
}

View File

@@ -0,0 +1,48 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
//command line parser class
//takes a command line and parses out arguments separated by spaces
//and whole arguments with spaces surrounded by quotes.
enum States {e_start, e_quote,e_end_quote, e_space, e_other, e_error, e_end};
class CCmdParse
{
void AddNewToken();
void AddChar();
public:
States State;
States Previous;//currently not being used. may be later
char m_szParseString[512];
CStringList *m_pStringList;
char *m_pCurrent;
char m_Token[512];
int m_nIndex;
CCmdParse(char *pszStringToParse,CStringList &lStringList); //No need to call Init() if used
CCmdParse(); //must call Init(...,...) with this constructor prior to calling ProcessCmdLine()
~CCmdParse();
BOOL ProcessCmdLine();
void Init(char *pszStringToParse,CStringList &lStringList);
};

357
mozilla/cmd/winfe/cntritem.cpp Executable file
View File

@@ -0,0 +1,357 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// cntritem.cpp : implementation of the CNetscapeCntrItem class
//
#include "stdafx.h"
#include "cntritem.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
#ifndef XP_WIN32
#include "olenls.h"
#define OLESTR(str) str
#endif
/////////////////////////////////////////////////////////////////////////////
// CNetscapeCntrItem implementation
#ifndef _AFXDLL
#undef new
#endif
IMPLEMENT_SERIAL(CNetscapeCntrItem, COleClientItem, 0)
#ifndef _AFXDLL
#define new DEBUG_NEW
#endif
extern void FE_ConvertSpace(char *newName);
CNetscapeCntrItem::CNetscapeCntrItem(CGenericDoc* pContainer)
: COleClientItem(pContainer)
{
m_bLoading = FALSE; // Not loading.
m_bBroken = FALSE; // Not broken.
m_bDelayed = FALSE; // Not delayed.
m_iLock = 0; // No one is referencing us.
m_pOriginalItem = NULL;
m_isFullPage = FALSE;
m_isDirty = FALSE;
m_bIsOleItem = FALSE;
m_bSetExtents = FALSE;
m_bCanSavedByOLE = FALSE;
m_idSavedAs =DISPID_UNKNOWN;
}
CNetscapeCntrItem::~CNetscapeCntrItem()
{
// If we've something loaded, then release it.
if(m_bLoading == FALSE && m_bBroken == FALSE && m_bDelayed == FALSE) {
// Assuming we're valid.
Release(OLECLOSE_SAVEIFDIRTY);
}
}
void CNetscapeCntrItem::OnActivate()
{
#if _MSC_VER >= 1200
USES_CONVERSION;
#endif
char * pSource = NULL;
const char* ptr;
LPDISPATCH pdisp;
HRESULT hr;
#if _MSC_VER < 1200
int _convert;
#endif
if (m_lpObject->QueryInterface(IID_IDispatch, (void**)&pdisp) == S_OK){
#ifdef XP_WIN32
LPCOLESTR lpOleStr = T2COLE("SaveAs");
hr = pdisp->GetIDsOfNames(IID_NULL, (unsigned short **)&lpOleStr, 1, LOCALE_USER_DEFAULT, &m_idSavedAs);
pdisp->Release();
if (hr == S_OK)
m_bCanSavedByOLE = TRUE;
else
m_idSavedAs = DISPID_UNKNOWN;
#else
m_idSavedAs = DISPID_UNKNOWN;
#endif
}
const char* ptr1 = m_csAddress;
if (NET_IsLocalFileURL((char*)ptr1)) {
XP_ConvertUrlToLocalFile(m_csAddress, &pSource);
m_csDosName = *pSource; // pick up the drive name.
m_csDosName += ":";
m_csDosName += strchr(pSource, '\\'); // pick up the real file name.
ptr = m_csDosName;
FE_ConvertSpace((char*)ptr);
XP_FREE(pSource);
}
// the object does not support ole automation, try to find out if this is a storagefile, so
// we can use OLESave().
if (!m_bCanSavedByOLE) {
#ifdef XP_WIN32 // we will only want to handle saving when the object had storage file.
#if _MSC_VER < 1200
int _convert;
#endif
LPCOLESTR lpsz = A2CW(m_csDosName);
if (StgIsStorageFile(lpsz) == S_OK)
m_bCanSavedByOLE = TRUE;
#else
HRESULT sc1 = StgIsStorageFile(m_csDosName);
if (GetScode(sc1) == S_OK)
m_bCanSavedByOLE = TRUE;
#endif
}
CGenericView* pView = GetActiveView();
CFrameGlue *pFrameGlue = pView->GetFrame();
if(pFrameGlue != NULL) {
m_bLocationBarShowing = pFrameGlue->GetChrome()->GetToolbarVisible(ID_LOCATION_TOOLBAR);
}
COleClientItem::OnActivate();
}
void CNetscapeCntrItem::OnChange(OLE_NOTIFICATION nCode, DWORD dwParam)
{
#ifdef MOZ_NGLAYOUT
XP_ASSERT(0);
#else
COleClientItem::OnChange(nCode, dwParam);
// this is a hack to test if we need to ask user to save the file or not.
// since I can not get lpPersistStorage->IsDirty() to give me the correct
// answer.
if (nCode == OLE_CLOSED)
m_isDirty = FALSE;
if (nCode == OLE_CHANGED && dwParam == DVASPECT_CONTENT)
m_isDirty = TRUE;
// Update all references to the item manually.
MWContext *pContext = GetDocument()->GetContext()->GetContext();
POSITION rIndex = m_cplElements.GetHeadPosition();
LO_EmbedStruct *pLayoutData;
while(rIndex != NULL) {
pLayoutData = (LO_EmbedStruct *)m_cplElements.GetNext(rIndex);
if (pContext->compositor) {
XP_Rect rect;
CL_GetLayerBbox(pLayoutData->objTag.layer, &rect);
CL_UpdateLayerRect(CL_GetLayerCompositor(pLayoutData->objTag.layer),
pLayoutData->objTag.layer, &rect, PR_FALSE);
}
else
pContext->funcs->DisplayEmbed(pContext, FE_VIEW, pLayoutData);
}
#endif /* MOZ_NGLAYOUT */
}
BOOL CNetscapeCntrItem::OnChangeItemPosition(const CRect& rectPos)
{
// Change the position of the item.
// Let this happen for them, we won't change layout, and we'll see how it goes.
if(FALSE == COleClientItem::OnChangeItemPosition(rectPos)) {
return(FALSE);
}
return(TRUE);
}
void CNetscapeCntrItem::OnGetItemPosition(CRect& rectPos) {
// Give them coordinates to the position of the in place activated item.
// So, which item was selected? We need layout data.
CGenericDoc *pDoc = GetDocument();
if(!pDoc) {
return;
}
CDCCX *pContextCX = pDoc->GetContext();
if(!pContextCX || pContextCX->IsFrameContext() == FALSE) {
return;
}
CWinCX *pWinCX = VOID2CX(pContextCX, CWinCX);
if(pWinCX->m_pSelected == NULL) {
// Don't do anything, we don't know of any selection.
return;
}
// Okay, we know about the selected item.
// Now, we need to figure out where it is located in the view.
HDC hdc = pWinCX->GetContextDC();
long lLeft = pWinCX->m_pSelected->objTag.x + pWinCX->m_pSelected->objTag.x_offset - pWinCX->GetOriginX();
long lRight = lLeft + pWinCX->m_pSelected->objTag.width;
long lTop = pWinCX->m_pSelected->objTag.y + pWinCX->m_pSelected->objTag.y_offset - pWinCX->GetOriginY();
long lBottom = lTop + pWinCX->m_pSelected->objTag.height;
// Convert our twips into pixels.
RECT crConvert;
::SetRect(&crConvert, CASTINT(lLeft), CASTINT(lTop), CASTINT(lRight), CASTINT(lBottom));
::LPtoDP(hdc, (POINT*) &crConvert, 2);
rectPos = crConvert;
pWinCX->ReleaseContextDC(hdc);
}
void CNetscapeCntrItem::OnDeactivateUI(BOOL bUndoable)
{
COleClientItem::OnDeactivateUI(bUndoable);
// Close an in-place active item whenever it removes the user
// interface. The action here should match as closely as possible
// to the handling of the escape key in the view.
if( IsInPlaceActive() == TRUE) {
TRY {
Deactivate();
}
CATCH(CException, e) {
// Something went wrong in OLE (other app down).
// No complicated handling here, just keep running.
}
END_CATCH
}
}
// TODO: We can remove this check once everyone moves to MSVC 4.0
#if _MSC_VER >= 1000
BOOL CNetscapeCntrItem::OnUpdateFrameTitle() {
// Nothing doing. We stay the same.
// This ASSERTs anyhow, if it continues on down.
return FALSE;
}
#else
void CNetscapeCntrItem::OnUpdateFrameTitle() {
// Nothing doing. We stay the same.
// This ASSERTs anyhow, if it continues on down.
return;
}
#endif
BOOL CNetscapeCntrItem::OnGetWindowContext(CFrameWnd **ppMainFrame, CFrameWnd **ppDocFrame, LPOLEINPLACEFRAMEINFO lpFrameInfo) {
// First call the base.
BOOL bRetval = COleClientItem::OnGetWindowContext(ppMainFrame, ppDocFrame, lpFrameInfo);
// Now, override the values with ones that make sense to us.
CGenericDoc *pDoc = GetDocument();
CDCCX *pCX = pDoc->GetContext();
if(pCX != NULL && pCX->IsFrameContext() == TRUE) {
// Get the frame from the window context.
CWinCX *pWinCX = (CWinCX *)pCX;
*ppMainFrame = pWinCX->GetFrame()->GetFrameWnd();
*ppDocFrame = NULL; // Act like SDI.
// It's possible that there is no frame.
// In which case we should do what? Fail.
if(pWinCX->GetFrame()->GetFrameWnd() == NULL) {
bRetval = FALSE;
}
}
else {
bRetval = FALSE;
*ppMainFrame = NULL;
*ppDocFrame = NULL;
}
return(bRetval);
}
BOOL CNetscapeCntrItem::OnShowControlBars(CFrameWnd *pFrameWnd, BOOL bShow) {
// Call the base, they'll at least handle our normal control bar.
BOOL bToolBarChanged = FALSE;
// Get the frame glue.
CFrameGlue *pFrameGlue = CFrameGlue::GetFrameGlue(pFrameWnd);
if(pFrameGlue != NULL) {
if(bShow == FALSE) {
// Hide our stuff.
if(m_bLocationBarShowing){
pFrameGlue->GetChrome()->ShowToolbar(ID_LOCATION_TOOLBAR, FALSE);
bToolBarChanged = TRUE;
}
}
else {
// Show our stuff.
// Assuming that we'll always be called to hide before we're called to show.
if(m_bLocationBarShowing){
pFrameGlue->GetChrome()->ShowToolbar(ID_LOCATION_TOOLBAR, m_bLocationBarShowing);
bToolBarChanged = TRUE;
}
}
}
BOOL bToolBarChanged1 = COleClientItem::OnShowControlBars(pFrameWnd, bShow);
return(bToolBarChanged || bToolBarChanged1);
}
void CNetscapeCntrItem::Serialize(CArchive& ar)
{
ASSERT_VALID(this);
// Call base class first to read in COleClientItem data.
// Since this sets up the m_pDocument pointer returned from
// CNetscapeCntrItem::GetDocument, it is a good idea to call
// the base class Serialize first.
COleClientItem::Serialize(ar);
// now store/retrieve data specific to CNetscapeCntrItem
if (ar.IsStoring())
{
}
else
{
}
}
BOOL CNetscapeCntrItem::CanActivate() {
// Can't activate if the document itself is inplace active.
CGenericDoc *pDoc = GetDocument();
ASSERT_VALID(pDoc);
ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(COleServerDoc)));
if(pDoc->IsInPlaceActive()) {
return(FALSE);
}
return(COleClientItem::CanActivate());
}
/////////////////////////////////////////////////////////////////////////////
// CNetscapeCntrItem diagnostics
#ifdef _DEBUG
void CNetscapeCntrItem::AssertValid() const
{
COleClientItem::AssertValid();
}
void CNetscapeCntrItem::Dump(CDumpContext& dc) const
{
COleClientItem::Dump(dc);
}
#endif
/////////////////////////////////////////////////////////////////////////////

105
mozilla/cmd/winfe/cntritem.h Executable file
View File

@@ -0,0 +1,105 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __CNTRITEM_H
#define __CNTRITEM_H
// cntritem.h : interface of the CNetscapeCntrItem class
//
class CGenericDoc;
class CGenericView;
class CNetscapeCntrItem : public COleClientItem
{
DECLARE_SERIAL(CNetscapeCntrItem)
// Constructors
public:
CNetscapeCntrItem(CGenericDoc* pContainer = NULL);
// Note: pContainer is allowed to be NULL to enable IMPLEMENT_SERIALIZE.
// IMPLEMENT_SERIALIZE requires the class have a constructor with
// zero arguments. Normally, OLE items are constructed with a
// non-NULL document pointer.
// Attributes
public:
BOOL m_bLoading; // If we are currently loading, from the net until completed creation from file.
BOOL m_bBroken; // Consider this item broken.
BOOL m_bDelayed; // We have postponed loading of this item.
BOOL m_isDirty;
BOOL m_isFullPage;
BOOL m_bIsOleItem;
BOOL m_bSetExtents;
CString m_csAddress; // The url that this originated from, to avoid redundant reloads.
CString m_csFileName; // The local temp file this item is located in, so on destruction we can also delete this file.
CString m_csDosName; // The dos file name for m_csAddress if it is a local file.
BOOL m_bCanSavedByOLE;
DISPID m_idSavedAs;
CFile m_cfOutput; // Output temporary file.
int m_iLock; // How many references to this item anyhow? To avoid freeing at inappropiate times.
CPtrList m_cplUnblock; // List of layout elements to unblock once the load is complete. Flushed on a per load basis.
CPtrList m_cplDisplay; // List of layout elements that we will manually update once the load is complete. Flushed on a per load basis.
CPtrList m_cplElements; // List of all layout elements referencing this item.
BOOL m_bLocationBarShowing; // Wether or not the URL bar was present in the Frame before we were activated.
BOOL m_bStarterBarShowing; // Wether or not the URL bar was present in the Frame before we were activated.
CNetscapeCntrItem* m_pOriginalItem; // Needed when we reuse cached existing NPEmbeddedApp(s), e.g. when printing
// Operations
public:
CGenericDoc* GetDocument()
{ return (CGenericDoc *)COleClientItem::GetDocument(); }
CGenericView* GetActiveView()
{ return (CGenericView *)COleClientItem::GetActiveView(); }
BOOL IsDirty() {return m_isDirty;}
// Implementation
public:
~CNetscapeCntrItem();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
virtual void Serialize(CArchive& ar);
virtual void OnDeactivateUI(BOOL bUndoable);
virtual BOOL OnShowControlBars(CFrameWnd *pFrame, BOOL bShow);
// TODO: We can remove this check once everyone moves to MSVC 4.0
#if defined(MSVC4)
virtual BOOL OnUpdateFrameTitle();
#else
virtual void OnUpdateFrameTitle();
#endif // MSVC4
protected:
virtual void OnChange(OLE_NOTIFICATION wNotification, DWORD dwParam);
virtual BOOL OnChangeItemPosition(const CRect& rectPos);
virtual void OnGetItemPosition(CRect& rectPos);
virtual BOOL OnGetWindowContext(CFrameWnd **ppMainFrame, CFrameWnd **ppDocFrame, LPOLEINPLACEFRAMEINFO lpFrameInfo);
virtual BOOL CanActivate();
virtual void OnActivate();
};
/////////////////////////////////////////////////////////////////////////////
#endif // __CNTRITEM_H

View File

@@ -0,0 +1,49 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __COLLAPSE_H
#define __COLLAPSE_H
typedef enum {
collapse_open = 0,
collapse_closed
} COLLAPSE_STATE;
class CNSCollapser
{
protected:
HBITMAP m_hVertSectionBitmap;
HBITMAP m_hHTabBitmap;
BOOL m_bHilite;
CRect m_rect;
CWnd * m_pWnd;
COLLAPSE_STATE m_cState;
int m_iSubtract;
UINT m_nTimer;
UINT m_cmdId;
public:
CNSCollapser();
~CNSCollapser();
void GetRect(CRect & rect) { rect = m_rect; }
BOOL ButtonPress(POINT & point);
void Initialize(CWnd * pWnd = NULL, UINT nCmd = 0);
void TimerEvent(UINT nIDEvent);
void DrawCollapseWidget(CDC &dc, COLLAPSE_STATE state = collapse_closed, BOOL bHilite = FALSE, int iSubtract = 0);
void MouseAround(POINT & point);
};
#endif

File diff suppressed because it is too large Load Diff

232
mozilla/cmd/winfe/compbar.h Normal file
View File

@@ -0,0 +1,232 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __COMPBAR_H
#define __COMPBAR_H
#include <afxwin.h>
#include <afxext.h>
#include "rosetta.h"
#include "compstd.h"
#include "msgcom.h"
#include "addrbook.h"
#include "apiaddr.h"
#include "apiimg.h"
#include "collapse.h"
#include "tooltip.h"
class CComposeEdit;
class CNSAddressList;
class CNSAttachmentList;
#define MAX_TIPS 4
class CComposeSubjectEdit;
class CComposeBar : public CDialogBar,
public IAddressParent
{
protected:
class CNSComposeToolInfo
{
public:
CRect m_rect;
UINT m_idText;
WPARAM m_idCommand;
CString m_csToolTip;
void Initialize(UINT idText, CRect & rect, WPARAM idCommand)
{
m_csToolTip = szLoadString(idText);
m_idText = idText;
m_rect = rect;
m_idCommand = idCommand;
}
};
LPUNKNOWN m_pUnkImage;
LPUNKNOWN m_pUnkAddressControl;
LPIMAGEMAP m_pIImage;
public:
CNSToolTip2 * m_pToolTip;
CNSCollapser collapser;
LPADDRESSCONTROL m_pIAddressList;
LPUNKNOWN m_pUnkAddress;
int m_iMinSize;
int m_iMaxSize;
int m_iHeight;
int m_iBoxHeight;
int m_cxChar;
int m_iFirstX;
int m_iSelectedTab;
int m_iPriorityIdx;
char * m_pszMessageFormat;
char * m_pszCharSet;
BOOL m_bReceipt;
BOOL m_bEncrypted;
BOOL m_bSigned;
BOOL m_bAttachVCard;
BOOL m_bUse8Bit;
BOOL m_bUseUUENCODE;
int m_iTotalAttachments;
int m_iPrevHeight;
CNSComposeToolInfo m_ToolTipInfo[MAX_TIPS];
HFONT m_cfTextFont;
HFONT m_cfStaticFont;
HFONT m_cfSubjectFont;
CComposeEdit * m_pComposeEdit;
#ifdef BUTTONS
CWnd * m_pButton[3];
#endif
CButton * m_pReturnReceipt;
CButton * m_pEncrypted;
CButton * m_pSigned;
CButton * m_pUse8Bit;
CButton * m_pUseUUENCODE;
CNSAttachmentList * m_pAttachmentList;
CWnd * m_pWidget;
CComposeSubjectEdit * m_pSubjectEdit;
CStatic * m_pPriorityText;
CStatic * m_pSubjectEditText;
CStatic * m_pMessageFormatText;
CComboBox * m_pPriority;
CComboBox * m_pMessageFormat;
CNSAttachDropTarget * m_pDropTarget;
MWContext *m_pContext;
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz );
void Enable3d(BOOL bEnable);
public:
CEdit * m_pSubject;
BOOL m_bClosed;
BOOL m_bHidden;
BOOL m_bSizing;
BOOL m_bCanSize;
int m_iY;
CComposeBar (MWContext *pContext );
~CComposeBar ( );
LPADDRESSCONTROL GetAddressWidgetInterface();
void ShowTab(int idx);
int GetTab();
void AttachFile(void);
void AttachUrl(void);
inline BOOL IsCollapsed(void) { return m_bClosed; }
void SetComposeEdit ( CComposeEdit * pEdit )
{
m_pComposeEdit = pEdit;
}
CComposeEdit * GetComposeEdit ( void )
{
return m_pComposeEdit;
}
void SetCSID(int m_iCSID);
HG29792
void SetReturnReceipt(BOOL bReceipt) { m_bReceipt = bReceipt; }
void SetUse8Bit(BOOL bUse8Bit) { m_bUse8Bit = bUse8Bit; }
void SetUseUUENCODE(BOOL bUseUUENCODE) {m_bUseUUENCODE = bUseUUENCODE; }
BOOL GetReturnReceipt(void) { return m_bReceipt; }
BOOL GetUse8Bit(void) { return m_bUse8Bit; }
BOOL GetUseUUENCODE(void) { return m_bUseUUENCODE; }
void Draw3DStaticEdgeSimulation(CDC & dc, CRect &rect, BOOL bReverse = FALSE);
void DrawVerticalTab(CDC &, int, CRect &);
BOOL IsAttachmentsMailOnly(void);
BOOL TabControl(BOOL bShift = FALSE, BOOL bControl = FALSE, CWnd * pWnd = (CWnd*)TABCTRL_HOME);
void CalcFieldLayout(void);
void DisplayHeaders ( MSG_HEADER_SET );
int GetHeightNeeded ( void );
void CreateAddressingBlock(void);
void CreateStandardFields(void);
void CreateAddressPage(void);
void CreateAttachmentsPage(void);
void CreateOptionsPage(void);
void DestroyOptionsPage(void);
void DestroyAddressPage(void);
void DestroyStandardFields(void);
void DestroyAttachmentsPage(void);
void UpdateFixedSize ( );
void UpdateHeaderInfo ( void );
void UpdateRecipientInfo ( char *pTo, char *pCc, char *pBcc );
int GetTotalAttachments(void);
void UpdateAttachmentInfo(int nTotal = -1);
void TabChanging(int tab);
void TabChanged(int tab);
void GetWidgetRect(CRect &WinRect, CRect &rect);
BOOL GetAttachMyCard() { return m_bAttachVCard; }
void SetAttachMyCard(BOOL bAttach) { m_bAttachVCard = bAttach; }
void Cleanup(void);
void UpdateSecurityOptions(void);
virtual void AddedItem (HWND hwnd, LONG id,int index);
virtual int ChangedItem (char * pString, int index, HWND hwnd, char ** ppszFullName, unsigned long* entryID = NULL, UINT* bitmapID = NULL);
virtual void DeletedItem (HWND hwnd, LONG id,int index);
virtual char * NameCompletion (char *);
virtual void StartNameCompletionSearch();
virtual void StopNameCompletionSearch();
virtual void SetProgressBarPercent(int32 lPercent);
virtual void SetStatusText(const char* pMessage );
virtual CWnd *GetOwnerWindow();
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
BOOL ProcessVCardData(COleDataObject * pDataObject,CPoint &point);
BOOL ProcessAddressBookIndexFormat(COleDataObject *pDataObject, DROPEFFECT effect,
CPoint &point);
BOOL AddURLToAddressPane(COleDataObject * pDataObject, CPoint &point, LPSTR szURL);
void OnAttachTab(void);
void OnAddressTab(void);
void OnOptionsTab(void);
void OnCollapse(void);
void OnToggleShow(void);
inline BOOL IsVisible() {return !m_bHidden;}
protected:
#ifdef XP_WIN16
BOOL PreTranslateMessage( MSG* pMsg );
#endif
void UpdateOptionsInfo();
afx_msg LRESULT OnSizeParent(WPARAM wParam, LPARAM lParam);
afx_msg void OnDropFiles( HDROP hDropInfo );
afx_msg void OnMouseMove( UINT nFlags, CPoint point );
afx_msg int OnCreate ( LPCREATESTRUCT );
afx_msg void OnPaint();
afx_msg BOOL OnSetCursor( CWnd* pWnd, UINT nHitTest, UINT message );
afx_msg void OnButtonAttach(void);
afx_msg void OnSize( UINT nType, int cx, int cy );
afx_msg LONG OnLeavingLastField(UINT, LONG);
afx_msg void OnLButtonDown( UINT nFlags, CPoint point );
afx_msg void OnLButtonUp( UINT nFlags, CPoint point );
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnTimer( UINT nIDEvent );
afx_msg void OnUpdateToolBar(void);
afx_msg void OnUpdateOptions(void);
DECLARE_MESSAGE_MAP()
friend class CComposeFrame;
};
#endif

View File

@@ -0,0 +1,636 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "template.h"
#include "msgcom.h"
#include "wfemsg.h"
#include "compstd.h"
#include "compbar.h"
#include "compmisc.h"
#include "compfrm.h"
#include "edt.h"
#include "edview.h"
#include "intl_csi.h"
#include "prefapi.h"
#include "apiaddr.h"
#include "postal.h"
#include "mailmisc.h"
#include "dlghtmrp.h"
#include "dlghtmmq.h"
extern "C" {
#include "xpgetstr.h"
extern int MK_MSG_MSG_COMPOSITION;
};
extern "C" int FE_LoadExchangeInfo(MWContext * context);
extern "C" MSG_Pane * DoAltMailComposition(MWContext *pOldContext, MSG_CompositionFields* fields);
int WFE_InsertMessage(void *closure, const char * data);
extern "C" void FE_DestroyMailCompositionContext(MWContext *pContext)
{
CGenericFrame * pFrame = wfe_FrameFromXPContext(pContext);
if ( pFrame ) {
CComposeFrame * pCompose = (CComposeFrame *) pFrame;
if (pCompose->UseHtml())
EDT_SetDirtyFlag(pContext,FALSE);
else
pCompose->GetEditorParent()->m_bModified = FALSE;
pCompose->SetMsgPane(NULL);
if(pCompose) {
pCompose->PostMessage ( WM_CLOSE );
}
}
}
extern "C" int FE_GetMessageBody(MSG_Pane *pPane, char **ppBody, uint32 *ulBodySize, MSG_FontCode **ppFontChanges)
{
ASSERT(pPane);
CComposeFrame * pCompose = (CComposeFrame *) MSG_GetFEData(pPane);
ASSERT(pCompose);
MWContext *pContext = pCompose->GetMainContext()->GetContext();
ASSERT(pContext);
if (pCompose->UseHtml())
{
MSG_SetHTMLMarkup(pPane,TRUE);
*ppBody = NULL;
*ulBodySize = 0;
if ( pCompose )
{
// Danger!!! This is not legal!!! We must change this to be a real XP_HUGE for win16.
// see bug #39756
EDT_SaveToBuffer(pContext,(XP_HUGE_CHAR_PTR*) ppBody);
if ( !*ppBody)
return 1;
else {
size_t lsize;
lsize = strlen(*ppBody);
*ulBodySize = lsize;
return lsize;
}
}
return 0;
}
// new compose window code
size_t lsize = 0;
#ifdef XP_WIN16
unsigned int textLength; // Cannot use uint32/int32; the compiler won't
// generate the correct code. Use unsigned int, at least
// we could get over with the 32767 boundary.
// Although 16-bit CEdit::GetWindowTextLength returns int casting it to
// unsigned int we can still get the correct text length if the text length is
// greater than 32767
textLength = (unsigned int) pCompose->GetEditor()->GetWindowTextLength();
#else
int32 textLength;
textLength = pCompose->GetEditor()->GetWindowTextLength();
#endif
if ( textLength >= 0 )
{
char * tmp = (char *)XP_CALLOC(1,textLength+1);
ASSERT ( tmp );
pCompose->GetEditor()->GetWindowText(tmp, textLength+1);
if (pCompose->GetWrapLongLines())
{
int32 lineWidth = 72;
PREF_GetIntPref("mailnews.wraplength", &lineWidth);
if (lineWidth < 10) lineWidth = 10;
if (lineWidth > 30000) lineWidth = 30000;
*ppBody = (char *) XP_WordWrap(INTL_DefaultWinCharSetID(pContext),
(unsigned char *)tmp, lineWidth, 1 /* look for '>' */);
free(tmp);
}
else
{
/* Else, don't wrap it at all. */
*ppBody = tmp;
}
if (ppBody && *ppBody)
for (const char *ptr = *ppBody; ptr && *ptr; ptr++)
lsize++;
}
*ulBodySize = lsize;
return 0;
}
//
// Create a composition window
//
extern "C" void FE_InitializeMailCompositionContext(MSG_Pane *pComposePane,
const char *pFrom,
const char *pReplyTo,
const char *pTo,
const char *pCc,
const char *pBcc,
const char *pFcc,
const char *pNewsgroups,
const char *pFollowupTo,
const char *pSubject,
const char *pAttachment)
{
MSG_SetCompHeader(pComposePane, MSG_TO_HEADER_MASK, pTo);
MSG_SetCompHeader(pComposePane, MSG_FROM_HEADER_MASK, pFrom);
MSG_SetCompHeader(pComposePane, MSG_SUBJECT_HEADER_MASK, pSubject);
MSG_SetCompHeader(pComposePane, MSG_CC_HEADER_MASK, pCc);
MSG_SetCompHeader(pComposePane, MSG_BCC_HEADER_MASK, pBcc);
MSG_SetCompHeader(pComposePane, MSG_FCC_HEADER_MASK, pFcc);
MSG_SetCompHeader(pComposePane, MSG_REPLY_TO_HEADER_MASK, pReplyTo);
MSG_SetCompHeader(pComposePane, MSG_FOLLOWUP_TO_HEADER_MASK, pFollowupTo);
MSG_SetCompHeader(pComposePane, MSG_NEWSGROUPS_HEADER_MASK, pNewsgroups);
}
MWContext * g_NastyContextSavingHack = NULL;
// create a new xpContext with type == MWContextMessageComposition
extern "C" MSG_Pane *FE_CreateCompositionPane(MWContext *pOldContext,
MSG_CompositionFields* fields,
const char *pInitialText,
MSG_EditorType editorType)
{
if(!theApp.m_hPostalLib) {
CGenericDoc * pDocument;
// Don't allow a compose window to be created if the user hasn't
// specified an email address
const char *real_addr = FE_UsersMailAddress();
if (MISC_ValidateReturnAddress(pOldContext, real_addr) < 0)
return NULL;
XP_Bool htmlCompose;
PREF_GetBoolPref("mail.html_compose",&htmlCompose);
if (theApp.m_bReverseSenseOfHtmlCompose)
htmlCompose = !htmlCompose;
if (editorType == MSG_HTML_EDITOR)
htmlCompose = TRUE;
else if (editorType == MSG_PLAINTEXT_EDITOR)
htmlCompose = FALSE;
INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(pOldContext);
int16 win_csid = INTL_GetCSIWinCSID(csi);
if (!MSG_GetForcePlainText(fields) && htmlCompose)
pDocument = (CGenericDoc*)theApp.m_ComposeTemplate->OpenDocumentFile(NULL, win_csid);
else
pDocument = (CGenericDoc*)theApp.m_TextComposeTemplate->OpenDocumentFile(NULL, win_csid);
g_NastyContextSavingHack = pOldContext;
if ( pDocument )
{
CWinCX * pContext = (CWinCX*) pDocument->GetContext();
if ( pContext ) {
MSG_CompositionPaneCallbacks Callbacks;
Callbacks.CreateRecipientsDialog= CreateRecipientsDialog;
Callbacks.CreateAskHTMLDialog= CreateAskHTMLDialog;
MWContext *context = pContext->GetContext();
CComposeFrame *pCompose = (CComposeFrame *) pContext->GetFrame()->GetFrameWnd();
pCompose->SetComposeStuff(pOldContext,fields); // squirl away stuff for post-create
// This needs to be set TRUE if using the old non-HTML text frame
// to prevent dropping dragged URLs
pContext->m_bDragging = !pCompose->UseHtml();
if (!pCompose->UseHtml())
{
pCompose->SetMsgPane(MSG_CreateCompositionPane(
pContext->GetContext(),
pOldContext, g_MsgPrefs.m_pMsgPrefs, fields,
WFE_MSGGetMaster()));
}
else
{
pCompose->SetMsgPane(MSG_CreateCompositionPaneNoInit(
pContext->GetContext(),
g_MsgPrefs.m_pMsgPrefs,
WFE_MSGGetMaster()));
//set the callbacks for askHTML and Recipients dialogs
MSG_SetCompositionPaneCallbacks( pCompose->GetMsgPane(),
&Callbacks,
0);
if (pCompose->GetMsgPane())
MSG_SetHTMLMarkup(pCompose->GetMsgPane(), TRUE);
}
ASSERT(pCompose->GetMsgPane());
MSG_SetFEData(pCompose->GetMsgPane(),(void *)pCompose);
pCompose->UpdateAttachmentInfo();
// Pass doccsid and win_csid info to new context for MailToWin conversion
INTL_CharSetInfo old_csi = LO_GetDocumentCharacterSetInfo(pOldContext);
INTL_CharSetInfo new_csi = LO_GetDocumentCharacterSetInfo(context);
int16 doccsid = INTL_GetCSIDocCSID(old_csi);
INTL_SetCSIDocCSID(new_csi,
(doccsid ? doccsid : INTL_DefaultDocCharSetID(pOldContext)));
INTL_SetCSIWinCSID(new_csi,
(win_csid ? win_csid : INTL_DocToWinCharSetID(INTL_GetCSIDocCSID(new_csi))));
pCompose->DisplayHeaders(NULL);
CComposeBar * pBar = pCompose->GetComposeBar();
ASSERT(pBar);
LPADDRESSCONTROL pIAddressList = pBar->GetAddressWidgetInterface();
if (!pIAddressList->IsCreated())
{
pBar->CreateAddressingBlock();
}
if (!pCompose->UseHtml())
{
pCompose->CompleteComposeInitialization();
const char * pBody = pInitialText ? pInitialText : MSG_GetCompBody(pCompose->GetMsgPane());
if (pBody)
{
FE_InsertMessageCompositionText(context,pBody,TRUE);
// We don't want to quote the original if open as draft
// Check for the editorType before we do the quoting
// Since only draft code will specify what editor to
// use, checking for editorType == MSG_DEFAULT will do
// the work.
if (MSG_ShouldAutoQuote(pCompose->GetMsgPane()) &&
editorType == MSG_DEFAULT)
{
pCompose->SetQuoteSelection();
MSG_QuoteMessage(
pCompose->GetMsgPane(),
WFE_InsertMessage,
(void*)pCompose->GetMainContext()->GetContext());
}
}
}
else
{
pCompose->SetInitialText (pInitialText);
URL_Struct * pUrl = NET_CreateURLStruct(EDT_NEW_DOC_URL,NET_DONT_RELOAD);
if (pUrl != NULL)
{
// pUrl->pre_exit_fn = wfe_GoldDoneLoading;
pUrl->internal_url = TRUE;
pContext->GetUrl(pUrl, FO_CACHE_AND_PRESENT);
pContext->GetContext()->bIsComposeWindow = TRUE;
}
}
if (MSG_GetAttachmentList(pCompose->GetMsgPane()))
pCompose->SetModified(TRUE);
else
pCompose->SetModified(FALSE);
// Post message to compose window to set the initial focus.
pCompose->PostMessage(WM_COMP_SET_INITIAL_FOCUS);
return pCompose->GetMsgPane();
}
}
return NULL;
}
else
return DoAltMailComposition(pOldContext, fields);
}
extern "C" void FE_RaiseMailCompositionWindow(MSG_Pane *pPane)
{
CComposeFrame * pCompose = (CComposeFrame *) MSG_GetFEData(pPane);
#ifdef XP_WIN32
if(!theApp.m_hPostalLib) {
#endif
pCompose->SendMessageToDescendants(WM_INITIALUPDATE, 0, 0, TRUE, TRUE);
pCompose->ShowWindow(SW_SHOW);
// Make Sure OnInitialUpdate gets called for the view.
pCompose->DisplayHeaders(pCompose->GetSavedHeaders());
#ifdef XP_WIN32
}
else {
FE_LoadExchangeInfo(pCompose->GetMainContext()->GetContext());
}
#endif
}
extern "C" void FE_InsertMessageCompositionText(MWContext * context,
const char* text,
XP_Bool leaveCursorAtBeginning)
{
if (context) {
if (ABSTRACTCX(context)->IsDestroyed())
return;
CGenericFrame * pFrame = wfe_FrameFromXPContext(context);
if (pFrame)
{
CComposeFrame * pCompose = (CComposeFrame *) pFrame;
if ( pCompose )
{
int nStartChar, nEndChar;
if (!pCompose->UseHtml())
{
if ( leaveCursorAtBeginning )
pCompose->GetEditor()->GetSel(nStartChar, nEndChar);
pCompose->GetEditor()->ReplaceSel ( text );
if ( leaveCursorAtBeginning )
pCompose->GetEditor()->SetSel (nStartChar, nEndChar, TRUE );
}
else
{
ED_BufferOffset ins = -1;
if ( leaveCursorAtBeginning ){
ins = EDT_GetInsertPointOffset( context );
}
EDT_PasteQuote( context, (char*) text );
if ( leaveCursorAtBeginning && ins != -1 ) {
EDT_SetInsertPointToOffset( context, ins, 0 );
}
}
pCompose->GetChrome()->StopAnimation();
}
}
}
}
extern "C" void FE_DoneWithMessageBody(MSG_Pane *pPane, char* body,
uint32 body_size)
{
XP_FREE(body);
}
extern "C" char * FE_PromptMessageSubject (MWContext * pContext)
{
HWND hWnd = GetFocus();
CString csText;
CString csDefault;
csText.LoadString(IDS_COMPOSE_NOSUBJECT);
csDefault.LoadString(IDS_COMPOSE_DEFAULTNOSUBJECT);
char * ptr = CFE_Prompt(pContext, csText, csDefault );
SetFocus(hWnd);
if (!ptr)
{
CGenericFrame * pFrame = wfe_FrameFromXPContext(pContext);
CComposeFrame * pCompose = (CComposeFrame *) pFrame;
pCompose->GetChrome()->StopAnimation();
}
return ptr;
}
#ifdef XP_WIN32
extern void FE_UpdateComposeWindowRecipients(MWContext *pContext,
char *pTo, char *pCc, char *pBcc)
{
CGenericFrame * pFrame = wfe_FrameFromXPContext(pContext);
CComposeFrame * pCompose = (CComposeFrame *) pFrame;
if ( pCompose )
{
CComposeBar * pBar = pCompose->GetComposeBar();
ASSERT(pBar);
pBar->UpdateRecipientInfo (pTo, pCc, pBcc);
}
}
#endif
extern "C" MSG_Pane * DoAltMailComposition(MWContext *pOldContext, MSG_CompositionFields* fields)
{
CGenericDoc * pDocument;
INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(pOldContext);
pDocument = (CGenericDoc*)theApp.m_TextComposeTemplate->OpenDocumentFile(NULL, INTL_GetCSIWinCSID(csi));
g_NastyContextSavingHack = pOldContext;
if ( pDocument )
{
CWinCX * pContext = (CWinCX*) pDocument->GetContext();
if ( pContext )
{
MWContext *context = pContext->GetContext();
CComposeFrame *pCompose = (CComposeFrame *) pContext->GetFrame()->GetFrameWnd();
pCompose->SetComposeStuff(pOldContext,fields); // squirl away stuff for post-create
pCompose->SetMsgPane(MSG_CreateCompositionPane(
pContext->GetContext(),
pOldContext, g_MsgPrefs.m_pMsgPrefs, fields,
WFE_MSGGetMaster()));
ASSERT(pCompose->GetMsgPane());
MSG_SetFEData(pCompose->GetMsgPane(),(void *)pCompose);
pCompose->DisplayHeaders(NULL);
FE_LoadExchangeInfo(context);
return pCompose->GetMsgPane();
}
}
return NULL;
}
#define MAX_MAIL_SIZE 300000
extern "C" void FE_DoneMailTo(PrintSetup * print)
{
ASSERT(print);
MWContext * context = (MWContext *) print->carg;
CGenericFrame * pFrame = wfe_FrameFromXPContext(context);
ASSERT(pFrame);
CComposeFrame * pCompose;
pCompose = (CComposeFrame *) pFrame;
ASSERT(pFrame);
MSG_Pane * pMsgPane = pCompose->GetMsgPane();
ASSERT(pMsgPane);
fclose(print->out);
//
// No no no, get the size the right way
//
char * buffer;
buffer = (char *) malloc(MAX_MAIL_SIZE + 5);
FILE * fp = fopen(print->filename, "r");
int len = fread(buffer, 1, MAX_MAIL_SIZE + 5, fp);
buffer[len] = '\0';
fclose(fp);
if(theApp.m_hPostalLib) {
if(theApp.m_bInitMapi) {
if(theApp.m_fnOpenMailSession) {
POSTCODE status = (*theApp.m_fnOpenMailSession) (NULL, NULL);
if(status == POST_OK) {
theApp.m_bInitMapi = FALSE;
}
else {
FE_DestroyMailCompositionContext(context);
return;
}
}
}
// create mail window with no quoting
if(theApp.m_fnComposeMailMessage)
(*theApp.m_fnComposeMailMessage) ((const char *) (const char *) MSG_GetCompHeader(pMsgPane, MSG_TO_HEADER_MASK),
(const char *) "", /* no refs field. BAD! BUG! */
(const char *) MSG_GetCompHeader(pMsgPane, MSG_ORGANIZATION_HEADER_MASK),
(const char *) "", /* no URL */
(const char *) MSG_GetCompHeader(pMsgPane, MSG_SUBJECT_HEADER_MASK),
buffer,
(const char *) MSG_GetCompHeader(pMsgPane, MSG_CC_HEADER_MASK),
(const char *) MSG_GetCompHeader(pMsgPane, MSG_BCC_HEADER_MASK));
// get rid of the file and free the memory
remove(print->filename);
// XP_FREE(print->filename);
// print->filename = NULL;
XP_FREE(buffer);
FE_DestroyMailCompositionContext(context);
return;
}
}
extern "C" int FE_LoadExchangeInfo(MWContext * context)
{
#ifdef MOZ_NGLAYOUT
XP_ASSERT(0);
#else
if(!context)
return(FALSE);
if(!theApp.m_hPostalLib)
return(FALSE);
CGenericFrame * pFrame = wfe_FrameFromXPContext(context);
ASSERT(pFrame);
CComposeFrame * pCompose;
pCompose = (CComposeFrame *) pFrame;
ASSERT(pFrame);
MSG_Pane * pMsgPane = pCompose->GetMsgPane();
ASSERT(pMsgPane);
History_entry * hist_ent = NULL;
if(g_NastyContextSavingHack)
hist_ent = SHIST_GetCurrent(&(g_NastyContextSavingHack->hist));
CString csURL;
if(hist_ent)
csURL = hist_ent->address;
else
csURL = "";
//Set hist_ent to NULL if context->title is "Message Composition"
//This is a nasty way of determining if we're in here in response
//to "Mail Doc" or "New Mail Message".
//Also, if there's To: field info present(pBar->m_pszTo) then
//we know that it's a Mailto: and set hist_ent to NULL
//Without this differentiation the code always sends the contents
//of the previously mailed document even when someone chooses
//"New Mail Message" or "Mailto:"
const char * pszTo = MSG_GetCompHeader(pMsgPane, MSG_TO_HEADER_MASK);
if(!strcmp(XP_GetString(MK_MSG_MSG_COMPOSITION), context->title) || strlen(pszTo) )
hist_ent = NULL;
// make sure there was a document loaded
if(!hist_ent) {
if(theApp.m_bInitMapi) {
if(theApp.m_fnOpenMailSession) {
POSTCODE status = (*theApp.m_fnOpenMailSession) (NULL, NULL);
if(status == POST_OK) {
theApp.m_bInitMapi = FALSE;
}
else {
FE_DestroyMailCompositionContext(context);
return(FALSE);
}
}
}
// create mail window with no quoting
if(theApp.m_fnComposeMailMessage)
(*theApp.m_fnComposeMailMessage) ((const char *) MSG_GetCompHeader(pMsgPane, MSG_TO_HEADER_MASK),
(const char *) "", /* no refs field. BAD! BUG! */
(const char *) MSG_GetCompHeader(pMsgPane, MSG_ORGANIZATION_HEADER_MASK),
(const char *) "", /* no URL */
(const char *) MSG_GetCompHeader(pMsgPane, MSG_SUBJECT_HEADER_MASK),
"",
(const char *) MSG_GetCompHeader(pMsgPane, MSG_CC_HEADER_MASK),
(const char *) MSG_GetCompHeader(pMsgPane, MSG_BCC_HEADER_MASK));
FE_DestroyMailCompositionContext(context);
return(TRUE);
}
URL_Struct * URL_s = SHIST_CreateURLStructFromHistoryEntry(g_NastyContextSavingHack, hist_ent);
// Zero out the saved data
memset(&URL_s->savedData, 0, sizeof(URL_s->savedData));
PrintSetup print;
XL_InitializeTextSetup(&print);
print.width = 68;
print.prefix = "";
print.eol = "\r\n";
char * name = WH_TempName(xpTemporary, NULL);
if(!name) {
FE_DestroyMailCompositionContext(context);
return(FALSE);
}
print.out = fopen(name, "w");
print.completion = (XL_CompletionRoutine) FE_DoneMailTo;
print.carg = context;
print.filename = name;
print.url = URL_s;
// leave pCompose window alive until completion routine
XL_TranslateText(g_NastyContextSavingHack, URL_s, &print);
#endif /* MOZ_NGLAYOUT */
return(TRUE);
}
extern "C" void FE_SecurityOptionsChanged(MWContext * pContext)
{
CGenericFrame * pFrame = wfe_FrameFromXPContext(pContext);
if ( pFrame ) {
CComposeFrame * pCompose = (CComposeFrame *) pFrame;
pCompose->UpdateSecurityOptions();
}
}

View File

@@ -0,0 +1,771 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "xp.h"
#include "forward.h"
#include "compfile.h"
#include "compfrm.h"
#include "compbar.h"
#include "ole2.h"
#include "abdefn.h"
#include "wfemsg.h"
#include "mailmisc.h"
#include "nsadrlst.h"
#include "addrfrm.h"
extern char* wfe_ConstructFilterString(int type);
extern char* XP_NetToDosFileName(const char * NetName);
#define BITMAP_WIDTH 16
#define BITMAP_HEIGHT 16
BEGIN_MESSAGE_MAP(CNSAttachmentList, CListBox)
ON_WM_CREATE()
ON_WM_KEYDOWN()
ON_WM_LBUTTONDOWN()
ON_WM_DROPFILES()
ON_WM_DESTROY()
ON_COMMAND(ID_EDIT_DELETE,OnDelete)
END_MESSAGE_MAP()
CNSAttachmentList::CNSAttachmentList(MSG_Pane * pPane)
{
m_pPane = pPane;
m_pDropTarget = NULL;
}
CNSAttachmentList::~CNSAttachmentList()
{
if (m_pDropTarget)
{
m_pDropTarget->Revoke();
delete m_pDropTarget;
}
}
BOOL CNSAttachmentList::Create(CWnd * pWnd, UINT id)
{
BOOL bRetVal = CListBox::Create (
WS_CLIPCHILDREN|WS_CHILD|WS_VISIBLE|WS_VSCROLL|LBS_OWNERDRAWFIXED|
LBS_HASSTRINGS|LBS_NOTIFY|LBS_WANTKEYBOARDINPUT|LBS_NOINTEGRALHEIGHT,
CRect(0,0,0,0), pWnd, id);
return bRetVal;
}
void CNSAttachmentList::OnDelete()
{
if (GetFocus() == this)
{
int idx = GetCurSel();
if (idx != LB_ERR)
{
DeleteString(idx);
CComposeBar * pComposeBar = (CComposeBar*)GetParent();
pComposeBar->UpdateAttachmentInfo(GetCount());
UpdateAttachments();
}
}
}
void CNSAttachmentList::OnUpdateDelete(CCmdUI * pCmdUI)
{
if (GetFocus() == this)
pCmdUI->Enable(GetCount()>0);
}
int CNSAttachmentList::OnCreate( LPCREATESTRUCT lpCreateStruct )
{
int iRet = CListBox::OnCreate(lpCreateStruct);
CComposeFrame * pFrame = (CComposeFrame*)GetParentFrame();
CDC * pdc = GetDC();
LOGFONT lf;
memset(&lf,0,sizeof(LOGFONT));
lf.lfPitchAndFamily = FF_SWISS;
if (INTL_DefaultWinCharSetID(0) == CS_LATIN1)
strcpy(lf.lfFaceName, "MS Sans Serif");
else
strcpy(lf.lfFaceName, IntlGetUIPropFaceName(0));
lf.lfCharSet = IntlGetLfCharset(pFrame->m_iCSID);
lf.lfHeight = -MulDiv(8,pdc->GetDeviceCaps(LOGPIXELSY), 72);
lf.lfQuality = PROOF_QUALITY;
m_cfTextFont = theApp.CreateAppFont( lf );
::SendMessage(GetSafeHwnd(), WM_SETFONT, (WPARAM)m_cfTextFont, FALSE);
ReleaseDC(pdc);
BOOL bDisableButtons = TRUE;
if(GetMsgPane())
{
const MSG_AttachmentData * pDataList = MSG_GetAttachmentList(GetMsgPane());
if(pDataList)
{
bDisableButtons = FALSE;
for (int i = 0; pDataList[i].url!=NULL; i++)
{
int idx;
MSG_AttachmentData * pEntry =
(MSG_AttachmentData*)XP_CALLOC(1,sizeof(MSG_AttachmentData));
ASSERT(pEntry);
pEntry->url = XP_STRDUP(pDataList[i].url);
if (pDataList[i].real_type)
pEntry->real_type = XP_STRDUP(pDataList[i].real_type);
if (pDataList[i].description)
pEntry->description = XP_STRDUP(pDataList[i].description);
if (pDataList[i].real_name)
pEntry->real_name = XP_STRDUP(pDataList[i].real_name);
if (pDataList[i].real_name)
idx = AddString (pEntry->real_name);
else
idx = AddString(pEntry->url);
#ifdef DEBUG_bienvenu
MSG_MessageLine msgLine;
int ret = MSG_GetMessageLineForURL(WFE_MSGGetMaster(), pEntry->url, &msgLine);
#endif
ASSERT(idx!=LB_ERR);
SetItemData(idx,(DWORD)pEntry);
ASSERT(pEntry->url);
if (pDataList[i].desired_type)
{
pEntry->desired_type = XP_STRDUP(pDataList[i].desired_type);
ASSERT(pEntry->desired_type);
}
}
SetCurSel(0);
}
}
if(!m_pDropTarget) {
m_pDropTarget = new CNSAttachDropTarget;
m_pDropTarget->Register(this);
}
DragAcceptFiles();
return(iRet);
}
void CNSAttachmentList::AttachUrl(char * pUrl)
{
CWnd * pFocusWnd = GetFocus();
CLocationDlg LocationDlg(pUrl,this);
if (LocationDlg.DoModal()==IDOK)
{
MSG_AttachmentData * pAttach =
(MSG_AttachmentData *)XP_CALLOC(1,sizeof(MSG_AttachmentData));
ASSERT(pAttach);
pAttach->url = XP_STRDUP(LocationDlg.m_Location);
ASSERT(pAttach->url);
int idx = AddString(pAttach->url);
ASSERT(idx!=LB_ERR);
SetItemData(idx,(DWORD)pAttach);
SetCurSel(idx);
CComposeBar * pComposeBar = (CComposeBar*)GetParent();
pComposeBar->UpdateAttachmentInfo(GetCount());
UpdateAttachments();
}
pFocusWnd->SetFocus();
}
void CNSAttachmentList::AddAttachment(char * pName)
{
if(pName)
{
MSG_AttachmentData * pAttach =
(MSG_AttachmentData *)XP_CALLOC(1,sizeof(MSG_AttachmentData));
CString cs;
WFE_ConvertFile2Url(cs,(const char *)pName);
pAttach->url = XP_STRDUP(cs);
ASSERT(pAttach->url);
int idx = AddString(pAttach->url);
CComposeBar * pComposeBar = (CComposeBar*)GetParent();
pComposeBar->UpdateAttachmentInfo(GetCount());
ASSERT(idx!=LB_ERR);
SetItemData(idx,(DWORD)pAttach);
SetCurSel(idx);
}
}
void CNSAttachmentList::AttachFile()
{
CWnd * pFocusWnd = GetFocus();
CString cs;
cs.LoadString(IDS_FILETOATTACH);
char * pName = GetAttachmentName( (char*)((const char *)cs), ALL, TRUE);
char * part = NULL;
char * filename = NULL;
char * full_path = NULL;
if (pName) {
// this assumes that there are space separators between filenames
// if the dialog getting the filenames changes to explorer style
// then this should change
if (part = strstr(pName, " ")) {
full_path = (char *) XP_ALLOC(_MAX_PATH * sizeof(char));
if(!full_path){
XP_FREEIF(pName);
return;
}
*part = NULL;
part++;
while (part) {
XP_STRCPY (full_path, "");
XP_STRCAT (full_path, pName);
if (*(full_path + strlen (full_path) - 1) != '\\')
XP_STRCAT (full_path, "\\");
filename = strstr(part, " ");
if (filename) {
*filename = NULL;
filename++;
}
XP_STRCAT (full_path, part);
AddAttachment(full_path);
part = filename;
}
XP_FREE(full_path);
}
else
AddAttachment(pName);
}
if (pName)
XP_FREE(pName);
pFocusWnd->SetFocus();
UpdateAttachments();
}
void CNSAttachmentList::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
switch (nChar)
{
case VK_INSERT:
AttachFile();
break;
case VK_DELETE:
RemoveAttachment();
break;
}
CListBox::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CNSAttachmentList::RemoveAttachment()
{
int idx = GetCurSel();
if (idx != LB_ERR)
{
MSG_AttachmentData * pAttach =
(MSG_AttachmentData*)GetItemData(idx);
ASSERT(pAttach);
if (pAttach == NULL)
return;
XP_FREE(pAttach);
DeleteString(idx);
CComposeBar * pComposeBar = (CComposeBar*)GetParent();
pComposeBar->UpdateAttachmentInfo(GetCount());
if (idx >= GetCount())
SetCurSel(idx-1);
UpdateAttachments();
}
}
void CNSAttachmentList::Cleanup()
{
int iCount = GetCount();
for (int i = 0; i<iCount; i++) {
MSG_AttachmentData * pAttach =
(MSG_AttachmentData*)GetItemData(i);
if (pAttach != NULL)
{
if (pAttach->url)
XP_FREE((void*)pAttach->url);
if (pAttach->desired_type)
XP_FREE((void*)pAttach->desired_type);
if (pAttach->real_type)
XP_FREE((void*)pAttach->real_type);
if (pAttach->description)
XP_FREE((void*)pAttach->description);
if (pAttach->real_name)
XP_FREE((void*)pAttach->real_name);
}
SetItemData(i,NULL);
}
}
void CNSAttachmentList::UpdateAttachments()
{
int iCount = GetCount();
if (iCount != LB_ERR)
{
MSG_AttachmentData * pAttachList =
(MSG_AttachmentData *)XP_CALLOC(iCount+1,sizeof(MSG_AttachmentData));
if (!pAttachList)
return;
for (int i = 0; i<iCount; i++) {
MSG_AttachmentData * pAttach =
(MSG_AttachmentData*)GetItemData(i);
if (pAttach != NULL)
XP_MEMCPY(&pAttachList[i],pAttach,sizeof(MSG_AttachmentData));
}
ASSERT(GetMsgPane());
MSG_SetAttachmentList(GetMsgPane(),pAttachList);
XP_FREE(pAttachList);
}
}
char * CNSAttachmentList::GetAttachmentName(
char * prompt, int type, XP_Bool bMustExist, BOOL * pOpenIntoEditor)
{
OPENFILENAME fname;
char * full_path = NULL;
char name[_MAX_FNAME];
char* filter = wfe_ConstructFilterString(type);
/* initialize the OPENFILENAME struct */
BOOL result;
UINT index = (type == HTM_ONLY) ? 1 : type;
// space for the full path name
full_path = (char *) XP_ALLOC(_MAX_PATH * sizeof(char));
if(!full_path){
XP_FREE(filter);
return(NULL);
}
name[0] = '\0';
full_path[0] = '\0';
// set up the entries
fname.lStructSize = sizeof(OPENFILENAME);
fname.hwndOwner = m_hWnd;
fname.lpstrFilter = filter;
fname.lpstrCustomFilter = NULL;
fname.nFilterIndex = index;
fname.lpstrFile = full_path;
fname.nMaxFile = _MAX_PATH;
fname.lpstrFileTitle = name;
fname.nMaxFileTitle = _MAX_FNAME;
fname.lpstrInitialDir = NULL;
fname.lpstrTitle = prompt;
fname.Flags = OFN_HIDEREADONLY;
fname.lpstrDefExt = NULL;
if(bMustExist)
fname.Flags |= OFN_FILEMUSTEXIST;
if (!pOpenIntoEditor)
fname.Flags |= OFN_ALLOWMULTISELECT;
result = FEU_GetOpenFileName(&fname);
XP_FREE(filter);
// see if the user selects a file or hits cancel
if(result) {
return(full_path);
} else {
// user hit cancel
if(full_path) XP_FREE(full_path);
return(NULL);
}
}
UINT CNSAttachmentList::ItemFromPoint(CPoint pt, BOOL& bOutside) const
{
RECT rect;
GetClientRect(&rect);
int iHeight = GetItemHeight(0);
int iCount = GetCount();
int iTopIndex = GetTopIndex();
int iListHeight = iHeight * ( iCount - iTopIndex );
rect.bottom = rect.bottom < iListHeight ? rect.bottom : iListHeight;
bOutside = !::PtInRect(&rect, pt);
if ( bOutside ) {
return 0;
}
return (pt.y / iHeight) + iTopIndex;
}
//=============================================================== OnLButtonDown
void CNSAttachmentList::OnLButtonDown(UINT nFlags, CPoint point)
{
CListBox::OnLButtonDown(nFlags, point);
BOOL bOutside;
if (!GetCount())
{
AttachFile();
return;
}
int nNewSelect = ItemFromPoint( point, bOutside );
CRect rect;
GetItemRect(nNewSelect,rect);
if (((point.y+rect.Height())/rect.Height())+GetTopIndex()>GetCount())
{
AttachFile();
}
}
/////////////////////////////////////////////////////////////////////////////
// CLocationDlg dialog
CLocationDlg::CLocationDlg(char * pUrl, CWnd* pParent /*=NULL*/)
: CDialog(CLocationDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLocationDlg)
m_Location = pUrl;
//}}AFX_DATA_INIT
}
void CLocationDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLocationDlg)
DDX_Control(pDX, IDC_EDIT1, m_LocationBox);
DDX_Text(pDX, IDC_EDIT1, m_Location);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLocationDlg, CDialog)
//{{AFX_MSG_MAP(CLocationDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLocationDlg message handlers
BOOL CLocationDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_LocationBox.SetFocus();
m_LocationBox.SetSel(0,-1);
return FALSE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL wfe_GetBookmarkData( COleDataObject* pDataObject, char ** ppURL, char ** ppTitle );
BOOL CNSAttachmentList::ProcessDropTarget(COleDataObject * pDataObject)
{
HGLOBAL hString = NULL;
char * pString = NULL;
UINT clipFormat;
// Get any string data
if (pDataObject->IsDataAvailable(
::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT)))
{
char * pURL = NULL, *pTitle = NULL;
wfe_GetBookmarkData(pDataObject, &pURL, &pTitle);
if (pURL)
{
if (!strnicmp(pURL,"addbook",7))
return FALSE;
if (!strnicmp(pURL,"mailto",6))
return FALSE;
AddAttachment(pURL);
UpdateAttachments();
}
return TRUE;
}
else if (pDataObject->IsDataAvailable(
clipFormat=::RegisterClipboardFormat(NETSCAPE_MESSAGE_FORMAT)))
{
HGLOBAL hContent = pDataObject->GetGlobalData (clipFormat);
MailNewsDragData *pDragData = (MailNewsDragData *) GlobalLock(hContent);
if (pDragData != NULL)
{
for (int i = 0; i< pDragData->m_count; i++)
{
ASSERT(pDragData->m_indices);
MessageKey key = MSG_GetMessageKey(pDragData->m_pane, pDragData->m_indices[i]);
URL_Struct* pUrl = MSG_ConstructUrlForMessage(pDragData->m_pane, key);
if (pUrl != NULL)
{
if (pUrl->address)
AddAttachment(pUrl->address);
NET_FreeURLStruct(pUrl);
}
}
UpdateAttachments();
}
return TRUE;
}
return FALSE;
}
void CNSAttachmentList::OnDropFiles( HDROP hDropInfo )
{
UINT wNumFilesDropped = ::DragQueryFile(hDropInfo,(UINT)-1,NULL,0);
if (wNumFilesDropped > 0)
{
for (UINT x = 0; x < wNumFilesDropped; x++)
{
int wPathnameSize = ::DragQueryFile(hDropInfo, x, NULL, 0);
char * pStr = (char*)XP_CALLOC(1,wPathnameSize+2);
ASSERT(pStr);
// Copy the pathname into the buffer & add to listbox
::DragQueryFile(hDropInfo, x, pStr, wPathnameSize+1);
AddAttachment(pStr);
XP_FREE(pStr);
}
UpdateAttachments();
}
}
void CNSAttachmentList::OnDestroy(void)
{
Cleanup();
CListBox::OnDestroy();
}
void CNSAttachmentList::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
if (lpDrawItemStruct->itemID != -1)
{
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
HBRUSH hRegBrush = ::CreateSolidBrush( GetSysColor( COLOR_WINDOW ) );
HPEN hRegPen = ::CreatePen( PS_SOLID, 1, GetSysColor ( COLOR_WINDOW ) );
HBRUSH hHighBrush = ::CreateSolidBrush( GetSysColor( COLOR_HIGHLIGHT ) );
HPEN hHighPen = ::CreatePen( PS_SOLID, 1, GetSysColor ( COLOR_HIGHLIGHT ) );
HBRUSH hOldBrush = (HBRUSH) dc.SelectObject ( hRegBrush );
HPEN hOldPen = (HPEN) dc.SelectObject ( hRegPen );
COLORREF cOldText = dc.SetTextColor ( GetSysColor ( COLOR_WINDOWTEXT ) );
COLORREF cOldBk = dc.SetBkColor ( GetSysColor ( COLOR_WINDOW ) );
CRect rect(lpDrawItemStruct->rcItem);
BOOL bSelected = lpDrawItemStruct->itemState & ODS_SELECTED;
if (bSelected && (GetFocus()==this))
{
dc.SelectObject ( hHighBrush );
dc.SelectObject ( hHighPen );
dc.SetTextColor ( GetSysColor ( COLOR_HIGHLIGHTTEXT ) );
dc.SetBkColor ( GetSysColor ( COLOR_HIGHLIGHT ) );
}
dc.Rectangle(rect);
MSG_AttachmentData * pAttach = (MSG_AttachmentData *)lpDrawItemStruct->itemData;
if (pAttach)
{
char* pFilePath = NULL;
char * pszString =
(pAttach->real_name && strlen(pAttach->real_name)) ? pAttach->real_name : pAttach->url;
int idBitmap = 0;
if (!strnicmp(pAttach->url, "file:", strlen("file:")))
{
idBitmap = IDB_FILEATTACHMENT;
if (XP_STRCHR(pAttach->url, '#'))
{
char* pTemp = XP_STRCHR(pAttach->url, ':');
pFilePath = XP_NetToDosFileName(pTemp + 4); // remove :/// 4 bytes
}
else if (pszString == pAttach->url)
{
XP_ConvertUrlToLocalFile(pAttach->url, &pFilePath);
}
if (pFilePath)
{
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath(pFilePath, NULL, NULL, fname, ext);
*pFilePath = '\0';
strcat(pFilePath, fname);
strcat(pFilePath, ext);
pszString = pFilePath; // rhp - move this into the conditional - or crash in MAPI
}
// pszString = pFilePath;
}
else if (MSG_RequiresNewsWindow(pAttach->url))
idBitmap = IDB_NEWSARTICLE;
else if (MSG_RequiresMailWindow(pAttach->url))
idBitmap = IDB_MAILMESSAGE;
else if (MSG_RequiresBrowserWindow(pAttach->url))
idBitmap = IDB_WEBATTACHMENT;
else
idBitmap = IDB_WEBATTACHMENT;
rect.left += BITMAP_WIDTH + 4;
dc.DrawText(pszString,strlen(pszString),rect,DT_LEFT|DT_VCENTER);
rect.left -= BITMAP_WIDTH + 4;
if (pFilePath)
XP_FREE(pFilePath);
BITMAP bitmap;
CBitmap cbitmap;
cbitmap.LoadBitmap(MAKEINTRESOURCE(idBitmap));
cbitmap.GetObject(sizeof(BITMAP),&bitmap);
int center_x = 2;
int center_y = rect.top + (rect.Height()-bitmap.bmHeight)/2;
DrawTransparentBitmap(
dc.GetSafeHdc(),
(HBITMAP)cbitmap.GetSafeHandle(),
center_x, center_y,
RGB(255,0,255));
cbitmap.DeleteObject();
}
if (bSelected)
dc.DrawFocusRect(rect);
dc.SetTextColor ( cOldText );
dc.SetBkColor ( cOldBk );
dc.SelectObject ( hOldPen );
dc.SelectObject ( hOldBrush );
dc.Detach();
VERIFY(DeleteObject( hRegBrush ));
VERIFY(DeleteObject( hRegPen ));
VERIFY(DeleteObject( hHighBrush ));
VERIFY(DeleteObject( hHighPen ));
}
}
//=============================================================== MeasureItem
void CNSAttachmentList::MeasureItem( LPMEASUREITEMSTRUCT lpMeasureItemStruct )
{
lpMeasureItemStruct->itemHeight = BITMAP_HEIGHT + 2;
}
//================================================================ DeleteItem
void CNSAttachmentList::DeleteItem( LPDELETEITEMSTRUCT lpDeleteItemStruct )
{
}
//////////////////////////////////////////////////////////////////////////////
// CNSAttachDropTarget
DROPEFFECT CNSAttachDropTarget::OnDragEnter(CWnd *, COleDataObject *, DWORD, CPoint)
{
DROPEFFECT DropEffect = DROPEFFECT_NONE;
return(DropEffect);
}
DROPEFFECT CNSAttachDropTarget::OnDragOver(CWnd * pWnd,
COleDataObject * pDataObject, DWORD dwKeyState, CPoint point)
{
DROPEFFECT deReturn = DROPEFFECT_NONE;
// Only interested in bookmarks
if (pDataObject->IsDataAvailable(
::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT)))
{
deReturn = DROPEFFECT_COPY;
}
else if (pDataObject->IsDataAvailable(
::RegisterClipboardFormat(NETSCAPE_MESSAGE_FORMAT)))
{
deReturn = DROPEFFECT_COPY;
}
else if(pDataObject->IsDataAvailable(
::RegisterClipboardFormat(vCardClipboardFormat)) )
{
deReturn = DROPEFFECT_COPY;
}
return(deReturn);
}
void CNSAttachDropTarget::OnDragLeave(CWnd *)
{
}
static LPSTR getDataObjectNewsURL(COleDataObject * pDataObject)
{
if (!pDataObject->IsDataAvailable(::RegisterClipboardFormat(NETSCAPE_BOOKMARK_FORMAT)))
return FALSE;
char * szURL = NULL;
char * szTitle = NULL;
wfe_GetBookmarkData(pDataObject, &szURL, &szTitle);
if((strnicmp(szURL, "news", 4) == 0) || (strnicmp(szURL, "snews", 5) == 0))
return szURL;
else
return NULL;
}
BOOL CNSAttachDropTarget::OnDrop(CWnd * pWnd, COleDataObject * pDataObject, DROPEFFECT effect, CPoint point)
{
CComposeFrame * pFrame = (CComposeFrame*)pWnd->GetParentFrame();
CComposeBar * pComposeBar = pFrame->GetComposeBar();
#ifdef MOZ_NEWADDR
if(pDataObject->IsDataAvailable(::RegisterClipboardFormat(ADDRESSBOOK_INDEX_FORMAT)))
{
pComposeBar->OnAddressTab();
pComposeBar->UpdateWindow();
pComposeBar->ProcessAddressBookIndexFormat(pDataObject,effect, point);
return TRUE;
}
else
#endif
if(pDataObject->IsDataAvailable(::RegisterClipboardFormat(vCardClipboardFormat)) )
{
pComposeBar->OnAddressTab();
pComposeBar->UpdateWindow();
return pComposeBar->ProcessVCardData(pDataObject,point);
}
else
{
// do not put news URLs to attachment
char * szURL = getDataObjectNewsURL(pDataObject);
if(szURL != NULL)
{
pComposeBar->OnAddressTab();
pComposeBar->UpdateWindow();
return pComposeBar->AddURLToAddressPane(pDataObject, point, szURL);
}
else
{
pComposeBar->OnAttachTab();
pComposeBar->UpdateWindow();
return pComposeBar->m_pAttachmentList->ProcessDropTarget(pDataObject);
}
}
}

View File

@@ -0,0 +1,101 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __COMPFILE_H
#define __COMPFILE_H
#include "msgcom.h"
#include "winproto.h"
class CNSAttachDropTarget;
class CNSAttachmentList : public CListBox
{
public:
HFONT m_cfTextFont;
CNSAttachmentList(MSG_Pane * pPane = NULL);
~CNSAttachmentList();
CNSAttachDropTarget * m_pDropTarget;
MSG_Pane * m_pPane;
MSG_Pane * GetMsgPane() { return m_pPane; }
void AttachFile();
void AttachUrl(char * pUrl = NULL);
void RemoveAttachment();
void UpdateAttachments();
char * GetAttachmentName(
char * prompt, int type = ALL, XP_Bool bMustExist = TRUE, BOOL * pOpenIntoEditor = NULL);
void Cleanup();
void AddAttachment(char * pName);
BOOL Create(CWnd * pWnd, UINT id);
BOOL ProcessDropTarget(COleDataObject * pDataObject);
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
afx_msg void OnDropFiles( HDROP hDropInfo );
protected:
UINT ItemFromPoint(CPoint pt, BOOL& bOutside) const;
afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) ;
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnDelete();
afx_msg void OnDestroy();
afx_msg void OnUpdateDelete(CCmdUI * pCmdUI);
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// CLocationDlg dialog
class CLocationDlg : public CDialog
{
// Construction
public:
CLocationDlg(char * pUrl = NULL, CWnd* pParent = NULL); // standard constructor
char * m_pUrl;
// Dialog Data
//{{AFX_DATA(CLocationDlg)
enum { IDD = IDD_ATTACHLOCATION };
CEdit m_LocationBox;
CString m_Location;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLocationDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CLocationDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif

1926
mozilla/cmd/winfe/compfrm.cpp Executable file

File diff suppressed because it is too large Load Diff

250
mozilla/cmd/winfe/compfrm.h Executable file
View File

@@ -0,0 +1,250 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
/* COMPFRM.H - header file for the ComposeFrame class.
*/
#ifndef __COMPFRM_H
#define __COMPFRM_H
#include "msgcom.h"
#include "mainfrm.h"
#include "edframe.h"
#include "compmisc.h"
#include "apiaddr.h"
#include "statbar.h"
// Message used to synchronize setting the initial keyboard focus in the
// compose window. This message is posted to the compose window by
// FE_CreateCompositionPane just before returning.
#define WM_COMP_SET_INITIAL_FOCUS WM_TOOLCONTROLLER + 1
#define ID_ENCRYPTED 1011
#define ID_SIGNED 1012
// rhp - Flags for MAPI operations...
#define MAPI_IGNORE 0
#define MAPI_SEND 1
#define MAPI_SAVE 2
#define MAPI_QUITWHENDONE 3
// Forward declarations
class CNSAddressList; // address list widget
class CEditToolBarController; // HTML toolbar controlling object
class CComposeBar; // embedded address/attachment area
// CComposeFrame class declaration
class CComposeFrame : public CGenericFrame
{
DECLARE_DYNCREATE(CComposeFrame)
protected:
CComposeFrame(); // protected constructor used by dynamic creation
~CComposeFrame();
MSG_Pane *m_pComposePane; // Backend supplied pane context
CNetscapeStatusBar m_barStatus;
CComposeBar * m_pComposeBar; // address/attachment block widget
BOOL m_bUseHtml;
BOOL m_bInitialized;
CEditToolBarController * m_pToolBarController;
// these are used for plain text
CComposeEdit m_Editor; // regular text editor - to be replaced by Gold editor
int32 m_quoteSel; // current plain text qutoing position
CBlankWnd m_EditorParent; // controls resizing the edit control (going away when Gold integrated)
CWnd * m_pFocus; // field which has focus in control
HFONT m_cfTextFont; // font to use in the edit control
MSG_HEADER_SET m_SavedHeaders; // hackery to redraw headers once we become visible and
MWContext * m_pOldContext;
MSG_CompositionFields * m_pFields;
char *m_pInitialText; // initial text
BOOL m_bWrapLongLines;
int m_cxChar;
int m_bMAPISendMode; // rhp - for MAPI Send Operations
public:
// data access functions
inline int GetCharWidth() { return m_cxChar; }
inline BOOL GetWrapLongLines() { return m_bWrapLongLines; }
inline void SetComposeStuff(MWContext *pOld, MSG_CompositionFields * pFields)
{ m_pOldContext = pOld; m_pFields = pFields; }
inline BOOL UseHtml(void) { return m_bUseHtml; }
inline CWnd * GetFocusField(void) { return m_pFocus; }
inline void SetFocusField(CWnd * pwnd = NULL) { m_pFocus = pwnd; }
inline MSG_Pane * GetMsgPane(void) { return m_pComposePane; }
inline void SetToolBarController(CEditToolBarController * pController = NULL) {
m_pToolBarController = pController;
}
inline CEditToolBarController * GetToolBarController(void) {
return m_pToolBarController;
}
inline CComposeEdit * GetEditor(void) { return &m_Editor; }
inline int32 GetQuoteSel(void) { return m_quoteSel; }
inline void SetQuoteSel(int32 sel) { m_quoteSel = sel; }
inline CBlankWnd * GetEditorParent(void) { return &m_EditorParent; }
inline CComposeBar * GetComposeBar(void) { return m_pComposeBar; }
inline void SetComposeBar(CComposeBar *pBar = NULL) { m_pComposeBar = pBar; }
inline void SetSavedHeaders(MSG_HEADER_SET headers) { m_SavedHeaders = headers; }
inline MSG_HEADER_SET GetSavedHeaders(void) { return m_SavedHeaders; }
inline BOOL Initialized(void) { return m_bInitialized; }
LPADDRESSCONTROL GetAddressWidgetInterface();
// public interface
void SetQuoteSelection(void);
void SetMsgPane(MSG_Pane * pPane = NULL);
void SetModified(BOOL bvalue);
void CompleteComposeInitialization(void); // gold specific stuff
void GoldDoneLoading(void);
void InsertInitialText(void);
void SetInitialText(const char *pText);
inline const char *GetInitialText() { return m_pInitialText; };
virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
AFX_CMDHANDLERINFO* pHandlerInfo);
#ifdef XP_WIN32
virtual int16 GetTitleWinCSID(); // jliu
#endif
BOOL AppendAddress(MSG_HEADER_SET header, const char * value);
void SetType(MWContextType type);
void SetCSID(int16 iCSID);
void UpdateToolBar(void);
BOOL CreateEditBars();
void DisplayHeaders ( MSG_HEADER_SET );
CWnd * GetEditorWnd();
void UpdateAttachmentInfo(void);
void SetHtmlMode(BOOL bMode = FALSE);
void UpdateSecurityOptions(void);
BOOL BccOnly(void);
virtual void RefreshNewEncoding(int16 doc_csid, BOOL bSave = TRUE);
// rhp - For MAPI Operations!
inline void SetMAPISendMode(int bSendMode) { m_bMAPISendMode = bSendMode; }; // rhp - for MAPI
inline int GetMAPISendMode(void) { return m_bMAPISendMode; }; // rhp - for MAPI
void UpdateComposeWindowForMAPI(void); // rhp - for MAPISendMail()
// Overriden for setting the command help for editor plugin tools and edit history list
virtual void GetMessageString(UINT MenuID, CString& Message) const;
protected:
virtual BOOL PreTranslateMessage( MSG* pMsg );
virtual BOOL PreCreateWindow ( CREATESTRUCT & );
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext *pContext);
virtual BOOL CanCloseFrame(void);
void OnUpdateThis ( CCmdUI* pCmdUI, MSG_CommandType tMenuType );
void MessageCommand( MSG_CommandType );
void ConvertToPlainText();
void ConvertToHtml();
void DoSend( BOOL bNow = TRUE );
int CreateHtmlToolbars();
void CreatePlainTextEditor();
void ShowHtmlToolbars();
void DestroyHtmlToolbars();
void SetEditorParent(CWnd*);
char * PromptMessageSubject();
void MakeComposeBarVisible();
afx_msg void OnNew();
afx_msg void OnConvert();
afx_msg void OnAttachMyCard();
afx_msg void OnUpdateAttachMyCard(CCmdUI * pCmdUI);
afx_msg void OnUpdateConvert(CCmdUI*pCmdUI);
afx_msg void OnUpdateButtonGeneral(CCmdUI* pCmdUI);
afx_msg LONG OnToolController(UINT,LONG);
afx_msg void OnPasteQuote( void );
afx_msg void OnUpdatePasteQuote(CCmdUI *);
afx_msg void OnSelectAll(void);
afx_msg void OnUpdateSelectAll(CCmdUI *);
afx_msg void OnButtonTo(void);
afx_msg void OnQuoteOriginal ( void );
afx_msg void OnSaveAs( void );
afx_msg void OnSaveDraft(void);
afx_msg void OnSaveTemplate(void);
afx_msg void OnAttachFile(void);
afx_msg void OnCheckSpelling(void);
afx_msg void OnUpdateCheckSpelling(CCmdUI * pCmdUI);
afx_msg void OnDoneGoingOffline(void);
afx_msg void OnUpdateSaveDraft( CCmdUI * pCmdUI );
afx_msg void OnUpdateSaveTemplate( CCmdUI * pCmdUI );
afx_msg void OnSend(void);
afx_msg void OnSendNow(void);
afx_msg void OnSendLater(void);
afx_msg void OnUpdateSend(CCmdUI * pCmdUI);
afx_msg void OnUpdateSendNow(CCmdUI * pCmdUI);
afx_msg void OnUpdateSendLater(CCmdUI * pCmdUI);
afx_msg void OnUpdateAttach ( CCmdUI * pCmdUI );
afx_msg void OnShowSecurityAdvisor ();
afx_msg void OnSetFocus(CWnd *);
afx_msg int OnCreate ( LPCREATESTRUCT );
afx_msg void OnClose ( void );
afx_msg void OnDestroy(void);
afx_msg void OnAttachUrl(void);
afx_msg void OnSelectAddresses(void);
afx_msg void OnWrapLongLines(void);
afx_msg void OnUpdateWrapLongLines(CCmdUI*pCmdUI);
afx_msg void OnViewAddresses();
afx_msg void OnViewAttachments();
afx_msg void OnViewOptions();
afx_msg void OnUpdateViewAddresses(CCmdUI * pCmdUI);
afx_msg void OnUpdateViewAttachments(CCmdUI * pCmdUI);
afx_msg void OnUpdateViewOptions(CCmdUI * pCmdUI);
afx_msg void OnToggleMessageToolbar();
afx_msg void OnUpdateToggleMessageToolbar(CCmdUI *pCmdUI);
afx_msg void OnToggleAddressArea();
afx_msg void OnUpdateToggleAddressArea(CCmdUI * pCmdUI);
afx_msg void OnSecurity();
afx_msg void OnAttachTab(void);
afx_msg void OnAddressTab(void);
afx_msg void OnOptionsTab(void);
afx_msg void OnCollapse(void);
afx_msg void OnUpdateSecurity(CCmdUI *pCmdUI);
afx_msg void OnUpdateSecureStatus(CCmdUI *pCmdUI);
afx_msg void OnUpdateToggleNameCompletion(CCmdUI *pCmdUI);
afx_msg void OnToggleNameCompletion();
afx_msg void OnUpdateShowNamePicker(CCmdUI *pCmdUI);
afx_msg void OnShowNamePicker();
afx_msg LONG OnSetInitialFocus(WPARAM wParam, LPARAM lParam);
LRESULT OnButtonMenuOpen(WPARAM wParam, LPARAM lParam);
afx_msg void OnUpdateEncoding(CCmdUI* pCmdUI);
afx_msg LRESULT OnFindReplace(WPARAM wParam, LPARAM lParam) ;
afx_msg LRESULT OnSetMessageString(WPARAM wParam, LPARAM lParam);
afx_msg LONG OnProcessMAPIMessage(WPARAM wParam, LPARAM lParam); // rhp: for MAPI
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
#endif

View File

@@ -0,0 +1,136 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
/* COMPFRM.CPP - Compose Window Frame. This module contains code for the
* compose window frame class. Handles all menu and tool commands.
*
*/
#include "stdafx.h"
#include "edt.h"
#include "compbar.h"
#include "compfrm.h"
#include "prefapi.h"
#include "addrdlg.h"
#include "intl_csi.h"
extern "C" {
#include "xpgetstr.h"
extern int MK_MSG_SAVE_AS;
extern int MK_MSG_CANT_OPEN;
extern int MK_MSG_MISSING_SUBJECT;
};
#ifdef XP_WIN32
#include "postal.h"
#endif
#include "netsvw.h"
void CComposeFrame::SetEditorParent(CWnd * pWnd)
{
CWinCX * pWinCX = (CWinCX*)GetMainContext();
// after the window is created, tell the browser view to resize the
// parent which resizes the editor.
if (pWinCX)
{
CNetscapeView * pView = (CNetscapeView*)pWinCX->GetView();
if (pView)
pView->SetChild (pWnd);
}
}
void CComposeFrame::SetHtmlMode(BOOL bMode)
{
m_bUseHtml = bMode;
}
void CComposeFrame::SetQuoteSelection(void)
{
int32 eReplyOnTop = 0;
if (PREF_NOERROR == PREF_GetIntPref("mailnews.reply_on_top", &eReplyOnTop) &&
eReplyOnTop != 0) {
// call backend with insertion call-back
if (UseHtml())
{
int32 offset = EDT_GetInsertPointOffset( GetMainContext()->GetContext() );
SetQuoteSel(offset);
}
else
{
int tmpStartSel, tmpEndSel;
GetEditor()->GetSel(tmpStartSel, tmpEndSel);
// we only care about start position
SetQuoteSel((int32) tmpStartSel);
}
}
}
CWnd * CComposeFrame::GetEditorWnd(void)
{
if (m_bUseHtml)
{
CWinCX * pWinCX = (CWinCX*)GetMainContext();
HWND hwnd = pWinCX->GetPane();
return CWnd::FromHandle(hwnd);
}
return (CWnd *)&m_Editor;
}
void CComposeFrame::UpdateAttachmentInfo(void)
{
ASSERT(m_pComposeBar);
m_pComposeBar->UpdateAttachmentInfo(MSG_GetAttachmentList(GetMsgPane()) ? 1 : 0);
}
BOOL CComposeFrame::PreTranslateMessage( MSG* pMsg )
{
if (pMsg->message == WM_KEYDOWN)
{
if (pMsg->wParam == VK_TAB)
{
BOOL bControl = GetKeyState(VK_CONTROL) & 0x8000;
BOOL bShift = GetKeyState(VK_SHIFT) & 0x8000;
CWnd * pWnd = CWnd::FromHandle(pMsg->hwnd);
if (GetComposeBar()->TabControl(bShift, bControl, pWnd))
return TRUE;
}
}
else if (pMsg->message == WM_COMMAND)
{
int ID = (int)LOWORD(pMsg->wParam);
if (ID == ID_CHECK_SPELLING)
{
OnCheckSpelling();
return TRUE;
}
}
return CGenericFrame::PreTranslateMessage(pMsg);
}
void CComposeFrame::OnSelectAddresses()
{
CAddrDialog AddressDialog(this);
GetComposeBar()->OnAddressTab();
GetComposeBar()->UpdateWindow();
CWnd * pWnd = GetFocus();
AddressDialog.DoModal();
pWnd->SetFocus();
}

View File

@@ -0,0 +1,256 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "allxpstr.h"
#include "xpgetstr.h"
typedef struct {
char * pszTo;
char * pszSubject;
char * pszOrganization;
} MAPI_HEADER_INFO;
static MAPI_HEADER_INFO _temp;
#ifdef XP_WIN32
extern "C" int FE_LoadExchangeInfo(
MWContext * context,
char * pszTo, char * pszCc, char * pszBcc,
char * pszOrganization,
char * pszNewsgroups,
char * pszSubject);
#endif
#define MAX_MAIL_SIZE 300000
extern "C" void FE_DoneMailTo(PrintSetup * print)
{
ASSERT(print);
MWContext * context = (MWContext *) print->carg;
CGenericFrame * pFrame = wfe_FrameFromXPContext(context);
ASSERT(pFrame);
fclose(print->out);
char * buffer;
buffer = (char *) malloc(MAX_MAIL_SIZE + 5);
FILE * fp = fopen(print->filename, "r");
int len = fread(buffer, 1, MAX_MAIL_SIZE + 5, fp);
buffer[len] = '\0';
fclose(fp);
if(theApp.m_hPostalLib) {
if(theApp.m_bInitMapi) {
if(theApp.m_fnOpenMailSession) {
POSTCODE status = (*theApp.m_fnOpenMailSession) (NULL, NULL);
if(status == POST_OK) {
theApp.m_bInitMapi = FALSE;
}
}
}
// create mail window with no quoting
if(theApp.m_fnComposeMailMessage)
(*theApp.m_fnComposeMailMessage) ((const char *) _temp.pszTo,
(const char *) "", /* no refs field. BAD! BUG! */
(const char *) _temp.pszOrganization,
(const char *) "", /* no URL */
(const char *) _temp.pszSubject,
buffer,
(const char *) "",
(const char *) "");
if (strlen(_temp.pszTo))
free(_temp.pszTo);
if (strlen(_temp.pszSubject))
free(_temp.pszSubject);
if (strlen(_temp.pszOrganization))
free(_temp.pszOrganization);
// get rid of the file and free the memory
remove(print->filename);
// XP_FREE(print->filename);
// print->filename = NULL;
XP_FREE(buffer);
return;
}
}
extern "C" int FE_LoadExchangeInfo(
MWContext * context,
char * pszTo, char * pszCc, char * pszBcc,
char * pszOrganization,
char * pszNewsgroups,
char * pszSubject)
{
#ifdef MOZ_NGLAYOUT
XP_ASSERT(0);
#else
_temp.pszTo = _temp.pszSubject = _temp.pszOrganization = "";
if(!context)
return(FALSE);
if(!theApp.m_hPostalLib)
return(FALSE);
History_entry * hist_ent = NULL;
if(context)
hist_ent = SHIST_GetCurrent(&(context->hist));
CString csURL;
if(hist_ent)
csURL = hist_ent->address;
else
csURL = "";
if (!pszSubject || !strlen(pszSubject))
pszSubject = (char *)(const char *)csURL;
//Set hist_ent to NULL if context->title is "Message Composition"
//This is a nasty way of determining if we're in here in response
//to "Mail Doc" or "New Mail Message".
//Also, if there's To: field info present(pBar->m_pszTo) then
//we know that it's a Mailto: and set hist_ent to NULL
//Without this differentiation the code always sends the contents
//of the previously mailed document even when someone chooses
//"New Mail Message" or "Mailto:"
if(!strcmp(XP_GetString(MK_MSG_MSG_COMPOSITION), context->title) || strlen(pszTo) )
hist_ent = NULL;
// make sure there was a document loaded
if(!hist_ent) {
if(theApp.m_bInitMapi) {
if(theApp.m_fnOpenMailSession) {
POSTCODE status = (*theApp.m_fnOpenMailSession) (NULL, NULL);
if(status == POST_OK) {
theApp.m_bInitMapi = FALSE;
}
else {
return(FALSE);
}
}
}
// create mail window with no quoting
if(theApp.m_fnComposeMailMessage)
(*theApp.m_fnComposeMailMessage) (
(const char *)pszTo,
(const char *) "", /* no refs field. BAD! BUG! */
(const char *)pszOrganization,
(const char *) "", /* no URL */
(const char *)pszSubject,
"",
(const char *)pszCc,
(const char *)pszBcc);
return(TRUE);
}
URL_Struct * URL_s = SHIST_CreateURLStructFromHistoryEntry(context, hist_ent);
// Zero out the saved data
memset(&URL_s->savedData, 0, sizeof(URL_s->savedData));
PrintSetup print;
XL_InitializeTextSetup(&print);
print.width = 68;
print.prefix = "";
print.eol = "\r\n";
char * name = WH_TempName(xpTemporary, NULL);
if(!name) {
return(FALSE);
}
print.out = fopen(name, "w");
print.completion = (XL_CompletionRoutine) FE_DoneMailTo;
print.carg = context;
print.filename = name;
print.url = URL_s;
if (pszSubject && strlen(pszSubject))
_temp.pszSubject = strdup(pszSubject);
if (pszTo && strlen(pszTo))
_temp.pszTo = strdup(pszTo);
if (pszOrganization && strlen(pszOrganization))
_temp.pszOrganization = strdup(pszOrganization);
// leave pCompose window alive until completion routine
XL_TranslateText(context, URL_s, &print);
#endif /* MOZ_NGLAYOUT */
return(TRUE);
}
void InitializeMapi(void)
{
}
extern "C" void DoAltMailComposition(MWContext *pContext)
{
if ( pContext )
{
FE_LoadExchangeInfo(
pContext,
"",
"",
"",
(char *)FE_UsersOrganization(),
"",
"");
}
}
extern "C" void FE_AlternateCompose(
char * from, char * reply_to, char * to, char * cc, char * bcc,
char * fcc, char * newsgroups, char * followup_to,
char * organization, char * subject, char * references,
char * other_random_headers, char * priority,
char * attachment, char * newspost_url, char * body)
{
if(theApp.m_bInitMapi) {
if(theApp.m_fnOpenMailSession) {
POSTCODE status = (*theApp.m_fnOpenMailSession) (NULL, NULL);
if(status == POST_OK) {
theApp.m_bInitMapi = FALSE;
}
else
return;
}
}
// create mail window with no quoting
if(theApp.m_fnComposeMailMessage)
(*theApp.m_fnComposeMailMessage) (
(const char *)to,
(const char *)references,
(const char *)(organization ? organization : FE_UsersOrganization()),
(const char *)"",
(const char *)subject,
(const char *)body,
(const char *)cc,
(const char *)bcc );
}

View File

@@ -0,0 +1,557 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
/* COMPMISC.CPP - Contains controls which are utilized in the compose
* window address/attachment block. Also contains the resizer control
* which resizes the text edit control
*/
#include "stdafx.h"
#include "compmisc.h"
#include "compfrm.h"
#include "compbar.h"
#include "findrepl.h"
#include "spellcli.h" // spell checker client
#include "prefapi.h"
#ifdef XP_WIN32
#define EDIT_CONTROL_BUFFER_SIZE UINT_MAX
#else
#define EDIT_CONTROL_BUFFER_SIZE ((UINT)(32*1024))
#endif
/////////////////////////////////////////////////////////////////////////////
// CBlankWnd - resizes the edit control and restores focus to the appropriate
// field.
BEGIN_MESSAGE_MAP(CBlankWnd,CWnd)
ON_EN_CHANGE(IDC_COMPOSEEDITOR,OnChange)
ON_WM_ERASEBKGND()
ON_WM_SIZE()
ON_WM_SETFOCUS()
ON_WM_PAINT()
ON_WM_CREATE()
ON_WM_DESTROY()
END_MESSAGE_MAP()
#define INDICATOR_WIDTH 5
#define INDICATOR_COLOR RGB(113,113,255)
PR_CALLBACK PrefSetWrapCol(const char *pPref, void *pData)
{
int32 iCol;
PREF_GetIntPref("mailnews.wraplength", &iCol);
CBlankWnd * pEditorWindow = (CBlankWnd *)pData;
pEditorWindow->SetWrapCol(iCol);
pEditorWindow->Invalidate(TRUE);// must pass TRUE
}
int CBlankWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
m_lWrapCol = 0L;
//register call back for wrap long line
PREF_RegisterCallback("mailnews.wraplength", PrefSetWrapCol, (void *)this);
PREF_GetIntPref("mailnews.wraplength",&m_lWrapCol);
return 0;
}
void CBlankWnd::OnDestroy()
{
PREF_UnregisterCallback("mailnews.wraplength", PrefSetWrapCol, this);
CWnd::OnDestroy();
}
void CBlankWnd::OnPaint()
{
CPaintDC dc(this);
CComposeFrame * pFrame = (CComposeFrame*)GetParentFrame();
if (pFrame->GetWrapLongLines())
{
CRect rect;
GetClientRect(rect);
int iPos = ((int)GetWrapCol()) * pFrame->GetCharWidth();
if (iPos < rect.Width())
{
CPen pen(PS_SOLID,1,INDICATOR_COLOR);
CPen * pOldPen = dc.SelectObject(&pen);
iPos -= (INDICATOR_WIDTH/2);
dc.MoveTo(iPos,1);
dc.LineTo(iPos+INDICATOR_WIDTH,1);
dc.MoveTo(iPos+1,2);
dc.LineTo((iPos+INDICATOR_WIDTH)-1,2);
dc.SetPixel(iPos+2,3,INDICATOR_COLOR);
dc.SelectObject(pOldPen);
}
}
}
void CBlankWnd::OnSetFocus(CWnd *)
{
// when focus is given to this window... focus is passed off to the
// last field which had focus.
CComposeFrame * pFrame = (CComposeFrame*)GetParentFrame();
if (pFrame->GetFocusField() && IsWindow(pFrame->GetFocusField()->m_hWnd))
pFrame->GetFocusField()->SetFocus();
}
void CBlankWnd::OnChange(void)
{
// the backend should be notified that the text has been
// changed whener an edit occurs
CComposeFrame * pFrame = (CComposeFrame*)GetParentFrame();
m_bModified = TRUE;
}
BOOL CBlankWnd::OnEraseBkgnd (CDC * pdc)
{
// erase the background with the default brush
CRect rect;
CBrush Brush(GetSysColor(COLOR_WINDOW));
GetClientRect (&rect);
pdc->FillRect (rect, &Brush);
return TRUE;
}
void CBlankWnd::OnSize ( UINT nType, int cx, int cy )
{
// resize the editor whenver this window is resized.
// a border is given on the left so that the cursor doesn't
// but right up against the edge (looks bad)
CWnd::OnSize ( nType, cx, cy );
CRect rect ( EDIT_MARGIN_OFFSET, EDIT_TOP_MARGIN, cx, cy );
CComposeFrame * pFrame = (CComposeFrame*)GetParent()->GetParent();
if (IsWindow(pFrame->GetEditor()->m_hWnd))
pFrame->GetEditor()->MoveWindow ( rect );
}
/////////////////////////////////////////////////////////////////////////////
// CComposeEdit - This is the regular text edit control. This is probably
//
BEGIN_MESSAGE_MAP(CComposeEdit, CGenericEdit)
ON_WM_KEYDOWN()
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_COMMAND(ID_CHECK_SPELLING, OnCheckSpelling)
// edit menu
ON_COMMAND(ID_EDIT_CUT,OnCut)
ON_COMMAND(ID_EDIT_COPY,OnCopy)
ON_COMMAND(ID_EDIT_PASTE,OnPaste)
ON_COMMAND(ID_EDIT_UNDO,OnUndo)
ON_COMMAND(idm_redo,OnRedo)
ON_COMMAND(ID_EDIT_DELETE,OnDelete)
ON_COMMAND(IDM_SELECTALL,OnSelectAll)
ON_COMMAND(IDM_FINDAGAIN,OnFindAgain)
ON_COMMAND(IDM_FINDINMESSAGE,OnFindInMessage)
ON_REGISTERED_MESSAGE(WM_FINDREPLACE, OnFindReplace)
ON_UPDATE_COMMAND_UI(ID_EDIT_CUT,OnUpdateCut)
ON_UPDATE_COMMAND_UI(ID_EDIT_COPY,OnUpdateCopy)
ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE,OnUpdatePaste)
ON_UPDATE_COMMAND_UI(IDM_PASTEASQUOTE,OnUpdatePasteAsQuote)
ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO,OnUpdateUndo)
ON_UPDATE_COMMAND_UI(ID_EDIT_DELETE,OnUpdateDelete)
ON_UPDATE_COMMAND_UI(IDM_SELECTALL,OnUpdateSelectAll)
ON_UPDATE_COMMAND_UI(IDM_FINDINMESSAGE,OnUpdateFindInMessage)
ON_UPDATE_COMMAND_UI(IDM_FINDAGAIN,OnUpdateFindAgain)
END_MESSAGE_MAP()
CComposeEdit::CComposeEdit(CComposeFrame * pFrame)
{
m_pComposeFrame = pFrame;
m_cxChar = 1;
#ifdef XP_WIN16
// win16 edit control's memory is by default, allocated from the heap.. which is
// usually not enough.... so create a 32K message buffer
m_hTextElementSegment = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, EDIT_CONTROL_BUFFER_SIZE);
#endif
}
CComposeEdit::~CComposeEdit()
{
#ifdef XP_WIN16
// free up the 16bit memory buffer
if (m_hTextElementSegment)
GlobalFree(m_hTextElementSegment);
#endif
}
#ifdef XP_WIN16
//
// The creator of this form element should have created a segment for
// us to live in before we got here. Tell Windows to use that
// segment rather than the application's so that we don't run out of
// DGROUP space
//
BOOL CComposeEdit::PreCreateWindow( CREATESTRUCT& cs )
{
// during a precreate in happy 16bit land, lock the edit data
// buffer and tell the control to use it.
if (CGenericEdit::PreCreateWindow(cs)) {
ASSERT(m_hTextElementSegment);
if(!m_hTextElementSegment)
return TRUE;
LPVOID lpEditDC = (LPVOID) GlobalLock(m_hTextElementSegment);
if (lpEditDC) {
UINT uSegment = HIWORD((LONG) lpEditDC);
if (LocalInit((UINT)uSegment,0,(WORD)(GlobalSize(m_hTextElementSegment)-16))) {
cs.hInstance = (HINSTANCE) uSegment;
UnlockSegment(uSegment);
}
else
GlobalUnlock(m_hTextElementSegment);
}
return TRUE;
}
return FALSE;
}
#endif
void CComposeEdit::OnSetFocus(CWnd * pWnd)
{
// When focus is set to the edit field, tell the parent
CGenericEdit::OnSetFocus(pWnd);
CComposeFrame * pFrame = (CComposeFrame*)GetParentFrame();
pFrame->SetFocusField(this);
}
int CComposeEdit::OnCreate ( LPCREATESTRUCT lpcs )
{
// set up the fonts, get the character size
int iRet = CGenericEdit::OnCreate ( lpcs );
LimitText(EDIT_CONTROL_BUFFER_SIZE);
CClientDC dc ( this );
LOGFONT lf;
XP_MEMSET(&lf,0,sizeof(LOGFONT));
CComposeFrame * pFrame = (CComposeFrame*)GetParentFrame();
lf.lfPitchAndFamily = FF_MODERN | FIXED_PITCH;
strcpy(lf.lfFaceName, IntlGetUIFixFaceName(pFrame->m_iCSID));
lf.lfCharSet = IntlGetLfCharset(pFrame->m_iCSID);
lf.lfHeight = -MulDiv(9,dc.GetDeviceCaps(LOGPIXELSY), 72);
lf.lfQuality = PROOF_QUALITY;
if (m_cfRegFont) {
theApp.ReleaseAppFont(m_cfRegFont);
}
m_cfRegFont = theApp.CreateAppFont( lf );
TEXTMETRIC tm;
CFont * pOldFont = dc.SelectObject(CFont::FromHandle(m_cfRegFont));
dc.GetTextMetrics(&tm);
dc.SelectObject(pOldFont);
m_cxChar = tm.tmAveCharWidth;
::SendMessage(GetSafeHwnd(), WM_SETFONT, (WPARAM)m_cfRegFont, FALSE);
return iRet;
}
void CComposeEdit::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags )
{
// process the tab key so that it properly tabs between the
// address block and the editor.
if ((nChar==VK_TAB)&&(GetKeyState(VK_SHIFT)&0x8000)) {
CComposeFrame * pFrame = (CComposeFrame*)GetParentFrame();
MSG msg;
while (PeekMessage(&msg,m_hWnd,WM_KEYFIRST,WM_KEYLAST,PM_REMOVE))
;
CComposeBar * pBar = pFrame->GetComposeBar();
ASSERT(pBar);
if (pBar)
pBar->m_pSubjectEdit->SetFocus();
}
else
{
CGenericEdit::OnKeyDown(nChar,nRepCnt,nFlags);
}
}
void CComposeEdit::OnCheckSpelling()
{
CPlainTextSpellChecker SpellChecker(this);
if (SpellChecker.ProcessDocument() != 0)
ASSERT(FALSE);
}
void CComposeEdit::OnCut()
{
Cut();
}
void CComposeEdit::OnCopy()
{
Copy();
}
void CComposeEdit::OnPaste()
{
Paste();
}
void CComposeEdit::OnUndo()
{
Undo();
}
void CComposeEdit::OnRedo()
{
}
void CComposeEdit::OnDelete()
{
if (GetFocus() == this)
Clear();
}
void CComposeEdit::OnFindInMessage()
{
CNetscapeFindReplaceDialog *dlg;
dlg = new CNetscapeFindReplaceDialog();
dlg->Create(TRUE,
theApp.m_csFindString,
NULL,
FR_DOWN | FR_NOWHOLEWORD | FR_HIDEWHOLEWORD | FR_NOUPDOWN,
GetParentFrame());
}
void CComposeEdit::OnFindAgain()
{
FindText();
}
void CComposeEdit::OnUpdateCut(CCmdUI * pCmdUI)
{
if (GetFocus() == this)
pCmdUI->Enable(IsSelection());
}
void CComposeEdit::OnUpdateCopy(CCmdUI * pCmdUI)
{
if (GetFocus() == this)
pCmdUI->Enable(IsSelection());
}
void CComposeEdit::OnUpdatePaste(CCmdUI * pCmdUI)
{
if (GetFocus() == this)
pCmdUI->Enable(IsClipboardData());
}
BOOL CComposeEdit::IsSelection()
{
int nStart, nEnd;
GetSel(nStart,nEnd);
return ((nEnd-nStart)>0);
}
BOOL CComposeEdit::IsClipboardData()
{
BOOL retVal = FALSE;
OpenClipboard();
if (GetClipboardData(CF_TEXT)) {
retVal = TRUE;
}
CloseClipboard();
return retVal;
}
void CComposeEdit::OnUpdatePasteAsQuote(CCmdUI * pCmdUI)
{
if (GetFocus() == this)
pCmdUI->Enable(IsClipboardData());
}
void CComposeEdit::OnUpdateUndo(CCmdUI * pCmdUI)
{
if (GetFocus() == this)
pCmdUI->Enable(CanUndo());
}
void CComposeEdit::OnUpdateDelete(CCmdUI * pCmdUI)
{
if (GetFocus() == this)
pCmdUI->Enable(IsSelection());
}
void CComposeEdit::OnUpdateFindInMessage(CCmdUI * pCmdUI)
{
if ( GetWindowTextLength() > 0 && (GetFocus() == this))
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
void CComposeEdit::OnUpdateFindAgain(CCmdUI * pCmdUI)
{
if ((theApp.m_csFindString && strlen(theApp.m_csFindString)) && (GetFocus() == this))
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
void CComposeEdit::OnSelectAll()
{
SetSel(0,-1);
SetFocus();
}
void CComposeEdit::OnUpdateSelectAll(CCmdUI *pCmdUI)
{
pCmdUI->Enable(TRUE);
}
BEGIN_MESSAGE_MAP(CComposeSubjectEdit, CGenericEdit)
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
END_MESSAGE_MAP()
void CComposeSubjectEdit::OnSetFocus(CWnd * pWnd)
{
// When focus is set to the edit field, tell the parent
CGenericEdit::OnSetFocus(pWnd);
CComposeFrame * pFrame = (CComposeFrame*)GetParentFrame();
pFrame->SetFocusField(this);
}
void CComposeSubjectEdit::OnKillFocus(CWnd * pWnd)
{
CGenericEdit::OnKillFocus(pWnd);
CComposeFrame * pFrame = (CComposeFrame*)GetParentFrame();
CString cs;
GetWindowText(cs);
if (cs.GetLength())
pFrame->GetChrome()->SetDocumentTitle(cs);
}
BOOL CComposeSubjectEdit::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
if (pMsg->wParam == VK_RETURN)
{
CComposeFrame * pFrame = (CComposeFrame*)GetParentFrame();
pFrame->GetComposeBar()->TabControl(FALSE,FALSE,this);
return TRUE;
}
if (pMsg->wParam == 'v' || pMsg->wParam == 'V')
{
if (GetKeyState(VK_CONTROL)&0x8000)
{
Paste();
return TRUE;
}
}
else if (pMsg->wParam == VK_INSERT)
{
if (GetKeyState(VK_SHIFT)&0x8000)
{
Paste();
return TRUE;
}
else if (GetKeyState(VK_CONTROL)&0x8000)
{
Copy();
return TRUE;
}
}
else if (pMsg->wParam == 'x' || pMsg->wParam == 'X')
{
if (GetKeyState(VK_CONTROL)&0x8000)
{
Cut();
return TRUE;
}
}
else if (pMsg->wParam == 'c' || pMsg->wParam == 'C')
{
if (GetKeyState(VK_CONTROL)&0x8000)
{
Copy();
return TRUE;
}
}
}
return CEdit::PreTranslateMessage(pMsg);
}
LRESULT CComposeEdit::OnFindReplace(WPARAM wParam, LPARAM lParam)
{
CFindReplaceDialog * dlg = ::CFindReplaceDialog::GetNotifier(lParam);
if (!dlg)
return NULL;
FINDREPLACE findstruct = dlg->m_fr;
if (dlg->IsTerminating()) {
return NULL;
}
// Something wrong or user cancelled dialog box
if(!(findstruct.Flags & FR_FINDNEXT))
return NULL;
// remember this string for next time
theApp.m_csFindString = findstruct.lpstrFindWhat;
theApp.m_csReplaceString = findstruct.lpstrReplaceWith;
theApp.m_bMatchCase = dlg->MatchCase();
theApp.m_bSearchDown = dlg->SearchDown();
return (LRESULT) FindText();
}
BOOL CComposeEdit::FindText()
{
CString cs, csSearch = theApp.m_csFindString;
GetWindowText(cs);
int nStart, nEnd;
GetSel(nStart,nEnd);
if (!theApp.m_bMatchCase)
{
cs.MakeLower();
csSearch.MakeLower();
}
if (!cs.IsEmpty())
{
int ipos = nEnd;
int ipos2;
LPCSTR lpcstr = cs;
if ((ipos2 = CString(&lpcstr[ipos]).Find(csSearch)) != -1)
{
SetSel(ipos + ipos2, ipos + ipos2 + strlen(csSearch));
return(TRUE);
}
}
return FALSE;
}

View File

@@ -0,0 +1,118 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __COMPMISC_H
#define __COMPMISC_H
#include "compstd.h"
#include "mainfrm.h"
#include "edframe.h"
class CComposeSubjectEdit : public CGenericEdit {
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
afx_msg void OnSetFocus(CWnd * pWnd);
afx_msg void OnKillFocus(CWnd*);
DECLARE_MESSAGE_MAP();
};
class CBlankWnd : public CWnd
{
public:
CBlankWnd () : CWnd ( )
{
m_bModified = FALSE;
}
BOOL m_bModified;
void SetModified(BOOL bValue) { m_bModified = bValue; }
void SetWrapCol(int32 lCol) { m_lWrapCol = lCol; }
int32 GetWrapCol() { return m_lWrapCol; }
protected:
int32 m_lWrapCol;
afx_msg BOOL OnEraseBkgnd( CDC* pDC );
afx_msg void OnSize ( UINT nType, int cx, int cy );
afx_msg void OnChange(void);
afx_msg void OnSetFocus(CWnd*);
afx_msg void OnPaint(void);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
DECLARE_MESSAGE_MAP();
};
class CComposeFrame;
class CComposeEdit : public CGenericEdit
{
protected:
CComposeFrame * m_pComposeFrame;
HFONT m_cfRegFont;
int m_cxChar;
#ifdef XP_WIN16
HGLOBAL m_hTextElementSegment;
BOOL PreCreateWindow( CREATESTRUCT& cs );
#endif
public:
CComposeEdit(CComposeFrame * pFrame = NULL);
void SetComposeFrame(CComposeFrame * pFrame)
{
m_pComposeFrame = pFrame;
}
~CComposeEdit();
BOOL FindText();
BOOL IsClipboardData();
BOOL IsSelection();
int GetCharWidth() { return m_cxChar; }
afx_msg void OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags );
afx_msg int OnCreate ( LPCREATESTRUCT );
afx_msg void OnSetFocus ( CWnd * );
afx_msg void OnCheckSpelling();
// edit menu
afx_msg void OnCut();
afx_msg void OnCopy();
afx_msg void OnPaste();
afx_msg void OnUndo();
afx_msg void OnRedo();
afx_msg void OnDelete();
afx_msg void OnFindInMessage();
afx_msg void OnFindAgain();
afx_msg void OnUpdateCut(CCmdUI * pCmdUI);
afx_msg void OnUpdateCopy(CCmdUI * pCmdUI);
afx_msg void OnUpdatePaste(CCmdUI * pCmdUI);
afx_msg void OnUpdatePasteAsQuote(CCmdUI * pCmdUI);
afx_msg void OnUpdateUndo(CCmdUI * pCmdUI);
afx_msg void OnUpdateRedo(CCmdUI * pCmdUI);
afx_msg void OnUpdateDelete(CCmdUI * pCmdUI);
afx_msg void OnUpdateFindInMessage(CCmdUI * pCmdUI);
afx_msg void OnUpdateFindAgain(CCmdUI * pCmdUI);
afx_msg void OnSelectAll();
afx_msg void OnUpdateSelectAll(CCmdUI *pCmdUI);
afx_msg LRESULT OnFindReplace(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
};
#endif

View File

@@ -0,0 +1,97 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
/* COMPSTD.H - standard Compose window header file contains standard
* definitions which are used throughout all comp*.* files.
*/
#ifndef __COMPSTD_H
#define __COMPSTD_H
#include "msgcom.h"
#define IDX_COMPOSEADDRESS 0 // tab indexes for attach/address
#define IDX_COMPOSEATTACH 1
#define IDX_COMPOSEOPTIONS 2
#define IDX_COMPOSEATTACHFILE 3
#define IDX_COMPOSEATTACHMAIL 4
#define IDX_TOOL_ADDRESS 0
#define IDX_TOOL_ATTACH 1
#define IDX_TOOL_OPTIONS 2
#define IDX_TOOL_COLLAPSE 3
#define EDIT_FIELD_OFFSET 4 // pixel border surrounding fields
#define EDIT_MARGIN_OFFSET 4
#define EDIT_TOP_MARGIN 4
#define IDC_ADDRESSADD 150
#define IDC_ADDRESSREMOVE 151
#define IDC_ADDRESSSELECT 152
#define IDC_DIRECTORY 153
#define IDC_ADDRESSTAB 155
#define IDC_ATTACHTAB 156
#define IDC_OPTIONSTAB 157
#define TABCTRL_HOME -2
#define TABCTRL_END -1
#define IDC_COMPOSEEDITOR 338 // control id for editor
#define FLIPPY_WIDTH 16 // width and height of the expansion bitmap
#define FLIPPY_HEIGHT 16
extern char * EDT_NEW_DOC_URL; // this is for the Gold editor. Loading this
// URL causes the creation of a new (blank)
// editor file.
class CNSAttachDropTarget : public COleDropTarget
{
public:
//Construction
CNSAttachDropTarget() { };
BOOL OnDrop(CWnd *, COleDataObject *, DROPEFFECT, CPoint);
DROPEFFECT OnDragEnter(CWnd *, COleDataObject *, DWORD, CPoint);
DROPEFFECT OnDragOver(CWnd *, COleDataObject *, DWORD, CPoint);
void OnDragLeave(CWnd *);
};
extern "C" int FE_LoadExchangeInfo(MWContext * context);
// temporary functions to allow the regular text editor to be functional
extern "C" int FE_GetMessageBody(
MSG_Pane *pPane,
char **ppBody,
uint32 *ulBodySize,
MSG_FontCode **ppFontChanges);
extern "C" void FE_InsertMessageCompositionText(
MWContext * context,
const char* text,
XP_Bool leaveCursorAtBeginning);
////////////////////////////////////////////////////////////
// backend candidates
MSG_HEADER_SET MSG_StringToHeaderMask(char * string);
const char * MSG_HeaderMaskToString(MSG_HEADER_SET header);
////////////////////////////////////////////////////////////
// end backend candidates
#endif

View File

@@ -0,0 +1,295 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// confhook.cpp : implementation file
//
#include "stdafx.h"
#include <shellapi.h>
#include "confhook.h"
extern "C" {
#include "xpgetstr.h"
extern int MK_MSG_CANT_FIND_CALLPOINT;
};
//
// NEEDED STRINGS
// ==============
// MK_MSG_CANT_FIND_CONFAPP - Can't find the app to run
// IDS_CONFAPP - "Conferencing Application" type string, I think?
//
//
// Other internal defines...
//
#define CONFAPP_UNAVAILABLE 0
#define CONFAPP_CONFERENCE 1
#define CONFAPP_THIRDPARTY 2
//
// Registry stuff:
//
#define _MAX_ARG_LEN_ 128
//
// Sections for profile lookups...
//
static TCHAR lpszWin32ConfAppBranch[] = _T("Software\\Netscape\\ConfApplication");
static TCHAR lpszWin16ConfAppSection[] = _T("ConfApplication");
static int confAppAvailibility = CONFAPP_UNAVAILABLE;
BOOL
FileExists(LPCSTR szFile)
{
struct _stat buf;
int result;
result = _stat( szFile, &buf );
return (result == 0);
}
//
// This routine is specific to looking up values in the new ConfApp
// registry/ini file section.
//
CString
FEU_GetConfAppProfileString(const CString &queryString)
{
char argBuffer[_MAX_PATH + 1];
CString returnVal("");
returnVal = "";
strcpy(argBuffer, "");
//
// If the defined conference application on the system is
// still a leftover NSCP Conference, we should still use
// that setting. In this case, simply return the default
// value for Netscape Conference.
//
if (confAppAvailibility == CONFAPP_CONFERENCE)
{
//
// First, we will assign a value to argBuffer that corresponds
// to NSCP Conference's value for this particular argument.
//
if (queryString == IDS_CONFAPP_FULLPATHNAME)
{
CString installDirectory, executable;
#ifdef WIN32
installDirectory = FEU_GetInstallationDirectory(szLoadString(IDS_CONFERENCE_REGISTRY), szLoadString(IDS_PATHNAME));
executable = "\\NSCONF32.EXE";
#else // XP_WIN16
installDirectory = FEU_GetInstallationDirectory(szLoadString(IDS_CONFERENCE),szLoadString(IDS_INSTALL_DIRECTORY));
executable = "\\NSCSTART.EXE";
#endif
wsprintf(argBuffer, "%s%s", installDirectory, executable);
}
else if (queryString == IDS_CONFAPP_NOBANNER)
{
strcpy(argBuffer, "/b");
}
else if (queryString == IDS_CONFAPP_MIMEFILE)
{
strcpy(argBuffer, "/f");
}
else if (queryString == IDS_CONFAPP_DIRECTIP)
{
strcpy(argBuffer, "/d");
}
else if (queryString == IDS_CONFAPP_EMAIL)
{
strcpy(argBuffer, "/i");
}
else if (queryString == IDS_CONFAPP_SERVER)
{
strcpy(argBuffer, "/s");
}
else if (queryString == IDS_CONFAPP_USERNAME)
{
strcpy(argBuffer, "");
}
returnVal = argBuffer;
return returnVal;
}
#ifdef _WIN32
HKEY hKey;
LONG lResult;
char szVal[_MAX_PATH + 1];
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpszWin32ConfAppBranch, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
{
unsigned long cbData = sizeof(szVal);
lResult = RegQueryValueEx(hKey, queryString, NULL, NULL, (LPBYTE) szVal, &cbData);
RegCloseKey(hKey);
if (lResult == ERROR_SUCCESS)
{
returnVal = szVal;
}
}
#else // XP_WIN16
char szPath[_MAX_PATH + 1];
const char *pOldProfile = theApp.m_pszProfileName;
UINT nSize = GetWindowsDirectory(szPath, _MAX_PATH + 1);
XP_STRCPY(szPath + nSize, szLoadString(IDS_NSCPINI));
theApp.m_pszProfileName = szPath;
returnVal = theApp.GetProfileString(lpszWin16ConfAppSection, queryString, NULL);
theApp.m_pszProfileName = pOldProfile;
#endif
return returnVal;
}
//
// This function is needed to see if a conferencing endpoint
// is defined on the machine. Return true if there is or false
// if it doesn't exist.
//
BOOL
FEU_IsConfAppAvailable(void)
{
//
// Check to see if a conf. app is defined on the local
// machine.
//
CString fileName = FEU_GetConfAppProfileString(IDS_CONFAPP_FULLPATHNAME);
if (fileName.IsEmpty())
{
if (FEU_IsConferenceAvailable())
{
confAppAvailibility = CONFAPP_CONFERENCE;
return TRUE;
}
else
{
confAppAvailibility = CONFAPP_UNAVAILABLE;
return FALSE;
}
}
//
// We should really make sure there is something at the location
// defined before we go further.
//
if (FileExists(fileName))
{
confAppAvailibility = CONFAPP_THIRDPARTY;
return TRUE;
}
else
{
confAppAvailibility = CONFAPP_UNAVAILABLE;
return FALSE;
}
}
//
// This will be the central function where we will do the launching
// of Conference on this endpoint.
//
// Args: makeCall - true if this is going to make a call or false
// if we are just launching the appliction.
//
void
LaunchConfEndpoint(char *commandLine, HWND parent)
{
CString executable;
char *cline = commandLine;
char cbuf[_MAX_ARG_LEN_];
executable = FEU_GetConfAppProfileString(IDS_CONFAPP_FULLPATHNAME);
//
// Check to see if the executable is defined on the machine. If it is not, then
// show a message and return.
//
if (executable.IsEmpty())
{
CString s;
if (s.LoadString( IDS_CONFERENCE ))
{
::MessageBox(parent, XP_GetString(MK_MSG_CANT_FIND_CALLPOINT), s, MB_OK | MB_APPLMODAL);
}
return;
}
//
// Check if the commandline is null...if so, we need to try to find the banner
// suppression flag and pass it to the executable.
//
if (!commandLine)
{
CString nobannerFlag = FEU_GetConfAppProfileString(IDS_CONFAPP_NOBANNER);
strcpy(cbuf, nobannerFlag);
cline = &(cbuf[0]);
}
int uSpawn = (int) ShellExecute(NULL, "open", executable, cline, ".", SW_SHOW);
if(uSpawn <= 32)
{
char szMsg[80];
switch(uSpawn)
{
case 0:
case 8:
sprintf(szMsg, szLoadString(IDS_WINEXEC_0_8));
break;
case 2:
case 3:
sprintf(szMsg, szLoadString(IDS_WINEXEC_2_3));
break;
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
sprintf(szMsg, szLoadString(IDS_WINEXEC_10_THRU_15));
break;
case 16:
sprintf(szMsg, szLoadString(IDS_WINEXEC_16));
break;
case 21:
sprintf(szMsg, szLoadString(IDS_WINEXEC_21));
break;
default:
sprintf(szMsg, szLoadString(IDS_WINEXEC_XX), uSpawn);
break;
}
CString s;
if (s.LoadString( IDS_BOOKMARK_ADDRESSPROPERTIES ))
{
::MessageBox(parent, szMsg, s, MB_OK | MB_APPLMODAL);
}
}
}

View File

@@ -0,0 +1,68 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
//
// This is a header file for the confhook.cpp file.
// Written by: Rich Pizzarro (rhp)
//
#ifndef _CONFHOOK
#define _CONFHOOK
//
// Defines needed for registry key names...
//
#define IDS_CONFAPP_FULLPATHNAME "FullPathName"
#define IDS_CONFAPP_NOBANNER "BannerSuppressionFlag"
#define IDS_CONFAPP_MIMEFILE "MIMEFileFlag"
#define IDS_CONFAPP_DIRECTIP "DirectIPFlag"
#define IDS_CONFAPP_EMAIL "EmailCallFlag"
#define IDS_CONFAPP_SERVER "QueryServerFlag"
#define IDS_CONFAPP_USERNAME "UserNameFlag"
//
// This routine will launch the conferencing endpoint define to the
// machine.
//
// Arguments:
// commandLine: This is the command line to pass into the
// conferencing application.
//
//
void
LaunchConfEndpoint(char *commandLine, HWND parentWnd = NULL);
//
// This routine is specific to looking up values in the new ConfApp
// registry/ini file section.
//
CString
FEU_GetConfAppProfileString(const CString &queryString);
//
// This function is needed to see if a conferencing endpoint
// is defined on the machine. Return true if there is or false
// if it doesn't exist.
//
BOOL
FEU_IsConfAppAvailable(void);
#endif // _CONFHOOK

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,355 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 _CSTTLBR2_H
#define _CSTTLBR2_H
#include "stdafx.h"
#include "toolbar2.h"
#include "animbar2.h"
#define CT_HIDETOOLBAR (WM_USER + 15)
#define CT_DRAGTOOLBAR (WM_USER + 16)
#define CT_DRAGTOOLBAR_OVER (WM_USER + 17)
#define CT_CUSTOMIZE (WM_USER + 18)
#define IDC_COLLAPSE (WM_USER + 19)
typedef enum {eLARGE_HTAB, eSMALL_HTAB} HTAB_BITMAP;
class CCustToolbar;
#ifdef XP_WIN16
class CNetscapeControlBar : public CControlBar {
protected:
virtual LRESULT WindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam);
};
#endif
// Class: CToolbarWindow
//
// The window that resides within the Tabbed toolbar. It holds the toolbar
// passed in by the user of the customizable toolbar
class CToolbarWindow {
protected:
CWnd *m_pToolbar; // the toolbar we're storing
int m_nNoviceHeight; // the height when in novice mode
int m_nAdvancedHeight; // the height when in advanced mode
int m_nToolbarStyle; // is this pictures and text, pictures, or text
HTAB_BITMAP m_nHTab; // Type of horizontal tab
public:
CToolbarWindow(CWnd *pToolbar, int nToolbarStyle, int nNoviceHeight, int nAdvancedHeight,
HTAB_BITMAP nHTab);
~CToolbarWindow();
CWnd *GetToolbar(void);
virtual CWnd* GetNSToolbar() { return NULL; }
// if bWindowHeight is TRUE then use toolbar's height, if FALSE use passed in height
virtual int GetHeight(void);
int GetNoviceHeight(void) { return m_nNoviceHeight; }
int GetAdvancedHeight(void) { return m_nAdvancedHeight; }
virtual void SetToolbarStyle(int nToolbarStyle) { m_nToolbarStyle = nToolbarStyle;}
int GetToolbarStyle(void) { return m_nToolbarStyle; }
HTAB_BITMAP GetHTab(void) { return m_nHTab; }
virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler ){}
virtual void UpdateURLBars(char* url) {}
};
// Class: CButtonToolbarWindow
//
// The window that resides within the Tabbed toolbar. It MUST hold a CNSToolbar2.
class CButtonToolbarWindow: public CToolbarWindow {
public:
CButtonToolbarWindow(CWnd *pToolbar, int nToolbarStyle, int nNoviceHeight, int nAdvancedHeight,
HTAB_BITMAP nHTab);
virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler );
virtual void UpdateURLBars(char* url);
virtual void SetToolbarStyle(int nToolbarStyle);
virtual int GetHeight(void);
virtual CWnd* GetNSToolbar() { return GetToolbar(); }
};
// Class: // Class: CControlBarToolbarWindow
//
// The window that resides within the Tabbed toolbar. It does not hold a CNSToolbar2.
class CControlBarToolbarWindow: public CToolbarWindow {
public:
CControlBarToolbarWindow(CWnd *pToolbar, int nToolbarStyle, int nNoviceHeight, int nAdvancedHeight,
HTAB_BITMAP nHTab);
virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler );
virtual int GetHeight(void);
};
class CDragToolbar : public CWnd {
protected:
CToolbarWindow * m_pToolbar;
BOOL m_bIsOpen;
BOOL m_bIsShowing;
CPoint m_mouseDownPoint;
BOOL m_bDragging;
BOOL m_bMouseDown;
UINT m_nDragTimer;
BOOL m_bMouseInTab;
UINT m_nTabFocusTimer;
CAnimationBar2* m_pAnimation;
HTAB_BITMAP m_eHTabType;
BOOL m_bEraseBackground;
CString m_tabTip;
int m_nToolID;
CNSToolTip2 m_toolTip;
UINT m_nToolbarID;
public:
CDragToolbar();
~CDragToolbar();
int Create(CWnd *pParent, CToolbarWindow *pToolbar);
virtual BOOL ShouldClipChildren() { return TRUE; }
CWnd *GetToolbar(void);
int GetToolbarHeight(void);
int GetMouseOffsetWithinToolbar(void) { return m_mouseDownPoint.y; }
void SetMouseOffsetWithinToolbar(int y) { m_mouseDownPoint.y = y; }
void SetShowing(BOOL bIsShowing) { m_bIsShowing = bIsShowing; }
BOOL GetShowing(void) { return m_bIsShowing; }
void SetOpen(BOOL bIsOpen) { m_bIsOpen = bIsOpen; }
BOOL GetOpen(void) { return m_bIsOpen;}
void SetTabTip(CString tabTip);
CString &GetTabTip (void) { return m_tabTip; }
void SetToolID(int nToolID) { m_nToolID = nToolID; }
int GetToolID(void) { return m_nToolID; }
void SetToolbarID(int nToolbarID) {m_nToolbarID = nToolbarID;}
UINT GetToolbarID(void) { return m_nToolbarID;}
void SetToolbarStyle(int nToolbarStyle);
void SetAnimation(CAnimationBar2 *pAnimation);
HTAB_BITMAP GetHTabType(void) { return m_eHTabType;}
void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler );
virtual void UpdateURLBars(char* url);
// Generated message map functions
//{{AFX_MSG(CDragToolbar)
afx_msg void OnSize( UINT nType, int cx, int cy );
afx_msg void OnPaint(void);
afx_msg void OnShowWindow( BOOL bShow, UINT nStatus );
afx_msg BOOL OnEraseBkgnd( CDC* pDC );
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
virtual afx_msg void OnTimer( UINT nIDEvent );
afx_msg void OnPaletteChanged( CWnd* pFocusWnd );
afx_msg void OnSysColorChange();
//}}AFX_MSG
private:
void ArrangeToolbar(int nWidth, int nHeight);
void StopDragging(void);
void CheckIfMouseInTab(CPoint point);
DECLARE_MESSAGE_MAP()
};
class CCustToolbarExternalTab {
private:
CWnd * m_pOwner;
HTAB_BITMAP m_eHTabType;
CString m_tabTip;
int m_nToolID;
UINT m_nTabID;
public:
CCustToolbarExternalTab(CWnd *pOwner, HTAB_BITMAP eHTabType, UINT nTipID, UINT nTabID);
CWnd *GetOwner(void);
HTAB_BITMAP GetHTabType(void);
CString &GetTabTip (void);
void SetToolID(int nToolID) { m_nToolID = nToolID; }
int GetToolID(void) { return m_nToolID; }
UINT GetTabID(void);
};
class CRDFToolbar;
class CCustToolbar : public CControlBar {
private:
CFrameWnd * m_pParent;
CDragToolbar** m_pToolbarArray;
CDragToolbar** m_pHiddenToolbarArray;
int m_nNumToolbars;
int m_nActiveToolbars;
CAnimationBar2* m_pAnimation; //The Netscape Icon Animation
int m_nAnimationPos;
int m_nNumOpen;
int m_nNumShowing;
CPoint m_oldDragPoint;
HBITMAP m_pHorizTabArray[4];
BOOL m_bEraseBackground;
CNSToolTip2 m_toolTip;
BOOL m_bSaveToolbarInfo; // Do we save toolbar state
UINT m_nTabHaveFocusTimer;
int m_nMouseOverTab;
CPtrArray m_externalTabArray;
BOOL m_bBottomBorder;
enum HORIZTAB {LARGE_FIRST, LARGE_OTHER, SMALL_FIRST, SMALL_OTHER};
public:
//Construction/destruction
CCustToolbar(int nNumToolbars);
virtual ~CCustToolbar();
//Creation
int Create(CFrameWnd* pParent, BOOL bHasAnimation);
void AddNewWindow(UINT nToolbarID, CToolbarWindow* pWindow, int nPosition, int nNoviceHeight, int nAdvancedHeight,
UINT nTabBitmapIndex, CString tabTip, BOOL bIsNoviceMode, BOOL bIsOpen,
BOOL bIsAnimation);
// Call this function when you are finished adding the toolbars that go in the
// customizable toolbar.
void FinishedAddingNewWindows(void){}
CDragToolbar** GetVisibleToolbarArray() { return m_pToolbarArray; };
//Controlling the animated icon
void StopAnimation();
void StartAnimation();
void SetToolbarStyle(int nToolbarStyle);
BOOL IsWindowShowing(CWnd *pToolbar);
BOOL IsWindowShowing(UINT nToolbarID);
BOOL IsWindowIconized(CWnd *pToolbar);
int GetWindowPosition(CWnd *pToolbar);
void ShowToolbar(CWnd *pToolbar, BOOL bShow);
void ShowToolbar(UINT nToolbarID, BOOL bShow);
void RenameToolbar(UINT nOldID, UINT nNewID, UINT nNewToolTipID);
CWnd *GetToolbar(UINT nToolbarID);
//Positioning/Resizing
CSize CalcDynamicLayout(int nLength, DWORD dwMode );
virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler );
virtual void UpdateURLBars(char* url);
void Customize(CRDFToolbar *pRDFToolbar = NULL, int nSelectedButton = 0);
BOOL GetSaveToolbarInfo(void);
void SetSaveToolbarInfo(BOOL bSaveToolbarInfo);
void SetNewParentFrame(CFrameWnd *pParent);
// Adding an external tab will cause the customizable toolbar to display
// a tab of eHTabType in iconized form. If that tab is clicked, the tab
// will be removed and a message will be sent to pOwner that the hidden
// window should now be shown.
void AddExternalTab(CWnd *pOwner, HTAB_BITMAP eHTabType, UINT nTipID, UINT nTabID);
// Removing this tab will cause it to no longer be drawn and mouse clicks will no longer
// be sent to pOwner.
void RemoveExternalTab(UINT nTabID);
void SetBottomBorder(BOOL bBottomBorder);
int FindDragToolbarFromWindow(CWnd *pWindow, CDragToolbar **pToolbarArray);
int FindDragToolbarFromID(UINT nToolbarID, CDragToolbar **pToolbarArray);
// Generated message map functions
//{{AFX_MSG(CCustToolbar)
afx_msg void OnSize( UINT nType, int cx, int cy );
afx_msg void OnPaint(void);
afx_msg void OnShowWindow( BOOL bShow, UINT nStatus );
afx_msg BOOL OnEraseBkgnd( CDC* pDC );
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg LRESULT OnHideToolbar(WPARAM, LPARAM);
afx_msg LRESULT OnDragToolbar(WPARAM, LPARAM);
afx_msg LRESULT OnDragToolbarOver(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT CCustToolbar::OnCustomize(WPARAM wParam, LPARAM lParam);
#ifndef WIN32
afx_msg LRESULT OnSizeParent(WPARAM wParam, LPARAM lParam);
#endif
virtual afx_msg void OnTimer( UINT nIDEvent );
afx_msg void OnPaletteChanged( CWnd* pFocusWnd );
//}}AFX_MSG
protected:
// virtual BOOL OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* pResult );
int CheckOpenButtons(CPoint point);
int CheckClosedButtons(CPoint point);
BOOL PointInClosedTab(CPoint point, HTAB_BITMAP tabType, int nNumClosedButtons, int nStartX,
int nBottom);
void DrawSeparator(HDC hDC, int nStartX, int nEndX, int nStartY, BOOL bToolbarSeparator = TRUE);
void SwitchChildren(CDragToolbar *pOriginal, CDragToolbar *pSwitch, int dir, int yPoint);
int FindIndex(CDragToolbar *pToolbar);
CDragToolbar *FindToolbarFromPoint(CPoint point, CDragToolbar *pIgnore);
int FindFirstShowingToolbar(int nIndex);
HBITMAP GetClosedButtonBitmap(HTAB_BITMAP tabType, int nNumClosedButtons);
int GetNextClosedButtonX(HTAB_BITMAP tabType, int nNumClosedButtons, int nClosedStartX);
void GetClosedButtonRegion(HTAB_BITMAP tabType, int nNumClosedButtons, CRgn &rgn);
HBITMAP CreateHorizTab(UINT nID);
void ShowDragToolbar(int nIndex, BOOL bShow);
void OpenDragToolbar(int nIndex);
void OpenExternalTab(int nIndex);
void CheckAnimationChangedToolbar(CDragToolbar *pToolbar, int nIndex, BOOL bOpen);
void ChangeToolTips(int nHeight);
void FindToolRect(CRect & toolRect, HTAB_BITMAP eTabType, int nStartX, int nStartY, int nButtonNum);
int FindFirstAvailablePosition(void);
void DrawClosedTab(HDC hCompatibleDC, HDC hDestDC, HTAB_BITMAP tabType, int nNumClosedButtons,
BOOL bMouseOver, int nStartX, int nBottom);
virtual CDragToolbar* CreateDragBar();
DECLARE_MESSAGE_MAP()
};
#endif

View File

@@ -0,0 +1,66 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// The main file used to provide customization (locking) of preferences to
// OEM partners and/or MIS directors for the Enterprise market....
//#define WFE_FILE 1
#include "stdafx.h"
#include "custom.h"
#include "resource.h"
#include "mainfrm.h"
#include "xp.h"
#include "sechash.h"
#include "prefapi.h"
BOOL CUST_IsCustomAnimation(int * iFrames)
{
char *pFile = NULL;
BOOL bRet = FALSE;
// set iFrames to default
int iError = PREF_CopyConfigString("toolbar.logo.win_small_file",&pFile);
if (PREF_ERROR != iError && pFile) {
if (*pFile) bRet = TRUE;
XP_FREE(pFile);
pFile = NULL;
}
pFile = NULL;
iError = PREF_CopyConfigString("toolbar.logo.win_large_file",&pFile);
if (PREF_ERROR != iError && pFile) {
if (*pFile) bRet = TRUE;
XP_FREE(pFile);
pFile = NULL;
}
if (bRet) {
int32 iTmp;
PREF_GetConfigInt("toolbar.logo.frames",&iTmp);
if (iTmp > 0 && iTmp <1000) // pure arbitrary bounds check
if (iFrames) *iFrames = iTmp;
}
return bRet;
}
void CUST_LoadCustomPaletteEntries()
{
int idx;
char * entry;
char szBuf[24];
int red = 0,green = 0,blue = 0;
}

View File

@@ -0,0 +1,21 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// Prototypes
extern BOOL CUST_IsCustomAnimation(int * iFrames);
extern void CUST_LoadCustomPaletteEntries();

237
mozilla/cmd/winfe/cuvfm.cpp Executable file
View File

@@ -0,0 +1,237 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
//--------------------------------------------------------------------------------------------------------
// Unicode Virtual Font Manager used for Unicode rendering
//--------------------------------------------------------------------------------------------------------
#include "stdafx.h"
#include "cuvfm.h"
//------------------------------------------------------------------------------------------------
//
// CUnicodeVirtualFontMgr
//
//------------------------------------------------------------------------------------------------
#ifdef XP_WIN
#ifndef XP_WIN32
#define GDI_ERROR NULL
#endif
#endif
CUnicodeVirtualFontMgr::CUnicodeVirtualFontMgr(HDC in_hdc)
{
TEXTMETRIC tm;
::GetTextMetrics(in_hdc, &tm);
m_DC = in_hdc;
m_OrigFont = (HFONT)::SelectObject(in_hdc, ::GetStockObject(SYSTEM_FONT));
if(m_OrigFont != (HGDIOBJ)GDI_ERROR)
{
CFont *pFont = CFont::FromHandle(m_OrigFont);
if( (pFont) &&
#ifdef XP_WIN32
(pFont->GetLogFont(& (this->m_lf))))
#else
(::GetObject(pFont->m_hObject ,sizeof(LOGFONT), &(this->m_lf))))
#endif
{
m_bFixed = ( m_lf.lfPitchAndFamily & FIXED_PITCH );
m_iOrigAscent = tm.tmAscent;
}
::SelectObject(in_hdc, m_OrigFont);
}
}
//------------------------------------------------------------------------------------------------
//
// ~CUnicodeVirtualFontMgr()
//
//------------------------------------------------------------------------------------------------
CUnicodeVirtualFontMgr::~CUnicodeVirtualFontMgr()
{
// restore the original font when we destroy.
if(m_OrigFont != (HGDIOBJ)GDI_ERROR)
{
::SelectObject(m_DC, m_OrigFont);
}
}
//------------------------------------------------------------------------------------------------
//
// CacularAscentDelta()
//
//------------------------------------------------------------------------------------------------
int CUnicodeVirtualFontMgr::CacularAscentDelta(HDC hDC)
{
// restore the original font when we destroy.
if(m_OrigFont != (HGDIOBJ)GDI_ERROR)
{
TEXTMETRIC tm;
::GetTextMetrics(hDC, &tm);
return m_iOrigAscent - tm.tmAscent;
}
return 0;
}
//------------------------------------------------------------------------------------------------
//
// CUnicodeVirtualFontMgr::GetCsidFont
//
//------------------------------------------------------------------------------------------------
CFont* CUnicodeVirtualFontMgr::GetCsidFont(int16 encoding)
{
if(m_OrigFont != (HGDIOBJ)GDI_ERROR)
{
CFont *pFont;
if(! GetFontFromCache(encoding, pFont))
{
VERIFY(pFont = CreateFont(encoding));
if(pFont != NULL)
{
if(AddFontToCache(encoding, pFont) == FALSE)
{
delete pFont;
return NULL;
}
}
}
return pFont;
}
return NULL;
}
CyaFont *CUnicodeVirtualFontMgr::GetCsidCyaFont(HDC hdc, int16 encoding)
{
if(m_OrigFont != (HGDIOBJ)GDI_ERROR)
{
CyaFont *pFont;
if(! GetCyaFontFromCache(encoding, pFont))
{
VERIFY(pFont = CreateCyaFont(hdc, encoding));
if(pFont != NULL)
{
if(AddCyaFontToCache(encoding, pFont) == FALSE)
{
delete pFont;
return NULL;
}
}
}
return pFont;
}
return NULL;
} // GetCsidCyaFont
//------------------------------------------------------------------------------------------------
//
// CUnicodeVirtualFontMgr::CreateFont
//
//------------------------------------------------------------------------------------------------
void CUnicodeVirtualFontMgr::UpdateLOGFONTForEncoding(int16 encoding)
{
m_lf.lfCharSet = DEFAULT_CHARSET;
m_lf.lfPitchAndFamily = DEFAULT_PITCH;
switch(encoding)
{
case CS_DINGBATS:
{
strcpy(m_lf.lfFaceName, "Wingdings");
if( (! theApp.m_bUseUnicodeFont) )
m_lf.lfCharSet = SYMBOL_CHARSET;
}
break;
case CS_SYMBOL:
{
strcpy(m_lf.lfFaceName, "Symbol");
if( (! theApp.m_bUseUnicodeFont) )
m_lf.lfCharSet = SYMBOL_CHARSET;
}
break;
default:
{
EncodingInfo *pEncoding = theApp.m_pIntlFont->GetEncodingInfo(theApp.m_pIntlFont->DocCSIDtoID(encoding & ~CS_AUTO));
XP_ASSERT(pEncoding);
if(pEncoding)
{
strcpy(m_lf.lfFaceName, ((m_bFixed) ? pEncoding->szFixName : pEncoding->szPropName ));
if(sysInfo.m_bWin4)
{
if( (! theApp.m_bUseUnicodeFont) )
{
m_lf.lfCharSet = ((m_bFixed) ?
pEncoding->iFixCharset : pEncoding->iPropCharset);
}
}
}
}
break;
}
}
CFont* CUnicodeVirtualFontMgr::CreateFont(int16 encoding)
{
UpdateLOGFONTForEncoding(encoding);
CFont *pSelectThis = new CFont();
VERIFY(pSelectThis->CreateFontIndirect(&m_lf));
return pSelectThis;
}
CyaFont* CUnicodeVirtualFontMgr::CreateCyaFont(HDC hdc, int16 encoding)
{
int isUnicode;
if ( CIntlWin::UseUnicodeFontAPI( encoding ))
{
isUnicode = 1;
}
else
{
isUnicode = 0;
}
UpdateLOGFONTForEncoding(encoding);
CyaFont *pSelectThis = new CyaFont();
// todo: pass in context as first paramer, it will be used
// to get current URL, for webfont security.
VERIFY(pSelectThis->CreateNetscapeFontWithLOGFONT(NULL,hdc, &m_lf, isUnicode) == FONTERR_OK );
return pSelectThis;
}
BOOL CUnicodeVirtualFontMgr::GetFontFromCache(int16 encoding, CFont*& pFont)
{
return CVirtualFontFontCache::Get(encoding,
m_lf.lfHeight, m_bFixed, (m_lf.lfWeight == FW_BOLD),
m_lf.lfItalic, m_lf.lfUnderline ,pFont);
}
BOOL CUnicodeVirtualFontMgr::AddFontToCache(int16 encoding, CFont* pFont)
{
return CVirtualFontFontCache::Add(encoding,
m_lf.lfHeight, m_bFixed, (m_lf.lfWeight == FW_BOLD),
m_lf.lfItalic, m_lf.lfUnderline ,pFont);
}
BOOL CUnicodeVirtualFontMgr::GetCyaFontFromCache(int16 encoding, CyaFont*& pFont)
{
return CVirtualFontFontCache::Get(encoding,
m_lf.lfHeight, m_bFixed, (m_lf.lfWeight == FW_BOLD),
m_lf.lfItalic, m_lf.lfUnderline ,pFont);
}
BOOL CUnicodeVirtualFontMgr::AddCyaFontToCache(int16 encoding, CyaFont* pFont)
{
return CVirtualFontFontCache::Add(encoding,
m_lf.lfHeight, m_bFixed, (m_lf.lfWeight == FW_BOLD),
m_lf.lfItalic, m_lf.lfUnderline ,pFont);
}

63
mozilla/cmd/winfe/cuvfm.h Executable file
View File

@@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
/* , 1997 */
//--------------------------------------------------------------------------------------------------------
// Author: Frank Tang ftang@netscape.com x2913
//
// Unicode Virtual Font Manager used for Unicode rendering
//--------------------------------------------------------------------------------------------------------
#ifndef __CUVFM_H
#define __CUVFM_H
#include "stdafx.h"
#include "cvffc.h"
//------------------------------------------------------------------------------------------------
//
// CUnicodeVirtualFontMgr
//
// The constructor save the font on dc
// The destructor restore the font on dc
//
//------------------------------------------------------------------------------------------------
class CUnicodeVirtualFontMgr {
public:
CUnicodeVirtualFontMgr(HDC in_hdc);
~CUnicodeVirtualFontMgr();
//#ifdef netscape_font_module
CyaFont *CUnicodeVirtualFontMgr::GetCsidCyaFont(HDC hdc, int16 encoding);
//#endif //netscape_font_module
CFont* GetCsidFont(int16 encoding);
static void ExitInstance();
int CacularAscentDelta(HDC hDC);
private:
CFont* CreateFont(int16 encoding);
//#ifdef netscape_font_module
CyaFont* CreateCyaFont(HDC hdc, int16 encoding);
BOOL GetCyaFontFromCache(int16 encoding, CyaFont*& pFont);
BOOL AddCyaFontToCache(int16 encoding, CyaFont* pFont);
//#endif //netscape_font_module
void UpdateLOGFONTForEncoding(int16 encoding);
BOOL GetFontFromCache(int16 encoding, CFont*& pFont);
BOOL AddFontToCache(int16 encoding, CFont* pFont);
private:
HDC m_DC;
HFONT m_OrigFont;
LOGFONT m_lf;
BOOL m_bFixed;
int m_iOrigAscent;
};
#endif

183
mozilla/cmd/winfe/cuvfs.cpp Executable file
View File

@@ -0,0 +1,183 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
//--------------------------------------------------------------------------------------------------------
// Author: Frank Tang ftang@netscape.com x2913
//
// Text Handlering Routien for Unicode rendering
//--------------------------------------------------------------------------------------------------------
#include "stdafx.h"
#include "cuvfs.h"
#include "cuvfm.h"
#include "libi18n.h"
//------------------------------------------------------------------------------------------------
// INTL_CompoundStrFromUTF8
//------------------------------------------------------------------------------------------------
static INTL_CompoundStr* INTL_CompoundStrFromUTF8(LPCSTR pString, int length)
{
WCHAR ucs2[512];
int ulen;
INTL_CompoundStr *This = NULL;
ulen = CASTINT(INTL_TextToUnicode(CS_UTF8, (unsigned char*)pString, length, ucs2, 512));
This = INTL_CompoundStrFromUnicode(ucs2, ulen);
return This;
}
//------------------------------------------------------------------------------------------------
//
// CIntlUnicodeVirtualFontStrategy::GetTextExtentPoint
//
//------------------------------------------------------------------------------------------------
BOOL CIntlUnicodeVirtualFontStrategy::GetTextExtentPoint(HDC hDC, LPCSTR pString, int iLength, LPSIZE pSize)
{
pSize->cx = 0;
pSize->cy = 0;
CUnicodeVirtualFontMgr ufm(hDC);
INTL_CompoundStr *str = INTL_CompoundStrFromUTF8(pString, iLength);
if(str)
{
CDC * pDC = CDC::FromHandle(hDC);
INTL_Encoding_ID encoding;
unsigned char *text;
INTL_CompoundStrIterator iter;
for(iter = INTL_CompoundStrFirstStr((INTL_CompoundStrIterator) str, &encoding, &text);
iter != NULL;
iter = INTL_CompoundStrNextStr(iter, &encoding, &text))
{
SIZE textsize;
pDC->SelectObject(ufm.GetCsidFont(encoding));
int textlength = XP_STRLEN((char*)text);
VERIFY(CIntlWin::GetTextExtentPoint(encoding, hDC, (char*)text, textlength, &textsize));
pSize->cx += textsize.cx;
if(textsize.cy > pSize->cy)
pSize->cy = textsize.cy;
}
INTL_CompoundStrDestroy(str);
}
// The destructor of CUnicodeVirtualFontMgr will reset the font.
return TRUE;
}
//------------------------------------------------------------------------------------------------
//
// CIntlUnicodeVirtualFontStrategy::TextOut
//
//------------------------------------------------------------------------------------------------
BOOL CIntlUnicodeVirtualFontStrategy::TextOut(HDC hDC, int nXStart, int nYStart, LPCSTR pString, int iLength)
{
// Save the current font on stack
CUnicodeVirtualFontMgr ufm(hDC);
INTL_CompoundStr *str = INTL_CompoundStrFromUTF8(pString, iLength);
if(str)
{
CDC * pDC = CDC::FromHandle(hDC);
INTL_Encoding_ID encoding;
unsigned char *text;
INTL_CompoundStrIterator iter;
for(iter = INTL_CompoundStrFirstStr((INTL_CompoundStrIterator) str, &encoding, &text);
iter != NULL;
iter = INTL_CompoundStrNextStr(iter, &encoding, &text))
{
SIZE textsize;
pDC->SelectObject(ufm.GetCsidFont(encoding));
int textlength = XP_STRLEN((char*)text);
VERIFY(CIntlWin::TextOut(encoding, hDC, nXStart, nYStart + ufm.CacularAscentDelta(hDC), (char*)text, textlength));
VERIFY(CIntlWin::GetTextExtentPoint(encoding, hDC, (char*)text, textlength, &textsize));
nXStart += textsize.cx;
}
INTL_CompoundStrDestroy(str);
}
// The destructor of CUnicodeVirtualFontMgr will reset the font.
return TRUE;
}
BOOL CIntlUnicodeVirtualFontStrategy::GetTextExtentPointWithCyaFont(CyaFont *theNSFont, HDC hDC, LPCSTR pString, int iLength, LPSIZE pSize)
{
pSize->cx = 0;
pSize->cy = 0;
CUnicodeVirtualFontMgr ufm(hDC); // Change this to get attribute from CyaFont instead of hDC
INTL_CompoundStr *str = INTL_CompoundStrFromUTF8(pString, iLength);
if(str)
{
CDC * pDC = CDC::FromHandle(hDC);
INTL_Encoding_ID encoding;
unsigned char *text;
INTL_CompoundStrIterator iter;
for(iter = INTL_CompoundStrFirstStr((INTL_CompoundStrIterator) str, &encoding, &text);
iter != NULL;
iter = INTL_CompoundStrNextStr(iter, &encoding, &text))
{
SIZE textsize;
CyaFont *encodingFont = ufm.GetCsidCyaFont(hDC, encoding);
encodingFont->PrepareDrawText( hDC ); // Select the Font in the DC
int textlength = XP_STRLEN((char*)text);
VERIFY(CIntlWin::GetTextExtentPointWithCyaFont(encodingFont ,encoding, hDC, (char*)text, textlength, &textsize));
encodingFont->EndDrawText( hDC ); // Restore the old Font in the DC
pSize->cx += textsize.cx;
if(textsize.cy > pSize->cy)
pSize->cy = textsize.cy;
}
INTL_CompoundStrDestroy(str);
}
// The destructor of CUnicodeVirtualFontMgr will reset the font.
return TRUE;
} // GetTextExtentPointWithCyaFont
BOOL CIntlUnicodeVirtualFontStrategy::TextOutWithCyaFont(CyaFont *theNSFont, HDC hDC, int nXStart, int nYStart, LPCSTR lpString, int iLength)
{
// Save the current font on stack
CUnicodeVirtualFontMgr ufm(hDC); /* May be we should pass theNSFont instead */
INTL_CompoundStr *str = INTL_CompoundStrFromUTF8(lpString, iLength);
if(str)
{
CDC * pDC = CDC::FromHandle(hDC);
INTL_Encoding_ID encoding;
unsigned char *text;
INTL_CompoundStrIterator iter;
for(iter = INTL_CompoundStrFirstStr((INTL_CompoundStrIterator) str, &encoding, &text);
iter != NULL;
iter = INTL_CompoundStrNextStr(iter, &encoding, &text))
{
CyaFont *encodingFont = ufm.GetCsidCyaFont(hDC, encoding);
SIZE textsize;
int textlength = XP_STRLEN((char*)text);
encodingFont->PrepareDrawText( hDC ); // Select the Font in the DC
VERIFY(CIntlWin::TextOutWithCyaFont(encodingFont,encoding, hDC, nXStart, nYStart + ufm.CacularAscentDelta(hDC), (char*)text, textlength));
VERIFY(CIntlWin::GetTextExtentPoint(encoding, hDC, (char*)text, textlength, &textsize));
encodingFont->EndDrawText( hDC ); // Restore the old Font in the DC
nXStart += textsize.cx;
}
INTL_CompoundStrDestroy(str);
}
// The destructor of CUnicodeVirtualFontMgr will reset the font.
return TRUE;
} // TextOutWithCyaFont

41
mozilla/cmd/winfe/cuvfs.h Executable file
View File

@@ -0,0 +1,41 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __CUVFS_H
#define __CUVFS_H
#include "stdafx.h"
//------------------------------------------------------------------------------------------------
//
// CIntlUnicodeVirtualFontStrategy
//
//------------------------------------------------------------------------------------------------
//
// CIntlUnicodeVirtualFontStrategy class is a static class that handles UTF8 Virtual Font
// text rendering.
// The implementation of CIntlUnicodeVirtualFontStrategy will switch the font and
// call the member of CIntlWin to do the actual drawing
//
class CIntlUnicodeVirtualFontStrategy {
public:
static BOOL GetTextExtentPoint(HDC hDC, LPCSTR pString, int iLength, LPSIZE lpSize);
static BOOL TextOut(HDC hDC, int nXStart, int nYStart, LPCSTR lpString, int iLength);
static BOOL GetTextExtentPointWithCyaFont(CyaFont *theNSFont, HDC hDC, LPCSTR pString, int iLength, LPSIZE lpSize);
static BOOL TextOutWithCyaFont(CyaFont *theNSFont, HDC hDC, int nXStart, int nYStart, LPCSTR lpString, int iLength);
};
#endif

292
mozilla/cmd/winfe/cvffc.cpp Executable file
View File

@@ -0,0 +1,292 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
/* , 1997 */
//--------------------------------------------------------------------------------------------------------
// Author: Frank Tang ftang@netscape.com x2913
//
// Virtual Font Cacahe used for Unicode rendering
//--------------------------------------------------------------------------------------------------------
#include "stdafx.h"
#include "cvffc.h"
//------------------------------------------------------------------------------------------------
//
// CVirtualFontFontCache
//
//------------------------------------------------------------------------------------------------
CMapWordToOb* CVirtualFontFontCache::m_cache = NULL;
//#ifdef netscape_font_module
CMapWordToOb* CVirtualFontFontCache::m_Cyacache = NULL;
//#endif //netscape_font_module
void CVirtualFontFontCache::Init()
{
CVirtualFontFontCache::m_cache = NULL;
// CVirtualFontFontCache::m_Cyacache = NULL;
}
void CVirtualFontFontCache::Exit()
{
CVirtualFontFontCache::Reset();
}
//------------------------------------------------------------------------------------------------
//
// CVirtualFontFontCache::Get
//
//------------------------------------------------------------------------------------------------
#define STYLEKEY(f,b,i,u) ( ((f) ? 8 : 0) | ((b) ? 4 : 0) | ((i) ? 2 : 0) | ((u) ? 1 : 0) )
BOOL CVirtualFontFontCache::Get(int16 encoding, int size, BOOL fixed, BOOL bold, BOOL italic, BOOL underline, CFont*& pFont )
{
if(CVirtualFontFontCache::m_cache)
{
CMapWordToOb* pSizecache;
if(CVirtualFontFontCache::m_cache->Lookup(encoding, (CObject*&)pSizecache))
{
CMapWordToOb* pStylecache;
if(pSizecache->Lookup(size, (CObject*&)pStylecache))
{
BOOL ret = pStylecache->Lookup( STYLEKEY(fixed,bold,italic,underline), (CObject*&)pFont);
return ret;
}
}
}
return FALSE;
}
//#ifdef netscape_font_module
BOOL CVirtualFontFontCache::Get(int16 encoding, int size, BOOL fixed, BOOL bold,
BOOL italic, BOOL underline, CyaFont*& pFont )
{
if(CVirtualFontFontCache::m_Cyacache)
{
CMapWordToOb* pSizecache;
if(CVirtualFontFontCache::m_Cyacache->Lookup(encoding, (CObject*&)pSizecache))
{
CMapWordToOb* pStylecache;
if(pSizecache->Lookup(size, (CObject*&)pStylecache))
{
BOOL ret = pStylecache->Lookup( STYLEKEY(fixed,bold,italic,underline), (CObject*&)pFont);
return ret;
}
}
}
return FALSE;
}
//#endif //netscape_font_module
//------------------------------------------------------------------------------------------------
//
// CVirtualFontFontCache::Add
//
//------------------------------------------------------------------------------------------------
BOOL CVirtualFontFontCache::Add(int16 encoding, int size, BOOL fixed, BOOL bold, BOOL italic, BOOL underline, CFont*& pFont )
{
ASSERT(pFont);
if(! CVirtualFontFontCache::m_cache)
{
// *** Fix me, we better tune the init of pSizecache
VERIFY(CVirtualFontFontCache::m_cache = new CMapWordToOb);
if(CVirtualFontFontCache::m_cache == NULL )
return FALSE;
}
CMapWordToOb* pSizecache;
if(! CVirtualFontFontCache::m_cache->Lookup(encoding, (CObject*&)pSizecache))
{
// *** Fix me, we better tune the init of pSizecache
VERIFY(pSizecache = new CMapWordToOb);
if(pSizecache == NULL)
return FALSE;
CVirtualFontFontCache::m_cache->SetAt(encoding, (CObject*&)pSizecache);
}
CMapWordToOb* pStylecache;
if(! pSizecache->Lookup(size, (CObject*&)pStylecache))
{
// *** Fix me, we better tune the init of pSizecache
VERIFY(pStylecache = new CMapWordToOb);
if(pStylecache == NULL )
return FALSE;
pSizecache->SetAt(size, (CObject*&)pStylecache);
}
pStylecache->SetAt(STYLEKEY(fixed,bold,italic,underline), (CObject*&)pFont);
return TRUE;
}
//#ifdef netscape_font_module
BOOL CVirtualFontFontCache::Add(int16 encoding, int size, BOOL fixed, BOOL bold,
BOOL italic, BOOL underline, CyaFont*& pFont )
{
ASSERT(pFont);
if(! CVirtualFontFontCache::m_Cyacache)
{
// *** Fix me, we better tune the init of pSizecache
VERIFY(CVirtualFontFontCache::m_Cyacache = new CMapWordToOb);
if(CVirtualFontFontCache::m_Cyacache == NULL )
return FALSE;
}
CMapWordToOb* pSizecache;
if(! CVirtualFontFontCache::m_Cyacache->Lookup(encoding, (CObject*&)pSizecache))
{
// *** Fix me, we better tune the init of pSizecache
VERIFY(pSizecache = new CMapWordToOb);
if(pSizecache == NULL)
return FALSE;
CVirtualFontFontCache::m_Cyacache->SetAt(encoding, (CObject*&)pSizecache);
}
CMapWordToOb* pStylecache;
if(! pSizecache->Lookup(size, (CObject*&)pStylecache))
{
// *** Fix me, we better tune the init of pSizecache
VERIFY(pStylecache = new CMapWordToOb);
if(pStylecache == NULL )
return FALSE;
pSizecache->SetAt(size, (CObject*&)pStylecache);
}
pStylecache->SetAt(STYLEKEY(fixed,bold,italic,underline), (CObject*&)pFont);
return TRUE;
}
//#endif //netscape_font_module
//------------------------------------------------------------------------------------------------
//
// CVirtualFontFontCache::Reset
//
//------------------------------------------------------------------------------------------------
void CVirtualFontFontCache::Reset()
{
CMapWordToOb* pEncodingcache = CVirtualFontFontCache::m_cache;
CVirtualFontFontCache::m_cache = NULL;
// we should really lock this function
if(pEncodingcache)
{
int16 encoding;
CMapWordToOb* pSizecache;
POSITION i;
for(i = pEncodingcache->GetStartPosition(); i != NULL;)
{
pEncodingcache->GetNextAssoc(i, (WORD&)encoding, (CObject*&)pSizecache);
// pEncodingcache->RemoveKey(encoding);
ASSERT(pSizecache);
if(pSizecache)
{
POSITION j;
for(j = pSizecache->GetStartPosition(); j != NULL;)
{
int size;
CMapWordToOb* pStylecache;
pSizecache->GetNextAssoc(j, (WORD&)size, (CObject*&)pStylecache);
// pSizecache->RemoveKey(size);
ASSERT(pStylecache);
if(pStylecache)
{
POSITION k;
for(k = pStylecache->GetStartPosition(); k != NULL;)
{
WORD style;
CFont* pFont = NULL;
pStylecache->GetNextAssoc(k, style, (CObject*&)pFont);
// pStylecache->RemoveKey(style);
ASSERT(pFont);
if(pFont)
{
delete pFont;
}
} // for each style
pStylecache->RemoveAll();
ASSERT( pStylecache->GetCount() == 0);
ASSERT( pStylecache->IsEmpty());
delete pStylecache;
}
} // for each size
pSizecache->RemoveAll();
ASSERT( pSizecache->GetCount() == 0);
ASSERT( pSizecache->IsEmpty());
delete pSizecache;
}
} // for each encoding
pEncodingcache->RemoveAll();
ASSERT( pEncodingcache->GetCount() == 0);
ASSERT( pEncodingcache->IsEmpty());
delete pEncodingcache;
}
//#ifdef netscape_font_module
CVirtualFontFontCache::ResetCyacache();
//#endif //netscape_font_module
}
//#ifdef netscape_font_module
void CVirtualFontFontCache::ResetCyacache()
{
CMapWordToOb* pEncodingcache = CVirtualFontFontCache::m_Cyacache;
CVirtualFontFontCache::m_Cyacache = NULL;
// we should really lock this function
if(pEncodingcache)
{
int16 encoding;
CMapWordToOb* pSizecache;
POSITION i;
for(i = pEncodingcache->GetStartPosition(); i != NULL;)
{
pEncodingcache->GetNextAssoc(i, (WORD&)encoding, (CObject*&)pSizecache);
// pEncodingcache->RemoveKey(encoding);
ASSERT(pSizecache);
if(pSizecache)
{
POSITION j;
for(j = pSizecache->GetStartPosition(); j != NULL;)
{
int size;
CMapWordToOb* pStylecache;
pSizecache->GetNextAssoc(j, (WORD&)size, (CObject*&)pStylecache);
// pSizecache->RemoveKey(size);
ASSERT(pStylecache);
if(pStylecache)
{
POSITION k;
for(k = pStylecache->GetStartPosition(); k != NULL;)
{
WORD style;
CyaFont* pFont = NULL;
pStylecache->GetNextAssoc(k, style, (CObject*&)pFont);
// pStylecache->RemoveKey(style);
ASSERT(pFont);
if(pFont)
{
delete pFont;
}
} // for each style
pStylecache->RemoveAll();
ASSERT( pStylecache->GetCount() == 0);
ASSERT( pStylecache->IsEmpty());
delete pStylecache;
}
} // for each size
pSizecache->RemoveAll();
ASSERT( pSizecache->GetCount() == 0);
ASSERT( pSizecache->IsEmpty());
delete pSizecache;
}
} // for each encoding
pEncodingcache->RemoveAll();
ASSERT( pEncodingcache->GetCount() == 0);
ASSERT( pEncodingcache->IsEmpty());
delete pEncodingcache;
}
}
//#endif //netscape_font_module

51
mozilla/cmd/winfe/cvffc.h Executable file
View File

@@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
//------------------------------------------------------------------------------
// Author: Frank Tang ftang@netscape.com x2913
//
// Virtual Font Cacahe used for Unicode rendering
//------------------------------------------------------------------------------
#ifndef __CVFFC_H
#define __CVFFC_H
#include "stdafx.h"
class CVirtualFontFontCache {
public:
static void Init();
static void Exit();
static void Reset();
static void ResetCyacache();
static BOOL Get( int16 encoding, int size, BOOL fixed, BOOL bold,
BOOL italic, BOOL underline, CyaFont*& pFont );
static BOOL Add( int16 encoding, int size, BOOL fixed, BOOL bold,
BOOL italic, BOOL underline, CyaFont*& pFont );
static BOOL Get( int16 encoding, int size, BOOL fixed, BOOL bold,
BOOL italic, BOOL underline, CFont*& pFont );
static BOOL Add( int16 encoding, int size, BOOL fixed, BOOL bold,
BOOL italic, BOOL underline, CFont*& pFont );
private:
static CMapWordToOb* m_cache;
static CMapWordToOb* m_Cyacache;
};
#endif

1408
mozilla/cmd/winfe/cxabstra.cpp Executable file

File diff suppressed because it is too large Load Diff

370
mozilla/cmd/winfe/cxabstra.h Executable file
View File

@@ -0,0 +1,370 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __CX_ABSTRACT_H
// Avoid include redundancy
//
#define __CX_ABSTRACT_H
#ifndef _APICX_H
#include "apicx.h"
#endif
#include "ni_pixmp.h"
// Purpose: Provide the abstract context implementation.
// Comments: Pure virtual; must be derived from.
// Through wrapping functions, the C XP libs will call into the context, and
// virtual resolution will resolve the correct context.
// Revision History:
// 04-26-95 created GAB
//
// Required Includes
//
// Constants
//
// Structures
//
// Mechanism for run time information.
// Must be updated with the addition of every new context type.
// For optimizations for specific output devices in common code.
// All classes meant to be abstract will have values of 0x0.
// This allows us to ASSERT if the context is of a valid type.
typedef enum ContextType {
Abstract = 0x0000,
DeviceContext = 0x0000,
Stubs = 0x0000,
Network,
Save,
Print,
Pane,
Window,
Bookmarks,
MetaFile,
MailCX,
NewsCX,
MailThreadCX,
NewsThreadCX,
SearchCX,
AddressCX,
HtmlHelp,
HistoryCX,
IconCX,
RDFSlave,
MaxContextTypes // Leave as last entry please
} ContextType;
#ifdef MOZ_NGLAYOUT
class nsIWebWidget;
#endif
// The abstract windows context
class CAbstractCX: public IMWContext {
private:
// The actual XP context.
MWContext *m_pXPCX;
protected:
// Set this in the constructor of each derived class for run time type information.
ContextType m_cxType;
IL_GroupContext* m_pImageGroupContext;
public:
CAbstractCX();
virtual ~CAbstractCX();
// Function to load a URL with this context, with the custom exit routing handler.
// Use this to NET_GetURL instead or XL_TranslateText instead.
virtual int GetUrl(URL_Struct *pUrl, FO_Present_Types iFormatOut, BOOL bReallyLoad = TRUE, BOOL bForceNew = FALSE);
#ifndef MOZ_NGLAYOUT
virtual XL_TextTranslation TranslateText(URL_Struct *pUrl, const char *pFileName, const char *pPrefix = NULL, int iWidth = 75);
#endif /* MOZ_NGLAYOUT */
virtual void UpdateStopState(MWContext *pContext) = 0;
// Generic brain dead interface to load a URL.
// This used to be known as OnNormalLoad.
int NormalGetUrl(const char *pUrl, const char *pReferrer = NULL, const char *pTarget = NULL, BOOL bForceNew = FALSE);
// Atomic load operations regarding history.
virtual void Reload(NET_ReloadMethod iReloadType = NET_NORMAL_RELOAD);
virtual void NiceReload(int usePassInType = 0, NET_ReloadMethod iReloadType = NET_NORMAL_RELOAD);
virtual void Back();
virtual void Forward();
virtual void ImageComplete(NI_Pixmap* image) {;}
virtual void SetInternetKeyword(const char *keyword) {}
virtual BITMAPINFO* NewPixmap(NI_Pixmap* pImage, BOOL mask = FALSE) { return NULL;}
// Function for easy creation of a URL from the current history entry.
virtual URL_Struct *CreateUrlFromHist(BOOL bClearStateData = FALSE, SHIST_SavedData *pSavedData = NULL, BOOL bWysiwyg = FALSE);
virtual BOOL CanCreateUrlFromHist();
// Construction/destruction (creates/destroys XP context)
virtual void DestroyContext();
void NiceDestroyContext();
private:
BOOL m_bDestroyed;
public:
char * m_pLastStatus;
BOOL IsDestroyed() const {
// This function is very important.
// It allows you to write code which can detect when a context
// is actually in the process of being destroyed.
// In many cases, you will receive callbacks from the XP libraries
// while the context is being destroyed. If you GPF, then use
// this function to better detect your course of action.
return(m_bDestroyed);
}
public:
// Access to type information, for optimizations in common code.
ContextType GetContextType() const {
ASSERT(m_cxType);
return(m_cxType);
}
int16 GetWinCsid();
BOOL IsDCContext() const {
ASSERT(m_cxType);
switch(m_cxType) {
case Print:
case Window:
case MetaFile:
case Pane:
return(TRUE);
default:
return(FALSE);
}
}
BOOL IsPureDCContext() const {
// Return TRUE if all we depend upon is
// a DC for display (non windowed).
return(!IsWindowContext() && IsDCContext() == TRUE);
}
BOOL IsPrintContext() const {
ASSERT(m_cxType);
switch(m_cxType) {
case Print:
return(TRUE);
default:
return(FALSE);
}
}
BOOL IsWindowContext() const {
ASSERT(m_cxType);
switch(m_cxType) {
case Window:
case Pane:
return(TRUE);
default:
return(FALSE);
}
}
BOOL IsFrameContext() const {
ASSERT(m_cxType);
switch (m_cxType) {
case Window:
return TRUE;
default:
return FALSE;
}
}
public:
// Owner of any dialogs that we'll bring up.
virtual CWnd *GetDialogOwner() const;
public:
// For the foolhardy, who desire access to the XP context in our hour of need.
MWContext *GetContext() const {
return(m_pXPCX);
}
MWContext *GetParentContext() const {
// Only valid if IsGridCell is true.
return(m_pXPCX->grid_parent);
}
// Override to allow XP Context->Frame matching
virtual CFrameGlue *GetFrame() const { return NULL; }
#ifdef MOZ_NGLAYOUT
// Convenience to get/set WebWidget from MWContext.
nsIWebWidget *GetWebWidget() const {
return((nsIWebWidget*)m_pXPCX->fe.webWidget);
}
void SetWebWidget(nsIWebWidget *pWW) {
m_pXPCX->fe.webWidget = pWW;
}
#endif
// Named contexts and grid stuff.
void SetContextName(const char *pName);
void SetParentContext(MWContext *pParentContext);
BOOL IsGridCell() const;
BOOL IsGridParent() const;
// layout modularization effort.
public:
MWContext *GetDocumentContext() const {
return(m_pXPCX);
}
public:
// A function to interrupt any loads in this context.
// This happens immediatly or idly.
// Also, if the call is not nested, it may destroy this object
// if DestroyContext has been called previously.
virtual void Interrupt();
public:
BOOL m_bIdleInterrupt;
BOOL m_bIdleDestroy;
private:
int m_iInterruptNest;
private:
BOOL m_bImagesLoading; // True if any images in this context are loading.
BOOL m_bImagesLooping; // True if any images in this context are looping.
BOOL m_bImagesDelayed; // True if any images in this context are delayed.
BOOL m_bMochaImagesLoading;
BOOL m_bMochaImagesLooping;
BOOL m_bMochaImagesDelayed;
BOOL IsContextStoppableRecurse();
public:
BOOL m_bNetHelpWnd;
BOOL IsNetHelpWnd() { return m_bNetHelpWnd; }
public:
// A wrapper around XP_IsContextStoppable. This is necessary
// because a context is stoppable if its image context is
// stoppable, and the image context is owned by the Front End.
BOOL IsContextStoppable();
// Returns TRUE if this context or its children have any looping images.
BOOL IsContextLooping();
void SetImagesLoading(BOOL val) {m_bImagesLoading = val;}
void SetImagesLooping(BOOL val) {m_bImagesLooping = val;}
void SetImagesDelayed(BOOL val) {m_bImagesDelayed = val;}
void SetMochaImagesLoading(BOOL val) {m_bMochaImagesLoading = val;}
void SetMochaImagesLooping(BOOL val) {m_bMochaImagesLooping = val;}
void SetMochaImagesDelayed(BOOL val) {m_bMochaImagesDelayed = val;}
// Client pull timer information.
public:
void *m_pClientPullData;
void *m_pClientPullTimeout;
private:
// Information to time a load.
time_t m_ttStopwatch;
time_t m_ttOldwatch;
public:
BOOL ProgressReady(time_t ttCurTime) {
BOOL bRetval = ttCurTime != m_ttOldwatch;
m_ttOldwatch = ttCurTime;
return(bRetval);
}
time_t GetElapsedSeconds(time_t ttCurTime) {
return(ttCurTime - m_ttStopwatch);
}
//moved to .cpp due to dependency problems
void ResetStopwatch();
public:
// Context Identification.
DWORD GetContextID() {
return((DWORD)(m_pXPCX->context_id));
}
static CAbstractCX *FindContextByID(DWORD dwID);
public:
// NCAPI context pointer.
CNcapiUrlData *m_pNcapiUrlData;
// Progress Helpers
virtual int32 QueryProgressPercent() { return 0; }
virtual void StartAnimation() {}
virtual void StopAnimation() {}
// MFC Helpers; abstraction away
public:
virtual void MailDocument();
virtual BOOL CanMailDocument();
virtual void NewWindow();
virtual BOOL CanNewWindow();
virtual void OpenUrl();
virtual BOOL CanOpenUrl();
virtual void AllBack();
virtual BOOL CanAllBack();
virtual void AllForward();
virtual BOOL CanAllForward();
virtual void AllInterrupt();
virtual BOOL CanAllInterrupt();
virtual void AllReload(NET_ReloadMethod iReloadType = NET_NORMAL_RELOAD);
virtual BOOL CanAllReload();
virtual void CopySelection();
virtual BOOL CanCopySelection();
virtual void AddToBookmarks();
virtual BOOL CanAddToBookmarks();
#ifdef LAYERS
virtual BOOL HandleLayerEvent(CL_Layer * pLayer, CL_Event * pEvent)
{ return FALSE; }
virtual BOOL HandleEmbedEvent(LO_EmbedStruct *embed, CL_Event * pEvent)
{ return FALSE; }
#endif
virtual void GoHome(){}
virtual void AllFind(MWContext *pSearchContext = NULL){}
virtual BOOL DoFind(CWnd * pWnd, const char * pFindString,
BOOL bMatchCase, BOOL bSearchDown, BOOL bAlertOnNotFound)
{ return FALSE; }
virtual void PrintContext(){}
virtual void GetWindowOffset(int32 *x, int32 *y){}
void MochaDestructionComplete();
};
// Global variables
//
// Macros
//
// Function declarations
//
// The common front end, called in every context, that in turn uses a virtual call into
// the correct context, except in specific optimized situations.
#define MAKE_FE_FUNCS_PREFIX(funkage) CFE_##funkage
#define MAKE_FE_FUNCS_EXTERN
#include "mk_cx_fn.h"
// The exit routines.
void CFE_GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext);
void CFE_SimpleGetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext);
void CFE_TextTranslationExitRoutine(PrintSetup *pTextFE);
#endif // __CX_ABSTRACT_H

3905
mozilla/cmd/winfe/cxdc.cpp Normal file

File diff suppressed because it is too large Load Diff

799
mozilla/cmd/winfe/cxdc.h Normal file
View File

@@ -0,0 +1,799 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __Context_Device_Context_H
// Avoid include redundancy
//
#define __Context_Device_Context_H
// Purpose: Implement a Context which holds the common code for
// contexts which draw information.
// Comments: Use for those contexts with actual windows to display,
// or for printing. Basically those with a CDC on
// which to display and which handle output formats
// that go through layout or other engines.
// Revision History:
// 05-26-95 created GAB
//
// Required Includes
//
#include "cxstubs.h"
#include "ni_pixmp.h"
#include "prtypes.h"
#include "il_types.h"
#include "il_util.h"
#include "libimg.h"
#ifdef XP_WIN32
//#define DDRAW
#endif
#ifdef DDRAW
#include "ddraw.h"
#endif
// Constants
//
#define HIMETRIC_INCH 2540 // HIMETRIC units per inch
#define TWIPS_INCH 1440
#define MAX_IMAGE_PALETTE_ENTRIES 216
// DIBSECTIONS are pretty slow on most platforms except NT3.51
// We can use them if they're sped up in a later version of Windows
#define USE_DIB_SECTIONS 0
// Use for selection highlighting of objects in Editor
#define ED_SELECTION_BORDER 3
//#ifndef NO_TAB_NAVIGATION
typedef enum {
FE_DRAW_NORMAL = 0x00000000,
FE_DRAW_TAB_FOCUS = 0x00000001,
} feDrawFlag_t ;
//#endif /* NO_TAB_NAVIGATION */
void WFE_StretchDIBitsWithMask(HDC hTargetDC,
BOOL isDeviceDC,
HDC hOffscreenDC,
int dx,
int dy,
int dw,
int dh,
int sx,
int sy,
int sw,
int sh,
void XP_HUGE *imageBit,
BITMAPINFO* lpImageInfo,
void XP_HUGE *maskBit,
BOOL bUseDibPalColors = FALSE,
COLORREF fillWithBackground = NULL
);
// Structures
//
class LTRB {
public:
union {
int32 m_lLeft;
int32 left;
};
union {
int32 m_lTop;
int32 top;
};
union {
int32 m_lRight;
int32 right;
};
union {
int32 m_lBottom;
int32 bottom;
};
LTRB( LTRB& theRect) {
m_lLeft = theRect.m_lLeft;
m_lTop = theRect.m_lTop;
m_lRight = theRect.m_lRight;
m_lBottom = theRect.m_lBottom;
}
LTRB& operator = (LTRB& theRect) {
m_lLeft = theRect.m_lLeft;
m_lTop = theRect.m_lTop;
m_lRight = theRect.m_lRight;
m_lBottom = theRect.m_lBottom;
return *this;
}
void MergeRect(LTRB& theRect) {
if ( m_lLeft >theRect.m_lLeft)
m_lLeft = theRect.m_lLeft;
if (m_lTop > theRect.m_lTop)
m_lTop = theRect.m_lTop;
if (m_lRight < theRect.m_lRight)
m_lRight = theRect.m_lRight;
if (m_lBottom < theRect.m_lBottom)
m_lBottom = theRect.m_lBottom;
}
void Empty() {
m_lLeft = 0;
m_lTop = 0;
m_lRight = 0;
m_lBottom = 0;
}
BOOL IsEmpty() {
return( m_lLeft == 0 &&
m_lTop == 0 &&
m_lRight == 0 &&
m_lBottom == 0);
}
LTRB(int32 lLeft, int32 lTop, int32 lRight, int32 lBottom) {
m_lLeft = lLeft;
m_lTop = lTop;
m_lRight = lRight;
m_lBottom = lBottom;
}
LTRB() {
m_lLeft = m_lTop = m_lRight = m_lBottom = 0L;
}
int32 Width() {
return(m_lRight - m_lLeft);
}
int32 Height() {
return(m_lBottom - m_lTop);
}
void Inflate(int32 lDelta) {
m_lLeft -= lDelta;
m_lTop -= lDelta;
m_lRight += lDelta;
m_lBottom += lDelta;
}
void Inflate(int32 lDeltaX, int32 lDeltaY) {
m_lLeft -= lDeltaX;
m_lTop -= lDeltaY;
m_lRight += lDeltaX;
m_lBottom += lDeltaY;
}
};
class XY {
public:
union {
int32 m_lX;
int32 x;
};
union {
int32 m_lY;
int32 y;
};
XY(int32 lX, int32 lY) {
m_lX = lX;
m_lY = lY;
}
XY() {
m_lX = m_lY = 0L;
}
};
class CDCCX : public CStubsCX {
// Construction/Destruction
public:
CDCCX();
~CDCCX();
virtual void DestroyContext();
// CDC Access
private:
BOOL m_bOwnDC;
BOOL m_bClassDC;
protected:
void SetOwnDC(BOOL bSet) { m_bOwnDC = bSet; }
void SetClassDC(BOOL bSet) { m_bClassDC = bSet; }
protected:
HDC m_pImageDC;
IL_IRGB rgbTransparentColor;
IL_ColorSpace* curColorSpace;
IL_ColorMap *curColorMap;
public:
virtual HDC GetContextDC() = 0;
virtual void ReleaseContextDC(HDC hDC) = 0;
virtual HDC GetAttribDC() { return GetContextDC(); }
virtual void ReleaseAttribDC(HDC hDC) { ReleaseContextDC(hDC); }
virtual HDC GetDispDC() { return GetContextDC(); }
virtual void ReleaseDispDC(HDC hDC) { ReleaseContextDC(hDC); }
virtual BOOL IsDeviceDC() { return TRUE; }
virtual int32 GetXConvertUnit() { return m_lConvertX;}
virtual int32 GetYConvertUnit() { return m_lConvertY;}
IL_ColorSpace* GetCurrentColorSpace() { return curColorSpace;}
virtual BOOL IsOwnDC() const {
return(m_bOwnDC);
}
virtual BOOL IsClassDC() const {
return(m_bClassDC);
}
HDC GetImageDC() {
// Use this, a compatible DC, to size things to the display or for bitmaps
// to blt on the screen.
// Don't use to actually attempt display of anything.
return(m_pImageDC);
}
// Post construction initialization.
// Variables should be set by those deriving from this class at
// the appropriate times.
public:
// MWH - The usage for bInitialPalette and bNewMemDC flags -
// if bInitialPalette is set to FALSE, we will use the default palette that is created when the App started.
// otherwise a palette will be created.
// if bNewMemDC = TRUE, the the cache memory DC(m_pImageDC) will be created. Otherwise, it will be
// NULL. If you set bNewMemDC = FALSE, you should call PrepareDraw() before any drawing happen, and
// call EndDraw() when you are done with this CDCCX. When I'm working on Aurora, I find out that
// I need this flag. In Aurora, every button has an associate view, it gets created when the button
// is created. If the view has HTML pane, it will create a CDCCX. I need to control when to cache
// memory DC and when to destroy memory DC in order to use GDI resource efficiently under WIN16.
virtual void Initialize(BOOL bOwnDC, RECT *pRect = NULL, BOOL bInitialPalette = TRUE, BOOL bNewMemDC = TRUE);
virtual void PrepareDraw();
virtual void EndDraw();
int32 m_lOrgX;
int32 m_lOrgY;
int32 m_lWidth;
int32 m_lHeight;
int32 m_lDocHeight;
int32 m_lDocWidth;
#ifdef DDRAW
virtual LPDDSURFACEDESC GetSurfDesc() {return 0;}
virtual LPDIRECTDRAWSURFACE GetPrimarySurface() {return 0;}
virtual LPDIRECTDRAW GetDrawObj() {return 0;}
virtual LPDIRECTDRAWSURFACE GetBackSurface(){return 0;}
virtual void ReleaseSurfDC(LPDIRECTDRAWSURFACE surf, HDC hdc){;}
virtual void RestoreAllDrawSurface() {;}
virtual void SetClipOnDrawSurface(LPDIRECTDRAWSURFACE surface, HRGN hClipRgn) {;}
virtual LPDIRECTDRAWSURFACE CreateOffscreenSurface(RECT& rect) {return NULL;}
virtual void BltToScreen(LTRB& rect) {;}
virtual void LockOffscreenSurfDC(){;}
virtual void ReleaseOffscreenSurfDC() {;}
#endif
// Drawing conversions, informational.
protected:
// Hacks for speedup.
int32 m_lConvertX;
int32 m_lConvertY;
// What mapping mode we're in.
int m_MM;
HRGN curClipRgn;
public:
virtual int GetLeftMargin() {return 0;}
virtual int GetTopMargin() {return 0;}
// How to set the mapping mode.
void SetMappingMode(HDC hdc) {
if(MMIsText() == TRUE) {
::SetMapMode(hdc, MM_TEXT);
}
else {
::SetMapMode(hdc, MM_ANISOTROPIC);
::SetWindowExtEx(hdc, 1440,1440, NULL);
::SetViewportExtEx(hdc, ::GetDeviceCaps(hdc, LOGPIXELSX), ::GetDeviceCaps(hdc, LOGPIXELSY), NULL);
}
}
// Can opt for 1 to 1 conversions.
BOOL MMIsText() const {
return(m_MM == MM_TEXT);
}
int32 Pix2TwipsX(int32 lPixX) {
return(GetXConvertUnit() * lPixX);
}
int32 Twips2PixX(int32 lTwipsX) {
return(lTwipsX / m_lConvertX);
}
int32 Pix2TwipsY(int32 lPixY) {
return(GetYConvertUnit() * lPixY);
}
int32 Twips2PixY(int32 lTwipsY) {
return(lTwipsY / m_lConvertY);
}
int32 Metric2TwipsX(int32 lMetricX) {
// We use a screen DC to get WYSIWYG
CDC *pTempDC = theApp.m_pMainWnd->GetDC();
float convertPixX = ((float)HIMETRIC_INCH / (float)pTempDC->GetDeviceCaps(LOGPIXELSX));
theApp.m_pMainWnd->ReleaseDC(pTempDC);
// Convert the Metrics to pixels first.
lMetricX = (int32)((float)lMetricX / convertPixX);
// Complete the conversion to twips.
return(Pix2TwipsX(lMetricX));
}
int32 Metric2TwipsY(int32 lMetricY) {
// We use a screen DC to get WYSIWYG
CDC *pTempDC = theApp.m_pMainWnd->GetDC();
float convertPixY = ((float)HIMETRIC_INCH / (float)pTempDC->GetDeviceCaps(LOGPIXELSY));
theApp.m_pMainWnd->ReleaseDC(pTempDC);
// Convert the Metrics to pixels first.
lMetricY = (int32)((float)lMetricY / convertPixY);
// Complete the conversion to twips.
return(Pix2TwipsY(lMetricY));
}
int32 Twips2MetricX(int32 lTwipsX) {
// Convert the twips to pixels first.
lTwipsX = Twips2PixX(lTwipsX);
// We use a screen DC to get WYSIWYG
CDC *pTempDC = theApp.m_pMainWnd->GetDC();
float convertPixX = ((float)HIMETRIC_INCH / (float)pTempDC->GetDeviceCaps(LOGPIXELSX));
theApp.m_pMainWnd->ReleaseDC(pTempDC);
// Go metric.
lTwipsX = (int32)((float)lTwipsX * convertPixX);
return(lTwipsX);
}
int32 Twips2MetricY(int32 lTwipsY) {
// Convert the twips to pixels first.
lTwipsY = Twips2PixY(lTwipsY);
// We use a screen DC to get WYSIWYG
CDC *pTempDC = theApp.m_pMainWnd->GetDC();
float convertPixY = ((float)HIMETRIC_INCH / (float)pTempDC->GetDeviceCaps(LOGPIXELSY));
theApp.m_pMainWnd->ReleaseDC(pTempDC);
// Go metric.
lTwipsY = (int32)((float)lTwipsY * convertPixY);
return(lTwipsY);
}
int32 GetOriginX() {
return(m_lOrgX);
}
int32 GetOriginY() {
return(m_lOrgY);
}
int32 GetWidth() {
return(m_lWidth);
}
int32 GetHeight() {
return(m_lHeight);
}
int32 GetDocumentWidth() {
return(m_lDocWidth);
}
int32 GetDocumentHeight() {
return(m_lDocHeight);
}
void SetTransparentColor(BYTE red, BYTE green, BYTE blue);
IL_IRGB &GetTransparentColor() {return rgbTransparentColor;}
// Turning on or off display blocking.
private:
BOOL m_bResolveElements;
protected:
BOOL CanBlockDisplay() const {
return(m_bResolveElements);
}
public:
void DisableDisplayBlocking() {
m_bResolveElements = FALSE;
}
void EnableDisplayBlocking() {
m_bResolveElements = TRUE;
}
// Coordinate resolution and display blocking.
public:
virtual BOOL ResolveElement(LTRB& Rect, NI_Pixmap *pImage, int32 lX, int32 lY,
int32 orgx, int32 orgy,
uint32 ulWidth, uint32 ulHeight,
int32 lScaleWidth, int32 lScaleHeight);
virtual BOOL ResolveElement(LTRB& Rect, int32 x, int32 y, int32 x_offset, int32 y_offset,
int32 width, int32 height);
virtual BOOL ResolveElement(LTRB& Rect, LO_SubDocStruct *pSubDoc, int iLocation);
virtual BOOL ResolveElement(LTRB& Rect, LO_LinefeedStruct *pLineFeed, int iLocation);
virtual BOOL ResolveElement(LTRB& Rect, LO_CellStruct *pCell, int iLocation);
virtual BOOL ResolveElement(LTRB& Rect, LO_TableStruct *pTable, int iLocation);
virtual BOOL ResolveElement(LTRB& Rect, LO_EmbedStruct *pEmbed, int iLocation, Bool bWindowed);
virtual BOOL ResolveElement(LTRB& Rect, LO_FormElementStruct *pFormElement);
virtual BOOL ResolveElement(LTRB& Rect, LO_TextStruct *pText, int iLocation, int32 lStartPos, int32 lEndPos, int iClear);
// How to make sure above functions work on windows 16.
public:
void SafeSixteen(LTRB& Rect) {
// This routine is called to make sure that drawing coords don't wrap
// with GDI functions which take short ints.
// Use some hard coded values to end this pain quickly.
// Leave some marginal values to allow for additional leeway of
// the result (2767 twips).
// Maximum display height known is 1200 pixels, which is about 24000
// twips, which is kinda close for the future of this product.
// This doesn't count those users which somehow get their app much
// larger than the screen size by using other means, and they
// are dead.
const int iMax = 30000;
const int iMin = -30000;
if(Rect.left > iMax) {
Rect.left = iMax;
}
else if(Rect.left < iMin) {
Rect.left = iMin;
}
if(Rect.top > iMax) {
Rect.top = iMax;
}
else if(Rect.top < iMin) {
Rect.top = iMin;
}
if(Rect.right > iMax) {
Rect.right = iMax;
}
else if(Rect.right < iMin) {
Rect.right = iMin;
}
if(Rect.bottom > iMax) {
Rect.bottom = iMax;
}
else if(Rect.bottom < iMin) {
Rect.bottom = iMin;
}
}
// Font selection, deselection, caching
private:
enum {
m_MaxFontSizes = 9,
m_MaxUnderline = 2,
m_MaxItalic = 2,
m_MaxBold = 2,
m_MaxFixed = 2
};
private :
CPtrList m_cplCachedFontList;
protected:
HDC m_lastDCWithCachedFont;
CyaFont *m_pSelectedCachedFont;
int m_iOffset;
public:
static void ClearAllFontCaches();
void ClearFontCache();
virtual int SelectNetscapeFont( HDC hdc, LO_TextAttr *pAttr, CyaFont *& pMyFont);
virtual int SelectNetscapeFontWithCache( HDC hdc, LO_TextAttr *pAttr, CyaFont *& pMyFont );
virtual void ReleaseNetscapeFont(HDC hdc, CyaFont * pNetscapeFont);
virtual void ReleaseNetscapeFontWithCache(HDC hdc, CyaFont * pNetscapeFont);
virtual void ChangeFontOffset(int iIncrementor);
// Context sensitive attribute mapping.
public:
virtual COLORREF ResolveTextColor(LO_TextAttr *pAttr);
virtual COLORREF ResolveBGColor(unsigned uRed, unsigned uGreen, unsigned uBlue);
virtual BOOL ResolveHRSolid(LO_HorizRuleStruct *pHorizRule);
virtual BOOL ResolveLineSolid();
virtual void ResolveTransparentColor(unsigned uRed, unsigned uGreen, unsigned uBlue);
virtual COLORREF ResolveDarkLineColor();
virtual COLORREF ResolveLightLineColor();
virtual COLORREF ResolveBorderColor(LO_TextAttr *pAttr);
COLORREF ResolveLOColor(LO_Color *color);
virtual PRBool ResolveIncrementalImages();
#ifdef XP_WIN16
static void HugeFree(void XP_HUGE *pFreeMe) {
#ifdef __WATCOMC__
hfree(pFreeMe);
#else
_hfree(pFreeMe);
#endif
}
void XP_HUGE *HugeAlloc(int32 iSize, int32 iNum) {
#ifdef __WATCOMC__
return(halloc( (long) iSize, (size_t) iNum));
#else
return(_halloc( (long) iSize, (size_t) iNum));
#endif
}
#else
static void HugeFree(void XP_HUGE *pFreeMe) {
free(pFreeMe);
}
void XP_HUGE *HugeAlloc(int32 iSize, int32 iNum) {
return(calloc(iNum, iSize));
}
#endif
BOOL ResolveTextExtent(int16 wincsid, HDC pDC, LPCTSTR pString, int iLength, LPSIZE pSize, CyaFont *pMyFont);
BOOL ResolveTextExtent(HDC pDC, LPCTSTR pString, int iLength, LPSIZE pSize, CyaFont *pMyFont );
BOOL ResolveTextExtent(HDC pDC, LPCTSTR pString, int iLength, LPSIZE pSize)
{
BOOL bRetval;
bRetval = CIntlWin::GetTextExtentPoint(0, pDC, pString, iLength, pSize);
return(bRetval);
}
// Color and palette.
protected:
COLORREF m_rgbLightColor;
COLORREF m_rgbDarkColor;
HPALETTE m_pPal;
BOOL m_bRGB565; // driver supports 565 mode for DIBs
public:
virtual HPALETTE GetPalette() const;
COLORREF m_rgbBackgroundColor; // let our view access this
// Misc draw helpers
public:
virtual double CalcFontPointSize(int size, int iBaseSize, int iOffset = 0);
void Display3DBox(LTRB& Rect, COLORREF rgbLight, COLORREF rgbDark, int32 lWidth, BOOL bAdjust = FALSE);
void EditorDisplayZeroWidthBorder(LTRB& Rect, BOOL bSelected);
void Compute3DColors(COLORREF rgbColor, COLORREF &rgbLight, COLORREF &rgbDark);
// Returns width of selection border (if any) - used only by Composer
int32 DisplayTableBorder(LTRB& Rect, LO_TableStruct *pTable);
void Display3DBorder(LTRB& Rect, COLORREF rgbLight, COLORREF rgbDark, LTRB &);
BOOL cxLoadBitmap(LPCSTR pszBmName, char** bits, BITMAPINFOHEADER** myBitmapInfo);
virtual void DisplayIcon(int32 x, int32 y, int icon_number);
virtual void GetIconDimensions(int32* width, int32* height, int iconNumber);
void FloodRect(LTRB& Rect, HBRUSH hColor);
BOOL WriteBitmapFile(LPCSTR lpszFileName, LO_ImageStruct*);
HANDLE WriteBitmapToMemory( IL_ImageReq *image_req, LO_Color* bgColor);
BOOL CanWriteBitmapFile(LO_ImageStruct*);
// Uses the document color/backdrop by default, but you can specify a color or backdrop image to be used instead
virtual BOOL _EraseBkgnd(HDC pDC, RECT&, int32 tileX, int32 tileY,
LO_Color* bg = NULL);
void DisplaySelectionFeedback(uint16 ele_attrmask, const LTRB& rect);
void EraseToBackground(const LTRB& rect, int32 borderWidth = 0);
protected:
int m_iBitsPerPixel;
BOOL m_bUseDibPalColors;
public:
BOOL GetUseDibPalColors() {
return m_bUseDibPalColors;
}
int GetBitsPerPixel() {
return m_iBitsPerPixel;
}
void SetUseDibPalColors(BOOL flag) {
m_bUseDibPalColors = flag;
}
// Preference representations needed per context.
protected:
public:
// OLE Embed implementation.
private:
BOOL m_bAutoDeleteDocument;
protected:
CGenericDoc *m_pDocument;
public:
CGenericDoc *GetDocument() const {
return(m_pDocument);
}
void ClearDoc() {
m_pDocument = NULL;
}
void GetPluginRect(MWContext *pContext,
LO_EmbedStruct *pLayoutData,
RECT &rect, int iLocation,
BOOL windowed);
BOOL IsPluginFullPage(LO_EmbedStruct *pLayoutData);
BOOL ContainsFullPagePlugin();
// Document helpers.
public:
virtual BOOL OnOpenDocumentCX(const char *pPathName);
// URL retrieval
public:
virtual int GetUrl(URL_Struct *pUrl, FO_Present_Types iFormatOut, BOOL bReallyLoad = TRUE, BOOL bForceNew = FALSE);
// Function for easy creation of a URL from the current history entry.
public:
virtual URL_Struct *CreateUrlFromHist(BOOL bClearStateData = FALSE, SHIST_SavedData *pSavedData = NULL, BOOL bWysiwyg = FALSE);
// Image conditional loading.
private:
CString m_csForceLoadImage;
CString m_csNexttimeForceLoadImage;
BOOL m_bLoadImagesNow;
BOOL m_bNexttimeLoadImagesNow;
public:
void ExplicitlyLoadThisImage(const char *pImageUrl) {
m_csNexttimeForceLoadImage = pImageUrl;
NiceReload();
}
void ExplicitlyLoadAllImages() {
m_bNexttimeLoadImagesNow = TRUE;
NiceReload();
}
// Wether or not we exist in an OLE server....
private:
BOOL m_bOleServer;
public:
BOOL IsOleServer() const {
return(m_bOleServer);
}
void EnableOleServer();
void DisableOleServer() {
m_bOleServer = FALSE;
}
// Font for Form Text Entry
private:
friend class CFormElement;
enum {
m_FixedFont,
m_ProportionalFont
};
#if 0 /* dp */
int m_DownloadedFontList; // for testing
#endif /* 0 */
HFONT m_pFormFixFont;
HFONT m_pFormPropFont;
int m_iFormFixCSID; // csid for current form.
int m_iFormPropCSID; // csid for current form.
void ExtendCoord(LTRB &Rect);
virtual void GetDrawingOrigin(int32 *plOrgX, int32 *plOrgY)
{ *plOrgX = 0; *plOrgY = 0; }
virtual FE_Region GetDrawingClip()
{ return NULL; }
private :
void CDCCX::DrawTabFocusLine( HDC hdc, BOOL supportPixel, int x, int y, int x2, int y2);
void CDCCX::DrawTabFocusRect( HDC hdc, BOOL supportPixel, int left, int top, int right, int bottom);
void CDCCX::DrawRectBorder(LTRB& Rect, COLORREF rgbColor, int32 lWidth);
void CDCCX::DrawMapAreaBorder( int baseX, int baseY, lo_MapAreaRec * theArea );
// MFC Helpers; abstraction away
public:
virtual void ViewImages();
virtual BOOL CanViewImages();
// Context Overrides
virtual void DisplayBullet(MWContext *pContext, int iLocation, LO_BullettStruct *pBullet);
#ifndef MOZ_NGLAYOUT
virtual void DisplayEmbed(MWContext *pContext, int iLocation, LO_EmbedStruct *pEmbed);
#endif
virtual void DisplayBuiltin(MWContext *pContext, int iLocation, LO_BuiltinStruct *pBuiltin);
virtual void DisplayBorder(MWContext *pContext, int iLocation, int x, int y, int width, int height, int bw, LO_Color *color, LO_LineStyle style);
virtual void DisplayHR(MWContext *pContext, int iLocation, LO_HorizRuleStruct *pHorizRule);
virtual BITMAPINFO* NewPixmap(NI_Pixmap* pImage, BOOL mask = FALSE);
virtual int DisplayPixmap(NI_Pixmap* image, NI_Pixmap* mask, int32 x, int32 y, int32 x_offset, int32 y_offset, int32 width, int32 height, int32 lScaleWidth, int32 lScaleHeight, LTRB& Rect);
virtual void DisplayLineFeed(MWContext *pContext, int iLocation, LO_LinefeedStruct *pLineFeed, XP_Bool clear);
virtual void DisplaySubDoc(MWContext *pContext, int iLocation, LO_SubDocStruct *pSubDoc);
virtual void DisplayCell(MWContext *pContext, int iLocation, LO_CellStruct *pCell);
virtual void DisplaySubtext(MWContext *pContext, int iLocation, LO_TextStruct *pText, int32 lStartPos, int32 lEndPos, XP_Bool clear);
virtual void DisplayTable(MWContext *pContext, int iLocation, LO_TableStruct *pTable);
// need to keep the old interface for calling from C
virtual void DisplayText(MWContext *pContext, int iLocation, LO_TextStruct *pText, XP_Bool clear);
void CDCCX::DisplayImageFeedback(MWContext *pContext, int iLocation, LO_Element *pElement, lo_MapAreaRec * theArea, uint32 drawFlag );
// /* cannot use default drawFlag = 0, if this function is called from C */
virtual void DisplayText(MWContext *pContext, int iLocation, LO_TextStruct *pText, XP_Bool clear, uint32 drawFlag );
// handle strike and under-line, after text is drawn.
virtual void CDCCX::DrawTextPostDecoration(HDC hdc, LO_TextAttr * attr, LTRB * Rect, COLORREF rgbColor );
virtual void DisplayWindowlessPlugin(MWContext *pContext, LO_EmbedStruct *pEmbed, NPEmbeddedApp *pEmbeddedApp, int iLocation);
virtual void DisplayPlugin(MWContext *pContext, LO_EmbedStruct *pEmbed, NPEmbeddedApp* pEmbeddedApp, int iLocation);
#ifdef LAYERS
virtual void EraseBackground(MWContext *pContext, int iLocation, int32 x, int32 y, uint32 width, uint32 height, LO_Color *pColor);
#endif
#ifndef MOZ_NGLAYOUT
virtual void FreeEmbedElement(MWContext *pContext, LO_EmbedStruct *pEmbed);
virtual void FreeBuiltinElement(MWContext *pContext, LO_BuiltinStruct *pBuiltin);
virtual void GetEmbedSize(MWContext *pContext, LO_EmbedStruct *pEmbed, NET_ReloadMethod bReload);
#endif /* MOZ_NGLAYOUT */
#ifdef LAYERS
virtual void GetTextFrame(MWContext *pContext, LO_TextStruct *pText,
int32 start, int32 end, XP_Rect *frame);
#endif
virtual int GetTextInfo(MWContext *pContext, LO_TextStruct *pText, LO_TextInfo *pTextInfo);
virtual void ImageComplete(NI_Pixmap* image);
virtual void LayoutNewDocument(MWContext *pContext, URL_Struct *pURL, int32 *pWidth, int32 *pHeight, int32 *pmWidth, int32 *pmHeight);
virtual void SetBackgroundColor(MWContext *pContext, uint8 uRed, uint8 uGreen, uint8 uBlue);
virtual COLORREF GetBackgroundColor() {return m_rgbBackgroundColor;}
virtual void Set3DColors( COLORREF crBackground );
static HPALETTE InitPalette(HDC hdc);
static HPALETTE CreateColorPalette(HDC hdc, IL_IRGB& transparentColor, int bitsPerPixel);
static void SetColormap(HDC hdc, NI_ColorMap *pMap, IL_IRGB& transparentColor, HPALETTE hPal);
virtual void SetDocDimension(MWContext *pContext, int iLocation, int32 lWidth, int32 lLength);
virtual void GetDocPosition(MWContext *pContext, int iLocation, int32 *lX_p, int32 *lY_p);
#ifndef MOZ_NGLAYOUT
virtual void DisplayFormElement(MWContext *pContext, int iLocation, LO_FormElementStruct *pFormElement);
virtual void FormTextIsSubmit(MWContext *pContext, LO_FormElementStruct *pFormElement);
virtual void GetFormElementInfo(MWContext *pContext, LO_FormElementStruct *pFormElement);
virtual void GetFormElementValue(MWContext *pContext, LO_FormElementStruct *pFormElement, XP_Bool bTurnOff);
virtual void ResetFormElement(MWContext *pContext, LO_FormElementStruct *pFormElement);
virtual void SetFormElementToggle(MWContext *pContext, LO_FormElementStruct *pFormElement, XP_Bool iState);
#endif
#ifdef TRANSPARENT_APPLET
virtual void DrawJavaApp(MWContext *pContext, int iLocation, LO_JavaAppStruct *pJava);
#endif
protected:
void StretchMaskBlt(HDC hTargetDC, HBITMAP theBitmap, HBITMAP theMask,
int32 dx, int32 dy, int32 dw, int32 dh,
int32 sx, int32 sy, int32 sw, int32 sh);
void StretchPixmap(HDC hTargetDC, NI_Pixmap* pImage,
int32 dx, int32 dy, int32 dw, int32 dh,
int32 sx, int32 sy, int32 sw, int32 sh);
virtual void _StretchDIBitsWithMask(HDC pDC,
int iDestX,
int iDestY,
int iDestWidth,
int iDestHeight,
int iSrcX,
int iSrcY,
int iSrcWidth,
int iSrcHeight,
NI_Pixmap *image,
NI_Pixmap *mask);
#ifdef DDRAW
BOOL TransparentBlt(int iDestX,
int iDestY,
int iDestWidth,
int iDestHeight,
int iSrcX,
int iSrcY,
int iSrcWidth,
int iSrcHeight,
NI_Pixmap *image,
COLORREF transColor,
LPDIRECTDRAWSURFACE surf);
#endif
BITMAPINFO* FillBitmapInfoHeader(NI_Pixmap* pImage);
HBITMAP CreateBitmap(HDC hTargetDC, NI_Pixmap *image);
HBITMAP CreateMask(HDC hTargetDC, NI_Pixmap* mask);
void TileImage(HDC hdc, LTRB& Rect, NI_Pixmap* image, NI_Pixmap* mask, int32 x, int32 y);
};
// Global functions
// Calculate a contrastng text and background colors to use for selection
// given a background color
void wfe_GetSelectionColors( COLORREF rgbBackgroundColor,
COLORREF* pTextColor, COLORREF* pBackColor);
// Global variables
//
// Macros
//
#endif // __Context_Device_Context_H

2262
mozilla/cmd/winfe/cxdc1.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,491 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "cxicon.h"
#include "feimage.h"
#include "winproto.h"
#include "helper.h"
HBITMAP CRDFImage::m_hBadImageBitmap = NULL;
int CRDFImage::refCount = 0;
CRDFImage::CRDFImage(const char * url)
{
m_nRefCount = 0;
pUrl = _strdup( url);
bmpInfo = NULL;
m_bCompletelyLoaded = FALSE;
m_bFrameLoaded = FALSE;
bits = 0;
maskbits = 0;
m_BadImage = FALSE;
CRDFImage::refCount++;
iconContext = NULL;
pairCount = 0;
}
CRDFImage::~CRDFImage()
{
// XP_FREE( bmpInfo);
// CDCCX::HugeFree(bits);
// CDCCX::HugeFree(maskbits);
free(pUrl);
CRDFImage::refCount--;
if (refCount == 0)
{
if (CRDFImage::m_hBadImageBitmap)
VERIFY(::DeleteObject(CRDFImage::m_hBadImageBitmap));
}
}
void CRDFImage::AddListener(CCustomImageObject* pObject, HT_Resource r)
{
// We only want to have one copy of the same image in this list.
for (POSITION pos = resourceList.GetHeadPosition();
pos != NULL; )
{
// Enumerate over the list and call remove listener on each image.
CIconCallbackInfo* pInfo = (CIconCallbackInfo*)resourceList.GetNext(pos);
if (pInfo->pObject == pObject &&
pInfo->pResource == r)
return; // We're already listening for this resource.
}
// Add a listener.
CIconCallbackInfo* iconCallbackInfo = new CIconCallbackInfo(pObject, r);
resourceList.AddHead(iconCallbackInfo);
pObject->AddLoadingImage(this);
m_nRefCount++;
if (iconContext == NULL)
{
// Kick off the load.
ProcessIcon();
}
}
void CRDFImage::RemoveListener(CCustomImageObject *pObject)
{
// Listener has been destroyed. Need to get all references to it out of the list.
// Just do this by NULLing out the pObject field of the iconcallbackinfo structs.
for (POSITION pos = resourceList.GetHeadPosition();
pos != NULL; )
{
CIconCallbackInfo* pInfo = (CIconCallbackInfo*)resourceList.GetNext(pos);
if (pInfo->pObject == pObject)
{
pInfo->pObject = NULL;
m_nRefCount--;
if (m_nRefCount == 0 && iconContext)
{
iconContext->Interrupt();
DestroyContext();
return;
}
}
}
}
void CRDFImage::RemoveListenerForSpecificResource(CCustomImageObject *pObject, HT_Resource r)
{
// Listener has been destroyed. Need to get all references to it out of the list.
// Just do this by NULLing out the pObject field of the iconcallbackinfo structs.
for (POSITION pos = resourceList.GetHeadPosition();
pos != NULL; )
{
CIconCallbackInfo* pInfo = (CIconCallbackInfo*)resourceList.GetNext(pos);
if (pInfo->pObject == pObject && pInfo->pResource == r)
{
pInfo->pObject = NULL;
m_nRefCount--;
if (m_nRefCount == 0 && iconContext)
{
iconContext->Interrupt();
DestroyContext();
return;
}
}
}
}
void CRDFImage::DestroyContext()
{
iconContext->DeleteContextDC();
iconContext->NiceDestruction();
iconContext = NULL;
resourceList.RemoveAll();
}
BOOL CRDFImage::FrameLoaded()
{
return (m_bFrameLoaded);
}
BOOL CRDFImage::FrameSuccessfullyLoaded()
{
return (m_bFrameLoaded && bits);
}
BOOL CRDFImage::CompletelyLoaded()
{
return m_bCompletelyLoaded;
}
void Icon_GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext)
{
// Report any errors.
if(iStatus < 0 && pUrl->error_msg != NULL)
{
void* pData;
CRDFImage* theImage = NULL;
if (CHTFEData::m_CustomURLCache.Lookup(pUrl->address, pData))
theImage = (CRDFImage*)pData;
if (theImage)
{ // Since we cannot load this url, replace it with a bad image.
theImage->m_BadImage = TRUE;
theImage->bits = 0;
theImage->maskbits = 0;
theImage->bmpInfo = 0;
if (!CRDFImage::m_hBadImageBitmap)
CRDFImage::m_hBadImageBitmap = ::LoadBitmap(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_IMAGE_BAD));
theImage->CompleteCallback();
}
}
// standard free-a-URL-with-Windows-DDE-gunk mechanism:
if (NCAPIDATA(pUrl))
NCAPIDATA(pUrl)->EndProgress();
if (!NCAPIDATA(pUrl) || NCAPIDATA(pUrl)->CanFreeUrl()) {
FEU_DeleteUrlData(pUrl, NULL);
NET_FreeURLStruct(pUrl);
}
}
static BOOL IsImageMimeType(const CString& theFormat)
{
BOOL val = FALSE;
if (theFormat.CompareNoCase(IMAGE_GIF) == 0)
val = TRUE;
else if (theFormat.CompareNoCase(IMAGE_JPG) == 0)
val = TRUE;
else if (theFormat.CompareNoCase(IMAGE_PJPG) == 0)
val = TRUE;
else if (theFormat.CompareNoCase(IMAGE_PPM) == 0)
val = TRUE;
else if (theFormat.CompareNoCase(IMAGE_PNG) == 0)
val = TRUE;
else if (theFormat.CompareNoCase(IMAGE_XBM) == 0)
val = TRUE;
else if (theFormat.CompareNoCase(IMAGE_XBM2) == 0)
val = TRUE;
else if (theFormat.CompareNoCase(IMAGE_XBM3) == 0)
val = TRUE;
return val;
}
static BOOL ValidNSBitmapFormat(char* extension)
{
CPtrList* allHelpers = &(CHelperApp::m_cplHelpers);
for (POSITION pos = allHelpers->GetHeadPosition(); pos != NULL;)
{
CHelperApp* app = (CHelperApp*)allHelpers->GetNext(pos);
CString helperMime(app->cd_item->ci.type);
if (IsImageMimeType(helperMime))
{
if (app->cd_item->num_exts > 0)
{
for (int i = 0; i < app->cd_item->num_exts; i++)
{
CString extString(app->cd_item->exts[i]);
if (extString == &extension[1])
return TRUE;
}
}
}
}
return FALSE;
}
void CRDFImage::ProcessIcon()
{
char *ext = FE_FindFileExt(pUrl);
if (ValidNSBitmapFormat(ext))
{
// If there is no context, create one for processing the image.
hSubDC = ::CreateCompatibleDC(NULL);
if (iconContext == NULL)
{
iconContext = new CXIcon(this);
iconContext->SubstituteDC(hSubDC);
iconContext->Initialize(FALSE, NULL, FALSE);
iconContext->SetUseDibPalColors(FALSE);
}
// Temporary hack to disable loading RDF images for the layout integration
// build.
#ifndef MOZ_NGLAYOUT
// Ask for this via client pull.
// We may be in the call stack of the image lib, and doing
// lots of fast small get urls causes it to barf due
// to list management not being reentrant.
FEU_ClientPull(iconContext->GetContext(), 0, NET_CreateURLStruct(pUrl, NET_DONT_RELOAD), FO_CACHE_AND_PRESENT, FALSE);
#endif
}
else
{ // handle window internal format BMP
CString extension = ext;
if (extension.CompareNoCase(".bmp"))
{
}
else
{
// TODO: Error handling here, unknow bitmap format.
}
}
}
void CRDFImage::CompleteCallback()
{
m_bCompletelyLoaded = TRUE;
while (!resourceList.IsEmpty())
{
CIconCallbackInfo* callback = (CIconCallbackInfo*)(resourceList.RemoveHead());
if (callback->pObject)
{
callback->pObject->LoadComplete(callback->pResource);
callback->pObject->RemoveLoadingImage(this);
}
delete callback;
}
DestroyContext();
}
void CRDFImage::CompleteFrameCallback()
{
m_bFrameLoaded = TRUE;
for (POSITION pos = resourceList.GetHeadPosition(); pos != NULL; )
{
CIconCallbackInfo* callback = (CIconCallbackInfo*)(resourceList.GetNext(pos));
if (callback->pObject)
{
callback->pObject->LoadComplete(callback->pResource);
}
}
}
CXIcon::CXIcon(CRDFImage* theImage)
{
MWContext *pContext = GetContext();
m_cxType = IconCX;
pContext->type = MWContextIcon;
m_MM = MM_TEXT;
m_hDC = 0;
m_icon = theImage;
m_image = NULL;
m_mask = NULL;
}
CXIcon::~CXIcon()
{
}
BITMAPINFO * CXIcon::NewPixmap(NI_Pixmap *pImage, BOOL isMask)
{
// remember which bitmap we have so we can get the bits later in imageComplete.
if (isMask)
m_mask = pImage;
else m_image = pImage;
return CDCCX::NewPixmap(pImage, isMask);
}
int CXIcon::DisplayPixmap(NI_Pixmap* image, NI_Pixmap* mask, int32 x, int32 y, int32 x_offset, int32 y_offset, int32 width, int32 height, int32 lScaleWidth, int32 lScaleHeight, LTRB& Rect)
{
/*
if (m_image)
{
CDCCX::HugeFree(m_image->bits);
m_image->bits = NULL;
FEBitmapInfo *imageInfo = (FEBitmapInfo*)m_image->client_data;
delete imageInfo;
m_image->client_data = NULL;
m_image = NULL;
}
if (m_mask)
{
CDCCX::HugeFree(m_mask->bits);
m_mask->bits = NULL;
FEBitmapInfo *imageInfo = (FEBitmapInfo*)m_mask->client_data;
delete imageInfo;
m_mask->client_data = NULL;
m_mask = NULL;
}
*/
if (m_icon->bits)
{
// Free the old pixmap to make way for the new.
CDCCX::HugeFree(m_icon->bits);
m_icon->bits = NULL;
}
if (m_icon->maskbits)
{
// Free the old mask to make way for the new.
CDCCX::HugeFree(m_icon->maskbits);
m_icon->maskbits = NULL;
}
if (m_icon->bmpInfo)
{
XP_FREE(m_icon->bmpInfo);
m_icon->bmpInfo = NULL;
}
// Get the new pixmap.
m_image = image;
m_mask = mask;
// Fill in our header.
m_icon->bmpInfo = FillBitmapInfoHeader(image);
// Copy our bits if we have any.
if (m_image->bits)
{
FEBitmapInfo* imageInfo = (FEBitmapInfo*) m_image->client_data;
BITMAPINFOHEADER* header = (BITMAPINFOHEADER*)imageInfo->bmpInfo;
m_icon->bits = HugeAlloc(header->biSizeImage, 1);
memcpy( m_icon->bits, m_image->bits, header->biSizeImage );
}
if (mask && m_mask->bits)
{
FEBitmapInfo* imageInfo = (FEBitmapInfo*) m_mask->client_data;
BITMAPINFOHEADER* header = (BITMAPINFOHEADER*)imageInfo->bmpInfo;
m_icon->maskbits = HugeAlloc(header->biSizeImage, 1);
memcpy( m_icon->maskbits, m_mask->bits, header->biSizeImage );
}
m_icon->CompleteFrameCallback();
return 1;
}
void CXIcon::ImageComplete(NI_Pixmap* image)
{
// Will get a call for both the mask and for the image.
if (m_image && m_mask)
{
m_icon->pairCount++;
if (m_icon->pairCount == 2)
m_icon->CompleteCallback();
}
else
{
// We have no mask.
m_icon->CompleteCallback();
}
}
// Don't display partial images.
void CXIcon::AllConnectionsComplete(MWContext *pContext)
{
CDCCX::AllConnectionsComplete(pContext);
}
void CXIcon::NiceDestruction()
{
m_bIdleDestroy = TRUE;
FEU_RequestIdleProcessing(GetContext());
}
// ========================= CCustomImageObject Helpers =============================
CRDFImage* CCustomImageObject::LookupImage(const char* url, HT_Resource r)
{
// Find the image.
void* pData;
CRDFImage* pImage = NULL;
if (CHTFEData::m_CustomURLCache.Lookup(url, pData))
{
pImage = (CRDFImage*)pData;
// Add ourselves to the callback list if the image hasn't completely loaded.
if (!pImage->CompletelyLoaded())
{
// The image is currently loading. Register ourselves with the image so that we will get called
// when the image finishes loading.
pImage->AddListener(this, r);
}
}
else
{
// Create a new NavCenter image.
pImage = new CRDFImage(url);
pImage->AddListener(this, r);
CHTFEData::m_CustomURLCache.SetAt(url, pImage);
}
return pImage;
}
CCustomImageObject::~CCustomImageObject()
{
// The displayer of the image is being destroyed. It should be removed as a listener from all
// images.
for (POSITION pos = loadingImagesList.GetHeadPosition();
pos != NULL; )
{
// Enumerate over the list and call remove listener on each image.
CRDFImage* pImage = (CRDFImage*)loadingImagesList.GetNext(pos);
pImage->RemoveListener(this);
}
}
void CCustomImageObject::AddLoadingImage(CRDFImage* pImage)
{
// We only want to have one copy of the same image in this list.
for (POSITION pos = loadingImagesList.GetHeadPosition();
pos != NULL; )
{
// Enumerate over the list and call remove listener on each image.
CRDFImage* pNavImage = (CRDFImage*)loadingImagesList.GetNext(pos);
if (pNavImage == pImage)
return;
}
// Add the image to the list.
loadingImagesList.AddHead(pImage);
}
void CCustomImageObject::RemoveLoadingImage(CRDFImage* pImage)
{
// Should only occur once in our list. Find and remove.
POSITION pos = loadingImagesList.Find(pImage);
if (pos)
loadingImagesList.RemoveAt(pos);
}

127
mozilla/cmd/winfe/cxicon.h Normal file
View File

@@ -0,0 +1,127 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 CXIcon_H
#define CXIcon_H
#include "cxdc.h"
void Icon_GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext);
class CXIcon;
class CCustomImageObject
{
protected:
CPtrList loadingImagesList; // A list of images that this window is still waiting for.
public:
virtual void LoadComplete(HT_Resource r) = 0;
virtual CRDFImage* LookupImage(const char* url, HT_Resource r);
virtual ~CCustomImageObject();
virtual void AddLoadingImage(CRDFImage* pImage);
virtual void RemoveLoadingImage(CRDFImage* pImage);
};
struct CIconCallbackInfo
{
HT_Resource pResource;
CCustomImageObject* pObject;
CIconCallbackInfo(CCustomImageObject* pObj, HT_Resource pRes)
:pObject(pObj), pResource(pRes) {}
};
class CRDFImage
{
public:
char *pUrl; // The URL at which the image can be found.
BOOL m_bCompletelyLoaded; // Whether or not the image has completely finished loading.
BOOL m_bFrameLoaded; // Whether or not a single frame of the image is available yet.
// (Lets you know whether or not you can start drawing something.)
BITMAPINFO *bmpInfo; // The current bits of the image.
void XP_HUGE *bits;
void XP_HUGE *maskbits;
HDC hSubDC;
BOOL m_BadImage; // Whether or not to use the bad image bitmap.
static HBITMAP m_hBadImageBitmap; // A bitmap to use if the image is not obtainable.
static int refCount; // A reference counter for the total # of RDF images that currently exist.
CXIcon* iconContext; // The context that is performing the load.
CPtrList resourceList; // The observers of this image.
int m_nRefCount; // The # of observers.
int pairCount; // Specifies whether or not the mask and the image bits are ready.
public:
CRDFImage(const char * pUrl);
virtual ~CRDFImage();
void ProcessIcon();
void CompleteCallback();
void CompleteFrameCallback();
BOOL FrameLoaded(); // Whether or not a single frame is ready (either good or bad).
BOOL FrameSuccessfullyLoaded(); // Whether or not a good frame is ready.
BOOL CompletelyLoaded(); // Whether or not the entire image is ready (either good or bad).
void DestroyContext();
void RemoveListener(CCustomImageObject* pObject);
void RemoveListenerForSpecificResource(CCustomImageObject *pObject, HT_Resource r);
void AddListener(CCustomImageObject* pObject, HT_Resource r);
};
class CXIcon : public CDCCX {
public:
CXIcon(){}
CXIcon(CRDFImage* image);
virtual ~CXIcon();
private:
CPtrList imageList;
HDC m_hDC;
NI_Pixmap* m_image;
NI_Pixmap* m_mask;
CRDFImage* m_icon;
public:
virtual HDC GetContextDC() { return m_hDC; }
void SubstituteDC(HDC hdc) { m_hDC = hdc; }
virtual BOOL IsDeviceDC() { return TRUE; }
virtual HDC GetAttribDC() { return m_hDC; }
virtual BITMAPINFO *NewPixmap(NI_Pixmap *pImage, BOOL mask);
void DeleteContextDC() { DeleteDC(m_hDC); }
void ReleaseContextDC(HDC pDC) {}
virtual void ImageComplete(NI_Pixmap* image);
// Don't display partial images.
virtual void AllConnectionsComplete(MWContext *pContext);
void NiceDestruction();
virtual int DisplayPixmap(NI_Pixmap* image, NI_Pixmap* mask, int32 x, int32 y, int32 x_offset, int32 y_offset, int32 width, int32 height, int32 lScaleWidth, int32 lScaleHeight, LTRB& Rect);
};
#endif

View File

@@ -0,0 +1,72 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "dialog.h"
/*----------------------------------------------------------------------**
** Hack alert. **
** The following code is needed so that backend libraries can perform **
** a small set of operations before we are initialized. **
** In specific, the fortezza security lib may call FE_PromptPassword **
** via the context function table before we ever have finished creating **
** a window. **
**----------------------------------------------------------------------*/
char *sux_PromptPassword(MWContext *pContext, const char *pMessage) {
char *pRetval = NULL;
char *pWinMessage = FE_Windowsify(pMessage);
if(pWinMessage) {
CDialogPASS dlgPass;
theApp.m_splash.SafeHide();
pRetval = dlgPass.DoModal(pWinMessage);
XP_FREE(pWinMessage);
}
return(pRetval);
}
MWContext *FE_GetInitContext(void) {
static MWContext *pCX = NULL;
static _ContextFuncs sFux;
static MWContext sCX;
// First time through, init context.
// Note, it should only set up the information
// needed to get the back end libraries by.
// It should not be added to the global context
// list or be routed through any of the CAbstractCX
// derived classes. ETC.
if(pCX == NULL) {
memset(&sCX, 0, sizeof(sCX));
memset(&sFux, 0, sizeof(sFux));
// Set up required functions.
sFux.PromptPassword = sux_PromptPassword;
// Fill in the context.
sCX.funcs = &sFux;
pCX = &sCX;
}
return(pCX);
}

174
mozilla/cmd/winfe/cxmeta.cpp Executable file
View File

@@ -0,0 +1,174 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "cxmeta.h"
// The purpose of this file is to output a load to a DC.
// The name MetaFile is just a term, the DC need not be a MetaFileDC.
// If however, the DC passed in is a MetaFile DC, then all setup of DC
// must occur outside of this code.
// Further, the DC must remain valid throughout the course of the load.
// It may be more easier for you to derive from this class and handle creation
// and destruction of your DC therein.
// Indirect construction of the Class which loads a URL and
// returns the context ID, 0 on failure.
// Calling code can track when the MetaFile is finished, by realizing
// when the context ID is no longer found in the context list.
DWORD CMetaFileCX::MetaFileAnchorObject(CDC * pMetaFileDC, SIZE& pSize, URL_Struct *pUrl)
{
// Create a new object.
CMetaFileCX *pDontCare = new CMetaFileCX(pMetaFileDC, pSize, pUrl);
if(pDontCare != NULL) {
// The return value is!
DWORD dwID = pDontCare->GetContextID();
// Load the URL.
pDontCare->GetUrl(pUrl, FO_CACHE_AND_PRESENT);
// Success as far as we are concerned.
return(dwID);
}
// Failure.
return(0);
}
// Construct the class.
CMetaFileCX::CMetaFileCX(CDC* pMetaFileDC, SIZE& pSize, URL_Struct *pUrl)
{
TRACE("Creating CMetaFileCX %p\n", this);
// Set the context type.
m_cxType = MetaFile;
GetContext()->type = MWContextMetaFile;
// this is a hack to save the layout data for embedlist. For embed layout will
// make a copy of the pSavedData. We need to free the memory here.
m_embedList = (lo_SavedEmbedListData*)pUrl->savedData.EmbedList;
// Initialize the class members.
m_pMetaFileDC = NULL;
m_csViewport.cx = m_csViewport.cy = 0;
// Set them.
m_pMetaFileDC = pMetaFileDC;
ASSERT(m_pMetaFileDC);
m_csViewport = pSize;
ASSERT(m_csViewport.cx != 0 && m_csViewport.cy != 0);
// Should be able to initialize ourselves safely now.
Initialize(TRUE);
}
// We are now destroyed.
// Callers can tell when we've gone away by checking for our context ID
// in the list of all contexts -- Returned by MetaFileAnchorObject.
CMetaFileCX::~CMetaFileCX()
{
TRACE("Destroying CMetaFileCX %p\n", this);
// MWH - this is a hack to free the embed list that layout make copy from the original
// SavedData. I removed the freeing from lib\layout\layfree.c lo_FreeDocumentEmbedListData.
// and free the data here. This will fix an OLE printing problem. The problem is when a .doc file
// is on the net, i.e. http://....//xxx.doc. When layout free the EmbedList in
// lo_FreeDocumentEmbedListData will cause the page not printed. Since for printing we need
// to use the cached data.
if (m_embedList && (m_embedList->embed_data_list != NULL)) {
int32 i;
lo_EmbedDataElement* embed_data_list;
PA_LOCK(embed_data_list, lo_EmbedDataElement*, m_embedList->embed_data_list);
for (i=0; i < m_embedList->embed_count; i++)
{
if (embed_data_list[i].freeProc && embed_data_list[i].data)
(*(embed_data_list[i].freeProc))(GetContext(), embed_data_list[i].data);
}
PA_UNLOCK(m_embedList->embed_data_list);
PA_FREE(m_embedList->embed_data_list);
m_embedList->embed_count = 0;
m_embedList->embed_data_list = NULL;
}
}
// Returns the DC for this context.
HDC CMetaFileCX::GetContextDC()
{
return(m_pMetaFileDC->GetSafeHdc());
}
// Releases the DC for this context.
// Since the DC is static, there is no need to really do anything fancy here.
void CMetaFileCX::ReleaseContextDC(HDC pDC)
{
}
// Initializes the context for work after all the members are set.
// We leave the DC as persistant, as it doesn't really change while we're doing
// this (it better!).
void CMetaFileCX::Initialize(BOOL bOwnDC, RECT *pRect, BOOL bInitialPalette, BOOL bNewMemDC)
{
// We're going to use MM_TEXT for simplicity sake.
// Another reason, is simply, that on 16 bit windows, all the GDI functions
// take 16 bit ints, which wrap if the page gets too long.
// The page will be increadibly long, since this is a metafile, and this
// will prolong the wrapping.
m_MM = MM_TEXT;
// Set our width and height to that specified in the constructor.
m_lWidth = Twips2PixX(Metric2TwipsX(m_csViewport.cx));
m_lHeight = Twips2PixY(Metric2TwipsY(m_csViewport.cy));
TRACE("Metafile width is %ld\n", m_lWidth);
TRACE("Metafile height is %ld\n", m_lHeight);
// Call the base.
CDCCX::Initialize(bOwnDC, pRect, bInitialPalette, bNewMemDC);
}
// A new document is starting to be laid out.
// Inform layout of our dimensions, etc.
void CMetaFileCX::LayoutNewDocument(MWContext *pContext, URL_Struct *pURL, int32 *pWidth, int32 *pHeight, int32 *pmWidth, int32 *pmHeight)
{
// Turn off all display blocking, since we allow the metafile to
// be the full representation of a document.
DisableDisplayBlocking();
// Call the base
CDCCX::LayoutNewDocument(pContext, pURL, pWidth, pHeight, pmWidth, pmHeight);
}
// The load is finished for all intents and purposes.
// Get rid of ourselves.
void CMetaFileCX::AllConnectionsComplete(MWContext *pContext)
{
// Call the base.
CDCCX::AllConnectionsComplete(pContext);
// We're done.
DestroyContext();
}
// Do not allow incremental image display.
PRBool CMetaFileCX::ResolveIncrementalImages()
{
return(PR_FALSE);
}

64
mozilla/cmd/winfe/cxmeta.h Executable file
View File

@@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 MetaFileContext__H
#define MetaFileContext__H
// Deriving from CDCCX
#include "cxdc.h"
class CMetaFileCX : public CDCCX {
// construction, destructions, indirect construction
public:
CMetaFileCX(CDC* pMetaFileDC, SIZE& pSize, URL_Struct *pUrl);
~CMetaFileCX();
static DWORD MetaFileAnchorObject(CDC *pMetaFileDC, SIZE& pSize, URL_Struct *pUrl);
// CDC Access.
private:
CDC *m_pMetaFileDC;
lo_SavedEmbedListData* m_embedList; /* to save the savedData from the URL struct.*/
public:
virtual HDC GetContextDC();
virtual BOOL IsDeviceDC() {return TRUE;}
virtual HDC GetAttribDC() {return m_pMetaFileDC->m_hAttribDC;}
virtual void ReleaseContextDC(HDC pDC);
// The size of the viewport which we'll be formatting layout to.
protected:
SIZE m_csViewport;
// Post Initialization
public:
virtual void Initialize(BOOL bOwnDC, RECT *pRect = NULL, BOOL bInitialPalette = TRUE, BOOL bNewMemDC = TRUE);
// Context sensitive attribute mapping.
public:
virtual PRBool ResolveIncrementalImages();
// Overrides
public:
// All connections complete.
virtual void AllConnectionsComplete(MWContext *pContext);
// Layout initialization respecting page size.
virtual void LayoutNewDocument(MWContext *pContext, URL_Struct *pURL, int32 *pWidth, int32 *pHeight, int32 *pmWidth, int32 *pmHeight);
};
#endif // MetaFileContext__H

View File

@@ -0,0 +1,733 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// network.cpp : implementation file
//
#include "stdafx.h"
#include "cxnet1.h"
/////////////////////////////////////////////////////////////////////////////
// Context functions
XP_Bool CNetworkCX::Confirm(MWContext *pContext, const char *pConfirmMessage) {
// Always return true, we don't want any dialogs coming up.
// Don't call the base.
// This will cause the prompt functions to be called multiple times as
// needed since both the netlib and this object cache different
// passwords.
return(TRUE);
}
void CNetworkCX::Alert(MWContext *pContext, const char *pMessage) {
// Hand over this in the error string, even if it's not an error.
// Can't have dialogs popping up everywhere.
m_lFlags |= m_ERRS;
m_csErrorMessage = pMessage;
// Do not call the base or a dialog comes up.
}
char *CNetworkCX::Prompt(MWContext *pContext, const char *pPrompt, const char *pDefault) {
// So, LJM tells me that this function is used to query for a username.
// Do that here.
// Only if not already asked for during this load.
if((m_lFlags & m_USER) == 0) {
SetUsernameRequested();
return(AllocUsername());
}
return(NULL);
}
char *CNetworkCX::PromptPassword(MWContext *pContext, const char *pMessage) {
// The caller should have proactively set the password before an Open().
// If not, then they will have to figure it out.
// Mark that a password was required for the transfer.
// Only if not already asked for during this load.
if((m_lFlags & m_PASS) == 0) {
SetPasswordRequested();
return(AllocPassword());
}
return(NULL);
}
XP_Bool CNetworkCX::PromptUsernameAndPassword(MWContext *pContext, const char *pMessage, char **ppUsername, char **ppPassword) {
// Initialize.
*ppPassword = NULL;
*ppUsername = NULL;
// If both have already been asked for, don't continue.
if((m_lFlags & m_USER) != 0 && (m_lFlags & m_PASS) != 0) {
return(FALSE);
}
// Prompt for both username and password.
// Default values are given, and if not already specified by the caller, then we can just use them.
// Set that both a username and a password were required for the transfer.
SetPasswordRequested();
SetUsernameRequested();
// Copy and set any user/password values that the controller has preemptively set.
char *pPass = AllocPassword();
if(pPass != NULL) {
*ppPassword = pPass;
}
char *pUser = AllocUsername();
if(pUser != NULL) {
*ppUsername = pUser;
}
return(TRUE);
}
XP_Bool CNetworkCX::ShowAllNewsArticles(MWContext *pContext) {
// Set to show all the news articles.
return(GetFlagShowAllNews());
}
XP_Bool CNetworkCX::UseFancyFTP(MWContext *pContext) {
// Check to see if we are to use Fancy FTP.
return(GetFlagFancyFTP());
}
XP_Bool CNetworkCX::UseFancyNewsgroupListing(MWContext *pContext) {
// See if we should use full newsgroup listings with descriptions.
return(GetFlagFancyNews());
}
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNetworkCX
#ifndef _AFXDLL
#undef new
#endif
IMPLEMENT_DYNCREATE(CNetworkCX, CCmdTarget)
#ifndef _AFXDLL
#define new DEBUG_NEW
#endif
CNetworkCX::CNetworkCX()
{
EnableAutomation();
// To keep the application running as long as an OLE automation
// object is active, the constructor calls AfxOleLockApp.
AfxOleLockApp();
// Set the type of context that we are.
m_cxType = Network;
GetContext()->type = MWContextOleNetwork;
// Initialize our URL property, other members won't work unless this is defined.
m_pUrlData = NULL;
// Our buffer is initially empty.
ASSERT(m_cplBuffers.IsEmpty());
// We're done loading any stream, as none have started.
m_bStreamComplete = TRUE;
// We don't want to initially show all news articles.
m_bShowAllNews = FALSE;
// We do want to use Fancy News and Fancy FTP by default.
m_bFancyNews = TRUE;
m_bFancyFTP = TRUE;
// We've no current status flags.
m_lFlags = m_OK;
// Username and password should be empty initially anyhow.
TRACE("Netscape.Network.1 started\n");
}
CNetworkCX::~CNetworkCX()
{
// To terminate the application when all objects created with
// with OLE automation, the destructor calls AfxOleUnlockApp.
AfxOleUnlockApp();
TRACE("Netscape.Network.1 ended\n");
}
void CNetworkCX::OnFinalRelease()
{
// When the last reference for an automation object is released
// OnFinalRelease is called. This implementation deletes the
// object. Add additional cleanup required for your object before
// deleting it from memory.
// If we have a currently loading stream, we need to do cleanup there.
if(m_pUrlData != NULL) {
Close();
}
DestroyContext();
}
char *CNetworkCX::AllocUsername() {
// See if we even have a username to allocate.
if(m_csUsername.IsEmpty() == TRUE) {
return(NULL);
}
return(XP_STRDUP(m_csUsername));
}
char *CNetworkCX::AllocPassword() {
// See if we even have a password to allocate.
if(m_csPassword.IsEmpty() == TRUE) {
return(NULL);
}
return(XP_STRDUP(m_csPassword));
}
BEGIN_MESSAGE_MAP(CNetworkCX, CCmdTarget)
//{{AFX_MSG_MAP(CNetworkCX)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BEGIN_DISPATCH_MAP(CNetworkCX, CCmdTarget)
//{{AFX_DISPATCH_MAP(CNetworkCX)
DISP_PROPERTY_EX(CNetworkCX, "Username", GetUsername, SetUsername, VT_BSTR)
DISP_PROPERTY_EX(CNetworkCX, "Password", GetPassword, SetPassword, VT_BSTR)
DISP_PROPERTY_EX(CNetworkCX, "FlagShowAllNews", GetFlagShowAllNews, SetFlagShowAllNews, VT_BOOL)
DISP_PROPERTY_EX(CNetworkCX, "FlagFancyFTP", GetFlagFancyFTP, SetFlagFancyFTP, VT_BOOL)
DISP_PROPERTY_EX(CNetworkCX, "FlagFancyNews", GetFlagFancyNews, SetFlagFancyNews, VT_BOOL)
DISP_FUNCTION(CNetworkCX, "Close", Close, VT_EMPTY, VTS_NONE)
DISP_FUNCTION(CNetworkCX, "Read", Read, VT_I2, VTS_PBSTR VTS_I2)
DISP_FUNCTION(CNetworkCX, "GetStatus", GetStatus, VT_I4, VTS_NONE)
DISP_FUNCTION(CNetworkCX, "Open", Open, VT_BOOL, VTS_BSTR VTS_I2 VTS_BSTR VTS_I4 VTS_BSTR)
DISP_FUNCTION(CNetworkCX, "GetErrorMessage", GetErrorMessage, VT_BSTR, VTS_NONE)
DISP_FUNCTION(CNetworkCX, "GetServerStatus", GetServerStatus, VT_I2, VTS_NONE)
DISP_FUNCTION(CNetworkCX, "GetContentLength", GetContentLength, VT_I4, VTS_NONE)
DISP_FUNCTION(CNetworkCX, "GetContentType", GetContentType, VT_BSTR, VTS_NONE)
DISP_FUNCTION(CNetworkCX, "GetContentEncoding", GetContentEncoding, VT_BSTR, VTS_NONE)
DISP_FUNCTION(CNetworkCX, "GetExpires", GetExpires, VT_BSTR, VTS_NONE)
DISP_FUNCTION(CNetworkCX, "GetLastModified", GetLastModified, VT_BSTR, VTS_NONE)
DISP_FUNCTION(CNetworkCX, "Resolve", Resolve, VT_BSTR, VTS_BSTR VTS_BSTR)
DISP_FUNCTION(CNetworkCX, "IsFinished", IsFinished, VT_BOOL, VTS_NONE)
DISP_FUNCTION(CNetworkCX, "BytesReady", BytesReady, VT_I2, VTS_NONE)
//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()
IMPLEMENT_OLECREATE(CNetworkCX, "Netscape.Network.1", 0xef5f7050, 0x385a, 0x11ce, 0x81, 0x93, 0x0, 0x20, 0xaf, 0x18, 0xf9, 0x5)
/////////////////////////////////////////////////////////////////////////////
// CNetworkCX message handlers
BOOL CNetworkCX::Open(LPCTSTR pURL, short iMethod, LPCTSTR pPostData, long lPostDataSize, LPCTSTR pPostHeaders)
{
// Reset our status flags.
m_lFlags = m_OK;
m_csErrorMessage.Empty();
// See if we're busy.
if(winfeInProcessNet == TRUE) {
m_lFlags |= m_BUSY;
return(FALSE);
}
// If we're handling a request already, shut it down.
if(m_pUrlData != NULL) {
Close();
}
// Create the URL we want to load.
m_pUrlData = NET_CreateURLStruct(pURL, NET_DONT_RELOAD);
// Create the ncapi data for the URL.
// Don't let it free off the URL in the exit routine.
// This is done in close.
// A pointer to the class is saved in the URL struct, and will
// be freed off in FE_DeleteUrlData.
CNcapiUrlData *pDontCare = new CNcapiUrlData(this, m_pUrlData);
pDontCare->DontFreeUrl();
// Set the method for the load.
// GET 0
// POST 1
// HEAD 3
m_pUrlData->method = iMethod;
// Contruct the post stuff.
if(pPostData != NULL && strlen(pPostData) != 0 && m_pUrlData->method == 1) {
m_pUrlData->post_data = (char *)XP_ALLOC(lPostDataSize);
memcpy(m_pUrlData->post_data, pPostData, CASTSIZE_T(lPostDataSize));
m_pUrlData->post_data_size = lPostDataSize;
if(pPostHeaders != NULL && strlen(pPostHeaders) != 0) {
m_pUrlData->post_headers = (char *)XP_ALLOC(strlen(pPostHeaders) + 1);
memcpy(m_pUrlData->post_headers, pPostHeaders, strlen(pPostHeaders) + 1);
}
else {
m_pUrlData->post_headers = strdup("Content-type: application/x-www-form-urlencoded");
}
StrAllocCat(m_pUrlData->post_headers, CRLF);
// Manually add the content-length.
// This was done automatically in versions of Netscape prior to 2.0.
char aBuffer[1024];
sprintf(aBuffer, "Content-length: %ld", lPostDataSize);
StrAllocCat(m_pUrlData->post_headers, aBuffer);
StrAllocCat(m_pUrlData->post_headers, CRLF);
}
// Finally, set that the stream is not yet completed.
m_bStreamComplete = FALSE;
// Need to request a URL for a particular format out, in our special context.
// Any errors should be caught in the exit routine.
GetUrl(m_pUrlData, FO_CACHE_AND_OLE_NETWORK);
return TRUE;
}
short CNetworkCX::Read(BSTR FAR* pBuffer, short iAmount)
{
// First, check for end of file condition.
if(m_cplBuffers.IsEmpty() && m_bStreamComplete == TRUE) {
return(-1);
}
// If the buffer's empty, we should just return right now.
if(m_cplBuffers.IsEmpty()) {
return(0);
}
// We'll want to either copy over the amount of data they are asking for,
// or copy over how much data we have in the buffer,
// whichever is less.
// To do this, we need to figure out the amount of data in the buffers first
// entry only.
// Get the first entry out.
CNetBuffer *pNetBuffer = (CNetBuffer *)m_cplBuffers.GetHead();
// See how much data we should be handling here.
int iBuffer = pNetBuffer->m_iSize - pNetBuffer->m_iHead;
ASSERT(iBuffer);
iAmount = min(iBuffer, iAmount);
if(iAmount <= 0) {
return(0);
}
// Copy over that amount from our buffer.
#if !defined(_UNICODE) && !defined(OLE2ANSI) && defined(MSVC4)
// Need to encode unicode ourselves.
MultiByteToWideChar(CP_ACP, 0, (pNetBuffer->m_pData + pNetBuffer->m_iHead), iAmount, *pBuffer, sizeof(OLECHAR) * iAmount);
#ifdef DEBUG
// Here's some extra goodies to make sure the conversion isn't lossy, as we can also transfer binary data.
// Can we reverse it correctly?
char *pCompare = new char[iAmount];
int iConvert = WideCharToMultiByte(CP_ACP, 0, *pBuffer, iAmount, pCompare, iAmount, NULL, NULL);
ASSERT(iConvert);
// Was the conversion correct?
int iCompare = memcmp(pCompare, (pNetBuffer->m_pData + pNetBuffer->m_iHead), iAmount);
ASSERT(!iCompare);
delete [] pCompare;
#endif
#else
memcpy(*pBuffer, (pNetBuffer->m_pData + pNetBuffer->m_iHead), iAmount);
#endif
pNetBuffer->m_iHead += iAmount;
ASSERT(pNetBuffer->m_iHead <= pNetBuffer->m_iSize);
// See if we should get rid of the buffer entry if completely read now.
if(pNetBuffer->m_iHead == pNetBuffer->m_iSize) {
// Get rid of it.
m_cplBuffers.RemoveHead();
delete pNetBuffer;
}
// Return the amount read.
return(iAmount);
}
void CNetworkCX::Close()
{
// Destroy the URL, if we have one.
if(m_pUrlData != NULL) {
// We really should check for reentrancy, but can't, as this event could happen beyond our control, such
// as the controlling application deleting their automation object.
// Only do this if we are actually loading, as netlib has probably unregistered this otherwise...
if(m_bStreamComplete == FALSE) {
BOOL bOld = winfeInProcessNet;
winfeInProcessNet = TRUE;
NET_InterruptStream(m_pUrlData);
winfeInProcessNet = bOld;
}
NET_FreeURLStruct(m_pUrlData);
m_pUrlData = NULL;
}
// Reset the end of the buffer, our stutus, et al.
CNetBuffer *pDelMe;
while(m_cplBuffers.IsEmpty() == FALSE) {
pDelMe = (CNetBuffer *)m_cplBuffers.RemoveHead();
delete pDelMe;
}
m_lFlags = m_OK;
m_csErrorMessage.Empty();
m_bStreamComplete = TRUE;
}
BSTR CNetworkCX::GetUsername()
{
// Return what the current username is.
// Up to caller to free the information.
return m_csUsername.AllocSysString();
}
void CNetworkCX::SetUsername(LPCTSTR lpszNewValue)
{
// Modify the current username to be something new.
if(lpszNewValue == NULL) {
m_csUsername.Empty();
return;
}
m_csUsername = lpszNewValue;
}
BSTR CNetworkCX::GetPassword()
{
// Return the current password setting.
// Up to caller to free the information.
return m_csPassword.AllocSysString();
}
void CNetworkCX::SetPassword(LPCTSTR lpszNewValue)
{
// Set the password to something new.
if(lpszNewValue == NULL) {
m_csPassword.Empty();
return;
}
m_csPassword = lpszNewValue;
}
long CNetworkCX::GetStatus()
{
// Give them the current status flags since the last open occurred.
return(m_lFlags);
}
BOOL CNetworkCX::GetFlagShowAllNews()
{
return m_bShowAllNews;
}
void CNetworkCX::SetFlagShowAllNews(BOOL bNewValue)
{
m_bShowAllNews = bNewValue;
}
BOOL CNetworkCX::GetFlagFancyFTP()
{
return m_bFancyFTP;
}
void CNetworkCX::SetFlagFancyFTP(BOOL bNewValue)
{
m_bFancyFTP = bNewValue;
}
BOOL CNetworkCX::GetFlagFancyNews()
{
return m_bFancyNews;
}
void CNetworkCX::SetFlagFancyNews(BOOL bNewValue)
{
m_bFancyNews = bNewValue;
}
int CNetworkCX::StreamWrite(const char *pWriteData, int32 lLength) {
// if we don't have a url, then don't do this.
if(m_pUrlData == NULL) {
return(-1);
}
// We should never get called to copy over more data than is reported by StreamReady.
// However, we don't care anymore.
// Allocate a new buffer in which to store the data.
ASSERT(lLength <= NETBUFSIZE);
CNetBuffer *pNewBuf = new CNetBuffer(CASTINT(lLength));
memcpy(pNewBuf->m_pData, pWriteData, pNewBuf->m_iSize);
// Add it to the tail of our buffer list.
m_cplBuffers.AddTail((void *)pNewBuf);
return(MK_DATA_LOADED);
}
unsigned int CNetworkCX::StreamReady() {
// If we don't have a URL, we won't take data.
if(m_pUrlData == NULL) {
return(0);
}
// If we already have n entries in our buffered data, don't do this.
// We can however take more if the netlib screws up due to this new
// buffer system.
if(m_cplBuffers.IsEmpty() == FALSE && m_cplBuffers.GetCount() >= 10) {
return(0);
}
// Return our max allowed size, don't really care if they fulfill this
// completely.
return(NETBUFSIZE);
}
void CNetworkCX::StreamComplete() {
// Function not utilized.
// Stream complete considered to be the URL exit routine.
}
void CNetworkCX::StreamAbort(int iStatus) {
// Function not utilized.
// Stream complete considered to be the URL exit routine.
}
void CNetworkCX::GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext) {
// URL is done loading.
m_bStreamComplete = TRUE;
// Check for internal loading errors.
if(iStatus != MK_DATA_LOADED) {
m_lFlags |= m_INTL;
}
else if(pUrl->server_status / 100 != 2 && pUrl->server_status / 100 != 3 && iStatus == MK_DATA_LOADED && pUrl->server_status != 0) {
m_lFlags |= m_SRVR;
}
// If we have any error message what so ever, then we will save it here and set that an error occurred.
if(m_lFlags & (m_SRVR | m_INTL)) {
if(pUrl->error_msg != NULL) {
if(strlen(pUrl->error_msg) != 0) {
m_lFlags |= m_ERRS;
m_csErrorMessage = pUrl->error_msg;
}
}
}
// Call the base.
CStubsCX::GetUrlExitRoutine(pUrl, iStatus, pContext);
}
BSTR CNetworkCX::GetErrorMessage()
{
// Simply return any error message that we currently have.
return m_csErrorMessage.AllocSysString();
}
extern "C" {
NET_StreamClass *nfe_OleStream(int iFormatOut, void *pDataObj, URL_Struct *pUrlData, MWContext *pContext) {
// Return a new stream class, pass the object along for the ride.
return(NET_NewStream("Netscape_Network_1",
nfe_StreamWrite,
nfe_StreamComplete,
nfe_StreamAbort,
nfe_StreamReady,
CX2VOID(pContext->fe.cx, CNetworkCX),
pContext));
}
int nfe_StreamWrite(NET_StreamClass *stream, const char *pWriteData, int32 lLength) {
void *pDataObj=stream->data_object;
CNetworkCX *pOle = VOID2CX(pDataObj, CNetworkCX);
// Have our object handle it.
return(pOle->StreamWrite(pWriteData, lLength));
}
void nfe_StreamComplete(NET_StreamClass *stream) {
void *pDataObj=stream->data_object;
CNetworkCX *pOle = VOID2CX(pDataObj, CNetworkCX);
// Have our object handle it.
pOle->StreamComplete();
}
void nfe_StreamAbort(NET_StreamClass *stream, int iStatus) {
void *pDataObj=stream->data_object;
CNetworkCX *pOle = VOID2CX(pDataObj, CNetworkCX);
// Have our object handle it.
pOle->StreamAbort(iStatus);
}
unsigned int nfe_StreamReady(NET_StreamClass *stream) {
void *pDataObj=stream->data_object;
CNetworkCX *pOle = VOID2CX(pDataObj, CNetworkCX);
// Have our object handle it.
return(pOle->StreamReady());
}
};
short CNetworkCX::GetServerStatus()
{
// Don't do this if we don't have a URL.
if(m_pUrlData == NULL) {
return(-1);
}
else if(m_bStreamComplete != TRUE) {
// Also can't do this unless the load is done.
return(-1);
}
return(m_pUrlData->server_status);
}
long CNetworkCX::GetContentLength()
{
// Don't do this if we don't have a URL.
if(m_pUrlData == NULL) {
return(-1);
}
return(m_pUrlData->content_length);
}
BSTR CNetworkCX::GetContentType()
{
// Don't do this if we don't have a URL.
if(m_pUrlData == NULL) {
return(NULL);
}
else if(m_pUrlData->content_type == NULL) {
return(NULL);
}
else if(strlen(m_pUrlData->content_type) == 0) {
return(NULL);
}
CString s = m_pUrlData->content_type;
return s.AllocSysString();
}
BSTR CNetworkCX::GetContentEncoding()
{
// Don't do this if we don't have a URL.
if(m_pUrlData == NULL) {
return(NULL);
}
else if(m_pUrlData->content_encoding == NULL) {
return(NULL);
}
else if(strlen(m_pUrlData->content_encoding) == 0) {
return(NULL);
}
CString s = m_pUrlData->content_encoding;
return s.AllocSysString();
}
BSTR CNetworkCX::GetExpires()
{
// Don't do this if we don't have a URL.
if(m_pUrlData == NULL) {
return(NULL);
}
else if(m_pUrlData->expires == (time_t)0) {
return(NULL);
}
char *pTime = ctime(&(m_pUrlData->expires));
if(pTime == NULL) {
return(NULL);
}
CString s = pTime;
return s.AllocSysString();
}
BSTR CNetworkCX::GetLastModified()
{
// Don't do this if we don't have a URL.
if(m_pUrlData == NULL) {
return(NULL);
}
else if(m_pUrlData->last_modified == (time_t)0) {
return(NULL);
}
char *pTime = ctime(&(m_pUrlData->last_modified));
if(pTime == NULL) {
return(NULL);
}
CString s = pTime;
return s.AllocSysString();
}
BSTR CNetworkCX::Resolve(LPCTSTR pBase, LPCTSTR pRelative)
{
// Have the netlib resolve the url stuff for us.
char *cpURL = NET_MakeAbsoluteURL((char *)pBase, (char *)pRelative);
if(cpURL == NULL) {
return(NULL);
}
CString s = cpURL;
XP_FREE(cpURL);
return s.AllocSysString();
}
BOOL CNetworkCX::IsFinished()
{
// Check for end of file condition.
if(m_cplBuffers.IsEmpty() && m_bStreamComplete == TRUE) {
return(TRUE);
}
return(FALSE);
}
short CNetworkCX::BytesReady()
{
// Check to see if there's any load ready.
if(m_cplBuffers.IsEmpty() && m_bStreamComplete == TRUE) {
return(0);
}
// Return the number of bytes we are currently ready to dish out.
CNetBuffer *pReady = (CNetBuffer *)m_cplBuffers.GetHead();
int iBuffer = pReady->m_iSize - pReady->m_iHead;
ASSERT(iBuffer);
return(iBuffer);
}

169
mozilla/cmd/winfe/cxnet1.h Normal file
View File

@@ -0,0 +1,169 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 "cxstubs.h"
/////////////////////////////////////////////////////////////////////////////
// CNetworkCX command target
class CNetworkCX : public CCmdTarget, public CStubsCX
{
DECLARE_DYNCREATE(CNetworkCX)
protected:
CNetworkCX(); // protected constructor used by dynamic creation
// Attributes
private:
URL_Struct *m_pUrlData; // The url to load.
BOOL m_bStreamComplete; // Wether or not the load is completed.
BOOL m_bShowAllNews; // Wether or not to show all news articles.
BOOL m_bFancyNews; // Wether or not to use Fancy News.
BOOL m_bFancyFTP; // Wether or not to use Fancy FTP.
CString m_csUsername; // The registered user name.
CString m_csPassword; // The registered password.
enum {
m_OK = 0x0000, // Data is loaded ok
m_USER = 0x0001, // User name requested, may have still loaded if supplied
m_PASS = 0x0002, // User password requested, may have still loaded if supplied
m_BUSY = 0x0100, // Busy, try back later
m_SRVR = 0x0200, // Server reported an irregular status, probably an error.
m_INTL = 0x0400, // Internal loading error, never got to server.
m_ERRS = 0x0800 // A helpful error string is available provided by Netscape.
};
long m_lFlags; // Some status flags, to mark what happened, to help caller figure out what went wrong.
CString m_csErrorMessage;
// Read buffers to store data as it comes in.
private:
CPtrList m_cplBuffers;
public:
char *AllocUsername();
char *AllocPassword();
void SetPasswordRequested() {
m_lFlags |= m_PASS;
}
void SetUsernameRequested() {
m_lFlags |= m_USER;
}
// Operations
public:
int StreamWrite(const char *pWriteData, int32 lLength);
void StreamComplete();
void StreamAbort(int iStatus);
unsigned int StreamReady();
// Context overrides
public:
virtual void Alert(MWContext *pContext, const char *pMessage);
virtual XP_Bool Confirm(MWContext *pContext, const char *pConfirmMessage);
virtual char *Prompt(MWContext *pContext, const char *pPrompt, const char *pDefault);
virtual char *PromptPassword(MWContext *pContext, const char *pMessage);
virtual XP_Bool PromptUsernameAndPassword(MWContext *pContext, const char *pMessage, char **ppUsername, char **ppPassword);
virtual XP_Bool ShowAllNewsArticles(MWContext *pContext);
virtual XP_Bool UseFancyFTP(MWContext *pContext);
virtual XP_Bool UseFancyNewsgroupListing(MWContext *pContext);
virtual void GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CNetworkCX)
public:
virtual void OnFinalRelease();
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CNetworkCX();
// Generated message map functions
//{{AFX_MSG(CNetworkCX)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
DECLARE_OLECREATE(CNetworkCX)
// Generated OLE dispatch map functions
//{{AFX_DISPATCH(CNetworkCX)
afx_msg BSTR GetUsername();
afx_msg void SetUsername(LPCTSTR lpszNewValue);
afx_msg BSTR GetPassword();
afx_msg void SetPassword(LPCTSTR lpszNewValue);
afx_msg BOOL GetFlagShowAllNews();
afx_msg void SetFlagShowAllNews(BOOL bNewValue);
afx_msg BOOL GetFlagFancyFTP();
afx_msg void SetFlagFancyFTP(BOOL bNewValue);
afx_msg BOOL GetFlagFancyNews();
afx_msg void SetFlagFancyNews(BOOL bNewValue);
afx_msg void Close();
afx_msg short Read(BSTR FAR* pBuffer, short iAmount);
afx_msg long GetStatus();
afx_msg BOOL Open(LPCTSTR pURL, short iMethod, LPCTSTR pPostData, long lPostDataSize, LPCTSTR pPostHeaders);
afx_msg BSTR GetErrorMessage();
afx_msg short GetServerStatus();
afx_msg long GetContentLength();
afx_msg BSTR GetContentType();
afx_msg BSTR GetContentEncoding();
afx_msg BSTR GetExpires();
afx_msg BSTR GetLastModified();
afx_msg BSTR Resolve(LPCTSTR pBase, LPCTSTR pRelative);
afx_msg BOOL IsFinished();
afx_msg short BytesReady();
//}}AFX_DISPATCH
DECLARE_DISPATCH_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// Miscellaneous Functions
extern "C" {
NET_StreamClass *nfe_OleStream(int iFormatOut, void *pDataObj, URL_Struct *pUrlData, MWContext *pContext);
int nfe_StreamWrite(NET_StreamClass *stream, const char *pWriteData, int32 lLength);
void nfe_StreamComplete(NET_StreamClass *stream);
void nfe_StreamAbort(NET_StreamClass *stream, int iStatus);
unsigned int nfe_StreamReady(NET_StreamClass *stream);
};
// Max amount of data to store in each CNetBuffer.
#define NETBUFSIZE (30 * 1024)
// Structure to store read data.
struct CNetBuffer {
int m_iHead;
int m_iSize;
char *m_pData;
CNetBuffer(int iSize) {
ASSERT(iSize);
m_iHead = 0;
m_iSize = iSize;
m_pData = new char[iSize];
}
~CNetBuffer() {
if(m_pData) {
delete m_pData;
}
}
};
/////////////////////////////////////////////////////////////////////////////

1573
mozilla/cmd/winfe/cxpane.cpp Normal file

File diff suppressed because it is too large Load Diff

264
mozilla/cmd/winfe/cxpane.h Normal file
View File

@@ -0,0 +1,264 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __HTML_PANE_CONTEXT_H
#define __HTML_PANE_CONTEXT_H
// What is CPaneCX?
// A pane is part of a complete window.
//
// There is no relation from a pane to the chrome of a full window.
// There is no frame, no document, no view, no toolbar, etc.
// No assumptions should be made, or the pane becomes non-reusable in a
// window that is yet to be invented.
//
// A pane can be put many places:
// In a dialog.
// In a navigation tool.
// In a browser.
// It is up to the place to provide the chrome. It is up to the pane to
// provide the HTML.
#include "cxdc.h"
#include "drawable.h"
#define VSCROLL_LINE 32
#define HSCROLL_LINE 32
#define SCROLL_UNITS 10000
#define RIGHT_MARGIN (-1 * Pix2TwipsX(8))
#define LEFT_MARGIN (Pix2TwipsX(8))
#define TOP_MARGIN (Pix2TwipsY(8))
#define BOTTOM_MARGIN (-1 * Pix2TwipsY(8))
struct PaneMessage {
PaneMessage(WPARAM wSet, LPARAM lSet)
{
wParam = wSet;
lParam = lSet;
bSetRetval = FALSE;
lRetval = NULL;
}
WPARAM wParam;
LPARAM lParam;
BOOL bSetRetval;
LPARAM lRetval;
};
class CPaneCX : public CDCCX {
public:
CPaneCX(HWND hPane, BOOL bDestroyOnWMDestroy);
~CPaneCX();
virtual void DestroyContext();
virtual void Initialize(BOOL bOwnDC, RECT *pRect = NULL, BOOL bInitialPalette = TRUE, BOOL bNewMemDC = TRUE);
private:
HWND m_hPane;
BOOL m_bDestroyOnWMDestroy;
private:
BOOL SubClass(HWND hWnd, BOOL bSubClass);
void CacheDCInfo(BOOL bCache);
public:
HWND GetPane() const;
HWND SetPane(HWND hPane);
public:
BOOL IsNavCenterHTMLPane() const;
private:
WNDPROC m_pPrevProc;
private:
WNDPROC GetSubclassedProc();
friend LRESULT CALLBACK
#ifndef _WIN32
_export
#endif
PaneProc(HWND hPane, UINT uMsg, WPARAM wParam, LPARAM lParam);
protected:
void PreWMPaint(PaneMessage *pMsg);
#ifdef EDITOR
virtual
#endif
void PreWMErasebkgnd(PaneMessage *pMsg);
void PreWMVScroll(PaneMessage *pMsg);
void PreWMHScroll(PaneMessage *pMsg);
void PreNavCenterQueryPosition(PaneMessage *pMsg);
void PreIdleUpdateCmdUI(PaneMessage *pMsg);
#if defined(XP_WIN32) && _MSC_VER >= 1100
void PreWMMouseWheel(PaneMessage *pMsg);
void PreWMHackedMouseWheel(PaneMessage *pMsg);
#endif
protected:
virtual void AftWMSize(PaneMessage *pMsg);
void AftWMDestroy(PaneMessage *pMsg);
void AftWMMouseActivate(PaneMessage *pMsg);
private:
HDC m_hClassDC;
HDC m_hOwnDC;
HDC m_hSubstDC;
public:
void RefreshArea(int32 lLeft, int32 lTop, uint32 lWidth, uint32 lHeight);
virtual HDC GetContextDC();
virtual void ReleaseContextDC(HDC hDC);
virtual BOOL IsOwnDC() const;
virtual BOOL IsClassDC() const;
HDC SubstituteDC(HDC hDC);
private:
CDrawable *m_pDrawable;
COffscreenDrawable *m_pOffscreenDrawable;
COnscreenDrawable *m_pOnscreenDrawable;
public:
CDrawable *GetDrawable();
virtual void SetDrawable(MWContext *pContext, CL_Drawable *pDrawable);
virtual void GetDrawingOrigin(int32 *plOrgX, int32 *plOrgY);
virtual FE_Region GetDrawingClip();
public:
void *m_pResizeReloadTimeout;
protected:
void NiceResizeReload(void);
private:
int32 m_nPageY;
int32 m_nPageX;
BOOL m_bVScrollBarOn;
BOOL m_bHScrollBarOn;
BOOL m_bDynamicScrollBars;
BOOL m_bAlwaysShowScrollBars;
#ifdef XP_WIN32
int m_iWheelDelta;
#endif
public:
void ShowScrollBars(int iBars, BOOL bShow);
BOOL IsVScrollBarOn();
BOOL IsHScrollBarOn();
BOOL DynamicScrollBars();
BOOL AlwaysShowScrollBars();
int32 GetPageY();
int32 GetPageX();
void SetAlwaysShowScrollBars(BOOL bSet);
void SetDynamicScrollBars(BOOL bSet);
void RealizeScrollBars(int32 *pX = NULL, int32 *pY = NULL);
#ifdef EDITOR
virtual
#endif
void Scroll(int iBars, UINT uSBCode, UINT uPos, HWND hCtrl, UINT uTimes = 1);
void MakeElementVisible(int32 lX, int32 lY);
#ifdef XP_WIN16
// 16-bit forms need their own segment.
private:
HGLOBAL m_hTextElementSegment;
LPVOID m_lpTextElementHeap;
public:
HINSTANCE GetSegment();
#endif
// Marginal implementation.
protected:
int32 m_lLeftMargin;
int32 m_lRightMargin;
int32 m_lTopMargin;
int32 m_lBottomMargin;
// Coordinate resolution.
public:
void ResolvePoint(XY& xy, POINT& point);
virtual void GetWindowOffset(int32 *pX, int32 *pY);
LO_Element *GetLayoutElement(XY& Point, CL_Layer *layer) const;
public:
virtual int GetUrl(URL_Struct *pUrl, FO_Present_Types iFormatOut, BOOL bReallyLoad = TRUE, BOOL bForceNew = FALSE);
public:
virtual void LayoutNewDocument(MWContext *pContext, URL_Struct *pURL, int32 *pWidth, int32 *pHeight, int32 *pmWidth, int32 *pmHeight);
virtual void FinishedLayout(MWContext *pContext);
virtual void SetDocDimension(MWContext *pContext, int iLocation, int32 lWidth, int32 lLength);
virtual void DisplayBuiltin(MWContext *pContext, int iLocation, LO_BuiltinStruct *pBuiltin);
virtual void FreeBuiltinElement(MWContext *pContext, LO_BuiltinStruct *pBuiltin);
};
inline HWND CPaneCX::GetPane() const
{
return(m_hPane);
}
inline WNDPROC CPaneCX::GetSubclassedProc()
{
return(m_pPrevProc);
}
inline CDrawable *CPaneCX::GetDrawable()
{
return(m_pDrawable);
}
inline BOOL CPaneCX::IsVScrollBarOn()
{
return(m_bVScrollBarOn);
}
inline BOOL CPaneCX::IsHScrollBarOn()
{
return(m_bHScrollBarOn);
}
inline BOOL CPaneCX::DynamicScrollBars()
{
return(m_bDynamicScrollBars);
}
inline BOOL CPaneCX::AlwaysShowScrollBars()
{
return(m_bAlwaysShowScrollBars);
}
inline int32 CPaneCX::GetPageY()
{
return(m_nPageY);
}
inline int32 CPaneCX::GetPageX()
{
return(m_nPageX);
}
inline void CPaneCX::SetAlwaysShowScrollBars(BOOL bSet)
{
m_bAlwaysShowScrollBars = bSet;
}
inline void CPaneCX::SetDynamicScrollBars(BOOL bSet)
{
m_bDynamicScrollBars = bSet;
}
inline void CPaneCX::ResolvePoint(XY& xy, POINT& point)
{
xy.x = Pix2TwipsX(point.x) + GetOriginX();
xy.y = Pix2TwipsY(point.y) + GetOriginY();
}
inline LO_Element *CPaneCX::GetLayoutElement(XY& Point, CL_Layer *layer) const
{
#ifdef MOZ_NGLAYOUT
XP_ASSERT(0);
return NULL;
#else
return(LO_XYToElement(GetContext(), Point.x, Point.y, layer));
#endif
}
inline BOOL CPaneCX::IsNavCenterHTMLPane() const
{
BOOL bRetval = FALSE;
MWContext *pContext = GetContext();
if(pContext && MWContextPane == pContext->type && Pane == GetContextType()) {
bRetval = TRUE;
}
return(bRetval);
}
#endif // __HTML_PANE_CONTEXT_H

File diff suppressed because it is too large Load Diff

302
mozilla/cmd/winfe/cxprint.h Normal file
View File

@@ -0,0 +1,302 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __PrintContext_H
// Avoid include redundancy
//
#define __PrintContext_H
// Purpose: Provide a context specifically for printing
// Comments:
// Required Includes
//
#include "cxdc.h"
#include "cxprndlg.h"
#include "drawable.h"
// Constants
//
#define POS_CENTER 1
#define POS_LEFT 2
#define POS_RIGHT 3
#define POS_HEADER 1
#define POS_FOOTER 2
typedef enum {
BLOCK_DISPLAY,
CAPTURE_POSITION,
DISPLAY
} PrinterDisplayMode;
// Structures
//
class CPrintCX : public CDCCX {
// Construction, destruction, indirect construction
public:
CPrintCX(URL_Struct *pUrl, SHIST_SavedData *pSavedData = NULL, char *pDisplayUrl = NULL);
~CPrintCX();
virtual void DestroyContext();
static void PrintAnchorObject(URL_Struct *pUrl, CView *pView,
SHIST_SavedData *pSavedData = NULL, char *pDisplayUrl = NULL);
static void PreviewAnchorObject(CPrintCX *& pPreview, URL_Struct *pUrl, CView *pView, CDC* pDC,
CPrintInfo *pInfo, SHIST_SavedData *pSavedData = NULL, char *pDisplayUrl = NULL);
static void AutomatedPrint(const char *pDocument, const char *pPrinter, const char *pDriver, const char *pPort);
// The anchor we're printing.
protected:
char *m_pAnchor;
// The actual anchor name to use for Header/Footer
// (In Composer: we may be printing from a temporary local file)
char *m_pDisplayUrl;
HFONT m_hFont;
int m_iFontCSID;
int m_iMaxWidth;
int m_offscrnWidth;
int m_offscrnHeight;
// CDC Access
private:
HDC m_hdcPrint;
#ifdef XP_WIN32
HDC m_hOffscrnDC;
HDC m_hOrgPrintDC;
HDC m_hOtherPrintDC;
HBITMAP m_hOffScrnBitmap;
HBITMAP m_saveBitmap;
BOOL m_printBk;
void SubOffscreenPrintDC() {m_hOrgPrintDC = m_hdcPrint; m_hdcPrint = m_hOffscrnDC;}
void RestorePrintDC() { m_hdcPrint = m_hOrgPrintDC;}
#endif
CDC *m_previewDC;
lo_SavedEmbedListData* m_embedList; /* to save the savedData from the URL struct.*/
public:
virtual HDC GetContextDC(){
if(IsPrintPreview())
return m_previewDC->GetSafeHdc();
else
return m_hdcPrint;
}
virtual BOOL IsDeviceDC();
#ifdef XP_WIN32
BOOL IsPrintingBackground() {return m_printBk;}
#endif
virtual HDC GetAttribDC();
virtual void ReleaseContextDC(HDC pDC);
// Post Initialization
public:
virtual void Initialize(BOOL bOwnDC, RECT *pRect = NULL, BOOL bInitialPalette = TRUE, BOOL bNewMemDC = TRUE);
private:
// Margins
int32 m_lLeftMargin;
int32 m_lTopMargin;
int32 m_lRightMargin;
int32 m_lBottomMargin;
// True page dimensions
int32 m_lPageHeight;
int32 m_lPageWidth;
// Document dimensions
int32 m_lDocWidth;
int32 m_lDocHeight;
// Color contingencies
BOOL m_bBlackText; // All text as black?
BOOL m_bBlackLines; // All line drawing as black?
// Drawing contingencies
BOOL m_bSolidLines; // All lines are solid?
BOOL m_bBackground; // Should we draw the backgrounds?
BOOL m_bBitmaps; // Should we print bitmaps?
BOOL m_bReverseOrder; // Print in reverse order?
// Headers/footers
BOOL m_bNumber; // Number the pages?
BOOL m_bTitle; // Give each page the appropriate title?
CPrinterDrawable *m_pDrawable; // Drawable that represents the printer
// Print status dialog, also the parent of any dialogs we present!
private:
CPrintStatusDialog *m_pStatusDialog;
// the real meat of the print process
public:
#ifdef XP_WIN32
HDC GetOffscreenDC() {return m_hOffscrnDC;}
virtual int GetLeftMargin()
{ if (m_printBk && m_hdcPrint == m_hOffscrnDC)
return 0;
else return m_lLeftMargin;
}
virtual int GetTopMargin()
{ if (m_printBk && m_hdcPrint == m_hOffscrnDC)
return 0;
else return m_lTopMargin;
}
int32 GetXConvertUnit()
{
if (m_printBk && (m_hdcPrint == m_hOffscrnDC)) return 1;
else return m_lConvertX;
}
int32 GetYConvertUnit()
{
if (m_printBk && (m_hdcPrint == m_hOffscrnDC)) return 1;
else return m_lConvertY;
}
#endif
void PrintPage(int iPage, HDC pNewDC = NULL, CPrintInfo *pNewInfo = NULL);
private:
void CommencePrinting(URL_Struct *pUrl);
void FormatPages();
void CapturePositions();
void Capture(int32 lOrgX, int32 lOrgY, int32 lWidth, int32 lHeight);
CPtrList m_cplCaptured;
CPtrList m_cplPages;
int32 m_lCaptureScrollOffset;
void CreateHeaderFooterFont();
// Useful information.
private:
int m_iLastPagePrinted;
public:
int PageCount();
int LastPagePrinted();
private:
PrinterDisplayMode m_iDisplayMode;
public:
static BOOL m_bGlobalBlockDisplay;
PrinterDisplayMode GetDisplayMode();
// Output overrides.
public:
virtual void DisplayIcon(int32 x, int32 y, int icon_number);
BOOL AdjustRect(LTRB& Rect);
virtual BOOL ResolveElement(LTRB& Rect, int32 x, int32 y, int32 x_offset, int32 y_offset,
int32 width, int32 height);
virtual BOOL ResolveElement(LTRB& Rect, NI_Pixmap *pImage, int32 lX, int32 lY,
int32 orgx, int32 orgy,
uint32 ulWidth, uint32 ulHeight,
int32 lScaleWidth, int32 lScaleHeight);
virtual BOOL ResolveElement(LTRB& Rect, LO_EmbedStruct *pEmbed, int iLocation, Bool bWindowed);
virtual BOOL ResolveElement(LTRB& Rect, LO_FormElementStruct *pFormElement);
virtual COLORREF ResolveTextColor(LO_TextAttr *pAttr);
virtual COLORREF ResolveBGColor(unsigned uRed, unsigned uGreen, unsigned uBlue);
virtual BOOL ResolveHRSolid(LO_HorizRuleStruct *pHorizRule);
virtual BOOL ResolveLineSolid();
virtual void ResolveTransparentColor(unsigned uRed, unsigned uGreen, unsigned uBlue);
virtual COLORREF ResolveDarkLineColor();
virtual COLORREF ResolveLightLineColor();
virtual COLORREF ResolveBorderColor(LO_TextAttr *pAttr);
virtual PRBool ResolveIncrementalImages();
virtual void SetDocDimension(MWContext *pContext, int iLocation, int32 lWidth, int32 lHeight);
virtual void GetDrawingOrigin(int32 *plOrgX, int32 *plOrgY);
virtual FE_Region GetDrawingClip();
virtual void EraseBackground(MWContext *pContext, int iLocation,
int32 x, int32 y, uint32 width, uint32 height,
LO_Color *pColor);
// Members needed to properly implement printing.
protected:
CPrintInfo *m_pcpiPrintJob;
DOCINFO m_docInfo;
// document charset id
public:
int m_iCSID;
void* p_TimeOut;
// Members need to properly implement print preview.
protected:
CView *m_pPreviewView;
BOOL m_bPreview;
public:
BOOL IsPrintPreview() const {
return(m_bPreview);
}
// Overrides
public:
// Dialog owner
virtual CWnd *GetDialogOwner() const;
// Progress messages.
virtual void Progress(MWContext *pContext, const char *pMessage);
// All connections complete.
virtual void AllConnectionsComplete(MWContext *pContext);
virtual void FinishedLayout(MWContext *pContext);
// Display routines
virtual void DisplayBullet(MWContext *pContext, int iLocation, LO_BullettStruct *pBullet);
#ifndef MOZ_NGLAYOUT
virtual void DisplayEmbed(MWContext *pContext, int iLocation, LO_EmbedStruct *pEmbed);
virtual void DisplayFormElement(MWContext *pContext, int iLocation, LO_FormElementStruct *pFormElement);
#endif
virtual void DisplayHR(MWContext *pContext, int iLocation, LO_HorizRuleStruct *pHorizRule);
virtual int DisplayPixmap(NI_Pixmap* image, NI_Pixmap* mask, int32 x, int32 y, int32 x_offset, int32 y_offset, int32 width, int32 height, int32 lScaleWidth, int32 lScaleHeight, LTRB& Rect);
virtual void DisplayLineFeed(MWContext *pContext, int iLocation, LO_LinefeedStruct *pLineFeed, XP_Bool clear);
virtual void DisplaySubDoc(MWContext *pContext, int iLocation, LO_SubDocStruct *pSubDoc);
virtual void DisplayCell(MWContext *pContext, int iLocation, LO_CellStruct *pCell);
virtual void DisplaySubtext(MWContext *pContext, int iLocation, LO_TextStruct *pText, int32 lStartPos, int32 lEndPos, XP_Bool clear);
virtual void DisplayTable(MWContext *pContext, int iLocation, LO_TableStruct *pTable);
virtual void DisplayText(MWContext *pContext, int iLocation, LO_TextStruct *pText, XP_Bool clear);
virtual void DisplayPlugin(MWContext *pContext, LO_EmbedStruct *pEmbed, NPEmbeddedApp* pEmbeddedApp, int iLocation);
virtual void DisplayWindowlessPlugin(MWContext *pContext, LO_EmbedStruct *pEmbed, NPEmbeddedApp *pEmbeddedApp, int iLocation);
#ifdef XP_WIN32
void CopyOffscreenBitmap(NI_Pixmap* image, int32 x, int32 y, int32 x_offset, int32 y_offset, int32 width, int32 height, int32 lScaleWidth, int32 lScaleHeight, LTRB& Rect);
#endif
// Layout initialization respecting page size.
virtual void LayoutNewDocument(MWContext *pContext, URL_Struct *pURL, int32 *pWidth, int32 *pHeight, int32 *pmWidth, int32 *pmHeight);
virtual void GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext);
// Call this to cancel the print job.
public:
void CancelPrintJob();
private:
BOOL m_bCancel;
// this is to prevent the destroycontext get call twice.
BOOL m_bHandleCancel;
// These determine wether or not we need to continue to attempt to start the
// document, and how we end the printing of the document.
// Doesn't apply to preview.
private:
BOOL m_bAbort;
BOOL m_bNeedStartDoc;
BOOL m_bAllConnectionCompleteCalled;
BOOL m_bFormatStarted;
BOOL m_bFinishedLayoutCalled;
SIZE screenRes;
SIZE printRes;
int StartDoc();
void PrintTextAllign ( HDC pDC, char * szBuffer, int position, int hpos );
void ScreenToPrint(POINT* point, int num = 1);
void FormatAndPrintPages(MWContext *context);
};
#endif // __PrintContext_H

View File

@@ -0,0 +1,126 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "stdafx.h"
#include "cxprndlg.h"
#include "cxprint.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPrintStatusDialog dialog
CPrintStatusDialog::CPrintStatusDialog(CWnd* pParent, CPrintCX *pCX)
: CDialog(CPrintStatusDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CPrintStatusDialog)
m_csLocation = _T("");
m_csProgress = _T("");
//}}AFX_DATA_INIT
// Save the context which owns us.
m_pCX = pCX;
}
void CPrintStatusDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrintStatusDialog)
DDX_Text(pDX, IDC_LOCATION, m_csLocation);
DDX_Text(pDX, IDC_PROGRESS, m_csProgress);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPrintStatusDialog, CDialog)
//{{AFX_MSG_MAP(CPrintStatusDialog)
ON_WM_PAINT()
ON_WM_SIZE()
ON_WM_QUERYDRAGICON()
ON_WM_SYSCOMMAND()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrintStatusDialog message handlers
void CPrintStatusDialog::OnCancel()
{
// Let the owning context know that the cancel button has been
// hit.
TRACE("Received request to cancel print job.\n");
m_pCX->CancelPrintJob();
// Don't call their on canel, or it blows away the dialog.
//CDialog::OnCancel();
}
BOOL CPrintStatusDialog::OnEraseBkgnd(CDC *pDC) {
if(IsIconic() == TRUE) {
return(TRUE);
}
return(CDialog::OnEraseBkgnd(pDC));
}
void CPrintStatusDialog::OnSysCommand(UINT nID, LPARAM lParam) {
// Don't maximize ourselves
if(nID == SC_MAXIMIZE) {
return;
}
CDialog::OnSysCommand(nID, lParam);
}
void CPrintStatusDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
// Check to see if we need to draw our icon.
if(IsIconic() != FALSE) {
HICON hIcon = theApp.LoadIcon(IDR_MAINFRAME);
ASSERT(hIcon);
dc.DrawIcon(2, 2, hIcon);
}
// Do not call CDialog::OnPaint() for painting messages
}
void CPrintStatusDialog::OnSize(UINT nType, int cx, int cy)
{
// Change any maximize request to a normal request.
if(nType == SIZE_MAXIMIZED) {
nType = SIZE_RESTORED;
}
CDialog::OnSize(nType, cx, cy);
}
HCURSOR CPrintStatusDialog::OnQueryDragIcon() {
// Return the icon that will show up when dragged.
HICON hIcon = theApp.LoadIcon(IDR_MAINFRAME);
ASSERT(hIcon);
return((HCURSOR)hIcon);
}

View File

@@ -0,0 +1,70 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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 __ContextPrintDialog_H
#define __ContextPrintDialog_H
// cxprndlg.h : header file
//
class CPrintCX;
/////////////////////////////////////////////////////////////////////////////
// CPrintStatusDialog dialog
class CPrintStatusDialog : public CDialog
{
// Construction
public:
CPrintStatusDialog(CWnd* pParent, CPrintCX *pCX);
BOOL Create(UINT id, CWnd * pParent) { return(CDialog::Create(id, pParent)); }
private:
// The context owning us.
CPrintCX *m_pCX;
public:
// Dialog Data
//{{AFX_DATA(CPrintStatusDialog)
enum { IDD = IDD_CONTEXT_PRINT_STATUS };
CString m_csLocation;
CString m_csProgress;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPrintStatusDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CPrintStatusDialog)
virtual void OnCancel();
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif // __ContextPrintDialog_H

1613
mozilla/cmd/winfe/cxsave.cpp Normal file

File diff suppressed because it is too large Load Diff

216
mozilla/cmd/winfe/cxsave.h Normal file
View File

@@ -0,0 +1,216 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.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.
*/
// cxsave.h : header file
//
#include "cxstubs.h"
#include "widgetry.h"
/////////////////////////////////////////////////////////////////////////////
// CSaveCX dialog
class CSaveCX : public CDialog, public CStubsCX
{
// Construction
private:
char* GetMailNewsTempFileName(char* pTempPath, char *pFileName = NULL);
BOOL CanCreate(URL_Struct * pUrl = NULL); // Can we proceed with creation? Used by SaveObject.
BOOL Creator();
public:
CSaveCX(const char *pAnchor, const char *pViewer = NULL, CWnd *pParent = NULL); // For external viewing or saving
~CSaveCX();
// Indirect Construction
private:
void DoCreate() {
// Set dimensions of progress
m_crBounds = CRect(5, 50, 5 + 175, 50 + 15);
MapDialogRect(m_crBounds);
m_crBounds.InflateRect(-1, -1); // Shrink for border.
}
// Helper function to figure out correct file extension
#ifdef MOZ_MAIL_NEWS
void AddFileExtension(char *& pFileName);
#endif
public:
static BOOL SaveAnchorObject(const char *pAnchor, History_entry *pHist, int16 iCSID = 0, CWnd *pParent = NULL, char * pFileName = NULL);
static BOOL SaveAnchorAsText(const char *pAnchor, History_entry *pHist, CWnd *pParent, char *pFileName);
static NET_StreamClass *SaveUrlObject(URL_Struct *pUrl, CWnd *pParent = NULL, char * pFileName = NULL);
static NET_StreamClass *ViewUrlObject(URL_Struct *pUrl, const char *pViewer, CWnd *pParent = NULL);
static NET_StreamClass *OleStreamObject(NET_StreamClass *pOleStream, URL_Struct *pUrl, const char *pViewer, CWnd *pParent = NULL);
static BOOL SaveToGlobal(HGLOBAL *phGlobal, LPCSTR lpszUrl, LPCSTR lpszTitle); // Returns context id
#ifdef MOZ_MAIL_NEWS
static BOOL SaveToFile(CFile *pFile, LPCSTR lpszUrl, LPCSTR lpszTitle);
#endif
// What we're saving
private:
CProgressMeter m_ProgressMeter;
History_entry * m_pHist;
CString m_csAnchor; // The anchor to load
CString m_csViewer; // The viewer to spawn, if specified, file will be removed on exit and
// the user is not prompted for a file name in which to save.
int m_iFileType; // The format of the file (needed for text front end when saving basically....)
CString m_csFileName; // The file to save it in
CWnd *m_pParent; // Our parent (need for possible file dialogs).
NET_StreamClass *m_pSecondaryStream; // A secondary stream, sometimes we chain together streams.
long tFirstTime;
long tLastTime;
long tLastBarTime;
int iLastPercent;
// Wether or not we were interrupted (cleanup even more).
public:
URL_Struct *m_pUrl; // The URL_Struct as known by the netlib
BOOL m_bInterrupted;
BOOL m_bAborted;
BOOL m_bSavingToGlobal;
int16 m_iCSID; //WinCX pass default character set information here
// A way to manually set the URL we're handling without having
// the dialog create one.
// Also a way to manually set the secondary stream for the URL that
// we're handling.
public:
void SetUrl(URL_Struct *pUrl) {
ASSERT(m_pUrl == NULL);
m_pUrl = pUrl;
}
void SetSecondaryStream(NET_StreamClass *pSecondaryStream) {
ASSERT(m_pSecondaryStream == NULL);
ASSERT(m_pSink == NULL); // Secondary streams require no sink.
ASSERT(!m_csViewer.IsEmpty() || m_bSavingToGlobal);
pSecondaryStream->window_id = GetContext();
m_pSecondaryStream = pSecondaryStream;
}
NET_StreamClass *GetSecondaryStream() const {
return(m_pSecondaryStream);
}
void ClearSecondary() {
m_pSecondaryStream = NULL;
}
// Informational
public:
BOOL IsSaving() const {
return(m_csViewer.IsEmpty());
}
BOOL IsViewing() const {
return(IsSaving() == FALSE ? TRUE : FALSE);
}
BOOL IsShellExecute() const {
return(m_csViewer == "ShellExecute");
}
BOOL IsSavingToGlobal() const {
return m_bSavingToGlobal;
}
CString GetFileName() const {
return(m_csFileName);
}
CString GetAnchor() const {
return(m_csAnchor);
}
CString GetViewer() const;
// For dialogs
public:
virtual CWnd *GetDialogOwner() const;
// Serialization information
private:
CStdioFile *m_pSink;
public:
void SetSink(CStdioFile *pSink) {
ASSERT(m_pSecondaryStream == NULL); // Sinks require no secondary stream.
m_pSink = pSink;
}
CStdioFile *GetSink() const {
return(m_pSink);
}
void ClearSink() {
m_pSink = NULL;
}
// Progress Information, manipulated by GraphProgress
private:
void Progress(int32 lPercent); // Draw progress bar
int32 m_lOldPercent; // Old percentage to optimize drawing in OnPaint.
CRect m_crBounds; // Bounds of dialog progress bar.
// Context Overrides
public:
// The URL exit routine.
virtual void GetUrlExitRoutine(URL_Struct *pUrl, int iStatus, MWContext *pContext);
// The text translation exit routine.
virtual void TextTranslationExitRoutine(PrintSetup *pTextFE);
// All Connections are done.
virtual void AllConnectionsComplete(MWContext *pContext);
// Textual progress information.
virtual void Progress(MWContext *pContext, const char *pMessage);
// Progress bar function.
virtual void SetProgressBarPercent(MWContext *pContext, int32 lPercent);
// Graph progression.
virtual void GraphProgress(MWContext *pContext, URL_Struct *pURL, int32 lBytesReceived, int32 lBytesSinceLastTime, int32 lContentLength);
// Dialog Data
//{{AFX_DATA(CSaveCX)
enum { IDD = IDD_CONTEXT_SAVE };
CString m_csAction;
CString m_csDestination;
CString m_csLocation;
CString m_csProgress;
CString m_csTimeLeft;
CString m_csPercentComplete;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSaveCX)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CSaveCX)
virtual void OnCancel();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
extern "C" {
// Netlib API to the stream that will save the file to disk.
NET_StreamClass *ContextSaveStream(int iFormatOut, void *pDataObj, URL_Struct *pUrl, MWContext *pContext);
unsigned int ContextSaveReady(NET_StreamClass *stream);
int ContextSaveWrite(NET_StreamClass *stream, const char *pWriteData, int32 iDataLength);
void ContextSaveComplete(NET_StreamClass *stream);
void ContextSaveAbort(NET_StreamClass *stream, int iStatus);
};

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