From 07bcfbdc9c8fca74f831dbe671b7425e31625c8b Mon Sep 17 00:00:00 2001 From: Krzysztof Foltman Date: Tue, 14 Feb 2006 14:48:29 +0100 Subject: [PATCH] programs: Add an implementation of Wordpad. --- configure | 3 +- configure.ac | 1 + programs/Makefile.in | 13 +- programs/wordpad/.gitignore | 4 + programs/wordpad/En.rc | 66 +++++ programs/wordpad/Makefile.in | 22 ++ programs/wordpad/resource.h | 54 ++++ programs/wordpad/rsrc.rc | 78 ++++++ programs/wordpad/wordpad.c | 514 +++++++++++++++++++++++++++++++++++ 9 files changed, 751 insertions(+), 4 deletions(-) create mode 100644 programs/wordpad/.gitignore create mode 100644 programs/wordpad/En.rc create mode 100644 programs/wordpad/Makefile.in create mode 100644 programs/wordpad/resource.h create mode 100644 programs/wordpad/rsrc.rc create mode 100644 programs/wordpad/wordpad.c diff --git a/configure b/configure index 80e58c51c15..97815d3580d 100755 --- a/configure +++ b/configure @@ -18850,7 +18850,7 @@ MAKE_LIB_RULES=libs/Makelib.rules MAKE_PROG_RULES=programs/Makeprog.rules - ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Makeimplib.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/activeds/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/advpack/tests/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/cabinet/tests/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/crypt32/tests/Makefile dlls/cryptdll/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3d9/tests/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput/tests/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mciavi32/Makefile dlls/mcicda/Makefile dlls/mciseq/Makefile dlls/midimap/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/tests/Makefile dlls/msacm/winemp3/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/mshtml/tests/Makefile dlls/msi/Makefile dlls/msi/tests/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/msxml3/Makefile dlls/msxml3/tests/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/objsel/Makefile dlls/odbc32/Makefile dlls/odbccp32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/powrprof/Makefile dlls/psapi/Makefile dlls/psapi/tests/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/riched20/Makefile dlls/riched20/tests/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/secur32/tests/Makefile dlls/security/Makefile dlls/sensapi/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/setupapi/tests/Makefile dlls/shdocvw/Makefile dlls/shdocvw/tests/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/stdole2.tlb/Makefile dlls/stdole32.tlb/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/usp10/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winecrt0/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/wineesd/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wldap32/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/wtsapi32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/eject/Makefile programs/expand/Makefile programs/explorer/Makefile programs/hh/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile" + ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Makeimplib.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/activeds/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/advpack/tests/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/cabinet/tests/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/crypt32/tests/Makefile dlls/cryptdll/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3d9/tests/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput/tests/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mciavi32/Makefile dlls/mcicda/Makefile dlls/mciseq/Makefile dlls/midimap/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/tests/Makefile dlls/msacm/winemp3/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/mshtml/tests/Makefile dlls/msi/Makefile dlls/msi/tests/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/msxml3/Makefile dlls/msxml3/tests/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/objsel/Makefile dlls/odbc32/Makefile dlls/odbccp32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/powrprof/Makefile dlls/psapi/Makefile dlls/psapi/tests/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/riched20/Makefile dlls/riched20/tests/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/secur32/tests/Makefile dlls/security/Makefile dlls/sensapi/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/setupapi/tests/Makefile dlls/shdocvw/Makefile dlls/shdocvw/tests/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/stdole2.tlb/Makefile dlls/stdole32.tlb/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/usp10/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winecrt0/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/wineesd/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wldap32/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/wtsapi32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/eject/Makefile programs/expand/Makefile programs/explorer/Makefile programs/hh/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile programs/wordpad/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile" cat >confcache <<\_ACEOF @@ -19651,6 +19651,7 @@ do "programs/winevdm/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/winevdm/Makefile" ;; "programs/winhelp/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/winhelp/Makefile" ;; "programs/winver/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/winver/Makefile" ;; + "programs/wordpad/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/wordpad/Makefile" ;; "server/Makefile" ) CONFIG_FILES="$CONFIG_FILES server/Makefile" ;; "tools/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;; "tools/widl/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/widl/Makefile" ;; diff --git a/configure.ac b/configure.ac index 7784f8ad287..de6e158d7b9 100644 --- a/configure.ac +++ b/configure.ac @@ -1697,6 +1697,7 @@ programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile +programs/wordpad/Makefile server/Makefile tools/Makefile tools/widl/Makefile diff --git a/programs/Makefile.in b/programs/Makefile.in index b3a4b636f28..87053c43664 100644 --- a/programs/Makefile.in +++ b/programs/Makefile.in @@ -38,7 +38,8 @@ SUBDIRS = \ winetest \ winevdm \ winhelp \ - winver + winver \ + wordpad # Sub-directories to run make install into INSTALLSUBDIRS = \ @@ -71,7 +72,8 @@ INSTALLSUBDIRS = \ winepath \ winevdm \ winhelp \ - winver + winver \ + wordpad # Programs to install in bin directory INSTALLPROGS = \ @@ -128,7 +130,8 @@ SYMLINKS = \ winetest.exe$(DLLEXT) \ winevdm.exe$(DLLEXT) \ winhelp.exe$(DLLEXT) \ - winver.exe$(DLLEXT) + winver.exe$(DLLEXT) \ + wordpad.exe$(DLLEXT) @MAKE_RULES@ @@ -278,6 +281,9 @@ winhelp.exe$(DLLEXT): winhelp/winhelp.exe$(DLLEXT) winver.exe$(DLLEXT): winver/winver.exe$(DLLEXT) $(RM) $@ && $(LN_S) winver/winver.exe$(DLLEXT) $@ +wordpad.exe$(DLLEXT): wordpad/wordpad.exe$(DLLEXT) + $(RM) $@ && $(LN_S) wordpad/wordpad.exe$(DLLEXT) $@ + avitools/aviinfo.exe$(DLLEXT): avitools avitools/aviplay.exe$(DLLEXT): avitools clock/clock.exe$(DLLEXT): clock @@ -313,5 +319,6 @@ winetest/winetest.exe$(DLLEXT): winetest winevdm/winevdm.exe$(DLLEXT): winevdm winhelp/winhelp.exe$(DLLEXT): winhelp winver/winver.exe$(DLLEXT): winver +wordpad/wordpad.exe$(DLLEXT): wordpad ### Dependencies: diff --git a/programs/wordpad/.gitignore b/programs/wordpad/.gitignore new file mode 100644 index 00000000000..5dd395151c7 --- /dev/null +++ b/programs/wordpad/.gitignore @@ -0,0 +1,4 @@ +Makefile +rsrc.res +toolbar.bmp +wordpad diff --git a/programs/wordpad/En.rc b/programs/wordpad/En.rc new file mode 100644 index 00000000000..cb89f8010b1 --- /dev/null +++ b/programs/wordpad/En.rc @@ -0,0 +1,66 @@ +/* + * Copyright 2004 by Krzysztof Foltman + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "resource.h" + +MAINMENU MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New", ID_FILE_NEW + MENUITEM "&Open", ID_FILE_OPEN + MENUITEM "&Save", ID_FILE_SAVE + MENUITEM SEPARATOR + MENUITEM "&Exit", ID_FILE_EXIT + END + POPUP "&Edit" + BEGIN + MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO + MENUITEM "&Redo\tCtrl+Y", ID_EDIT_REDO + MENUITEM "&Select all\tCtrl+A", ID_EDIT_SELECTALL + MENUITEM SEPARATOR + MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT + MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY + MENUITEM SEPARATOR + MENUITEM "Read-&only", ID_EDIT_READONLY + MENUITEM "&Modified", ID_EDIT_MODIFIED + MENUITEM SEPARATOR + POPUP "&Extras" + BEGIN + MENUITEM "Selection &info", ID_EDIT_SELECTIONINFO + MENUITEM "Character &format", ID_EDIT_CHARFORMAT + MENUITEM "&Def. char format", ID_EDIT_DEFCHARFORMAT + MENUITEM "Paragrap&h format", ID_EDIT_PARAFORMAT + MENUITEM "&Get text", ID_EDIT_GETTEXT + END + END + POPUP "F&ormat" + BEGIN + POPUP "&Background" + BEGIN + MENUITEM "&System\tCtrl+1", ID_BACK_1 + MENUITEM "&PostThat yellowish\tCtrl+2", ID_BACK_2 + END + POPUP "&Alignment" + BEGIN + MENUITEM "&Left\tCtrl+L", ID_ALIGN_LEFT + MENUITEM "&Center\tCtrl+E", ID_ALIGN_CENTER + MENUITEM "&Right\tCtrl+R", ID_ALIGN_RIGHT + END + END +END diff --git a/programs/wordpad/Makefile.in b/programs/wordpad/Makefile.in new file mode 100644 index 00000000000..291f36f8e1c --- /dev/null +++ b/programs/wordpad/Makefile.in @@ -0,0 +1,22 @@ +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +MODULE = wordpad.exe +APPMODE = -mwindows +IMPORTS = comdlg32 shell32 user32 gdi32 msvcrt advapi32 kernel32 comctl32 +EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt +EXTRADEFS = -DNO_LIBWINE_PORT +MODCFLAGS = @BUILTINFLAG@ + +C_SRCS = \ + wordpad.c + +RC_SRCS = rsrc.rc +RC_BINSRC = rsrc.rc +RC_BINARIES = \ + toolbar.bmp + +@MAKE_PROG_RULES@ + +### Dependencies: diff --git a/programs/wordpad/resource.h b/programs/wordpad/resource.h new file mode 100644 index 00000000000..15350f56e58 --- /dev/null +++ b/programs/wordpad/resource.h @@ -0,0 +1,54 @@ +/* + * Copyright 2004 by Krzysztof Foltman + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define ID_FILE_EXIT 1000 +#define ID_FILE_OPEN 1001 +#define ID_FILE_SAVE 1002 +#define ID_FILE_NEW 1003 + +#define ID_ALIGN_LEFT 1100 +#define ID_ALIGN_CENTER 1101 +#define ID_ALIGN_RIGHT 1102 + +#define ID_BACK_1 1200 +#define ID_BACK_2 1201 + +#define ID_EDIT_SELECTALL 1300 +#define ID_EDIT_SELECTIONINFO 1301 +#define ID_EDIT_READONLY 1302 +#define ID_EDIT_MODIFIED 1303 +#define ID_EDIT_CHARFORMAT 1304 +#define ID_EDIT_PARAFORMAT 1305 +#define ID_EDIT_DEFCHARFORMAT 1306 +#define ID_EDIT_UNDO 1307 +#define ID_EDIT_REDO 1308 +#define ID_EDIT_GETTEXT 1309 +#define ID_EDIT_COPY 1310 +#define ID_EDIT_CUT 1311 + +#define ID_FORMAT_BOLD 1400 +#define ID_FORMAT_ITALIC 1401 +#define ID_FORMAT_UNDERLINE 1402 + +#define IDC_STATUSBAR 2000 +#define IDC_EDITOR 2001 +#define IDC_TOOLBAR 2002 +#define IDC_REBAR 2003 +#define IDC_COMBO 2004 + +#define IDB_TOOLBAR 100 diff --git a/programs/wordpad/rsrc.rc b/programs/wordpad/rsrc.rc new file mode 100644 index 00000000000..2ba5627efeb --- /dev/null +++ b/programs/wordpad/rsrc.rc @@ -0,0 +1,78 @@ +/* + * Copyright 2004 by Krzysztof Foltman + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "resource.h" + +MAINACCELTABLE ACCELERATORS +BEGIN + "1", ID_BACK_1, VIRTKEY, CONTROL + "2", ID_BACK_2, VIRTKEY, CONTROL + "L", ID_ALIGN_LEFT, VIRTKEY, CONTROL + "E", ID_ALIGN_CENTER, VIRTKEY, CONTROL + "R", ID_ALIGN_RIGHT, VIRTKEY, CONTROL + "A", ID_EDIT_SELECTALL, VIRTKEY, CONTROL + "X", ID_EDIT_CUT, VIRTKEY, CONTROL + "C", ID_EDIT_COPY, VIRTKEY, CONTROL + "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL + "Y", ID_EDIT_REDO, VIRTKEY, CONTROL + "B", ID_FORMAT_BOLD, VIRTKEY, CONTROL + "I", ID_FORMAT_ITALIC, VIRTKEY, CONTROL + "U", ID_FORMAT_UNDERLINE,VIRTKEY, CONTROL + "N", ID_FILE_NEW, VIRTKEY, CONTROL + "O", ID_FILE_OPEN, VIRTKEY, CONTROL + "S", ID_FILE_SAVE, VIRTKEY, CONTROL +END + +/* BINRES toolbar.bmp */ +IDB_TOOLBAR BITMAP "toolbar.bmp" +/* { + '42 4D F6 01 00 00 00 00 00 00 76 00 00 00 28 00' + '00 00 30 00 00 00 10 00 00 00 01 00 04 00 00 00' + '00 00 80 01 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 80' + '00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80' + '00 00 80 80 80 00 C0 C0 C0 00 00 00 FF 00 00 FF' + '00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF' + '00 00 FF FF FF 00 88 88 88 88 88 88 88 88 88 88' + '88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88' + '88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88' + '00 00 00 00 88 88 88 88 88 88 88 88 88 88 88 88' + '88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 80' + '00 00 00 88 88 88 88 88 00 00 08 88 88 88 88 88' + '80 00 00 08 88 88 88 80 08 88 80 08 88 88 88 88' + '88 08 88 88 88 88 88 88 08 88 88 80 88 88 88 80' + '08 88 80 08 88 88 88 88 88 08 88 88 88 88 88 88' + '08 88 88 80 88 88 88 80 08 88 80 08 88 88 88 88' + '88 08 88 88 88 88 88 88 08 88 88 80 88 88 88 80' + '08 88 80 08 88 88 88 88 88 80 88 88 88 88 88 88' + '08 88 88 80 88 88 88 80 00 00 00 88 88 88 88 88' + '88 80 88 88 88 88 88 88 08 88 88 80 88 88 88 80' + '08 88 80 08 88 88 88 88 88 80 88 88 88 88 88 88' + '08 88 88 80 88 88 88 80 08 88 80 08 88 88 88 88' + '88 88 08 88 88 88 88 88 08 88 88 80 88 88 88 80' + '08 88 80 08 88 88 88 88 88 88 08 88 88 88 88 88' + '08 88 88 80 88 88 88 80 00 00 00 88 88 88 88 88' + '88 00 00 08 88 88 88 88 08 88 88 80 88 88 88 88' + '88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88' + '88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88' + '88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88' + '88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88' + '88 88 88 88 88 88' +} */ + +#include "En.rc" diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c new file mode 100644 index 00000000000..c32e28bb819 --- /dev/null +++ b/programs/wordpad/wordpad.c @@ -0,0 +1,514 @@ +/* + * Wordpad implementation + * + * Copyright 2004 by Krzysztof Foltman + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define WIN32_LEAN_AND_MEAN +#define _WIN32_IE 0x0400 + +#include +#include +#include +#include + +#include +#include +#include + +#include "resource.h" + + +/* use LoadString */ +static const WCHAR xszAppTitle[] = {'W','i','n','e',' ','W','o','r','d','p','a','d',0}; +static const WCHAR xszMainMenu[] = {'M','A','I','N','M','E','N','U',0}; + +static const WCHAR wszRichEditClass[] = {'R','I','C','H','E','D','I','T','2','0','W',0}; +static const WCHAR wszMainWndClass[] = {'W','O','R','D','P','A','D','T','O','P',0}; +static const WCHAR wszAppTitle[] = {'W','i','n','e',' ','W','o','r','d','p','a','d',0}; + +static HWND hMainWnd = NULL; + +void AddButton(HWND hwndToolBar, int nImage, int nCommand) +{ + TBBUTTON button; + + ZeroMemory(&button, sizeof(button)); + button.iBitmap = nImage; + button.idCommand = nCommand; + button.fsState = TBSTATE_ENABLED; + button.fsStyle = TBSTYLE_BUTTON; + button.dwData = 0; + button.iString = -1; + SendMessage(hwndToolBar, TB_ADDBUTTONS, 1, (LPARAM)&button); +} + +void AddSeparator(HWND hwndToolBar) +{ + TBBUTTON button; + + ZeroMemory(&button, sizeof(button)); + button.iBitmap = -1; + button.idCommand = 0; + button.fsState = 0; + button.fsStyle = TBSTYLE_SEP; + button.dwData = 0; + button.iString = -1; + SendMessage(hwndToolBar, TB_ADDBUTTONS, 1, (LPARAM)&button); +} + +static LRESULT OnCreate( HWND hWnd, WPARAM wParam, LPARAM lParam) +{ + HWND hEditorWnd, hToolBarWnd, hReBarWnd; + HINSTANCE hInstance = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); + HANDLE hDLL; + TBADDBITMAP ab; + int nStdBitmaps = 0; + REBARINFO rbi; + REBARBANDINFO rbb; + + CreateStatusWindow(CCS_NODIVIDER|WS_CHILD|WS_VISIBLE, "RichEdit text", hWnd, IDC_STATUSBAR); + + hReBarWnd = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, + CCS_NODIVIDER|WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|RBS_VARHEIGHT|CCS_TOP, + CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, hWnd, (HMENU)IDC_REBAR, hInstance, NULL); + + rbi.cbSize = sizeof(rbi); + rbi.fMask = 0; + rbi.himl = NULL; + if(!SendMessage(hReBarWnd, RB_SETBARINFO, 0, (LPARAM)&rbi)) + return -1; + + hToolBarWnd = CreateToolbarEx(hReBarWnd, CCS_NOPARENTALIGN|CCS_NODIVIDER|CCS_NOMOVEY|WS_VISIBLE|WS_CHILD|TBSTYLE_TOOLTIPS|TBSTYLE_FLAT, + IDC_TOOLBAR, + 3, hInstance, IDB_TOOLBAR, + NULL, 0, + 24, 24, 16, 16, sizeof(TBBUTTON)); + + ab.hInst = HINST_COMMCTRL; + ab.nID = IDB_STD_SMALL_COLOR; + nStdBitmaps = SendMessage(hToolBarWnd, TB_ADDBITMAP, 3, (LPARAM)&ab); + AddButton(hToolBarWnd, nStdBitmaps+STD_FILENEW, ID_FILE_NEW); + AddButton(hToolBarWnd, nStdBitmaps+STD_FILEOPEN, ID_FILE_OPEN); + AddButton(hToolBarWnd, nStdBitmaps+STD_FILESAVE, ID_FILE_SAVE); + AddSeparator(hToolBarWnd); + AddButton(hToolBarWnd, nStdBitmaps+STD_CUT, ID_EDIT_CUT); + AddButton(hToolBarWnd, nStdBitmaps+STD_COPY, ID_EDIT_COPY); + AddSeparator(hToolBarWnd); + AddButton(hToolBarWnd, nStdBitmaps+STD_UNDO, ID_EDIT_UNDO); + AddButton(hToolBarWnd, nStdBitmaps+STD_REDOW, ID_EDIT_REDO); + AddSeparator(hToolBarWnd); + AddButton(hToolBarWnd, 0, ID_FORMAT_BOLD); + AddButton(hToolBarWnd, 1, ID_FORMAT_ITALIC); + AddButton(hToolBarWnd, 2, ID_FORMAT_UNDERLINE); + + SendMessage(hToolBarWnd, TB_ADDSTRING, 0, (LPARAM)"Exit\0"); + SendMessage(hToolBarWnd, TB_AUTOSIZE, 0, 0); + + rbb.cbSize = sizeof(rbb); + rbb.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD | RBBIM_STYLE; + rbb.fStyle = RBBS_CHILDEDGE; + rbb.cx = 500; + rbb.hwndChild = hToolBarWnd; + rbb.cxMinChild = 0; + rbb.cyChild = rbb.cyMinChild = HIWORD(SendMessage(hToolBarWnd, TB_GETBUTTONSIZE, 0, 0)); + + SendMessage(hReBarWnd, RB_INSERTBAND, -1, (LPARAM)&rbb); + + hDLL = LoadLibrary("RICHED20.DLL"); + assert(hDLL); + + hEditorWnd = CreateWindowExW(WS_EX_CLIENTEDGE, wszRichEditClass, NULL, + WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOVSCROLL|ES_WANTRETURN, + 0, 0, 1000, 100, hWnd, (HMENU)IDC_EDITOR, hInstance, NULL); + if (!hEditorWnd) + { + fprintf(stderr, "Error code %lu\n", GetLastError()); + return -1; + } + assert(hEditorWnd); + + SetFocus(hEditorWnd); + SendMessage(hEditorWnd, EM_SETEVENTMASK, 0, ENM_SELCHANGE); + return 0; +} + +static LRESULT OnUser( HWND hWnd, WPARAM wParam, LPARAM lParam) +{ + HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR); + HWND hwndReBar = GetDlgItem(hWnd, IDC_REBAR); + HWND hwndToolBar = GetDlgItem(hwndReBar, IDC_TOOLBAR); + int from, to; + CHARFORMAT2W fmt; + + ZeroMemory(&fmt, sizeof(fmt)); + fmt.cbSize = sizeof(fmt); + + SendMessage(hwndEditor, EM_GETCHARFORMAT, TRUE, (LPARAM)&fmt); + + SendMessage(hwndEditor, EM_GETSEL, (WPARAM)&from, (LPARAM)&to); + SendMessage(hwndToolBar, TB_ENABLEBUTTON, ID_EDIT_UNDO, + SendMessage(hwndEditor, EM_CANUNDO, 0, 0)); + SendMessage(hwndToolBar, TB_ENABLEBUTTON, ID_EDIT_REDO, + SendMessage(hwndEditor, EM_CANREDO, 0, 0)); + SendMessage(hwndToolBar, TB_ENABLEBUTTON, ID_EDIT_CUT, from == to ? 0 : 1); + SendMessage(hwndToolBar, TB_ENABLEBUTTON, ID_EDIT_COPY, from == to ? 0 : 1); + SendMessage(hwndToolBar, TB_CHECKBUTTON, ID_FORMAT_BOLD, (fmt.dwMask & CFM_BOLD) && (fmt.dwEffects & CFE_BOLD)); + SendMessage(hwndToolBar, TB_INDETERMINATE, ID_FORMAT_BOLD, !(fmt.dwMask & CFM_BOLD)); + SendMessage(hwndToolBar, TB_CHECKBUTTON, ID_FORMAT_ITALIC, (fmt.dwMask & CFM_ITALIC) && (fmt.dwEffects & CFE_ITALIC)); + SendMessage(hwndToolBar, TB_INDETERMINATE, ID_FORMAT_ITALIC, !(fmt.dwMask & CFM_ITALIC)); + SendMessage(hwndToolBar, TB_CHECKBUTTON, ID_FORMAT_UNDERLINE, (fmt.dwMask & CFM_UNDERLINE) && (fmt.dwEffects & CFE_UNDERLINE)); + SendMessage(hwndToolBar, TB_INDETERMINATE, ID_FORMAT_UNDERLINE, !(fmt.dwMask & CFM_UNDERLINE)); + return 0; +} + +static LRESULT OnNotify( HWND hWnd, WPARAM wParam, LPARAM lParam) +{ + HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR); + NMHDR *pHdr = (NMHDR *)lParam; + + if (pHdr->hwndFrom != hwndEditor) + return 0; + + if (pHdr->code == EN_SELCHANGE) + { + SELCHANGE *pSC = (SELCHANGE *)lParam; + char buf[128]; + + sprintf( buf,"selection = %ld..%ld, line count=%ld\n", + pSC->chrg.cpMin, pSC->chrg.cpMax, + SendMessage(hwndEditor, EM_GETLINECOUNT, 0, 0)); + SetWindowText(GetDlgItem(hWnd, IDC_STATUSBAR), buf); + SendMessage(hWnd, WM_USER, 0, 0); + return 1; + } + return 0; +} + +static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) +{ + HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR); + + if ((HWND)lParam == hwndEditor) + return 0; + + switch(LOWORD(wParam)) + { + case ID_FILE_EXIT: + PostMessage(hWnd, WM_CLOSE, 0, 0); + break; + + case ID_FILE_NEW: + SetWindowTextA(hwndEditor, ""); + /* FIXME: set default format too */ + break; + + case ID_FILE_OPEN: + case ID_FILE_SAVE: + MessageBox(hWnd, "Open/Save not implemented", "WordPad", MB_OK); + break; + + case ID_FORMAT_BOLD: + case ID_FORMAT_ITALIC: + case ID_FORMAT_UNDERLINE: + { + CHARFORMAT2W fmt; + int mask = CFM_BOLD; + if (LOWORD(wParam) == ID_FORMAT_ITALIC) mask = CFM_ITALIC; + if (LOWORD(wParam) == ID_FORMAT_UNDERLINE) mask = CFM_UNDERLINE; + + ZeroMemory(&fmt, sizeof(fmt)); + fmt.cbSize = sizeof(fmt); + SendMessage(hwndEditor, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt); + if (!(fmt.dwMask&mask)) + fmt.dwEffects |= mask; + else + fmt.dwEffects ^= mask; + fmt.dwMask = mask; + SendMessage(hwndEditor, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt); + break; + } + + case ID_EDIT_CUT: + PostMessage(hwndEditor, WM_CUT, 0, 0); + break; + + case ID_EDIT_COPY: + PostMessage(hwndEditor, WM_COPY, 0, 0); + break; + + case ID_EDIT_SELECTALL: + { + CHARRANGE range = {0, -1}; + SendMessage(hwndEditor, EM_EXSETSEL, 0, (LPARAM)&range); + /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */ + return 0; + } + + case ID_EDIT_GETTEXT: + { + int nLen = GetWindowTextLengthW(hwndEditor); + LPWSTR data = HeapAlloc( GetProcessHeap(), 0, (nLen+1)*sizeof(WCHAR) ); + TEXTRANGEW tr; + + GetWindowTextW(hwndEditor, data, nLen+1); + MessageBoxW(NULL, data, xszAppTitle, MB_OK); + + HeapFree( GetProcessHeap(), 0, data); + data = HeapAlloc(GetProcessHeap(), 0, (nLen+1)*sizeof(WCHAR)); + tr.chrg.cpMin = 0; + tr.chrg.cpMax = nLen; + tr.lpstrText = data; + SendMessage (hwndEditor, EM_GETTEXTRANGE, 0, (LPARAM)&tr); + MessageBoxW(NULL, data, xszAppTitle, MB_OK); + HeapFree( GetProcessHeap(), 0, data ); + + /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */ + return 0; + } + + case ID_EDIT_CHARFORMAT: + case ID_EDIT_DEFCHARFORMAT: + { + CHARFORMAT2W cf; + LRESULT i; + ZeroMemory(&cf, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = 0; + i = SendMessage(hwndEditor, EM_GETCHARFORMAT, + LOWORD(wParam) == ID_EDIT_CHARFORMAT, (LPARAM)&cf); + return 0; + } + + case ID_EDIT_PARAFORMAT: + { + PARAFORMAT2 pf; + ZeroMemory(&pf, sizeof(pf)); + pf.cbSize = sizeof(pf); + SendMessage(hwndEditor, EM_GETPARAFORMAT, 0, (LPARAM)&pf); + return 0; + } + + case ID_EDIT_SELECTIONINFO: + { + CHARRANGE range = {0, -1}; + char buf[128]; + WCHAR *data = NULL; + + SendMessage(hwndEditor, EM_EXGETSEL, 0, (LPARAM)&range); + data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data) * (range.cpMax-range.cpMin+1)); + SendMessage(hwndEditor, EM_GETSELTEXT, 0, (LPARAM)data); + sprintf(buf, "Start = %ld, End = %ld", range.cpMin, range.cpMax); + MessageBoxA(hWnd, buf, "Editor", MB_OK); + MessageBoxW(hWnd, data, xszAppTitle, MB_OK); + HeapFree( GetProcessHeap(), 0, data); + /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */ + return 0; + } + + case ID_EDIT_READONLY: + { + long nStyle = GetWindowLong(hwndEditor, GWL_STYLE); + if (nStyle & ES_READONLY) + SendMessage(hwndEditor, EM_SETREADONLY, 0, 0); + else + SendMessage(hwndEditor, EM_SETREADONLY, 1, 0); + return 0; + } + + case ID_EDIT_MODIFIED: + if (SendMessage(hwndEditor, EM_GETMODIFY, 0, 0)) + SendMessage(hwndEditor, EM_SETMODIFY, 0, 0); + else + SendMessage(hwndEditor, EM_SETMODIFY, 1, 0); + return 0; + + case ID_EDIT_UNDO: + SendMessage(hwndEditor, EM_UNDO, 0, 0); + return 0; + + case ID_EDIT_REDO: + SendMessage(hwndEditor, EM_REDO, 0, 0); + return 0; + + case ID_ALIGN_LEFT: + case ID_ALIGN_CENTER: + case ID_ALIGN_RIGHT: + { + PARAFORMAT2 pf; + + pf.cbSize = sizeof(pf); + pf.dwMask = PFM_ALIGNMENT; + switch(LOWORD(wParam)) { + case ID_ALIGN_LEFT: pf.wAlignment = PFA_LEFT; break; + case ID_ALIGN_CENTER: pf.wAlignment = PFA_CENTER; break; + case ID_ALIGN_RIGHT: pf.wAlignment = PFA_RIGHT; break; + } + SendMessage(hwndEditor, EM_SETPARAFORMAT, 0, (LPARAM)&pf); + break; + } + + case ID_BACK_1: + SendMessage(hwndEditor, EM_SETBKGNDCOLOR, 1, 0); + break; + + case ID_BACK_2: + SendMessage(hwndEditor, EM_SETBKGNDCOLOR, 0, RGB(255,255,192)); + break; + + default: + SendMessage(hwndEditor, WM_COMMAND, wParam, lParam); + break; + } + return 0; +} + +static LRESULT OnInitPopupMenu( HWND hWnd, WPARAM wParam, LPARAM lParam ) +{ + HMENU hMenu = (HMENU)wParam; + HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR); + PARAFORMAT pf; + int nAlignment = -1; + + pf.cbSize = sizeof(PARAFORMAT); + SendMessage(hwndEditor, EM_GETPARAFORMAT, 0, (LPARAM)&pf); + CheckMenuItem(hMenu, ID_EDIT_READONLY, + MF_BYCOMMAND|(GetWindowLong(hwndEditor, GWL_STYLE)&ES_READONLY ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(hMenu, ID_EDIT_MODIFIED, + MF_BYCOMMAND|(SendMessage(hwndEditor, EM_GETMODIFY, 0, 0) ? MF_CHECKED : MF_UNCHECKED)); + if (pf.dwMask & PFM_ALIGNMENT) + nAlignment = pf.wAlignment; + CheckMenuItem(hMenu, ID_ALIGN_LEFT, MF_BYCOMMAND|(nAlignment == PFA_LEFT) ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(hMenu, ID_ALIGN_CENTER, MF_BYCOMMAND|(nAlignment == PFA_CENTER) ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(hMenu, ID_ALIGN_RIGHT, MF_BYCOMMAND|(nAlignment == PFA_RIGHT) ? MF_CHECKED : MF_UNCHECKED); + EnableMenuItem(hMenu, ID_EDIT_UNDO, MF_BYCOMMAND|(SendMessage(hwndEditor, EM_CANUNDO, 0, 0)) ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(hMenu, ID_EDIT_REDO, MF_BYCOMMAND|(SendMessage(hwndEditor, EM_CANREDO, 0, 0)) ? MF_ENABLED : MF_GRAYED); + return 0; +} + +static LRESULT OnSize( HWND hWnd, WPARAM wParam, LPARAM lParam ) +{ + int nStatusSize = 0, nTBSize = 0; + RECT rc; + HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR); + HWND hwndStatusBar = GetDlgItem(hWnd, IDC_STATUSBAR); + HWND hwndReBar = GetDlgItem(hWnd, IDC_REBAR); + HWND hwndToolBar = GetDlgItem(hwndReBar, IDC_TOOLBAR); + + if (hwndStatusBar) + { + SendMessage(hwndStatusBar, WM_SIZE, 0, 0); + GetClientRect(hwndStatusBar, &rc); + nStatusSize = rc.bottom - rc.top; + } + if (hwndToolBar) + { + rc.left = rc.top = 0; + rc.right = LOWORD(lParam); + rc.bottom = HIWORD(lParam); + SendMessage(hwndToolBar, TB_AUTOSIZE, 0, 0); + SendMessage(hwndReBar, RB_SIZETORECT, 0, (LPARAM)&rc); + nTBSize = SendMessage(hwndReBar, RB_GETBARHEIGHT, 0, 0); + GetClientRect(hwndReBar, &rc); + MoveWindow(hwndReBar, 0, 0, LOWORD(lParam), rc.right, FALSE); + } + if (hwndEditor) + { + GetClientRect(hWnd, &rc); + MoveWindow(hwndEditor, 0, nTBSize, rc.right, rc.bottom-nStatusSize-nTBSize, TRUE); + } + + return DefWindowProcW(hWnd, WM_SIZE, wParam, lParam); +} + +LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_CREATE: + return OnCreate( hWnd, wParam, lParam ); + + case WM_USER: + return OnUser( hWnd, wParam, lParam ); + + case WM_NOTIFY: + return OnNotify( hWnd, wParam, lParam ); + + case WM_COMMAND: + return OnCommand( hWnd, wParam, lParam ); + + case WM_DESTROY: + PostQuitMessage(0); + break; + + case WM_ACTIVATE: + if (LOWORD(wParam)) + SetFocus(GetDlgItem(hWnd, IDC_EDITOR)); + return 0; + + case WM_INITMENUPOPUP: + return OnInitPopupMenu( hWnd, wParam, lParam ); + + case WM_SIZE: + return OnSize( hWnd, wParam, lParam ); + + default: + return DefWindowProcW(hWnd, msg, wParam, lParam); + } + + return 0; +} + +int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdParagraph, int res) +{ + INITCOMMONCONTROLSEX classes = {8, ICC_BAR_CLASSES|ICC_COOL_CLASSES}; + HACCEL hAccel; + WNDCLASSW wc; + MSG msg; + + InitCommonControlsEx(&classes); + + hAccel = LoadAccelerators(hInstance, "MAINACCELTABLE"); + + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = WndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 4; + wc.hInstance = hInstance; + wc.hIcon = NULL; + wc.hCursor = LoadCursor(NULL, IDC_IBEAM); + wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW); + wc.lpszMenuName = xszMainMenu; + wc.lpszClassName = wszMainWndClass; + RegisterClassW(&wc); + + hMainWnd = CreateWindowExW(0, wszMainWndClass, wszAppTitle, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, hInstance, NULL); + ShowWindow(hMainWnd, SW_SHOWMAXIMIZED); + + while(GetMessage(&msg,0,0,0)) + { + if (TranslateAccelerator(hMainWnd, hAccel, &msg)) + continue; + TranslateMessage(&msg); + DispatchMessage(&msg); + if (!PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) + SendMessage(hMainWnd, WM_USER, 0, 0); + } + + return 0; +}