Release 0.4.7
Mon Nov 1 14:40:21 1993 julliard@di.epfl.ch (Alexandre Julliard)
* [if1632/user.spec]
Removed some duplicate entries.
* [include/dialog.h] [windows/dialog.c]
Implemented dialog units and fonts.
Added preliminary loading of dialog resources.
Preliminary implementation of DialogBox().
Implemented Get/SetDlgItem* functions.
* [windows/win.c]
Implemented WM_PARENTNOTIFY message.
Implemented CreateWindowEx() and GetWindow().
Completed DestroyWindow().
Mon Nov 1 18:19:34 1993 Erik Bos
* [loader/signal.c]
Added support for int 0x11 & 0x12.
* [loader/int21.c]
Improved function handling.
Sun Oct 31 12:38:09 1993 David Metcalfe <david@prism.demon.co.uk>
* [objects/font.c]
Implemented GetCharWidth().
Wed Oct 27 09:56:06 1993 John Brezak <brezak@ch.hp.com>
* [Makefile]
Use GNU malloc.
* [include/int21.h include/wine.h]
Change sc_eflags to sc_efl .
* [include/wine.h]
Fix misplaced #endif
Include <signal.h> for NetBSD
* [loader/int21.c]
Don't include <sys/vfs.h> in NetBSD
Do include <sys/mount.h> in NetBSD
Cleanup some lint.
Mon Oct 26 17:59:01 1993 Erik Bos
* [include/int21.h]
Added.
* [loader/int21.c]
Added support for many dos ints.
* [misc/file.c] [include/files.h]
Moved OPEN_MAX and DosDriveStruct to files.h.
Sun Oct 24 13:36:50 1993 David Metcalfe <david@prism.demon.co.uk>
* [controls/button.c]
Implemented CHECKBOX, AUTOCHECKBOX, 3STATE, AUTO3STATE,
RADIOBUTTON, AUTORADIOBUTTON, GROUPBOX controls, together with
a preliminary USERBUTTON control.
* [objects/text.c]
Corrected bugs in TEXT_NextLine() and added handling of prefix
character.
* [controls/button.c]
Disabled focus handling by commenting out SetFocus() calls until
serious bug can be found.
Oct 20, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [controls/listbox.c]
Listbox control window
Painting cleanup, new messages processed.
* [controls/scroll.c]
Scroll bar control window
Painting cleanup.
* [controls/combo.c]
Combo box control window
Painting cleanup.
Tue Oct 12 17:50:11 1993 julliard@di.epfl.ch (Alexandre Julliard)
* [objects/color.c] [objects/palette.c] [windows/syscolor.c]
Better support for the private color map.
Using a private map is now the default.
* [windows/win.c]
Bug fix.
* [include/dialog.h] [windows/dialog.c]
Implemented CreateDialog*() and IsDialogMessage().
* [misc/xt.c] [windows/defwnd.c]
Moved DefWindowProc() to defwnd.c.
Added WM_NCCREATE, WM_NCDESTROY and WM_CTLCOLOR handling.
* [windows/defdlg.c]
Started the implementation of DefDlgProc().
* [windows/win.c]
Added WM_NCCREATE and WM_NCDESTROY messages.
Implemented IsChild().
Tue Oct 12 17:50:20 1993 David Metcalfe <david@prism.demon.co.uk>
* [windows/focus.c]
Implemented GetFocus() and SetFocus().
* [windows/event.c]
Added processing of FocusIn and FocusOut events.
* [windows/graphics.c]
Added DrawFocusRect().
Sat Oct 9 14:36:57 1993 Erik Bos
* [loader/int1a.c]
Added more function handling.
Wed Oct 6 12:21:22 1993 Erik Bos
* [loader/signal.c]
Split signal.c into int1a.c, int21.c and signal.c.
Tue Oct 5 22:12:40 1993 David Metcalfe
* [controls/static.c] [control/widgets.c]
Static control class.
* [objects/text.c]
Added processing of additional DT_ flags to DrawText().
* [windows/win.c] [misc/xt.c]
Added SetWindowText() and WM_SETTEXT processing.
Tue Oct 5 22:12:40 1993 Martin Ayotte
* [controls/listbox.c]
Listbox control window
* [controls/scroll.c]
Scroll bar control window
* [controls/combo.c]
Combo box control window
* [include/combo.h]
Combo box definitions
* [include/listbox.h]
Listbox definitions
* [include/scroll.h]
Scroll bar definitions
Sat Oct 2 09:35:54 1993 Bob Amstadt (bob at pooh)
* [if1632/callback.c]
Fixed bug in MakeProcInstance().
* [debugger/info.c]
Changed x/w and x/b to display in hex.
* [debugger/i386-pinsn.c]
Added code to properly unassemble 16-bit indexing.
Fri Oct 1 08:29:05 1993 Bob Amstadt (bob at pooh)
* [loader/files.c] [misc/profile.c]
System initialization file is now called "wine.ini" and can
be located in the current directory, the user's home directory,
or any directories specified in the WINEPATH environment variable.
* [tools/build.c] [if1632/call.S] [include/regfunc.h]
Changed register function stack to match sigcontext structure.
Thu Sep 30 22:30:21 1993 Bob Amstadt (bob at pooh)
* [loader/files.c]
Created function to search a path for files to load.
* [loader/wine.c]
Modified exe and dll file loading to search through path
specified by the environment variable WINEPATH.
Thu Sep 30 22:30:21 1993 Eric Youngdale
* [loader/signal.c]
Bug fix.
Thu Sep 30 22:30:21 1993 John Brezak
* [debugger/dbg.y] [debugger/debug.l] [debugger/dtest.c]
[debugger/obstack.h]
Updates to allow debugger to function under NetBSD.
diff --git a/ChangeLog b/ChangeLog
index 18ff63d..086760b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,205 @@
+Mon Nov 1 14:40:21 1993 julliard@di.epfl.ch (Alexandre Julliard)
+
+ * [if1632/user.spec]
+ Removed some duplicate entries.
+
+ * [include/dialog.h] [windows/dialog.c]
+ Implemented dialog units and fonts.
+ Added preliminary loading of dialog resources.
+ Preliminary implementation of DialogBox().
+ Implemented Get/SetDlgItem* functions.
+
+ * [windows/win.c]
+ Implemented WM_PARENTNOTIFY message.
+ Implemented CreateWindowEx() and GetWindow().
+ Completed DestroyWindow().
+
+Mon Nov 1 18:19:34 1993 Erik Bos
+
+ * [loader/signal.c]
+ Added support for int 0x11 & 0x12.
+
+ * [loader/int21.c]
+ Improved function handling.
+
+Sun Oct 31 12:38:09 1993 David Metcalfe <david@prism.demon.co.uk>
+
+ * [objects/font.c]
+ Implemented GetCharWidth().
+
+Wed Oct 27 09:56:06 1993 John Brezak <brezak@ch.hp.com>
+
+ * [Makefile]
+ Use GNU malloc.
+
+ * [include/int21.h include/wine.h]
+ Change sc_eflags to sc_efl .
+
+ * [include/wine.h]
+ Fix misplaced #endif
+ Include <signal.h> for NetBSD
+
+ * [loader/int21.c]
+ Don't include <sys/vfs.h> in NetBSD
+ Do include <sys/mount.h> in NetBSD
+ Cleanup some lint.
+
+Mon Oct 26 17:59:01 1993 Erik Bos
+
+ * [include/int21.h]
+ Added.
+
+ * [loader/int21.c]
+ Added support for many dos ints.
+
+ * [misc/file.c] [include/files.h]
+ Moved OPEN_MAX and DosDriveStruct to files.h.
+
+Sun Oct 24 13:36:50 1993 David Metcalfe <david@prism.demon.co.uk>
+
+ * [controls/button.c]
+ Implemented CHECKBOX, AUTOCHECKBOX, 3STATE, AUTO3STATE,
+ RADIOBUTTON, AUTORADIOBUTTON, GROUPBOX controls, together with
+ a preliminary USERBUTTON control.
+
+ * [objects/text.c]
+ Corrected bugs in TEXT_NextLine() and added handling of prefix
+ character.
+
+ * [controls/button.c]
+ Disabled focus handling by commenting out SetFocus() calls until
+ serious bug can be found.
+
+Oct 20, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
+
+ * [controls/listbox.c]
+ Listbox control window
+ Painting cleanup, new messages processed.
+
+ * [controls/scroll.c]
+ Scroll bar control window
+ Painting cleanup.
+
+ * [controls/combo.c]
+ Combo box control window
+ Painting cleanup.
+
+Tue Oct 12 17:50:11 1993 julliard@di.epfl.ch (Alexandre Julliard)
+
+ * [objects/color.c] [objects/palette.c] [windows/syscolor.c]
+ Better support for the private color map.
+ Using a private map is now the default.
+
+ * [windows/win.c]
+ Bug fix.
+
+ * [include/dialog.h] [windows/dialog.c]
+ Implemented CreateDialog*() and IsDialogMessage().
+
+ * [misc/xt.c] [windows/defwnd.c]
+ Moved DefWindowProc() to defwnd.c.
+ Added WM_NCCREATE, WM_NCDESTROY and WM_CTLCOLOR handling.
+
+ * [windows/defdlg.c]
+ Started the implementation of DefDlgProc().
+
+ * [windows/win.c]
+ Added WM_NCCREATE and WM_NCDESTROY messages.
+ Implemented IsChild().
+
+Tue Oct 12 17:50:20 1993 David Metcalfe <david@prism.demon.co.uk>
+
+ * [windows/focus.c]
+ Implemented GetFocus() and SetFocus().
+
+ * [windows/event.c]
+ Added processing of FocusIn and FocusOut events.
+
+ * [windows/graphics.c]
+ Added DrawFocusRect().
+
+Sat Oct 9 14:36:57 1993 Erik Bos
+
+ * [loader/int1a.c]
+ Added more function handling.
+
+Wed Oct 6 12:21:22 1993 Erik Bos
+
+ * [loader/signal.c]
+ Split signal.c into int1a.c, int21.c and signal.c.
+
+Tue Oct 5 22:12:40 1993 David Metcalfe
+
+ * [controls/static.c] [control/widgets.c]
+ Static control class.
+
+ * [objects/text.c]
+ Added processing of additional DT_ flags to DrawText().
+
+ * [windows/win.c] [misc/xt.c]
+ Added SetWindowText() and WM_SETTEXT processing.
+
+Tue Oct 5 22:12:40 1993 Martin Ayotte
+
+ * [controls/listbox.c]
+ Listbox control window
+
+ * [controls/scroll.c]
+ Scroll bar control window
+
+ * [controls/combo.c]
+ Combo box control window
+
+ * [include/combo.h]
+ Combo box definitions
+
+ * [include/listbox.h]
+ Listbox definitions
+
+ * [include/scroll.h]
+ Scroll bar definitions
+
+Sat Oct 2 09:35:54 1993 Bob Amstadt (bob at pooh)
+
+ * [if1632/callback.c]
+ Fixed bug in MakeProcInstance().
+
+ * [debugger/info.c]
+ Changed x/w and x/b to display in hex.
+
+ * [debugger/i386-pinsn.c]
+ Added code to properly unassemble 16-bit indexing.
+
+Fri Oct 1 08:29:05 1993 Bob Amstadt (bob at pooh)
+
+ * [loader/files.c] [misc/profile.c]
+ System initialization file is now called "wine.ini" and can
+ be located in the current directory, the user's home directory,
+ or any directories specified in the WINEPATH environment variable.
+
+ * [tools/build.c] [if1632/call.S] [include/regfunc.h]
+ Changed register function stack to match sigcontext structure.
+
+Thu Sep 30 22:30:21 1993 Bob Amstadt (bob at pooh)
+
+ * [loader/files.c]
+ Created function to search a path for files to load.
+
+ * [loader/wine.c]
+ Modified exe and dll file loading to search through path
+ specified by the environment variable WINEPATH.
+
+Thu Sep 30 22:30:21 1993 Eric Youngdale
+
+ * [loader/signal.c]
+ Bug fix.
+
+Thu Sep 30 22:30:21 1993 John Brezak
+
+ * [debugger/dbg.y] [debugger/debug.l] [debugger/dtest.c]
+ [debugger/obstack.h]
+ Updates to allow debugger to function under NetBSD.
+
Tue Sep 28 19:59:21 1993 David Metcalfe
* [windows/win.c]
diff --git a/Makefile b/Makefile
index b6d3236..8b508d9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
######################################################################
# These variables are inherited by the sub-makefiles
-DEBUGOPTS=
+DEBUGOPTS=-DDEBUG_RESOURCE
COPTS=-O2 -m486
INCLUDE_DIR=include
LDFLAGS=
@@ -18,7 +18,7 @@
dummy:
clean:
- rm -f *~ *.o
+ rm -f *~ *.o *#
@for i in tools $(SUBDIRS); do (cd $$i && $(MAKE) clean) || exit; done
$(TARGET): dummy
diff --git a/README b/README
index bdc28e2..9e326d6 100644
--- a/README
+++ b/README
@@ -18,15 +18,42 @@
All:
To build Wine, first do a "make depend" and then a "make". The
-executable "wine" will be built.
+executable "wine" will be built. "wine" will load and run Windows'
+executables. You must specify the entire path to the executable,
+have the executable in the current directory, or specify a load
+path with environment variable WINEPATH.
-Grab a copy of Windows sol.exe (Solitaire) and run it with the command:
+For example, to run Windows' solitaire:
- wine sol.exe
+ export WINEPATH=/dos/windows;/dos/windows/system
+ wine sol
Have a nice game of solitaire, but be careful. Emulation isn't perfect.
So, occassionally it will crash.
+WHAT'S NEW with version 0.4.7: (see ChangeLog for details)
+ - More dialog box functions
+ - More DOS interrupts
+ - NetBSD compatibility patches
+
+WHAT'S NEW with version 0.4.5: (see ChangeLog for details)
+ - Bug fixes
+ - focus routines
+ - dialog box functions
+ - improvements to control windows
+
+WHAT'S NEW with version 0.4.4: (see ChangeLog for details)
+ - Bug fixes
+ - New static control class
+ - Preliminary listbox, combobox and scrollbar controls
+ - System initialization file is now called "wine.ini", and
+ may be located in the user's current directory, the
+ user's home directory or any directory specified by
+ the WINEPATH environment variable.
+ - The loader now searches the directories specified by the
+ WINEPATH environment variable for programs and DLLs.
+ - Internal debugger now works on 386BSD.
+
WHAT'S NEW with version 0.4.3: (see ChangeLog for details)
- Bug fixes
- Resource loading now able to load DLL resources
diff --git a/README.DEBUGGER b/README.DEBUGGER
deleted file mode 100644
index 2f6ff99..0000000
--- a/README.DEBUGGER
+++ /dev/null
@@ -1,47 +0,0 @@
-Date: Sun, 26 Sep 93 03:18:19 EDT
-From: eric@tantalus.nrl.navy.mil (Eric Youngdale)
-Message-Id: <9309260718.AA13966@tantalus.nrl.navy.mil>
-To: bob@amscons.amscons.com
-Cc: linux-activists@Niksula.hut.fi
-In-Reply-To: Bob Amstadt's message of Sat, 25 Sep 1993 23:36:32 +0300
- <m0oggMt-000CrhC@amscons.amscons.com>
-X-Mn-Key: WABI
-
-
-
->I may just be dreaming, but I'm beginning to like the idea of a built
->in debugger.
-
- So do I. I like it so much that I wrote one. It turns out that the
-disassembly code in gdb is pretty much localized to one source file, and this
-was easy to splice into a simple program. In addition, there are 2 variables
-that you set if you are disassembling 16 bit code, so it makes it all the
-better.
-
- Anyway, there is a parser that understands a limited set of gdb
-commands (very limited, but the 'x' command is pretty functional as long as you
-stick to numeric rather than symbolic addresses). The parser understands $pc
-and $sp for your convenience, and you can do things like "x/10i $pc" and "info
-regs" to see what is going on. In principle you can do "x/x", "x/s", "x/d",
-"x/w", "x/b", "x/i" and "x/c". I implemented an "info stack" command that
-simply dumps a number of bytes from the stack onto the screen, but it currently
-makes no attempt to actually interpret the stack frames.
-
- This will probably not work on non-linux systems, and I have no idea
-how much work it will be to fix it. To start with we need some simple macros
-to determine (based upon a segment selector) whether we are in a 16 bit or a 32
-bit segment, but this should be pretty easy to fix. I shamelessly ripped off a
-bunch of files from gdb, and I obviously picked the ones for linux. For other
-systems you may need to make adjustments to these files somehow. It is too
-late in the evening to worry about this now.
-
- It will probably be easy to modify the parser to allow you to change
-memory locations and/or register values and then continue execution. Also,
-some of the hooks for using readline with the parser are in place, but it does
-not work reliably for some reason, so I left it out for now. Adding gnu
-readline really would bloat the package a lot. Instead I could use Rich Salz's
-editlib (the canonical test case for the DLL tools), which has a command line
-history feature that could be an acceptable substitute - this is much smaller
-than gnu readline, but I am not sure what features are present.
-
--Eric
diff --git a/bsdmake.patch b/bsdmake.patch
index 7be2893..99fa57a 100644
--- a/bsdmake.patch
+++ b/bsdmake.patch
@@ -6,7 +6,7 @@
# These definitions are for the top level
TARGET=wine
-LIBS=-L. -L/usr/X386/lib -lXext -lXaw -lXt -lXmu -lX11 -lm
-+LIBS=-L. -L/usr/X386/lib -lXext -lXaw -lXt -lXmu -lX11 -lm -li386
++LIBS=-L. -L/usr/X386/lib -lXext -lXaw -lXt -lXmu -lX11 -lm -li386 -lgnumalloc
OBJS=if1632/if1632.o controls/controls.o loader/loader.o \
memory/memory.o misc/misc.o objects/objects.o windows/windows.o
SUBDIRS=if1632 controls loader memory misc objects windows
@@ -122,3 +122,12 @@
+.if exists(.depend)
+.include ".depend"
+.endif
+--- debugger/Makefile.orig Thu Sep 30 07:29:39 1993
++++ debugger/Makefile Thu Sep 30 07:27:00 1993
+@@ -37,3 +37,6 @@
+ depend: dbg.tab.c dbg.tab.h lex.yy.c
+ $(CC) $(CFLAGS) -M *.c > .depend
+
++.if exists(.depend)
++.include ".depend"
++.endif
diff --git a/controls/Makefile b/controls/Makefile
index 46a93ba..2f4c081 100644
--- a/controls/Makefile
+++ b/controls/Makefile
@@ -1,7 +1,8 @@
CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR)
-OBJS=menu.o widgets.o button.o SmeMenuButto.o WinLabel.o WinCommand.o \
- WinMenuButto.o
+OBJS=menu.o widgets.o button.o scroll.o listbox.o combo.o static.o \
+ SmeMenuButto.o WinLabel.o WinCommand.o \
+ WinMenuButto.o
default: controls.o
@@ -9,7 +10,7 @@
$(LD) -r -o controls.o $(OBJS)
clean:
- rm -f *.o *~ *.s dll_* *.a
+ rm -f *.o *~ *.s dll_* *.a *#
depend:
$(CC) $(CFLAGS) -M *.c > .depend
diff --git a/controls/button.c b/controls/button.c
index f843beb..1a13b9d 100644
--- a/controls/button.c
+++ b/controls/button.c
@@ -1,33 +1,53 @@
-/* File: button.c -- MS-Windows(tm) compatible "Button" replacement widget
+/* File: button.c -- Button type widgets
*
- * programmed by Johannes Ruscheinski for the Linux WABI
- * project.
- * (C) 1993 by Johannes Ruscheinski
- *
- * Modifications by David Metcalfe
+ * Copyright (C) 1993 Johannes Ruscheinski
+ * Copyright (C) 1993 David Metcalfe
*/
+static char Copyright1[] = "Copyright Johannes Ruscheinski, 1993";
+static char Copyright2[] = "Copyright David Metcalfe, 1993";
+
#include <windows.h>
#include "win.h"
LONG ButtonWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam);
-static COLORREF color_windowframe, color_btnface, color_btnshadow,
- color_btntext, color_btnhighlight;
+static COLORREF color_windowtext, color_windowframe, color_btnface,
+ color_btnshadow, color_btntext, color_btnhighlight;
static BOOL pressed;
#define NOTIFY_PARENT(hWndCntrl, wNotifyCode) \
SendMessage(GetParent(hWndCntrl), WM_COMMAND, \
- GetDlgCtrlID(hWndCntrl), MAKELPARAM(hWndCntrl, wNotifyCode));
+ GetDlgCtrlID(hWndCntrl), MAKELPARAM(hWndCntrl, wNotifyCode));
#define DIM(array) ((sizeof array)/(sizeof array[0]))
static LONG PB_Paint(HWND hWnd);
static LONG PB_LButtonDown(HWND hWnd, WORD wParam, LONG lParam);
static LONG PB_LButtonUp(HWND hWnd, WORD wParam, LONG lParam);
static LONG PB_LButtonDblClk(HWND hWnd, WORD wParam, LONG lParam);
+static LONG PB_KillFocus(HWND hwnd);
static void DrawRaisedPushButton(HDC hDC, HWND hButton, RECT rc);
static void DrawPressedPushButton(HDC hDC, HWND hButton, RECT rc);
+static LONG CB_Paint(HWND hWnd);
+static LONG CB_LButtonDown(HWND hWnd, WORD wParam, LONG lParam);
+static LONG CB_LButtonUp(HWND hWnd, WORD wParam, LONG lParam);
+static LONG CB_LButtonDblClk(HWND hWnd, WORD wParam, LONG lParam);
+static LONG CB_KillFocus(HWND hWnd);
+static LONG CB_SetCheck(HWND hWnd, WORD wParam);
+static LONG CB_GetCheck(HWND hWnd);
+static LONG RB_Paint(HWND hWnd);
+static LONG RB_LButtonDown(HWND hWnd, WORD wParam, LONG lParam);
+static LONG RB_LButtonUp(HWND hWnd, WORD wParam, LONG lParam);
+static LONG RB_LButtonDblClk(HWND hWnd, WORD wParam, LONG lParam);
+static LONG RB_KillFocus(HWND hWnd);
+static LONG RB_SetCheck(HWND hWnd, WORD wParam);
+static LONG RB_GetCheck(HWND hWnd);
+static LONG GB_Paint(HWND hWnd);
+static LONG UB_Paint(HWND hWnd);
+static LONG UB_LButtonDown(HWND hWnd, WORD wParam, LONG lParam);
+static LONG UB_LButtonUp(HWND hWnd, WORD wParam, LONG lParam);
+static LONG UB_KillFocus(HWND hWnd);
typedef struct
{
@@ -35,9 +55,12 @@
LONG (*lButtonDownfn)();
LONG (*lButtonUpfn)();
LONG (*lButtonDblClkfn)();
+ LONG (*killFocusfn)();
+ LONG (*setCheckfn)();
+ LONG (*getCheckfn)();
} BTNFN;
-#define MAX_BTN_TYPE 2
+#define MAX_BTN_TYPE 10
static BTNFN btnfn[MAX_BTN_TYPE] =
{
@@ -45,13 +68,91 @@
(LONG(*)())PB_Paint, /* BS_PUSHBUTTON */
(LONG(*)())PB_LButtonDown,
(LONG(*)())PB_LButtonUp,
- (LONG(*)())PB_LButtonDblClk
+ (LONG(*)())PB_LButtonDblClk,
+ (LONG(*)())PB_KillFocus,
+ (LONG(*)())NULL,
+ (LONG(*)())NULL
},
{
(LONG(*)())PB_Paint, /* BS_DEFPUSHBUTTON */
(LONG(*)())PB_LButtonDown,
(LONG(*)())PB_LButtonUp,
- (LONG(*)())PB_LButtonDblClk
+ (LONG(*)())PB_LButtonDblClk,
+ (LONG(*)())PB_KillFocus,
+ (LONG(*)())NULL,
+ (LONG(*)())NULL
+ },
+ {
+ (LONG(*)())CB_Paint, /* BS_CHECKBOX */
+ (LONG(*)())CB_LButtonDown,
+ (LONG(*)())CB_LButtonUp,
+ (LONG(*)())CB_LButtonDblClk,
+ (LONG(*)())CB_KillFocus,
+ (LONG(*)())CB_SetCheck,
+ (LONG(*)())CB_GetCheck
+ },
+ {
+ (LONG(*)())CB_Paint, /* BS_AUTOCHECKBOX */
+ (LONG(*)())CB_LButtonDown,
+ (LONG(*)())CB_LButtonUp,
+ (LONG(*)())CB_LButtonDblClk,
+ (LONG(*)())CB_KillFocus,
+ (LONG(*)())CB_SetCheck,
+ (LONG(*)())CB_GetCheck
+ },
+ {
+ (LONG(*)())RB_Paint, /* BS_RADIOBUTTON */
+ (LONG(*)())RB_LButtonDown,
+ (LONG(*)())RB_LButtonUp,
+ (LONG(*)())RB_LButtonDblClk,
+ (LONG(*)())RB_KillFocus,
+ (LONG(*)())RB_SetCheck,
+ (LONG(*)())RB_GetCheck
+ },
+ {
+ (LONG(*)())CB_Paint, /* BS_3STATE */
+ (LONG(*)())CB_LButtonDown,
+ (LONG(*)())CB_LButtonUp,
+ (LONG(*)())CB_LButtonDblClk,
+ (LONG(*)())CB_KillFocus,
+ (LONG(*)())CB_SetCheck,
+ (LONG(*)())CB_GetCheck
+ },
+ {
+ (LONG(*)())CB_Paint, /* BS_AUTO3STATE */
+ (LONG(*)())CB_LButtonDown,
+ (LONG(*)())CB_LButtonUp,
+ (LONG(*)())CB_LButtonDblClk,
+ (LONG(*)())CB_KillFocus,
+ (LONG(*)())CB_SetCheck,
+ (LONG(*)())CB_GetCheck
+ },
+ {
+ (LONG(*)())GB_Paint, /* BS_GROUPBOX */
+ (LONG(*)())NULL,
+ (LONG(*)())NULL,
+ (LONG(*)())NULL,
+ (LONG(*)())NULL,
+ (LONG(*)())NULL,
+ (LONG(*)())NULL
+ },
+ {
+ (LONG(*)())UB_Paint, /* BS_USERBUTTON */
+ (LONG(*)())UB_LButtonDown,
+ (LONG(*)())UB_LButtonUp,
+ (LONG(*)())NULL,
+ (LONG(*)())UB_KillFocus,
+ (LONG(*)())NULL,
+ (LONG(*)())NULL
+ },
+ {
+ (LONG(*)())RB_Paint, /* BS_AUTORADIOBUTTON */
+ (LONG(*)())RB_LButtonDown,
+ (LONG(*)())RB_LButtonUp,
+ (LONG(*)())RB_LButtonDblClk,
+ (LONG(*)())RB_KillFocus,
+ (LONG(*)())RB_SetCheck,
+ (LONG(*)())RB_GetCheck
}
};
@@ -80,42 +181,49 @@
else
{
/* initialise colours used for button rendering: */
+ color_windowtext = GetSysColor(COLOR_WINDOWTEXT);
color_windowframe = GetSysColor(COLOR_WINDOWFRAME);
color_btnface = GetSysColor(COLOR_BTNFACE);
color_btnshadow = GetSysColor(COLOR_BTNSHADOW);
color_btntext = GetSysColor(COLOR_BTNTEXT);
color_btnhighlight = GetSysColor(COLOR_BTNHIGHLIGHT);
+ (WORD)(*(wndPtr->wExtra)) = 0;
pressed = FALSE;
lResult = 0L;
}
break;
case WM_PAINT:
- (btnfn[style].paintfn)(hWnd);
+ if (btnfn[style].paintfn)
+ (btnfn[style].paintfn)(hWnd);
break;
case WM_LBUTTONDOWN:
- (btnfn[style].lButtonDownfn)(hWnd, wParam, lParam);
+ if (btnfn[style].lButtonDownfn)
+ (btnfn[style].lButtonDownfn)(hWnd, wParam, lParam);
break;
case WM_LBUTTONUP:
- (btnfn[style].lButtonUpfn)(hWnd, wParam, lParam);
+ if (btnfn[style].lButtonUpfn)
+ (btnfn[style].lButtonUpfn)(hWnd, wParam, lParam);
break;
case WM_LBUTTONDBLCLK:
- (btnfn[style].lButtonDblClkfn)(hWnd, wParam, lParam);
+ if (btnfn[style].lButtonDblClkfn)
+ (btnfn[style].lButtonDblClkfn)(hWnd, wParam, lParam);
break;
case WM_SETFOCUS:
break;
case WM_KILLFOCUS:
- InvalidateRect(hWnd, NULL, FALSE);
- UpdateWindow(hWnd);
+ if (btnfn[style].killFocusfn)
+ (btnfn[style].killFocusfn)(hWnd);
break;
case WM_SYSCOLORCHANGE:
+ color_windowtext = GetSysColor(COLOR_WINDOWTEXT);
color_windowframe = GetSysColor(COLOR_WINDOWFRAME);
color_btnface = GetSysColor(COLOR_BTNFACE);
color_btnshadow = GetSysColor(COLOR_BTNSHADOW);
@@ -124,6 +232,16 @@
InvalidateRect(hWnd, NULL, TRUE);
break;
+ case BM_SETCHECK:
+ if (btnfn[style].setCheckfn)
+ (btnfn[style].setCheckfn)(hWnd, wParam);
+ break;
+
+ case BM_GETCHECK:
+ if (btnfn[style].getCheckfn)
+ (btnfn[style].getCheckfn)(hWnd);
+ break;
+
default:
lResult = DefWindowProc(hWnd, uMsg, wParam, lParam);
break;
@@ -155,7 +273,7 @@
static LONG PB_LButtonDown(HWND hWnd, WORD wParam, LONG lParam)
{
-/* SetFocus(hWnd); */
+/* SetFocus(hWnd); */
SetCapture(hWnd);
pressed = TRUE;
InvalidateRect(hWnd, NULL, FALSE);
@@ -184,6 +302,13 @@
NOTIFY_PARENT(hWnd, BN_DOUBLECLICKED);
}
+static LONG PB_KillFocus(HWND hWnd)
+{
+ pressed = FALSE;
+ InvalidateRect(hWnd, NULL, FALSE);
+ UpdateWindow(hWnd);
+}
+
static void DrawRaisedPushButton(HDC hDC, HWND hButton, RECT rc)
{
HPEN hOldPen, hFramePen;
@@ -255,19 +380,16 @@
CombineRgn(rgn, rgn1, rgn2, RGN_AND);
FillRgn(hDC, rgn2, hShadowBrush);
-#if 0
/* do we have the focus? */
if (len >= 1 && GetFocus() == hButton) {
dwTextSize = GetTextExtent(hDC, text, len);
- delta = ((rc.right - rc.left) - LOWORD(dwTextSize) + 1) >> 1;
+ delta = ((rc.right - rc.left) - LOWORD(dwTextSize) - 1) >> 1;
rc.left += delta; rc.right -= delta;
GetTextMetrics(hDC, &tm);
- delta = ((rc.bottom - rc.top) -
- tm.tmHeight + tm.tmInternalLeading) >> 1;
+ delta = ((rc.bottom - rc.top) - tm.tmHeight - 1) >> 1;
rc.top += delta; rc.bottom -= delta;
DrawFocusRect(hDC, &rc);
}
-#endif
SelectObject(hDC, (HANDLE)hOldPen);
SelectObject(hDC, (HANDLE)hOldBrush);
@@ -275,10 +397,8 @@
DeleteObject((HANDLE)hShadowBrush);
DeleteObject((HANDLE)hBackgrndBrush);
DeleteObject((HANDLE)rgn1);
-#if 0
DeleteObject((HANDLE)rgn2);
DeleteObject((HANDLE)rgn);
-#endif
}
@@ -320,19 +440,16 @@
DT_SINGLELINE | DT_CENTER| DT_VCENTER);
}
-#if 0
/* do we have the focus? */
if (len >= 1 && GetFocus() == hButton) {
dwTextSize = GetTextExtent(hDC, text, len);
- delta = ((rc.right - rc.left) - LOWORD(dwTextSize)) >> 1;
+ delta = ((rc.right - rc.left) - LOWORD(dwTextSize) - 1) >> 1;
rc.left += delta; rc.right -= delta;
GetTextMetrics(hDC, &tm);
- delta = ((rc.bottom - rc.top) -
- tm.tmHeight + tm.tmInternalLeading) >> 1;
+ delta = ((rc.bottom - rc.top) - tm.tmHeight - 1) >> 1;
rc.top += delta; rc.bottom -= delta;
DrawFocusRect(hDC, &rc);
}
-#endif
SelectObject(hDC, (HANDLE)hOldPen);
SelectObject(hDC, (HANDLE)hOldBrush);
@@ -342,10 +459,498 @@
}
+/**********************************************************************
+ * Check Box Functions
+ */
+
+static LONG CB_Paint(HWND hWnd)
+{
+ PAINTSTRUCT ps;
+ RECT rc, rc3;
+ HDC hDC;
+ HPEN hPen, hOldPen;
+ HBRUSH hBrush, hGrayBrush;
+ int textlen, delta;
+ char *text;
+ HANDLE hText;
+ TEXTMETRIC tm;
+ SIZE size;
+ WND *wndPtr = WIN_FindWndPtr(hWnd);
+
+ hDC = BeginPaint(hWnd, &ps);
+ GetClientRect(hWnd, &rc);
+
+ hPen = CreatePen(PS_SOLID, 1, color_windowtext);
+ hOldPen = (HPEN)SelectObject(hDC, (HANDLE)hPen);
+ hGrayBrush = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
+
+ hBrush = SendMessage(GetParent(hWnd), WM_CTLCOLOR, (WORD)hDC,
+ MAKELPARAM(hWnd, CTLCOLOR_BTN));
+ FillRect(hDC, &rc, hBrush);
+
+ textlen = GetWindowTextLength(hWnd);
+ hText = LocalAlloc(LMEM_MOVEABLE, textlen+1);
+ text = LocalLock(hText);
+ GetWindowText(hWnd, text, textlen+1);
+ GetTextMetrics(hDC, &tm);
+
+ delta = (rc.bottom - rc.top - tm.tmHeight) >> 1;
+ Rectangle(hDC, 0, rc.top + delta, tm.tmHeight, tm.tmHeight + delta);
+ if (pressed)
+ Rectangle(hDC, 1, rc.top + delta + 1, tm.tmHeight - 1,
+ tm.tmHeight + delta - 1);
+
+ switch ((WORD)(*(wndPtr->wExtra)))
+ {
+ case 1:
+ MoveTo(hDC, 0, rc.top + delta);
+ LineTo(hDC, tm.tmHeight - 1, tm.tmHeight + delta - 1);
+ MoveTo(hDC, 0, tm.tmHeight + delta - 1);
+ LineTo(hDC, tm.tmHeight - 1, rc.top + delta);
+ break;
+
+ case 2:
+ rc3.left = 1;
+ rc3.top = rc.top + delta + 1;
+ rc3.right = tm.tmHeight - 1;
+ rc3.bottom = tm.tmHeight + delta - 1;
+ FillRect(hDC, &rc3, hGrayBrush);
+ break;
+ }
+
+ rc.left = tm.tmHeight + tm.tmAveCharWidth / 2;
+ DrawText(hDC, text, textlen, &rc, DT_SINGLELINE | DT_VCENTER);
+
+ /* do we have the focus? */
+ if (GetFocus() == hWnd)
+ {
+ GetTextExtentPoint(hDC, text, textlen, &size);
+ rc.top += delta - 1;
+ rc.bottom -= delta + 1;
+ rc.left--;
+ rc.right = rc.left + size.cx + 2;
+ DrawFocusRect(hDC, &rc);
+ }
+
+ LocalUnlock(hText);
+ LocalFree(hText);
+ GlobalUnlock(hWnd);
+ EndPaint(hWnd, &ps);
+}
+
+static LONG CB_LButtonDown(HWND hWnd, WORD wParam, LONG lParam)
+{
+ RECT rc;
+ HDC hDC;
+ TEXTMETRIC tm;
+ int delta;
+
+ hDC = GetDC(hWnd);
+ GetTextMetrics(hDC, &tm);
+ ReleaseDC(hWnd, hDC);
+ GetClientRect(hWnd, &rc);
+ delta = (rc.bottom - rc.top - tm.tmHeight) >> 1;
+ rc.top += delta;
+ rc.bottom = tm.tmHeight + delta;
+ rc.right = tm.tmHeight;
+ if (PtInRect(&rc, MAKEPOINT(lParam)))
+ {
+/* SetFocus(hWnd); */
+ SetCapture(hWnd);
+ pressed = TRUE;
+ InvalidateRect(hWnd, NULL, FALSE);
+ UpdateWindow(hWnd);
+ }
+}
+
+static LONG CB_LButtonUp(HWND hWnd, WORD wParam, LONG lParam)
+{
+ RECT rc;
+ HDC hDC;
+ TEXTMETRIC tm;
+ int delta;
+ WND *wndPtr = WIN_FindWndPtr(hWnd);
+ LONG style;
+
+ pressed = FALSE;
+ ReleaseCapture();
+ hDC = GetDC(hWnd);
+ GetTextMetrics(hDC, &tm);
+ ReleaseDC(hWnd, hDC);
+ GetClientRect(hWnd, &rc);
+ delta = (rc.bottom - rc.top - tm.tmHeight) >> 1;
+ rc.top += delta;
+ rc.bottom = tm.tmHeight + delta;
+ rc.right = tm.tmHeight;
+
+ if (PtInRect(&rc, MAKEPOINT(lParam)))
+ {
+ style = wndPtr->dwStyle & 0x0000000F;
+ if (style == BS_AUTOCHECKBOX)
+ {
+ switch ((WORD)(*(wndPtr->wExtra)))
+ {
+ case 0:
+ (WORD)(*(wndPtr->wExtra)) = 1;
+ break;
+
+ case 1:
+ (WORD)(*(wndPtr->wExtra)) = 0;
+ break;
+ }
+ }
+ else if (style == BS_AUTO3STATE)
+ {
+ switch ((WORD)(*(wndPtr->wExtra)))
+ {
+ case 0:
+ (WORD)(*(wndPtr->wExtra)) = 1;
+ break;
+
+ case 1:
+ (WORD)(*(wndPtr->wExtra)) = 2;
+ break;
+
+ case 2:
+ (WORD)(*(wndPtr->wExtra)) = 0;
+ break;
+ }
+ }
+ NOTIFY_PARENT(hWnd, BN_CLICKED);
+ }
+ GlobalUnlock(hWnd);
+ InvalidateRect(hWnd, NULL, FALSE);
+ UpdateWindow(hWnd);
+}
+
+static LONG CB_LButtonDblClk(HWND hWnd, WORD wParam, LONG lParam)
+{
+ RECT rc;
+ HDC hDC;
+ TEXTMETRIC tm;
+ int delta;
+
+ hDC = GetDC(hWnd);
+ GetTextMetrics(hDC, &tm);
+ ReleaseDC(hWnd, hDC);
+ GetClientRect(hWnd, &rc);
+ delta = (rc.bottom - rc.top - tm.tmHeight) >> 1;
+ rc.top += delta;
+ rc.bottom = tm.tmHeight + delta;
+ rc.right = tm.tmHeight;
+ if (PtInRect(&rc, MAKEPOINT(lParam)))
+ NOTIFY_PARENT(hWnd, BN_DOUBLECLICKED);
+}
+
+static LONG CB_KillFocus(HWND hWnd)
+{
+ pressed = FALSE;
+ InvalidateRect(hWnd, NULL, FALSE);
+ UpdateWindow(hWnd);
+}
+
+static LONG CB_SetCheck(HWND hWnd, WORD wParam)
+{
+ WND *wndPtr = WIN_FindWndPtr(hWnd);
+
+ if ((WORD)(*(wndPtr->wExtra)) != wParam)
+ {
+ (WORD)(*(wndPtr->wExtra)) = wParam;
+ InvalidateRect(hWnd, NULL, FALSE);
+ UpdateWindow(hWnd);
+ }
+ GlobalUnlock(hWnd);
+}
+
+static LONG CB_GetCheck(HWND hWnd)
+{
+ WORD wResult;
+ WND *wndPtr = WIN_FindWndPtr(hWnd);
+
+ wResult = (WORD)(*(wndPtr->wExtra));
+ GlobalUnlock(hWnd);
+ return (LONG)wResult;
+}
+/**********************************************************************
+ * Radio Button Functions
+ */
+
+static LONG RB_Paint(HWND hWnd)
+{
+ PAINTSTRUCT ps;
+ RECT rc;
+ HDC hDC;
+ HPEN hPen, hOldPen;
+ HBRUSH hBrush, hOldBrush;
+ int textlen, delta;
+ char *text;
+ HANDLE hText;
+ TEXTMETRIC tm;
+ SIZE size;
+ WND *wndPtr = WIN_FindWndPtr(hWnd);
+
+ hDC = BeginPaint(hWnd, &ps);
+ GetClientRect(hWnd, &rc);
+
+ hPen = CreatePen(PS_SOLID, 1, color_windowtext);
+ hOldPen = (HPEN)SelectObject(hDC, (HANDLE)hPen);
+
+ hBrush = SendMessage(GetParent(hWnd), WM_CTLCOLOR, (WORD)hDC,
+ MAKELPARAM(hWnd, CTLCOLOR_BTN));
+ FillRect(hDC, &rc, hBrush);
+
+ textlen = GetWindowTextLength(hWnd);
+ hText = LocalAlloc(LMEM_MOVEABLE, textlen+1);
+ text = LocalLock(hText);
+ GetWindowText(hWnd, text, textlen+1);
+ GetTextMetrics(hDC, &tm);
+
+ delta = (rc.bottom - rc.top - tm.tmHeight) >> 1;
+ Ellipse(hDC, 0, rc.top + delta, tm.tmHeight, tm.tmHeight + delta);
+ if (pressed)
+ Ellipse(hDC, 1, rc.top + delta + 1, tm.tmHeight - 1,
+ tm.tmHeight + delta - 1);
+
+ if ((WORD)(*(wndPtr->wExtra)) == 1)
+ {
+ hBrush = CreateSolidBrush(color_windowtext);
+ hOldBrush = (HBRUSH)SelectObject(hDC, (HANDLE)hBrush);
+ Ellipse(hDC, 3, rc.top + delta + 3, tm.tmHeight - 3,
+ tm.tmHeight + delta -3);
+ SelectObject(hDC, (HANDLE)hOldBrush);
+ DeleteObject((HANDLE)hBrush);
+ }
+
+ rc.left = tm.tmHeight + tm.tmAveCharWidth / 2;
+ DrawText(hDC, text, textlen, &rc, DT_SINGLELINE | DT_VCENTER);
+
+ /* do we have the focus? */
+ if (GetFocus() == hWnd)
+ {
+ GetTextExtentPoint(hDC, text, textlen, &size);
+ rc.top += delta - 1;
+ rc.bottom -= delta + 1;
+ rc.left--;
+ rc.right = rc.left + size.cx + 2;
+ DrawFocusRect(hDC, &rc);
+ }
+
+ LocalUnlock(hText);
+ LocalFree(hText);
+ GlobalUnlock(hWnd);
+ EndPaint(hWnd, &ps);
+}
+
+static LONG RB_LButtonDown(HWND hWnd, WORD wParam, LONG lParam)
+{
+ RECT rc;
+ HDC hDC;
+ TEXTMETRIC tm;
+ int delta;
+
+ hDC = GetDC(hWnd);
+ GetTextMetrics(hDC, &tm);
+ ReleaseDC(hWnd, hDC);
+ GetClientRect(hWnd, &rc);
+ delta = (rc.bottom - rc.top - tm.tmHeight) >> 1;
+ rc.top += delta;
+ rc.bottom = tm.tmHeight + delta;
+ rc.right = tm.tmHeight;
+ if (PtInRect(&rc, MAKEPOINT(lParam)))
+ {
+/* SetFocus(hWnd); */
+ SetCapture(hWnd);
+ pressed = TRUE;
+ InvalidateRect(hWnd, NULL, FALSE);
+ UpdateWindow(hWnd);
+ }
+}
+
+static LONG RB_LButtonUp(HWND hWnd, WORD wParam, LONG lParam)
+{
+ RECT rc;
+ HDC hDC;
+ TEXTMETRIC tm;
+ int delta;
+ WND *wndPtr = WIN_FindWndPtr(hWnd);
+ LONG style;
+
+ pressed = FALSE;
+ ReleaseCapture();
+ hDC = GetDC(hWnd);
+ GetTextMetrics(hDC, &tm);
+ ReleaseDC(hWnd, hDC);
+ GetClientRect(hWnd, &rc);
+ delta = (rc.bottom - rc.top - tm.tmHeight) >> 1;
+ rc.top += delta;
+ rc.bottom = tm.tmHeight + delta;
+ rc.right = tm.tmHeight;
+
+ if (PtInRect(&rc, MAKEPOINT(lParam)))
+ {
+ style = wndPtr->dwStyle & 0x0000000F;
+ if (style == BS_AUTORADIOBUTTON)
+ (WORD)(*(wndPtr->wExtra)) = 1;
+ NOTIFY_PARENT(hWnd, BN_CLICKED);
+ }
+ GlobalUnlock(hWnd);
+ InvalidateRect(hWnd, NULL, FALSE);
+ UpdateWindow(hWnd);
+}
+
+static LONG RB_LButtonDblClk(HWND hWnd, WORD wParam, LONG lParam)
+{
+ RECT rc;
+ HDC hDC;
+ TEXTMETRIC tm;
+ int delta;
+
+ hDC = GetDC(hWnd);
+ GetTextMetrics(hDC, &tm);
+ ReleaseDC(hWnd, hDC);
+ GetClientRect(hWnd, &rc);
+ delta = (rc.bottom - rc.top - tm.tmHeight) >> 1;
+ rc.top += delta;
+ rc.bottom = tm.tmHeight + delta;
+ rc.right = tm.tmHeight;
+ if (PtInRect(&rc, MAKEPOINT(lParam)))
+ NOTIFY_PARENT(hWnd, BN_DOUBLECLICKED);
+}
+
+static LONG RB_KillFocus(HWND hWnd)
+{
+ pressed = FALSE;
+ InvalidateRect(hWnd, NULL, FALSE);
+ UpdateWindow(hWnd);
+}
+
+static LONG RB_SetCheck(HWND hWnd, WORD wParam)
+{
+ WND *wndPtr = WIN_FindWndPtr(hWnd);
+
+ if ((WORD)(*(wndPtr->wExtra)) != wParam)
+ {
+ (WORD)(*(wndPtr->wExtra)) = wParam;
+ InvalidateRect(hWnd, NULL, FALSE);
+ UpdateWindow(hWnd);
+ }
+ GlobalUnlock(hWnd);
+}
+
+static LONG RB_GetCheck(HWND hWnd)
+{
+ WORD wResult;
+ WND *wndPtr = WIN_FindWndPtr(hWnd);
+
+ wResult = (WORD)(*(wndPtr->wExtra));
+ GlobalUnlock(hWnd);
+ return (LONG)wResult;
+}
+/**********************************************************************
+ * Group Box Functions
+ */
+
+static LONG GB_Paint(HWND hWnd)
+{
+ PAINTSTRUCT ps;
+ RECT rc;
+ HDC hDC;
+ HPEN hPen, hOldPen;
+ HBRUSH hBrush;
+ int textlen;
+ char *text;
+ HANDLE hText;
+ SIZE size;
+
+ hDC = BeginPaint(hWnd, &ps);
+ GetClientRect(hWnd, &rc);
+
+ hPen = CreatePen(PS_SOLID, 1, color_windowtext);
+ hOldPen = (HPEN)SelectObject(hDC, (HANDLE)hPen);
+
+ hBrush = SendMessage(GetParent(hWnd), WM_CTLCOLOR, (WORD)hDC,
+ MAKELPARAM(hWnd, CTLCOLOR_BTN));
+ FillRect(hDC, &rc, hBrush);
+
+ textlen = GetWindowTextLength(hWnd);
+ hText = LocalAlloc(LMEM_MOVEABLE, textlen+1);
+ text = LocalLock(hText);
+ GetWindowText(hWnd, text, textlen+1);
+ GetTextExtentPoint(hDC, text, textlen, &size);
+
+ rc.top = 5;
+ Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
+ rc.left = 10;
+ rc.top = 0;
+ rc.right = rc.left + size.cx + 1;
+ rc.bottom = size.cy;
+ DrawText(hDC, text, textlen, &rc, DT_SINGLELINE);
+
+ LocalUnlock(hText);
+ LocalFree(hText);
+ EndPaint(hWnd, &ps);
+}
+/**********************************************************************
+ * User Button Functions
+ */
+
+static LONG UB_Paint(HWND hWnd)
+{
+ PAINTSTRUCT ps;
+ HDC hDC;
+ RECT rc;
+ HBRUSH hBrush;
+
+ hDC = BeginPaint(hWnd, &ps);
+ GetClientRect(hWnd, &rc);
+
+ hBrush = SendMessage(GetParent(hWnd), WM_CTLCOLOR, (WORD)hDC,
+ MAKELPARAM(hWnd, CTLCOLOR_BTN));
+ FillRect(hDC, &rc, hBrush);
+
+ NOTIFY_PARENT(hWnd, BN_PAINT);
+
+ /* do we have the focus? */
+ if (GetFocus() == hWnd)
+ DrawFocusRect(hDC, &rc);
+
+ EndPaint(hWnd, &ps);
+}
+
+static LONG UB_LButtonDown(HWND hWnd, WORD wParam, LONG lParam)
+{
+ RECT rc;
+
+/* SetFocus(hWnd); */
+ SetCapture(hWnd);
+ GetClientRect(hWnd, &rc);
+ if (PtInRect(&rc, MAKEPOINT(lParam)))
+ NOTIFY_PARENT(hWnd, BN_HILITE);
+ InvalidateRect(hWnd, NULL, FALSE);
+ UpdateWindow(hWnd);
+}
+
+static LONG UB_LButtonUp(HWND hWnd, WORD wParam, LONG lParam)
+{
+ RECT rc;
+
+ ReleaseCapture();
+ GetClientRect(hWnd, &rc);
+ if (PtInRect(&rc, MAKEPOINT(lParam)))
+ NOTIFY_PARENT(hWnd, BN_UNHILITE);
+ InvalidateRect(hWnd, NULL, FALSE);
+ UpdateWindow(hWnd);
+}
+
+static LONG UB_KillFocus(HWND hWnd)
+{
+ InvalidateRect(hWnd, NULL, FALSE);
+ UpdateWindow(hWnd);
+}
diff --git a/controls/combo.c b/controls/combo.c
new file mode 100644
index 0000000..ee90962
--- /dev/null
+++ b/controls/combo.c
@@ -0,0 +1,256 @@
+/*
+ * Interface code to COMBOBOX widget
+ *
+ * Copyright Martin Ayotte, 1993
+ *
+ */
+
+/*
+#define DEBUG_COMBO
+*/
+
+static char Copyright[] = "Copyright Martin Ayotte, 1993";
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include "windows.h"
+#include "combo.h"
+#include "heap.h"
+#include "win.h"
+#include "dirent.h"
+#include <sys/stat.h>
+
+LPHEADCOMBO ComboGetStorageHeader(HWND hwnd);
+int CreateComboStruct(HWND hwnd);
+
+
+void COMBOBOX_CreateComboBox(LPSTR className, LPSTR comboLabel, HWND hwnd)
+{
+ WND *wndPtr = WIN_FindWndPtr(hwnd);
+ WND *parentPtr = WIN_FindWndPtr(wndPtr->hwndParent);
+ DWORD style;
+ char widgetName[15];
+
+#ifdef DEBUG_COMBO
+ printf("combo: label = %s, x = %d, y = %d\n", comboLabel,
+ wndPtr->rectClient.left, wndPtr->rectClient.top);
+ printf(" width = %d, height = %d\n",
+ wndPtr->rectClient.right - wndPtr->rectClient.left,
+ wndPtr->rectClient.bottom - wndPtr->rectClient.top);
+#endif
+
+ if (!wndPtr)
+ return;
+
+ style = wndPtr->dwStyle & 0x0000FFFF;
+/*
+ if ((style & LBS_NOTIFY) == LBS_NOTIFY)
+*/
+ sprintf(widgetName, "%s%d", className, wndPtr->wIDmenu);
+ wndPtr->winWidget = XtVaCreateManagedWidget(widgetName,
+ compositeWidgetClass,
+ parentPtr->winWidget,
+ XtNx, wndPtr->rectClient.left,
+ XtNy, wndPtr->rectClient.top,
+ XtNwidth, wndPtr->rectClient.right -
+ wndPtr->rectClient.left,
+ XtNheight, 16,
+ NULL );
+ GlobalUnlock(hwnd);
+ GlobalUnlock(wndPtr->hwndParent);
+}
+
+
+/***********************************************************************
+ * WIDGETS_ComboWndProc
+ */
+LONG COMBOBOX_ComboBoxWndProc( HWND hwnd, WORD message,
+ WORD wParam, LONG lParam )
+{
+ WORD wRet;
+ RECT rect;
+ int y;
+ int width, height;
+ WND *wndPtr;
+ LPHEADCOMBO lphc;
+ char str[128];
+ static RECT rectsel;
+ switch(message)
+ {
+ case WM_CREATE:
+ CreateComboStruct(hwnd);
+ wndPtr = WIN_FindWndPtr(hwnd);
+ width = wndPtr->rectClient.right - wndPtr->rectClient.left;
+ height = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
+ lphc = ComboGetStorageHeader(hwnd);
+ if (lphc == NULL) return 0;
+ lphc->hWndDrop = CreateWindow("BUTTON", "",
+ WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
+ width - 16, 0, 16, 16, hwnd, 1, wndPtr->hInstance, 0L);
+ lphc->hWndEdit = CreateWindow("STATIC", "",
+ WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT,
+ 0, 0, width - 16, 16, hwnd, 1, wndPtr->hInstance, 0L);
+ lphc->hWndLBox = CreateWindow("LISTBOX", "",
+ WS_CHILD | WS_CLIPCHILDREN | WS_BORDER | WS_VSCROLL | LBS_NOTIFY,
+ wndPtr->rectClient.left, wndPtr->rectClient.top + 16, width, height,
+ wndPtr->hwndParent, 1, wndPtr->hInstance, (LPSTR)MAKELONG(0, hwnd));
+/*
+ ShowWindow(lphc->hWndLBox, SW_HIDE);
+*/
+ InvalidateRect(lphc->hWndEdit, NULL, TRUE);
+ UpdateWindow(lphc->hWndEdit);
+ InvalidateRect(lphc->hWndDrop, NULL, TRUE);
+ UpdateWindow(lphc->hWndDrop);
+#ifdef DEBUG_COMBO
+ printf("Combo Creation Drop=%X LBox=%X!\n", lphc->hWndDrop, lphc->hWndLBox);
+#endif
+ return 0;
+ case WM_DESTROY:
+ lphc = ComboGetStorageHeader(hwnd);
+ DestroyWindow(lphc->hWndDrop);
+ DestroyWindow(lphc->hWndEdit);
+ DestroyWindow(lphc->hWndLBox);
+ free(lphc);
+#ifdef DEBUG_COMBO
+ printf("Combo WM_DESTROY !\n");
+#endif
+ return 0;
+
+ case WM_COMMAND:
+ wndPtr = WIN_FindWndPtr(hwnd);
+ lphc = ComboGetStorageHeader(hwnd);
+ if (lphc == NULL) return 0;
+ if (LOWORD(lParam) == lphc->hWndDrop) {
+ if (HIWORD(lParam) != BN_CLICKED) return 0;
+#ifdef DEBUG_COMBO
+ printf("CB_SHOWDROPDOWN !\n");
+#endif
+ lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN;
+ if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) {
+ ShowWindow(lphc->hWndLBox, SW_SHOW);
+ }
+ else {
+ ShowWindow(lphc->hWndLBox, SW_HIDE);
+ y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
+ SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str);
+ SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str);
+ printf("combo hide\n");
+ }
+ }
+ if (LOWORD(lParam) == lphc->hWndLBox) {
+ switch(HIWORD(lParam))
+ {
+ case LBN_SELCHANGE:
+ lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN;
+ ShowWindow(lphc->hWndLBox, SW_HIDE);
+ y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
+ SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str);
+ SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str);
+ SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu,
+ MAKELONG(hwnd, CBN_SELCHANGE));
+ break;
+ case LBN_DBLCLK:
+ SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu,
+ MAKELONG(hwnd, CBN_DBLCLK));
+ break;
+ }
+ }
+ break;
+ case WM_LBUTTONDOWN:
+ printf("Combo WM_LBUTTONDOWN wParam=%x lParam=%lX !\n", wParam, lParam);
+ break;
+ case WM_KEYDOWN:
+ printf("Combo WM_KEYDOWN wParam %X!\n", wParam);
+ break;
+ case WM_CTLCOLOR:
+ return(SendMessage(GetParent(hwnd), WM_CTLCOLOR, wParam, lParam));
+ case WM_PAINT:
+ lphc = ComboGetStorageHeader(hwnd);
+ InvalidateRect(lphc->hWndEdit, NULL, TRUE);
+ UpdateWindow(lphc->hWndEdit);
+ InvalidateRect(lphc->hWndDrop, NULL, TRUE);
+ UpdateWindow(lphc->hWndDrop);
+ if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) {
+ InvalidateRect(lphc->hWndLBox, NULL, TRUE);
+ UpdateWindow(lphc->hWndLBox);
+ }
+ break;
+ case WM_MOUSEMOVE:
+ if ((wParam & MK_LBUTTON) != 0) {
+ y = HIWORD(lParam);
+ if (y < 4) {
+ lphc = ComboGetStorageHeader(hwnd);
+ }
+ GetClientRect(hwnd, &rect);
+ if (y > (rect.bottom - 4)) {
+ lphc = ComboGetStorageHeader(hwnd);
+ }
+ }
+ case CB_ADDSTRING:
+#ifdef DEBUG_COMBO
+ printf("CB_ADDSTRING '%s' !\n", (LPSTR)lParam);
+#endif
+ lphc = ComboGetStorageHeader(hwnd);
+ return(SendMessage(lphc->hWndLBox, LB_ADDSTRING, wParam, lParam));
+ case CB_GETLBTEXT:
+ printf("CB_GETLBTEXT #%u !\n", wParam);
+ lphc = ComboGetStorageHeader(hwnd);
+ return(SendMessage(lphc->hWndLBox, LB_GETTEXT, wParam, lParam));
+ case CB_INSERTSTRING:
+ printf("CB_INSERTSTRING '%s' !\n", (LPSTR)lParam);
+ lphc = ComboGetStorageHeader(hwnd);
+ return(SendMessage(lphc->hWndLBox, LB_INSERTSTRING, wParam, lParam));
+ case CB_DELETESTRING:
+ printf("CB_DELETESTRING #%u !\n", wParam);
+ lphc = ComboGetStorageHeader(hwnd);
+ return(SendMessage(lphc->hWndLBox, LB_DELETESTRING, wParam, 0L));
+ case CB_RESETCONTENT:
+ printf("CB_RESETCONTENT !\n");
+ lphc = ComboGetStorageHeader(hwnd);
+ return(SendMessage(lphc->hWndLBox, LB_RESETCONTENT, 0, 0L));
+ case CB_DIR:
+ printf("ComboBox CB_DIR !\n");
+ return(SendMessage(lphc->hWndLBox, LB_DIR, wParam, lParam));
+ case CB_FINDSTRING:
+ return(SendMessage(lphc->hWndLBox, LB_FINDSTRING, wParam, lParam));
+ case CB_GETCOUNT:
+ return(SendMessage(lphc->hWndLBox, LB_GETCOUNT, 0, 0L));
+ case CB_GETCURSEL:
+ printf("ComboBox CB_GETCURSEL !\n");
+ return(SendMessage(lphc->hWndLBox, LB_GETCOUNT, 0, 0L));
+ case CB_SETCURSEL:
+ printf("ComboBox CB_SETCURSEL wParam=%x !\n", wParam);
+ return(SendMessage(lphc->hWndLBox, LB_GETCOUNT, wParam, 0L));
+
+ default:
+ return DefWindowProc( hwnd, message, wParam, lParam );
+ }
+return 0;
+}
+
+
+
+LPHEADCOMBO ComboGetStorageHeader(HWND hwnd)
+{
+ WND *wndPtr;
+ LPHEADCOMBO lphc;
+ wndPtr = WIN_FindWndPtr(hwnd);
+ lphc = *((LPHEADCOMBO *)&wndPtr->wExtra[1]);
+ return lphc;
+}
+
+
+
+int CreateComboStruct(HWND hwnd)
+{
+ WND *wndPtr;
+ LPHEADCOMBO lphc;
+ wndPtr = WIN_FindWndPtr(hwnd);
+ lphc = (LPHEADCOMBO)malloc(sizeof(HEADCOMBO));
+ *((LPHEADCOMBO *)&wndPtr->wExtra[1]) = lphc;
+ lphc->dwState = 0;
+ return TRUE;
+}
+
+
+
diff --git a/controls/listbox.c b/controls/listbox.c
new file mode 100644
index 0000000..dc2ae49
--- /dev/null
+++ b/controls/listbox.c
@@ -0,0 +1,963 @@
+/*
+ * Interface code to listbox widgets
+ *
+ * Copyright Martin Ayotte, 1993
+ *
+ */
+
+/*
+#define DEBUG_LISTBOX
+*/
+
+static char Copyright[] = "Copyright Martin Ayotte, 1993";
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include "windows.h"
+#include "user.h"
+#include "heap.h"
+#include "win.h"
+#include "listbox.h"
+#include "scroll.h"
+#include "dirent.h"
+#include <sys/stat.h>
+
+#define GMEM_ZEROINIT 0x0040
+
+
+LPHEADLIST ListBoxGetWindowAndStorage(HWND hwnd, WND **wndPtr);
+LPHEADLIST ListBoxGetStorageHeader(HWND hwnd);
+void StdDrawListBox(HWND hwnd);
+void OwnerDrawListBox(HWND hwnd);
+int ListBoxFindMouse(HWND hwnd, int X, int Y);
+int CreateListBoxStruct(HWND hwnd);
+int ListBoxAddString(HWND hwnd, LPSTR newstr);
+int ListBoxInsertString(HWND hwnd, UINT uIndex, LPSTR newstr);
+int ListBoxGetText(HWND hwnd, UINT uIndex, LPSTR OutStr);
+int ListBoxDeleteString(HWND hwnd, UINT uIndex);
+int ListBoxFindString(HWND hwnd, UINT nFirst, LPSTR MatchStr);
+int ListBoxResetContent(HWND hwnd);
+int ListBoxSetCurSel(HWND hwnd, WORD wIndex);
+int ListBoxSetSel(HWND hwnd, WORD wIndex);
+int ListBoxDirectory(HWND hwnd, UINT attrib, LPSTR filespec);
+int ListBoxGetItemRect(HWND hwnd, WORD wIndex, LPRECT rect);
+int ListBoxSetItemHeight(HWND hwnd, WORD wIndex, long height);
+int ListBoxDefaultItem(HWND hwnd, WND *wndPtr,
+ LPHEADLIST lphl, LPLISTSTRUCT lpls);
+int ListBoxFindNextMatch(HWND hwnd, WORD wChar);
+
+
+
+void LISTBOX_CreateListBox(LPSTR className, LPSTR listboxLabel, HWND hwnd)
+{
+ WND *wndPtr = WIN_FindWndPtr(hwnd);
+ WND *parentPtr = WIN_FindWndPtr(wndPtr->hwndParent);
+ DWORD style;
+ char widgetName[15];
+
+#ifdef DEBUG_LISTBOX
+ printf("listbox: label = %s, x = %d, y = %d\n", listboxLabel,
+ wndPtr->rectClient.left, wndPtr->rectClient.top);
+ printf(" width = %d, height = %d\n",
+ wndPtr->rectClient.right - wndPtr->rectClient.left,
+ wndPtr->rectClient.bottom - wndPtr->rectClient.top);
+#endif
+
+ if (!wndPtr)
+ return;
+
+ style = wndPtr->dwStyle & 0x0000FFFF;
+/*
+ if ((style & LBS_NOTIFY) == LBS_NOTIFY)
+ if ((style & LBS_SORT) == LBS_SORT)
+*/
+ sprintf(widgetName, "%s%d", className, wndPtr->wIDmenu);
+ wndPtr->winWidget = XtVaCreateManagedWidget(widgetName,
+ compositeWidgetClass,
+ parentPtr->winWidget,
+ XtNx, wndPtr->rectClient.left,
+ XtNy, wndPtr->rectClient.top,
+ XtNwidth, wndPtr->rectClient.right -
+ wndPtr->rectClient.left,
+ XtNheight, wndPtr->rectClient.bottom -
+ wndPtr->rectClient.top,
+ NULL );
+ GlobalUnlock(hwnd);
+ GlobalUnlock(wndPtr->hwndParent);
+}
+
+
+
+/***********************************************************************
+ * WIDGETS_ListBoxWndProc
+ */
+LONG LISTBOX_ListBoxWndProc( HWND hwnd, WORD message,
+ WORD wParam, LONG lParam )
+{
+ WND *wndPtr;
+ LPHEADLIST lphl;
+ WORD wRet;
+ RECT rect;
+ int y;
+ int width, height;
+ CREATESTRUCT *createStruct;
+ static RECT rectsel;
+ switch(message)
+ {
+ case WM_CREATE:
+ CreateListBoxStruct(hwnd);
+ lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
+ createStruct = (CREATESTRUCT *)lParam;
+ if (HIWORD(createStruct->lpCreateParams) != 0)
+ lphl->hWndLogicParent = (HWND)HIWORD(createStruct->lpCreateParams);
+ else
+ lphl->hWndLogicParent = GetParent(hwnd);
+ width = wndPtr->rectClient.right - wndPtr->rectClient.left;
+ height = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
+ lphl->hWndScroll = CreateWindow("SCROLLBAR", "",
+ WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBS_VERT,
+ width - 17, 0, 16, height, hwnd, 1, wndPtr->hInstance, NULL);
+ ShowWindow(lphl->hWndScroll, SW_HIDE);
+ SetScrollRange(lphl->hWndScroll, WM_VSCROLL, 1, lphl->ItemsCount, TRUE);
+ return 0;
+ case WM_DESTROY:
+ lphl = ListBoxGetStorageHeader(hwnd);
+ ListBoxResetContent(hwnd);
+ DestroyWindow(lphl->hWndScroll);
+ free(lphl);
+ printf("ListBox WM_DESTROY !\n");
+ return 0;
+
+ case WM_VSCROLL:
+ lphl = ListBoxGetStorageHeader(hwnd);
+ if (lphl == NULL) return 0;
+ y = lphl->FirstVisible;
+ switch(wParam) {
+ case SB_LINEUP:
+ if (lphl->FirstVisible > 1)
+ lphl->FirstVisible--;
+ break;
+ case SB_LINEDOWN:
+ if (lphl->FirstVisible < lphl->ItemsCount)
+ lphl->FirstVisible++;
+ break;
+ case SB_PAGEUP:
+ if (lphl->FirstVisible > 1)
+ lphl->FirstVisible -= lphl->ItemsVisible;
+ break;
+ case SB_PAGEDOWN:
+ if (lphl->FirstVisible < lphl->ItemsCount)
+ lphl->FirstVisible += lphl->ItemsVisible;
+ break;
+ case SB_THUMBTRACK:
+ lphl->FirstVisible = LOWORD(lParam);
+ break;
+ }
+ if (lphl->FirstVisible < 1) lphl->FirstVisible = 1;
+ if (lphl->FirstVisible > lphl->ItemsCount)
+ lphl->FirstVisible = lphl->ItemsCount;
+ if (y != lphl->FirstVisible) {
+ SetScrollPos(lphl->hWndScroll, WM_VSCROLL, lphl->FirstVisible, TRUE);
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ }
+ return 0;
+
+ case WM_LBUTTONDOWN:
+ lphl = ListBoxGetStorageHeader(hwnd);
+ if (lphl == NULL) return 0;
+ lphl->PrevSelected = lphl->ItemSelected;
+ wRet = ListBoxFindMouse(hwnd, LOWORD(lParam), HIWORD(lParam));
+ ListBoxSetCurSel(hwnd, wRet);
+ ListBoxGetItemRect(hwnd, wRet, &rectsel);
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ return 0;
+ case WM_LBUTTONUP:
+ lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
+ if (lphl == NULL) return 0;
+ if (lphl->PrevSelected != lphl->ItemSelected)
+ SendMessage(lphl->hWndLogicParent, WM_COMMAND, wndPtr->wIDmenu,
+ MAKELONG(hwnd, LBN_SELCHANGE));
+ return 0;
+ case WM_RBUTTONUP:
+ case WM_LBUTTONDBLCLK:
+ lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
+ if (lphl == NULL) return 0;
+ SendMessage(lphl->hWndLogicParent, WM_COMMAND, wndPtr->wIDmenu,
+ MAKELONG(hwnd, LBN_DBLCLK));
+ printf("ListBox Send LBN_DBLCLK !\n");
+ return 0;
+ case WM_KEYDOWN:
+ printf("ListBox WM_KEYDOWN wParam %X!\n", wParam);
+ ListBoxFindNextMatch(hwnd, wParam);
+ break;
+ case WM_PAINT:
+ wndPtr = WIN_FindWndPtr(hwnd);
+ if ((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) == LBS_OWNERDRAWFIXED) {
+ OwnerDrawListBox(hwnd);
+ break;
+ }
+ if ((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE) {
+ OwnerDrawListBox(hwnd);
+ break;
+ }
+ StdDrawListBox(hwnd);
+ break;
+ case WM_MOUSEMOVE:
+ if ((wParam & MK_LBUTTON) != 0) {
+ y = HIWORD(lParam);
+ if (y < 4) {
+ lphl = ListBoxGetStorageHeader(hwnd);
+ if (lphl->FirstVisible > 1) {
+ lphl->FirstVisible--;
+ SetScrollPos(lphl->hWndScroll, WM_VSCROLL, lphl->FirstVisible, TRUE);
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ break;
+ }
+ }
+ GetClientRect(hwnd, &rect);
+ if (y > (rect.bottom - 4)) {
+ lphl = ListBoxGetStorageHeader(hwnd);
+ if (lphl->FirstVisible < lphl->ItemsCount) {
+ lphl->FirstVisible++;
+ SetScrollPos(lphl->hWndScroll, WM_VSCROLL, lphl->FirstVisible, TRUE);
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ break;
+ }
+ }
+ if ((y > 0) && (y < (rect.bottom - 4))) {
+ if ((y < rectsel.top) || (y > rectsel.bottom)) {
+ wRet = ListBoxFindMouse(hwnd, LOWORD(lParam), HIWORD(lParam));
+ ListBoxSetCurSel(hwnd, wRet);
+ ListBoxGetItemRect(hwnd, wRet, &rectsel);
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ }
+
+ }
+ }
+ break;
+
+ case LB_RESETCONTENT:
+ printf("ListBox LB_RESETCONTENT !\n");
+ ListBoxResetContent(hwnd);
+ return 0;
+ case LB_DIR:
+ printf("ListBox LB_DIR !\n");
+ wRet = ListBoxDirectory(hwnd, wParam, (LPSTR)lParam);
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ return wRet;
+ case LB_ADDSTRING:
+ wRet = ListBoxAddString(hwnd, (LPSTR)lParam);
+ return wRet;
+ case LB_GETTEXT:
+ wRet = ListBoxGetText(hwnd, wParam, (LPSTR)lParam);
+ printf("ListBox LB_GETTEXT #%u '%s' !\n", wParam, (LPSTR)lParam);
+ return wRet;
+ case LB_INSERTSTRING:
+ wRet = ListBoxInsertString(hwnd, wParam, (LPSTR)lParam);
+ return wRet;
+ case LB_DELETESTRING:
+ printf("ListBox LB_DELETESTRING #%u !\n", wParam);
+ wRet = ListBoxDeleteString(hwnd, wParam);
+ return wRet;
+ case LB_FINDSTRING:
+ wRet = ListBoxFindString(hwnd, wParam, (LPSTR)lParam);
+ return wRet;
+ case LB_GETCARETINDEX:
+ return wRet;
+ case LB_GETCOUNT:
+ lphl = ListBoxGetStorageHeader(hwnd);
+ return lphl->ItemsCount;
+ case LB_GETCURSEL:
+ lphl = ListBoxGetStorageHeader(hwnd);
+ printf("ListBox LB_GETCURSEL %u !\n", lphl->ItemSelected);
+ if (lphl->ItemSelected == 0) return LB_ERR;
+ return lphl->ItemSelected;
+ case LB_GETHORIZONTALEXTENT:
+ return wRet;
+ case LB_GETITEMDATA:
+ return wRet;
+ case LB_GETITEMHEIGHT:
+ return wRet;
+ case LB_GETITEMRECT:
+ return wRet;
+ case LB_GETSEL:
+ return wRet;
+ case LB_GETSELCOUNT:
+ return wRet;
+ case LB_GETSELITEMS:
+ return wRet;
+ case LB_GETTEXTLEN:
+ return wRet;
+ case LB_GETTOPINDEX:
+ return wRet;
+ case LB_SELECTSTRING:
+ return wRet;
+ case LB_SELITEMRANGE:
+ return wRet;
+ case LB_SETCARETINDEX:
+ return wRet;
+ case LB_SETCOLUMNWIDTH:
+ return wRet;
+ case LB_SETHORIZONTALEXTENT:
+ return wRet;
+ case LB_SETITEMDATA:
+ return wRet;
+ case LB_SETTABSTOPS:
+ return wRet;
+ case LB_SETCURSEL:
+#ifdef DEBUG_LISTBOX
+ printf("ListBox LB_SETCURSEL wParam=%x !\n", wParam);
+#endif
+ wRet = ListBoxSetCurSel(hwnd, wParam);
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ return wRet;
+ case LB_SETSEL:
+ printf("ListBox LB_SETSEL wParam=%x lParam=%lX !\n", wParam, lParam);
+ wRet = ListBoxSetSel(hwnd, wParam);
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ return wRet;
+ case LB_SETTOPINDEX:
+ printf("ListBox LB_SETTOPINDEX wParam=%x !\n", wParam);
+ lphl = ListBoxGetStorageHeader(hwnd);
+ lphl->FirstVisible = wParam;
+ SetScrollPos(lphl->hWndScroll, WM_VSCROLL, lphl->FirstVisible, TRUE);
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ break;
+ case LB_SETITEMHEIGHT:
+#ifdef DEBUG_LISTBOX
+ printf("ListBox LB_SETITEMHEIGHT wParam=%x lParam=%lX !\n", wParam, lParam);
+#endif
+ wRet = ListBoxSetItemHeight(hwnd, wParam, lParam);
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ return wRet;
+
+ default:
+ return DefWindowProc( hwnd, message, wParam, lParam );
+ }
+return 0;
+}
+
+
+LPHEADLIST ListBoxGetWindowAndStorage(HWND hwnd, WND **wndPtr)
+{
+ WND *Ptr;
+ LPHEADLIST lphl;
+ *(wndPtr) = Ptr = WIN_FindWndPtr(hwnd);
+ lphl = *((LPHEADLIST *)&Ptr->wExtra[1]);
+ return lphl;
+}
+
+
+LPHEADLIST ListBoxGetStorageHeader(HWND hwnd)
+{
+ WND *wndPtr;
+ LPHEADLIST lphl;
+ wndPtr = WIN_FindWndPtr(hwnd);
+ lphl = *((LPHEADLIST *)&wndPtr->wExtra[1]);
+ return lphl;
+}
+
+
+void StdDrawListBox(HWND hwnd)
+{
+ LPHEADLIST lphl;
+ LPLISTSTRUCT lpls;
+ PAINTSTRUCT ps;
+ HBRUSH hBrush;
+ HWND hWndParent;
+ HDC hdc;
+ RECT rect;
+ UINT i, h, h2;
+ char C[128];
+ h = 0;
+ hdc = BeginPaint( hwnd, &ps );
+ GetClientRect(hwnd, &rect);
+ lphl = ListBoxGetStorageHeader(hwnd);
+ if (lphl == NULL) goto EndOfPaint;
+ hBrush = SendMessage(lphl->hWndLogicParent, WM_CTLCOLOR, (WORD)hdc,
+ MAKELONG(hwnd, CTLCOLOR_LISTBOX));
+ if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(WHITE_BRUSH);
+ if (lphl->ItemsCount > lphl->ItemsVisible) rect.right -= 16;
+ FillRect(hdc, &rect, hBrush);
+ if (lphl->ItemsCount == 0) goto EndOfPaint;
+ lpls = lphl->lpFirst;
+ if (lpls == NULL) goto EndOfPaint;
+ lphl->ItemsVisible = 0;
+ for(i = 1; i <= lphl->ItemsCount; i++) {
+ if (i >= lphl->FirstVisible) {
+ h2 = lpls->dis.rcItem.bottom - lpls->dis.rcItem.top;
+ lpls->dis.rcItem.top = h;
+ lpls->dis.rcItem.bottom = h + h2;
+ lpls->dis.rcItem.right = rect.right;
+ TextOut(hdc, 5, h + 2, (char *)lpls->dis.itemData,
+ strlen((char *)lpls->dis.itemData));
+ if (lpls->dis.itemState != 0) {
+ InvertRect(hdc, &lpls->dis.rcItem);
+ }
+ h += h2;
+ lphl->ItemsVisible++;
+ if (h > rect.bottom) break;
+ }
+ if (lpls->lpNext == NULL) goto EndOfPaint;
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ }
+EndOfPaint:
+ EndPaint( hwnd, &ps );
+ if (lphl->ItemsCount > lphl->ItemsVisible) {
+ InvalidateRect(lphl->hWndScroll, NULL, TRUE);
+ UpdateWindow(lphl->hWndScroll);
+ }
+}
+
+
+
+void OwnerDrawListBox(HWND hwnd)
+{
+ LPHEADLIST lphl;
+ LPLISTSTRUCT lpls;
+ HANDLE hTemp;
+ PAINTSTRUCT ps;
+ HBRUSH hBrush;
+ HWND hWndParent;
+ HDC hdc;
+ RECT rect;
+ UINT i, h, h2;
+ char C[128];
+ h = 0;
+ hdc = BeginPaint( hwnd, &ps );
+ GetClientRect(hwnd, &rect);
+ lphl = ListBoxGetStorageHeader(hwnd);
+ if (lphl == NULL) goto EndOfPaint;
+ hBrush = SendMessage(lphl->hWndLogicParent, WM_CTLCOLOR, (WORD)hdc,
+ MAKELONG(hwnd, CTLCOLOR_LISTBOX));
+ if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(WHITE_BRUSH);
+ if (lphl->ItemsCount > lphl->ItemsVisible) rect.right -= 16;
+ FillRect(hdc, &rect, hBrush);
+ if (lphl->ItemsCount == 0) goto EndOfPaint;
+ lpls = lphl->lpFirst;
+ if (lpls == NULL) goto EndOfPaint;
+ lphl->ItemsVisible = 0;
+ for(i = 1; i <= lphl->ItemsCount; i++) {
+ if (i >= lphl->FirstVisible) {
+ lpls->dis.hDC = hdc;
+ lpls->dis.itemID = i;
+ h2 = lpls->dis.rcItem.bottom - lpls->dis.rcItem.top;
+ lpls->dis.rcItem.top = h;
+ lpls->dis.rcItem.bottom = h + h2;
+ lpls->dis.rcItem.right = rect.right;
+ lpls->dis.itemAction = ODA_DRAWENTIRE;
+ if (lpls->dis.itemState != 0) {
+ lpls->dis.itemAction |= ODA_SELECT;
+ }
+#ifdef DEBUT_LISTBOX
+ printf("LBOX WM_DRAWITEM #%d left=%d top=%d right=%d bottom=%d !\n",
+ i, lpls->dis.rcItem.left, lpls->dis.rcItem.top,
+ lpls->dis.rcItem.right, lpls->dis.rcItem.bottom);
+ printf("LBOX WM_DRAWITEM Parent=%X &dis=%lX CtlID=%u !\n",
+ hWndParent, (LONG)&lpls->dis, lpls->dis.CtlID);
+#endif
+ printf("LBOX WM_DRAWITEM '%s' !\n", lpls->dis.itemData);
+ SendMessage(lphl->hWndLogicParent, WM_DRAWITEM, i, (LPARAM)&lpls->dis);
+ GlobalUnlock(hTemp);
+ GlobalFree(hTemp);
+ if (lpls->dis.itemState != 0) {
+ InvertRect(hdc, &lpls->dis.rcItem);
+ }
+ h += h2;
+ lphl->ItemsVisible++;
+ if (h > rect.bottom) break;
+ }
+ if (lpls->lpNext == NULL) goto EndOfPaint;
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ }
+EndOfPaint:
+ EndPaint( hwnd, &ps );
+ if (lphl->ItemsCount > lphl->ItemsVisible) {
+ InvalidateRect(lphl->hWndScroll, NULL, TRUE);
+ UpdateWindow(lphl->hWndScroll);
+ }
+}
+
+
+
+int ListBoxFindMouse(HWND hwnd, int X, int Y)
+{
+LPHEADLIST lphl;
+LPLISTSTRUCT lpls;
+RECT rect;
+UINT i, h, h2;
+char C[128];
+h = 0;
+lphl = ListBoxGetStorageHeader(hwnd);
+if (lphl == NULL) return LB_ERR;
+if (lphl->ItemsCount == 0) return LB_ERR;
+lpls = lphl->lpFirst;
+if (lpls == NULL) return LB_ERR;
+for(i = 1; i <= lphl->ItemsCount; i++) {
+ if (i >= lphl->FirstVisible) {
+ h2 = h;
+ h += lpls->dis.rcItem.bottom - lpls->dis.rcItem.top;
+ if ((Y > h2) && (Y < h)) return(i);
+ }
+ if (lpls->lpNext == NULL) return LB_ERR;
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ }
+return(LB_ERR);
+}
+
+
+
+int CreateListBoxStruct(HWND hwnd)
+{
+ WND *wndPtr;
+ LPHEADLIST lphl;
+ wndPtr = WIN_FindWndPtr(hwnd);
+ lphl = (LPHEADLIST)malloc(sizeof(HEADLIST));
+ lphl->lpFirst = NULL;
+ *((LPHEADLIST *)&wndPtr->wExtra[1]) = lphl; /* HEAD of List */
+ lphl->ItemsCount = 0;
+ lphl->ItemsVisible = 0;
+ lphl->FirstVisible = 1;
+ lphl->StdItemHeight = 15;
+ lphl->DrawCtlType = ODT_LISTBOX;
+ return TRUE;
+}
+
+
+int ListBoxAddString(HWND hwnd, LPSTR newstr)
+{
+ WND *wndPtr;
+ LPHEADLIST lphl;
+ LPLISTSTRUCT lpls, lplsnew;
+ HANDLE hTemp;
+ LPSTR str;
+ lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
+ if (lphl == NULL) return LB_ERR;
+ hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(LISTSTRUCT));
+ lplsnew = (LPLISTSTRUCT) USER_HEAP_ADDR(hTemp);
+ lpls = lphl->lpFirst;
+ if (lpls != NULL) {
+ while(lpls->lpNext != NULL) {
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ }
+ lpls->lpNext = lplsnew;
+ }
+ else
+ lphl->lpFirst = lplsnew;
+ lphl->ItemsCount++;
+#ifdef DEBUG_LISTBOX
+ printf("Items Count = %u\n", lphl->ItemsCount);
+#endif
+ hTemp = 0;
+ if ((wndPtr->dwStyle & LBS_HASSTRINGS) != LBS_HASSTRINGS) {
+ if (((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) != LBS_OWNERDRAWFIXED) &&
+ ((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) != LBS_OWNERDRAWVARIABLE)) {
+ hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, strlen(newstr) + 1);
+ str = (LPSTR)USER_HEAP_ADDR(hTemp);
+ if (str == NULL) return LB_ERRSPACE;
+ strcpy(str, newstr);
+ newstr = str;
+ }
+ }
+ ListBoxDefaultItem(hwnd, wndPtr, lphl, lplsnew);
+ lplsnew->hMem = hTemp;
+ lplsnew->lpNext = NULL;
+ lplsnew->dis.itemID = lphl->ItemsCount;
+ lplsnew->dis.itemData = (DWORD)newstr;
+ lplsnew->hData = hTemp;
+ SetScrollRange(lphl->hWndScroll, WM_VSCROLL, 1, lphl->ItemsCount, TRUE);
+ if (lphl->FirstVisible >= (lphl->ItemsCount - lphl->ItemsVisible)) {
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ }
+ if ((lphl->ItemsCount - lphl->FirstVisible) == lphl->ItemsVisible)
+ ShowWindow(lphl->hWndScroll, SW_NORMAL);
+ return lphl->ItemsCount;
+}
+
+
+int ListBoxInsertString(HWND hwnd, UINT uIndex, LPSTR newstr)
+{
+ WND *wndPtr;
+ LPHEADLIST lphl;
+ LPLISTSTRUCT lpls, lplsnew;
+ HANDLE hTemp;
+ LPSTR str;
+ UINT Count;
+ lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
+ if (lphl == NULL) return LB_ERR;
+ if (uIndex < 1 || uIndex > lphl->ItemsCount) return LB_ERR;
+ lpls = lphl->lpFirst;
+ if (lpls == NULL) return LB_ERR;
+ if (uIndex > lphl->ItemsCount) return LB_ERR;
+ for(Count = 1; Count < uIndex; Count++) {
+ if (lpls->lpNext == NULL) return LB_ERR;
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ }
+ hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(LISTSTRUCT));
+ lplsnew = (LPLISTSTRUCT) USER_HEAP_ADDR(hTemp);
+ ListBoxDefaultItem(hwnd, wndPtr, lphl, lplsnew);
+ lplsnew->hMem = hTemp;
+ lpls->lpNext = lplsnew;
+ lphl->ItemsCount++;
+ hTemp = 0;
+ if ((wndPtr->dwStyle & LBS_HASSTRINGS) != LBS_HASSTRINGS) {
+ if (((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) != LBS_OWNERDRAWFIXED) &&
+ ((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) != LBS_OWNERDRAWVARIABLE)) {
+ hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, strlen(newstr) + 1);
+ str = (LPSTR)USER_HEAP_ADDR(hTemp);
+ if (str == NULL) return LB_ERRSPACE;
+ strcpy(str, newstr);
+ newstr = str;
+ }
+ }
+ lplsnew->lpNext = NULL;
+ lplsnew->dis.itemID = lphl->ItemsCount;
+ lplsnew->dis.itemData = (DWORD)newstr;
+ lplsnew->hData = hTemp;
+ SetScrollRange(lphl->hWndScroll, WM_VSCROLL, 1, lphl->ItemsCount, TRUE);
+ if (((lphl->ItemsCount - lphl->FirstVisible) == lphl->ItemsVisible) &&
+ (lphl->ItemsVisible != 0))
+ ShowWindow(lphl->hWndScroll, SW_NORMAL);
+ if ((lphl->FirstVisible <= uIndex) &&
+ ((lphl->FirstVisible + lphl->ItemsVisible) >= uIndex)) {
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ }
+ return lphl->ItemsCount;
+}
+
+
+int ListBoxGetText(HWND hwnd, UINT uIndex, LPSTR OutStr)
+{
+ WND *wndPtr;
+ LPHEADLIST lphl;
+ LPLISTSTRUCT lpls;
+ UINT Count;
+ lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
+ if (lphl == NULL) return LB_ERR;
+ if (uIndex < 1 || uIndex > lphl->ItemsCount) return LB_ERR;
+ lpls = lphl->lpFirst;
+ if (lpls == NULL) return LB_ERR;
+ if (uIndex > lphl->ItemsCount) return LB_ERR;
+ for(Count = 1; Count < uIndex; Count++) {
+ if (lpls->lpNext == NULL) return LB_ERR;
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ }
+ if (((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) == LBS_OWNERDRAWFIXED) ||
+ ((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE)) {
+ if ((wndPtr->dwStyle & LBS_HASSTRINGS) != LBS_HASSTRINGS) {
+ *((long *)OutStr) = lpls->dis.itemData;
+ return 4;
+ }
+ }
+
+ strcpy(OutStr, (char *)lpls->dis.itemData);
+ return strlen(OutStr);
+}
+
+
+int ListBoxDeleteString(HWND hwnd, UINT uIndex)
+{
+ LPHEADLIST lphl;
+ LPLISTSTRUCT lpls, lpls2;
+ UINT Count;
+ lphl = ListBoxGetStorageHeader(hwnd);
+ if (lphl == NULL) return LB_ERR;
+ if (uIndex < 1 || uIndex > lphl->ItemsCount) return LB_ERR;
+ lpls = lphl->lpFirst;
+ if (lpls == NULL) return LB_ERR;
+ if (uIndex > lphl->ItemsCount) return LB_ERR;
+ for(Count = 1; Count < uIndex; Count++) {
+ if (lpls->lpNext == NULL) return LB_ERR;
+ lpls2 = lpls;
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ }
+ lpls2->lpNext = (LPLISTSTRUCT)lpls->lpNext;
+ lphl->ItemsCount--;
+ if (lpls->hData != 0) USER_HEAP_FREE(lpls->hData);
+ if (lpls->hMem != 0) USER_HEAP_FREE(lpls->hMem);
+ SetScrollRange(lphl->hWndScroll, WM_VSCROLL, 1, lphl->ItemsCount, TRUE);
+ if (lphl->ItemsCount < lphl->ItemsVisible)
+ ShowWindow(lphl->hWndScroll, SW_HIDE);
+ if ((lphl->FirstVisible <= uIndex) &&
+ ((lphl->FirstVisible + lphl->ItemsVisible) >= uIndex)) {
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ }
+ return lphl->ItemsCount;
+}
+
+
+int ListBoxFindString(HWND hwnd, UINT nFirst, LPSTR MatchStr)
+{
+ LPHEADLIST lphl;
+ LPLISTSTRUCT lpls;
+ UINT Count;
+ lphl = ListBoxGetStorageHeader(hwnd);
+ if (lphl == NULL) return LB_ERR;
+ if (nFirst < 1 || nFirst > lphl->ItemsCount) return LB_ERR;
+ lpls = lphl->lpFirst;
+ if (lpls == NULL) return LB_ERR;
+ Count = 1;
+ while(lpls != NULL) {
+ if (strcmp((char *)lpls->dis.itemData, MatchStr) == 0)
+ return Count;
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ Count++;
+ }
+ return LB_ERR;
+}
+
+
+int ListBoxResetContent(HWND hwnd)
+{
+ WND *wndPtr;
+ LPHEADLIST lphl;
+ LPLISTSTRUCT lpls, lpls2;
+ UINT i;
+ lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
+ if (lphl == NULL) return LB_ERR;
+ lpls = lphl->lpFirst;
+ if (lpls == NULL) return LB_ERR;
+ for(i = 0; i <= lphl->ItemsCount; i++) {
+ lpls2 = lpls;
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ if (i != 0) {
+#ifdef DEBUG_LISTBOX
+ printf("ResetContent #%u\n", i);
+#endif
+ if (lpls2->hData != 0) USER_HEAP_FREE(lpls->hData);
+ if (lpls2->hMem != 0) USER_HEAP_FREE(lpls->hMem);
+ }
+ if (lpls == NULL) break;
+ }
+ lphl->lpFirst = NULL;
+ lphl->FirstVisible = 1;
+ lphl->ItemsCount = 0;
+ lphl->ItemSelected = 0;
+ lphl->PrevSelected = 0;
+ if ((wndPtr->dwStyle && LBS_NOTIFY) != 0)
+ SendMessage(wndPtr->hwndParent, WM_COMMAND,
+ wndPtr->wIDmenu, MAKELONG(hwnd, LBN_SELCHANGE));
+
+ SetScrollRange(lphl->hWndScroll, WM_VSCROLL, 1, lphl->ItemsCount, TRUE);
+ ShowWindow(lphl->hWndScroll, SW_HIDE);
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ return TRUE;
+}
+
+
+int ListBoxSetCurSel(HWND hwnd, WORD wIndex)
+{
+ WND *wndPtr;
+ LPHEADLIST lphl;
+ LPLISTSTRUCT lpls, lpls2;
+ UINT i;
+ lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
+ if (lphl == NULL) return LB_ERR;
+ lphl->ItemSelected = LB_ERR;
+ if (wIndex < 1 || wIndex > lphl->ItemsCount) return LB_ERR;
+ lpls = lphl->lpFirst;
+ if (lpls == NULL) return LB_ERR;
+ for(i = 1; i <= lphl->ItemsCount; i++) {
+ lpls2 = lpls;
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ if (i == wIndex)
+ lpls2->dis.itemState = 1;
+ else
+ if (lpls2->dis.itemState != 0)
+ lpls2->dis.itemState = 0;
+ if (lpls == NULL) break;
+ }
+ lphl->ItemSelected = wIndex;
+ if ((wndPtr->dwStyle && LBS_NOTIFY) != 0)
+ SendMessage(wndPtr->hwndParent, WM_COMMAND,
+ wndPtr->wIDmenu, MAKELONG(hwnd, LBN_SELCHANGE));
+ return LB_ERR;
+}
+
+
+
+int ListBoxSetSel(HWND hwnd, WORD wIndex)
+{
+ LPHEADLIST lphl;
+ LPLISTSTRUCT lpls, lpls2;
+ UINT i;
+ lphl = ListBoxGetStorageHeader(hwnd);
+ if (lphl == NULL) return LB_ERR;
+ if (wIndex < 1 || wIndex > lphl->ItemsCount) return LB_ERR;
+ lpls = lphl->lpFirst;
+ if (lpls == NULL) return LB_ERR;
+ for(i = 1; i <= lphl->ItemsCount; i++) {
+ lpls2 = lpls;
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ if (i == wIndex) {
+ lpls2->dis.itemState = 1;
+ break;
+ }
+ if (lpls == NULL) break;
+ }
+ return LB_ERR;
+}
+
+
+int ListBoxDirectory(HWND hwnd, UINT attrib, LPSTR filespec)
+{
+DIR *dirp;
+struct dirent *dp;
+struct stat st;
+char str[128];
+int wRet;
+dirp = opendir(".");
+while ( (dp = readdir(dirp)) != NULL)
+ {
+ stat(dp->d_name, &st);
+#ifdef DEBUG_LBDIR
+ printf("LB_DIR : st_mode=%lX / d_name='%s'\n", st.st_mode, dp->d_name);
+#endif
+ if S_ISDIR(st.st_mode) {
+ sprintf(str, "[%s]", dp->d_name);
+ }
+ else
+ strcpy(str, dp->d_name);
+ wRet = ListBoxAddString(hwnd, str);
+ if (wRet == LB_ERR) break;
+ }
+closedir(dirp);
+return wRet;
+}
+
+
+int ListBoxGetItemRect(HWND hwnd, WORD wIndex, LPRECT lprect)
+{
+ LPHEADLIST lphl;
+ LPLISTSTRUCT lpls, lpls2;
+ UINT i;
+ lphl = ListBoxGetStorageHeader(hwnd);
+ if (lphl == NULL) return LB_ERR;
+ if (wIndex < 1 || wIndex > lphl->ItemsCount) return LB_ERR;
+ lpls = lphl->lpFirst;
+ if (lpls == NULL) return LB_ERR;
+ for(i = 0; i <= lphl->ItemsCount; i++) {
+ lpls2 = lpls;
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ if (i == wIndex) {
+ *(lprect) = lpls2->dis.rcItem;
+ break;
+ }
+ if (lpls == NULL) break;
+ }
+ return LB_ERR;
+}
+
+
+
+int ListBoxSetItemHeight(HWND hwnd, WORD wIndex, long height)
+{
+ LPHEADLIST lphl;
+ LPLISTSTRUCT lpls, lpls2;
+ UINT i;
+ lphl = ListBoxGetStorageHeader(hwnd);
+ if (lphl == NULL) return LB_ERR;
+ if (wIndex < 1 || wIndex > lphl->ItemsCount) return LB_ERR;
+ lpls = lphl->lpFirst;
+ if (lpls == NULL) return LB_ERR;
+ for(i = 0; i <= lphl->ItemsCount; i++) {
+ lpls2 = lpls;
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ if (i == wIndex) {
+ lpls2->dis.rcItem.bottom = lpls2->dis.rcItem.top + (short)height;
+ break;
+ }
+ if (lpls == NULL) break;
+ }
+ return LB_ERR;
+}
+
+
+
+
+
+int ListBoxDefaultItem(HWND hwnd, WND *wndPtr,
+ LPHEADLIST lphl, LPLISTSTRUCT lpls)
+{
+ RECT rect;
+ GetClientRect(hwnd, &rect);
+ SetRect(&lpls->dis.rcItem, 0, 0, rect.right, lphl->StdItemHeight);
+ lpls->dis.CtlType = lphl->DrawCtlType;
+ lpls->dis.CtlID = wndPtr->wIDmenu;
+ lpls->dis.itemID = 0;
+ lpls->dis.itemAction = 0;
+ lpls->dis.itemState = 0;
+ lpls->dis.hwndItem = hwnd;
+ lpls->dis.hDC = 0;
+ lpls->dis.itemData = 0;
+}
+
+
+
+int ListBoxFindNextMatch(HWND hwnd, WORD wChar)
+{
+ WND *wndPtr;
+ LPHEADLIST lphl;
+ LPLISTSTRUCT lpls;
+ UINT Count;
+ lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
+ if (lphl == NULL) return LB_ERR;
+ lpls = lphl->lpFirst;
+ if (lpls == NULL) return LB_ERR;
+ if (wChar < ' ') return LB_ERR;
+ if (((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) == LBS_OWNERDRAWFIXED) ||
+ ((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE)) {
+ if ((wndPtr->dwStyle & LBS_HASSTRINGS) != LBS_HASSTRINGS) {
+ return LB_ERR;
+ }
+ }
+ Count = 1;
+ while(lpls != NULL) {
+ if (Count > lphl->ItemSelected) {
+ if (*((char *)lpls->dis.itemData) == (char)wChar) {
+ lphl->FirstVisible = Count - lphl->ItemsVisible / 2;
+ if (lphl->FirstVisible < 1) lphl->FirstVisible = 1;
+ ListBoxSetCurSel(hwnd, Count);
+ SetScrollPos(lphl->hWndScroll, WM_VSCROLL, lphl->FirstVisible, TRUE);
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ return Count;
+ }
+ }
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ Count++;
+ }
+ Count = 1;
+ lpls = lphl->lpFirst;
+ while(lpls != NULL) {
+ if (*((char *)lpls->dis.itemData) == (char)wChar) {
+ if (Count == lphl->ItemSelected) return LB_ERR;
+ lphl->FirstVisible = Count - lphl->ItemsVisible / 2;
+ if (lphl->FirstVisible < 1) lphl->FirstVisible = 1;
+ ListBoxSetCurSel(hwnd, Count);
+ SetScrollPos(lphl->hWndScroll, WM_VSCROLL, lphl->FirstVisible, TRUE);
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ return Count;
+ }
+ lpls = (LPLISTSTRUCT)lpls->lpNext;
+ Count++;
+ }
+ return LB_ERR;
+}
+
+
diff --git a/controls/scroll.c b/controls/scroll.c
new file mode 100644
index 0000000..83816f5
--- /dev/null
+++ b/controls/scroll.c
@@ -0,0 +1,379 @@
+/*
+ * Interface code to SCROLLBAR widget
+ *
+ * Copyright Martin Ayotte, 1993
+ *
+ */
+
+/*
+#define DEBUG_SCROLL
+*/
+
+static char Copyright[] = "Copyright Martin Ayotte, 1993";
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include "windows.h"
+#include "scroll.h"
+#include "heap.h"
+#include "win.h"
+#include "dirent.h"
+#include <sys/stat.h>
+
+LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hwnd, WND **wndPtr);
+LPHEADSCROLL ScrollBarGetStorageHeader(HWND hwnd);
+void StdDrawScrollBar(HWND hwnd);
+int CreateScrollBarStruct(HWND hwnd);
+
+
+void SCROLLBAR_CreateScrollBar(LPSTR className, LPSTR scrollLabel, HWND hwnd)
+{
+ WND *wndPtr = WIN_FindWndPtr(hwnd);
+ WND *parentPtr = WIN_FindWndPtr(wndPtr->hwndParent);
+ DWORD style;
+ char widgetName[15];
+
+#ifdef DEBUG_SCROLLBAR
+ printf("scroll: label = %s, x = %d, y = %d\n", scrollLabel,
+ wndPtr->rectClient.left, wndPtr->rectClient.top);
+ printf(" width = %d, height = %d\n",
+ wndPtr->rectClient.right - wndPtr->rectClient.left,
+ wndPtr->rectClient.bottom - wndPtr->rectClient.top);
+#endif
+
+ if (!wndPtr)
+ return;
+
+ style = wndPtr->dwStyle & 0x0000FFFF;
+/*
+ if ((style & SBS_NOTIFY) == SBS_NOTIFY)
+*/
+ sprintf(widgetName, "%s%d", className, wndPtr->wIDmenu);
+ wndPtr->winWidget = XtVaCreateManagedWidget(widgetName,
+ compositeWidgetClass,
+ parentPtr->winWidget,
+ XtNx, wndPtr->rectClient.left,
+ XtNy, wndPtr->rectClient.top,
+ XtNwidth, wndPtr->rectClient.right -
+ wndPtr->rectClient.left,
+ XtNheight, wndPtr->rectClient.bottom -
+ wndPtr->rectClient.top,
+ NULL );
+ GlobalUnlock(hwnd);
+ GlobalUnlock(wndPtr->hwndParent);
+}
+
+
+
+/***********************************************************************
+ * WIDGETS_ScrollBarWndProc
+ */
+LONG SCROLLBAR_ScrollBarWndProc( HWND hwnd, WORD message,
+ WORD wParam, LONG lParam )
+{
+ WORD wRet;
+ short x, y;
+ WND *wndPtr;
+ LPHEADSCROLL lphs;
+ RECT rect;
+ static RECT rectsel;
+ switch(message)
+ {
+ case WM_CREATE:
+ CreateScrollBarStruct(hwnd);
+#ifdef DEBUG_SCROLL
+ printf("ScrollBar Creation up=%X down=%X!\n", lphs->hWndUp, lphs->hWndDown);
+#endif
+ return 0;
+ case WM_DESTROY:
+ lphs = ScrollBarGetStorageHeader(hwnd);
+ DestroyWindow(lphs->hWndUp);
+ DestroyWindow(lphs->hWndDown);
+ free(lphs);
+ printf("ScrollBar WM_DESTROY !\n");
+ return 0;
+
+ case WM_COMMAND:
+#ifdef DEBUG_SCROLL
+ printf("ScrollBar WM_COMMAND wParam=%X lParam=%lX !\n", wParam, lParam);
+#endif
+ lphs = ScrollBarGetWindowAndStorage(hwnd, &wndPtr);
+ if (HIWORD(lParam) != BN_CLICKED) return 0;
+ if (LOWORD(lParam) == lphs->hWndUp)
+ SendMessage(wndPtr->hwndParent, lphs->Direction,
+ SB_LINEUP, MAKELONG(0, hwnd));
+ if (LOWORD(lParam) == lphs->hWndDown)
+ SendMessage(wndPtr->hwndParent, lphs->Direction,
+ SB_LINEDOWN, MAKELONG(0, hwnd));
+ return 0;
+
+ case WM_LBUTTONDOWN:
+ lphs = ScrollBarGetWindowAndStorage(hwnd, &wndPtr);
+ GetClientRect(hwnd, &rect);
+ if (lphs->Direction == WM_VSCROLL) {
+ y = HIWORD(lParam);
+#ifdef DEBUG_SCROLL
+ printf("WM_LBUTTONDOWN y=%d cur+right=%d %d\n",
+ y, lphs->CurPix + rect.right, lphs->CurPix + (rect.right << 1));
+#endif
+ if (y < (lphs->CurPix + rect.right))
+ SendMessage(wndPtr->hwndParent, lphs->Direction,
+ SB_PAGEUP, MAKELONG(0, hwnd));
+ if (y > (lphs->CurPix + (rect.right << 1)))
+ SendMessage(wndPtr->hwndParent, lphs->Direction,
+ SB_PAGEDOWN, MAKELONG(0, hwnd));
+ if ((y > (lphs->CurPix + rect.right)) &&
+ (y < (lphs->CurPix + (rect.right << 1)))) {
+ lphs->ThumbActive = TRUE;
+#ifdef DEBUG_SCROLL
+ printf("THUMB DOWN !\n");
+#endif
+ }
+ }
+ else {
+ x = LOWORD(lParam);
+#ifdef DEBUG_SCROLL
+ printf("WM_LBUTTONDOWN x=%d Cur+bottom=%d %d\n",
+ x, lphs->CurPix + rect.bottom, lphs->CurPix + (rect.bottom << 1));
+#endif
+ if (x < (lphs->CurPix + rect.bottom))
+ SendMessage(wndPtr->hwndParent, lphs->Direction,
+ SB_PAGEUP, MAKELONG(0, hwnd));
+ if (x > (lphs->CurPix + (rect.bottom << 1)))
+ SendMessage(wndPtr->hwndParent, lphs->Direction,
+ SB_PAGEDOWN, MAKELONG(0, hwnd));
+ if ((x > (lphs->CurPix + rect.bottom)) &&
+ (x < (lphs->CurPix + (rect.bottom << 1)))) {
+ lphs->ThumbActive = TRUE;
+#ifdef DEBUG_SCROLL
+ printf("THUMB DOWN !\n");
+#endif
+ }
+ }
+ break;
+ case WM_LBUTTONUP:
+ lphs->ThumbActive = FALSE;
+ break;
+
+ case WM_KEYDOWN:
+ printf("ScrollBar WM_KEYDOWN wParam %X!\n", wParam);
+ break;
+ case WM_PAINT:
+ StdDrawScrollBar(hwnd);
+ break;
+ case WM_MOUSEMOVE:
+ if ((wParam & MK_LBUTTON) != 0) {
+ lphs = ScrollBarGetWindowAndStorage(hwnd, &wndPtr);
+ if (lphs->ThumbActive == 0) break;
+ GetClientRect(hwnd, &rect);
+ if (lphs->Direction == WM_VSCROLL)
+ y = HIWORD(lParam) - rect.right - (rect.right >> 1);
+ else
+ y = LOWORD(lParam) - rect.bottom - (rect.bottom >> 1);
+ x = (y * (lphs->MaxVal - lphs->MinVal) /
+ lphs->MaxPix) + lphs->MinVal;
+#ifdef DEBUG_SCROLL
+ printf("WM_MOUSEMOVE val=%d pix=%d\n", x, y);
+#endif
+ SendMessage(wndPtr->hwndParent, lphs->Direction,
+ SB_THUMBTRACK, MAKELONG(x, hwnd));
+ }
+ break;
+ default:
+ return DefWindowProc( hwnd, message, wParam, lParam );
+ }
+return(0);
+}
+
+
+
+LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hwnd, WND **wndPtr)
+{
+ WND *Ptr;
+ LPHEADSCROLL lphs;
+ *(wndPtr) = Ptr = WIN_FindWndPtr(hwnd);
+ lphs = *((LPHEADSCROLL *)&Ptr->wExtra[1]);
+ return lphs;
+}
+
+
+LPHEADSCROLL ScrollBarGetStorageHeader(HWND hwnd)
+{
+ WND *wndPtr;
+ LPHEADSCROLL lphs;
+ wndPtr = WIN_FindWndPtr(hwnd);
+ lphs = *((LPHEADSCROLL *)&wndPtr->wExtra[1]);
+ return lphs;
+}
+
+
+void StdDrawScrollBar(HWND hwnd)
+{
+ LPHEADSCROLL lphs;
+ PAINTSTRUCT ps;
+ HBRUSH hBrush;
+ HDC hdc;
+ RECT rect;
+ UINT i, w, h, siz;
+ char C[128];
+ hdc = BeginPaint( hwnd, &ps );
+ hBrush = SendMessage(GetParent(hwnd), WM_CTLCOLOR, (WORD)hdc,
+ MAKELONG(hwnd, CTLCOLOR_SCROLLBAR));
+ if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(LTGRAY_BRUSH);
+ lphs = ScrollBarGetStorageHeader(hwnd);
+ if (lphs == NULL) goto EndOfPaint;
+ GetClientRect(hwnd, &rect);
+ w = rect.right - rect.left;
+ h = rect.bottom - rect.top;
+ if (lphs->Direction == WM_VSCROLL) {
+ rect.top += w;
+ rect.bottom -= w;
+ }
+ else {
+ rect.left += h;
+ rect.right -= h;
+ }
+ FillRect(hdc, &rect, hBrush);
+ if (lphs->Direction == WM_VSCROLL)
+ SetRect(&rect, 0, lphs->CurPix + w,
+ w, lphs->CurPix + (w << 1));
+ else
+ SetRect(&rect, lphs->CurPix + h,
+ 0, lphs->CurPix + (h << 1), h);
+ FrameRect(hdc, &rect, GetStockObject(BLACK_BRUSH));
+ InflateRect(&rect, -1, -1);
+ FillRect(hdc, &rect, GetStockObject(LTGRAY_BRUSH));
+ DrawReliefRect(hdc, rect, 2, 0);
+ InflateRect(&rect, -3, -3);
+ DrawReliefRect(hdc, rect, 1, 1);
+EndOfPaint:
+ EndPaint( hwnd, &ps );
+ InvalidateRect(lphs->hWndUp, NULL, TRUE);
+ UpdateWindow(lphs->hWndUp);
+ InvalidateRect(lphs->hWndDown, NULL, TRUE);
+ UpdateWindow(lphs->hWndDown);
+}
+
+
+
+int CreateScrollBarStruct(HWND hwnd)
+{
+ RECT rect;
+ int width, height;
+ WND *wndPtr;
+ LPHEADSCROLL lphs;
+ wndPtr = WIN_FindWndPtr(hwnd);
+ lphs = (LPHEADSCROLL)malloc(sizeof(HEADSCROLL));
+ *((LPHEADSCROLL *)&wndPtr->wExtra[1]) = lphs;
+ lphs->ThumbActive;
+ lphs->MinVal = 0;
+ lphs->MaxVal = 100;
+ lphs->CurVal = 0;
+ lphs->CurPix = 0;
+ width = wndPtr->rectClient.right - wndPtr->rectClient.left;
+ height = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
+ lphs = ScrollBarGetStorageHeader(hwnd);
+ if (lphs == NULL) return 0;
+ if (width <= height)
+ {
+ lphs->MaxPix = height - 3 * width;
+ lphs->Direction = WM_VSCROLL;
+ lphs->hWndUp = CreateWindow("BUTTON", "",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+ 0, 0, width, width, hwnd, 1, wndPtr->hInstance, 0L);
+ lphs->hWndDown = CreateWindow("BUTTON", "",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+ 0, height - width, width, width, hwnd, 2,
+ wndPtr->hInstance, 0L);
+ }
+ else
+ {
+ lphs->MaxPix = width - 3 * height;
+ lphs->Direction = WM_HSCROLL;
+ lphs->hWndUp = CreateWindow("BUTTON", "",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+ 0, 0, height, height, hwnd, 0, wndPtr->hInstance, 0L);
+ lphs->hWndDown = CreateWindow("BUTTON", "",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+ width - height, 0, height, height, hwnd, 0,
+ wndPtr->hInstance, 0L);
+ }
+ if (lphs->MaxPix < 1) lphs->MaxPix = 1;
+ return TRUE;
+}
+
+
+
+int GetScrollPos(HWND hwnd, int nBar)
+{
+ LPHEADSCROLL lphs;
+ lphs = ScrollBarGetStorageHeader(hwnd);
+ if (lphs == NULL) return;
+ return lphs->CurVal;
+}
+
+
+
+void GetScrollRange(HWND hwnd, int nBar, LPINT lpMin, LPINT lpMax)
+{
+ LPHEADSCROLL lphs;
+ lphs = ScrollBarGetStorageHeader(hwnd);
+ if (lphs == NULL) return;
+ *lpMin = lphs->MinVal;
+ *lpMax = lphs->MaxVal;
+}
+
+
+
+int SetScrollPos(HWND hwnd, int nBar, int nPos, BOOL bRedraw)
+{
+ int nRet;
+ LPHEADSCROLL lphs;
+ lphs = ScrollBarGetStorageHeader(hwnd);
+ if (lphs == NULL) return;
+ nRet = lphs->CurVal;
+ lphs->CurVal = (short)nPos;
+ if (lphs->MaxVal != lphs->MinVal)
+ lphs->CurPix = lphs->MaxPix * (abs((short)nPos) - abs(lphs->MinVal)) /
+ (abs(lphs->MaxVal) - abs(lphs->MinVal));
+ if (lphs->CurPix > lphs->MaxPix) lphs->CurPix = lphs->MaxPix;
+#ifdef DEBUG_SCROLL
+ printf("SetScrollPos val=%d pixval=%d pixmax%d\n",
+ (short)nPos, lphs->CurPix, lphs->MaxPix);
+ printf("SetScrollPos min=%d max=%d\n",
+ lphs->MinVal, lphs->MaxVal);
+#endif
+ if (bRedraw) {
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ }
+ return nRet;
+}
+
+
+
+void SetScrollRange(HWND hwnd, int nBar, int MinPos, int MaxPos, BOOL bRedraw)
+{
+ LPHEADSCROLL lphs;
+ lphs = ScrollBarGetStorageHeader(hwnd);
+ if (lphs == NULL) return;
+ lphs->MinVal = (short)MinPos;
+ lphs->MaxVal = (short)MaxPos;
+ if (lphs->MaxVal != lphs->MinVal)
+ lphs->CurPix = abs(lphs->MaxVal) *
+ (abs(lphs->CurVal) - abs(lphs->MinVal)) /
+ (abs(lphs->MaxVal) - abs(lphs->MinVal));
+ if (lphs->CurPix > lphs->MaxPix) lphs->CurPix = lphs->MaxPix;
+#ifdef DEBUG_SCROLL
+ printf("SetScrollRange min=%d max=%d\n", lphs->MinVal, lphs->MaxVal);
+#endif
+ if (bRedraw) {
+ InvalidateRect(hwnd, NULL, TRUE);
+ UpdateWindow(hwnd);
+ }
+}
+
+
+
+
+
diff --git a/controls/static.c b/controls/static.c
new file mode 100644
index 0000000..40e5fbb
--- /dev/null
+++ b/controls/static.c
@@ -0,0 +1,266 @@
+/*
+ * Static control
+ *
+ * Copyright David W. Metcalfe, 1993
+ *
+ */
+
+static char Copyright[] = "Copyright David W. Metcalfe, 1993";
+
+#include <windows.h>
+#include "win.h"
+#include "user.h"
+
+LONG StaticWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam);
+
+static LONG PaintTextfn(HWND hwnd);
+static LONG PaintRectfn(HWND hwnd);
+static LONG PaintFramefn(HWND hwnd);
+
+static COLORREF color_windowframe, color_background, color_window,
+ color_windowtext;
+
+#define NOTIFY_PARENT(hWndCntrl, wNotifyCode) \
+ SendMessage(GetParent(hWndCntrl), WM_COMMAND, \
+ GetDlgCtrlID(hWndCntrl), MAKELPARAM(hWndCntrl, wNotifyCode));
+#define DIM(array) ((sizeof array)/(sizeof array[0]))
+
+typedef struct
+{
+ LONG (*paintfn)();
+} STATICFN;
+
+#define MAX_STATIC_TYPE 12
+
+static STATICFN staticfn[MAX_STATIC_TYPE] =
+{
+ { (LONG(*)())PaintTextfn }, /* SS_LEFT */
+ { (LONG(*)())PaintTextfn }, /* SS_CENTER */
+ { (LONG(*)())PaintTextfn }, /* SS_RIGHT */
+ { (LONG(*)())NULL }, /* SS_ICON */
+ { (LONG(*)())PaintRectfn }, /* SS_BLACKRECT */
+ { (LONG(*)())PaintRectfn }, /* SS_GRAYRECT */
+ { (LONG(*)())PaintRectfn }, /* SS_WHITERECT */
+ { (LONG(*)())PaintFramefn }, /* SS_BLACKFRAME */
+ { (LONG(*)())PaintFramefn }, /* SS_GRAYFRAME */
+ { (LONG(*)())PaintFramefn }, /* SS_WHITEFRAME */
+ { (LONG(*)())PaintTextfn }, /* SS_SIMPLE */
+ { (LONG(*)())PaintTextfn } /* SS_LEFTNOWORDWRAP */
+};
+
+
+LONG StaticWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam)
+{
+ LONG lResult = 0;
+ HDC hDC;
+ RECT rc;
+ LPSTR textPtr;
+
+ WND *wndPtr = WIN_FindWndPtr(hWnd);
+ LONG style = wndPtr->dwStyle & 0x0000000F;
+
+ switch (uMsg) {
+ case WM_ENABLE:
+ InvalidateRect(hWnd, NULL, FALSE);
+ break;
+
+ case WM_CREATE:
+ if (style < 0L || style >= (LONG)DIM(staticfn))
+ lResult = -1L;
+ else
+ {
+ /* initialise colours */
+ color_windowframe = GetSysColor(COLOR_WINDOWFRAME);
+ color_background = GetSysColor(COLOR_BACKGROUND);
+ color_window = GetSysColor(COLOR_WINDOW);
+ color_windowtext = GetSysColor(COLOR_WINDOWTEXT);
+ lResult = 0L;
+ }
+ break;
+
+ case WM_PAINT:
+ if (staticfn[style].paintfn)
+ (staticfn[style].paintfn)(hWnd);
+ break;
+
+ case WM_SYSCOLORCHANGE:
+ color_windowframe = GetSysColor(COLOR_WINDOWFRAME);
+ color_background = GetSysColor(COLOR_BACKGROUND);
+ color_window = GetSysColor(COLOR_WINDOW);
+ color_windowtext = GetSysColor(COLOR_WINDOWTEXT);
+ InvalidateRect(hWnd, NULL, TRUE);
+ break;
+
+ case WM_SETTEXT:
+ if (wndPtr->hText)
+ USER_HEAP_FREE(wndPtr->hText);
+
+ wndPtr->hText = USER_HEAP_ALLOC(GMEM_MOVEABLE,
+ strlen((LPSTR)lParam) + 1);
+ textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
+ strcpy(textPtr, (LPSTR)lParam);
+ InvalidateRect(hWnd, NULL, TRUE);
+ break;
+
+ default:
+ lResult = DefWindowProc(hWnd, uMsg, wParam, lParam);
+ break;
+ }
+
+ GlobalUnlock(hWnd);
+ return lResult;
+}
+
+
+static LONG PaintTextfn(HWND hwnd)
+{
+ PAINTSTRUCT ps;
+ RECT rc;
+ HDC hdc;
+ HBRUSH hBrush;
+ HANDLE hText;
+ char *text;
+ int textlen;
+ WORD wFormat;
+
+ WND *wndPtr = WIN_FindWndPtr(hwnd);
+ LONG style = wndPtr->dwStyle;
+
+ hdc = BeginPaint(hwnd, &ps);
+ GetClientRect(hwnd, &rc);
+
+ textlen = GetWindowTextLength(hwnd);
+ hText = LocalAlloc(LMEM_MOVEABLE, textlen+1);
+ text = LocalLock(hText);
+ GetWindowText(hwnd, text, textlen+1);
+
+ switch (style & 0x0000000F)
+ {
+ case SS_LEFT:
+ wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK;
+ break;
+
+ case SS_CENTER:
+ wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK;
+ break;
+
+ case SS_RIGHT:
+ wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK;
+ break;
+
+ case SS_SIMPLE:
+ wFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER;
+ break;
+
+ case SS_LEFTNOWORDWRAP:
+ wFormat = DT_LEFT | DT_SINGLELINE | DT_EXPANDTABS | DT_VCENTER;
+ break;
+ }
+
+ if (style & SS_NOPREFIX)
+ wFormat |= DT_NOPREFIX;
+
+ hBrush = SendMessage(GetParent(hwnd), WM_CTLCOLOR, (WORD)hdc,
+ MAKELONG(hwnd, CTLCOLOR_STATIC));
+ if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(WHITE_BRUSH);
+ FillRect(hdc, &rc, hBrush);
+ DrawText(hdc, text, textlen, &rc, wFormat);
+
+ LocalUnlock(hText);
+ LocalFree(hText);
+ GlobalUnlock(hwnd);
+ EndPaint(hwnd, &ps);
+}
+
+static LONG PaintRectfn(HWND hwnd)
+{
+ PAINTSTRUCT ps;
+ RECT rc;
+ HDC hdc;
+ HPEN hOldPen, hPen;
+ HBRUSH hOldBrush, hBrush;
+
+ WND *wndPtr = WIN_FindWndPtr(hwnd);
+
+ hdc = BeginPaint(hwnd, &ps);
+ GetClientRect(hwnd, &rc);
+
+ switch (wndPtr->dwStyle & 0x0000000F)
+ {
+ case SS_BLACKRECT:
+ hPen = CreatePen(PS_SOLID, 1, color_windowframe);
+ hBrush = CreateSolidBrush(color_windowframe);
+ break;
+
+ case SS_GRAYRECT:
+ hPen = CreatePen(PS_SOLID, 1, color_background);
+ hBrush = CreateSolidBrush(color_background);
+ break;
+
+ case SS_WHITERECT:
+ hPen = CreatePen(PS_SOLID, 1, color_window);
+ hBrush = CreateSolidBrush(color_window);
+ break;
+ }
+
+ hOldPen = (HPEN)SelectObject(hdc, (HANDLE)hPen);
+ hOldBrush = (HBRUSH)SelectObject(hdc, (HANDLE)hBrush);
+ Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
+
+ SelectObject(hdc, (HANDLE)hOldPen);
+ SelectObject(hdc, (HANDLE)hOldBrush);
+ DeleteObject((HANDLE)hPen);
+ DeleteObject((HANDLE)hBrush);
+
+ GlobalUnlock(hwnd);
+ EndPaint(hwnd, &ps);
+}
+
+static LONG PaintFramefn(HWND hwnd)
+{
+ PAINTSTRUCT ps;
+ RECT rc;
+ HDC hdc;
+ HPEN hOldPen, hPen;
+ HBRUSH hOldBrush, hBrush;
+
+ WND *wndPtr = WIN_FindWndPtr(hwnd);
+
+ hdc = BeginPaint(hwnd, &ps);
+ GetClientRect(hwnd, &rc);
+
+ switch (wndPtr->dwStyle & 0x0000000F)
+ {
+ case SS_BLACKFRAME:
+ hPen = CreatePen(PS_SOLID, 1, color_windowframe);
+ break;
+
+ case SS_GRAYFRAME:
+ hPen = CreatePen(PS_SOLID, 1, color_background);
+ break;
+
+ case SS_WHITEFRAME:
+ hPen = CreatePen(PS_SOLID, 1, color_window);
+ break;
+ }
+
+ hBrush = CreateSolidBrush(color_window);
+ hOldPen = (HPEN)SelectObject(hdc, (HANDLE)hPen);
+ hOldBrush = (HBRUSH)SelectObject(hdc, (HANDLE)hBrush);
+ Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
+
+ SelectObject(hdc, (HANDLE)hOldPen);
+ SelectObject(hdc, (HANDLE)hOldBrush);
+ DeleteObject((HANDLE)hPen);
+ DeleteObject((HANDLE)hBrush);
+
+ GlobalUnlock(hwnd);
+ EndPaint(hwnd, &ps);
+}
+
+
+
+
+
+
+
diff --git a/controls/widgets.c b/controls/widgets.c
index 90272e5..6733486 100644
--- a/controls/widgets.c
+++ b/controls/widgets.c
@@ -8,21 +8,32 @@
#include "windows.h"
#include "win.h"
+#include "dialog.h"
LONG ButtonWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam );
-static LONG WIDGETS_StaticWndProc( HWND hwnd, WORD message,
+LONG StaticWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam );
+
+LONG SCROLLBAR_ScrollBarWndProc( HWND hwnd, WORD message,
+ WORD wParam, LONG lParam );
+LONG LISTBOX_ListBoxWndProc( HWND hwnd, WORD message,
+ WORD wParam, LONG lParam );
+LONG COMBOBOX_ComboBoxWndProc( HWND hwnd, WORD message,
WORD wParam, LONG lParam );
-#define NB_BUILTIN_CLASSES 2
-static WNDCLASS WIDGETS_BuiltinClasses[NB_BUILTIN_CLASSES] =
+static WNDCLASS WIDGETS_BuiltinClasses[] =
{
- { 0, (LONG(*)())ButtonWndProc, 0, 0, 0, 0, 0, 0, NULL, "BUTTON" },
- { 0, (LONG(*)())WIDGETS_StaticWndProc, 0, 0, 0, 0, 0, 0, NULL, "STATIC" }
+ { 0, (LONG(*)())ButtonWndProc, 0, 2, 0, 0, 0, 0, NULL, "BUTTON" },
+ { 0, (LONG(*)())StaticWndProc, 0, 0, 0, 0, 0, 0, NULL, "STATIC" },
+ { 0, (LONG(*)())SCROLLBAR_ScrollBarWndProc, 0, 8, 0, 0, 0, 0, NULL, "SCROLLBAR" },
+ { 0, (LONG(*)())LISTBOX_ListBoxWndProc, 0, 8, 0, 0, 0, 0, NULL, "LISTBOX" },
+ { 0, (LONG(*)())COMBOBOX_ComboBoxWndProc, 0, 8, 0, 0, 0, 0, NULL, "COMBOBOX" },
+ { 0, (LONG(*)())DefDlgProc, 0, DLGWINDOWEXTRA, 0, 0, 0, 0, NULL, DIALOG_CLASS_NAME }
};
-static FARPROC WndProc32[NB_BUILTIN_CLASSES];
+#define NB_BUILTIN_CLASSES \
+ (sizeof(WIDGETS_BuiltinClasses)/sizeof(WIDGETS_BuiltinClasses[0]))
/***********************************************************************
@@ -33,56 +44,9 @@
BOOL WIDGETS_Init()
{
int i;
- WNDCLASS * pClass = WIDGETS_BuiltinClasses;
-
- for (i = 0; i < NB_BUILTIN_CLASSES; i++, pClass++)
+ for (i = 0; i < NB_BUILTIN_CLASSES; i++)
{
- if (!RegisterClass(pClass)) return FALSE;
+ if (!RegisterClass(&WIDGETS_BuiltinClasses[i])) return FALSE;
}
return TRUE;
}
-
-
-/**********************************************************************
- * WIDGETS_Call32WndProc
- *
- * Call the window procedure of a built-in class.
- */
-LONG WIDGETS_Call32WndProc( FARPROC func, HWND hwnd, WORD message,
- WORD wParam, LONG lParam )
-{
- unsigned int i = (unsigned int) func;
- if (!i || (i > NB_BUILTIN_CLASSES)) return 0;
- return (*WndProc32[i-1])( hwnd, message, wParam, lParam );
-}
-
-
-/***********************************************************************
- * WIDGETS_StaticWndProc
- */
-static LONG WIDGETS_StaticWndProc( HWND hwnd, WORD message,
- WORD wParam, LONG lParam )
-{
- switch(message)
- {
- case WM_CREATE:
- return 0;
-
- case WM_PAINT:
- {
- HDC hdc;
- PAINTSTRUCT ps;
- RECT rect;
-
- hdc = BeginPaint( hwnd, &ps );
- GetClientRect( hwnd, &rect );
- DrawText(hdc, "Static", -1, &rect,
- DT_SINGLELINE | DT_CENTER | DT_VCENTER );
- EndPaint( hwnd, &ps );
- return 0;
- }
-
- default:
- return DefWindowProc( hwnd, message, wParam, lParam );
- }
-}
diff --git a/debugger/Makefile b/debugger/Makefile
index 493297a..78954c0 100644
--- a/debugger/Makefile
+++ b/debugger/Makefile
@@ -1,6 +1,10 @@
-CFLAGS=-g -I../include # -DUSE_READLINE
+CFLAGS=-g -I../include -DUSE_READLINE
LIBS= readline/libedit.a
OBJS=dbg.tab.o hash.o lex.yy.o info.o i386-pinsn.o
+#YACC=bison -v -d
+YACC=yacc -b dbg -d
+#LEX=flex
+LEX=lex
debugger.o: ${OBJS} readline/libedit.a
(cd readline; make)
@@ -18,10 +22,10 @@
lex.yy.c: debug.l
- flex -I debug.l
+ ${LEX} -I debug.l
dbg.tab.c dbg.tab.h: dbg.y
- bison -v -d dbg.y
+ ${YACC} dbg.y
dtest: dtest.o debugger.o
gcc -o dtest dtest.o debugger.o
@@ -29,3 +33,7 @@
clean:
rm -f *.o main dbg.tab.* lex.yy.* *.output *~ *# dtest
(cd readline; make clean)
+
+depend: dbg.tab.c dbg.tab.h lex.yy.c
+ $(CC) $(CFLAGS) -M *.c > .depend
+
diff --git a/debugger/dbg.y b/debugger/dbg.y
index 80e8d34..a627962 100644
--- a/debugger/dbg.y
+++ b/debugger/dbg.y
@@ -115,7 +115,7 @@
yyin = stdin;
regval = regs;
- /* This only works for linux - NetBSD will need something different here. */
+#ifdef linux
if((SC_CS & 7) != 7) {
dbg_mask = 0xffffffff;
dbg_mode = 32;
@@ -123,6 +123,16 @@
dbg_mask = 0xffff;
dbg_mode = 16;
};
+#endif
+#ifdef __NetBSD__
+ if(SC_CS == 0x1f) {
+ dbg_mask = 0xffffffff;
+ dbg_mode = 32;
+ } else {
+ dbg_mask = 0xffff;
+ dbg_mode = 16;
+ };
+#endif
/* This is intended to read the entry points from the Windows image, and
insert them in the hash table. It does not work yet, so it is commented out. */
diff --git a/debugger/debug.l b/debugger/debug.l
index dac7d3f..6de63a4 100644
--- a/debugger/debug.l
+++ b/debugger/debug.l
@@ -24,6 +24,7 @@
static char * make_symbol(char *);
void flush_symbols();
static int syntax_error;
+extern int yylval;
%}
DIGIT [0-9]
diff --git a/debugger/dtest.c b/debugger/dtest.c
index 4d70008..bbad04e 100644
--- a/debugger/dtest.c
+++ b/debugger/dtest.c
@@ -56,25 +56,16 @@
char * pnt;
#ifdef linux
segv_act.sa_handler = (__sighandler_t) win_fault;
- /* Point to the top of the stack, minus 4 just in case, and make
- it aligned */
sigaction(SIGSEGV, &segv_act, NULL);
#endif
#ifdef __NetBSD__
- struct sigstack ss;
sigset_t sig_mask;
- ss.ss_sp = (char *) (((unsigned int)(cstack + sizeof(cstack) - 4)) & ~3);
- ss.ss_onstack = 0;
- if (sigstack(&ss, NULL) < 0) {
- perror("sigstack");
- exit(1);
- }
sigemptyset(&sig_mask);
segv_act.sa_handler = (__sighandler_t) win_fault;
- segv_act.sa_flags = SA_ONSTACK;
+ segv_act.sa_flags = 0;
segv_act.sa_mask = sig_mask;
- if (sigaction(SIGBUS, &segv_act, NULL) < 0) {
+ if (sigaction(SIGSEGV, &segv_act, NULL) < 0) {
perror("sigaction");
exit(1);
}
diff --git a/debugger/i386-pinsn.c b/debugger/i386-pinsn.c
index bd22a93..9a63361 100644
--- a/debugger/i386-pinsn.c
+++ b/debugger/i386-pinsn.c
@@ -1467,6 +1467,57 @@
}
append_prefix ();
+
+ if (bytemode == w_mode || (bytemode == v_mode && !dflag))
+ {
+ if (mod == 0 && rm == 6)
+ {
+ sprintf(scratchbuf, "%04.4x", get16());
+ oappend(scratchbuf);
+ return 0;
+ }
+
+ disp = 0;
+ if (mod == 1)
+ disp = *(char *)codep++;
+ else if (mod == 2)
+ disp = get16();
+ if (disp != 0)
+ {
+ sprintf(scratchbuf, "0x%x", disp);
+ oappend(scratchbuf);
+ }
+
+ switch (rm)
+ {
+ case 0:
+ oappend("(%bx,%si)");
+ break;
+ case 1:
+ oappend("(%bx,%di)");
+ break;
+ case 2:
+ oappend("(%bp,%si)");
+ break;
+ case 3:
+ oappend("(%bp,%di)");
+ break;
+ case 4:
+ oappend("(%si)");
+ break;
+ case 5:
+ oappend("(%di)");
+ break;
+ case 6:
+ oappend("(%bp)");
+ break;
+ case 7:
+ oappend("(%bx)");
+ break;
+ }
+ return 0;
+ }
+
if (rm == 4)
{
havesib = 1;
diff --git a/debugger/info.c b/debugger/info.c
index 96046e8..063447a 100644
--- a/debugger/info.c
+++ b/debugger/info.c
@@ -140,10 +140,10 @@
wdump = (unsigned short int *) addr;
for(i=0; i<count; i++)
{
- fprintf(stderr," %d", *wdump++);
+ fprintf(stderr," %x", *wdump++);
if ((i % 10) == 7) {
fprintf(stderr,"\n");
- print_address((unsigned int) dump, stderr);
+ print_address((unsigned int) wdump, stderr);
fprintf(stderr,": ");
};
}
@@ -172,10 +172,10 @@
pnt = (char *) addr;
for(i=0; i<count; i++)
{
- fprintf(stderr," %d", *pnt++);
+ fprintf(stderr," %w", *pnt++);
if ((i % 32) == 7) {
fprintf(stderr,"\n");
- print_address((unsigned int) dump, stderr);
+ print_address((unsigned int) pnt, stderr);
fprintf(stderr,": ");
};
}
diff --git a/debugger/obstack.h b/debugger/obstack.h
new file mode 100644
index 0000000..72832ee
--- /dev/null
+++ b/debugger/obstack.h
@@ -0,0 +1,467 @@
+/* obstack.h - object stack macros
+ Copyright (C) 1988 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+This program 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* Summary:
+
+All the apparent functions defined here are macros. The idea
+is that you would use these pre-tested macros to solve a
+very specific set of problems, and they would run fast.
+Caution: no side-effects in arguments please!! They may be
+evaluated MANY times!!
+
+These macros operate a stack of objects. Each object starts life
+small, and may grow to maturity. (Consider building a word syllable
+by syllable.) An object can move while it is growing. Once it has
+been "finished" it never changes address again. So the "top of the
+stack" is typically an immature growing object, while the rest of the
+stack is of mature, fixed size and fixed address objects.
+
+These routines grab large chunks of memory, using a function you
+supply, called `obstack_chunk_alloc'. On occasion, they free chunks,
+by calling `obstack_chunk_free'. You must define them and declare
+them before using any obstack macros.
+
+Each independent stack is represented by a `struct obstack'.
+Each of the obstack macros expects a pointer to such a structure
+as the first argument.
+
+One motivation for this package is the problem of growing char strings
+in symbol tables. Unless you are "fascist pig with a read-only mind"
+[Gosper's immortal quote from HAKMEM item 154, out of context] you
+would not like to put any arbitrary upper limit on the length of your
+symbols.
+
+In practice this often means you will build many short symbols and a
+few long symbols. At the time you are reading a symbol you don't know
+how long it is. One traditional method is to read a symbol into a
+buffer, realloc()ating the buffer every time you try to read a symbol
+that is longer than the buffer. This is beaut, but you still will
+want to copy the symbol from the buffer to a more permanent
+symbol-table entry say about half the time.
+
+With obstacks, you can work differently. Use one obstack for all symbol
+names. As you read a symbol, grow the name in the obstack gradually.
+When the name is complete, finalize it. Then, if the symbol exists already,
+free the newly read name.
+
+The way we do this is to take a large chunk, allocating memory from
+low addresses. When you want to build a symbol in the chunk you just
+add chars above the current "high water mark" in the chunk. When you
+have finished adding chars, because you got to the end of the symbol,
+you know how long the chars are, and you can create a new object.
+Mostly the chars will not burst over the highest address of the chunk,
+because you would typically expect a chunk to be (say) 100 times as
+long as an average object.
+
+In case that isn't clear, when we have enough chars to make up
+the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
+so we just point to it where it lies. No moving of chars is
+needed and this is the second win: potentially long strings need
+never be explicitly shuffled. Once an object is formed, it does not
+change its address during its lifetime.
+
+When the chars burst over a chunk boundary, we allocate a larger
+chunk, and then copy the partly formed object from the end of the old
+chunk to the beginning of the new larger chunk. We then carry on
+accreting characters to the end of the object as we normally would.
+
+A special macro is provided to add a single char at a time to a
+growing object. This allows the use of register variables, which
+break the ordinary 'growth' macro.
+
+Summary:
+ We allocate large chunks.
+ We carve out one object at a time from the current chunk.
+ Once carved, an object never moves.
+ We are free to append data of any size to the currently
+ growing object.
+ Exactly one object is growing in an obstack at any one time.
+ You can run one obstack per control block.
+ You may have as many control blocks as you dare.
+ Because of the way we do it, you can `unwind' a obstack
+ back to a previous state. (You may remove objects much
+ as you would with a stack.)
+*/
+
+
+/* Don't do the contents of this file more than once. */
+
+#ifndef __OBSTACKS__
+#define __OBSTACKS__
+
+/* We use subtraction of (char *)0 instead of casting to int
+ because on word-addressable machines a simple cast to int
+ may ignore the byte-within-word field of the pointer. */
+
+#ifndef __PTR_TO_INT
+#define __PTR_TO_INT(P) ((P) - (char *)0)
+#endif
+
+#ifndef __INT_TO_PTR
+#define __INT_TO_PTR(P) ((P) + (char *)0)
+#endif
+
+struct _obstack_chunk /* Lives at front of each chunk. */
+{
+ char *limit; /* 1 past end of this chunk */
+ struct _obstack_chunk *prev; /* address of prior chunk or NULL */
+ char contents[4]; /* objects begin here */
+};
+
+struct obstack /* control current object in current chunk */
+{
+ long chunk_size; /* preferred size to allocate chunks in */
+ struct _obstack_chunk* chunk; /* address of current struct obstack_chunk */
+ char *object_base; /* address of object we are building */
+ char *next_free; /* where to add next char to current object */
+ char *chunk_limit; /* address of char after current chunk */
+ int temp; /* Temporary for some macros. */
+ int alignment_mask; /* Mask of alignment for each object. */
+ struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */
+ void (*freefun) (); /* User's function to free a chunk. */
+ void *area_id; /* Select which region to alloc/free in */
+ int flags; /* Miscellaneous special purpose flags */
+};
+
+/* Declare bits for flags word. */
+
+/* Means there is a possibility the current chunk contains a zero-length
+ object. This prevents freeing the chunk if we allocate a bigger chunk
+ to replace it. */
+
+#define OBSTACK_MAYBE_EMPTY_OBJECT (1 << 0)
+
+/* Means that the allocation and deallocation functions take two arguments,
+ ala the mmalloc package. The first argument is a generic pointer that
+ is saved in the area_id member of the obstack struct. */
+
+#define OBSTACK_MMALLOC_LIKE (1 << 1)
+
+/* Declare the external functions we use; they are in obstack.c. */
+
+#ifdef __STDC__
+ extern void _obstack_newchunk (struct obstack *, int);
+ extern void _obstack_free (struct obstack *, void *);
+ extern void _obstack_begin (struct obstack *, int, int,
+ void *(*) (int), void (*) (int), void *, int);
+#else
+ extern void _obstack_newchunk ();
+ extern void _obstack_free ();
+ extern void _obstack_begin ();
+#endif
+
+#ifdef __STDC__
+
+/* Do the function-declarations after the structs
+ but before defining the macros. */
+
+void obstack_init (struct obstack *obstack);
+
+void * obstack_alloc (struct obstack *obstack, int size);
+
+void * obstack_copy (struct obstack *obstack, void *address, int size);
+void * obstack_copy0 (struct obstack *obstack, void *address, int size);
+
+void obstack_free (struct obstack *obstack, void *block);
+
+void obstack_blank (struct obstack *obstack, int size);
+
+void obstack_grow (struct obstack *obstack, void *data, int size);
+void obstack_grow0 (struct obstack *obstack, void *data, int size);
+
+void obstack_1grow (struct obstack *obstack, int data_char);
+void obstack_ptr_grow (struct obstack *obstack, void *data);
+void obstack_int_grow (struct obstack *obstack, int data);
+
+void * obstack_finish (struct obstack *obstack);
+
+int obstack_object_size (struct obstack *obstack);
+
+int obstack_room (struct obstack *obstack);
+void obstack_1grow_fast (struct obstack *obstack, int data_char);
+void obstack_ptr_grow_fast (struct obstack *obstack, void *data);
+void obstack_int_grow_fast (struct obstack *obstack, int data);
+void obstack_blank_fast (struct obstack *obstack, int size);
+
+void * obstack_base (struct obstack *obstack);
+void * obstack_next_free (struct obstack *obstack);
+int obstack_alignment_mask (struct obstack *obstack);
+int obstack_chunk_size (struct obstack *obstack);
+
+#endif /* __STDC__ */
+
+/* Non-ANSI C cannot really support alternative functions for these macros,
+ so we do not declare them. */
+
+/* Pointer to beginning of object being allocated or to be allocated next.
+ Note that this might not be the final address of the object
+ because a new chunk might be needed to hold the final size. */
+
+#define obstack_base(h) ((h)->object_base)
+
+/* Size for allocating ordinary chunks. */
+
+#define obstack_chunk_size(h) ((h)->chunk_size)
+
+/* Pointer to next byte not yet allocated in current chunk. */
+
+#define obstack_next_free(h) ((h)->next_free)
+
+/* Mask specifying low bits that should be clear in address of an object. */
+
+#define obstack_alignment_mask(h) ((h)->alignment_mask)
+
+#define obstack_init(h) \
+ _obstack_begin ((h), 0, 0, \
+ (void *(*) ()) obstack_chunk_alloc, (void (*) ())obstack_chunk_free, (void *) 0, 0)
+
+#define obstack_begin(h, size) \
+ _obstack_begin ((h), (size), 0, \
+ (void *(*) ()) obstack_chunk_alloc, (void (*) ())obstack_chunk_free, (void *) 0, 0)
+
+#define obstack_full_begin(h,size,alignment,chunkfun,freefun,area_id,flags) \
+ _obstack_begin ((h), (size), (alignment), \
+ (void *(*) ()) (chunkfun), (void (*) ()) (freefun), \
+ (area_id), (flags))
+
+#define obstack_chunkfun(h, newchunkfun) \
+ ((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun))
+
+#define obstack_freefun(h, newfreefun) \
+ ((h) -> freefun = (void (*)()) (newfreefun))
+
+#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar)
+
+#define obstack_blank_fast(h,n) ((h)->next_free += (n))
+
+#if defined (__GNUC__) && defined (__STDC__)
+#if __GNUC__ < 2
+#define __extension__
+#endif
+
+/* For GNU C, if not -traditional,
+ we can define these macros to compute all args only once
+ without using a global variable.
+ Also, we can avoid using the `temp' slot, to make faster code. */
+
+#define obstack_object_size(OBSTACK) \
+ __extension__ \
+ ({ struct obstack *__o = (OBSTACK); \
+ (unsigned) (__o->next_free - __o->object_base); })
+
+#define obstack_room(OBSTACK) \
+ __extension__ \
+ ({ struct obstack *__o = (OBSTACK); \
+ (unsigned) (__o->chunk_limit - __o->next_free); })
+
+/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
+ so that we can avoid having void expressions
+ in the arms of the conditional expression.
+ Casting the third operand to void was tried before,
+ but some compilers won't accept it. */
+#define obstack_grow(OBSTACK,where,length) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ int __len = (length); \
+ ((__o->next_free + __len > __o->chunk_limit) \
+ ? (_obstack_newchunk (__o, __len), 0) : 0); \
+ bcopy (where, __o->next_free, __len); \
+ __o->next_free += __len; \
+ (void) 0; })
+
+#define obstack_grow0(OBSTACK,where,length) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ int __len = (length); \
+ ((__o->next_free + __len + 1 > __o->chunk_limit) \
+ ? (_obstack_newchunk (__o, __len + 1), 0) : 0), \
+ bcopy (where, __o->next_free, __len), \
+ __o->next_free += __len, \
+ *(__o->next_free)++ = 0; \
+ (void) 0; })
+
+#define obstack_1grow(OBSTACK,datum) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ ((__o->next_free + 1 > __o->chunk_limit) \
+ ? (_obstack_newchunk (__o, 1), 0) : 0), \
+ *(__o->next_free)++ = (datum); \
+ (void) 0; })
+
+/* These assume that the obstack alignment is good enough for pointers or ints,
+ and that the data added so far to the current object
+ shares that much alignment. */
+
+#define obstack_ptr_grow(OBSTACK,datum) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ ((__o->next_free + sizeof (void *) > __o->chunk_limit) \
+ ? (_obstack_newchunk (__o, sizeof (void *)), 0) : 0), \
+ *(*(void ***)&__o->next_free)++ = ((void *)datum); \
+ (void) 0; })
+
+#define obstack_int_grow(OBSTACK,datum) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ ((__o->next_free + sizeof (int) > __o->chunk_limit) \
+ ? (_obstack_newchunk (__o, sizeof (int)), 0) : 0), \
+ *(*(int **)&__o->next_free)++ = ((int)datum); \
+ (void) 0; })
+
+#define obstack_ptr_grow_fast(h,aptr) (*(*(void ***)&(h)->next_free)++ = (void *)aptr)
+#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint)
+
+#define obstack_blank(OBSTACK,length) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ int __len = (length); \
+ ((__o->chunk_limit - __o->next_free < __len) \
+ ? (_obstack_newchunk (__o, __len), 0) : 0); \
+ __o->next_free += __len; \
+ (void) 0; })
+
+#define obstack_alloc(OBSTACK,length) \
+__extension__ \
+({ struct obstack *__h = (OBSTACK); \
+ obstack_blank (__h, (length)); \
+ obstack_finish (__h); })
+
+#define obstack_copy(OBSTACK,where,length) \
+__extension__ \
+({ struct obstack *__h = (OBSTACK); \
+ obstack_grow (__h, (where), (length)); \
+ obstack_finish (__h); })
+
+#define obstack_copy0(OBSTACK,where,length) \
+__extension__ \
+({ struct obstack *__h = (OBSTACK); \
+ obstack_grow0 (__h, (where), (length)); \
+ obstack_finish (__h); })
+
+/* The local variable is named __o1 to avoid a name conflict
+ when obstack_blank is called. */
+#define obstack_finish(OBSTACK) \
+__extension__ \
+({ struct obstack *__o1 = (OBSTACK); \
+ void *value = (void *) __o1->object_base; \
+ if (__o1->next_free == value) \
+ __o1->flags |= OBSTACK_MAYBE_EMPTY_OBJECT; \
+ __o1->next_free \
+ = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
+ & ~ (__o1->alignment_mask)); \
+ ((__o1->next_free - (char *)__o1->chunk \
+ > __o1->chunk_limit - (char *)__o1->chunk) \
+ ? (__o1->next_free = __o1->chunk_limit) : 0); \
+ __o1->object_base = __o1->next_free; \
+ value; })
+
+#define obstack_free(OBSTACK, OBJ) \
+__extension__ \
+({ struct obstack *__o = (OBSTACK); \
+ void *__obj = (OBJ); \
+ if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \
+ __o->next_free = __o->object_base = __obj; \
+ else (obstack_free) (__o, __obj); })
+
+#else /* not __GNUC__ or not __STDC__ */
+
+#define obstack_object_size(h) \
+ (unsigned) ((h)->next_free - (h)->object_base)
+
+#define obstack_room(h) \
+ (unsigned) ((h)->chunk_limit - (h)->next_free)
+
+#define obstack_grow(h,where,length) \
+( (h)->temp = (length), \
+ (((h)->next_free + (h)->temp > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
+ bcopy (where, (h)->next_free, (h)->temp), \
+ (h)->next_free += (h)->temp)
+
+#define obstack_grow0(h,where,length) \
+( (h)->temp = (length), \
+ (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \
+ bcopy (where, (h)->next_free, (h)->temp), \
+ (h)->next_free += (h)->temp, \
+ *((h)->next_free)++ = 0)
+
+#define obstack_1grow(h,datum) \
+( (((h)->next_free + 1 > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), 1), 0) : 0), \
+ *((h)->next_free)++ = (datum))
+
+#define obstack_ptr_grow(h,datum) \
+( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
+ *(*(char ***)&(h)->next_free)++ = ((char *)datum))
+
+#define obstack_int_grow(h,datum) \
+( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
+ *(*(int **)&(h)->next_free)++ = ((int)datum))
+
+#define obstack_ptr_grow_fast(h,aptr) (*(*(char ***)&(h)->next_free)++ = (char *)aptr)
+#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint)
+#define obstack_blank(h,length) \
+( (h)->temp = (length), \
+ (((h)->chunk_limit - (h)->next_free < (h)->temp) \
+ ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
+ (h)->next_free += (h)->temp)
+
+#define obstack_alloc(h,length) \
+ (obstack_blank ((h), (length)), obstack_finish ((h)))
+
+#define obstack_copy(h,where,length) \
+ (obstack_grow ((h), (where), (length)), obstack_finish ((h)))
+
+#define obstack_copy0(h,where,length) \
+ (obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
+
+#define obstack_finish(h) \
+( ((h)->next_free == (h)->object_base \
+ ? (((h)->flags |= OBSTACK_MAYBE_EMPTY_OBJECT), 0) \
+ : 0), \
+ (h)->temp = __PTR_TO_INT ((h)->object_base), \
+ (h)->next_free \
+ = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \
+ & ~ ((h)->alignment_mask)), \
+ (((h)->next_free - (char *)(h)->chunk \
+ > (h)->chunk_limit - (char *)(h)->chunk) \
+ ? ((h)->next_free = (h)->chunk_limit) : 0), \
+ (h)->object_base = (h)->next_free, \
+ __INT_TO_PTR ((h)->temp))
+
+#ifdef __STDC__
+#define obstack_free(h,obj) \
+( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \
+ (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
+ ? (int) ((h)->next_free = (h)->object_base \
+ = (h)->temp + (char *) (h)->chunk) \
+ : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
+#else
+#define obstack_free(h,obj) \
+( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \
+ (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
+ ? (int) ((h)->next_free = (h)->object_base \
+ = (h)->temp + (char *) (h)->chunk) \
+ : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0)))
+#endif
+
+#endif /* not __GNUC__ or not __STDC__ */
+
+#endif /* not __OBSTACKS__ */
diff --git a/debugger/readline/Makefile b/debugger/readline/Makefile
index 77c6bfc..0ec3889 100644
--- a/debugger/readline/Makefile
+++ b/debugger/readline/Makefile
@@ -49,7 +49,7 @@
shar $(SHARFILES) >shar
clean:
- rm -f *.[oa] testit foo core tags lint lint.all a.out shar
+ rm -f *.[oa] testit foo core tags lint lint.all a.out shar *# *~
lint: testit
lint -a -b -u -x $(DEFS) $(SOURCES) testit.c >lint.all
diff --git a/debugger/regpos.h b/debugger/regpos.h
index c3d3086..d3c3a4f 100644
--- a/debugger/regpos.h
+++ b/debugger/regpos.h
@@ -25,9 +25,32 @@
#define RN_CR2 21
#endif
+#ifdef __NetBSD__
+/* Register numbers */
+#define RN_ESP 2
+#define RN_EBP 3
+#define RN_ESP_AT_SIGNAL 4
+#define RN_EIP 5
+#define RN_EFLAGS 6
+#define RN_ES 7
+#define RN_DS 8
+#define RN_CS 9
+#define RN_SS 10
+#define RN_EDI 11
+#define RN_ESI 12
+#define RN_EBX 13
+#define RN_EDX 14
+#define RN_ECX 15
+#define RN_EAX 16
+/* NetBSD doesn't context switch gs or fs */
+#define SC_GS 0x27
+#define SC_FS 0x27
+#endif
+#ifdef linux
#define SC_GS regval[RN_GS]
#define SC_FS regval[RN_FS]
+#endif
#define SC_ES regval[RN_ES]
#define SC_DS regval[RN_DS]
#define SC_EDI(dbg_mask) (regval[RN_EDI] & dbg_mask)
diff --git a/if1632/Makefile b/if1632/Makefile
index eac9218..0746063 100644
--- a/if1632/Makefile
+++ b/if1632/Makefile
@@ -16,7 +16,7 @@
$(LD) -r -o if1632.o $(OBJS)
clean:
- rm -f *.o *~ *.s dll_* *.a
+ rm -f *.o *~ *.s dll_* *.a *#
dll_kernel.S dll_kernel_tab.c: ../tools/build kernel.spec
../tools/build kernel.spec
diff --git a/if1632/call.S b/if1632/call.S
index e09c1f5..9da87f0 100644
--- a/if1632/call.S
+++ b/if1632/call.S
@@ -102,7 +102,7 @@
movl %esp,%eax
movl %eax,%ebp
#if 1
- movw $ UDATASEL,%ax
+ movw $UDATASEL,%ax
movw %ax,%fs
movw %ax,%gs
#endif
@@ -124,7 +124,7 @@
* GDT usage.
*/
pushl %eax
- movw $ UDATASEL,%ax
+ movw $UDATASEL,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%fs
@@ -204,7 +204,7 @@
* GDT usage.
*/
pushl %eax
- movw $ UDATASEL,%ax
+ movw $UDATASEL,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%fs
@@ -259,7 +259,7 @@
* Restore segment registers.
*/
pushl %eax
- movw $ UDATASEL,%ax
+ movw $UDATASEL,%ax
movw %ax,%ds
movw %ax,%es
popl %eax
@@ -359,21 +359,23 @@
* the return address, the saved registers, and the return
* address again.
*/
- popw %ax /* Throw away the number of arguments */
- popl %eax /* Throw away first copy of return address */
+ add $6,%esp /* argument count, return address */
+ popw %gs
+ add $2,%esp
+ popw %fs
+ add $2,%esp
popw %es
+ add $2,%esp
popw %ds
- popw %di
- popw %si
- popw %bp
- popw %ax /* Throw away pushed stack pointer */
- popw %bx
- popw %dx
- popw %cx
- popw %ax
+ add $2,%esp
+ popal
+ add $16,%esp /* trapno, err, eip, cs */
+ popfl
+ add $20,%esp /* esp, ss, i387, oldmask, cr2 */
/*
* Return to original caller.
*/
.byte 0x66
lret
+
diff --git a/if1632/callback.c b/if1632/callback.c
index 3c35e88..60a9e88 100644
--- a/if1632/callback.c
+++ b/if1632/callback.c
@@ -104,6 +104,7 @@
tp->thunk[4] = 0xd8;
tp->thunk[5] = 0xea;
memcpy(&tp->thunk[6], &func, 4);
+ tp->used = 1;
return tp->thunk;
}
@@ -141,9 +142,6 @@
PushOn16( CALLBACK_SIZE_WORD, message );
PushOn16( CALLBACK_SIZE_WORD, wParam );
PushOn16( CALLBACK_SIZE_LONG, lParam );
-
- printf("%8.8x(%4.4x, %4.4x, %4.4x, %8.8x)\n", func, hwnd, message, wParam, lParam);
-
return CallTo16((unsigned int) func,
FindDataSegmentForCode((unsigned long) func));
}
diff --git a/if1632/gdi.spec b/if1632/gdi.spec
index 6af75c1..a1fc5c5 100644
--- a/if1632/gdi.spec
+++ b/if1632/gdi.spec
@@ -131,6 +131,7 @@
346 pascal SetTextAlign(word word) SetTextAlign(1 2)
348 pascal Chord(word s_word s_word s_word s_word s_word s_word s_word s_word)
Chord(1 2 3 4 5 6 7 8 9)
+350 pascal GetCharWidth(word word word ptr) GetCharWidth(1 2 3 4)
360 pascal CreatePalette(ptr) CreatePalette(1)
363 pascal GetPaletteEntries(word word word ptr) GetPaletteEntries(1 2 3 4)
364 pascal SetPaletteEntries(word word word ptr) SetPaletteEntries(1 2 3 4)
diff --git a/if1632/kernel.spec b/if1632/kernel.spec
index 63eb008..755f843 100644
--- a/if1632/kernel.spec
+++ b/if1632/kernel.spec
@@ -44,7 +44,7 @@
86 pascal _lwrite(word ptr word) KERNEL__lwrite(1 2 3)
88 pascal lstrcpy(ptr ptr) lstrcpy(1 2)
89 pascal lstrcat(ptr ptr) lstrcat(1 2)
-90 pascal lstrlen(ptr) lstrcpy(1)
+90 pascal lstrlen(ptr) lstrlen(1)
91 register InitTask(word word word word word
word word word word word)
KERNEL_InitTask()
@@ -66,6 +66,7 @@
154 return GlobalNotify 4 0
163 pascal GlobalLRUOldest(word) ReturnArg(1)
164 pascal GlobalLRUNewest(word) ReturnArg(1)
+166 pascal WinExec(ptr word) WinExec(1 2)
178 equate __WINFLAGS 0x413
184 return GlobalDOSAlloc 4 0
185 return GlobalDOSFree 2 0
diff --git a/if1632/user.spec b/if1632/user.spec
index 4a32a6a..9f92bd8 100644
--- a/if1632/user.spec
+++ b/if1632/user.spec
@@ -15,9 +15,13 @@
15 pascal GetCurrentTime() GetTickCount()
18 pascal SetCapture(word) SetCapture(1)
19 pascal ReleaseCapture() ReleaseCapture()
+22 pascal SetFocus(word) SetFocus(1)
+23 pascal GetFocus() GetFocus()
31 pascal IsIconic(word) IsIconic(1)
+32 pascal GetWindowRect(word ptr) GetWindowRect(1 2)
33 pascal GetClientRect(word ptr) GetClientRect(1 2)
36 pascal GetWindowText(word ptr word) GetWindowText(1 2 3)
+37 pascal SetWindowText(word ptr) SetWindowText(1 2)
38 pascal GetWindowTextLength(word) GetWindowTextLength(1)
39 pascal BeginPaint(word ptr) BeginPaint(1 2)
40 pascal EndPaint(word ptr) EndPaint(1 2)
@@ -25,8 +29,13 @@
CreateWindow(1 2 3 4 5 6 7 8 9 10 11)
42 pascal ShowWindow(word word) ShowWindow(1 2)
46 pascal GetParent(word) GetParent(1)
+48 pascal IsChild(word word) IsChild(1 2)
53 pascal DestroyWindow(word) DestroyWindow(1)
+56 pascal MoveWindow(word word word word word word)
+ MoveWindow(1 2 3 4 5 6)
57 pascal RegisterClass(ptr) RegisterClass(1)
+62 pascal SetScrollPos(word word word word) SetScrollPos(1 2 3 4)
+64 pascal SetScrollRange(word word word word word) SetScrollRange(1 2 3 4 5)
66 pascal GetDC(word) GetDC(1)
68 pascal ReleaseDC(word word) ReleaseDC(1 2)
72 pascal SetRect(ptr s_word s_word s_word s_word) SetRect(1 2 3 4 5)
@@ -42,7 +51,22 @@
82 pascal InvertRect(word ptr) InvertRect(1 2)
83 pascal FrameRect(word ptr word) FrameRect(1 2 3)
85 pascal DrawText(word ptr s_word ptr word) DrawText(1 2 3 4 5)
+87 pascal DialogBox(word ptr word ptr) DialogBox(1 2 3 4)
+88 pascal EndDialog(word s_word) EndDialog(1 2)
+89 pascal CreateDialog(word ptr word ptr) CreateDialog(1 2 3 4)
+90 pascal IsDialogMessage(word ptr) IsDialogMessage(1 2)
+91 pascal GetDlgItem(word word) GetDlgItem(1 2)
+92 pascal SetDlgItemText(word ptr) SetDlgItemText(1 2)
+93 pascal GetDlgItemText(word word ptr word) GetDlgItemText(1 2 3 4)
+94 pascal SetDlgItemInt(word word word word) SetDlgItemInt(1 2 3 4)
+95 pascal GetDlgItemInt(word word ptr word) GetDlgItemInt(1 2 3 4)
+96 pascal CheckRadioButton(word word word word) CheckRadioButton(1 2 3 4)
+97 pascal CheckDlgButton(word word word) CheckDlgButton(1 2 3)
+98 pascal IsDlgButtonChecked(word word) IsDlgButtonChecked(1 2)
+101 pascal SendDlgItemMessage(word word word word long)
+ SendDlgItemMessage(1 2 3 4 5)
102 pascal AdjustWindowRect(ptr long word) AdjustWindowRect(1 2 3)
+103 pascal MapDialogRect(word ptr) MapDialogRect(1 2)
104 pascal MessageBeep(word) MessageBeep(1)
106 pascal GetKeyState(word) GetKeyState(1)
107 pascal DefWindowProc(word word word long) DefWindowProc(1 2 3 4)
@@ -55,6 +79,7 @@
118 pascal RegisterWindowMessage(ptr) RegisterWindowMessage(1)
119 pascal GetMessagePos() GetMessagePos()
120 pascal GetMessageTime() GetMessageTime()
+122 pascal CallWindowProc(ptr word word word long) CallWindowProc(1 2 3 4 5)
124 pascal UpdateWindow(word) UpdateWindow(1)
125 pascal InvalidateRect(word ptr word) InvalidateRect(1 2 3)
126 pascal InvalidateRgn(word word word) InvalidateRgn(1 2 3)
@@ -73,6 +98,7 @@
154 pascal CheckMenu(word word word) CheckMenu(1 2 3)
157 pascal GetMenu(word) GetMenu(1)
158 pascal SetMenu(word word) SetMenu(1 2)
+171 pascal WinHelp(word word long) WinHelp(1 2 3)
173 pascal LoadCursor(word ptr) LoadCursor(1 2)
174 pascal LoadIcon(word ptr) LoadIcon(1 2)
175 pascal LoadBitmap(word ptr) LoadBitmap(1 2)
@@ -81,27 +107,25 @@
179 pascal GetSystemMetrics(word) GetSystemMetrics(1)
180 pascal GetSysColor(word) GetSysColor(1)
181 pascal SetSysColors(word ptr ptr) SetSysColors(1 2 3)
-430 pascal lstrcmp(ptr ptr) lstrcmp(1 2)
-431 pascal AnsiUpper(ptr) AnsiUpper(1)
-432 pascal AnsiLower(ptr) AnsiLower(1)
-433 pascal IsCharAlpha(byte) IsCharAlpha(1)
-434 pascal IsCharAlphanumeric(byte) IsCharAlphanumeric(1)
-435 pascal IsCharUpper(byte) IsCharUpper(1)
-436 pascal IsCharLower(byte) IsCharLower(1)
-437 pascal AnsiUpperBuff(ptr word) AnsiUpperBuff(1 2)
-438 pascal AnsiLowerBuff(ptr word) AnsiLowerBuff(1 2)
-471 pascal lstrcmpi(ptr ptr) lstrcmpi(1 2)
-472 pascal AnsiNext(ptr) AnsiNext(1 )
-473 pascal AnsiPrev(ptr ptr) AnsiPrev(1 2)
-
-
-
-
182 pascal KillSystemTimer(word word) KillSystemTimer(1 2)
190 pascal GetUpdateRect(word ptr word) GetUpdateRect(1 2 3)
+219 pascal CreateDialogIndirect(word ptr word ptr)
+ CreateDialogIndirect(1 2 3 4)
+227 pascal GetNextDlgGroupItem(word word word) GetNextDlgGroupItem(1 2 3)
+228 pascal GetNextDlgTabItem(word word word) GetNextDlgTabItem(1 2 3)
+229 pascal GetTopWindow(word) GetTopWindow(1)
+230 pascal GetNextWindow(word word) GetNextWindow(1 2)
+232 pascal SetWindowPos(word word word word word word word)
+ SetWindowPos(1 2 3 4 5 6 7)
237 pascal GetUpdateRgn(word word word) GetUpdateRgn(1 2 3)
+241 pascal CreateDialogParam(word ptr word ptr long)
+ CreateDialogParam(1 2 3 4 5)
+242 pascal CreateDialogIndirectParam(word ptr word ptr long)
+ CreateDialogIndirectParam(1 2 3 4 5)
244 pascal EqualRect(ptr ptr) EqualRect(1 2)
+262 pascal GetWindow(word word) GetWindow(1 2)
266 pascal SetMessageQueue(word) SetMessageQueue(1)
+277 pascal GetDlgCtrlID(word) GetDlgCtrlID(1)
286 pascal GetDesktopWindow() GetDesktopWindow()
288 pascal GetMessageExtraInfo() GetMessageExtraInfo()
324 pascal FillWindow(word word word word) FillWindow(1 2 3 4)
@@ -111,4 +135,20 @@
373 pascal SubtractRect(ptr ptr ptr) SubtractRect(1 2 3)
403 pascal UnregisterClass(ptr word) UnregisterClass(1 2)
411 pascal AppendMenu(word word word ptr) AppendMenu(1 2 3 4)
+420 pascal wsprintf(ptr ptr) wsprintf(1 2)
421 pascal wvsprintf(ptr ptr ptr) wvsprintf(1 2 3)
+430 pascal lstrcmp(ptr ptr) lstrcmp(1 2)
+431 pascal AnsiUpper(ptr) AnsiUpper(1)
+432 pascal AnsiLower(ptr) AnsiLower(1)
+433 pascal IsCharAlpha(byte) IsCharAlpha(1)
+434 pascal IsCharAlphanumeric(byte) IsCharAlphanumeric(1)
+435 pascal IsCharUpper(byte) IsCharUpper(1)
+436 pascal IsCharLower(byte) IsCharLower(1)
+437 pascal AnsiUpperBuff(ptr word) AnsiUpperBuff(1 2)
+438 pascal AnsiLowerBuff(ptr word) AnsiLowerBuff(1 2)
+452 pascal CreateWindowEx(long ptr ptr long s_word s_word s_word s_word
+ word word word ptr)
+ CreateWindowEx(1 2 3 4 5 6 7 8 9 10 11 12)
+471 pascal lstrcmpi(ptr ptr) lstrcmpi(1 2)
+472 pascal AnsiNext(ptr) AnsiNext(1 )
+473 pascal AnsiPrev(ptr ptr) AnsiPrev(1 2)
diff --git a/include/combo.h b/include/combo.h
new file mode 100644
index 0000000..b6ea1d8
--- /dev/null
+++ b/include/combo.h
@@ -0,0 +1,15 @@
+/*
+ * Combo box definitions
+ */
+
+
+typedef struct tagHEADCOMBO {
+ DWORD dwStyle;
+ DWORD dwState;
+ HWND hWndDrop;
+ HWND hWndEdit;
+ HWND hWndLBox;
+} HEADCOMBO;
+typedef HEADCOMBO FAR* LPHEADCOMBO;
+
+
diff --git a/include/dialog.h b/include/dialog.h
new file mode 100644
index 0000000..190c8c9
--- /dev/null
+++ b/include/dialog.h
@@ -0,0 +1,79 @@
+/*
+ * Dialog definitions
+ *
+ * Copyright 1993 Alexandre Julliard
+ */
+
+#ifndef DIALOG_H
+#define DIALOG_H
+
+#include "windows.h"
+
+#define DIALOG_CLASS_NAME "#32770" /* Integer atom */
+
+
+ /* Dialog info structure.
+ * This structure is stored into the window extra bytes (cbWndExtra).
+ * sizeof(DIALOGINFO) must be <= DLGWINDOWEXTRA (=30).
+ */
+typedef struct
+{
+ LONG msgResult;
+ FARPROC dlgProc;
+ LONG userInfo;
+ HWND hwndFocus;
+ HFONT hUserFont;
+ HMENU hMenu;
+ WORD xBaseUnit;
+ WORD yBaseUnit;
+ WORD fEnd;
+} DIALOGINFO;
+
+
+ /* Dialog template header */
+typedef struct
+{
+ DWORD style;
+ BYTE nbItems __attribute__ ((packed));
+ WORD x __attribute__ ((packed));
+ WORD y __attribute__ ((packed));
+ WORD cx __attribute__ ((packed));
+ WORD cy __attribute__ ((packed));
+} DLGTEMPLATEHEADER;
+
+
+ /* Dialog control header */
+typedef struct
+{
+ WORD x;
+ WORD y;
+ WORD cx;
+ WORD cy;
+ WORD id;
+ DWORD style __attribute__ ((packed));
+} DLGCONTROLHEADER;
+
+
+ /* Dialog control data */
+typedef struct
+{
+ DLGCONTROLHEADER * header;
+ LPSTR class;
+ LPSTR text;
+} DLGCONTROL;
+
+
+ /* Dialog template */
+typedef struct
+{
+ DLGTEMPLATEHEADER * header;
+ unsigned char * menuName;
+ LPSTR className;
+ LPSTR caption;
+ WORD pointSize;
+ LPSTR faceName;
+ DLGCONTROL * controls;
+} DLGTEMPLATE;
+
+
+#endif /* DIALOG_H */
diff --git a/include/files.h b/include/files.h
new file mode 100644
index 0000000..1b628a2
--- /dev/null
+++ b/include/files.h
@@ -0,0 +1,17 @@
+#ifndef _FILES_H
+#define _FILES_H
+
+#define OPEN_MAX 256
+
+/***************************************************************************
+ This structure stores the infomation needed for a single DOS drive
+ ***************************************************************************/
+struct DosDriveStruct
+{
+ char RootDirectory [256]; /* Unix base for this drive letter */
+ char CurrentDirectory [256]; /* Current directory for this drive */
+ char VolumeLabel [11];
+ unsigned long serialnumber;
+};
+
+#endif /*_FILES_H*/
diff --git a/include/int21.h b/include/int21.h
new file mode 100644
index 0000000..92cabc5
--- /dev/null
+++ b/include/int21.h
@@ -0,0 +1,93 @@
+#ifndef INT21_H
+#define INT21_H
+
+#define DosVersion 0x0303;
+
+#define SectorSize 0x200;
+#define SectorsPerCluster 0x04;
+
+#define AX context->sc_eax
+#define BX context->sc_ebx
+#define CX context->sc_ecx
+#define DX context->sc_edx
+#define ES context->sc_es
+#define DS context->sc_ds
+#define DI context->sc_edi
+#define SI context->sc_esi
+
+#define pointer(a,b) (((unsigned int) a << 16) | b)
+#define segment(a) (a >> 16)
+#define offset(a) (a & 0xffff)
+
+#define SetCflag (context->sc_efl |= 0x00000001L)
+#define ResetCflag (context->sc_efl &= 0xfffffffeL)
+
+struct diskinfo {
+ WORD infolevel;
+ DWORD serialnumber;
+ char label[11];
+ char fstype[8];
+};
+
+/* extended error codes */
+
+#define NoError 0x00
+#define InvalidFunction 0x01
+#define FileNotFound 0x02
+#define PathNotFound 0x03
+#define AccessDenied 0x05
+#define InvalidHandle 0x06
+#define MCBDestroyed 0x07
+#define OutOfMemory 0x08
+#define MCBInvalid 0x09
+#define DataInvalid 0x0d
+#define InvalidDrive 0x0f
+#define CanNotRemoveCwd 0x10
+#define NotSameDevice 0x11
+#define NoMoreFiles 0x12
+#define WriteProtected 0x13
+#define UnknownUnit 0x14
+#define DriveNotReady 0x15
+#define UnknownCommand 0x16
+#define CRCError 0x17
+#define BadRqLength 0x18
+#define SeekError 0x19
+#define UnknownMedia 0x1a
+#define SectorNotFound 0x1b
+#define OutOfPaper 0x1c
+#define WriteFault 0x1d
+#define ReadFault 0x1e
+#define GeneralFailure 0x1f
+#define ShareViolation 0x20
+#define LockViolation 0x21
+#define DiskFull 0x27
+#define NoNetwork 0x49
+#define FileExists 0x50
+#define CanNotMakeDir 0x52
+
+/* Error classes */
+
+#define EC_Temporary 0x02
+#define EC_AccessDenied 0x03
+#define EC_AppError 0x04
+#define EC_SystemFailure 0x06
+#define EC_NotFound 0x08
+#define EC_MediaError 0x0b
+#define EC_Exists 0x0c
+#define EC_Unknown 0x0d
+
+/* Suggested actions */
+
+#define SA_Retry 0x01
+#define SA_Abort 0x04
+#define SA_Ignore 0x06
+#define SA_Ask4Retry 0x07
+
+/* Error locus */
+
+#define EL_Unknown 0x01
+#define EL_Disk 0x02
+#define EL_Network 0x03
+#define EL_Memory 0x05
+
+#endif /* INT21_H */
diff --git a/include/listbox.h b/include/listbox.h
new file mode 100644
index 0000000..f44cf8c
--- /dev/null
+++ b/include/listbox.h
@@ -0,0 +1,31 @@
+/*
+ * List Box definitions
+ */
+
+
+typedef struct tagLISTSTRUCT {
+ DRAWITEMSTRUCT dis;
+ HANDLE hMem;
+ HANDLE hData;
+ void *lpNext;
+} LISTSTRUCT;
+typedef LISTSTRUCT FAR* LPLISTSTRUCT;
+
+
+typedef struct tagHEADLIST {
+ short FirstVisible;
+ short ItemSelect;
+ short ItemsCount;
+ short ItemsVisible;
+ short ItemSelected;
+ short PrevSelected;
+ short StdItemHeight;
+ short DrawCtlType;
+ void *lpFirst;
+ DWORD dwStyle;
+ HWND hWndScroll;
+ HWND hWndLogicParent;
+} HEADLIST;
+typedef HEADLIST FAR* LPHEADLIST;
+
+
diff --git a/include/prototypes.h b/include/prototypes.h
index 39560dd..c1c7bf9 100644
--- a/include/prototypes.h
+++ b/include/prototypes.h
@@ -30,5 +30,8 @@
extern struct mz_header_s *CurrentMZHeader;
extern struct ne_header_s *CurrentNEHeader;
extern int CurrentNEFile;
+extern do_int1A(struct sigcontext_struct * context);
+extern do_int21(struct sigcontext_struct * context);
#endif /* PROTOTYPES_H */
+
diff --git a/include/regfunc.h b/include/regfunc.h
index 263675f..e31e9aa 100644
--- a/include/regfunc.h
+++ b/include/regfunc.h
@@ -6,16 +6,16 @@
extern unsigned short *Stack16Frame;
-#define _AX Stack16Frame[21]
-#define _BX Stack16Frame[18]
-#define _CX Stack16Frame[20]
-#define _DX Stack16Frame[19]
-#define _SP Stack16Frame[17]
-#define _BP Stack16Frame[16]
-#define _SI Stack16Frame[15]
-#define _DI Stack16Frame[14]
-#define _DS Stack16Frame[13]
-#define _ES Stack16Frame[12]
+#define _AX Stack16Frame[34]
+#define _BX Stack16Frame[28]
+#define _CX Stack16Frame[32]
+#define _DX Stack16Frame[30]
+#define _SP Stack16Frame[26]
+#define _BP Stack16Frame[24]
+#define _SI Stack16Frame[22]
+#define _DI Stack16Frame[20]
+#define _DS Stack16Frame[18]
+#define _ES Stack16Frame[16]
extern void ReturnFromRegisterFunc(void);
diff --git a/include/scroll.h b/include/scroll.h
new file mode 100644
index 0000000..4dd4e7d
--- /dev/null
+++ b/include/scroll.h
@@ -0,0 +1,20 @@
+/*
+ * Scroll Bar definitions
+ */
+
+
+typedef struct tagHEADSSCROLL {
+ short CurVal;
+ short MinVal;
+ short MaxVal;
+ short MaxPix;
+ short CurPix;
+ BOOL ThumbActive;
+ WORD Direction;
+ DWORD dwStyle;
+ HWND hWndUp;
+ HWND hWndDown;
+} HEADSCROLL;
+typedef HEADSCROLL FAR* LPHEADSCROLL;
+
+
diff --git a/include/windows.h b/include/windows.h
index 9c8e0d2..dd937c5 100644
--- a/include/windows.h
+++ b/include/windows.h
@@ -5,6 +5,7 @@
#ifndef _WINARGS
+typedef unsigned short UINT;
typedef unsigned short WORD;
typedef unsigned long DWORD;
#ifndef _WINMAIN
@@ -12,6 +13,61 @@
typedef unsigned char BYTE;
#endif
typedef long LONG;
+typedef UINT WPARAM;
+typedef LONG LPARAM;
+typedef LONG LRESULT;
+typedef WORD HANDLE;
+#define DECLARE_HANDLE(a) typedef HANDLE a;
+
+DECLARE_HANDLE(HTASK);
+DECLARE_HANDLE(HDRVR);
+DECLARE_HANDLE(HWND);
+DECLARE_HANDLE(HDC);
+DECLARE_HANDLE(HCLASS);
+DECLARE_HANDLE(HCURSOR);
+DECLARE_HANDLE(HFONT);
+DECLARE_HANDLE(HPEN);
+DECLARE_HANDLE(HRGN);
+DECLARE_HANDLE(HPALETTE);
+DECLARE_HANDLE(HICON);
+DECLARE_HANDLE(HINSTANCE);
+DECLARE_HANDLE(HMENU);
+DECLARE_HANDLE(HBITMAP);
+DECLARE_HANDLE(HBRUSH);
+DECLARE_HANDLE(LOCALHANDLE);
+
+typedef char *LPSTR;
+typedef const char *LPCSTR;
+typedef char *NPSTR;
+typedef short *LPINT;
+typedef void *LPVOID;
+typedef long (*FARPROC)();
+typedef int CATCHBUF[9];
+typedef int *LPCATCHBUF;
+
+#define TRUE 1
+#define FALSE 0
+#define CW_USEDEFAULT ((short)0x8000)
+#define FAR
+#define NEAR
+#define PASCAL
+#define VOID void
+#define WINAPI PASCAL
+#define CALLBACK PASCAL
+#ifndef NULL
+#define NULL (void *)0
+#endif
+
+#define LOBYTE(w) ((BYTE)(w))
+#define HIBYTE(w) ((BYTE)((UINT)(w) >> 8))
+
+#define LOWORD(l) ((WORD)(l))
+#define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
+
+#define MAKELONG(low, high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
+
+/*
+typedef long LONG;
typedef WORD HANDLE;
typedef HANDLE HWND;
typedef HANDLE HDC;
@@ -44,6 +100,7 @@
#ifndef NULL
#define NULL (void *)0
#endif
+*/
#define MAKELPARAM(low, high) ((LONG)(((WORD)(low)) | \
(((DWORD)((WORD)(high))) << 16)))
@@ -133,6 +190,46 @@
#define DWL_DLGPROC 4
#define DWL_USER 8
+ /* GetWindow() constants */
+#define GW_HWNDFIRST 0
+#define GW_HWNDLAST 1
+#define GW_HWNDNEXT 2
+#define GW_HWNDPREV 3
+#define GW_OWNER 4
+#define GW_CHILD 5
+
+ /* Dialogs */
+
+ /* cbWndExtra bytes for dialog class */
+#define DLGWINDOWEXTRA 30
+
+ /* Dialog styles */
+#define DS_ABSALIGN 0x001
+#define DS_SYSMODAL 0x002
+#define DS_LOCALEDIT 0x020
+#define DS_SETFONT 0x040
+#define DS_MODALFRAME 0x080
+#define DS_NOIDLEMSG 0x100
+
+ /* Dialog messages */
+#define DM_GETDEFID (WM_USER+0)
+#define DM_SETDEFID (WM_USER+1)
+
+#define DC_HASDEFID 0x534b
+
+ /* WM_GETDLGCODE values */
+#define DLGC_WANTARROWS 0x0001
+#define DLGC_WANTTAB 0x0002
+#define DLGC_WANTALLKEYS 0x0004
+#define DLGC_WANTMESSAGE 0x0004
+#define DLGC_HASSETSEL 0x0008
+#define DLGC_DEFPUSHBUTTON 0x0010
+#define DLGC_UNDEFPUSHBUTTON 0x0020
+#define DLGC_RADIOBUTTON 0x0040
+#define DLGC_WANTCHARS 0x0080
+#define DLGC_STATIC 0x0100
+#define DLGC_BUTTON 0x2000
+
typedef struct { short x, y; } POINT;
typedef POINT *PPOINT;
@@ -787,6 +884,11 @@
WM_DELETEITEM, WM_VKEYTOITEM,
WM_CHARTOITEM, WM_SETFONT, WM_GETFONT };
+#define WM_NCCREATE 0x0081
+#define WM_NCDESTROY 0x0082
+
+#define WM_GETDLGCODE 0x0087
+
/* Keyboard messages */
#define WM_KEYDOWN 0x0100
#define WM_KEYUP 0x0101
@@ -798,11 +900,16 @@
#define WM_SYSDEADCHAR 0x0107
#define WM_KEYFIRST WM_KEYDOWN
#define WM_KEYLAST 0x0108
-
+
+#define WM_INITDIALOG 0x0110
#define WM_COMMAND 0x0111
#define WM_TIMER 0x0113
#define WM_SYSTIMER 0x0118
+ /* scroll messages */
+#define WM_HSCROLL 0x0114
+#define WM_VSCROLL 0x0115
+
/* Mouse messages */
#define WM_MOUSEMOVE 0x0200
#define WM_LBUTTONDOWN 0x0201
@@ -817,6 +924,13 @@
#define WM_MOUSEFIRST WM_MOUSEMOVE
#define WM_MOUSELAST WM_MBUTTONDBLCLK
+#define WM_PARENTNOTIFY 0x0210
+
+ /* misc messages */
+#define WM_NULL 0x0000
+#define WM_USER 0x0400
+
+
/* Key status flags for mouse events */
#define MK_LBUTTON 0x0001
#define MK_RBUTTON 0x0002
@@ -851,6 +965,30 @@
#define SIZE_MAXSHOW 3
#define SIZE_MAXHIDE 4
+/* SetWindowPos() and WINDOWPOS flags */
+#define SWP_NOSIZE 0x0001
+#define SWP_NOMOVE 0x0002
+#define SWP_NOZORDER 0x0004
+#define SWP_NOREDRAW 0x0008
+#define SWP_NOACTIVATE 0x0010
+#define SWP_FRAMECHANGED 0x0020 /* The frame changed: send WM_NCCALCSIZE */
+#define SWP_SHOWWINDOW 0x0040
+#define SWP_HIDEWINDOW 0x0080
+#define SWP_NOCOPYBITS 0x0100
+#define SWP_NOOWNERZORDER 0x0200 /* Don't do owner Z ordering */
+
+#define SWP_DRAWFRAME SWP_FRAMECHANGED
+#define SWP_NOREPOSITION SWP_NOOWNERZORDER
+
+#define SWP_NOSENDCHANGING 0x0400
+#define SWP_DEFERERASE 0x2000
+
+/* SetWindowPos() hwndInsertAfter field values */
+#define HWND_TOP ((HWND)0)
+#define HWND_BOTTOM ((HWND)1)
+#define HWND_TOPMOST ((HWND)-1)
+#define HWND_NOTOPMOST ((HWND)-2)
+
#define MF_INSERT 0
#define MF_CHANGE 0x0080
@@ -934,6 +1072,13 @@
#define WS_CHILDWINDOW (WS_CHILD)
#define WS_TILEDWINDOW (WS_OVERLAPPEDWINDOW)
+/* Window extended styles */
+#define WS_EX_DLGMODALFRAME 0x00000001L
+#define WS_EX_NOPARENTNOTIFY 0x00000004L
+#define WS_EX_TOPMOST 0x00000008L
+#define WS_EX_ACCEPTFILES 0x00000010L
+#define WS_EX_TRANSPARENT 0x00000020L
+
/* Button control styles */
#define BS_PUSHBUTTON 0x00000000L
#define BS_DEFPUSHBUTTON 0x00000001L
@@ -948,16 +1093,310 @@
#define BS_OWNERDRAW 0x0000000BL
#define BS_LEFTTEXT 0x00000020L
+/* Button control messages */
+#define BM_GETCHECK (WM_USER+0)
+#define BM_SETCHECK (WM_USER+1)
+#define BM_GETSTATE (WM_USER+2)
+#define BM_SETSTATE (WM_USER+3)
+#define BM_SETSTYLE (WM_USER+4)
+
/* Button notification codes */
#define BN_CLICKED 0
#define BN_PAINT 1
#define BN_HILITE 2
-#define BN_UNLITE 3
+#define BN_UNHILITE 3
#define BN_DISABLE 4
#define BN_DOUBLECLICKED 5
+/* Static Control Styles */
+#define SS_LEFT 0x00000000L
+#define SS_CENTER 0x00000001L
+#define SS_RIGHT 0x00000002L
+#define SS_ICON 0x00000003L
+#define SS_BLACKRECT 0x00000004L
+#define SS_GRAYRECT 0x00000005L
+#define SS_WHITERECT 0x00000006L
+#define SS_BLACKFRAME 0x00000007L
+#define SS_GRAYFRAME 0x00000008L
+#define SS_WHITEFRAME 0x00000009L
+#define SS_SIMPLE 0x0000000BL
+#define SS_LEFTNOWORDWRAP 0x0000000CL
+#define SS_NOPREFIX 0x00000080L
-#define GMEM_MOVEABLE 0x0002
+/* Static Control Mesages */
+#define STM_SETICON (WM_USER+0)
+#define STM_GETICON (WM_USER+1)
+
+/* WM_H/VSCROLL commands */
+#define SB_LINEUP 0
+#define SB_LINELEFT 0
+#define SB_LINEDOWN 1
+#define SB_LINERIGHT 1
+#define SB_PAGEUP 2
+#define SB_PAGELEFT 2
+#define SB_PAGEDOWN 3
+#define SB_PAGERIGHT 3
+#define SB_THUMBPOSITION 4
+#define SB_THUMBTRACK 5
+#define SB_TOP 6
+#define SB_LEFT 6
+#define SB_BOTTOM 7
+#define SB_RIGHT 7
+#define SB_ENDSCROLL 8
+
+/* Scroll bar selection constants */
+#define SB_HORZ 0
+#define SB_VERT 1
+#define SB_CTL 2
+#define SB_BOTH 3
+
+/* Scrollbar styles */
+#define SBS_HORZ 0x0000L
+#define SBS_VERT 0x0001L
+#define SBS_TOPALIGN 0x0002L
+#define SBS_LEFTALIGN 0x0002L
+#define SBS_BOTTOMALIGN 0x0004L
+#define SBS_RIGHTALIGN 0x0004L
+#define SBS_SIZEBOXTOPLEFTALIGN 0x0002L
+#define SBS_SIZEBOXBOTTOMRIGHTALIGN 0x0004L
+#define SBS_SIZEBOX 0x0008L
+
+/* EnableScrollBar() flags */
+#define ESB_ENABLE_BOTH 0x0000
+#define ESB_DISABLE_BOTH 0x0003
+
+#define ESB_DISABLE_LEFT 0x0001
+#define ESB_DISABLE_RIGHT 0x0002
+
+#define ESB_DISABLE_UP 0x0001
+#define ESB_DISABLE_DOWN 0x0002
+
+#define ESB_DISABLE_LTUP ESB_DISABLE_LEFT
+#define ESB_DISABLE_RTDN ESB_DISABLE_RIGHT
+
+/* Listbox styles */
+#define LBS_NOTIFY 0x0001L
+#define LBS_SORT 0x0002L
+#define LBS_NOREDRAW 0x0004L
+#define LBS_MULTIPLESEL 0x0008L
+#define LBS_OWNERDRAWFIXED 0x0010L
+#define LBS_OWNERDRAWVARIABLE 0x0020L
+#define LBS_HASSTRINGS 0x0040L
+#define LBS_USETABSTOPS 0x0080L
+#define LBS_NOINTEGRALHEIGHT 0x0100L
+#define LBS_MULTICOLUMN 0x0200L
+#define LBS_WANTKEYBOARDINPUT 0x0400L
+#define LBS_EXTENDEDSEL 0x0800L
+#define LBS_DISABLENOSCROLL 0x1000L
+#define LBS_STANDARD (LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER)
+
+/* Listbox messages */
+#define LB_ADDSTRING (WM_USER+1)
+#define LB_INSERTSTRING (WM_USER+2)
+#define LB_DELETESTRING (WM_USER+3)
+#define LB_RESETCONTENT (WM_USER+5)
+#define LB_SETSEL (WM_USER+6)
+#define LB_SETCURSEL (WM_USER+7)
+#define LB_GETSEL (WM_USER+8)
+#define LB_GETCURSEL (WM_USER+9)
+#define LB_GETTEXT (WM_USER+10)
+#define LB_GETTEXTLEN (WM_USER+11)
+#define LB_GETCOUNT (WM_USER+12)
+#define LB_SELECTSTRING (WM_USER+13)
+#define LB_DIR (WM_USER+14)
+#define LB_GETTOPINDEX (WM_USER+15)
+#define LB_FINDSTRING (WM_USER+16)
+#define LB_GETSELCOUNT (WM_USER+17)
+#define LB_GETSELITEMS (WM_USER+18)
+#define LB_SETTABSTOPS (WM_USER+19)
+#define LB_GETHORIZONTALEXTENT (WM_USER+20)
+#define LB_SETHORIZONTALEXTENT (WM_USER+21)
+#define LB_SETCOLUMNWIDTH (WM_USER+22)
+#define LB_SETTOPINDEX (WM_USER+24)
+#define LB_GETITEMRECT (WM_USER+25)
+#define LB_GETITEMDATA (WM_USER+26)
+#define LB_SETITEMDATA (WM_USER+27)
+#define LB_SELITEMRANGE (WM_USER+28)
+#define LB_SETCARETINDEX (WM_USER+31)
+#define LB_GETCARETINDEX (WM_USER+32)
+#define LB_SETITEMHEIGHT (WM_USER+33)
+#define LB_GETITEMHEIGHT (WM_USER+34)
+#define LB_FINDSTRINGEXACT (WM_USER+35)
+
+/* Listbox notification codes */
+#define LBN_ERRSPACE (-2)
+#define LBN_SELCHANGE 1
+#define LBN_DBLCLK 2
+#define LBN_SELCANCEL 3
+#define LBN_SETFOCUS 4
+#define LBN_KILLFOCUS 5
+
+/* Listbox notification messages */
+#define WM_VKEYTOITEM 0x002E
+#define WM_CHARTOITEM 0x002F
+
+/* Listbox message return values */
+#define LB_OKAY 0
+#define LB_ERR (-1)
+#define LB_ERRSPACE (-2)
+
+#define LB_CTLCODE 0L
+
+/* Combo box styles */
+#define CBS_SIMPLE 0x0001L
+#define CBS_DROPDOWN 0x0002L
+#define CBS_DROPDOWNLIST 0x0003L
+#define CBS_OWNERDRAWFIXED 0x0010L
+#define CBS_OWNERDRAWVARIABLE 0x0020L
+#define CBS_AUTOHSCROLL 0x0040L
+#define CBS_OEMCONVERT 0x0080L
+#define CBS_SORT 0x0100L
+#define CBS_HASSTRINGS 0x0200L
+#define CBS_NOINTEGRALHEIGHT 0x0400L
+#define CBS_DISABLENOSCROLL 0x0800L
+
+/* Combo box messages */
+#define CB_GETEDITSEL (WM_USER+0)
+#define CB_LIMITTEXT (WM_USER+1)
+#define CB_SETEDITSEL (WM_USER+2)
+#define CB_ADDSTRING (WM_USER+3)
+#define CB_DELETESTRING (WM_USER+4)
+#define CB_DIR (WM_USER+5)
+#define CB_GETCOUNT (WM_USER+6)
+#define CB_GETCURSEL (WM_USER+7)
+#define CB_GETLBTEXT (WM_USER+8)
+#define CB_GETLBTEXTLEN (WM_USER+9)
+#define CB_INSERTSTRING (WM_USER+10)
+#define CB_RESETCONTENT (WM_USER+11)
+#define CB_FINDSTRING (WM_USER+12)
+#define CB_SELECTSTRING (WM_USER+13)
+#define CB_SETCURSEL (WM_USER+14)
+#define CB_SHOWDROPDOWN (WM_USER+15)
+#define CB_GETITEMDATA (WM_USER+16)
+#define CB_SETITEMDATA (WM_USER+17)
+#define CB_GETDROPPEDCONTROLRECT (WM_USER+18)
+#define CB_SETITEMHEIGHT (WM_USER+19)
+#define CB_GETITEMHEIGHT (WM_USER+20)
+#define CB_SETEXTENDEDUI (WM_USER+21)
+#define CB_GETEXTENDEDUI (WM_USER+22)
+#define CB_GETDROPPEDSTATE (WM_USER+23)
+#define CB_FINDSTRINGEXACT (WM_USER+24)
+
+/* Combo box notification codes */
+#define CBN_ERRSPACE (-1)
+#define CBN_SELCHANGE 1
+#define CBN_DBLCLK 2
+#define CBN_SETFOCUS 3
+#define CBN_KILLFOCUS 4
+#define CBN_EDITCHANGE 5
+#define CBN_EDITUPDATE 6
+#define CBN_DROPDOWN 7
+#define CBN_CLOSEUP 8
+#define CBN_SELENDOK 9
+#define CBN_SELENDCANCEL 10
+
+/* Combo box message return values */
+#define CB_OKAY 0
+#define CB_ERR (-1)
+#define CB_ERRSPACE (-2)
+
+
+/* Owner draw control types */
+#define ODT_MENU 1
+#define ODT_LISTBOX 2
+#define ODT_COMBOBOX 3
+#define ODT_BUTTON 4
+
+/* Owner draw actions */
+#define ODA_DRAWENTIRE 0x0001
+#define ODA_SELECT 0x0002
+#define ODA_FOCUS 0x0004
+
+/* Owner draw state */
+#define ODS_SELECTED 0x0001
+#define ODS_GRAYED 0x0002
+#define ODS_DISABLED 0x0004
+#define ODS_CHECKED 0x0008
+#define ODS_FOCUS 0x0010
+
+#define WM_DRAWITEM 0x002B
+
+typedef struct tagDRAWITEMSTRUCT
+{
+ UINT CtlType;
+ UINT CtlID;
+ UINT itemID;
+ UINT itemAction;
+ UINT itemState;
+ HWND hwndItem;
+ HDC hDC;
+ RECT rcItem;
+ DWORD itemData;
+} DRAWITEMSTRUCT;
+typedef DRAWITEMSTRUCT NEAR* PDRAWITEMSTRUCT;
+typedef DRAWITEMSTRUCT FAR* LPDRAWITEMSTRUCT;
+
+#define WM_MEASUREITEM 0x002C
+
+typedef struct tagMEASUREITEMSTRUCT
+{
+ UINT CtlType;
+ UINT CtlID;
+ UINT itemID;
+ UINT itemWidth;
+ UINT itemHeight;
+ DWORD itemData;
+} MEASUREITEMSTRUCT;
+typedef MEASUREITEMSTRUCT NEAR* PMEASUREITEMSTRUCT;
+typedef MEASUREITEMSTRUCT FAR* LPMEASUREITEMSTRUCT;
+
+#define WM_DELETEITEM 0x002D
+
+typedef struct tagDELETEITEMSTRUCT
+{
+ UINT CtlType;
+ UINT CtlID;
+ UINT itemID;
+ HWND hwndItem;
+ DWORD itemData;
+} DELETEITEMSTRUCT;
+typedef DELETEITEMSTRUCT NEAR* PDELETEITEMSTRUCT;
+typedef DELETEITEMSTRUCT FAR* LPDELETEITEMSTRUCT;
+
+#define WM_COMPAREITEM 0x0039
+
+typedef struct tagCOMPAREITEMSTRUCT
+{
+ UINT CtlType;
+ UINT CtlID;
+ HWND hwndItem;
+ UINT itemID1;
+ DWORD itemData1;
+ UINT itemID2;
+ DWORD itemData2;
+} COMPAREITEMSTRUCT;
+typedef COMPAREITEMSTRUCT NEAR* PCOMPAREITEMSTRUCT;
+typedef COMPAREITEMSTRUCT FAR* LPCOMPAREITEMSTRUCT;
+
+
+#define LMEM_MOVEABLE 0x0002
+
+#define GMEM_FIXED 0x0000
+#define GMEM_MOVEABLE 0x0002
+#define GMEM_NOCOMPACT 0x0010
+#define GMEM_NODISCARD 0x0020
+#define GMEM_ZEROINIT 0x0040
+#define GMEM_MODIFY 0x0080
+#define GMEM_DISCARDABLE 0x0100
+#define GMEM_NOT_BANKED 0x1000
+#define GMEM_SHARE 0x2000
+#define GMEM_DDESHARE 0x2000
+#define GMEM_NOTIFY 0x4000
+#define GMEM_LOWER GMEM_NOT_BANKED
+
+#define GHND (GMEM_MOVEABLE | GMEM_ZEROINIT)
+#define GPTR (GMEM_FIXED | GMEM_ZEROINIT)
+
#define F(ret,name) ret name(void);
#define Fa(ret,name,t1,a1) ret name(t1 a1);
@@ -991,6 +1430,7 @@
F(BOOL,EmptyClipboard)
F(BOOL,InSendMessage)
F(DWORD,GetCurrentTime)
+F(DWORD,GetDialogBaseUnits)
F(DWORD,GetTickCount)
F(HANDLE,GetCurrentTask)
F(HMENU,CreatePopupMenu)
@@ -1020,7 +1460,6 @@
F(int,StartSound)
F(int,StopSound)
F(int,SyncAllVoices)
-F(long,GetDialogBaseUnits)
F(void,CloseSound)
F(void,DebugBreak)
F(void,DestroyCaret)
@@ -1043,7 +1482,7 @@
Fa(BOOL,SetMessageQueue,int,a)
Fa(int,_lclose,int,a)
Fb(int,_lopen,LPSTR,a,int,b)
-Fa(int,lstrlen,LPSTR,a)
+Fa(int,lstrlen,LPCSTR,a)
Fa(LONG,DispatchMessage,LPMSG,msg)
Fa(void,UpdateWindow,HWND,a)
Fa(ATOM,AddAtom,LPSTR,a)
@@ -1230,11 +1669,11 @@
Fb(BOOL,GetBitmapDimensionEx,HBITMAP,a,LPSIZE,b)
Fb(BOOL,ShowWindow,HWND,a,int,b)
Fb(HDC,BeginPaint,HWND,a,LPPAINTSTRUCT,b)
-Fb(LPSTR,lstrcat,LPSTR,a,LPSTR,b )
-Fb(LPSTR,lstrcpy,LPSTR,a,LPSTR,b )
+Fb(LPSTR,lstrcat,LPSTR,a,LPCSTR,b )
+Fb(LPSTR,lstrcpy,LPSTR,a,LPCSTR,b )
Fb(int,_lcreat,LPSTR,a,int,b)
-Fb(int,lstrcmp,LPSTR,a,LPSTR,b )
-Fb(int,lstrcmpi,LPSTR,a,LPSTR,b )
+Fb(int,lstrcmp,LPCSTR,a,LPCSTR,b )
+Fb(int,lstrcmpi,LPCSTR,a,LPCSTR,b )
Fb(void,EndPaint,HWND,a,LPPAINTSTRUCT,b)
Fb(void,GetClientRect,HWND,a,LPRECT,b)
Fb(void,SetDCState,HDC,a,HDC,b)
@@ -1291,7 +1730,7 @@
Fb(HMENU,LoadMenu,HANDLE,a,LPSTR,b)
Fb(HWND,ChildWindowFromPoint,HWND,a,POINT,b)
Fb(HWND,FindWindow,LPSTR,a,LPSTR,b)
-Fb(HWND,GetDlgItem,HWND,a,int,b)
+Fb(HWND,GetDlgItem,HWND,a,WORD,b)
Fb(HWND,GetNextWindow,HWND,a,WORD,b)
Fb(HWND,GetWindow,HWND,a,WORD,b)
Fb(BOOL,GetCurrentPositionEx,HDC,a,LPPOINT,b)
@@ -1315,7 +1754,7 @@
Fb(WORD,GetSystemPaletteUse,HDC,a,WORD,b)
Fb(WORD,GetWindowWord,HWND,a,short,b)
Fb(WORD,GetWindowsDirectory,LPSTR,a,WORD,b)
-Fb(WORD,IsDlgButtonChecked,HWND,a,int,b)
+Fb(WORD,IsDlgButtonChecked,HWND,a,WORD,b)
Fb(WORD,LocalShrink,HANDLE,a,WORD,b)
Fb(WORD,MapVirtualKey,WORD,a,WORD,b)
Fb(WORD,SetSystemPaletteUse,HDC,a,WORD,b)
@@ -1349,7 +1788,7 @@
Fb(short,SetTextCharacterExtra,HDC,a,short,b)
Fb(void,ClientToScreen,HWND,a,LPPOINT,b)
Fb(void,DrawFocusRect,HDC,a,LPRECT,b)
-Fb(void,EndDialog,HWND,a,int,b)
+Fb(void,EndDialog,HWND,a,short,b)
Fb(void,GetCodeInfo,FARPROC,lpProc,LPVOID,lpSegInfo)
Fb(void,GetWindowRect,HWND,a,LPRECT,b)
Fb(void,InvertRect,HDC,a,LPRECT,b)
@@ -1457,13 +1896,13 @@
Fc(short,SetTextJustification,HDC,a,short,b,short,c)
Fc(void,AdjustWindowRect,LPRECT,a,DWORD,b,BOOL,c)
Fc(void,AnsiToOemBuff,LPSTR,a,LPSTR,b,int,c)
-Fc(void,CheckDlgButton,HWND,a,int,b,WORD,c)
+Fc(void,CheckDlgButton,HWND,a,WORD,b,WORD,c)
Fc(void,InflateRect,LPRECT,a,short,b,short,c)
Fc(void,InvalidateRect,HWND,a,LPRECT,b,BOOL,c)
Fc(void,InvalidateRgn,HWND,a,HRGN,b,BOOL,c)
Fc(void,OemToAnsiBuff,LPSTR,a,LPSTR,b,int,c)
Fc(void,OffsetRect,LPRECT,a,short,b,short,c)
-Fc(void,SetDlgItemText,HWND,a,int,b,LPSTR,c)
+Fc(void,SetDlgItemText,HWND,a,WORD,b,LPSTR,c)
Fc(void,SetSysColors,int,a,LPINT,b,COLORREF*,c)
Fc(void,ShowScrollBar,HWND,a,WORD,b,BOOL,c)
Fc(void,SwitchStackTo,WORD,a,WORD,b,WORD,c)
@@ -1490,12 +1929,12 @@
Fd(HRGN,CreateEllipticRgn,short,a,short,b,short,c,short,d)
Fd(HRGN,CreatePolyPolygonRgn,LPPOINT,a,LPINT,b,short,c,short,d)
Fd(HRGN,CreateRectRgn,short,a,short,b,short,c,short,d)
-Fd(HWND,CreateDialog,HANDLE,a,LPSTR,b,HWND,c,FARPROC,d)
-Fd(HWND,CreateDialogIndirect,HANDLE,a,LPSTR,b,HWND,c,FARPROC,d)
+Fd(HWND,CreateDialog,HANDLE,a,LPCSTR,b,HWND,c,FARPROC,d)
+Fd(HWND,CreateDialogIndirect,HANDLE,a,LPCSTR,b,HWND,c,FARPROC,d)
Fd(LONG,DefDlgProc,HWND,a,WORD,b,WORD,c,LONG,d)
Fd(LONG,DefMDIChildProc,HWND,a,WORD,b,WORD,c,LONG,d)
Fd(LONG,DefWindowProc,HWND,a,WORD,b,WORD,c,LONG,d)
-Fd(WORD,GetDlgItemInt,HWND,a,int,b,BOOL FAR*,c,BOOL,d)
+Fd(WORD,GetDlgItemInt,HWND,a,WORD,b,BOOL FAR*,c,BOOL,d)
Fd(WORD,GetPaletteEntries,HPALETTE,a,WORD,b,WORD,c,LPPALETTEENTRY,d)
Fd(WORD,GetPrivateProfileInt,LPSTR,a,LPSTR,b,short,c,LPSTR,d)
Fd(WORD,GetSystemPaletteEntries,HDC,a,WORD,b,WORD,c,LPPALETTEENTRY,d)
@@ -1508,11 +1947,11 @@
Fd(BOOL,OffsetViewportOrgEx,HDC,a,short,b,short,c,LPPOINT,d)
Fd(BOOL,OffsetWindowOrgEx,HDC,a,short,b,short,c,LPPOINT,d)
Fd(int,CombineRgn,HRGN,a,HRGN,b,HRGN,c,short,d)
-Fd(int,DialogBox,HANDLE,a,LPSTR,b,HWND,c,FARPROC,d)
+Fd(int,DialogBox,HINSTANCE,a,LPCSTR,b,HWND,c,FARPROC,d)
Fd(int,DialogBoxIndirect,HANDLE,a,HANDLE,b,HWND,c,FARPROC,d)
Fd(int,EnumFonts,HDC,a,LPSTR,b,FARPROC,c,LPSTR,d)
Fd(int,EnumObjects,HDC,a,int,b,FARPROC,c,LPSTR,d)
-Fd(int,GetDlgItemText,HWND,a,int,b,LPSTR,c,int,d)
+Fd(int,GetDlgItemText,HWND,a,WORD,b,LPSTR,c,WORD,d)
Fd(int,GetTempFileName,BYTE,a,LPSTR,b,WORD,c,LPSTR,d)
Fd(int,LoadString,HANDLE,a,WORD,b,LPSTR,c,int,d)
Fd(int,MessageBox,HWND,a,LPSTR,b,LPSTR,c,WORD,d)
@@ -1520,12 +1959,12 @@
Fd(int,SetVoiceNote,int,a,int,b,int,c,int,d)
Fd(void,AdjustWindowRectEx,LPRECT,a,LONG,b,BOOL,c,DWORD,d)
Fd(void,AnimatePalette,HPALETTE,a,WORD,b,WORD,c,LPPALETTEENTRY,d)
-Fd(void,CheckRadioButton,HWND,a,int,b,int,c,int,d)
+Fd(void,CheckRadioButton,HWND,a,WORD,b,WORD,c,WORD,d)
Fd(void,CreateCaret,HWND,a,HBITMAP,b,int,c,int,d)
Fd(void,FillWindow,HWND,a,HWND,b,HDC,c,HBRUSH,d)
Fd(void,GetScrollRange,HWND,a,int,b,LPINT,c,LPINT,d)
Fd(void,PlayMetaFileRecord,HDC,a,LPHANDLETABLE,b,LPMETARECORD,c,WORD,d)
-Fd(void,SetDlgItemInt,HWND,a,int,b,WORD,c,BOOL,d)
+Fd(void,SetDlgItemInt,HWND,a,WORD,b,WORD,c,BOOL,d)
Fe(BOOL,Rectangle,HDC,a,int,xLeft,int,yTop,int,xRight,int,yBottom)
Fe(int,DrawText,HDC,a,LPSTR,str,int,c,LPRECT,d,WORD,flag)
Fe(BOOL,PeekMessage,LPMSG,a,HWND,b,WORD,c,WORD,d,WORD,e)
@@ -1542,10 +1981,10 @@
Fe(DWORD,ScaleViewportExt,HDC,a,short,b,short,c,short,d,short,e)
Fe(DWORD,ScaleWindowExt,HDC,a,short,b,short,c,short,d,short,e)
Fe(HBITMAP,CreateBitmap,short,a,short,b,BYTE,c,BYTE,d,LPSTR,e)
-Fe(HWND,CreateDialogIndirectParam,HANDLE,a,LPSTR,b,HWND,c,FARPROC,d,LONG,e)
-Fe(HWND,CreateDialogParam,HANDLE,a,LPSTR,b,HWND,c,FARPROC,d,LONG,e)
+Fe(HWND,CreateDialogIndirectParam,HANDLE,a,LPCSTR,b,HWND,c,FARPROC,d,LPARAM,e)
+Fe(HWND,CreateDialogParam,HANDLE,a,LPCSTR,b,HWND,c,FARPROC,d,LPARAM,e)
Fe(LONG,DefFrameProc,HWND,a,HWND,b,WORD,c,WORD,d,LONG,e)
-Fe(LONG,SendDlgItemMessage,HWND,a,int,b,WORD,c,WORD,d,LONG,e)
+Fe(LONG,SendDlgItemMessage,HWND,a,WORD,b,WORD,c,WORD,d,LONG,e)
Fe(int,DialogBoxIndirectParam,HANDLE,a,HANDLE,b,HWND,c,FARPROC,d,LONG,e)
Fe(int,DialogBoxParam,HANDLE,a,LPSTR,b,HWND,c,FARPROC,d,LONG,e)
Fe(int,DlgDirList,HWND,a,LPSTR,b,int,c,int,d,WORD,e)
@@ -1579,7 +2018,7 @@
Fg(HICON,CreateIcon,HANDLE,a,int,b,int,c,BYTE,d,BYTE,e,LPSTR,f,LPSTR,g)
Fg(int,GetDIBits,HDC,a,HANDLE,a2,WORD,b,WORD,c,LPSTR,d,LPBITMAPINFO,e,WORD,f)
Fg(int,SetDIBits,HDC,a,HANDLE,a2,WORD,b,WORD,c,LPSTR,d,LPBITMAPINFO,e,WORD,f)
-Fg(void,SetWindowPos,HWND,a,HWND,b,int,c,int,d,int,e,int,f,WORD,g)
+Fg(void,SetWindowPos,HWND,a,HWND,b,short,c,short,d,short,e,short,f,WORD,g)
Fh(BOOL,ExtTextOut,HDC,a,int,b,int,c,WORD,d,LPRECT,e,LPSTR,f,WORD,g,LPINT,h)
Fh(HANDLE,DeferWindowPos,HANDLE,hWinPosInfo,HWND,hWnd,HWND,hWndInsertAfter,int,x,int,y,int,cx,int,cy,WORD,wFlags)
Fh(LONG,TabbedTextOut,HDC,a,int,b,int,c,LPSTR,d,int,e,int,f,LPINT,g,int,h)
diff --git a/include/wine.h b/include/wine.h
index afe11d6..6a602e9 100644
--- a/include/wine.h
+++ b/include/wine.h
@@ -22,5 +22,40 @@
extern char *GetFilenameFromInstance(unsigned short instance);
extern struct w_files *GetFileInfo(unsigned short instance);
-
+extern char *FindFileInPath(char *buffer, int buflen, char *rootname,
+ char **extensions, char *path);
+extern char *GetSystemIniFilename(void);
+#ifdef linux
+struct sigcontext_struct {
+ unsigned short sc_gs, __gsh;
+ unsigned short sc_fs, __fsh;
+ unsigned short sc_es, __esh;
+ unsigned short sc_ds, __dsh;
+ unsigned long sc_edi;
+ unsigned long sc_esi;
+ unsigned long sc_ebp;
+ unsigned long sc_esp;
+ unsigned long sc_ebx;
+ unsigned long sc_edx;
+ unsigned long sc_ecx;
+ unsigned long sc_eax;
+ unsigned long sc_trapno;
+ unsigned long sc_err;
+ unsigned long sc_eip;
+ unsigned short sc_cs, __csh;
+ unsigned long sc_efl;
+ unsigned long esp_at_signal;
+ unsigned short sc_ss, __ssh;
+ unsigned long i387;
+ unsigned long oldmask;
+ unsigned long cr2;
+};
#endif
+
+#ifdef __NetBSD__
+#include <signal.h>
+#define sigcontext_struct sigcontext
+#define HZ 100
+#endif
+
+#endif /* WINE_H */
diff --git a/loader/Makefile b/loader/Makefile
index a48a749..662b597 100644
--- a/loader/Makefile
+++ b/loader/Makefile
@@ -1,6 +1,7 @@
-CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR)
+CFLAGS=$(COPTS) $(DEBUGOPTS) -I../include
-OBJS=dump.o ldt.o ldtlib.o resource.o selector.o signal.o wine.o
+OBJS=dump.o files.o ldt.o ldtlib.o resource.o selector.o signal.o int1a.o \
+ int21.o wine.o
default: loader.o
@@ -8,7 +9,7 @@
$(LD) -r -o loader.o $(OBJS)
clean:
- rm -f *.o *~ *.s dll_* *.a
+ rm -f *.o *~ *.s dll_* *.a *#
depend:
$(CC) $(CFLAGS) -M *.c > .depend
diff --git a/loader/files.c b/loader/files.c
new file mode 100644
index 0000000..8bf3fbb
--- /dev/null
+++ b/loader/files.c
@@ -0,0 +1,108 @@
+static char RCSId[] = "$Id: wine.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
+static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
+
+#include <stdlib.h>
+#include <dirent.h>
+#include <string.h>
+
+/**********************************************************************
+ * FindFileInPath
+ */
+char *
+FindFileInPath(char *buffer, int buflen, char *rootname,
+ char **extensions, char *path)
+{
+ char *workingpath;
+ char *dirname;
+ DIR *d;
+ struct dirent *f;
+ char **e;
+ int rootnamelen;
+ int found = 0;
+
+ if (strchr(rootname, '/') != NULL)
+ {
+ strncpy(buffer, rootname, buflen);
+ return buffer;
+ }
+
+ rootnamelen = strlen(rootname);
+ workingpath = malloc(strlen(path) + 1);
+ if (workingpath == NULL)
+ return NULL;
+ strcpy(workingpath, path);
+
+ for(dirname = strtok(workingpath, ":;");
+ dirname != NULL;
+ dirname = strtok(NULL, ":;"))
+ {
+ d = opendir(dirname);
+ if (d != NULL)
+ {
+ while ((f = readdir(d)) != NULL)
+ {
+ if (strncasecmp(rootname, f->d_name, rootnamelen) == 0)
+ {
+ if (extensions == NULL ||
+ strcasecmp(rootname, f->d_name) == 0)
+ {
+ found = 1;
+ }
+ else if (f->d_name[rootnamelen] == '.')
+ {
+ for (e = extensions; *e != NULL; e++)
+ {
+ if (strcasecmp(*e, f->d_name + rootnamelen + 1)
+ == 0)
+ {
+ found = 1;
+ break;
+ }
+ }
+ }
+
+ if (found)
+ {
+ strncpy(buffer, dirname, buflen);
+ strncat(buffer, "/", buflen - strlen(buffer));
+ strncat(buffer, f->d_name, buflen - strlen(buffer));
+ return buffer;
+ }
+ }
+ }
+ closedir(d);
+ }
+ }
+
+ return NULL;
+}
+
+/**********************************************************************
+ * GetSystemIniFilename
+ */
+char *
+GetSystemIniFilename()
+{
+ static char *IniName = NULL;
+ char inipath[256];
+
+ if (IniName)
+ return IniName;
+
+ getcwd(inipath, 256);
+ strcat(inipath, ":");
+ strcat(inipath, getenv("HOME"));
+ strcat(inipath, ":");
+ strcat(inipath, getenv("WINEPATH"));
+
+ IniName = malloc(1024);
+ if (FindFileInPath(IniName, 1024, "wine.ini", NULL, inipath) == NULL)
+ {
+ free(IniName);
+ IniName = NULL;
+ return NULL;
+ }
+
+ IniName = realloc(IniName, strlen(IniName) + 1);
+ return IniName;
+}
diff --git a/loader/int1a.c b/loader/int1a.c
new file mode 100644
index 0000000..2441d77
--- /dev/null
+++ b/loader/int1a.c
@@ -0,0 +1,58 @@
+#include <time.h>
+#include <stdio.h>
+#include "wine.h"
+
+#ifdef linux
+#include <linux/sched.h> /* needed for HZ */
+#endif
+
+#define BCD_TO_BIN(x) ((x&15) + (x>>4)*10)
+#define BIN_TO_BCD(x) ((x%10) + ((x/10)<<4))
+
+int do_int1A(struct sigcontext_struct * context){
+ time_t ltime;
+ struct tm *bdtime;
+ int ticks;
+
+ switch((context->sc_eax >> 8) & 0xff){
+ case 0:
+ ltime = time(NULL);
+ ticks = (int) (ltime * HZ);
+ context->sc_ecx = ticks >> 16;
+ context->sc_edx = ticks & 0x0000FFFF;
+ context->sc_eax = 0; /* No midnight rollover */
+ break;
+
+ case 2:
+ ltime = time(NULL);
+ bdtime = localtime(<ime);
+
+ context->sc_ecx = (BIN_TO_BCD(bdtime->tm_hour)<<8) | BIN_TO_BCD(bdtime->tm_min);
+ context->sc_edx = (BIN_TO_BCD(bdtime->tm_sec)<<8);
+
+ case 4:
+ ltime = time(NULL);
+ bdtime = localtime(<ime);
+ context->sc_ecx = (BIN_TO_BCD(bdtime->tm_year/100)<<8) | BIN_TO_BCD((bdtime->tm_year-1900)%100);
+ context->sc_edx = (BIN_TO_BCD(bdtime->tm_mon)<<8) | BIN_TO_BCD(bdtime->tm_mday);
+ break;
+
+ /* setting the time,date or RTC is not allow -EB */
+ case 1:
+ /* set system time */
+ case 3:
+ /* set RTC time */
+ case 5:
+ /* set RTC date */
+ case 6:
+ /* set ALARM */
+ case 7:
+ /* cancel ALARM */
+ break;
+
+ default:
+ fprintf(stderr,"Unable to handle int 0x1A AX %x\n", context->sc_eax);
+ return 1;
+ };
+ return 1;
+}
diff --git a/loader/int21.c b/loader/int21.c
new file mode 100644
index 0000000..968801b
--- /dev/null
+++ b/loader/int21.c
@@ -0,0 +1,1205 @@
+#include <time.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <malloc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#ifdef linux
+#include <sys/vfs.h>
+#endif
+#ifdef __NetBSD__
+#include <sys/mount.h>
+#endif
+#include <time.h>
+#include <unistd.h>
+#include <utime.h>
+
+#include "windows.h"
+#include "wine.h"
+#include "int21.h"
+#include "files.h"
+
+#define MAX_DRIVES 26
+
+static char Copyright[] = "int21.c, copyright Erik Bos, 1993";
+
+extern struct DosDriveStruct DosDrives[];
+extern int CurrentDrive;
+extern void ParseDOSFileName();
+
+int ValidDrive(int);
+
+WORD ExtendedError, CodePage = 437;
+BYTE ErrorClass, Action, ErrorLocus;
+
+void Error(int e, int class, int el)
+{
+ ExtendedError = e;
+ ErrorClass = class;
+ Action = SA_Ask4Retry;
+ ErrorLocus = el;
+}
+
+void GetFreeDiskSpace(struct sigcontext_struct *context)
+{
+ int drive;
+ struct statfs info;
+ long size,avail;
+
+ if (!(DX & 0xff))
+ drive = CurrentDrive;
+ else
+ drive = (DX & 0xff) - 1;
+
+ if (!ValidDrive(drive)) {
+ Error(InvalidDrive, EC_MediaError , EL_Disk);
+ AX = 0xffff;
+ return;
+ }
+
+ {
+ if (statfs(DosDrives[drive].RootDirectory, &info) < 0) {
+ fprintf(stderr,"cannot do statfs(%s)\n",DosDrives[drive].RootDirectory);
+ Error(GeneralFailure, EC_MediaError , EL_Disk);
+ AX = 0xffff;
+ return;
+ }
+
+ size = info.f_bsize * info.f_blocks / 1024;
+ avail = info.f_bavail * info.f_bsize / 1024;
+
+ #ifdef DOSDEBUG
+ fprintf(stderr,"statfs: size: %8d avail: %8d\n",size,avail);
+ #endif
+
+ AX = SectorsPerCluster;
+ CX = SectorSize;
+
+ BX = (avail / (CX * AX));
+ DX = (size / (CX * AX));
+ Error (0,0,0);
+ }
+}
+
+void SetDefaultDrive(struct sigcontext_struct *context)
+{
+ if ((DX & 0xff) < MAX_DRIVES) {
+ CurrentDrive = DX & 0xff;
+ AX &= 0xff00;
+ AX |= MAX_DRIVES; /* # of valid drive letters */
+ Error (0,0,0);
+ } else
+ Error (InvalidDrive, EC_MediaError, EL_Disk);
+}
+
+void GetDefaultDrive(struct sigcontext_struct *context)
+{
+ AX &= 0xff00;
+ AX |= CurrentDrive;
+ Error (0,0,0);
+}
+
+void GetDriveAllocInfo(struct sigcontext_struct *context)
+{
+ int drive;
+ long size;
+ BYTE mediaID;
+ struct statfs info;
+
+ drive = DX & 0xff;
+
+ if (!ValidDrive(drive)) {
+ AX = SectorsPerCluster;
+ CX = SectorSize;
+ DX = 0;
+ Error (InvalidDrive, EC_MediaError, EL_Disk);
+ return;
+ }
+
+ {
+ if (statfs(DosDrives[drive].RootDirectory, &info) < 0) {
+ fprintf(stderr,"cannot do statfs(%s)\n",DosDrives[drive].RootDirectory);
+ Error(GeneralFailure, EC_MediaError , EL_Disk);
+ AX = 0xffff;
+ return;
+ }
+
+ size = info.f_bsize * info.f_blocks / 1024;
+
+ #ifdef DOSDEBUG
+ fprintf(stderr,"statfs: size: %8d\n",size);
+ #endif
+
+ AX = SectorsPerCluster;
+ CX = SectorSize;
+ DX = (size / (CX * AX));
+
+ mediaID = 0xf0;
+
+ DS = segment(mediaID);
+ BX = offset(mediaID);
+ Error (0,0,0);
+ }
+}
+
+void GetDefDriveAllocInfo(struct sigcontext_struct *context)
+{
+ DX = CurrentDrive;
+ GetDriveAllocInfo(context);
+}
+
+void GetDrivePB(struct sigcontext_struct *context)
+{
+ Error (InvalidDrive, EC_MediaError, EL_Disk);
+ AX = 0xff; /* I'm sorry but I only got networked drives :-) */
+}
+
+void ReadFile(struct sigcontext_struct *context)
+{
+ char *ptr;
+ int size;
+
+ /* can't read from stdout / stderr */
+
+ if (((BX & 0xffff) == 1) ||((BX & 0xffff) == 2)) {
+ Error (InvalidHandle, EL_Unknown, EC_Unknown);
+ AX = InvalidHandle;
+ SetCflag;
+ return;
+ }
+
+ ptr = (char *) pointer (DS,DX);
+
+ if ((BX & 0xffff) == 0) {
+ *ptr = EOF;
+ Error (0,0,0);
+ AX = 1;
+ ResetCflag;
+ return;
+ } else {
+ size = read(BX, ptr, CX);
+ if (size == 0) {
+ Error (ReadFault, EC_Unknown, EL_Unknown);
+ AX = ExtendedError;
+ return;
+ }
+
+ if (size == -1) {
+ switch (errno) {
+ case EAGAIN:
+ Error (ShareViolation, EC_Temporary, EL_Unknown);
+ break;
+ case EBADF:
+ Error (InvalidHandle, EC_AppError, EL_Unknown);
+ break;
+ default:
+ Error (GeneralFailure, EC_SystemFailure, EL_Unknown);
+ break;
+ }
+ AX = ExtendedError;
+ SetCflag;
+ return;
+ }
+ Error (0,0,0);
+ AX = size;
+ ResetCflag;
+ }
+}
+
+void WriteFile(struct sigcontext_struct *context)
+{
+ char *ptr;
+ int x,size;
+
+ ptr = (char *) pointer (DS,DX);
+
+ if ((BX & 0xffff) == 0) {
+ Error (InvalidHandle, EC_Unknown, EL_Unknown);
+ AX = InvalidHandle;
+ SetCflag;
+ return;
+ }
+
+ if ((BX & 0xffff) < 3) {
+ for (x = 0;x != CX;x++) {
+ fprintf(stderr, "%c", *ptr++);
+ }
+ fflush(stderr);
+
+ Error (0,0,0);
+ AX = CX;
+ ResetCflag;
+ } else {
+ size = write(BX, ptr , CX);
+ if (size == 0) {
+ Error (WriteFault, EC_Unknown, EL_Unknown);
+ AX = ExtendedError;
+ return;
+ }
+
+ if (size == -1) {
+ switch (errno) {
+ case EAGAIN:
+ Error (ShareViolation, EC_Temporary, EL_Unknown);
+ break;
+ case EBADF:
+ Error (InvalidHandle, EC_AppError, EL_Unknown);
+ break;
+ case ENOSPC:
+ Error (DiskFull, EC_MediaError, EL_Disk);
+ break;
+ default:
+ Error (GeneralFailure, EC_SystemFailure, EL_Unknown);
+ break;
+ }
+ AX = ExtendedError;
+ SetCflag;
+ return;
+ }
+ Error (0,0,0);
+ AX = size;
+ ResetCflag;
+ }
+}
+
+void UnlinkFile(struct sigcontext_struct *context)
+{
+ char UnixFileName[256];
+ int drive, status;
+
+ ParseDOSFileName(UnixFileName, (char *) pointer(DS,DX), &drive);
+
+ {
+ status = unlink((char *) pointer(DS,DX));
+ if (status == -1) {
+ switch (errno) {
+ case EACCES:
+ case EPERM:
+ case EROFS:
+ Error (WriteProtected, EC_AccessDenied, EL_Unknown);
+ break;
+ case EBUSY:
+ Error (LockViolation, EC_AccessDenied, EL_Unknown);
+ break;
+ case EAGAIN:
+ Error (ShareViolation, EC_Temporary, EL_Unknown);
+ break;
+ case ENOENT:
+ Error (FileNotFound, EC_NotFound, EL_Unknown);
+ break;
+ default:
+ Error (GeneralFailure, EC_SystemFailure, EL_Unknown);
+ break;
+ }
+ AX = ExtendedError;
+ SetCflag;
+ return;
+ }
+ Error (0,0,0);
+ ResetCflag;
+ }
+}
+
+void SeekFile(struct sigcontext_struct *context)
+{
+ char UnixFileName[256];
+ int drive, handle, status, fileoffset;
+
+
+ ParseDOSFileName(UnixFileName, (char *) pointer(DS,DX), &drive);
+
+ {
+ switch (AX & 0xff) {
+ case 1: fileoffset = SEEK_CUR;
+ break;
+ case 2: fileoffset = SEEK_END;
+ break;
+ default:
+ case 0: fileoffset = SEEK_SET;
+ break;
+ }
+ status = lseek(BX, (CX * 0x100) + DX, fileoffset);
+ if (status == -1) {
+ switch (errno) {
+ case EBADF:
+ Error (InvalidHandle, EC_AppError, EL_Unknown);
+ break;
+ case EINVAL:
+ Error (DataInvalid, EC_AppError, EL_Unknown);
+ break;
+ default:
+ Error (GeneralFailure, EC_SystemFailure, EL_Unknown);
+ break;
+ }
+ AX = ExtendedError;
+ SetCflag;
+ return;
+ }
+ Error (0,0,0);
+ ResetCflag;
+ }
+}
+
+void GetFileAttributes(struct sigcontext_struct *context)
+{
+ char UnixFileName[256];
+ int drive,handle;
+
+ ParseDOSFileName(UnixFileName, (char *) pointer(DS,DX), &drive);
+
+ {
+ CX = 0x0;
+ ResetCflag;
+ }
+}
+
+void SetFileAttributes(struct sigcontext_struct *context)
+{
+ ResetCflag;
+}
+
+void DosIOCTL(struct sigcontext_struct *context)
+{
+ AX = UnknownUnit;
+ SetCflag;
+}
+
+void DupeFileHandle(struct sigcontext_struct *context)
+{
+ AX = dup(BX);
+ ResetCflag;
+}
+
+void GetSystemDate(struct sigcontext_struct *context)
+{
+ struct tm *now;
+ time_t ltime;
+
+ ltime = time(NULL);
+ now = localtime(<ime);
+
+ CX = now->tm_year + 1900;
+ DX = ((now->tm_mon + 1) << 8) | now->tm_mday;
+ AX &= 0xff00;
+ AX |= now->tm_wday;
+}
+
+void GetSystemTime(struct sigcontext_struct *context)
+{
+ struct tm *now;
+ time_t ltime;
+
+ ltime = time(NULL);
+ now = localtime(<ime);
+
+ CX = (now->tm_hour << 8) | now->tm_min;
+ DX = now->tm_sec << 8;
+}
+
+void GetExtendedErrorInfo(struct sigcontext_struct *context)
+{
+ AX = ExtendedError;
+ BX = (0x100 * ErrorClass) | Action;
+ CX &= 0x00ff;
+ CX |= (0x100 * ErrorLocus);
+}
+
+void GetInDosFlag(struct sigcontext_struct *context)
+{
+ const BYTE InDosFlag = 0;
+
+ ES = segment(InDosFlag);
+ BX = offset(InDosFlag);
+}
+
+void CreateFile(struct sigcontext_struct *context)
+{
+ char UnixFileName[256];
+ int drive,handle;
+
+ ParseDOSFileName(UnixFileName, (char *) pointer(DS,DX), &drive);
+
+ {
+ handle = open(UnixFileName, O_CREAT | O_TRUNC);
+
+ if (handle == -1) {
+ switch (errno) {
+ case EACCES:
+ case EPERM:
+ case EROFS:
+ Error (WriteProtected, EC_AccessDenied, EL_Unknown);
+ break;
+ case EISDIR:
+ Error (CanNotMakeDir, EC_AccessDenied, EL_Unknown);
+ break;
+ case ENFILE:
+ case EMFILE:
+ Error (NoMoreFiles, EC_MediaError, EL_Unknown);
+ case EEXIST:
+ Error (FileExists, EC_Exists, EL_Disk);
+ break;
+ case ENOSPC:
+ Error (DiskFull, EC_MediaError, EL_Disk);
+ break;
+ default:
+ Error (GeneralFailure, EC_SystemFailure, EL_Unknown);
+ break;
+ }
+ AX = ExtendedError;
+ SetCflag;
+ return;
+ }
+ Error (0,0,0);
+ BX = handle;
+ AX = NoError;
+ ResetCflag;
+ }
+}
+
+void OpenExistingFile(struct sigcontext_struct *context)
+{
+ char UnixFileName[256];
+ int drive, handle;
+
+ ParseDOSFileName(UnixFileName, (char *) pointer(DS,DX), &drive);
+
+ {
+ handle = open(UnixFileName, O_RDWR);
+
+ if (handle == -1) {
+ switch (errno) {
+ case EACCES:
+ case EPERM:
+ case EROFS:
+ Error (WriteProtected, EC_AccessDenied, EL_Unknown);
+ break;
+ case EISDIR:
+ Error (CanNotMakeDir, EC_AccessDenied, EL_Unknown);
+ break;
+ case ENFILE:
+ case EMFILE:
+ Error (NoMoreFiles, EC_MediaError, EL_Unknown);
+ case EEXIST:
+ Error (FileExists, EC_Exists, EL_Disk);
+ break;
+ case ENOSPC:
+ Error (DiskFull, EC_MediaError, EL_Disk);
+ break;
+ case ENOENT:
+ Error (FileNotFound, EC_MediaError, EL_Disk);
+ break;
+ default:
+ Error (GeneralFailure, EC_SystemFailure, EL_Unknown);
+ break;
+ }
+ AX = ExtendedError;
+ SetCflag;
+ return;
+ }
+ Error (0,0,0);
+ BX = handle;
+ AX = NoError;
+ ResetCflag;
+ }
+}
+
+void CloseFile(struct sigcontext_struct *context)
+{
+ if (close(BX) == -1) {
+ switch (errno) {
+ case EBADF:
+ Error (InvalidHandle, EC_AppError, EL_Unknown);
+ break;
+ default:
+ Error (GeneralFailure, EC_SystemFailure, EL_Unknown);
+ break;
+ }
+ AX = ExtendedError;
+ SetCflag;
+ return;
+ }
+ Error (0,0,0);
+ AX = NoError;
+ ResetCflag;
+}
+
+void RenameFile(struct sigcontext_struct *context)
+{
+ rename((char *) pointer(DS,DX), (char *) pointer(ES,DI));
+ ResetCflag;
+}
+
+void GetTrueFileName(struct sigcontext_struct *context)
+{
+ strncpy((char *) pointer(ES,DI), (char *) pointer(DS,SI), strlen((char *) pointer(DS,SI)) & 0x7f);
+ ResetCflag;
+}
+
+void MakeDir(struct sigcontext_struct *context)
+{
+ int drive;
+ char *dirname;
+ char unixname[256];
+
+ dirname = (char *) pointer(DS,DX);
+
+ ParseDOSFileName(unixname,dirname,&drive);
+
+ {
+ if (mkdir(unixname,0) == -1) {
+ AX = CanNotMakeDir;
+ SetCflag;
+ }
+ ResetCflag;
+ }
+}
+
+void ChangeDir(struct sigcontext_struct *context)
+{
+ int drive;
+ char *dirname;
+ char unixname[256];
+
+ dirname = (char *) pointer(DS,DX);
+
+ ParseDOSFileName(unixname,dirname,&drive);
+
+ {
+ strcpy(unixname,DosDrives[drive].CurrentDirectory);
+ ResetCflag;
+ }
+}
+
+void RemoveDir(struct sigcontext_struct *context)
+{
+ int drive;
+ char *dirname;
+ char unixname[256];
+
+ dirname = (char *) pointer(DS,DX);
+
+ ParseDOSFileName(unixname,dirname,&drive);
+
+ {
+ if (strcmp(unixname,DosDrives[drive].CurrentDirectory)) {
+ AX = CanNotRemoveCwd;
+ SetCflag;
+ }
+
+ #ifdef DOSDEBUG
+ fprintf(stderr,"rmdir %s\n",unixname);
+ #endif
+
+ if (rmdir(unixname) == -1) {
+ AX = CanNotMakeDir; /* HUH ?*/
+ SetCflag;
+ }
+ ResetCflag;
+ }
+}
+
+void AllocateMemory(struct sigcontext_struct *context)
+{
+ char *ptr;
+
+ if ((ptr = (void *) memalign((size_t) (BX * 0x10), 0x10)) == NULL) {
+ AX = OutOfMemory;
+ BX = 0x0; /* out of memory */
+ SetCflag;
+ }
+ AX = segment((unsigned long) ptr);
+ ResetCflag;
+}
+
+void FreeMemory(struct sigcontext_struct *context)
+{
+ free((void *)(ES * 0x10));
+ ResetCflag;
+}
+
+void ResizeMemoryBlock(struct sigcontext_struct *context)
+{
+ char *ptr;
+
+ if ((ptr = (void *) realloc((void *)(ES * 0x10), (size_t) BX * 0x10)) == NULL) {
+ AX = OutOfMemory;
+ BX = 0x0; /* out of memory */
+ SetCflag;
+ }
+ BX = segment((unsigned long) ptr);
+ ResetCflag;
+}
+
+void ExecProgram(struct sigcontext_struct *context)
+{
+ execl("wine",(char *) pointer(DS,DX));
+}
+
+void GetReturnCode(struct sigcontext_struct *context)
+{
+ AX = NoError; /* normal exit */
+}
+
+void FindFirst(struct sigcontext_struct *context)
+{
+
+}
+
+void FindNext(struct sigcontext_struct *context)
+{
+
+}
+
+void GetSysVars(struct sigcontext_struct *context)
+{
+ ES = 0x0;
+ BX = 0x0;
+}
+
+void GetFileDateTime(struct sigcontext_struct *context)
+{
+ int drive;
+ char *dirname;
+ char unixname[256];
+ struct stat filestat;
+ struct tm *now;
+
+ ParseDOSFileName(unixname, dirname, &drive);
+
+ {
+ stat(unixname, &filestat);
+
+ now = localtime (&filestat.st_mtime);
+
+ CX = (now->tm_hour * 0x2000) + (now->tm_min * 0x20) + now->tm_sec/2;
+ DX = (now->tm_year * 0x200) + (now->tm_mon * 0x20) + now->tm_mday;
+
+ ResetCflag;
+ }
+}
+
+void SetFileDateTime(struct sigcontext_struct *context)
+{
+ int drive;
+ char *dirname;
+ char unixname[256];
+ struct utimbuf filetime;
+
+ dirname = (char *) pointer(DS,DX);
+
+ ParseDOSFileName(unixname, dirname, &drive);
+
+ {
+ filetime.actime = 0L;
+ filetime.modtime = filetime.actime;
+
+ utime(unixname,&filetime);
+ ResetCflag;
+ }
+}
+
+void CreateTempFile(struct sigcontext_struct *context)
+{
+ char UnixFileName[256],TempString[256];
+ int drive,handle;
+
+ ParseDOSFileName(UnixFileName, (char *) pointer(DS,DX), &drive);
+
+ sprintf(TempString,"%s%s%d",UnixFileName,"eb",(int) getpid());
+
+ {
+ handle = open(TempString, O_CREAT | O_TRUNC | O_RDWR);
+
+ if (handle == -1) {
+ AX = WriteProtected;
+ SetCflag;
+ return;
+ }
+
+ strcpy((char *) pointer(DS,DX), UnixFileName);
+
+ AX = handle;
+ ResetCflag;
+ }
+}
+
+void CreateNewFile(struct sigcontext_struct *context)
+{
+ char UnixFileName[256];
+ int drive,handle;
+
+ ParseDOSFileName(UnixFileName, (char *) pointer(DS,DX), &drive);
+
+ {
+ handle = open(UnixFileName, O_CREAT | O_TRUNC | O_RDWR);
+
+ if (handle == -1) {
+ AX = WriteProtected;
+ SetCflag;
+ return;
+ }
+
+ AX = handle;
+ ResetCflag;
+ }
+}
+
+void FileLock(struct sigcontext_struct *context)
+{
+
+}
+
+void GetExtendedCountryInfo(struct sigcontext_struct *context)
+{
+ ResetCflag;
+}
+
+int ValidDrive(int d)
+{
+ return 1;
+}
+
+void GetCurrentDirectory(struct sigcontext_struct *context)
+{
+ int drive;
+ char *ptr;
+
+ if ((DX & 0xff) == 0)
+ drive = CurrentDrive;
+ else
+ drive = (DX & 0xff)-1;
+
+ if (!ValidDrive(drive)) {
+ AX = InvalidDrive;
+ SetCflag;
+ return;
+ }
+
+ strcpy((char *) pointer(DS,SI), DosDrives[drive].CurrentDirectory);
+ ResetCflag;
+ AX = 0x0100;
+}
+
+void GetCurrentPSP(struct sigcontext_struct *context)
+{
+
+}
+
+void GetDiskSerialNumber(struct sigcontext_struct *context)
+{
+ int drive;
+ struct diskinfo *ptr;
+
+ if ((BX & 0xff)== 0)
+ drive = CurrentDrive;
+ else
+ drive = (BX & 0xff)-1;
+
+ if (!ValidDrive(drive)) {
+ AX = InvalidDrive;
+ SetCflag;
+ return;
+ }
+
+ {
+ ptr =(struct diskinfo *) pointer(DS,SI);
+
+ ptr->infolevel = 0;
+ ptr->serialnumber = 0xEBEBEB00 | drive;
+ strcpy(ptr->label,"NO NAME ");
+ strcpy(ptr->fstype,"FAT16 ");
+
+ AX = NoError;
+ ResetCflag;
+ }
+}
+
+void SetDiskSerialNumber(struct sigcontext_struct *context)
+{
+ AX &= 0xff00;
+ AX |= 1;
+ ResetCflag;
+}
+
+void CommitFile(struct sigcontext_struct *context)
+{
+
+}
+
+/************************************************************************/
+
+int do_int21(struct sigcontext_struct * context){
+ int ah;
+
+ fprintf(stderr,"int21: doing AX=%4x BX=%4x CX=%4x DX=%4x\n",
+ AX & 0xffff,BX & 0xffff,CX & 0xffff,DX & 0xffff);
+
+ ah = (AX >> 8) & 0xff;
+
+ if (ah == 0x59) {
+ GetExtendedErrorInfo(context);
+ return 1;
+ } else {
+
+ Error (0,0,0);
+
+ switch(ah) {
+
+ case 0x00: /* TERMINATE PROGRAM */
+ exit(0);
+
+ case 0x01: /* READ CHARACTER FROM STANDARD INPUT, WITH ECHO */
+ case 0x02: /* WRITE CHARACTER TO STANDARD OUTPUT */
+ case 0x03: /* READ CHARACTER FROM STDAUX */
+ case 0x04: /* WRITE CHARACTER TO STDAUX */
+ case 0x05: /* WRITE CHARACTER TO PRINTER */
+ case 0x06: /* DIRECT CONSOLE IN/OUTPUT */
+ case 0x07: /* DIRECT CHARACTER INPUT, WITHOUT ECHO */
+ case 0x08: /* CHARACTER INPUT WITHOUT ECHO */
+ case 0x09: /* WRITE STRING TO STANDARD OUTPUT */
+ case 0x0a: /* BUFFERED INPUT */
+ case 0x0b: /* GET STDIN STATUS */
+ case 0x0c: /* FLUSH BUFFER AND READ STANDARD INPUT */
+ case 0x0d: /* DISK BUFFER FLUSH */
+ break;
+
+ /* no FCB support for CP/M hackers */
+
+ case 0x0f: /* OPEN FILE USING FCB */
+ case 0x10: /* CLOSE FILE USING FCB */
+ case 0x11: /* FIND FIRST MATCHING FILE USING FCB */
+ case 0x12: /* FIND NEXT MATCHING FILE USING FCB */
+ case 0x13: /* DELETE FILE USING FCB */
+ case 0x14: /* SEQUENTIAL READ FROM FCB FILE */
+ case 0x15: /* SEQUENTIAL WRITE TO FCB FILE
+ case 0x16: /* CREATE OR TRUNCATE FILE USING FCB */
+ case 0x17: /* RENAME FILE USING FCB */
+ case 0x1a: /* SET DISK TRANSFER AREA ADDRESS */
+ case 0x21: /* READ RANDOM RECORD FROM FCB FILE */
+ case 0x22: /* WRITE RANDOM RECORD TO FCB FILE */
+ case 0x23: /* GET FILE SIZE FOR FCB */
+ case 0x24: /* SET RANDOM RECORD NUMBER FOR FCB */
+ case 0x27: /* RANDOM BLOCK READ FROM FCB FILE */
+ case 0x28: /* RANDOM BLOCK WRITE TO FCB FILE */
+ case 0x29: /* PARSE FILENAME INTO FCB */
+ case 0x2f: /* GET DISK TRANSFER AREA ADDRESS */
+
+ case 0x2e: /* SET VERIFY FLAG */
+ break;
+
+ case 0x18: /* NULL FUNCTIONS FOR CP/M COMPATIBILITY *
+ case 0x1d:
+ case 0x1e:
+ case 0x20:
+ case 0x2b: /* SET SYSTEM DATE */
+ case 0x2d: /* SET SYSTEM TIME */
+ case 0x37: /* "SWITCHAR" - GET SWITCH CHARACTER
+ "SWITCHAR" - SET SWITCH CHARACTER
+ "AVAILDEV" - SPECIFY \DEV\ PREFIX USE */
+ case 0x54: /* GET VERIFY FLAG */
+ case 0x61: /* UNUSED */
+ case 0x6b: /* NULL FUNCTION */
+ AX &= 0xff00;
+ break;
+
+ case 0x67: /* SET HANDLE COUNT */
+ ResetCflag;
+ break;
+
+ case 0x0e: /* SELECT DEFAULT DRIVE */
+ SetDefaultDrive(context);
+ break;
+
+ case 0x19: /* GET CURRENT DEFAULT DRIVE */
+ GetDefaultDrive(context);
+ break;
+
+ case 0x1b: /* GET ALLOCATION INFORMATION FOR DEFAULT DRIVE */
+ GetDefDriveAllocInfo(context);
+ break;
+
+ case 0x1c: /* GET ALLOCATION INFORMATION FOR SPECIFIC DRIVE */
+ GetDriveAllocInfo(context);
+ break;
+
+ case 0x1f: /* GET DRIVE PARAMETER BLOCK FOR DEFAULT DRIVE */
+ case 0x32: /* GET DOS DRIVE PARAMETER BLOCK FOR SPECIFIC DRIVE */
+ GetDrivePB(context);
+ break;
+
+ case 0x25: /* SET INTERRUPT VECTOR */
+ /* Ignore any attempt to set a segment vector */
+ return 1;
+
+ case 0x26: /* CREATE NEW PROGRAM SEGMENT PREFIX */
+ break;
+
+ case 0x2a: /* GET SYSTEM DATE */
+ GetSystemDate(context);
+ break;
+
+ case 0x2c: /* GET SYSTEM TIME */
+ GetSystemTime(context);
+ break;
+
+ case 0x30: /* GET DOS VERSION */
+ AX = DosVersion; /* Hey folks, this is DOS V3.3! */
+ BX = 0x0012; /* 0x123456 is Wine's serial # */
+ CX = 0x3456;
+ break;
+
+ case 0x31: /* TERMINATE AND STAY RESIDENT */
+ break;
+
+ case 0x33: /* MULTIPLEXED */
+ switch (AX & 0xff) {
+ case 0x00: /* GET CURRENT EXTENDED BREAK STATE */
+ if (!(AX & 0xff))
+ DX &= 0xff00;
+ break;
+
+ case 0x01: /* SET EXTENDED BREAK STATE */
+ break;
+
+ case 0x02: /* GET AND SET EXTENDED CONTROL-BREAK CHECKING STATE */
+ DX &= 0xff00;
+ break;
+
+ case 0x05: /* GET BOOT DRIVE */
+ DX &= 0xff00;
+ DX |= 2; /* c: is Wine's bootdrive */
+ break;
+
+ case 0x06: /* GET TRUE VERSION NUMBER */
+ BX = DosVersion;
+ DX = 0x00;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case 0x34: /* GET ADDRESS OF INDOS FLAG */
+ GetInDosFlag(context);
+ break;
+
+ case 0x35: /* GET INTERRUPT VECTOR */
+ /* Return a NULL segment selector - this will bomb,
+ if anyone ever tries to use it */
+ ES = 0;
+ BX = 0;
+ break;
+
+ case 0x36: /* GET FREE DISK SPACE */
+ GetFreeDiskSpace(context);
+ break;
+
+ case 0x38: /* GET COUNTRY-SPECIFIC INFORMATION */
+ AX &= 0xff00;
+ AX |= 0x02; /* no country support available */
+ SetCflag;
+ break;
+
+ case 0x39: /* "MKDIR" - CREATE SUBDIRECTORY */
+ MakeDir(context);
+ break;
+
+ case 0x3a: /* "RMDIR" - REMOVE SUBDIRECTORY */
+ RemoveDir(context);
+ break;
+
+ case 0x3b: /* "CHDIR" - SET CURRENT DIRECTORY */
+ ChangeDir(context);
+ break;
+
+ case 0x3c: /* "CREAT" - CREATE OR TRUNCATE FILE */
+ CreateFile(context);
+ break;
+
+ case 0x3d: /* "OPEN" - OPEN EXISTING FILE */
+ OpenExistingFile(context);
+ break;
+
+ case 0x3e: /* "CLOSE" - CLOSE FILE */
+ case 0x68: /* "FFLUSH" - COMMIT FILE */
+ case 0x6a: /* COMMIT FILE */
+
+ CloseFile(context);
+ break;
+
+ case 0x3f: /* "READ" - READ FROM FILE OR DEVICE */
+ ReadFile(context);
+ break;
+
+ case 0x40: /* "WRITE" - WRITE TO FILE OR DEVICE */
+ WriteFile(context);
+ break;
+
+ case 0x41: /* "UNLINK" - DELETE FILE */
+ UnlinkFile(context);
+ break;
+
+ case 0x42: /* "LSEEK" - SET CURRENT FILE POSITION */
+ SeekFile(context);
+ break;
+
+ case 0x43: /* FILE ATTRIBUTES */
+ switch (AX & 0xff) {
+ case 0x00:
+ GetFileAttributes(context);
+ break;
+ case 0x01:
+ SetFileAttributes(context);
+ break;
+ }
+ break;
+
+ case 0x44: /* IOCTL */
+ DosIOCTL(context);
+ break;
+
+ case 0x45: /* "DUP" - DUPLICATE FILE HANDLE */
+ case 0x46: /* "DUP2", "FORCEDUP" - FORCE DUPLICATE FILE HANDLE */
+ DupeFileHandle(context);
+ break;
+
+ case 0x47: /* "CWD" - GET CURRENT DIRECTORY */
+ GetCurrentDirectory(context);
+ AX = 0x0100; /* many Microsoft products for Windows rely
+ on this */
+ break;
+
+ case 0x48: /* ALLOCATE MEMORY */
+ AllocateMemory(context);
+ break;
+
+ case 0x49: /* FREE MEMORY */
+ FreeMemory(context);
+ break;
+
+ case 0x4a: /* RESIZE MEMORY BLOCK */
+ ResizeMemoryBlock(context);
+ break;
+
+ case 0x4b: /* "EXEC" - LOAD AND/OR EXECUTE PROGRAM */
+ ExecProgram(context);
+ break;
+
+ case 0x4c: /* "EXIT" - TERMINATE WITH RETURN CODE */
+ exit(AX & 0xff);
+
+ case 0x4d: /* GET RETURN CODE */
+ GetReturnCode(context);
+ break;
+
+ case 0x4e: /* "FINDFIRST" - FIND FIRST MATCHING FILE */
+ FindFirst(context);
+ break;
+
+ case 0x4f: /* "FINDNEXT" - FIND NEXT MATCHING FILE */
+ FindNext(context);
+ break;
+
+ case 0x52: /* "SYSVARS" - GET LIST OF LISTS */
+ GetSysVars(context);
+ break;
+
+ case 0x56: /* "RENAME" - RENAME FILE */
+ RenameFile(context);
+ break;
+
+ case 0x57: /* FILE DATE AND TIME */
+ switch (AX & 0xff) {
+ case 0x00:
+ GetFileDateTime(context);
+ break;
+ case 0x01:
+ SetFileDateTime(context);
+ break;
+ }
+ break;
+
+ case 0x58: /* GET OR SET MEMORY/UMB ALLOCATION STRATEGY */
+ switch (AX & 0xff) {
+ case 0x00:
+ AX = 0x01;
+ break;
+ case 0x02:
+ AX &= 0xff00;
+ break;
+ case 0x01:
+ case 0x03:
+ break;
+ }
+ ResetCflag;
+ break;
+
+ case 0x59: /* GET EXTENDED ERROR INFO */
+ GetExtendedErrorInfo(context);
+ break;
+
+ case 0x5a: /* CREATE TEMPORARY FILE */
+ CreateTempFile(context);
+ break;
+
+ case 0x5b: /* CREATE NEW FILE */
+ CreateNewFile(context);
+ break;
+
+ case 0x5c: /* "FLOCK" - RECORD LOCKING */
+ FileLock(context);
+ break;
+
+ case 0x5d: /* NETWORK */
+ case 0x5e:
+ case 0x5f:
+ AX &= 0xff00;
+ AX |= NoNetwork; /* network software not installed */
+ SetCflag;
+ break;
+
+ case 0x60: /* "TRUENAME" - CANONICALIZE FILENAME OR PATH */
+ GetTrueFileName(context);
+ break;
+
+ case 0x62: /* GET CURRENT PSP ADDRESS */
+ GetCurrentPSP(context);
+ break;
+
+ case 0x65: /* GET EXTENDED COUNTRY INFORMATION */
+ GetExtendedCountryInfo(context);
+ break;
+
+ case 0x66: /* GLOBAL CODE PAGE TABLE */
+ switch (AX & 0xff) {
+ case 0x01:
+ BX = CodePage;
+ DX = BX;
+ ResetCflag;
+ break;
+ case 0x02:
+ CodePage = BX;
+ ResetCflag;
+ break;
+ }
+ break;
+
+ case 0x69: /* DISK SERIAL NUMBER */
+ switch (AX & 0xff) {
+ case 0x00:
+ GetDiskSerialNumber(context);
+ break;
+ case 0x01:
+ SetDiskSerialNumber(context);
+ break;
+ }
+ break;
+
+ default:
+ fprintf(stderr,"Unable to handle int 0x21 %x\n", context->sc_eax);
+ return 1;
+ };
+ }
+ return 1;
+}
diff --git a/loader/ldtlib.c b/loader/ldtlib.c
index 65bf92c..3945537 100644
--- a/loader/ldtlib.c
+++ b/loader/ldtlib.c
@@ -20,7 +20,6 @@
struct segment_descriptor *
make_sd(unsigned base, unsigned limit, int contents, int read_exec_only, int seg32, int inpgs)
{
-#if 1
static long d[2];
d[0] = ((base & 0x0000ffff) << 16) |
@@ -34,24 +33,7 @@
(inpgs << 23) |
0xf000;
- printf("%x %x\n", d[1], d[0]);
-
return ((struct segment_descriptor *)d);
-#else
- static struct segment_descriptor d;
-
- d.sd_lolimit = limit & 0x0000ffff;
- d.sd_lobase = base & 0x00ffffff;
- d.sd_type = contents & 0x01f;
- d.sd_dpl = SEL_UPL & 0x3;
- d.sd_p = 1;
- d.sd_hilimit = (limit & 0x00ff0000) >> 16;
- d.sd_xx = 0;
- d.sd_def32 = seg32?1:0;
- d.sd_gran = inpgs?1:0;
- d.sd_hibase = (base & 0xff000000) >> 24;
- return ((struct segment_descriptor *)&d);
-#endif
}
#endif
@@ -88,7 +70,7 @@
struct segment_descriptor *sd;
int ret;
-#ifdef DEBUG
+#ifdef DEBUG_LDT
printf("set_ldt_entry: entry=%x base=%x limit=%x%s %s-bit contents=%d %s\n",
entry, base, limit, limit_in_pages_flag?"-pages":"",
seg_32bit_flag?"32":"16",
diff --git a/loader/resource.c b/loader/resource.c
index fcc1af3..eeafc9e 100644
--- a/loader/resource.c
+++ b/loader/resource.c
@@ -211,6 +211,7 @@
if (read(ResourceFd, &size_shift, sizeof(size_shift)) !=
sizeof(size_shift))
{
+ printf("FindResourceByName (%s) bad block size !\n", resource_name);
return -1;
}
@@ -223,6 +224,7 @@
if (read(ResourceFd, &typeinfo, sizeof(typeinfo)) !=
sizeof(typeinfo))
{
+ printf("FindResourceByName (%s) bad typeinfo size !\n", resource_name);
return -1;
}
if (typeinfo.type_id == type_id || type_id == -1)
@@ -232,6 +234,7 @@
if (read(ResourceFd, &nameinfo, sizeof(nameinfo)) !=
sizeof(nameinfo))
{
+ printf("FindResourceByName (%s) bad nameinfo size !\n", resource_name);
return -1;
}
@@ -245,7 +248,6 @@
read(ResourceFd, name, nbytes);
lseek(ResourceFd, old_pos, SEEK_SET);
name[nbytes] = '\0';
-
if (strcasecmp(name, resource_name) == 0)
{
memcpy(result_p, &nameinfo, sizeof(nameinfo));
@@ -254,6 +256,7 @@
}
}
}
+ printf("FindResourceByName (%s) typeinfo.type_id = 0 !\n", resource_name);
return -1;
}
@@ -373,7 +376,6 @@
image_size = nameinfo.length << size_shift;
if (image_size_ret != NULL)
*image_size_ret = image_size;
-
hmem = GlobalAlloc(GMEM_MOVEABLE, image_size);
image = GlobalLock(hmem);
if (image == NULL || read(ResourceFd, image, image_size) != image_size)
@@ -443,6 +445,7 @@
{
HBITMAP hbitmap;
HANDLE rsc_mem;
+ GDIOBJHDR * ptr;
HDC hdc;
long *lp;
int image_size;
@@ -462,7 +465,6 @@
GlobalFree(rsc_mem);
return 0;
}
-
if (*lp == sizeof(BITMAPCOREHEADER))
hbitmap = ConvertCoreBitmap( hdc, (BITMAPCOREHEADER *) lp );
else if (*lp == sizeof(BITMAPINFOHEADER))
diff --git a/loader/signal.c b/loader/signal.c
index a240104..cc85fc7 100644
--- a/loader/signal.c
+++ b/loader/signal.c
@@ -10,6 +10,7 @@
#include <linux/sched.h>
#include <asm/system.h>
#endif
+#include <wine.h>
char * cstack[4096];
struct sigaction segv_act;
@@ -17,6 +18,7 @@
#ifdef linux
extern void ___sig_restore();
extern void ___masksig_restore();
+#endif
/* Similar to the sigaction function in libc, except it leaves alone the
restorer field */
@@ -32,123 +34,6 @@
return -1;
}
-struct sigcontext_struct {
- unsigned short sc_gs, __gsh;
- unsigned short sc_fs, __fsh;
- unsigned short sc_es, __esh;
- unsigned short sc_ds, __dsh;
- unsigned long sc_edi;
- unsigned long sc_esi;
- unsigned long sc_ebp;
- unsigned long sc_esp;
- unsigned long sc_ebx;
- unsigned long sc_edx;
- unsigned long sc_ecx;
- unsigned long sc_eax;
- unsigned long sc_trapno;
- unsigned long sc_err;
- unsigned long sc_eip;
- unsigned short sc_cs, __csh;
- unsigned long sc_eflags;
- unsigned long esp_at_signal;
- unsigned short sc_ss, __ssh;
- unsigned long i387;
- unsigned long oldmask;
- unsigned long cr2;
-};
-#endif
-
-#ifdef __NetBSD__
-#define sigcontext_struct sigcontext
-#define HZ 100
-#endif
-
-static void
-GetTimeDate(int time_flag, struct sigcontext_struct * context)
-{
- struct tm *now;
- time_t ltime;
-
- ltime = time(NULL);
- now = localtime(<ime);
- if (time_flag)
- {
- context->sc_ecx = (now->tm_hour << 8) | now->tm_min;
- context->sc_edx = now->tm_sec << 8;
- }
- else
- {
- context->sc_ecx = now->tm_year + 1900;
- context->sc_edx = ((now->tm_mon + 1) << 8) | now->tm_mday;
- context->sc_eax &= 0xff00;
- context->sc_eax |= now->tm_wday;
- }
-}
-
-/* We handle all int21 calls here. There is some duplicate code from
- misc/dos.c that I am unsure how to deal with, since the locations
- that we store the registers are all different */
-
-static int
-do_int21(struct sigcontext_struct * context){
- fprintf(stderr,"Doing int21 %x ", (context->sc_eax >> 8) & 0xff);
- switch((context->sc_eax >> 8) & 0xff){
- case 0x30:
- context->sc_eax = 0x0303; /* Hey folks, this is DOS V3.3! */
- context->sc_ebx = 0;
- context->sc_ecx = 0;
- break;
-
- /* Ignore any attempt to set a segment vector */
- case 0x25:
- return 1;
-
- case 0x35: /* Return a NULL segment selector - this will bomb
- if anyone ever tries to use it */
- context->sc_es = 0;
- context->sc_ebx = 0;
- break;
-
- case 0x2a:
- GetTimeDate(0, context);
- /* Function does not return */
-
- case 0x2c:
- GetTimeDate(1, context);
- /* Function does not return */
-
- case 0x4c:
- exit(context->sc_eax & 0xff);
-
-
- default:
- fprintf(stderr,"Unable to handle int 0x21 %x\n", context->sc_eax);
- return 1;
- };
- return 1;
-}
-
-static int
-do_int1A(struct sigcontext_struct * context){
- time_t ltime;
- int ticks;
-
- switch((context->sc_eax >> 8) & 0xff){
- case 0:
- ltime = time(NULL);
- ticks = (int) (ltime * HZ);
- context->sc_ecx = ticks >> 16;
- context->sc_edx = ticks & 0x0000FFFF;
- context->sc_eax = 0; /* No midnight rollover */
- break;
-
- default:
- fprintf(stderr,"Unable to handle int 0x1A %x\n", context->sc_eax);
- return 1;
- };
- return 1;
-}
-
#ifdef linux
static void win_fault(int signal, struct sigcontext_struct context){
struct sigcontext_struct *scp = &context;
@@ -198,6 +83,12 @@
case 0x21:
if(!do_int21(scp)) goto oops;
break;
+ case 0x11:
+ scp->sc_eax = 0x00000000; /* get equipment list: we haven't */
+ break; /* got anything */
+ case 0x12:
+ scp->sc_eax = 640L; /* get base mem size */
+ break;
case 0x1A:
if(!do_int1A(scp)) goto oops;
break;
@@ -210,7 +101,6 @@
scp->sc_eip += 2; /* Bypass the int instruction */
return;
-
oops:
fprintf(stderr,"In win_fault %x:%x\n", scp->sc_cs, scp->sc_eip);
#ifdef linux
@@ -236,14 +126,14 @@
/* Point to the top of the stack, minus 4 just in case, and make
it aligned */
segv_act.sa_restorer =
- (void (*)()) (((unsigned int)(cstack + sizeof(cstack) - 4)) & ~3);
+ (void (*)()) (((unsigned int)(cstack) + sizeof(cstack) - 4) & ~3);
wine_sigaction(SIGSEGV, &segv_act, NULL);
#endif
#ifdef __NetBSD__
struct sigstack ss;
sigset_t sig_mask;
- ss.ss_sp = (char *) (((unsigned int)(cstack + sizeof(cstack) - 4)) & ~3);
+ ss.ss_sp = (char *) (((unsigned int)(cstack) + sizeof(cstack) - 4) & ~3);
ss.ss_onstack = 0;
if (sigstack(&ss, NULL) < 0) {
perror("sigstack");
diff --git a/loader/wine.c b/loader/wine.c
index 1cd77a0..82928ca 100644
--- a/loader/wine.c
+++ b/loader/wine.c
@@ -39,6 +39,10 @@
struct ne_header_s *CurrentNEHeader;
int CurrentNEFile;
+static char *dllExtensions[] = { "dll", "exe", NULL };
+static char *exeExtensions[] = { "exe", NULL };
+static char *WinePath = NULL;
+
/**********************************************************************
* DebugPrintString
*/
@@ -215,39 +219,23 @@
*/
for(i=0; i<wpnt->ne_header->n_mod_ref_tab; i++){
char buff[14];
- char buff2[14];
+ char buff2[256];
int fd, j;
GetModuleName(wpnt, i + 1, buff);
if(FindDLLTable(buff)) continue; /* This module already loaded */
- /* The next trick is to convert the case, and add the .dll
- * extension if required to find the actual library. We may want
- * to use a search path at some point as well. */
-
- /* First try the straight name */
- strcpy(buff2, buff);
- if(fd = open(buff2, O_RDONLY) >= 0) {
- close(fd);
- LoadImage(buff2, buff);
- continue;
- };
-
- /* OK, that did not work, try making it lower-case, and add the .dll
- extension */
-
- for(j=0; j<strlen(buff2); j++)
- if(buff2[j] >= 'A' && buff2[j] <= 'Z') buff2[j] |= 0x20;
- strcat(buff2, ".dll");
-
- if(fd = open(buff2, O_RDONLY) >= 0) {
- close(fd);
- LoadImage(buff2, buff);
- continue;
- };
+ if (FindFileInPath(buff2, sizeof(buff2),
+ buff, dllExtensions, WinePath) != NULL &&
+ (fd = open(buff2, O_RDONLY)) >= 0)
+ {
+ close(fd);
+ LoadImage(buff2, buff);
+ continue;
+ }
fprintf(stderr,"Unable to load:%s\n", buff);
- };
+ }
}
@@ -257,6 +245,8 @@
_WinMain(int argc, char **argv)
{
int segment;
+ char *p;
+ char exe_path[256];
#ifdef WINESTAT
char * cp;
#endif
@@ -273,8 +263,21 @@
fprintf(stderr, "usage: %s FILENAME\n", argv[0]);
exit(1);
}
+
+ p = getenv("WINEPATH");
+ WinePath = malloc(256 + strlen(p));
+ getcwd(WinePath, 256);
+ strcat(WinePath, ";");
+ strcat(WinePath, p);
+
+ if (FindFileInPath(exe_path, 256, argv[1], exeExtensions, WinePath)
+ == NULL)
+ {
+ fprintf(stderr, "Could not find file '%s'\n", argv[1]);
+ exit(1);
+ }
- LoadImage(argv[1], NULL);
+ LoadImage(exe_path, NULL);
if(ran_out) exit(1);
#ifdef DEBUG
diff --git a/memory/Makefile b/memory/Makefile
index 1b8c9d8..b624e09 100644
--- a/memory/Makefile
+++ b/memory/Makefile
@@ -8,7 +8,7 @@
$(LD) -r -o memory.o $(OBJS)
clean:
- rm -f *.o *~ *.s dll_* *.a
+ rm -f *.o *~ *.s dll_* *.a *#
depend:
$(CC) $(CFLAGS) -M *.c > .depend
diff --git a/misc/Makefile b/misc/Makefile
index 0d5fa81..e5d5542 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -1,7 +1,7 @@
CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR)
OBJS=dos.o kernel.o user.o xt.o rect.o file.o sound.o emulate.o \
- keyboard.o profile.o lstr.o
+ keyboard.o profile.o lstr.o exec.o
default: misc.o
@@ -9,7 +9,7 @@
$(LD) -r -o misc.o $(OBJS)
clean:
- rm -f *.o *~ *.s dll_* *.a
+ rm -f *.o *~ *.s dll_* *.a *#
depend:
$(CC) $(CFLAGS) -M *.c > .depend
diff --git a/misc/exec.c b/misc/exec.c
new file mode 100644
index 0000000..d2e7866
--- /dev/null
+++ b/misc/exec.c
@@ -0,0 +1,103 @@
+/*
+* Windows Exec & Help
+*
+*/
+
+#include "win.h"
+
+#define HELP_CONTEXT 0x0001
+#define HELP_QUIT 0x0002
+#define HELP_INDEX 0x0003
+#define HELP_CONTENTS 0x0003
+#define HELP_HELPONHELP 0x0004
+#define HELP_SETINDEX 0x0005
+#define HELP_SETCONTENTS 0x0005
+#define HELP_CONTEXTPOPUP 0x0008
+#define HELP_FORCEFILE 0x0009
+#define HELP_KEY 0x0101
+#define HELP_COMMAND 0x0102
+#define HELP_PARTIALKEY 0x0105
+#define HELP_MULTIKEY 0x0201
+#define HELP_SETWINPOS 0x0203
+
+
+WORD WinExec(LPSTR lpCmdLine, WORD nCmdShow)
+{
+ int X, X2, C;
+ char *ArgV[20];
+ printf("WinExec(%s, %u)\n", lpCmdLine, nCmdShow);
+ for (X = X2 = C = 0; X < strlen(lpCmdLine) + 1; X++) {
+ if ((lpCmdLine[X] == ' ') || (lpCmdLine[X] == '\0')) {
+ ArgV[C] = (char *)malloc(X - X2 + 1);
+ strncpy(ArgV[C], &lpCmdLine[X2], X - X2);
+ ArgV[C][X - X2] = '\0';
+ C++; X2 = X + 1;
+ }
+ }
+ ArgV[C] = NULL;
+ for (C = 0; ; C++) {
+ if (ArgV[C] == NULL) break;
+ printf("--> '%s' \n", ArgV[C]);
+ }
+ switch(fork()) {
+ case -1:
+ printf("Can'k 'fork' process !\n");
+ break;
+ case 0:
+ printf("New process started !\n");
+ execvp(ArgV[0], ArgV);
+ printf("Child process died !\n");
+ exit(1);
+ break;
+ default:
+ printf("Main process stay alive !\n");
+ break;
+ }
+ for (C = 0; ; C++) {
+ if (ArgV[C] == NULL) break;
+ free(ArgV[C]);
+ }
+ return(TRUE);
+}
+
+
+BOOL WinHelp(HWND hWnd, LPSTR lpHelpFile, WORD wCommand, DWORD dwData)
+{
+ char *ArgV[6];
+ char str[32];
+ printf("WinHelp(%s, %u, %lu)\n", lpHelpFile, wCommand, dwData);
+ switch(fork()) {
+ case -1:
+ printf("Can'k 'fork' process !\n");
+ break;
+ case 0:
+ printf("New process started !\n");
+ ArgV[0] = "wine";
+ ArgV[1] = "/C:/windows/winhelp.exe";
+ ArgV[2] = lpHelpFile;
+ switch (wCommand) {
+ case HELP_CONTEXT:
+ case HELP_KEY:
+ case HELP_SETINDEX:
+ sprintf(str, "%lu", dwData);
+ ArgV[3] = str;
+ default:
+ ArgV[3] = NULL;
+ }
+ ArgV[4] = NULL;
+ if (wCommand == HELP_HELPONHELP) ArgV[2] = NULL;
+/*
+ _WinMain(ArgV, 2);
+*/
+ execvp(ArgV[0], ArgV);
+ printf("Child process died !\n");
+ exit(1);
+ break;
+ default:
+ printf("Main process stay alive !\n");
+ break;
+ }
+return(TRUE);
+}
+
+
diff --git a/misc/kernel.c b/misc/kernel.c
index cb6aa17..ea3c3c0 100644
--- a/misc/kernel.c
+++ b/misc/kernel.c
@@ -71,7 +71,7 @@
int
KERNEL_GetModuleFileName(int module, char *filename, int bytes)
{
-#ifdef RELAY_DEBUG
+#ifdef DEBUG_RELAY
printf("GetModuleFileName: module %d, filename %x, bytes %d\n",
module, filename, bytes);
#endif
diff --git a/misc/lstr.c b/misc/lstr.c
index 7bf2250..77e178c 100644
--- a/misc/lstr.c
+++ b/misc/lstr.c
@@ -12,9 +12,6 @@
#include "windows.h"
-#define LPCSTR LPSTR /* I think this should be const char **/
-typedef unsigned short UINT;
-
/* Funny to divide them between user and kernel. */
/* KERNEL.89 */
@@ -113,7 +110,7 @@
}
/* AnsiNext USER.472 */
-LPSTR AnsiNext(LPCSTR current)
+LPSTR AnsiNext(LPSTR current)
{
return (*current)?current+1:current;
}
diff --git a/misc/profile.c b/misc/profile.c
index b38c6f8..ac50d86 100644
--- a/misc/profile.c
+++ b/misc/profile.c
@@ -10,8 +10,9 @@
#include <stdio.h>
#include <string.h>
#include "windows.h"
+#include "wine.h"
-#define INIFILE "win.ini"
+#define INIFILE GetSystemIniFilename()
#define STRSIZE 255
#define xmalloc(x) malloc(x)
#define overflow (next == &CharBuffer [STRSIZE-1])
@@ -298,25 +299,3 @@
{
dump_profile (Base);
}
-
-#ifdef DUMBTEST
-main ()
-{
- char r [100], app [100], key [100], valor [100];
-
- while (1){
- printf ("Dame, Aplicacion, llave\n");
- gets (app);
- if (!app [0]){
- sync_profiles ();
- return;
- }
- gets (key);
- gets (valor);
- GetProfileString (app, key, "1No_Encontrado", r, sizeof (r));
- printf ("(%d)\n", GetProfileInt (app, key, 5));
- printf ("%s\n", r);
- WriteProfileString (app, key, valor);
- }
-}
-#endif
diff --git a/misc/user.c b/misc/user.c
index 476d861..58087ee 100644
--- a/misc/user.c
+++ b/misc/user.c
@@ -50,7 +50,10 @@
DCE_Init();
/* Initialize built-in window classes */
- WIDGETS_Init();
+ if (!WIDGETS_Init()) return 0;
+
+ /* Initialize dialog manager */
+ if (!DIALOG_Init()) return 0;
/* Create task message queue */
if (!SetMessageQueue( DEFAULT_MSG_QUEUE_SIZE )) return 0;
diff --git a/misc/xt.c b/misc/xt.c
index 5756d39..928d6dd 100644
--- a/misc/xt.c
+++ b/misc/xt.c
@@ -14,12 +14,7 @@
#include <X11/Core.h>
#include <X11/Shell.h>
-#include "message.h"
-#include "callback.h"
-#include "win.h"
-#include "class.h"
-#include "gdi.h"
-#include "user.h"
+#include "windows.h"
#ifdef __NetBSD__
#define HZ 100
@@ -50,87 +45,6 @@
}
-/***********************************************************************
- * DefWindowProc (USER.107)
- */
-LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam )
-{
- WND * wndPtr;
- CLASS * classPtr;
- LPSTR textPtr;
- int len;
-
-#ifdef DEBUG_MESSAGE
- printf( "DefWindowProc: %d %d %d %08x\n", hwnd, msg, wParam, lParam );
-#endif
-
- switch(msg)
- {
- case WM_PAINT:
- {
- PAINTSTRUCT paintstruct;
- BeginPaint( hwnd, &paintstruct );
- EndPaint( hwnd, &paintstruct );
- return 0;
- }
-
- case WM_CREATE:
- return 0;
-
- case WM_CLOSE:
- DestroyWindow( hwnd );
- return 0;
-
- case WM_ERASEBKGND:
- case WM_ICONERASEBKGND:
- {
- if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 1;
- if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return 1;
- if (!classPtr->wc.hbrBackground) return 1;
- FillWindow( wndPtr->hwndParent, hwnd, (HDC)wParam,
- classPtr->wc.hbrBackground );
- GlobalUnlock( hwnd );
- return 0;
- }
-
- case WM_GETTEXT:
- {
- if (wParam)
- {
- wndPtr = WIN_FindWndPtr(hwnd);
- if (wndPtr->hText)
- {
- textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
- if ((int)wParam > (len = strlen(textPtr)))
- {
- strcpy((LPSTR)lParam, textPtr);
- GlobalUnlock(hwnd);
- return (DWORD)len;
- }
- }
- ((LPSTR)lParam)[0] = NULL;
- }
- GlobalUnlock(hwnd);
- return (0L);
- }
-
- case WM_GETTEXTLENGTH:
- {
- wndPtr = WIN_FindWndPtr(hwnd);
- if (wndPtr->hText)
- {
- textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
- len = strlen(textPtr);
- GlobalUnlock(hwnd);
- return (DWORD)len;
- }
- GlobalUnlock(hwnd);
- return (0L);
- }
- }
- return 0;
-}
-
/********************************************************************
*
@@ -194,7 +108,8 @@
return FALSE;
}
-HMENU CreateMenu() { }
+HMENU CreateMenu() { return 0; }
-BOOL AppendMenu( HMENU hmenu, WORD flags, WORD id, LPSTR text ) { }
+BOOL AppendMenu( HMENU hmenu, WORD flags, WORD id, LPSTR text ) { return TRUE;}
+BOOL DestroyMenu( HMENU hmenu ) { return TRUE; }
diff --git a/objects/Makefile b/objects/Makefile
index f1dcd06..cb70d89 100644
--- a/objects/Makefile
+++ b/objects/Makefile
@@ -9,7 +9,7 @@
$(LD) -r -o objects.o $(OBJS)
clean:
- rm -f *.o *~ *.s dll_* *.a
+ rm -f *.o *~ *.s dll_* *.a *#
depend:
$(CC) $(CFLAGS) -M *.c > .depend
diff --git a/objects/color.c b/objects/color.c
index a57b46e..0215d47 100644
--- a/objects/color.c
+++ b/objects/color.c
@@ -19,6 +19,7 @@
* We try to use a private color map if possible, because Windows programs
* assume that palette(0) == Black and palette(max-1) == White.
*/
+#define USE_PRIVATE_MAP
Colormap COLOR_WinColormap = 0;
@@ -71,11 +72,39 @@
*
* Fill the private colormap.
*/
+#ifdef USE_PRIVATE_MAP
+
static BOOL COLOR_BuildMap( Colormap map, int depth, int size )
{
XColor color;
int i;
+ /* Fill the whole map with a range of colors */
+
+ if ((1 << depth) > NB_SYS_COLORS)
+ {
+ int red_incr, green_incr, blue_incr;
+ int r, g, b;
+
+ blue_incr = 0x10000 >> (depth / 3);
+ red_incr = 0x10000 >> ((depth + 1) / 3);
+ green_incr = 0x10000 >> ((depth + 2) / 3);
+
+ for (i = 0, r = red_incr - 1; r < 0x10000; r += red_incr)
+ for (g = green_incr - 1; g < 0x10000; g += green_incr)
+ for (b = blue_incr - 1; b < 0x10000; b += blue_incr)
+ {
+ if (i >= size) break;
+ color.pixel = i++;
+ color.red = r;
+ color.green = g;
+ color.blue = b;
+ XStoreColor( XT_display, map, &color );
+ }
+ }
+
+ /* Store the system palette colors */
+
for (i = 0; i < NB_SYS_COLORS; i++)
{
if (!XParseColor( XT_display, map, SysColors[i], &color ))
@@ -86,7 +115,7 @@
}
return TRUE;
}
-
+#endif /* USE_PRIVATE_MAP */
/***********************************************************************
* COLOR_Init
@@ -117,7 +146,7 @@
case StaticColor:
case TrueColor:
COLOR_FillDefaultMap();
- COLOR_WinColormap = CopyFromParent;
+ COLOR_WinColormap = DefaultColormapOfScreen( XT_screen );
break;
}
return TRUE;
diff --git a/objects/font.c b/objects/font.c
index c30fcec..1299a26 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -330,3 +330,38 @@
return TRUE;
}
+
+/***********************************************************************
+ * GetCharWidth (GDI.350)
+ */
+BOOL GetCharWidth(HDC hdc, WORD wFirstChar, WORD wLastChar, LPINT lpBuffer)
+{
+ int i, j;
+ XFontStruct *xfont;
+ XCharStruct *charPtr;
+ int default_width;
+
+ DC *dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC);
+ if (!dc) return FALSE;
+ xfont = dc->u.x.font.fstruct;
+
+ /* fixed font? */
+ if (xfont->per_char == NULL)
+ {
+ for (i = wFirstChar, j = 0; i <= wLastChar; i++, j++)
+ *(lpBuffer + j) = xfont->max_bounds.width;
+ return TRUE;
+ }
+
+ charPtr = xfont->per_char;
+ default_width = (charPtr + xfont->default_char)->width;
+
+ for (i = wFirstChar, j = 0; i <= wLastChar; i++, j++)
+ {
+ if (i < xfont->min_char_or_byte2 || i > xfont->max_char_or_byte2)
+ *(lpBuffer + j) = default_width;
+ else
+ *(lpBuffer + j) = charPtr->width;
+ }
+ return TRUE;
+}
diff --git a/objects/palette.c b/objects/palette.c
index ec69700..3b101b2 100644
--- a/objects/palette.c
+++ b/objects/palette.c
@@ -33,7 +33,6 @@
{
int i, size;
XColor color;
- Colormap map;
HPALETTE hpalette;
LOGPALETTE * palPtr;
@@ -44,13 +43,10 @@
palPtr->palNumEntries = size;
memset( palPtr->palPalEntry, 0xff, size*sizeof(PALETTEENTRY) );
- if ((map = COLOR_WinColormap) == CopyFromParent)
- map = DefaultColormapOfScreen( XT_screen );
-
for (i = 0; i < size; i++)
{
color.pixel = i;
- XQueryColor( XT_display, map, &color );
+ XQueryColor( XT_display, COLOR_WinColormap, &color );
palPtr->palPalEntry[i].peRed = color.red >> 8;
palPtr->palPalEntry[i].peGreen = color.green >> 8;
palPtr->palPalEntry[i].peBlue = color.blue >> 8;
@@ -136,7 +132,8 @@
palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
if (!palPtr) return 0;
- if (COLOR_WinColormap && (hpalette == STOCK_DEFAULT_PALETTE))
+ if ((COLOR_WinColormap != DefaultColormapOfScreen(XT_screen)) &&
+ (hpalette == STOCK_DEFAULT_PALETTE))
{
if ((color & 0xffffff) == 0) return 0; /* Entry 0 is black */
if ((color & 0xffffff) == 0xffffff) /* Max entry is white */
diff --git a/objects/text.c b/objects/text.c
index 97ff35b..bbb2740 100644
--- a/objects/text.c
+++ b/objects/text.c
@@ -17,6 +17,159 @@
#include "win.h"
#include "gdi.h"
+#define TAB 9
+#define LF 10
+#define CR 13
+#define SPACE 32
+#define PREFIX 38
+
+static int tabstop = 8;
+static int tabwidth;
+static int spacewidth;
+static int prefix_offset;
+
+
+static char *TEXT_NextLine(HDC hdc, char *str, int *count, char *dest,
+ int *len, int width, WORD format)
+{
+ /* Return next line of text from a string.
+ *
+ * hdc - handle to DC.
+ * str - string to parse into lines.
+ * count - length of str.
+ * dest - destination in which to return line.
+ * len - length of resultant line in dest in chars.
+ * width - maximum width of line in pixels.
+ * format - format type passed to DrawText.
+ *
+ * Returns pointer to next char in str after end of the line
+ * or NULL if end of str reached.
+ */
+
+ int i = 0, j = 0, k;
+ int plen = 0;
+ int numspaces;
+ SIZE size;
+ int lasttab = 0;
+ int wb_i = 0, wb_j = 0, wb_count;
+
+ while (*count)
+ {
+ switch (str[i])
+ {
+ case CR:
+ case LF:
+ if (!(format & DT_SINGLELINE))
+ {
+ i++;
+ if (str[i] == CR || str[i] == LF)
+ i++;
+ *len = j;
+ return (&str[i]);
+ }
+ dest[j++] = str[i++];
+ if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX))
+ {
+ if (!GetTextExtentPoint(hdc, &dest[j-1], 1, &size))
+ return NULL;
+ plen += size.cx;
+ }
+ break;
+
+ case PREFIX:
+ if (!(format & DT_NOPREFIX))
+ {
+ prefix_offset = j + 1;
+ i++;
+ }
+ else
+ {
+ dest[j++] = str[i++];
+ if (!(format & DT_NOCLIP))
+ {
+ if (!GetTextExtentPoint(hdc, &dest[j-1], 1, &size))
+ return NULL;
+ plen += size.cx;
+ }
+ }
+ break;
+
+ case TAB:
+ if (format & DT_EXPANDTABS)
+ {
+ wb_i = ++i;
+ wb_j = j;
+ wb_count = *count;
+
+ if (!GetTextExtentPoint(hdc, &dest[lasttab], j - lasttab,
+ &size))
+ return NULL;
+
+ numspaces = (tabwidth - size.cx) / spacewidth;
+ for (k = 0; k < numspaces; k++)
+ dest[j++] = SPACE;
+ plen += tabwidth - size.cx;
+ lasttab = wb_j + numspaces;
+ }
+ else
+ {
+ dest[j++] = str[i++];
+ if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX))
+ {
+ if (!GetTextExtentPoint(hdc, &dest[j-1], 1, &size))
+ return NULL;
+ plen += size.cx;
+ }
+ }
+ break;
+
+ case SPACE:
+ dest[j++] = str[i++];
+ if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX))
+ {
+ wb_i = i;
+ wb_j = j - 1;
+ wb_count = *count;
+ if (!GetTextExtentPoint(hdc, &dest[j-1], 1, &size))
+ return NULL;
+ plen += size.cx;
+ }
+ break;
+
+ default:
+ dest[j++] = str[i++];
+ if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX))
+ {
+ if (!GetTextExtentPoint(hdc, &dest[j-1], 1, &size))
+ return NULL;
+ plen += size.cx;
+ }
+ }
+
+ (*count)--;
+ if (!(format & DT_NOCLIP) || (format & DT_WORDBREAK))
+ {
+ if (plen > width)
+ {
+ if (format & DT_WORDBREAK)
+ {
+ *len = wb_j;
+ *count = wb_count;
+ return (&str[wb_i]);
+ }
+ else
+ {
+ *len = j;
+ return (&str[i]);
+ }
+ }
+ }
+ }
+
+ *len = j;
+ return NULL;
+}
+
/***********************************************************************
* DrawText (USER.85)
@@ -24,17 +177,77 @@
int DrawText( HDC hdc, LPSTR str, int count, LPRECT rect, WORD flags )
{
SIZE size;
+ char *strPtr;
+ static char line[1024];
+ int len, lh, prefix_x, prefix_len;
+ TEXTMETRIC tm;
int x = rect->left, y = rect->top;
+ int width = rect->right - rect->left;
+
if (count == -1) count = strlen(str);
+ strPtr = str;
- if (!GetTextExtentPoint( hdc, str, count, &size )) return 0;
-
- if (flags & DT_CENTER) x = (rect->left + rect->right - size.cx) / 2;
- else if (flags & DT_RIGHT) x = rect->right - size.cx;
- if (flags & DT_VCENTER) y = (rect->top + rect->bottom - size.cy) / 2;
- else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
+ GetTextMetrics(hdc, &tm);
+ if (flags & DT_EXTERNALLEADING)
+ lh = tm.tmHeight + tm.tmExternalLeading;
+ else
+ lh = tm.tmHeight;
- if (!TextOut( hdc, x, y, str, count )) return 0;
+ if (flags & DT_TABSTOP)
+ tabstop = flags >> 8;
+
+ if (flags & DT_EXPANDTABS)
+ {
+ GetTextExtentPoint(hdc, " ", 1, &size);
+ spacewidth = size.cx;
+ GetTextExtentPoint(hdc, "o", 1, &size);
+ tabwidth = size.cx * tabstop;
+ }
+
+ do
+ {
+ prefix_offset = -1;
+ strPtr = TEXT_NextLine(hdc, strPtr, &count, line, &len, width, flags);
+
+ if (prefix_offset != -1)
+ {
+ GetTextExtentPoint(hdc, line, prefix_offset - 1, &size);
+ prefix_x = size.cx;
+ GetTextExtentPoint(hdc, line + prefix_offset, 1, &size);
+ prefix_len = size.cx;
+ }
+
+ if (!GetTextExtentPoint(hdc, line, len, &size)) return 0;
+ if (flags & DT_CENTER) x = (rect->left + rect->right -
+ size.cx) / 2;
+ else if (flags & DT_RIGHT) x = rect->right - size.cx;
+
+ if (flags & DT_SINGLELINE)
+ {
+ if (flags & DT_VCENTER) y = (rect->top + rect->bottom -
+ size.cy) / 2;
+ else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
+ }
+
+ if (!TextOut(hdc, x, y, line, len)) return 0;
+ if (prefix_offset != -1)
+ {
+ MoveTo(hdc, x + prefix_x, y + size.cy);
+ LineTo(hdc, x + prefix_x + prefix_len, y + size.cy);
+ }
+
+ if (strPtr)
+ {
+ y += lh;
+ if (!(flags & DT_NOCLIP))
+ {
+ if (y > rect->bottom - lh)
+ break;
+ }
+ }
+ }
+ while (strPtr);
+
return 1;
}
diff --git a/test/btnlook.c b/test/btnlook.c
index d5b8dcd..28f5608 100755
--- a/test/btnlook.c
+++ b/test/btnlook.c
@@ -7,23 +7,22 @@
struct
{
- long style;
- char *text;
+ long style;
+ char *text;
}
button[] =
{
- BS_PUSHBUTTON, "PUSHBUTTON",
- BS_DEFPUSHBUTTON, "DEFPUSHBUTTON",
-/* BS_CHECKBOX, "CHECKBOX",
- BS_AUTOCHECKBOX, "AUTOCHECKBOX",
- BS_RADIOBUTTON, "RADIOBUTTON",
- BS_3STATE, "3STATE",
- BS_AUTO3STATE, "AUTO3STATE",
- BS_GROUPBOX, "GROUPBOX",
- BS_USERBUTTON, "USERBUTTON",
- BS_AUTORADIOBUTTON, "AUTORADIOBUTTON",
- BS_PUSHBOX, "PUSHBOX"
-*/};
+ BS_PUSHBUTTON, "PUSHBUTTON",
+ BS_DEFPUSHBUTTON, "DEFPUSHBUTTON",
+ BS_CHECKBOX, "CHECKBOX",
+ BS_AUTOCHECKBOX, "AUTOCHECKBOX",
+ BS_RADIOBUTTON, "RADIOBUTTON",
+ BS_3STATE, "3STATE",
+ BS_AUTO3STATE, "AUTO3STATE",
+ BS_GROUPBOX, "GROUPBOX",
+ BS_USERBUTTON, "USERBUTTON",
+ BS_AUTORADIOBUTTON, "AUTORADIOBUTTON"
+};
#define NUM (sizeof button / sizeof button[0])
@@ -72,18 +71,18 @@
long FAR PASCAL _export WndProc(HWND hwnd, WORD message, WORD wParam, LONG lParam)
{
- static char szPrm[] = "wParam LOWORD(lParam) HIWORD(lParam)",
- szTop[] = "Control ID Window Handle Notification",
- szUnd[] = "__________ _____________ ____________",
- szFormat[] = " %5u %4X %5u",
- szBuffer[50];
- static HWND hwndButton[NUM];
- static RECT rect;
- static int cxChar, cyChar;
+ static char szPrm[] = "wParam LOWORD(lParam) HIWORD(lParam)",
+ szTop[] = "Control ID Window Handle Notification",
+ szUnd[] = "__________ _____________ ____________",
+ szFormat[] = " %5u %4X %5u",
+ szBuffer[50];
+ static HWND hwndButton[NUM];
+ static RECT rect;
+ static int cxChar, cyChar;
HDC hdc;
PAINTSTRUCT ps;
- int i;
- TEXTMETRIC tm;
+ int i;
+ TEXTMETRIC tm;
switch (message)
{
diff --git a/test/btnlook.exe b/test/btnlook.exe
index b65a5ed..134c8a1 100755
--- a/test/btnlook.exe
+++ b/test/btnlook.exe
Binary files differ
diff --git a/test/hyperoid/blank.bmp b/test/hyperoid/blank.bmp
deleted file mode 100644
index 11840af..0000000
--- a/test/hyperoid/blank.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/bomb.bmp b/test/hyperoid/bomb.bmp
deleted file mode 100644
index 5fcde4a..0000000
--- a/test/hyperoid/bomb.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/copying.txt b/test/hyperoid/copying.txt
deleted file mode 100644
index 2d64ec5..0000000
--- a/test/hyperoid/copying.txt
+++ /dev/null
@@ -1,292 +0,0 @@
-
- GNU GENERAL PUBLIC LICENSE
- Version 1, February 1989
-
- Copyright (C) 1989 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The license agreements of most software companies try to keep users
-at the mercy of those companies. By contrast, our General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. The
-General Public License applies to the Free Software Foundation's
-software and to any other program whose authors commit to using it.
-You can use it for your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Specifically, the General Public License is designed to make
-sure that you have the freedom to give away or sell copies of free
-software, that you receive source code or can get it if you want it,
-that you can change the software or use pieces of it in new free
-programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of a such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must tell them their rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any program or other work which
-contains a notice placed by the copyright holder saying it may be
-distributed under the terms of this General Public License. The
-"Program", below, refers to any such program or work, and a "work based
-on the Program" means either the Program or any work containing the
-Program or a portion of it, either verbatim or with modifications. Each
-licensee is addressed as "you".
-
- 1. You may copy and distribute verbatim copies of the Program's source
-code as you receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice and
-disclaimer of warranty; keep intact all the notices that refer to this
-General Public License and to the absence of any warranty; and give any
-other recipients of the Program a copy of this General Public License
-along with the Program. You may charge a fee for the physical act of
-transferring a copy.
-
- 2. You may modify your copy or copies of the Program or any portion of
-it, and copy and distribute such modifications under the terms of Paragraph
-1 above, provided that you also do the following:
-
- a) cause the modified files to carry prominent notices stating that
- you changed the files and the date of any change; and
-
- b) cause the whole of any work that you distribute or publish, that
- in whole or in part contains the Program or any part thereof, either
- with or without modifications, to be licensed at no charge to all
- third parties under the terms of this General Public License (except
- that you may choose to grant warranty protection to some or all
- third parties, at your option).
-
- c) If the modified program normally reads commands interactively when
- run, you must cause it, when started running for such interactive use
- in the simplest and most usual way, to print or display an
- announcement including an appropriate copyright notice and a notice
- that there is no warranty (or else, saying that you provide a
- warranty) and that users may redistribute the program under these
- conditions, and telling the user how to view a copy of this General
- Public License.
-
- d) You may charge a fee for the physical act of transferring a
- copy, and you may at your option offer warranty protection in
- exchange for a fee.
-
-Mere aggregation of another independent work with the Program (or its
-derivative) on a volume of a storage or distribution medium does not bring
-the other work under the scope of these terms.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 3. You may copy and distribute the Program (or a portion or derivative of
-it, under Paragraph 2) in object code or executable form under the terms of
-Paragraphs 1 and 2 above provided that you also do one of the following:
-
- a) accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of
- Paragraphs 1 and 2 above; or,
-
- b) accompany it with a written offer, valid for at least three
- years, to give any third party free (except for a nominal charge
- for the cost of distribution) a complete machine-readable copy of the
- corresponding source code, to be distributed under the terms of
- Paragraphs 1 and 2 above; or,
-
- c) accompany it with the information you received as to where the
- corresponding source code may be obtained. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form alone.)
-
-Source code for a work means the preferred form of the work for making
-modifications to it. For an executable file, complete source code means
-all the source code for all modules it contains; but, as a special
-exception, it need not include source code for modules which are standard
-libraries that accompany the operating system on which the executable
-file runs, or for standard header files or definitions files that
-accompany that operating system.
-
- 4. You may not copy, modify, sublicense, distribute or transfer the
-Program except as expressly provided under this General Public License.
-Any attempt otherwise to copy, modify, sublicense, distribute or transfer
-the Program is void, and will automatically terminate your rights to use
-the Program under this License. However, parties who have received
-copies, or rights to use copies, from you under this General Public
-License will not have their licenses terminated so long as such parties
-remain in full compliance.
-
- 5. By copying, distributing or modifying the Program (or any work based
-on the Program) you indicate your acceptance of this license to do so,
-and all its terms and conditions.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the original
-licensor to copy, distribute or modify the Program subject to these
-terms and conditions. You may not impose any further restrictions on the
-recipients' exercise of the rights granted herein.
-
-
-
- 7. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of the license which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-the license, you may choose any version ever published by the Free Software
-Foundation.
-
- 8. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
-
-
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to humanity, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these
-terms.
-
- To do so, attach the following notices to the program. It is safest to
-attach them to the start of each source file to most effectively convey
-the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- any later version.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19xx name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the
-appropriate parts of the General Public License. Of course, the
-commands you use may be called something other than `show w' and `show
-c'; they could even be mouse-clicks or menu items--whatever suits your
-program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- program `Gnomovision' (a program to direct compilers to make passes
- at assemblers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-That's all there is to it!
-
diff --git a/test/hyperoid/hyperoid.c b/test/hyperoid/hyperoid.c
deleted file mode 100644
index f396d55..0000000
--- a/test/hyperoid/hyperoid.c
+++ /dev/null
@@ -1,1851 +0,0 @@
-//
-// HYPEROID - a neato game
-//
-// Version: 1.1 Copyright (C) 1990,91 Hutchins Software
-// This software is licenced under the GNU General Public Licence
-// Please read the associated legal documentation
-// Author: Edward Hutchins
-// Internet: eah1@cec1.wustl.edu
-// USNail: c/o Edward Hutchins, 63 Ridgemoor Dr., Clayton, MO, 63105
-// Revisions:
-// 10/31/91 made game better/harder - Ed.
-//
-// Music: R.E.M./The Cure/Ministry/Front 242/The Smiths/New Order/Hendrix...
-// Beers: Bass Ale, Augsberger Dark
-//
-
-#include "hyperoid.h"
-
-//
-// imports
-//
-
-IMPORT POINT LetterPart[] FROM( roidsupp.c );
-IMPORT NPSTR szNumberDesc[] FROM( roidsupp.c );
-IMPORT NPSTR szLetterDesc[] FROM( roidsupp.c );
-
-//
-// globals
-//
-
-GLOBAL CHAR szAppName[32];
-GLOBAL HANDLE hAppInst;
-GLOBAL HWND hAppWnd;
-GLOBAL HPALETTE hAppPalette;
-GLOBAL INT nDrawDelay;
-GLOBAL INT nLevel;
-GLOBAL INT nSafe;
-GLOBAL INT nShield;
-GLOBAL INT nBomb;
-GLOBAL INT nBadGuys;
-GLOBAL LONG lScore;
-GLOBAL LONG lLastLife;
-GLOBAL LONG lHighScore;
-GLOBAL BOOL bRestart;
-GLOBAL BOOL bPaused;
-GLOBAL BOOL bBW;
-GLOBAL INT vkShld;
-GLOBAL INT vkClkw;
-GLOBAL INT vkCtrClkw;
-GLOBAL INT vkThrst;
-GLOBAL INT vkRvThrst;
-GLOBAL INT vkFire;
-GLOBAL INT vkBomb;
-GLOBAL NPOBJ npPlayer;
-GLOBAL LIST FreeList;
-GLOBAL LIST RoidList;
-GLOBAL LIST ShotList;
-GLOBAL LIST FlameList;
-GLOBAL LIST SpinnerList;
-GLOBAL LIST HunterList;
-GLOBAL LIST HunterShotList;
-GLOBAL LIST SwarmerList;
-GLOBAL LIST LetterList;
-GLOBAL LIST BonusList;
-GLOBAL INT nCos[DEGREE_SIZE];
-GLOBAL INT nSin[DEGREE_SIZE];
-GLOBAL HPEN hPen[PALETTE_SIZE];
-GLOBAL OBJ Obj[MAX_OBJS];
-GLOBAL HBITMAP hBitmap[IDB_MAX];
-
-//
-// locals
-//
-
-LOCAL DWORD dwSeed;
-LOCAL INT nScoreLen;
-LOCAL CHAR szScore[40];
-LOCAL RECT rectScoreClip;
-LOCAL RECT rectShotClip;
-LOCAL POINT Player[] =
-{ {0, 0}, {160, 150}, {0, 250}, {96, 150}, {0, 0} };
-LOCAL POINT Spinner[] =
-{ {160, 150}, {224, 100}, {96, 100}, {32, 150}, {160, 150} };
-LOCAL POINT Swarmer[] =
-{ {0, 100}, {64, 100}, {128, 100}, {192, 100}, {0, 100} };
-LOCAL POINT Hunter[] =
-{
- {160, 150}, {0, 250}, {192, 30}, {64, 30},
- {0, 250}, {96, 150}, {128, 150}, {160, 150}
-};
-LOCAL POINT Bonus[] =
-{ {0, 150}, {102, 150}, {205, 150}, {51, 150}, {154, 150}, {0, 150} };
-
-//
-// KillBadGuy - kill off a badguy (made into a macro)
-//
-
-#define KillBadGuy() \
-((--nBadGuys <= 0)?(SetRestart( RESTART_NEXTLEVEL ),TRUE):FALSE)
-
-//
-// arand - pseudorandom number from 0 to x-1 (thanks antman!)
-//
-
-INT NEAR PASCAL arand( INT x )
-{
- dwSeed = dwSeed * 0x343fd + 0x269ec3;
- return( (INT)(((dwSeed >> 16) & 0x7fff) * x >> 15) );
-}
-
-//
-// AddHead - add an object to the head of a list
-//
-
-VOID NEAR PASCAL AddHead( NPLIST npList, NPNODE npNode )
-{
- if (npList->npHead)
- {
- npNode->npNext = npList->npHead;
- npNode->npPrev = NULL;
- npList->npHead = (npList->npHead->npPrev = npNode);
- }
- else // add to an empty list
- {
- npList->npHead = npList->npTail = npNode;
- npNode->npNext = npNode->npPrev = NULL;
- }
-}
-
-//
-// RemHead - remove the first element in a list
-//
-
-NPNODE NEAR PASCAL RemHead( NPLIST npList )
-{
- if (npList->npHead)
- {
- NPNODE npNode = npList->npHead;
- if (npList->npTail != npNode)
- {
- npList->npHead = npNode->npNext;
- npNode->npNext->npPrev = NULL;
- }
- else npList->npHead = npList->npTail = NULL;
- return( npNode );
- }
- else return( NULL );
-}
-
-//
-// Remove - remove an arbitrary element from a list
-//
-
-VOID NEAR PASCAL Remove( NPLIST npList, NPNODE npNode )
-{
- if (npNode->npPrev) npNode->npPrev->npNext = npNode->npNext;
- else npList->npHead = npNode->npNext;
- if (npNode->npNext) npNode->npNext->npPrev = npNode->npPrev;
- else npList->npTail = npNode->npPrev;
-}
-
-//
-// DrawObject - draw a single object
-//
-
-VOID NEAR PASCAL DrawObject( HDC hDC, NPOBJ npObj )
-{
- INT nCnt;
- INT nDir = (npObj->nDir += npObj->nSpin);
- INT x = (npObj->Pos.x += npObj->Vel.x);
- INT y = (npObj->Pos.y += npObj->Vel.y);
- POINT Pts[MAX_PTS];
-
- if (x < -CLIP_COORD) npObj->Pos.x = x = CLIP_COORD;
- else if (x > CLIP_COORD) npObj->Pos.x = x = -CLIP_COORD;
- if (y < -CLIP_COORD) npObj->Pos.y = y = CLIP_COORD;
- else if (y > CLIP_COORD) npObj->Pos.y = y = -CLIP_COORD;
-
- for (nCnt = npObj->byPts - 1; nCnt >= 0; --nCnt)
- {
- WORD wDeg = DEG( npObj->Pts[nCnt].x + nDir );
- INT nLen = npObj->Pts[nCnt].y;
- Pts[nCnt].x = x + MULDEG( nLen, nCos[wDeg] );
- Pts[nCnt].y = y + MULDEG( nLen, nSin[wDeg] );
- }
-
- if (npObj->byPts > 1)
- {
- SelectObject( hDC, hPen[BLACK] );
- Polyline( hDC, npObj->Old, npObj->byPts );
- if (npObj->nCount > 0)
- {
- SelectObject( hDC, hPen[npObj->byColor] );
- Polyline( hDC, Pts, npObj->byPts );
- for (nCnt = npObj->byPts - 1; nCnt >= 0; --nCnt)
- npObj->Old[nCnt] = Pts[nCnt];
- }
- }
- else // just a point
- {
- SetPixel( hDC, npObj->Old[0].x, npObj->Old[0].y, PALETTEINDEX( BLACK ) );
- if (npObj->nCount > 0)
- {
- SetPixel( hDC, Pts[0].x, Pts[0].y, PALETTEINDEX( npObj->byColor ) );
- npObj->Old[0] = Pts[0];
- }
- }
-}
-
-//
-// SetRestart - set the restart timer
-//
-
-VOID NEAR PASCAL SetRestart( RESTART_MODE Restart )
-{
- POINT Pt;
- CHAR szBuff[32];
-
- if (bRestart) return;
- SetTimer( hAppWnd, RESTART_TIMER, RESTART_DELAY, NULL );
- bRestart = TRUE;
-
- Pt.x = Pt.y = 0;
- switch (Restart)
- {
- case RESTART_GAME:
- SpinLetters( "GAME OVER", Pt, Pt, RED, 400 );
- break;
- case RESTART_LEVEL:
- PrintLetters( "GET READY", Pt, Pt, BLUE, 300 );
- break;
- case RESTART_NEXTLEVEL:
- wsprintf( szBuff, "LEVEL %u", nLevel + 1 );
- PrintLetters( szBuff, Pt, Pt, BLUE, 300 );
- break;
- }
-}
-
-//
-// PrintPlayerMessage - show the player a status message
-//
-
-VOID NEAR PASCAL PrintPlayerMessage( NPSTR npszText )
-{
- POINT Pos, Vel;
-
- Pos = npPlayer->Pos;
- Pos.y -= 400;
- Vel.x = 0;
- Vel.y = -50;
- PrintLetters( npszText, Pos, Vel, GREEN, 150 );
-}
-
-//
-// AddExtraLife - give the player another life
-//
-
-VOID NEAR PASCAL AddExtraLife( VOID )
-{
- PrintPlayerMessage( "EXTRA LIFE" );
- ++npPlayer->nCount;
- npPlayer->byColor = (BYTE)(BLACK + npPlayer->nCount);
- if (npPlayer->byColor > WHITE) npPlayer->byColor = WHITE;
-}
-
-//
-// Hit - something hit an object, do fireworks
-//
-
-VOID NEAR PASCAL Hit( HDC hDC, NPOBJ npObj )
-{
- INT nCnt;
-
- for (nCnt = 0; nCnt < 6; ++nCnt)
- {
- NPOBJ npFlame = RemHeadObj( &FreeList );
- if (!npFlame) return;
- npFlame->Pos.x = npObj->Pos.x;
- npFlame->Pos.y = npObj->Pos.y;
- npFlame->Vel.x = npObj->Vel.x;
- npFlame->Vel.y = npObj->Vel.y;
- npFlame->nDir = npObj->nDir + (nCnt * DEGREE_SIZE) / 6;
- npFlame->nSpin = 0;
- npFlame->nCount = 10 + arand( 8 );
- npFlame->byColor = YELLOW;
- npFlame->byPts = 1;
- npFlame->Pts[0].x = npFlame->Pts[0].y = 0;
- ACCEL( npFlame, npFlame->nDir, 50 - npFlame->nCount );
- AddHeadObj( &FlameList, npFlame );
- }
-}
-
-//
-// Explode - explode an object
-//
-
-VOID NEAR PASCAL Explode( HDC hDC, NPOBJ npObj )
-{
- INT nCnt, nSize = npObj->byPts;
-
- DrawObject( hDC, npObj );
- for (nCnt = 0; nCnt < nSize; ++nCnt)
- {
- NPOBJ npFlame;
- if (arand( 2 )) continue;
- if (!(npFlame = RemHeadObj( &FreeList ))) return;
- npFlame->Pos.x = npObj->Pos.x;
- npFlame->Pos.y = npObj->Pos.y;
- npFlame->Vel.x = npObj->Vel.x;
- npFlame->Vel.y = npObj->Vel.y;
- npFlame->nDir = npObj->nDir + nCnt * DEGREE_SIZE / nSize + arand( 32 );
- npFlame->nSpin = arand( 31 ) - 15;
- npFlame->nCount = 25 + arand( 16 );
- npFlame->byColor = npObj->byColor;
- npFlame->byPts = 2;
- npFlame->Pts[0] = npObj->Pts[nCnt];
- if (nCnt == nSize - 1) npFlame->Pts[1] = npObj->Pts[0];
- else npFlame->Pts[1] = npObj->Pts[nCnt + 1];
- ACCEL( npFlame, npFlame->nDir, 60 - npFlame->nCount );
- AddHeadObj( &FlameList, npFlame );
- }
- Hit( hDC, npObj );
-}
-
-//
-// HitPlayer - blow up the player
-//
-
-BOOL NEAR PASCAL HitPlayer( HDC hDC, NPOBJ npObj )
-{
- POINT Vel;
- INT nMass, nSpin;
-
- if (nSafe || (npPlayer->nCount <= 0)) return( FALSE );
-
- // rumble and shake both objects
- nMass = npPlayer->nMass + npObj->nMass;
-
- nSpin = npPlayer->nSpin + npObj->nSpin;
- npObj->nSpin -= MulDiv( nSpin, npPlayer->nMass, nMass );
- npPlayer->nSpin -= MulDiv( nSpin, npObj->nMass, nMass );
-
- Vel.x = npPlayer->Vel.x - npObj->Vel.x;
- Vel.y = npPlayer->Vel.y - npObj->Vel.y;
- npObj->Vel.x += MulDiv( Vel.x, npPlayer->nMass, nMass );
- npObj->Vel.y += MulDiv( Vel.y, npPlayer->nMass, nMass );
- npPlayer->Vel.x -= MulDiv( Vel.x, npObj->nMass, nMass );
- npPlayer->Vel.y -= MulDiv( Vel.y, npObj->nMass, nMass );
-
- if (--npPlayer->nCount)
- {
- npPlayer->byColor = (BYTE)(BLACK + npPlayer->nCount);
- if (npPlayer->byColor > WHITE) npPlayer->byColor = WHITE;
- Hit( hDC, npPlayer );
- return( TRUE );
- }
-
- // final death
- npPlayer->byColor = WHITE;
- Explode( hDC, npPlayer );
- SetRestart( RESTART_GAME );
- return( FALSE );
-}
-
-//
-// CreateLetter - make a new letter object
-//
-
-NPOBJ FAR PASCAL CreateLetter( CHAR cLetter, INT nSize )
-{
- NPOBJ npLtr;
- INT nCnt;
- NPSTR npDesc;
-
- if (cLetter >= '0' && cLetter <= '9') npDesc = szNumberDesc[cLetter - '0'];
- else if (cLetter >= 'A' && cLetter <= 'Z') npDesc = szLetterDesc[cLetter - 'A'];
- else if (cLetter >= 'a' && cLetter <= 'z') npDesc = szLetterDesc[cLetter - 'a'];
- else if (cLetter == '.') npDesc = "l";
- else return( NULL );
-
- if (npLtr = RemHeadObj( &FreeList ))
- {
- npLtr->nMass = 1;
- npLtr->nDir = 0;
- npLtr->nSpin = 0;
- npLtr->nCount = 40;
- npLtr->byColor = WHITE;
- npLtr->byPts = (BYTE)(nCnt = strlen( npDesc ));
- while (nCnt--)
- {
- npLtr->Pts[nCnt] = LetterPart[npDesc[nCnt] - 'a'];
- npLtr->Pts[nCnt].y = MulDiv( npLtr->Pts[nCnt].y, nSize, LETTER_MAX );
- }
- AddHeadObj( &LetterList, npLtr );
- }
- return( npLtr );
-}
-
-//
-// DrawLetters - draw letters and such
-//
-
-VOID NEAR PASCAL DrawLetters( HDC hDC )
-{
- NPOBJ npLtr, npNext;
-
- for (npLtr = HeadObj( &LetterList ); npLtr; npLtr = npNext)
- {
- npNext = NextObj( npLtr );
- switch (--npLtr->nCount)
- {
- case 3:
- --npLtr->byColor;
- break;
- case 0:
- RemoveObj( &LetterList, npLtr );
- AddHeadObj( &FreeList, npLtr );
- break;
- }
- DrawObject( hDC, npLtr );
- }
-}
-
-//
-// CreateBonus - make a new bonus object
-//
-
-VOID NEAR PASCAL CreateBonus( VOID )
-{
- NPOBJ npBonus;
- INT nCnt;
-
- if (npBonus = RemHeadObj( &FreeList ))
- {
- npBonus->Pos.x = arand( CLIP_COORD * 2 ) - CLIP_COORD;
- npBonus->Pos.y = -CLIP_COORD;
- npBonus->Vel.x = npBonus->Vel.y = 0;
- npBonus->nDir = arand( DEGREE_SIZE );
- npBonus->nSpin = (arand( 2 ) ? 12 : -12);
- npBonus->nCount = arand( 4 ) + 1;
- npBonus->nDelay = 64 + arand( 128 );
- npBonus->nMass = 1;
- npBonus->byColor = (BYTE)(WHITE + (npBonus->nCount * 2));
- npBonus->byPts = DIM(Bonus);
- for (nCnt = 0; nCnt < DIM(Bonus); ++nCnt)
- npBonus->Pts[nCnt] = Bonus[nCnt];
- ACCEL( npBonus, npBonus->nDir, 30 + nLevel * 2 );
- AddHeadObj( &BonusList, npBonus );
- }
-}
-
-//
-// DrawBonuses - process and draw the bonus list
-//
-
-VOID NEAR PASCAL DrawBonuses( HDC hDC )
-{
- NPOBJ npBonus, npNext;
- LOCAL INT nNextBonus = 1000;
-
- if (nBadGuys && (--nNextBonus < 0))
- {
- CreateBonus();
- nNextBonus = 1000;
- }
-
- for (npBonus = HeadObj( &BonusList ); npBonus; npBonus = npNext)
- {
- NPOBJ npShot;
- INT nDelta;
- RECT rect;
-
- npNext = NextObj( npBonus );
-
- MKRECT( &rect, npBonus->Pos, 150 );
-
- if (PTINRECT( &rect, npPlayer->Pos ))
- {
- if (npPlayer->nCount > 0) switch (npBonus->nCount)
- {
- case 1:
- {
- CHAR szBuff[32];
- LONG lBonus = 1000L * nLevel;
- if (lBonus == 0) lBonus = 500;
- lScore += lBonus;
- wsprintf( szBuff, "%ld", lBonus );
- PrintPlayerMessage( szBuff );
- }
- break;
- case 2:
- nSafe = 15;
- ++nShield;
- npPlayer->byColor = GREEN;
- PrintPlayerMessage( "EXTRA SHIELD" );
- break;
- case 3:
- ++nBomb;
- PrintPlayerMessage( "EXTRA BOMB" );
- break;
- case 4:
- AddExtraLife();
- break;
- }
- npBonus->nCount = 0;
- Explode( hDC, npBonus );
- RemoveObj( &BonusList, npBonus );
- AddHeadObj( &FreeList, npBonus );
- }
- else if (INTRECT(&rect, &rectShotClip))
- {
- for (npShot = HeadObj( &ShotList ); npShot; npShot = NextObj( npShot ))
- {
- if (!PTINRECT( &rect, npShot->Pos )) continue;
- npShot->nCount = 1;
- npBonus->nCount = 0;
- Explode( hDC, npBonus );
- RemoveObj( &BonusList, npBonus );
- AddHeadObj( &FreeList, npBonus );
- }
- }
- if (npBonus->nCount && --npBonus->nDelay <= 0)
- {
- --npBonus->nCount;
- npBonus->nDelay = 64 + arand( 128 );
- npBonus->byColor = (BYTE)(WHITE + (npBonus->nCount * 2));
- if (npBonus->nCount == 0)
- {
- Explode( hDC, npBonus );
- RemoveObj( &BonusList, npBonus );
- AddHeadObj( &FreeList, npBonus );
- }
- }
- nDelta = npPlayer->Pos.x - npBonus->Pos.x;
- while (nDelta < -16 || nDelta > 16) nDelta /= 2;
- npBonus->Vel.x += nDelta - npBonus->Vel.x / 16;
- nDelta = npPlayer->Pos.y - npBonus->Pos.y;
- while (nDelta < -16 || nDelta > 16) nDelta /= 2;
- npBonus->Vel.y += nDelta - npBonus->Vel.y / 16;
- DrawObject( hDC, npBonus );
- }
-}
-
-//
-// DrawHunterShots - process and draw the hunter shot list
-//
-
-VOID NEAR PASCAL DrawHunterShots( HDC hDC )
-{
- NPOBJ npShot, npNext;
-
- for (npShot = HeadObj( &HunterShotList ); npShot; npShot = npNext)
- {
- RECT rect;
-
- npNext = NextObj( npShot );
-
- MKRECT( &rect, npShot->Pos, 200 );
-
- if (PTINRECT( &rect, npPlayer->Pos ))
- {
- HitPlayer( hDC, npShot );
- npShot->nCount = 1;
- }
- switch (--npShot->nCount)
- {
- case 7:
- npShot->byColor = DKGREEN;
- break;
- case 0:
- RemoveObj( &HunterShotList, npShot );
- AddHeadObj( &FreeList, npShot );
- break;
- }
- DrawObject( hDC, npShot );
- }
-}
-
-//
-// FireHunterShot - fire a hunter bullet
-//
-
-VOID NEAR PASCAL FireHunterShot( NPOBJ npHunt )
-{
- NPOBJ npShot;
-
- if (npShot = RemHeadObj( &FreeList ))
- {
- npShot->Pos.x = npHunt->Pos.x;
- npShot->Pos.y = npHunt->Pos.y;
- npShot->Vel.x = npHunt->Vel.x;
- npShot->Vel.y = npHunt->Vel.y;
- npShot->nMass = 8;
- npShot->nDir = npHunt->nDir + arand( 5 ) - 2;
- npShot->nSpin = (arand( 2 ) ? 10 : -10);
- npShot->nCount = 16 + arand( 8 );
- npShot->byColor = GREEN;
- npShot->byPts = 2;
- npShot->Pts[0].x = 128;
- npShot->Pts[0].y = 50;
- npShot->Pts[1].x = 0;
- npShot->Pts[1].y = 50;
- ACCEL( npShot, npShot->nDir, 200 + npShot->nCount );
- AddHeadObj( &HunterShotList, npShot );
- }
-}
-
-//
-// CreateHunter - make a new hunter
-//
-
-VOID NEAR PASCAL CreateHunter( VOID )
-{
- NPOBJ npHunt;
- INT nCnt;
-
- if (npHunt = RemHeadObj( &FreeList ))
- {
- npHunt->Pos.x = arand( CLIP_COORD * 2 ) - CLIP_COORD;
- npHunt->Pos.y = -CLIP_COORD;
- npHunt->Vel.x = npHunt->Vel.y = 0;
- npHunt->nMass = 256;
- npHunt->nDir = arand( DEGREE_SIZE );
- npHunt->nSpin = 0;
- npHunt->nCount = 1 + arand( nLevel );
- npHunt->nDelay = 2 + arand( 10 );
- npHunt->byColor = CYAN;
- npHunt->byPts = DIM(Hunter);
- for (nCnt = 0; nCnt < DIM(Hunter); ++nCnt)
- npHunt->Pts[nCnt] = Hunter[nCnt];
- ACCEL( npHunt, npHunt->nDir, 30 + nLevel * 2 );
- AddHeadObj( &HunterList, npHunt );
- ++nBadGuys;
- }
-}
-
-//
-// DrawHunters - process and draw the hunter list
-//
-
-VOID NEAR PASCAL DrawHunters( HDC hDC )
-{
- NPOBJ npHunt, npNext;
- LOCAL INT nNextHunter = 200;
-
- if (nBadGuys && (--nNextHunter < 0))
- {
- CreateHunter();
- nNextHunter = 1000 + arand( 1000 ) - nLevel * 8;
- }
-
- for (npHunt = HeadObj( &HunterList ); npHunt; npHunt = npNext)
- {
- NPOBJ npShot;
- RECT rect;
-
- npNext = NextObj( npHunt );
-
- MKRECT( &rect, npHunt->Pos, 200 );
-
- if (PTINRECT( &rect, npPlayer->Pos ))
- {
- HitPlayer( hDC, npHunt );
- --npHunt->nCount;
- if (npHunt->nCount < 1)
- {
- KillBadGuy();
- npHunt->byColor = CYAN;
- Explode( hDC, npHunt );
- RemoveObj( &HunterList, npHunt );
- AddHeadObj( &FreeList, npHunt );
- }
- else if (npHunt->nCount == 1) npHunt->byColor = DKCYAN;
- }
- else if (INTRECT(&rect, &rectShotClip))
- {
- for (npShot = HeadObj( &ShotList ); npShot; npShot = NextObj( npShot ))
- {
- if (!PTINRECT( &rect, npShot->Pos )) continue;
- npShot->nCount = 1;
- lScore += npHunt->nCount * 1000;
- if (--npHunt->nCount < 1)
- {
- KillBadGuy();
- npHunt->byColor = CYAN;
- Explode( hDC, npHunt );
- RemoveObj( &HunterList, npHunt );
- AddHeadObj( &FreeList, npHunt );
- }
- else
- {
- if (npHunt->nCount == 1) npHunt->byColor = DKCYAN;
- Hit( hDC, npHunt );
- }
- break;
- }
- }
- ACCEL( npHunt, npHunt->nDir, 8 );
- npHunt->Vel.x -= npHunt->Vel.x / 16;
- npHunt->Vel.y -= npHunt->Vel.y / 16;
- if (--npHunt->nDelay <= 0)
- {
- npHunt->nDelay = arand( 10 );
- npHunt->nSpin = arand( 11 ) - 5;
- FireHunterShot( npHunt );
- }
- DrawObject( hDC, npHunt );
- }
-}
-
-//
-// CreateSwarmer - make a new swarmer
-//
-
-VOID NEAR PASCAL CreateSwarmer( POINT Pos, INT nDir, INT nCount )
-{
- NPOBJ npSwarm;
- INT nCnt;
-
- if (npSwarm = RemHeadObj( &FreeList ))
- {
- npSwarm->Pos = Pos;
- npSwarm->Vel.x = npSwarm->Vel.y = 0;
- npSwarm->nDir = nDir;
- npSwarm->nSpin = arand( 31 ) - 15;
- npSwarm->nCount = nCount;
- npSwarm->nDelay = 64 + arand( 64 );
- npSwarm->nMass = 32;
- npSwarm->byColor = DKGREEN;
- npSwarm->byPts = DIM(Swarmer);
- for (nCnt = 0; nCnt < DIM(Swarmer); ++nCnt)
- {
- npSwarm->Pts[nCnt] = Swarmer[nCnt];
- npSwarm->Pts[nCnt].y += nCount * 10;
- }
- ACCEL( npSwarm, npSwarm->nDir, 30 + nLevel * 2 );
- AddHeadObj( &SwarmerList, npSwarm );
- ++nBadGuys;
- }
-}
-
-//
-// DrawSwarmers - process and draw the swarmer list
-//
-
-VOID NEAR PASCAL DrawSwarmers( HDC hDC )
-{
- NPOBJ npSwarm, npNext;
- LOCAL INT nNextSwarmer = 1000;
-
- if (nBadGuys && (--nNextSwarmer < 0))
- {
- POINT Pos;
- Pos.x = arand( CLIP_COORD * 2 ) - CLIP_COORD;
- Pos.y = -CLIP_COORD;
- CreateSwarmer( Pos, arand( DEGREE_SIZE ), 8 + nLevel * 2 );
- nNextSwarmer = 1000 + arand( 500 ) - nLevel * 4;
- }
-
- for (npSwarm = HeadObj( &SwarmerList ); npSwarm; npSwarm = npNext)
- {
- NPOBJ npShot;
- RECT rect;
-
- npNext = NextObj( npSwarm );
-
- MKRECT( &rect, npSwarm->Pos, 150 + npSwarm->nCount * 10 );
-
- if (PTINRECT( &rect, npPlayer->Pos ))
- {
- HitPlayer( hDC, npSwarm );
- npSwarm->nCount = 0;
- }
- else if (INTRECT(&rect, &rectShotClip))
- {
- for (npShot = HeadObj( &ShotList ); npShot; npShot = NextObj( npShot ))
- {
- if (!PTINRECT( &rect, npShot->Pos )) continue;
- npShot->nCount = 1;
- lScore += npSwarm->nCount * 25;
- npSwarm->nCount = 0;
- break;
- }
- }
- if (npSwarm->nCount <= 0)
- {
- npSwarm->byColor = GREEN;
- KillBadGuy();
- Explode( hDC, npSwarm );
- RemoveObj( &SwarmerList, npSwarm );
- AddHeadObj( &FreeList, npSwarm );
- }
- else
- {
- if ((npSwarm->nCount > 1) && (--npSwarm->nDelay <= 0))
- {
- INT nDir = arand( DEGREE_SIZE );
- INT nCount = npSwarm->nCount / 2;
- CreateSwarmer( npSwarm->Pos, nDir, nCount );
- nCount = npSwarm->nCount - nCount;
- CreateSwarmer( npSwarm->Pos, nDir + 128, nCount );
- npSwarm->nCount = 0;
- }
- DrawObject( hDC, npSwarm );
- }
- }
-}
-
-//
-// CreateSpinner - make a new spinner
-//
-
-VOID NEAR PASCAL CreateSpinner( VOID )
-{
- NPOBJ npSpin;
- INT nCnt;
-
- if (npSpin = RemHeadObj( &FreeList ))
- {
- npSpin->Pos.x = arand( CLIP_COORD * 2 ) - CLIP_COORD;
- npSpin->Pos.y = -CLIP_COORD;
- npSpin->Vel.x = npSpin->Vel.y = 0;
- npSpin->nDir = arand( DEGREE_SIZE );
- npSpin->nSpin = -12;
- npSpin->nCount = 1 + arand( nLevel );
- npSpin->nMass = 64 + npSpin->nCount * 32;
- npSpin->byColor = (BYTE)(MAGENTA - npSpin->nCount);
- npSpin->byPts = DIM(Spinner);
- for (nCnt = 0; nCnt < DIM(Spinner); ++nCnt)
- npSpin->Pts[nCnt] = Spinner[nCnt];
- ACCEL( npSpin, npSpin->nDir, 30 + nLevel * 2 );
- AddHeadObj( &SpinnerList, npSpin );
- ++nBadGuys;
- }
-}
-
-//
-// DrawSpinners - process and draw the spinner list
-//
-
-VOID NEAR PASCAL DrawSpinners( HDC hDC )
-{
- NPOBJ npSpin, npNext;
- LOCAL INT nNextSpinner = 1000;
-
- if (nBadGuys && (--nNextSpinner < 0))
- {
- CreateSpinner();
- nNextSpinner = 100 + arand( 900 ) - nLevel * 2;
- }
-
- for (npSpin = HeadObj( &SpinnerList ); npSpin; npSpin = npNext)
- {
- NPOBJ npShot;
- INT nDelta;
- RECT rect;
-
- npNext = NextObj( npSpin );
-
- MKRECT( &rect, npSpin->Pos, 150 );
-
- if (PTINRECT( &rect, npPlayer->Pos ))
- {
- HitPlayer( hDC, npSpin );
- --npSpin->nCount;
- npSpin->byColor = (BYTE)(MAGENTA - npSpin->nCount);
- if (npSpin->nCount < 1)
- {
- KillBadGuy();
- Explode( hDC, npSpin );
- RemoveObj( &SpinnerList, npSpin );
- AddHeadObj( &FreeList, npSpin );
- }
- }
- else if (INTRECT(&rect, &rectShotClip))
- {
- for (npShot = HeadObj( &ShotList ); npShot; npShot = NextObj( npShot ))
- {
- if (!PTINRECT( &rect, npShot->Pos )) continue;
- npShot->nCount = 1;
- lScore += npSpin->nCount * 500;
- npSpin->byColor = (BYTE)(MAGENTA - (--npSpin->nCount));
- if (npSpin->nCount < 1)
- {
- KillBadGuy();
- Explode( hDC, npSpin );
- RemoveObj( &SpinnerList, npSpin );
- AddHeadObj( &FreeList, npSpin );
- }
- else Hit( hDC, npSpin );
- break;
- }
- }
- nDelta = npPlayer->Pos.x - npSpin->Pos.x;
- while (nDelta < -16 || nDelta > 16) nDelta /= 2;
- npSpin->Vel.x += nDelta - npSpin->Vel.x / 16;
- nDelta = npPlayer->Pos.y - npSpin->Pos.y;
- while (nDelta < -16 || nDelta > 16) nDelta /= 2;
- npSpin->Vel.y += nDelta - npSpin->Vel.y / 16;
- DrawObject( hDC, npSpin );
- }
-}
-
-//
-// CreateRoid - make a new asteroid
-//
-
-VOID NEAR PASCAL CreateRoid( POINT Pos, POINT Vel, INT nSides, BYTE byColor,
- INT nDir, INT nSpeed, INT nSpin )
-{
- NPOBJ npRoid;
- INT nCnt;
-
- if (npRoid = RemHeadObj( &FreeList ))
- {
- npRoid->Pos = Pos;
- npRoid->Vel = Vel;
- npRoid->nMass = nSides * 128;
- npRoid->nDir = nDir;
- npRoid->nSpin = nSpin + arand( 11 ) - 5;
- npRoid->nCount = nSides * 100;
- npRoid->byColor = byColor;
- npRoid->byPts = (BYTE)(nSides + 1);
- for (nCnt = 0; nCnt < nSides; ++nCnt)
- {
- npRoid->Pts[nCnt].x = nCnt * DEGREE_SIZE / nSides + arand( 30 );
- npRoid->Pts[nCnt].y = (nSides - 1) * 100 + 20 + arand( 80 );
- }
- npRoid->Pts[nSides] = npRoid->Pts[0];
- ACCEL( npRoid, nDir, nSpeed );
- AddHeadObj( &RoidList, npRoid );
- ++nBadGuys;
- }
-}
-
-//
-// BreakRoid - break up an asteroid
-//
-
-VOID NEAR PASCAL BreakRoid( HDC hDC, NPOBJ npRoid, NPOBJ npShot )
-{
- INT nCnt, nNew;
-
- lScore += npRoid->nCount;
- if (npShot) npShot->nCount = 1;
- switch (npRoid->byPts)
- {
- case 8:
- nNew = 2 + arand( 3 );
- break;
- case 7:
- nNew = 1 + arand( 3 );
- break;
- case 6:
- nNew = 1 + arand( 2 );
- break;
- case 5:
- nNew = arand( 2 );
- break;
- default:
- nNew = 0;
- break;
- }
- if (nNew == 1) // don't explode outward
- {
- POINT Pt = npRoid->Pos;
- Pt.x += arand( 301 ) - 150; Pt.y += arand( 301 ) - 150;
- CreateRoid( Pt, npRoid->Vel, npRoid->byPts - (nNew + 1),
- npRoid->byColor, npShot->nDir, 8, npRoid->nSpin );
- }
- else if (nNew > 0)
- {
- INT nSpeed = npRoid->nSpin * npRoid->nSpin * nNew + 16;
- for (nCnt = 0; nCnt < nNew; ++nCnt)
- {
- POINT Pt = npRoid->Pos;
- Pt.x += arand( 601 ) - 300; Pt.y += arand( 601 ) - 300;
- CreateRoid( Pt, npRoid->Vel, npRoid->byPts - (nNew + 1),
- npRoid->byColor,
- npRoid->nDir + nCnt * DEGREE_SIZE / nNew + arand( 32 ),
- nSpeed + arand( nLevel * 4 ),
- npRoid->nSpin / 2 );
- }
- }
- KillBadGuy();
- ++npRoid->byColor;
- npRoid->nCount = 0;
- if (nNew)
- {
- Hit( hDC, npRoid );
- DrawObject( hDC, npRoid );
- }
- else Explode( hDC, npRoid );
- RemoveObj( &RoidList, npRoid );
- AddHeadObj( &FreeList, npRoid );
-}
-
-//
-// DrawRoids - process and draw the asteroid list
-//
-
-VOID NEAR PASCAL DrawRoids( HDC hDC )
-{
- NPOBJ npRoid, npNext;
-
- for (npRoid = HeadObj( &RoidList ); npRoid; npRoid = npNext)
- {
- INT nSize = npRoid->nCount;
- NPOBJ npShot;
- RECT rect;
-
- npNext = NextObj( npRoid );
-
- DrawObject( hDC, npRoid );
-
- MKRECT( &rect, npRoid->Pos, nSize );
-
- if (PTINRECT( &rect, npPlayer->Pos ) && HitPlayer( hDC, npRoid ))
- {
- npPlayer->nCount = -npPlayer->nCount;
- npPlayer->byColor = WHITE;
- Explode( hDC, npPlayer );
- BreakRoid( hDC, npRoid, NULL );
- if (nBadGuys) SetRestart( RESTART_LEVEL );
- else SetRestart( RESTART_NEXTLEVEL );
- }
- else if (INTRECT(&rect, &rectShotClip))
- {
- for (npShot = HeadObj( &ShotList ); npShot; npShot = NextObj( npShot ))
- {
- if (!PTINRECT( &rect, npShot->Pos )) continue;
- BreakRoid( hDC, npRoid, npShot );
- break;
- }
- }
- }
-}
-
-//
-// DrawShots - process and draw the player shot list
-//
-
-VOID NEAR PASCAL DrawShots( HDC hDC )
-{
- NPOBJ npShot, npNext;
-
- if (npShot = HeadObj( &ShotList ))
- {
- rectShotClip.left = rectShotClip.right = npShot->Pos.x;
- rectShotClip.top = rectShotClip.bottom = npShot->Pos.y;
- while (npShot)
- {
- npNext = NextObj( npShot );
- switch (--npShot->nCount)
- {
- case 10:
- npShot->byColor = DKCYAN;
- break;
- case 5:
- npShot->byColor = DKBLUE;
- break;
- case 0:
- RemoveObj( &ShotList, npShot );
- AddHeadObj( &FreeList, npShot );
- break;
- }
- DrawObject( hDC, npShot );
- if (npShot->Pos.x < rectShotClip.left) rectShotClip.left = npShot->Pos.x;
- else if (npShot->Pos.x > rectShotClip.right) rectShotClip.right = npShot->Pos.x;
- if (npShot->Pos.y < rectShotClip.top) rectShotClip.top = npShot->Pos.y;
- else if (npShot->Pos.y > rectShotClip.bottom) rectShotClip.bottom = npShot->Pos.y;
- npShot = npNext;
- }
- }
- else rectShotClip.left = rectShotClip.right = rectShotClip.top = rectShotClip.bottom = 32767;
-}
-
-//
-// DrawFlames - process and draw the flame list
-//
-
-VOID NEAR PASCAL DrawFlames( HDC hDC )
-{
- NPOBJ npFlame, npNext;
-
- for (npFlame = HeadObj( &FlameList ); npFlame; npFlame = npNext)
- {
- npNext = NextObj( npFlame );
- switch (--npFlame->nCount)
- {
- case 7:
- npFlame->byColor = RED;
- break;
- case 3:
- npFlame->byColor = DKRED;
- break;
- case 0:
- RemoveObj( &FlameList, npFlame );
- AddHeadObj( &FreeList, npFlame );
- break;
- }
- DrawObject( hDC, npFlame );
- }
-}
-
-//
-// FireShot - fire a bullet
-//
-
-VOID NEAR PASCAL FireShot( VOID )
-{
- NPOBJ npShot;
-
- if (npShot = RemHeadObj( &FreeList ))
- {
- npShot->Pos.x = npPlayer->Pos.x;
- npShot->Pos.y = npPlayer->Pos.y;
- npShot->Vel.x = npPlayer->Vel.x;
- npShot->Vel.y = npPlayer->Vel.y;
- npShot->nMass = 8;
- npShot->nDir = npPlayer->nDir + arand( 5 ) - 2;
- npShot->nSpin = 0;
- npShot->nCount = 16 + arand( 8 );
- npShot->byColor = CYAN;
- npShot->byPts = 2;
- npShot->Pts[0].x = 128;
- npShot->Pts[0].y = 50;
- npShot->Pts[1].x = 0;
- npShot->Pts[1].y = 50;
- ACCEL( npShot, npShot->nDir, 200 + npShot->nCount );
- AddHeadObj( &ShotList, npShot );
- }
-}
-
-//
-// AccelPlayer - move the player forward
-//
-
-VOID NEAR PASCAL AccelPlayer( INT nDir, INT nAccel )
-{
- NPOBJ npFlame;
-
- nDir += npPlayer->nDir;
- if (nAccel) ACCEL( npPlayer, nDir, nAccel );
- if (npFlame = RemHeadObj( &FreeList ))
- {
- npFlame->Pos.x = npPlayer->Pos.x;
- npFlame->Pos.y = npPlayer->Pos.y;
- npFlame->Vel.x = npPlayer->Vel.x;
- npFlame->Vel.y = npPlayer->Vel.y;
- npFlame->nDir = nDir + 100 + arand( 57 );
- npFlame->nSpin = 0;
- npFlame->nCount = nAccel + arand( 7 );
- npFlame->byColor = YELLOW;
- npFlame->byPts = 1;
- npFlame->Pts[0].x = npFlame->Pts[0].y = 0;
- ACCEL( npFlame, npFlame->nDir, 50 + arand( 10 ) );
- AddHeadObj( &FlameList, npFlame );
- }
-}
-
-//
-// DrawPlayer - process and draw the player
-//
-
-VOID NEAR PASCAL DrawPlayer( HDC hDC )
-{
- LOCAL INT nBombing = 0;
- LOCAL INT nShotDelay = 0;
-
- if (npPlayer->nCount <= 0) return;
-
- if (nSafe > 0)
- {
- if (--nSafe == 0)
- {
- npPlayer->byColor = (BYTE)(BLACK + npPlayer->nCount);
- if (npPlayer->byColor > WHITE) npPlayer->byColor = WHITE;
- }
- }
- else if (IsKeyDown( vkShld ) && nShield > 0)
- {
- nSafe = 15;
- if (--nShield > 0) npPlayer->byColor = GREEN;
- else npPlayer->byColor = DKGREEN;
- }
-
- if (nBombing > 0)
- {
- if (--nBombing == 0)
- {
- ExplodeBadguys( hDC, &SpinnerList );
- ExplodeBadguys( hDC, &SwarmerList );
- ExplodeBadguys( hDC, &HunterList );
- }
- else
- {
- HitList( hDC, &SpinnerList );
- HitList( hDC, &SwarmerList );
- HitList( hDC, &HunterList );
- }
- }
- else if (nBomb && IsKeyDown( vkBomb )) --nBomb, nBombing = 5;
-
- if (IsKeyDown( vkClkw )) npPlayer->nSpin += 8;
- if (IsKeyDown( vkCtrClkw )) npPlayer->nSpin -= 8;
- if (IsKeyDown( vkThrst )) AccelPlayer( 0, 12 );
- if (IsKeyDown( vkRvThrst )) AccelPlayer( 128, 12 );
- if (nShotDelay) --nShotDelay;
- else if (IsKeyDown( vkFire )) FireShot(), nShotDelay = 2;
- DrawObject( hDC, npPlayer );
- npPlayer->nSpin /= 2;
-}
-
-//
-// GetHyperoidDC - get the correct DC for hyperoid rendering
-//
-
-HDC NEAR PASCAL GetHyperoidDC( HWND hWnd )
-{
- HDC hDC;
- INT cx, cy;
- RECT rect;
-
- GetClientRect( hWnd, &rect );
- cx = rect.right - rect.left;
- cy = rect.bottom - rect.top;
-
- hDC = GetDC( hWnd );
-
- // set up the mapping mode
- SetMapMode( hDC, MM_ISOTROPIC );
- SetWindowExt( hDC, MAX_COORD, MAX_COORD );
- SetViewportExt( hDC, cx / 2, -cy / 2 );
- SetViewportOrg( hDC, cx / 2, cy / 2 );
-
- // realize the palette
- SelectPalette( hDC, hAppPalette, 0 );
- RealizePalette( hDC );
-
- return( hDC );
-}
-
-//
-// DrawObjects - transform and redraw everything in the system
-//
-
-VOID NEAR PASCAL DrawObjects( HWND hWnd )
-{
- HDC hDC = GetHyperoidDC( hWnd );
-
- // move and draw things (I don't think the order is important...)
- DrawPlayer( hDC );
- DrawFlames( hDC );
- DrawShots( hDC );
- DrawRoids( hDC );
- DrawSpinners( hDC );
- DrawSwarmers( hDC );
- DrawHunters( hDC );
- DrawHunterShots( hDC );
- DrawLetters( hDC );
- DrawBonuses( hDC );
- // (...but I'm not changing it!!! :-)
-
- ReleaseDC( hWnd, hDC );
-}
-
-//
-// SetIndicator - set a quantity indicator
-//
-
-INT NEAR PASCAL SetIndicator( NPSTR npBuff, CHAR IDBitmap, INT nQuant )
-{
- if (nQuant > 5)
- {
- *npBuff++ = IDBitmap; *npBuff++ = IDBitmap;
- *npBuff++ = IDBitmap; *npBuff++ = IDBitmap;
- *npBuff++ = IDB_plus;
- }
- else
- {
- INT nBlank = 5 - nQuant;
- while (nQuant--) *npBuff++ = IDBitmap;
- while (nBlank--) *npBuff++ = IDB_blank;
- }
- return( 5 );
-}
-
-//
-// CheckScore - show the score and such stuff
-//
-
-VOID NEAR PASCAL CheckScore( HWND hWnd )
-{
- CHAR szBuff[sizeof(szScore)];
- NPSTR npBuff = szBuff;
- INT nLives, nLen, nCnt, x, y;
- HBITMAP hbmOld;
- HDC hDC, hDCMem;
-
- if (IsIconic( hWnd )) return;
- if (lScore - lLastLife > EXTRA_LIFE)
- {
- AddExtraLife();
- lLastLife = lScore;
- }
- nLives = ((npPlayer->nCount > 0) ? npPlayer->nCount : -npPlayer->nCount);
-
- *npBuff++ = IDB_level;
- wsprintf( npBuff, "%2.2u", nLevel );
- while (isdigit( *npBuff ))
- *npBuff = (CHAR)(*npBuff + IDB_num0 - '0'), ++npBuff;
- *npBuff++ = IDB_blank; *npBuff++ = IDB_score;
- wsprintf( npBuff, "%7.7lu", lScore );
- while (isdigit( *npBuff ))
- *npBuff = (CHAR)(*npBuff + IDB_num0 - '0'), ++npBuff;
- *npBuff++ = IDB_blank;
- npBuff += SetIndicator( npBuff, IDB_life, nLives );
- npBuff += SetIndicator( npBuff, IDB_shield, nShield );
- npBuff += SetIndicator( npBuff, IDB_bomb, nBomb );
- nLen = npBuff - szBuff;
-
- hDC = GetWindowDC( hWnd );
- IntersectClipRect( hDC, rectScoreClip.left, rectScoreClip.top,
- rectScoreClip.right, rectScoreClip.bottom );
- hDCMem = CreateCompatibleDC( hDC );
- hbmOld = SelectObject( hDCMem, hBitmap[0] );
- x = rectScoreClip.left;
- y = rectScoreClip.top;
-
- for (nCnt = 0; nCnt < nLen; ++nCnt)
- {
- if (szBuff[nCnt] != szScore[nCnt])
- {
- SelectObject( hDCMem, hBitmap[szBuff[nCnt] - IDB_blank] );
- BitBlt( hDC, x, y, CX_BITMAP, CY_BITMAP, hDCMem, 0, 0, SRCCOPY );
- szScore[nCnt] = szBuff[nCnt];
- }
- x += CX_BITMAP;
- }
- if (nCnt < nScoreLen)
- {
- SelectObject( hDCMem, hBitmap[0] );
- do {
- if (szScore[nCnt] != IDB_blank)
- {
- BitBlt( hDC, x, y, CX_BITMAP, CY_BITMAP, hDCMem, 0, 0, SRCCOPY );
- szScore[nCnt] = IDB_blank;
- }
- x += CX_BITMAP;
- } while (++nCnt < nScoreLen);
- }
- nScoreLen = nLen;
-
- SelectObject( hDCMem, hbmOld );
- DeleteDC( hDCMem );
- ReleaseDC( hWnd, hDC );
-}
-
-//
-// HitList - Hit() a list of things
-//
-
-VOID NEAR PASCAL HitList( HDC hDC, NPLIST npList )
-{
- NPOBJ npObj;
-
- for (npObj = HeadObj( npList ); npObj; npObj = NextObj( npObj ))
- if (npObj->nCount) Hit( hDC, npObj );
-}
-
-//
-// ExplodeBadguys - explode a list of badguys
-//
-
-VOID NEAR PASCAL ExplodeBadguys( HDC hDC, NPLIST npList )
-{
- NPOBJ npObj;
-
- while (npObj = HeadObj( npList ))
- {
- KillBadGuy();
- npObj->nCount = 0;
- Explode( hDC, npObj );
- RemoveObj( npList, npObj );
- AddHeadObj( &FreeList, npObj );
- }
-}
-
-//
-// NewGame - start a new game
-//
-
-VOID NEAR PASCAL NewGame( HWND hWnd )
-{
- HDC hDC = GetHyperoidDC( hWnd );
-
- npPlayer->nCount = 0;
- npPlayer->byColor = WHITE;
- Explode( hDC, npPlayer );
- SetRestart( RESTART_GAME );
- ExplodeBadguys( hDC, &RoidList );
- ExplodeBadguys( hDC, &SpinnerList );
- ExplodeBadguys( hDC, &SwarmerList );
- ExplodeBadguys( hDC, &HunterList );
-
- ReleaseDC( hWnd, hDC );
-}
-
-//
-// RestartHyperoid - set up a game!
-//
-
-VOID NEAR PASCAL RestartHyperoid( VOID )
-{
- if (npPlayer->nCount == 0)
- {
- POINT Pos, Vel;
- Pos.x = 0;
- Pos.y = -CLIP_COORD / 2;
- Vel.x = 0;
- Vel.y = 150;
- PrintLetters( szAppName, Pos, Vel, YELLOW, 800 );
- npPlayer->nCount = 3;
- if (lHighScore < lScore) lHighScore = lScore;
- lLastLife = lScore = 0;
- nLevel = 0;
- nShield = nBomb = 3;
- }
- else if (npPlayer->nCount < 0)
- {
- // cheesy way of restarting after a major collision
- npPlayer->nCount = -npPlayer->nCount;
- nShield = nBomb = 3;
- }
-
- npPlayer->Pos.x = npPlayer->Pos.y = 0;
- npPlayer->Vel.x = npPlayer->Vel.y = 0;
- npPlayer->nDir = 64;
- npPlayer->nSpin = 0;
- npPlayer->byColor = GREEN;
- nSafe = 30;
-
- if (ShotList.npHead)
- {
- NPOBJ npShot;
- for (npShot = HeadObj( &ShotList ); npShot; npShot = NextObj( npShot ))
- npShot->nCount = 1;
- }
-
- // reseed the asteroid field
- if (nBadGuys == 0)
- {
- INT nCnt;
- ++nLevel;
- for (nCnt = 5 + nLevel; nCnt; --nCnt)
- {
- POINT Pos, Vel;
- Pos.x = arand( MAX_COORD * 2 ) - MAX_COORD;
- Pos.y = arand( MAX_COORD * 2 ) - MAX_COORD;
- Vel.x = Vel.y = 0;
- CreateRoid( Pos, Vel, 6 + arand( 2 ),
- (BYTE)(arand( 2 ) ? DKYELLOW : DKGREY),
- arand( DEGREE_MAX ), 30 + arand( nLevel * 8 ), 0 );
- }
- }
-}
-
-//
-// Panic - boss key (or just pause)
-//
-
-VOID NEAR PASCAL Panic( BOOL bPanic )
-{
- if (bPanic && !bPaused)
- {
- bPaused = TRUE;
- KillTimer( hAppWnd, DRAW_TIMER );
- SetWindowText( hAppWnd, "Program Manager Help - PROGMAN.HLP" );
- ShowWindow( hAppWnd, SW_SHOWMINNOACTIVE );
- InvalidateRect( hAppWnd, NULL, TRUE );
- }
- else if (bPaused) // double-panic == normal
- {
- bPaused = FALSE;
- SetWindowText( hAppWnd, szAppName );
- if (bPanic) ShowWindow( hAppWnd, SW_RESTORE );
- SetTimer( hAppWnd, DRAW_TIMER, nDrawDelay, NULL );
- }
-}
-
-//
-// PaintHyperoid - paint the hyperoid window
-//
-
-VOID NEAR PASCAL PaintHyperoid( HWND hWnd )
-{
- PAINTSTRUCT ps;
-
- BeginPaint( hWnd, &ps );
- if (bPaused) DrawIcon( ps.hdc, 2, 2, LoadIcon( hAppInst, INTRES(IDI_PANIC) ) );
- EndPaint( hWnd, &ps );
-}
-
-//
-// EraseHyperoidBkgnd - fill in the background
-//
-
-BOOL NEAR PASCAL EraseHyperoidBkgnd( HWND hWnd, HDC hDC )
-{
- HBRUSH hbr;
- RECT rect;
-
- GetClientRect( hWnd, &rect );
-
- if (bPaused)
- {
- SetBrushOrg( hDC, 0, 0 );
- hbr = CreateSolidBrush( GetSysColor( COLOR_BACKGROUND ) );
- }
- else
- {
- SelectPalette( hDC, hAppPalette, 0 );
- RealizePalette( hDC );
- hbr = CreateSolidBrush( PALETTEINDEX( BLACK ) );
- }
-
- FillRect( hDC, &rect, hbr );
- DeleteObject( hbr );
- return( TRUE );
-}
-
-//
-// DrawShadowRect - draw a shaded rectangle around an object
-//
-
-VOID NEAR PASCAL DrawShadowRect( HDC hDC, NPRECT npRect, HPEN hHi, HPEN hLo )
-{
- SelectObject( hDC, hHi );
- MoveTo( hDC, npRect->right, npRect->top );
- LineTo( hDC, npRect->left, npRect->top );
- LineTo( hDC, npRect->left, npRect->bottom );
- SelectObject( hDC, hLo );
- LineTo( hDC, npRect->right, npRect->bottom );
- LineTo( hDC, npRect->right, npRect->top );
-}
-
-//
-// NCPaintHyperoid - paint a custom frame
-//
-
-VOID NEAR PASCAL NCPaintHyperoid( HWND hWnd )
-{
- HDC hDC, hDCMem;
- INT cx, cy, cyCap, h;
- HPEN hpenHi, hpenLo;
- HBRUSH hbr;
- HBITMAP hbm, hbmOld;
- BITMAP bm;
- RECT rect;
-
- if (IsIconic( hWnd )) return;
- hDC = GetWindowDC( hWnd );
- GetWindowRect( hWnd, &rect );
- rect.right -= rect.left, rect.left = 0;
- rect.bottom -= rect.top, rect.top = 0;
- cx = GetSystemMetrics( SM_CXFRAME );
- cy = GetSystemMetrics( SM_CYFRAME );
- cyCap = cy + GetSystemMetrics( SM_CYCAPTION ) - 1;
- h = rect.bottom - (cyCap + cy);
-
- SelectPalette( hDC, hAppPalette, 0 );
- RealizePalette( hDC );
- if (bBW)
- {
- hbr = SelectObject( hDC, CreateSolidBrush( PALETTEINDEX( WHITE ) ) );
- hpenHi = hPen[BLACK];
- hpenLo = hPen[BLACK];
- }
- else
- {
- hbr = SelectObject( hDC, CreateSolidBrush( PALETTEINDEX( GREY ) ) );
- hpenHi = hPen[WHITE];
- hpenLo = hPen[DKGREY];
- }
-
- PatBlt( hDC, 0, 0, rect.right, cyCap, PATCOPY );
- PatBlt( hDC, 0, rect.bottom - cy, rect.right, rect.bottom, PATCOPY );
- PatBlt( hDC, 0, cyCap, cx, h, PATCOPY );
- PatBlt( hDC, rect.right - cx, cyCap, cx, h, PATCOPY );
-
- --rect.bottom; --rect.right;
- DrawShadowRect( hDC, &rect, hpenHi, hpenLo );
- --cx; --cy;
- rect.left += cx; rect.top += cy;
- rect.right -= cx; rect.bottom -= cy;
- if (!bBW) DrawShadowRect( hDC, &rect, hpenLo, hpenHi );
-
- // get the title bar rect
- ++rect.left; ++rect.top; --rect.right;
- rect.bottom = rect.top + cyCap - (cy + 2);
- DrawShadowRect( hDC, &rect, hpenHi, hpenLo );
- ++rect.right; // for zoom/restore bitmap
-
- hDCMem = CreateCompatibleDC( hDC );
-
- hbm = LoadBitmap( NULL, INTRES(OBM_CLOSE) );
- GetObject( hbm, sizeof(bm), (LPSTR)&bm );
- bm.bmWidth /= 2; // they packed two images in here!
- hbmOld = SelectObject( hDCMem, hbm );
- BitBlt( hDC, rect.left, rect.top, bm.bmWidth, bm.bmHeight, hDCMem, 0, 0, SRCCOPY );
- rect.left += bm.bmWidth;
-
- if (IsZoomed( hWnd )) hbm = LoadBitmap( NULL, INTRES(OBM_RESTORE) );
- else hbm = LoadBitmap( NULL, INTRES(OBM_ZOOM) );
- GetObject( hbm, sizeof(bm), (LPSTR)&bm );
- SelectObject( hDCMem, hbm );
- rect.right -= bm.bmWidth;
- BitBlt( hDC, rect.right, rect.top, bm.bmWidth, bm.bmHeight, hDCMem, 0, 0, SRCCOPY );
-
- hbm = LoadBitmap( NULL, INTRES(OBM_REDUCE) );
- GetObject( hbm, sizeof(bm), (LPSTR)&bm );
- SelectObject( hDCMem, hbm );
- rect.right -= bm.bmWidth;
- BitBlt( hDC, rect.right, rect.top, bm.bmWidth, bm.bmHeight, hDCMem, 0, 0, SRCCOPY );
-
- --rect.right;
- DrawShadowRect( hDC, &rect, hpenHi, hpenLo );
-
- // clip the score to the free titlebar area
- ++rect.left; ++rect.top;
- rectScoreClip = rect;
-
- DeleteObject( SelectObject( hDCMem, hbmOld ) );
- DeleteObject( SelectObject( hDC, hbr ) );
- DeleteDC( hDCMem );
- ReleaseDC( hWnd, hDC );
-
- // make sure the score gets redrawn
- for (cx = 0; cx < nScoreLen; ++cx) szScore[cx] = '\0';
-}
-
-//
-// HyperoidWndProc - the main window proc for Hyperoid
-//
-
-LONG FAR PASCAL EXPORT HyperoidWndProc( HWND hWnd, unsigned message,
- WORD wParam, LONG lParam )
-{
- switch (message)
- {
- case WM_CREATE:
- RestartHyperoid();
- SetTimer( hWnd, DRAW_TIMER, nDrawDelay, NULL );
- NCPaintHyperoid( hWnd );
- break;
-
- case WM_TIMER:
- switch (wParam)
- {
- case DRAW_TIMER:
- CheckScore( hWnd );
- DrawObjects( hWnd );
- return( 0 );
-
- case RESTART_TIMER:
- KillTimer( hWnd, RESTART_TIMER );
- bRestart = FALSE;
- RestartHyperoid();
- return( 0 );
- }
- break;
-
- case WM_SYSCOMMAND:
- switch (wParam)
- {
- case IDM_NEW:
- NewGame( hWnd );
- break;
-
- case IDM_ABOUT:
- AboutHyperoid( hWnd );
- break;
-
- default:
- return( DefWindowProc( hWnd, message, wParam, lParam ) );
- }
- break;
-
- case WM_QUERYOPEN:
- Panic( FALSE );
- return( DefWindowProc( hWnd, message, wParam, lParam ) );
-
- case WM_CHAR:
- if (wParam == VK_ESCAPE) Panic( TRUE );
- break;
-
- case WM_SYSKEYDOWN:
- case WM_SYSKEYUP:
- case WM_SYSCHAR:
- if (lParam & (1L<<29)) // alt key is down
- {
- return( DefWindowProc( hWnd, message, wParam, lParam ) );
- }
- switch (wParam)
- {
- case VK_ESCAPE:
- if (message == WM_SYSKEYDOWN) Panic( TRUE );
- return( 0 );
- case VK_SPACE:
- case VK_TAB:
- return( 0 );
- default:
- return( DefWindowProc( hWnd, message, wParam, lParam ) );
- }
- break;
-
- case WM_ERASEBKGND:
- return( EraseHyperoidBkgnd( hWnd, (HDC)wParam ) );
-
- case WM_NCACTIVATE:
- case WM_NCPAINT:
- NCPaintHyperoid( hWnd );
- return( TRUE );
-
- case WM_PAINT:
- PaintHyperoid( hWnd );
- break;
-
- case WM_QUERYNEWPALETTE:
- {
- HDC hDC = GetDC( hWnd );
- SelectPalette( hDC, hAppPalette, 0 );
- RealizePalette( hDC );
- ReleaseDC( hWnd, hDC );
- }
- return( TRUE );
-
- case WM_DESTROY:
- KillTimer( hWnd, DRAW_TIMER );
- KillTimer( hWnd, RESTART_TIMER );
- SaveHyperoidWindowPos( hWnd );
- PostQuitMessage( 0 );
- break;
-
- default:
- return( DefWindowProc( hWnd, message, wParam, lParam ) );
- }
- return( 0 );
-}
-
-//
-// InitHyperoid - initialize everything
-//
-
-BOOL NEAR PASCAL InitHyperoid( VOID )
-{
- DOUBLE dRad;
- INT nCnt;
-
- // allocate the logical palette
- hAppPalette = CreateHyperoidPalette();
- if (!hAppPalette) return( FALSE );
- for (nCnt = 0; nCnt < PALETTE_SIZE; ++nCnt)
- {
- hPen[nCnt] = CreatePen( PS_SOLID, 1, PALETTEINDEX( nCnt ) );
- if (!hPen[nCnt]) return( FALSE );
- }
- for (nCnt = 0; nCnt < IDB_MAX; ++nCnt)
- {
- hBitmap[nCnt] = LoadBitmap( hAppInst, INTRES(IDB_blank + nCnt) );
- if (!hPen[nCnt]) return( FALSE );
- }
-
- // seed the randomizer
- dwSeed = GetCurrentTime();
-
- // create the lookup table (should use resources)
- for (nCnt = 0; nCnt < DEGREE_SIZE; ++nCnt)
- {
- dRad = nCnt * 6.2831855 / DEGREE_SIZE;
- nCos[nCnt] = (INT)(DEGREE_MAX * cos( dRad ));
- nSin[nCnt] = (INT)(DEGREE_MAX * sin( dRad ));
- }
-
- // get the initialization file info
- GetHyperoidIni();
-
- // allocate all objects as free
- for (nCnt = 0; nCnt < MAX_OBJS; ++nCnt)
- AddHeadObj( &FreeList, &(Obj[nCnt]) );
-
- // set up the player
- npPlayer = RemHeadObj( &FreeList );
- npPlayer->byPts = DIM(Player);
- npPlayer->nMass = 256;
- for (nCnt = 0; nCnt < DIM(Player); ++nCnt)
- npPlayer->Pts[nCnt] = Player[nCnt];
-
- return( TRUE );
-}
-
-//
-// ExitHyperoid - quit the damn game already!
-//
-
-VOID NEAR PASCAL ExitHyperoid( VOID )
-{
- INT nCnt;
-
- if (hAppPalette) DeleteObject( hAppPalette );
- for (nCnt = 0; nCnt < PALETTE_SIZE; ++nCnt)
- if (hPen[nCnt]) DeleteObject( hPen[nCnt] );
- for (nCnt = 0; nCnt < IDB_MAX; ++nCnt)
- if (hBitmap[nCnt]) DeleteObject( hBitmap[nCnt] );
-}
-
-//
-// WinMain - everybody has to have one
-//
-
-INT FAR PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance,
- LPSTR lpszCmdLine, INT nCmdShow )
-{
- MSG msg;
-
- hAppInst = hInstance;
- if (!hPrevInstance)
- {
- // create the class if we're first
- if (!CreateHyperoidClass()) return( FALSE );
- }
- else
- {
- // Copy data from previous instance
- GetInstanceData( hPrevInstance, (PSTR)szAppName, sizeof(szAppName) );
- }
- if (!InitHyperoid()) goto Abort; // I LOVE GOTOS! REALLY I DO!
- hAppWnd = CreateHyperoidWindow( lpszCmdLine, nCmdShow );
- if (!hAppWnd) return( FALSE );
-
- while (GetMessage( &msg, NULL, 0, 0 ))
- {
- TranslateMessage( &msg );
- DispatchMessage( &msg );
- }
-
-Abort:
- ExitHyperoid();
- return( msg.wParam );
-}
diff --git a/test/hyperoid/hyperoid.def b/test/hyperoid/hyperoid.def
deleted file mode 100644
index 3309007..0000000
--- a/test/hyperoid/hyperoid.def
+++ /dev/null
@@ -1,15 +0,0 @@
-NAME Hyperoid
-DESCRIPTION 'Hyperoid Copyright (C) 1990,91 Hutchins Software'
-EXETYPE WINDOWS
-STUB 'WINSTUB.EXE'
-STACKSIZE 4096
-HEAPSIZE 32768
-DATA MOVEABLE MULTIPLE
-CODE LOADONCALL MOVEABLE DISCARDABLE
-SEGMENTS
- HYPEROID LOADONCALL MOVEABLE DISCARDABLE
- ROIDSUPP LOADONCALL MOVEABLE DISCARDABLE
-
-EXPORTS
- HyperoidWndProc @1
- HyperoidAboutDlg @2
diff --git a/test/hyperoid/hyperoid.exe b/test/hyperoid/hyperoid.exe
deleted file mode 100644
index 0f34f62..0000000
--- a/test/hyperoid/hyperoid.exe
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/hyperoid.h b/test/hyperoid/hyperoid.h
deleted file mode 100644
index e16b057..0000000
--- a/test/hyperoid/hyperoid.h
+++ /dev/null
@@ -1,241 +0,0 @@
-//
-// HYPEROID.H - hyperoid internal header information
-//
-// Version: 1.1 Copyright (C) 1990,91 Hutchins Software
-// This software is licenced under the GNU General Public Licence
-// Please read the associated legal documentation
-// Author: Edward Hutchins
-// Revisions:
-//
-
-#ifndef RC_INVOKED
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <math.h>
-#include <limits.h>
-#define OEMRESOURCE
-#include <winext.h>
-
-//
-// typedefs and defines
-//
-
-// color stuff
-#define PALETTE_SIZE 16
-typedef enum
-{
- BLACK, DKGREY, GREY, WHITE,
- DKRED, RED, DKGREEN, GREEN, DKBLUE, BLUE,
- DKYELLOW, YELLOW, DKCYAN, CYAN, DKMAGENTA, MAGENTA
-} COLORS;
-
-// degrees scaled to integer math
-#define DEGREE_SIZE 256
-#define DEGREE_MASK 255
-#define DEGREE_MAX 0x4000
-
-// object limits
-#define MAX_PTS 8
-#define MAX_OBJS 100
-#define MAX_COORD 0x2000
-#define CLIP_COORD (MAX_COORD+300)
-
-// timer stuff
-#define DRAW_TIMER 1
-#define DRAW_DELAY 50
-#define RESTART_TIMER 2
-#define RESTART_DELAY 5000
-
-// restart modes
-typedef enum { RESTART_GAME, RESTART_LEVEL, RESTART_NEXTLEVEL } RESTART_MODE;
-
-// letter scaling
-#define LETTER_MAX 256
-
-// extra life every
-#define EXTRA_LIFE 100000
-
-// list node
-typedef struct tagNODE
-{
- struct tagNODE *npNext, *npPrev;
-} NODE;
-pointerdef( NODE );
-
-// list header
-typedef struct
-{
- NPNODE npHead, npTail;
-} LIST;
-pointerdef( LIST );
-
-// object descriptor
-typedef struct
-{
- NODE Link; // for object list
- POINT Pos; // position of center of object
- POINT Vel; // velocity in logical units/update
- INT nMass; // mass of object
- INT nDir; // direction in degrees
- INT nSpin; // angular momentum degrees/update
- INT nCount; // used by different objects
- INT nDelay; // used by different objects
- BYTE byColor; // palette color
- BYTE byPts; // number of points in object
- POINT Pts[MAX_PTS]; // points making up an object
- POINT Old[MAX_PTS]; // last plotted location
-} OBJ;
-pointerdef( OBJ );
-
-//
-// inline macro functions
-//
-
-// function aliases
-#define AddHeadObj(l,o) AddHead((l),((NPNODE)o))
-#define RemHeadObj(l) ((NPOBJ)RemHead(l))
-#define RemoveObj(l,o) Remove((l),((NPNODE)o))
-#define HeadObj(l) ((NPOBJ)((l)->npHead))
-#define NextObj(o) ((NPOBJ)((o)->Link.npNext))
-
-// real-time check of the keyboard
-#define IsKeyDown(x) (GetAsyncKeyState(x)<0)
-
-// I HATE typing this allatime!
-#define INTRES(x) MAKEINTRESOURCE(x)
-
-// size of an array
-#define DIM(x) (sizeof(x)/sizeof((x)[0]))
-
-// faster than MulDiv!
-#define MULDEG(x,y) ((INT)(((LONG)(x)*(y))/DEGREE_MAX))
-
-// DEG - convert an integer into a degree lookup index
-#define DEG(x) ((WORD)(x)&DEGREE_MASK)
-
-// ACCEL - accelerate an object in a given direction
-#define ACCEL(o,d,s) \
-(((o)->Vel.x += MULDEG((s),nCos[DEG(d)])), \
-((o)->Vel.y += MULDEG((s),nSin[DEG(d)])))
-
-// PTINRECT - a faster PtInRect
-#define PTINRECT(r,p) \
-(((r)->left <= (p).x) && ((r)->right > (p).x) && \
-((r)->top <= (p).y) && ((r)->bottom > (p).y))
-
-// INTRECT - a faster IntersectRect that just returns the condition
-#define INTRECT(r1,r2) \
-(((r1)->right >= (r2)->left) && \
-((r1)->left < (r2)->right) && \
-((r1)->bottom >= (r2)->top) && \
-((r1)->top < (r2)->bottom))
-
-// MKRECT - make a rect around a point
-#define MKRECT(r,p,s) \
-(((r)->left = ((p).x-(s))), ((r)->right = ((p).x+(s))), \
-((r)->top = ((p).y-(s))), ((r)->bottom = ((p).y+(s))))
-
-//
-// prototypes
-//
-
-// hyperoid.c
-INT NEAR PASCAL arand( INT x );
-VOID NEAR PASCAL AddHead( NPLIST npList, NPNODE npNode );
-NPNODE NEAR PASCAL RemHead( NPLIST npList );
-VOID NEAR PASCAL Remove( NPLIST npList, NPNODE npNode );
-VOID NEAR PASCAL DrawObject( HDC hDC, NPOBJ npObj );
-VOID NEAR PASCAL SetRestart( BOOL bGameOver );
-VOID NEAR PASCAL AddExtraLife( VOID );
-VOID NEAR PASCAL Hit( HDC hDC, NPOBJ npObj );
-VOID NEAR PASCAL Explode( HDC hDC, NPOBJ npObj );
-BOOL NEAR PASCAL HitPlayer( HDC hDC, NPOBJ npObj );
-NPOBJ FAR PASCAL CreateLetter( CHAR cLetter, INT nSize );
-VOID NEAR PASCAL DrawLetters( HDC hDC );
-VOID NEAR PASCAL DrawHunterShots( HDC hDC );
-VOID NEAR PASCAL FireHunterShot( NPOBJ npHunt );
-VOID NEAR PASCAL CreateHunter( VOID );
-VOID NEAR PASCAL DrawHunters( HDC hDC );
-VOID NEAR PASCAL CreateSpinner( VOID );
-VOID NEAR PASCAL DrawSpinners( HDC hDC );
-VOID NEAR PASCAL CreateRoid( POINT Pos, POINT Vel, INT nSides, BYTE byColor, INT nDir, INT nSpeed, INT nSpin );
-VOID NEAR PASCAL BreakRoid( HDC hDC, NPOBJ npRoid, NPOBJ npShot );
-VOID NEAR PASCAL DrawRoids( HDC hDC );
-VOID NEAR PASCAL DrawShots( HDC hDC );
-VOID NEAR PASCAL DrawFlames( HDC hDC );
-VOID NEAR PASCAL FireShot( VOID );
-VOID NEAR PASCAL AccelPlayer( INT nDir, INT nAccel );
-VOID NEAR PASCAL DrawPlayer( HDC hDC );
-VOID NEAR PASCAL DrawObjects( HWND hWnd );
-VOID NEAR PASCAL CheckScore( HWND hWnd );
-VOID NEAR PASCAL HitList( HDC hDC, NPLIST npList );
-VOID NEAR PASCAL ExplodeBadguys( HDC hDC, NPLIST npList );
-VOID NEAR PASCAL NewGame( HWND hWnd );
-VOID NEAR PASCAL RestartHyperoid( VOID );
-VOID NEAR PASCAL Panic( BOOL bPanic );
-VOID NEAR PASCAL PaintHyperoid( HWND hWnd );
-VOID NEAR PASCAL DisableHyperoidInput( HWND hWnd, BOOL bCapture );
-LONG FAR PASCAL EXPORT HyperoidWndProc( HWND hWnd, unsigned message, WORD wParam, LONG lParam );
-BOOL NEAR PASCAL InitHyperoid( VOID );
-VOID NEAR PASCAL ExitHyperoid( VOID );
-INT FAR PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, INT nCmdShow );
-
-// roidsupp.c
-VOID FAR PASCAL PrintLetters( NPSTR npszText, POINT Pos, POINT Vel, BYTE byColor, INT nSize );
-VOID FAR PASCAL SpinLetters( NPSTR npszText, POINT Pos, POINT Vel, BYTE byColor, INT nSize );
-HPALETTE FAR PASCAL CreateHyperoidPalette( VOID );
-BOOL FAR PASCAL CreateHyperoidClass( VOID );
-VOID NEAR PASCAL SetHyperoidMenu( HWND hWnd, INT nFirstID, INT nLastID );
-HWND FAR PASCAL CreateHyperoidWindow( LPSTR lpszCmd, INT nCmdShow );
-VOID FAR PASCAL SaveHyperoidWindowPos( HWND hWnd );
-VOID FAR PASCAL GetHyperoidIni( VOID );
-VOID FAR PASCAL HyperoidHelp( HWND hWnd );
-BOOL FAR PASCAL EXPORT HyperoidAboutDlg( HWND hDlg, WORD mess, WORD wParam, LONG lParam );
-VOID FAR PASCAL AboutHyperoid( HWND hWnd );
-
-#endif // RC_INVOKED //
-
-//
-// resource IDs
-//
-
-// icons and bitmaps
-#define IDI_HYPEROID 10
-#define IDI_PANIC 20
-
-// bitmaps
-#define IDB_blank 50
-#define IDB_bomb 51
-#define IDB_level 52
-#define IDB_life 53
-#define IDB_num0 54
-#define IDB_num1 55
-#define IDB_num2 56
-#define IDB_num3 57
-#define IDB_num4 58
-#define IDB_num5 59
-#define IDB_num6 60
-#define IDB_num7 61
-#define IDB_num8 62
-#define IDB_num9 63
-#define IDB_plus 64
-#define IDB_score 65
-#define IDB_shield 66
-// additional bitmap stuff
-#define IDB_MAX 17
-#define CX_BITMAP 16
-#define CY_BITMAP 16
-
-// strings
-#define IDS_NAME 100
-
-// menus
-#define IDM_NEW 200
-#define IDM_ABOUT 201
-
-// about box
-#define IDD_ABOUT 500
-#define IDD_A_HELP 501
-#define IDD_A_HISCORE 502
diff --git a/test/hyperoid/hyperoid.ico b/test/hyperoid/hyperoid.ico
deleted file mode 100644
index 6641a83..0000000
--- a/test/hyperoid/hyperoid.ico
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/hyperoid.mak b/test/hyperoid/hyperoid.mak
deleted file mode 100644
index c885a1b..0000000
--- a/test/hyperoid/hyperoid.mak
+++ /dev/null
@@ -1,35 +0,0 @@
-PROJ =HYPEROID
-DEBUG =1
-CC =qcl
-CFLAGS_G = /AM /W3 /Ze
-CFLAGS_D = /Zi /Od
-CFLAGS_R = /O /Ol /Gs /DNDEBUG
-CFLAGS =$(CFLAGS_G) $(CFLAGS_D)
-LFLAGS_G = /CP:0xffff /NOI /SE:0x80 /ST:0x2000
-LFLAGS_D = /CO /M
-LFLAGS_R =
-LFLAGS =$(LFLAGS_G) $(LFLAGS_D)
-RUNFLAGS =
-OBJS_EXT =
-LIBS_EXT =
-
-all: $(PROJ).exe
-
-hyperoid.obj: hyperoid.c
-
-roidsupp.obj: roidsupp.c
-
-$(PROJ).exe: hyperoid.obj roidsupp.obj $(OBJS_EXT)
- echo >NUL @<<$(PROJ).crf
-hyperoid.obj +
-roidsupp.obj +
-$(OBJS_EXT)
-$(PROJ).exe
-
-$(LIBS_EXT);
-<<
- ilink -a -e "link $(LFLAGS) @$(PROJ).crf" $(PROJ)
-
-run: $(PROJ).exe
- $(PROJ) $(RUNFLAGS)
-
diff --git a/test/hyperoid/hyperoid.map b/test/hyperoid/hyperoid.map
deleted file mode 100644
index 34edf19..0000000
--- a/test/hyperoid/hyperoid.map
+++ /dev/null
@@ -1,671 +0,0 @@
-Stack Allocation = 8192 bytes
-
- hyperoid
-
- Start Length Name Class
- 0001:0000 022D8H HYPEROID CODE
- 0001:22D8 006E8H ROIDSUPP CODE
- 0001:29C0 02834H _TEXT CODE
- 0001:5200 026F0H EMULATOR_TEXT CODE
- 0001:78F0 00000H C_ETEXT ENDCODE
- 0002:0000 00170H EMULATOR_DATA FAR_DATA
- 0003:0000 00042H NULL BEGDATA
- 0003:0042 00A00H _DATA DATA
- 0003:0A42 00002H XIQC DATA
- 0003:0A44 0000EH DBDATA DATA
- 0003:0A52 0000EH CDATA DATA
- 0003:0A60 00000H XIFB DATA
- 0003:0A60 00000H XIF DATA
- 0003:0A60 00000H XIFE DATA
- 0003:0A60 00000H XIB DATA
- 0003:0A60 0000CH XI DATA
- 0003:0A6C 00000H XIE DATA
- 0003:0A6C 00000H XPB DATA
- 0003:0A6C 00000H XP DATA
- 0003:0A6C 00000H XPE DATA
- 0003:0A6C 00000H XCB DATA
- 0003:0A6C 00000H XC DATA
- 0003:0A6C 00000H XCE DATA
- 0003:0A6C 00000H XCFB DATA
- 0003:0A6C 00000H XCF DATA
- 0003:0A6C 00000H XCFE DATA
- 0003:0A6C 00018H CONST CONST
- 0003:0A84 00008H HDR MSG
- 0003:0A8C 001DDH MSG MSG
- 0003:0C69 00002H PAD MSG
- 0003:0C6B 00001H EPAD MSG
- 0003:0C6C 0006EH _BSS BSS
- 0003:0CDA 00000H XOB BSS
- 0003:0CDA 00000H XO BSS
- 0003:0CDA 00000H XOE BSS
- 0003:0CE0 02616H c_common BSS
- 0003:3300 02000H STACK STACK
-
- Origin Group
- 0003:0 DGROUP
-
- Address Export Alias
-
- 0001:28D9 HYPEROIDABOUTDLG HYPEROIDABOUTDLG
- 0001:1ECA HYPEROIDWNDPROC HYPEROIDWNDPROC
-
- Address Publics by Name
-
- 0001:3B44 $I10_OUTPUT
- 0001:382E $i8_output
- 0001:3AEF $i8_tpwr10
- 0001:296C ABOUTHYPEROID
- 0001:029D ACCELERATE
- 0001:18B6 ACCELPLAYER
- 0001:006B ADDHEAD
- 0001:0000 ARAND
- 0001:13D9 BREAKROID
- 0001:1B94 CHECKSCORE
- 0001:0C8A CREATEHUNTER
- 0001:2595 CREATEHYPEROIDCLASS
- 0001:23AC CREATEHYPEROIDPALETTE
- 0001:268F CREATEHYPEROIDWINDOW
- 0001:08E8 CREATELETTER
- 0001:12D3 CREATEROID
- 0001:0F98 CREATESPINNER
- 0001:1754 DRAWFLAMES
- 0001:0D5E DRAWHUNTERS
- 0001:0AD2 DRAWHUNTERSHOTS
- 0001:0A44 DRAWLETTERS
- 0001:02F2 DRAWOBJECT
- 0001:1AB6 DRAWOBJECTS
- 0001:198E DRAWPLAYER
- 0001:15AC DRAWROIDS
- 0001:16C5 DRAWSHOTS
- 0001:107D DRAWSPINNERS
- 0001:1E41 ERASEHYPEROIDBKGND
- 0001:21CC EXITHYPEROID
- 0001:0630 EXPLODE
- 0001:3552 fFYTOX
- 0000:FE32 Abs FIARQQ
- 0000:0E32 Abs FICRQQ
- 0000:5C32 Abs FIDRQQ
- 0000:1632 Abs FIERQQ
- 0001:0BAC FIREHUNTERSHOT
- 0001:17E3 FIRESHOT
- 0000:0632 Abs FISRQQ
- 0000:A23D Abs FIWRQQ
- 0000:4000 Abs FJARQQ
- 0000:C000 Abs FJCRQQ
- 0000:8000 Abs FJSRQQ
- 0001:0547 HIT
- 0001:0787 HITPLAYER
- 0001:28D9 HYPEROIDABOUTDLG
- 0001:28AA HYPEROIDHELP
- 0001:1ECA HYPEROIDWNDPROC
- 0001:214C INITHYPEROID
- 0001:0195 INITOBJECTS
- 0001:1DF2 PAINTHYPEROID
- 0001:1D51 PANIC
- 0003:0CE4 PLOCALHEAP
- 0001:22D8 PRINTLETTERS
- 0001:00D0 REMHEAD
- 0001:0136 REMOVE
- 0001:1C13 RESTARTHYPEROID
- 0001:2790 SAVEHYPEROIDWINDOWPOS
- 0001:2616 SETHYPEROIDMENU
- 0001:0513 SETRESTART
- 0001:2222 WINMAIN
- 0001:317C _atof
- 0001:3178 _atoi
- 0003:32C6 _bPaused
- 0003:32BE _bRestart
- 0001:4AE4 _cos
- 0003:0C6C _edata
- 0003:3300 _end
- 0003:06AF _environ
- 0003:0688 _errno
- 0001:2B8D _exit
- 0003:3086 _FlameList
- 0003:32C2 _FreeList
- 0003:30AE _hAppInst
- 0003:32D2 _hAppPalette
- 0003:32C0 _hAppWnd
- 0003:308E _hPen
- 0003:0A38 _HUGE
- 0003:30B0 _HunterList
- 0003:0CE8 _HunterShotList
- 0003:0CE0 _LetterList
- 0003:0250 _LetterPart
- 0003:30B8 _lScore
- 0001:2F34 _malloc
- 0001:4E30 _matherr
- 0001:32F4 _memmove
- 0001:333C _memset
- 0003:32BC _nBadGuys
- 0003:0CEE _nCos
- 0003:32C8 _nGravity
- 0003:308C _nLevel
- 0003:0CEC _npPlayer
- 0003:0CE6 _nSafe
- 0003:32F4 _nShield
- 0003:30BC _nSin
- 0003:0EEE _Obj
- 0003:32CE _RoidList
- 0003:32CA _ShotList
- 0001:4ADE _sin
- 0003:30B4 _SpinnerList
- 0001:3130 _strcmp
- 0001:30FE _strcpy
- 0001:315C _strlen
- 0003:32D4 _szAppName
- 0003:0298 _szLetterDesc
- 0003:0284 _szNumberDesc
- 0001:4AE9 _tan
- 0003:308A _wTick
- 0003:09A4 __80x87
- 0003:066C __acfinfo
- 0000:9876 Abs __acrtmsg
- 0000:9876 Abs __acrtused
- 0000:D6D6 Abs __aDBdoswp
- 0003:06BE __adbgmsg
- 0003:0650 __aexit_rtn
- 0001:4AF4 __aFCIcos
- 0001:4AEE __aFCIsin
- 0001:4AF9 __aFCItan
- 0001:4D08 __aFftol
- 0001:3386 __aFldiv
- 0001:3420 __aFlmul
- 0001:3420 __aFulmul
- 0003:067A __aintdiv
- 0003:06C6 __amblksiz
- 0001:2AA3 __amsg_exit
- 0003:0042 __anullsize
- 0003:0668 __aseghi
- 0003:066A __aseglo
- 0003:0652 __asizds
- 0003:06E4 __asizeC
- 0003:06E5 __asizeD
- 0001:29D0 __astart
- 0001:51D0 __atold
- 0003:064E __atopsp
- 0001:31C2 __catox
- 0001:2B9C __cexit
- 0001:4A64 __cfltcvt
- 0003:06C8 __cfltcvt_tab
- 0001:474E __cftoe
- 0001:489C __cftof
- 0001:49B2 __cftog
- 0003:06B6 __child
- 0001:2AC8 __cinit
- 0001:2A93 __cintDIV
- 0001:4BA2 __cintrindisp1
- 0001:4B79 __cintrindisp2
- 0001:517A __cldcvt
- 0001:4E40 __cldtoe
- 0001:4FCE __cldtof
- 0001:510C __cldtog
- 0003:08E2 __cosjmptab
- 0003:0912 __cotanjmptab
- 0003:07FC __cpower
- 0001:4656 __cropzeros
- 0001:2C10 __ctermsub
- 0001:4BD7 __ctrandisp1
- 0001:4BC4 __ctrandisp2
- 0003:06E6 __ctype
- 0003:06E6 __ctype_
- 0001:2BA6 __c_exit
- 0001:2AC5 __dataseg
- 0001:32BB __DOSCREATECSALIAS
- 0001:3286 __DOSDEVCONFIG
- 0003:0693 __doserrno
- 0001:32D1 __DOSFREESEG
- 0001:329D __DOSGETMACHINEMODE
- 0001:32B2 __DOSSETVEC
- 0003:0690 __dosvermajor
- 0003:0691 __dosverminor
- 0001:32DA __DOSWRITE
- 0001:5200 __EmDataSeg
- 0001:2B94 __exit
- 0003:08A0 __expjmptab
- 0003:067E __fac
- 0001:46F2 __fassign
- 0001:36D7 __fFCOS
- 0001:355E __fFEXP
- 0001:3686 __ffexpm1
- 0001:360B __fFLN
- 0001:36F0 __fFSIN
- 0001:2C50 __FF_MSGBANNER
- 0001:30DD __findlast
- 0001:4D3C __fltin
- 0001:4D92 __fltout
- 0000:9876 Abs __fltused
- 0001:45EE __forcdecpt
- 0001:5A7F __fpemulator
- 0001:5210 __fpemulatorbegin
- 0001:786F __fpemulatorend
- 0001:54DE __FPEXCEPTION87
- 0003:0A54 __fpinit
- 0001:787A __FPINSTALL87
- 0001:523A __fpmath
- 0001:4DD8 __fpsignal
- 0002:0169 __fptaskdata
- 0001:78A9 __FPTERMINATE87
- 0001:3216 __fptostr
- 0001:2C72 __fptrap
- 0001:4D08 __ftol
- 0001:3000 __growseg
- 0001:308C __incseg
- 0003:07E8 __indefinite
- 0003:080E __infinity
- 0001:4AFE __Init80x87
- 0003:06B9 __intno
- 0001:40DF __LD12MULT
- 0001:400A __LD12MULTTENPOWER
- 0003:0888 __lnjmptab
- 0003:0818 __logemax
- 0003:0870 __logjmptab
- 0001:4264 __MANTOLD12
- 0003:0A40 __matherr_flag
- 0001:2F0E __myalloc
- 0003:0695 __nfile
- 0001:2F3A __nfree
- 0003:0654 __nheap_desc
- 0001:2F5B __nmalloc
- 0001:2EAC __NMSG_TEXT
- 0001:2ED7 __NMSG_WRITE
- 0001:2C78 __nullcheck
- 0003:0693 __oserr
- 0003:0697 __osfile
- 0003:0690 __osmajor
- 0003:0691 __osminor
- 0003:0692 __osmode
- 0003:0690 __osversion
- 0003:06B8 __ovlflag
- 0003:06BA __ovlvec
- 0003:06B1 __pgmptr
- 0003:07F2 __piby2
- 0001:46C4 __positive
- 0003:068E __psp
- 0003:068C __pspadr
- 0001:351A __rtbignan
- 0001:3549 __rtchsifneg
- 0001:3540 __rtifprojnpop
- 0001:3521 __rtifprojpop
- 0001:352B __rtindfnpop
- 0001:3528 __rtindfpop
- 0001:366B __rtinfnpop
- 0001:35FE __rtinfnpopse
- 0001:3668 __rtinfpop
- 0001:35FB __rtinfpopse
- 0001:34FD __rtnospop
- 0001:3501 __rtnospopde
- 0001:3513 __rtonenpop
- 0001:3510 __rtonepop
- 0001:3500 __rttosnpop
- 0001:3539 __rttosnpopde
- 0001:34FA __rttospop
- 0001:34F7 __rttospopde
- 0001:3509 __rtzeronpop
- 0001:3506 __rtzeropop
- 0001:2F84 __searchseg
- 0001:2C9C __setargv
- 0001:2E2E __setenvp
- 0003:06E2 __sigintoff
- 0003:06E0 __sigintseg
- 0003:08CA __sinjmptab
- 0001:431E __STRINGTOD
- 0001:4386 __STRINGTOLD
- 0003:08FA __tanjmptab
- 0001:3452 __trandisp1
- 0001:3494 __trandisp2
- 0003:068A __umaskval
- 0001:336A __wrt2err
- 0003:0840 __ytoxjmptab
- 0003:0A4A ___aDBexit
- 0003:0A50 ___aDBptrchk
- 0003:0A48 ___aDBrterr
- 0003:0A46 ___aDBswpchk
- 0003:0A44 ___aDBswpflg
- 0003:06AB ___argc
- 0003:06AD ___argv
- 0003:0A42 ___qczrinit
-
- Address Publics by Value
-
- 0000:0632 Abs FISRQQ
- 0000:0E32 Abs FICRQQ
- 0000:1632 Abs FIERQQ
- 0000:4000 Abs FJARQQ
- 0000:5C32 Abs FIDRQQ
- 0000:8000 Abs FJSRQQ
- 0000:9876 Abs __acrtmsg
- 0000:9876 Abs __acrtused
- 0000:9876 Abs __fltused
- 0000:A23D Abs FIWRQQ
- 0000:C000 Abs FJCRQQ
- 0000:D6D6 Abs __aDBdoswp
- 0000:FE32 Abs FIARQQ
- 0001:0000 ARAND
- 0001:006B ADDHEAD
- 0001:00D0 REMHEAD
- 0001:0136 REMOVE
- 0001:0195 INITOBJECTS
- 0001:029D ACCELERATE
- 0001:02F2 DRAWOBJECT
- 0001:0513 SETRESTART
- 0001:0547 HIT
- 0001:0630 EXPLODE
- 0001:0787 HITPLAYER
- 0001:08E8 CREATELETTER
- 0001:0A44 DRAWLETTERS
- 0001:0AD2 DRAWHUNTERSHOTS
- 0001:0BAC FIREHUNTERSHOT
- 0001:0C8A CREATEHUNTER
- 0001:0D5E DRAWHUNTERS
- 0001:0F98 CREATESPINNER
- 0001:107D DRAWSPINNERS
- 0001:12D3 CREATEROID
- 0001:13D9 BREAKROID
- 0001:15AC DRAWROIDS
- 0001:16C5 DRAWSHOTS
- 0001:1754 DRAWFLAMES
- 0001:17E3 FIRESHOT
- 0001:18B6 ACCELPLAYER
- 0001:198E DRAWPLAYER
- 0001:1AB6 DRAWOBJECTS
- 0001:1B94 CHECKSCORE
- 0001:1C13 RESTARTHYPEROID
- 0001:1D51 PANIC
- 0001:1DF2 PAINTHYPEROID
- 0001:1E41 ERASEHYPEROIDBKGND
- 0001:1ECA HYPEROIDWNDPROC
- 0001:214C INITHYPEROID
- 0001:21CC EXITHYPEROID
- 0001:2222 WINMAIN
- 0001:22D8 PRINTLETTERS
- 0001:23AC CREATEHYPEROIDPALETTE
- 0001:2595 CREATEHYPEROIDCLASS
- 0001:2616 SETHYPEROIDMENU
- 0001:268F CREATEHYPEROIDWINDOW
- 0001:2790 SAVEHYPEROIDWINDOWPOS
- 0001:28AA HYPEROIDHELP
- 0001:28D9 HYPEROIDABOUTDLG
- 0001:296C ABOUTHYPEROID
- 0001:29D0 __astart
- 0001:2A93 __cintDIV
- 0001:2AA3 __amsg_exit
- 0001:2AC5 __dataseg
- 0001:2AC8 __cinit
- 0001:2B8D _exit
- 0001:2B94 __exit
- 0001:2B9C __cexit
- 0001:2BA6 __c_exit
- 0001:2C10 __ctermsub
- 0001:2C50 __FF_MSGBANNER
- 0001:2C72 __fptrap
- 0001:2C78 __nullcheck
- 0001:2C9C __setargv
- 0001:2E2E __setenvp
- 0001:2EAC __NMSG_TEXT
- 0001:2ED7 __NMSG_WRITE
- 0001:2F0E __myalloc
- 0001:2F34 _malloc
- 0001:2F3A __nfree
- 0001:2F5B __nmalloc
- 0001:2F84 __searchseg
- 0001:3000 __growseg
- 0001:308C __incseg
- 0001:30DD __findlast
- 0001:30FE _strcpy
- 0001:3130 _strcmp
- 0001:315C _strlen
- 0001:3178 _atoi
- 0001:317C _atof
- 0001:31C2 __catox
- 0001:3216 __fptostr
- 0001:3286 __DOSDEVCONFIG
- 0001:329D __DOSGETMACHINEMODE
- 0001:32B2 __DOSSETVEC
- 0001:32BB __DOSCREATECSALIAS
- 0001:32D1 __DOSFREESEG
- 0001:32DA __DOSWRITE
- 0001:32F4 _memmove
- 0001:333C _memset
- 0001:336A __wrt2err
- 0001:3386 __aFldiv
- 0001:3420 __aFulmul
- 0001:3420 __aFlmul
- 0001:3452 __trandisp1
- 0001:3494 __trandisp2
- 0001:34F7 __rttospopde
- 0001:34FA __rttospop
- 0001:34FD __rtnospop
- 0001:3500 __rttosnpop
- 0001:3501 __rtnospopde
- 0001:3506 __rtzeropop
- 0001:3509 __rtzeronpop
- 0001:3510 __rtonepop
- 0001:3513 __rtonenpop
- 0001:351A __rtbignan
- 0001:3521 __rtifprojpop
- 0001:3528 __rtindfpop
- 0001:352B __rtindfnpop
- 0001:3539 __rttosnpopde
- 0001:3540 __rtifprojnpop
- 0001:3549 __rtchsifneg
- 0001:3552 fFYTOX
- 0001:355E __fFEXP
- 0001:35FB __rtinfpopse
- 0001:35FE __rtinfnpopse
- 0001:360B __fFLN
- 0001:3668 __rtinfpop
- 0001:366B __rtinfnpop
- 0001:3686 __ffexpm1
- 0001:36D7 __fFCOS
- 0001:36F0 __fFSIN
- 0001:382E $i8_output
- 0001:3AEF $i8_tpwr10
- 0001:3B44 $I10_OUTPUT
- 0001:400A __LD12MULTTENPOWER
- 0001:40DF __LD12MULT
- 0001:4264 __MANTOLD12
- 0001:431E __STRINGTOD
- 0001:4386 __STRINGTOLD
- 0001:45EE __forcdecpt
- 0001:4656 __cropzeros
- 0001:46C4 __positive
- 0001:46F2 __fassign
- 0001:474E __cftoe
- 0001:489C __cftof
- 0001:49B2 __cftog
- 0001:4A64 __cfltcvt
- 0001:4ADE _sin
- 0001:4AE4 _cos
- 0001:4AE9 _tan
- 0001:4AEE __aFCIsin
- 0001:4AF4 __aFCIcos
- 0001:4AF9 __aFCItan
- 0001:4AFE __Init80x87
- 0001:4B79 __cintrindisp2
- 0001:4BA2 __cintrindisp1
- 0001:4BC4 __ctrandisp2
- 0001:4BD7 __ctrandisp1
- 0001:4D08 __aFftol
- 0001:4D08 __ftol
- 0001:4D3C __fltin
- 0001:4D92 __fltout
- 0001:4DD8 __fpsignal
- 0001:4E30 _matherr
- 0001:4E40 __cldtoe
- 0001:4FCE __cldtof
- 0001:510C __cldtog
- 0001:517A __cldcvt
- 0001:51D0 __atold
- 0001:5200 __EmDataSeg
- 0001:5210 __fpemulatorbegin
- 0001:523A __fpmath
- 0001:54DE __FPEXCEPTION87
- 0001:5A7F __fpemulator
- 0001:786F __fpemulatorend
- 0001:787A __FPINSTALL87
- 0001:78A9 __FPTERMINATE87
- 0002:0169 __fptaskdata
- 0003:0042 __anullsize
- 0003:0250 _LetterPart
- 0003:0284 _szNumberDesc
- 0003:0298 _szLetterDesc
- 0003:064E __atopsp
- 0003:0650 __aexit_rtn
- 0003:0652 __asizds
- 0003:0654 __nheap_desc
- 0003:0668 __aseghi
- 0003:066A __aseglo
- 0003:066C __acfinfo
- 0003:067A __aintdiv
- 0003:067E __fac
- 0003:0688 _errno
- 0003:068A __umaskval
- 0003:068C __pspadr
- 0003:068E __psp
- 0003:0690 __osversion
- 0003:0690 __dosvermajor
- 0003:0690 __osmajor
- 0003:0691 __osminor
- 0003:0691 __dosverminor
- 0003:0692 __osmode
- 0003:0693 __oserr
- 0003:0693 __doserrno
- 0003:0695 __nfile
- 0003:0697 __osfile
- 0003:06AB ___argc
- 0003:06AD ___argv
- 0003:06AF _environ
- 0003:06B1 __pgmptr
- 0003:06B6 __child
- 0003:06B8 __ovlflag
- 0003:06B9 __intno
- 0003:06BA __ovlvec
- 0003:06BE __adbgmsg
- 0003:06C6 __amblksiz
- 0003:06C8 __cfltcvt_tab
- 0003:06E0 __sigintseg
- 0003:06E2 __sigintoff
- 0003:06E4 __asizeC
- 0003:06E5 __asizeD
- 0003:06E6 __ctype_
- 0003:06E6 __ctype
- 0003:07E8 __indefinite
- 0003:07F2 __piby2
- 0003:07FC __cpower
- 0003:080E __infinity
- 0003:0818 __logemax
- 0003:0840 __ytoxjmptab
- 0003:0870 __logjmptab
- 0003:0888 __lnjmptab
- 0003:08A0 __expjmptab
- 0003:08CA __sinjmptab
- 0003:08E2 __cosjmptab
- 0003:08FA __tanjmptab
- 0003:0912 __cotanjmptab
- 0003:09A4 __80x87
- 0003:0A38 _HUGE
- 0003:0A40 __matherr_flag
- 0003:0A42 ___qczrinit
- 0003:0A44 ___aDBswpflg
- 0003:0A46 ___aDBswpchk
- 0003:0A48 ___aDBrterr
- 0003:0A4A ___aDBexit
- 0003:0A50 ___aDBptrchk
- 0003:0A54 __fpinit
- 0003:0C6C _edata
- 0003:0CE0 _LetterList
- 0003:0CE4 PLOCALHEAP
- 0003:0CE6 _nSafe
- 0003:0CE8 _HunterShotList
- 0003:0CEC _npPlayer
- 0003:0CEE _nCos
- 0003:0EEE _Obj
- 0003:3086 _FlameList
- 0003:308A _wTick
- 0003:308C _nLevel
- 0003:308E _hPen
- 0003:30AE _hAppInst
- 0003:30B0 _HunterList
- 0003:30B4 _SpinnerList
- 0003:30B8 _lScore
- 0003:30BC _nSin
- 0003:32BC _nBadGuys
- 0003:32BE _bRestart
- 0003:32C0 _hAppWnd
- 0003:32C2 _FreeList
- 0003:32C6 _bPaused
- 0003:32C8 _nGravity
- 0003:32CA _ShotList
- 0003:32CE _RoidList
- 0003:32D2 _hAppPalette
- 0003:32D4 _szAppName
- 0003:32F4 _nShield
- 0003:3300 _end
-
-Program entry point at 0001:29D0
-
- : error L2029: 'ENDDIALOG' : unresolved external
- : error L2029: 'ISZOOMED' : unresolved external
- : error L2029: '_main' : unresolved external
- : error L2029: 'GETPRIVATEPROFILEINT' : unresolved external
- : error L2029: 'SELECTPALETTE' : unresolved external
- : error L2029: 'CREATEWINDOW' : unresolved external
- : error L2029: 'SETBRUSHORG' : unresolved external
- : error L2029: 'MULDIV' : unresolved external
- : error L2029: 'MULDIV' : unresolved external
- : error L2029: '_wsprintf' : unresolved external
- : error L2029: '_wsprintf' : unresolved external
- : error L2029: 'GETPRIVATEPROFILESTRING' : unresolved external
- : error L2029: 'GETASYNCKEYSTATE' : unresolved external
- : error L2029: 'RELEASEDC' : unresolved external
- : error L2029: 'DELETEDC' : unresolved external
- : error L2029: 'POSTQUITMESSAGE' : unresolved external
- : error L2029: 'MESSAGEBOX' : unresolved external
- : error L2029: 'UPDATEWINDOW' : unresolved external
- : error L2029: 'LOADSTRING' : unresolved external
- : error L2029: 'GETDC' : unresolved external
- : error L2029: 'MAKEPROCINSTANCE' : unresolved external
- : error L2029: 'GETCURRENTTIME' : unresolved external
- : error L2029: 'FREEPROCINSTANCE' : unresolved external
- : error L2029: 'CREATEIC' : unresolved external
- : error L2029: 'SETMAPMODE' : unresolved external
- : error L2029: 'FILLRECT' : unresolved external
- : error L2029: 'LOADICON' : unresolved external
- : error L2029: 'REGISTERCLASS' : unresolved external
- : error L2029: 'LOADCURSOR' : unresolved external
- : error L2029: 'GETSYSTEMMENU' : unresolved external
- : error L2029: 'WRITEPRIVATEPROFILESTRING' : unresolved external
- : error L2029: 'DRAWICON' : unresolved external
- : error L2029: 'CREATEPEN' : unresolved external
- : error L2029: 'CREATESOLIDBRUSH' : unresolved external
- : error L2029: 'SETVIEWPORTORG' : unresolved external
- : error L2029: 'ENDPAINT' : unresolved external
- : error L2029: 'TRANSLATEMESSAGE' : unresolved external
- : error L2029: 'GETMESSAGE' : unresolved external
- : error L2029: 'SETWINDOWEXT' : unresolved external
- : error L2029: 'PTINRECT' : unresolved external
- : error L2029: 'GETDEVICECAPS' : unresolved external
- : error L2029: 'DELETEOBJECT' : unresolved external
- : error L2029: 'KILLTIMER' : unresolved external
- : error L2029: 'DISPATCHMESSAGE' : unresolved external
- : error L2029: 'SETVIEWPORTEXT' : unresolved external
- : error L2029: 'DEFWINDOWPROC' : unresolved external
- : error L2029: 'SHOWWINDOW' : unresolved external
- : error L2029: 'SHOWWINDOW' : unresolved external
- : error L2029: 'GETCLIENTRECT' : unresolved external
- : error L2029: 'INVALIDATERECT' : unresolved external
- : error L2029: 'SELECTOBJECT' : unresolved external
- : error L2029: 'GETINSTANCEDATA' : unresolved external
- : error L2029: 'SETTIMER' : unresolved external
- : error L2029: 'BEGINPAINT' : unresolved external
- : error L2029: 'CHANGEMENU' : unresolved external
- : error L2029: 'GETWINDOWRECT' : unresolved external
- : error L2029: 'CREATEPALETTE' : unresolved external
- : error L2029: 'POLYLINE' : unresolved external
- : error L2029: 'DIALOGBOX' : unresolved external
- : error L2029: 'REALIZEPALETTE' : unresolved external
- : error L2029: 'SETPIXEL' : unresolved external
- : error L2029: 'GETSYSCOLOR' : unresolved external
- : error L2029: 'SETWINDOWTEXT' : unresolved external
-
diff --git a/test/hyperoid/hyperoid.rc b/test/hyperoid/hyperoid.rc
deleted file mode 100644
index 4f8afb7..0000000
--- a/test/hyperoid/hyperoid.rc
+++ /dev/null
@@ -1,59 +0,0 @@
-//
-// HYPEROID.RC - orbiter resources
-//
-
-#include <windows.h>
-#include "hyperoid.h"
-
-IDI_HYPEROID ICON "hyperoid.ico"
-IDI_PANIC ICON "panic.ico"
-
-STRINGTABLE
-{
- IDS_NAME, "Hyperoid"
- IDM_NEW, "New Game&!"
- IDM_ABOUT, "&About..."
-}
-
-//
-// About box
-//
-
-IDD_ABOUT DIALOG LOADONCALL MOVEABLE DISCARDABLE 30, 30, 150, 120
-CAPTION "About"
-STYLE WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME | WS_POPUP
-{
- CTEXT "Hyperoid", -1, 0, 10, 150, 8
- CTEXT "The classic game", -1, 0, 20, 150, 8
- CTEXT "Version 1.1", -1, 0, 30, 150, 8
- CTEXT "Copyright © 1991 Hutchins Software", -1, 0, 45, 150, 8
- CTEXT "This program is freeware", -1, 0, 55, 150, 8
- CTEXT "Author: Edward Hutchins", -1, 0, 65, 150, 8
- CTEXT "eah1@cec1.wustl.edu", -1, 0, 75, 150, 8
- CTEXT "", IDD_A_HISCORE, 0, 85, 150, 8
- ICON IDI_HYPEROID, -1, 10, 16, 0, 0
- DEFPUSHBUTTON "Ok!", IDOK, 20, 100, 40, 12
- CONTROL "&Help", IDD_A_HELP, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 90, 100, 40, 12
-}
-
-//
-// bitmaps
-//
-
-IDB_blank BITMAP DISCARDABLE "blank.bmp"
-IDB_bomb BITMAP DISCARDABLE "bomb.bmp"
-IDB_level BITMAP DISCARDABLE "level.bmp"
-IDB_life BITMAP DISCARDABLE "life.bmp"
-IDB_num0 BITMAP DISCARDABLE "num0.bmp"
-IDB_num1 BITMAP DISCARDABLE "num1.bmp"
-IDB_num2 BITMAP DISCARDABLE "num2.bmp"
-IDB_num3 BITMAP DISCARDABLE "num3.bmp"
-IDB_num4 BITMAP DISCARDABLE "num4.bmp"
-IDB_num5 BITMAP DISCARDABLE "num5.bmp"
-IDB_num6 BITMAP DISCARDABLE "num6.bmp"
-IDB_num7 BITMAP DISCARDABLE "num7.bmp"
-IDB_num8 BITMAP DISCARDABLE "num8.bmp"
-IDB_num9 BITMAP DISCARDABLE "num9.bmp"
-IDB_plus BITMAP DISCARDABLE "plus.bmp"
-IDB_score BITMAP DISCARDABLE "score.bmp"
-IDB_shield BITMAP DISCARDABLE "shield.bmp"
diff --git a/test/hyperoid/level.bmp b/test/hyperoid/level.bmp
deleted file mode 100644
index eb1f03e..0000000
--- a/test/hyperoid/level.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/life.bmp b/test/hyperoid/life.bmp
deleted file mode 100644
index 70fd623..0000000
--- a/test/hyperoid/life.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/list.c b/test/hyperoid/list.c
deleted file mode 100644
index e427064..0000000
--- a/test/hyperoid/list.c
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// LIST - list processing functions for orbiter
-//
-// Version: 1.0 Copyright (C) 1990, Hutchins Software
-// Author: Edward Hutchins
-// Revisions:
-//
-
-#include "orbiter.h"
-
-//
-// AddHead - add an object to the head of a list
-//
-
-VOID FAR PASCAL AddHead( NPLIST npList, NPNODE npNode )
-{
- if (npList->npHead)
- {
- npNode->npNext = npList->npHead;
- npNode->npPrev = NULL;
- npList->npHead = (npList->npHead->npPrev = npNode);
- }
- else // add to an empty list
- {
- npList->npHead = npList->npTail = npNode;
- npNode->npNext = npNode->npPrev = NULL;
- }
-}
-
-//
-// RemHead - remove the first element in a list
-//
-
-NPNODE FAR PASCAL RemHead( NPLIST npList )
-{
- if (npList->npHead)
- {
- NPNODE npNode = npList->npHead;
- if (npList->npTail != npNode)
- {
- npList->npHead = npNode->npNext;
- npNode->npNext->npPrev = NULL;
- }
- else npList->npHead = npList->npTail = NULL;
- return( npNode );
- }
- else return( NULL );
-}
-
-//
-// Remove - remove an arbitrary element from a list
-//
-
-VOID FAR PASCAL Remove( NPLIST npList, NPNODE npNode )
-{
- if (npNode->npPrev) npNode->npPrev->npNext = npNode->npNext;
- else npList->npHead = npNode->npNext;
- if (npNode->npNext) npNode->npNext->npPrev = npNode->npPrev;
- else npList->npTail = npNode->npPrev;
-}
-
diff --git a/test/hyperoid/makefile.mk b/test/hyperoid/makefile.mk
deleted file mode 100644
index 61c3938..0000000
--- a/test/hyperoid/makefile.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-########################################################
-#
-# hyperoid makefile
-#
-# Copyright (C) 1988-1990 Lantern Corp.
-#
-########################################################
-
-# This is just a teaser to show how little you have to do to make projects
-# under Lantern Corp.'s software engineering system. To make Hyperoid on
-# your system, make sure <winext.h> is in your include path and set up your
-# makefile like you normally do for your own stuff.
-# I'll (hopefully) post the 100k of stuff you need for this makefile to
-# be usefull. I'll have to talk to my boss first...
-# P.S. The system only works for the Mircosoft C6.0 compiler, but its easy
-# enough to change.
-# P.P.S. I hate every integrated environment I've run across so far, thus
-# the system is run from a command prompt.
-
-PROJ = hyperoid
-OBJS = hyperoid.obj roidsupp.obj
-RESS = hyperoid.res
-LIBS =
-
-!include <windows.mk>
-
diff --git a/test/hyperoid/num0.bmp b/test/hyperoid/num0.bmp
deleted file mode 100644
index 9dfa846..0000000
--- a/test/hyperoid/num0.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/num1.bmp b/test/hyperoid/num1.bmp
deleted file mode 100644
index 302d0f9..0000000
--- a/test/hyperoid/num1.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/num2.bmp b/test/hyperoid/num2.bmp
deleted file mode 100644
index c1b70fa..0000000
--- a/test/hyperoid/num2.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/num3.bmp b/test/hyperoid/num3.bmp
deleted file mode 100644
index f8b9971..0000000
--- a/test/hyperoid/num3.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/num4.bmp b/test/hyperoid/num4.bmp
deleted file mode 100644
index 4ce4a6c..0000000
--- a/test/hyperoid/num4.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/num5.bmp b/test/hyperoid/num5.bmp
deleted file mode 100644
index ce2ca46..0000000
--- a/test/hyperoid/num5.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/num6.bmp b/test/hyperoid/num6.bmp
deleted file mode 100644
index af200bd..0000000
--- a/test/hyperoid/num6.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/num7.bmp b/test/hyperoid/num7.bmp
deleted file mode 100644
index d5eaf6c..0000000
--- a/test/hyperoid/num7.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/num8.bmp b/test/hyperoid/num8.bmp
deleted file mode 100644
index 3a9eeb0..0000000
--- a/test/hyperoid/num8.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/num9.bmp b/test/hyperoid/num9.bmp
deleted file mode 100644
index d2b18d2..0000000
--- a/test/hyperoid/num9.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/panic.ico b/test/hyperoid/panic.ico
deleted file mode 100644
index 6be4492..0000000
--- a/test/hyperoid/panic.ico
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/plus.bmp b/test/hyperoid/plus.bmp
deleted file mode 100644
index 4beda94..0000000
--- a/test/hyperoid/plus.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/read.me b/test/hyperoid/read.me
deleted file mode 100644
index 65f70db..0000000
--- a/test/hyperoid/read.me
+++ /dev/null
@@ -1,109 +0,0 @@
-****************************************************************************
-LEGAL JUNK:
-
- Hyperoid - a game for Mircosoft Windows (tm)
- Copyright (C) 1991 Edward Hutchins
- internet: eah1@cec1.wustl.edu
- usnail: c/o Edward Hutchins, 63 Ridgemoor Dr., Clayton, MO 63105
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- any later version.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Note: Windows is a trademark of Microsoft Corp. (Duh)
-
-With this aside,
-****************************************************************************
-
-Hello, and Welcome to Hyperoid version 1.1!
-
-The object of the game is intuitive---shoot everything! (Well, almost
-everything, heh heh!). If the keyboard buffer overflows in all the
-excitement, ignore the beeps you hear and they'll go away.
-
-Hyperoids uses the palette manager, so if you have a palette-capable display
-(and you read the on-line help pages) you should be able to set up better
-colors than the Windows defaults. I have tested hyperoids on a monochrome
-'286, and it seems to work fine. If you want to re-map the keys, look at
-Appendix A (or the Windows SDK) for some non-ASCII virtual key codes.
-
-The source is available through the same channel that you got the executable
-through, as per the GNU general public licence. Please read the licence if
-you have any questions, or contact me at the above addresses (email
-preferred).
-
-If you make modifications/bug fixes to Hyperoid, please use me as a clearing
-house to prevent versions flooding out into the universe. (You don't have to,
-but I'd appreciate it :-). If you write the world's greatest game using some
-of my source, please send me note telling what it is and where it's available.
-
-Changes since 1.0:
- Explosion processing a little faster
- Swarmers (little green guys) no longer flood the system
- Scoring is better
- Extra lives every 100,000 points (not 50,000)
- Firepower reduced a little (hey, the game was too darn easy)
- Spinning Game Over (Oooooh...)
-
-Look for:
- ls - *nix ls command with MUCHO bells&whistles (couldn't live w/out it!)
- blitfix - util that sets the CS_BYTEALIGNCLIENT bit on all top windows
- (speeds up my 1024x768 display by a factor of 3)
- eyecon - xeyes clone (may have to be renamed)
- ilbm - Amiga IFF bitmap viewer (supports HAM mode and palettes!)
- life - 7 blit life with a few bells&whistles
- loadmon - nifty system performance monitor
- mbrot - mandelbrot hack that runs in the background
- yow - Zippy the Pinhead in his very own icon, telling it like it is
- (more games... stuff... junk...)
-Coming real soon now to a (net,BBS,Wherever this stuff ends up) near YOU!
-
-Appendix A: Virtual Key Codes
------------------------------
-
- VK_TAB 9 = default shields
- VK_RETURN 13
- VK_SHIFT 16
- VK_CONTROL 17
- VK_CAPITAL 20 - useful for autofire!
- VK_ESCAPE 27 = default boss key
- VK_SPACE 32 = default fire key
- VK_PRIOR 33
- VK_NEXT 34
- VK_END 35
- VK_HOME 36
- VK_LEFT 37 = default counter-clockwise key
- VK_UP 38 = default reverse thrust key
- VK_RIGHT 39 = default clockwise key
- VK_DOWN 40 = default thrust key
- VK_INSERT 45
- VK_DELETE 46
- VK_A-VK_Z 64-90, 83 = default smartbomb key (ASCII 'S')
- VK_NUMPAD0 96
- VK_NUMPAD1 97
- VK_NUMPAD2 98
- VK_NUMPAD3 99
- VK_NUMPAD4 100
- VK_NUMPAD5 101
- VK_NUMPAD6 102
- VK_NUMPAD7 103
- VK_NUMPAD8 104
- VK_NUMPAD9 105
- VK_MULTIPLY 106
- VK_ADD 107
- VK_SEPARATOR 108
- VK_SUBTRACT 109
- VK_DECIMAL 110
- VK_DIVIDE 111
- VK_F1-VK_F16 112-127
-
diff --git a/test/hyperoid/roidsupp.c b/test/hyperoid/roidsupp.c
deleted file mode 100644
index 3da30f1..0000000
--- a/test/hyperoid/roidsupp.c
+++ /dev/null
@@ -1,497 +0,0 @@
-//
-// ROIDSUPP - hyperoid support functions
-//
-// Version: 1.1 Copyright (C) 1991, Hutchins Software
-// This software is licenced under the GNU General Public Licence
-// Please read the associated legal documentation
-// Author: Edward Hutchins
-// Revisions:
-// 11/01/91 added GNU General Public License - Ed.
-//
-
-#include "hyperoid.h"
-
-//
-// defines
-//
-
-// you may ask, "why did he embed all these string constants instead of
-// using the resource file?". Good question. The answer is: I feel better
-// knowing this stuff is part of the executable, and not part of the resource
-// file (which can be changed by sneaky people). Or maybe I wuz lazy.
-// If you don't like it, then YOU can change it!
-
-#define NL "\x0d\x0a"
-
-#define HYPEROID_HELP \
-"The following keys control your ship:" NL NL \
-" Left, Right Arrow .... spin left or right" NL \
-" Down, Up Arrow ..... forward or reverse thrust" NL \
-" Space Bar .............. fire!" NL \
-" Tab ......................... shields" NL \
-" S ............................. smartbomb" NL \
-" Esc ......................... pause/boss key" NL NL \
-"Note: You have 3 lives, unlimited fuel and firepower, 3 shields and 3 " \
-"smartbombs. Your ship gets darker when you lose a life, but you keep on " \
-"playing (unless you hit an asteroid). You get an extra life every 100,000 " \
-"points. When you lose the game, you start over immediately and can finish " \
-"off the current level (which should now be 0) before starting over at " \
-"level 1 (There is no waiting around between games)."
-
-#define HYPEROID_HELP2 \
-"The HYPEROID.INI file can be created/modified to change default settings " \
-"in Hyperoid. Here are some of the items you can set:" NL \
-NL "[Hyperoid]" NL "Max=<0/1>" NL "{X,Y,W,H}=<n>" NL "Mono=<0/1>" NL \
-"DrawDelay=<ms> ;microseconds/frame" NL \
-NL "[Palette]" NL \
-"{Black,DkGrey,Grey,White," NL \
-" DkRed,Red,DkGreen,Green,DkBlue,Blue," NL \
-" DkYellow,Yellow,DkCyan,Cyan," NL \
-" DkMagenta,Magenta}=<r>,<g>,<b>" NL \
-NL "[Keys]" NL \
-"{Shield,Clockwise,CtrClockwise," NL \
-" Thrust,RevThrust,Fire,Bomb}=<virtual keycode>" NL NL \
-"Note: Virtual keycodes usually match the key's ASCII value."
-
-#define HYPEROID_HELPSTYLE (MB_OK | MB_ICONASTERISK)
-
-// this is the part I especially want in the executable image
-
-#define HYPEROID_LICENSE \
-"This program is free software; you can redistribute it and/or modify " \
-"it under the terms of the GNU General Public License as published by " \
-"the Free Software Foundation; either version 1, or (at your option) " \
-"any later version. " \
-NL NL \
-"This program 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 General Public License for more details. " \
-NL NL \
-"You should have received a copy of the GNU General Public License " \
-"along with this program; if not, write to the Free Software " \
-"Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. "
-
-//
-// imports
-//
-
-IMPORT CHAR szAppName[32] FROM( hyperoid.c );
-IMPORT HANDLE hAppInst FROM( hyperoid.c );
-IMPORT BOOL bBW FROM( hyperoid.c );
-IMPORT INT nDrawDelay FROM( hyperoid.c );
-IMPORT INT vkShld FROM( hyperoid.c );
-IMPORT INT vkClkw FROM( hyperoid.c );
-IMPORT INT vkCtrClkw FROM( hyperoid.c );
-IMPORT INT vkThrst FROM( hyperoid.c );
-IMPORT INT vkRvThrst FROM( hyperoid.c );
-IMPORT INT vkFire FROM( hyperoid.c );
-IMPORT INT vkBomb FROM( hyperoid.c );
-IMPORT LONG lHighScore FROM( hyperoid.c );
-
-//
-// globals
-//
-
-// these parts map to "abcdefghijklm"
-GLOBAL POINT LetterPart[] =
-{
- {83, 572}, {64, 512}, {45, 572}, {96, 362}, {32, 362},
- {128, 256}, {0, 0}, {0, 256},
- {160, 362}, {224, 362}, {173, 572}, {192, 512}, {211, 572}
-};
-// here's the vector font
-GLOBAL NPSTR szNumberDesc[] =
-{
- "cakmck", // 0
- "dbl", // 1
- "abekm", // 2
- "abegjlk", // 3
- "mcfh", // 4
- "cbfgjlk", // 5
- "bdiljgi", // 6
- "acgl", // 7
- "bdjlieb", // 8
- "ljebdge" // 9
-};
-GLOBAL NPSTR szLetterDesc[] =
-{
- "kdbemhf", // A
- "kabegjlk", // B
- "cbflm", // C
- "kabejlk", // D
- "cafgfkm", // E
- "cafgfk", // F
- "bdiljhg", // G
- "kafhcm", // H
- "bl", // I
- "cjli", // J
- "akcgm", // K
- "akm", // L
- "kagcm", // M
- "kamc", // N
- "bdiljeb", // O
- "kabegf", // P
- "mlidbejl", // Q
- "kabegfgm", // R
- "ebdjli", // S
- "lbac", // T
- "ailjc", // U
- "alc", // V
- "akgmc", // W
- "amgkc", // X
- "aglgc", // Y
- "ackm" // Z
-};
-
-//
-// locals
-//
-
-LOCAL CHAR szIni[] = "HYPEROID.INI";
-LOCAL CHAR szLicense[] = "LicenseRead";
-LOCAL CHAR szDrawDelay[] = "DrawDelay";
-LOCAL CHAR szMax[] = "Max";
-LOCAL CHAR szX[] = "X";
-LOCAL CHAR szY[] = "Y";
-LOCAL CHAR szW[] = "W";
-LOCAL CHAR szH[] = "H";
-LOCAL CHAR szBW[] = "Mono";
-LOCAL CHAR szPalette[] = "Palette";
-LOCAL CHAR szKeys[] = "Keys";
-LOCAL CHAR szShield[] = "Shield";
-LOCAL CHAR szClockwise[] = "Clockwise";
-LOCAL CHAR szCtrClockwise[] = "CtrClockwise";
-LOCAL CHAR szThrust[] = "Thrust";
-LOCAL CHAR szRevThrust[] = "RevThrust";
-LOCAL CHAR szFire[] = "Fire";
-LOCAL CHAR szBomb[] = "Bomb";
-LOCAL CHAR szHi[] = "Hi";
-LOCAL CHAR *szColorName[] =
-{
- "Black", "DkGrey", "Grey", "White",
- "DkRed", "Red", "DkGreen", "Green", "DkBlue", "Blue",
- "DkYellow", "Yellow", "DkCyan", "Cyan", "DkMagenta", "Magenta"
-};
-LOCAL DWORD dwColors[] =
-{
- RGB(0,0,0), RGB(128,128,128),
- RGB(192,192,192), RGB(255,255,255),
- RGB(128,0,0), RGB(255,0,0),
- RGB(0,128,0), RGB(0,255,0),
- RGB(0,0,128), RGB(0,0,255),
- RGB(128,128,0), RGB(255,255,0),
- RGB(0,128,128), RGB(0,255,255),
- RGB(128,0,128), RGB(255,0,255),
-};
-
-//
-// PrintLetters - create letter objects from a string
-//
-
-VOID FAR PASCAL PrintLetters( NPSTR npszText, POINT Pos, POINT Vel,
- BYTE byColor, INT nSize )
-{
- INT nLen = strlen( npszText );
- INT nCnt = nLen;
- INT nSpace = nSize + nSize / 2;
- INT nBase = (nLen - 1) * nSpace;
- INT nBaseStart = Pos.x + nBase / 2;
-
- while (nCnt--)
- {
- NPOBJ npLtr = CreateLetter( npszText[nCnt], nSize / 2 );
- if (npLtr)
- {
- npLtr->Pos.x = nBaseStart;
- npLtr->Pos.y = Pos.y;
- npLtr->Vel = Vel;
- npLtr->byColor = byColor;
- }
- nBaseStart -= nSpace;
- }
-}
-
-//
-// SpinLetters - spin letter objects away from center for effect
-//
-
-VOID FAR PASCAL SpinLetters( NPSTR npszText, POINT Pos, POINT Vel,
- BYTE byColor, INT nSize )
-{
- INT nLen = strlen( npszText );
- INT nCnt = nLen;
- INT nSpace = nSize + nSize / 2;
- INT nBase = (nLen - 1) * nSpace;
- INT nBaseStart = Pos.x + nBase / 2;
-
- while (nCnt--)
- {
- NPOBJ npLtr = CreateLetter( npszText[nCnt], nSize / 2 );
- if (npLtr)
- {
- INT nSpin = (nCnt - nLen / 2) * 2;
- npLtr->Pos.x = nBaseStart;
- npLtr->Pos.y = Pos.y;
- npLtr->Vel = Vel;
- npLtr->Vel.x += nSpin * 16;
- npLtr->nSpin = -nSpin;
- npLtr->byColor = byColor;
- }
- nBaseStart -= nSpace;
- }
-}
-
-//
-// CreateHyperoidPalette - create a logical palette
-//
-
-HPALETTE FAR PASCAL CreateHyperoidPalette( VOID )
-{
- HPALETTE hPalette;
- HDC hIC = CreateIC( "DISPLAY", NULL, NULL, NULL );
- INT t;
- PALETTEENTRY Pal[PALETTE_SIZE + 2];
- NPLOGPALETTE npLogPalette = (NPLOGPALETTE)Pal;
-
- // are we forced into using b&w?
- bBW = FALSE;
- if (GetDeviceCaps( hIC, NUMCOLORS ) < 8) bBW = TRUE;
- DeleteDC( hIC );
- if (GetPrivateProfileInt( szAppName, szBW, FALSE, szIni )) bBW = TRUE;
-
- npLogPalette->palVersion = 0x0300;
- npLogPalette->palNumEntries = PALETTE_SIZE;
-
- for (t = 0; t < PALETTE_SIZE; ++t)
- {
- DWORD dwColor = dwColors[t];
- CHAR szBuff[32];
-
- GetPrivateProfileString( szPalette, szColorName[t], "",
- szBuff, sizeof(szBuff), szIni );
- if (szBuff[0])
- {
- INT r, g, b;
- NPSTR npBuff = szBuff;
- r = g = b = 255;
- while (*npBuff == ' ') ++npBuff;
- r = atoi( npBuff );
- while (*npBuff && *npBuff != ',') ++npBuff;
- if (*npBuff == ',') g = atoi( ++npBuff );
- while (*npBuff && *npBuff != ',') ++npBuff;
- if (*npBuff == ',') b = atoi( ++npBuff );
- dwColor = RGB( r, g, b );
- }
- if (bBW) dwColor = ((dwColor == RGB(0,0,0)) ? RGB(0,0,0) : RGB(255,255,255));
- npLogPalette->palPalEntry[t].peRed = GetRValue( dwColor );
- npLogPalette->palPalEntry[t].peGreen = GetGValue( dwColor );
- npLogPalette->palPalEntry[t].peBlue = GetBValue( dwColor );
- npLogPalette->palPalEntry[t].peFlags = 0;
- }
-
- hPalette = CreatePalette( npLogPalette );
- return( hPalette );
-}
-
-//
-// CreateHyperoidClass - create the class of Hyperoid's window
-//
-
-BOOL FAR PASCAL CreateHyperoidClass( VOID )
-{
- WNDCLASS Class;
-
- // load the name from the resource file
- LoadString( hAppInst, IDS_NAME, szAppName, sizeof(szAppName) );
-
- Class.style = CS_HREDRAW | CS_VREDRAW;
- Class.lpfnWndProc = HyperoidWndProc;
- Class.cbClsExtra = 0;
- Class.cbWndExtra = 0;
- Class.hInstance = hAppInst;
- Class.hIcon = NULL;
- Class.hCursor = LoadCursor( NULL, IDC_CROSS );
- Class.hbrBackground = HNULL;
- Class.lpszMenuName = szAppName;
- Class.lpszClassName = szAppName;
-
- return( RegisterClass( &Class ) );
-}
-
-//
-// SetHyperoidMenu - add Hyperoid's menu items to the system menu
-//
-
-VOID NEAR PASCAL SetHyperoidMenu( HWND hWnd, INT nFirstID, INT nLastID )
-{
- CHAR szMenuName[40];
- HMENU hMenu;
-
- hMenu = GetSystemMenu( hWnd, TRUE );
- if (hMenu == HNULL) hMenu = GetSystemMenu( hWnd, FALSE );
- if (hMenu == HNULL) return;
-
- while (nFirstID <= nLastID)
- {
- LoadString( hAppInst, nFirstID, szMenuName, sizeof(szMenuName) );
- ChangeMenu( hMenu, 0, szMenuName, nFirstID, MF_APPEND );
- ++nFirstID;
- }
-}
-
-//
-// CreateHyperoidWindow - open the Hyperoid window
-//
-
-HWND FAR PASCAL CreateHyperoidWindow( LPSTR lpszCmd, INT nCmdShow )
-{
- HWND hWnd;
- INT x, y, w, h;
- CHAR szBuff[32];
-
- // get the highscore profile here for lack of a better place...
- GetPrivateProfileString( szAppName, szHi, "0", szBuff, sizeof(szBuff), szIni );
- lHighScore = atol( szBuff );
-
- x = GetPrivateProfileInt( szAppName, szX, CW_USEDEFAULT, szIni );
- y = GetPrivateProfileInt( szAppName, szY, CW_USEDEFAULT, szIni );
- w = GetPrivateProfileInt( szAppName, szW, CW_USEDEFAULT, szIni );
- h = GetPrivateProfileInt( szAppName, szH, CW_USEDEFAULT, szIni );
- if (GetPrivateProfileInt( szAppName, szMax, FALSE, szIni ) &&
- nCmdShow == SW_NORMAL) nCmdShow = SW_SHOWMAXIMIZED;
-
- hWnd = CreateWindow( szAppName, szAppName, WS_OVERLAPPEDWINDOW,
- x, y, w, h, HNULL, HNULL, hAppInst, NULL );
- if (hWnd == HNULL) return( HNULL );
-
- ShowWindow( hWnd, nCmdShow );
- UpdateWindow( hWnd );
- SetHyperoidMenu( hWnd, IDM_NEW, IDM_ABOUT );
-
- // show the license...
- if (!GetPrivateProfileInt( szAppName, szLicense, FALSE, szIni ))
- {
- MessageBeep( HYPEROID_HELPSTYLE );
- MessageBox( hWnd, HYPEROID_LICENSE, "Hyperoid License", HYPEROID_HELPSTYLE );
- // ...and never show it again (unless they want to see it)
- WritePrivateProfileString( szAppName, szLicense, "1", szIni );
- }
-
- return( hWnd );
-}
-
-//
-// SaveHyperoidWindowPos - write out the .ini information
-//
-
-VOID FAR PASCAL SaveHyperoidWindowPos( HWND hWnd )
-{
- RECT rect;
- CHAR szBuff[32];
-
- // save the highscore profile here for lack of a better place...
- if (lHighScore)
- {
- wsprintf( szBuff, "%lu", lHighScore );
- WritePrivateProfileString( szAppName, szHi, szBuff, szIni );
- }
-
- if (IsIconic( hWnd )) return;
- if (IsZoomed( hWnd ))
- {
- WritePrivateProfileString( szAppName, szMax, "1", szIni );
- return;
- }
- else WritePrivateProfileString( szAppName, szMax, NULL, szIni );
-
- GetWindowRect( hWnd, &rect );
- wsprintf( szBuff, "%d", rect.left );
- WritePrivateProfileString( szAppName, szX, szBuff, szIni );
- wsprintf( szBuff, "%d", rect.top );
- WritePrivateProfileString( szAppName, szY, szBuff, szIni );
- wsprintf( szBuff, "%d", rect.right - rect.left );
- WritePrivateProfileString( szAppName, szW, szBuff, szIni );
- wsprintf( szBuff, "%d", rect.bottom - rect.top );
- WritePrivateProfileString( szAppName, szH, szBuff, szIni );
-}
-
-//
-// GetHyperoidIni - load the ini file information
-//
-
-VOID FAR PASCAL GetHyperoidIni( VOID )
-{
- nDrawDelay = GetPrivateProfileInt( szAppName, szDrawDelay, DRAW_DELAY, szIni );
- vkShld = GetPrivateProfileInt( szKeys, szShield, VK_TAB, szIni );
- vkClkw = GetPrivateProfileInt( szKeys, szClockwise, VK_LEFT, szIni );
- vkCtrClkw = GetPrivateProfileInt( szKeys, szCtrClockwise, VK_RIGHT, szIni );
- vkThrst = GetPrivateProfileInt( szKeys, szThrust, VK_DOWN, szIni );
- vkRvThrst = GetPrivateProfileInt( szKeys, szRevThrust, VK_UP, szIni );
- vkFire = GetPrivateProfileInt( szKeys, szFire, VK_SPACE, szIni );
- vkBomb = GetPrivateProfileInt( szKeys, szBomb, 'S', szIni );
-}
-
-//
-// HyperoidHelp - show help
-//
-
-VOID FAR PASCAL HyperoidHelp( HWND hWnd )
-{
- MessageBox( hWnd, HYPEROID_HELP, "Hyperoid help", HYPEROID_HELPSTYLE );
- MessageBox( hWnd, HYPEROID_HELP2, "Hyperoid.ini help", HYPEROID_HELPSTYLE );
-}
-
-//
-// HyperoidAboutDlg - the about box proc
-//
-
-BOOL FAR PASCAL EXPORT HyperoidAboutDlg( HWND hDlg, WORD mess,
- WORD wParam, LONG lParam )
-{
- switch (mess)
- {
- case WM_INITDIALOG:
- if (lHighScore)
- {
- CHAR szBuff[40];
- wsprintf( szBuff, "High Score: %7.7lu", lHighScore );
- SetDlgItemText( hDlg, IDD_A_HISCORE, szBuff );
- }
- break;
-
- case WM_COMMAND:
- switch (wParam)
- {
- case IDD_A_HELP:
- HyperoidHelp( hDlg );
- // fall through...
- case IDOK:
- EndDialog( hDlg, 0 );
- break;
-
- default:
- return( FALSE );
- }
- break;
-
- case WM_CLOSE:
- EndDialog( hDlg, FALSE );
- break;
-
- default:
- return( FALSE );
- }
- return( TRUE );
-}
-
-//
-// AboutHyperoid - show the about box
-//
-
-VOID FAR PASCAL AboutHyperoid( HWND hWnd )
-{
- FARPROC lpprocAbout = MakeProcInstance( HyperoidAboutDlg, hAppInst );
- DialogBox( hAppInst, INTRES( IDD_ABOUT ), hWnd, lpprocAbout );
- FreeProcInstance( lpprocAbout );
-}
diff --git a/test/hyperoid/score.bmp b/test/hyperoid/score.bmp
deleted file mode 100644
index 73a35f1..0000000
--- a/test/hyperoid/score.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/shield.bmp b/test/hyperoid/shield.bmp
deleted file mode 100644
index d61606b..0000000
--- a/test/hyperoid/shield.bmp
+++ /dev/null
Binary files differ
diff --git a/test/hyperoid/winext.h b/test/hyperoid/winext.h
deleted file mode 100644
index 5694920..0000000
--- a/test/hyperoid/winext.h
+++ /dev/null
@@ -1,109 +0,0 @@
-#if !defined(WINEXT_H)
-#define WINEXT_H
-
-#if defined(__cplusplus)
-extern "C" {
-#endif // __cplusplus
-
-//
-// WINEXT.H - additional windows definitions
-//
-// Version 1.0 03/21/89 Copyright (C) 1989,90,91 Lantern Coroporation.
-// Author: Edward Hutchins
-// Status: Freeware
-// Revisions:
-// 06/06/90 modified HUGE to LARGE to preserve compatibility with math.h
-// also nested windows.h include to prevent modifications on the
-// actual source file - Ed.
-// 10/01/90 added CONST and CONSTP,NP,LP,HP and a few comments - Ed.
-// 08/28/91 added EXPORT and SEGMENT - Ed.
-// 10/28/91 added DLLEXP - Ed.
-// 11/02/91 posted on Compuserve - Ed.
-//
-
-//
-// include WINDOWS.H, if needed
-//
-
-#if !defined(WINDOWS_H)
- #if defined(NULL)
- #undef NULL
- #endif
- #include <windows.h>
- #if !defined(NULL)
- #define NULL 0
- #endif
- #define WINDOWS_H
-#endif // WINDOWS_H
-
-//
-// extra data types and defines
-//
-
-#define LARGE huge
-#define CDECL cdecl
-#define CONST const
-#define HNULL (0)
-#define LPNULL (0L)
-
-typedef char CHAR;
-typedef int INT;
-typedef float FLOAT;
-typedef double DOUBLE;
-typedef long double LDOUBLE;
-
-// extend the string type
-typedef CHAR LARGE *HPSTR;
-
-// useful macros for typedefing pointers to objects //
-#define npointerdef(o) typedef o NEAR * NP ## o
-#define lpointerdef(o) typedef o FAR * LP ## o
-#define hpointerdef(o) typedef o LARGE * HP ## o
-#define pointerdef(o) npointerdef(o); lpointerdef(o); hpointerdef(o)
-
-// define the different kinds of pointers to things //
-pointerdef( BOOL );
-npointerdef( BYTE ); hptrdef( BYTE );
-pointerdef( CHAR );
-npointerdef( INT ); hpointerdef( INT );
-npointerdef( WORD ); hpointerdef( WORD );
-npointerdef( LONG ); hpointerdef( LONG );
-npointerdef( DWORD ); hpointerdef( DWORD );
-pointerdef( FLOAT );
-pointerdef( DOUBLE );
-pointerdef( LDOUBLE );
-npointerdef( HANDLE ); hpointerdef( HANDLE );
-npointerdef( VOID ); hpointerdef( VOID );
-
-// these are here for compatibility - use NPVOID etc...
-typedef VOID NEAR *NPMEM;
-typedef VOID FAR *LPMEM;
-
-// window proc function pointer
-typedef LONG (FAR PASCAL *WNDPROC)( HWND, unsigned, WORD, LONG );
-
-//
-// scope protocol definitions
-//
-
-#define GLOBAL // GLOBAL
-#define LOCAL static
-#define IMPORT extern
-#define FROM(where) // FROM where
-#define PROTO // PROTOTYPE
-
-#define EXPORT _export
-#define SEGMENT _segment
-
-#if defined(__cplusplus)
-}
-#endif // __cplusplus
-
-// c++ class export type
-#if defined(__DLL__)
-#define DLLEXP EXPORT
-#else
-#define DLLEXP LARGE
-#endif
-
-#endif // WINEXT_H
diff --git a/test/martin_ship2/widget.c b/test/martin_ship2/widget.c
new file mode 100755
index 0000000..de7e29a
--- /dev/null
+++ b/test/martin_ship2/widget.c
@@ -0,0 +1,442 @@
+/**********************************************************************
+ * Copyright (c) 1991 by TRG ELECTRONIK *
+ * *
+ * widget.C *
+ * widget Inventory Controler PART # 1 *
+ * *
+ **********************************************************************/
+
+#include <WINDOWS.H>
+#include "STDIO.h"
+#include "STDLIB.h"
+#include "STDARG.h"
+#include "STRING.H"
+
+#include "widget.H"
+#include "widget.VAR"
+#include "widget.P"
+
+#define NoREF(a) a=a
+
+WORD wPlayDiskID;
+
+HWND hWndBut;
+HWND hWndChk;
+HWND hWndRadio;
+HWND hWndLBox;
+HWND hWndScrol;
+HWND hWndScro2;
+HWND hWndStat;
+HWND hWndEdit;
+HWND hWndCBox;
+int x, y;
+
+/**********************************************************************/
+
+
+int PASCAL WinMain(HANDLE hInstance,HANDLE hPrevInstance,
+ LPSTR lpszCmdLine,int nCmdShow)
+{
+WNDCLASS wndClass;
+MSG msg;
+HWND hWnd;
+HDC hDC;
+char C[40];
+int X;
+NoREF(lpszCmdLine);
+if ( !hPrevInstance )
+ {
+ wndClass.style = CS_HREDRAW | CS_VREDRAW ;
+ wndClass.lpfnWndProc = (WNDPROC)WndProc;
+ wndClass.cbClsExtra = 0;
+ wndClass.cbWndExtra = 0;
+ wndClass.hInstance = hInstance;
+ wndClass.hIcon = LoadIcon(hInstance,(LPSTR)"ICON_1");
+ wndClass.hCursor = LoadCursor(NULL, IDC_ARROW );
+ wndClass.hbrBackground = GetStockObject(WHITE_BRUSH );
+ wndClass.lpszMenuName = szAppName;
+ wndClass.lpszClassName = szAppName;
+ if (!RegisterClass(&wndClass))
+ return FALSE;
+ }
+hWnd = CreateWindow(szAppName, "widget test program",
+ WS_POPUP | WS_BORDER | WS_VISIBLE, 50, 50,
+ 400, 400, NULL, NULL, hInstance, NULL);
+hWndMain = hWnd;
+hInst = hInstance;
+hDCMain = GetDC(hWndMain);
+
+InitWidgets();
+
+while (GetMessage(&msg, NULL, 0, 0))
+ {
+ TranslateMessage(&msg );
+ DispatchMessage(&msg );
+ }
+ReleaseDC(hWndMain, hDC);
+return(0);
+}
+
+
+void InitWidgets()
+{
+hWndBut = CreateWindow("BUTTON", "Button #1",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_PUSHBUTTON,
+ 230, 40, 80, 30, hWndMain, 1001, hInst, NULL);
+hWndScrol = CreateWindow("SCROLLBAR", "Scroll #1",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBS_VERT,
+ 200, 140, 15, 100, hWndMain, 1004, hInst, NULL);
+hWndScro2 = CreateWindow("SCROLLBAR", "Scroll #2",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBS_HORZ,
+ 50, 140, 100, 15, hWndMain, 1005, hInst, NULL);
+x = y = 25;
+SetVertScroll(NULL, hWndScrol, 25, 0, 50);
+SetScrollRange(hWndScro2, SB_CTL, 0, 50, TRUE);
+SetScrollPos(hWndScro2, SB_CTL, 25, TRUE);
+hWndLBox = CreateWindow("LISTBOX", "",
+ WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_NOTIFY,
+ 230, 160, 150, 100, hWndMain, 1004, hInst, NULL);
+SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #1");
+}
+
+
+
+long FAR PASCAL WndProc(HWND hWnd, unsigned Message, WORD wParam, LONG lParam)
+{
+int ShiftState;
+char C[80];
+ShiftState = GetKeyState(VK_SHIFT);
+switch(Message)
+ {
+ case WM_COMMAND:
+ if (LOWORD(lParam) != 0)
+ {
+ sprintf(C, "MAIN WM_COMMAND wParam=%X lParam=%lX !!!", wParam, lParam);
+ TextOut(hDCMain, 25, 280, C, strlen(C));
+ }
+ break;
+
+ case WM_KEYDOWN:
+ sprintf(C, "WM_KEYDOWN !!!");
+ TextOut(hDCMain, 25, 40, C, strlen(C));
+ KeyDown(hWnd, Message, wParam);
+ break;
+
+ case WM_CHAR:
+ sprintf(C, "WM_CHAR !!!");
+ TextOut(hDCMain, 25, 50, C, strlen(C));
+ break;
+
+ case WM_LBUTTONDOWN:
+ break;
+
+ case WM_LBUTTONUP:
+ break;
+
+ case WM_RBUTTONDOWN:
+ break;
+
+ case WM_RBUTTONUP:
+ break;
+
+ case WM_MOUSEMOVE:
+ break;
+
+ case WM_VSCROLL:
+ sprintf(C, "WM_VSCROLL %X %X %lX !!!", Message, wParam, lParam);
+ TextOut(hDCMain, 25, 370, C, strlen(C));
+ Do_Dlg_VertScroll(hWnd, wParam, lParam, &y, 0, 50);
+ break;
+
+ case WM_HSCROLL:
+ sprintf(C, "WM_HSCROLL %X %X %lX !!!", Message, wParam, lParam);
+ TextOut(hDCMain, 25, 370, C, strlen(C));
+ Do_Dlg_HorzScroll(hWnd, wParam, lParam, &x, 0, 50);
+ break;
+
+ case WM_PAINT:
+ DoPaint(hWnd);
+ break;
+
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+
+ default:
+ return DefWindowProc(hWnd, Message, wParam, lParam);
+ }
+return(0);
+}
+
+
+
+BOOL KeyDown(HWND hWnd, unsigned Message, WORD wParam)
+{
+WORD wRet;
+UINT uRet;
+DWORD dwRet;
+char C[128];
+char C2[64];
+NoREF(hWnd);
+NoREF(Message);
+sprintf(C, "KeyDown %x !!!", wParam);
+TextOut(hDCMain, 25, 100, C, strlen(C));
+switch (wParam)
+ {
+ case VK_HOME: /* 'HOME' KEY */
+ break;
+ case VK_LEFT: /* 'LEFT' CURSOR KEY */
+ break;
+ case VK_RIGHT: /* 'RIGHT' CURSOR KEY */
+ break;
+ case VK_UP: /* 'UP' CURSOR KEY */
+ break;
+ case VK_DOWN: /* 'DOWN' CURSOR KEY */
+ break;
+ case VK_PRIOR: /* 'PGUP' CURSOR KEY */
+ break;
+ case VK_NEXT: /* 'PGDN' CURSOR KEY */
+ break;
+ case '1':
+ break;
+ case '2':
+ break;
+ case '3':
+ break;
+ case '4':
+ break;
+ case '5':
+ break;
+ case 'A':
+ break;
+ case 'B':
+ break;
+ case 'C':
+ break;
+ case 'D':
+ break;
+ case 'E':
+ break;
+ case 'F':
+ break;
+ case 'G':
+ break;
+ case 'H':
+ WinHelp(hWndMain, "toto.hlp", HELP_INDEX, 0L);
+ break;
+ case 'J':
+ WinExec("/D:/wine/widget.exe arg1 arg2 arg3 arg4 arg5 arg6", SW_NORMAL);
+ break;
+ case 'K':
+ break;
+ case 'Q':
+ hWndStat = CreateWindow("STATIC", "Static #1",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_SIMPLE,
+ 230, 20, 80, 20, hWndMain, 1000, hInst, NULL);
+ break;
+ case 'W':
+ hWndChk = CreateWindow("BUTTON", "CheckBox #1",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_CHECKBOX,
+ 230, 90, 120, 20, hWndMain, 1002, hInst, NULL);
+ break;
+ case 'R':
+ hWndRadio = CreateWindow("BUTTON", "RadioBut #1",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_RADIOBUTTON,
+ 230, 120, 120, 20, hWndMain, 1003, hInst, NULL);
+ SendMessage(hWndRadio, BM_SETCHECK, 0, 0L);
+ break;
+ case 'T':
+ SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox Single item");
+ break;
+ case 'Y':
+ SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #2");
+ SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #3");
+ SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #4");
+ SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #5");
+ SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #6");
+ SendMessage(hWndLBox, LB_SETCURSEL, 3, 0L);
+ SendMessage(hWndLBox, LB_INSERTSTRING, 5, (LPARAM)"Item between 5 & 6");
+ wRet = SendMessage(hWndLBox, LB_FINDSTRING, -1, (LPARAM)"Item between 5 & 6");
+ sprintf(C, "LB_FINDSTRING returned #%u ", wRet);
+ TextOut(hDCMain, 25, 300, C, strlen(C));
+ wRet = SendMessage(hWndLBox, LB_GETCURSEL, 0, 0L);
+ sprintf(C, "LB_GETCURSEL returned #%u ", wRet);
+ TextOut(hDCMain, 25, 320, C, strlen(C));
+ break;
+ case 'U':
+ SendMessage(hWndLBox, LB_DELETESTRING, 3, 0L);
+ break;
+ case 'I':
+ SendMessage(hWndLBox, LB_RESETCONTENT, 0, 0L);
+ break;
+ case 'O':
+ C2[0] = '\0';
+ SendMessage(hWndLBox, LB_GETTEXT, 2, (DWORD)C2);
+ sprintf(C, "LB_GETTEXT returned '%s' ", C2);
+ TextOut(hDCMain, 25, 320, C, strlen(C));
+ break;
+ case 'P':
+ SendMessage(hWndLBox, LB_DIR, 0, (DWORD)"*.*");
+ break;
+ case 'Z':
+ ShowWindow(hWndScrol, SW_HIDE);
+ break;
+ case 'X':
+ ShowWindow(hWndScrol, SW_SHOW);
+ break;
+ case 'V':
+ hWndCBox = CreateWindow("COMBOBOX", "Combo #1",
+ WS_CHILD | WS_VISIBLE | WS_BORDER | CBS_DROPDOWNLIST,
+ 230, 270, 150, 100, hWndMain, 1006, hInst, NULL);
+ SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #1");
+ SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #2");
+ break;
+ case 'N':
+ hWndCBox = CreateWindow("COMBOBOX", "Combo #2",
+ WS_CHILD | WS_VISIBLE | WS_BORDER | CBS_DROPDOWN,
+ 30, 270, 150, 100, hWndMain, 1007, hInst, NULL);
+ SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #1");
+ SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #2");
+ break;
+
+ case VK_F10: /* 'F10' FUNCTION KEY */
+ break;
+ case VK_F11: /* 'F11' FUNCTION KEY */
+ break;
+ }
+return(TRUE);
+}
+
+
+
+void DoPaint(HWND hWnd)
+{
+HDC hDC;
+RECT rect;
+PAINTSTRUCT ps;
+char C[80];
+GetClientRect(hWnd, &rect);
+hDC = BeginPaint(hWnd, &ps);
+FillRect(hDC, &rect, GetStockObject(GRAY_BRUSH));
+InflateRect(&rect, -3, -3);
+FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH));
+InflateRect(&rect, -10, -10);
+FillRect(hDC, &rect, GetStockObject(WHITE_BRUSH));
+sprintf(C, "Wine Testing !!!");
+TextOut(hDC, 25, 25, C, strlen(C));
+ReleaseDC(hWnd,hDC);
+EndPaint(hWnd,&ps);
+}
+
+
+/**********************************************************************/
+
+
+void SetVertScroll(int hDlg, int hWndSCROLL, int VAL, int MIN, int MAX)
+{
+char C[12];
+SetScrollRange(hWndSCROLL, SB_CTL, -MAX, -MIN, FALSE);
+SetScrollPos(hWndSCROLL, SB_CTL, -VAL, TRUE);
+itoa(VAL, C, 10);
+//SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(hWndSCROLL) - IDDSCROLL1), C);
+}
+
+
+
+void SetHorzScroll(int hDlg, int hWndSCROLL, int VAL, int MIN, int MAX)
+{
+char C[12];
+SetScrollRange(hWndSCROLL, SB_CTL, MAX, MIN, FALSE);
+SetScrollPos(hWndSCROLL, SB_CTL, VAL, TRUE);
+itoa(VAL, C, 10);
+//SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(hWndSCROLL) - IDDSCROLL1), C);
+}
+
+
+
+void Do_Dlg_VertScroll(HWND hDlg, WORD wParam, DWORD lParam, int *V, int MIN, int MAX)
+{
+char C[12];
+int VAL;
+int VAL2;
+int Step = 100;
+if (MAX < 1000) Step = 10;
+if (MAX < 100) Step = MAX / 10;
+VAL = *(V);
+VAL2 = VAL;
+switch (wParam)
+ {
+ case SB_LINEUP:
+ VAL++;
+ break;
+ case SB_LINEDOWN:
+ VAL--;
+ break;
+ case SB_PAGEUP:
+ VAL += Step;
+ break;
+ case SB_PAGEDOWN:
+ VAL -= Step;
+ break;
+ case SB_THUMBTRACK:
+ case SB_THUMBPOSITION:
+ VAL = -(LOWORD(lParam));
+ break;
+ }
+if (VAL > MAX) VAL = MAX;
+if (VAL < MIN) VAL = MIN;
+if (VAL != VAL2)
+ {
+ SetScrollPos(HIWORD(lParam), SB_CTL, -VAL, TRUE);
+ ltoa(VAL, C, 10);
+// SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(HIWORD(lParam)) - IDDSCROLL1), C);
+ }
+*(V) = VAL;
+}
+
+
+void Do_Dlg_HorzScroll(HWND hDlg, WORD wParam, DWORD lParam, int *V, int MIN, int MAX)
+{
+char C[12];
+int VAL;
+int VAL2;
+int Step = 100;
+if (MAX < 1000) Step = 10;
+if (MAX < 100) Step = MAX / 10;
+VAL = *(V);
+VAL2 = VAL;
+switch (wParam)
+ {
+ case SB_LINEUP:
+ VAL--;
+ break;
+ case SB_LINEDOWN:
+ VAL++;
+ break;
+ case SB_PAGEUP:
+ VAL -= Step;
+ break;
+ case SB_PAGEDOWN:
+ VAL += Step;
+ break;
+ case SB_THUMBTRACK:
+ case SB_THUMBPOSITION:
+ VAL = (LOWORD(lParam));
+ break;
+ }
+if (VAL > MAX) VAL = MAX;
+if (VAL < MIN) VAL = MIN;
+if (VAL != VAL2)
+ {
+ SetScrollPos(HIWORD(lParam), SB_CTL, VAL, TRUE);
+ ltoa(VAL, C, 10);
+// SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(HIWORD(lParam)) - IDDSCROLL1), C);
+ }
+*(V) = VAL;
+}
+
+
+/**********************************************************************/
+
+
+
\ No newline at end of file
diff --git a/test/martin_ship2/widget.def b/test/martin_ship2/widget.def
new file mode 100755
index 0000000..9a5296b
--- /dev/null
+++ b/test/martin_ship2/widget.def
@@ -0,0 +1,23 @@
+;**********************************************************************
+;* Copyright (c) 1991 by TRG ELECTRONIK *
+;**********************************************************************
+
+
+NAME WineTest
+DESCRIPTION 'Drink Inventry Controler'
+STUB 'WINSTUB.EXE'
+CODE PRELOAD MOVEABLE DISCARDABLE
+DATA PRELOAD MOVEABLE MULTIPLE
+EXETYPE WINDOWS
+SEGMENTS
+ DRINK_TEXT PRELOAD MOVEABLE DISCARDABLE
+
+HEAPSIZE 20000
+STACKSIZE 8192
+
+EXPORTS WndProc @1
+ About_Proc @3
+
+
+
+
\ No newline at end of file
diff --git a/test/martin_ship2/widget.h b/test/martin_ship2/widget.h
new file mode 100755
index 0000000..a0d9f01
--- /dev/null
+++ b/test/martin_ship2/widget.h
@@ -0,0 +1,250 @@
+/**********************************************************************
+* Copyright (c) 1991 by TRG ELECTRONIK *
+**********************************************************************/
+
+#define szAppName "widgetClass"
+
+#define IDNULL -1
+
+#define IDSCLOSE 20
+#define IDSOKCLOSE 21
+#define IDSSAVE 22
+#define IDSOKSAVE 23
+#define IDINFO 24
+#define IDSAVE 25
+#define IDDELETE 26
+#define IDNEW 27
+
+
+#define IDBUSER 30
+#define IDBUSER1 31
+#define IDBUSER2 32
+#define IDBUSER3 33
+#define IDBUSER4 34
+#define IDBUSER5 35
+#define IDBUSER6 36
+#define IDBUSER7 37
+#define IDBUSER8 38
+#define IDBUSER9 39
+
+#define IDDJOBNAME 50
+#define IDDPRINTER 51
+
+#define IDSETUP 60
+
+
+#define IDI_MKSICON 99
+
+/******************************************/
+
+#define MID_NEW 100
+#define MID_OPEN 101
+#define MID_SAVE 102
+#define MID_SAVEAS 103
+#define MID_PRINT 104
+#define MID_PRSETUP 105
+#define MID_STATUS 106
+#define MID_QUIT 107
+
+#define MID_CUT 121
+#define MID_COPY 122
+#define MID_PASTE 123
+#define MID_CLEAR 124
+#define MID_COPYTO 125
+#define MID_PASTEFROM 126
+
+#define MID_NEWPROD 140
+#define MID_NEWBEER 141
+#define MID_USERCFG 142
+
+#define MID_POREGIE 151
+#define MID_POBIERE 152
+#define MID_DAYSTOCK 153
+#define MID_RESERVE 154
+#define MID_COCKSALE 155
+#define MID_DRYSALE 156
+#define MID_COMPILE 157
+#define MID_RECETTES 158
+#define MID_HD 159
+#define MID_TESTPRN 160
+#define MID_INFODSK 161
+#define MID_SHARP 162
+#define MID_PASSWORD 163
+
+/******************************************/
+
+#define IDDTEXT 200
+#define IDDTXT1 201
+#define IDDTXT2 202
+#define IDDTXT3 203
+#define IDDTXT4 204
+#define IDDTXT5 205
+#define IDDTXT6 206
+#define IDDTXT7 207
+#define IDDTXT8 208
+#define IDDTXT9 209
+#define IDDTXT10 210
+#define IDDTXT11 211
+#define IDDTXT12 212
+#define IDDTXT13 213
+#define IDDTXT14 214
+#define IDDTXT15 215
+#define IDDTXT16 216
+#define IDDTXT17 217
+#define IDDTXT18 218
+#define IDDTXT19 219
+
+#define IDDBUTTON1 220
+#define IDDBUTTON2 221
+#define IDDBUTTON3 222
+#define IDDBUTTON4 223
+#define IDDBUTTON5 224
+#define IDDBUTTON6 225
+#define IDDBUTTON7 226
+#define IDDBUTTON8 227
+#define IDDBUTTON9 228
+#define IDDBUTTON10 229
+
+#define IDDCHKBOX1 240
+#define IDDCHKBOX2 241
+#define IDDCHKBOX3 242
+#define IDDCHKBOX4 243
+#define IDDCHKBOX5 244
+#define IDDCHKBOX6 245
+#define IDDCHKBOX7 246
+#define IDDCHKBOX8 247
+#define IDDCHKBOX9 248
+#define IDDCHKBOX10 249
+
+#define IDDSCROLL1 250
+#define IDDSCROLL2 251
+#define IDDSCROLL3 252
+#define IDDSCROLL4 253
+#define IDDSCROLL5 254
+#define IDDSCROLL6 255
+#define IDDSCROLL7 256
+#define IDDSCROLL8 257
+
+#define IDDSTR1 2000
+#define IDDSTR2 2001
+#define IDDSTR3 2002
+#define IDDSTR4 2003
+#define IDDSTR5 2004
+#define IDDSTR6 2005
+#define IDDSTR7 2006
+#define IDDSTR8 2007
+#define IDDSTR9 2008
+#define IDDSTR10 2009
+#define IDDSTR11 2010
+#define IDDSTR12 2011
+#define IDDSTR13 2012
+#define IDDSTR14 2013
+#define IDDSTR15 2014
+#define IDDSTR16 2015
+#define IDDSTR17 2016
+#define IDDSTR18 2017
+#define IDDSTR19 2018
+#define IDDSTR20 2019
+#define IDDSTR21 2020
+#define IDDSTR22 2021
+#define IDDSTR23 2022
+#define IDDSTR24 2023
+#define IDDSTR25 2024
+#define IDDSTR26 2025
+#define IDDSTR27 2026
+#define IDDSTR28 2027
+#define IDDSTR29 2028
+#define IDDSTR30 2029
+#define IDDSTR31 2030
+#define IDDSTR32 2031
+#define IDDSTR33 2032
+#define IDDSTR34 2033
+#define IDDSTR35 2034
+#define IDDSTR36 2035
+#define IDDSTR37 2036
+#define IDDSTR38 2037
+#define IDDSTR39 2038
+#define IDDSTR40 2039
+#define IDDSTR41 2040
+#define IDDSTR42 2041
+#define IDDSTR43 2042
+#define IDDSTR44 2043
+#define IDDSTR45 2044
+#define IDDSTR46 2045
+#define IDDSTR47 2046
+#define IDDSTR48 2047
+#define IDDSTR49 2048
+#define IDDSTR50 2049
+#define IDDSTR51 2050
+#define IDDSTR52 2051
+#define IDDSTR53 2052
+#define IDDSTR54 2053
+#define IDDSTR55 2054
+#define IDDSTR56 2055
+#define IDDSTR57 2056
+#define IDDSTR58 2057
+#define IDDSTR59 2058
+#define IDDSTR60 2059
+#define IDDSTR61 2060
+#define IDDSTR62 2061
+#define IDDSTR63 2062
+#define IDDSTR64 2063
+#define IDDSTR65 2064
+#define IDDSTR66 2065
+#define IDDSTR67 2066
+#define IDDSTR68 2067
+#define IDDSTR69 2068
+#define IDDSTR70 2069
+
+
+/******************************************/
+
+#define IDDDEFAULTS 1001
+#define IDDCHECKBOX 1002
+#define IDDNULL 1003
+#define IDDRBLEFT 1004
+#define IDDRBRIGHT 1005
+#define IDDRBCENTER 1006
+#define IDDLISTBOX 1007
+#define IDDSBH 1008
+#define IDDSBV 1009
+
+/******************************************/
+
+#define ABOUT_Dlg 2001
+#define NEW_Dlg 2002
+#define OPEN_Dlg 2003
+#define SAVE_Dlg 2004
+#define SAVEAS_Dlg 2005
+#define PRINT_Dlg 2006
+#define ABORT_Dlg 2007
+#define PRSETUP_Dlg 2008
+#define QUIT_Dlg 2009
+
+#define GETOBJ_Dlg 2020
+#define NEWPROD_Dlg 2021
+#define NEWBEER_Dlg 2022
+#define USERCFG_Dlg 2023
+#define POREGIE_Dlg 2024
+#define POBIERE_Dlg 2025
+#define PASSWORD_Dlg 2026
+#define TVQ_Dlg 2027
+
+#define LTEXTOK_Dlg 2070
+
+
+/******************************************/
+
+#define RED 0x000000FF
+#define GREEN 0x0000FF00
+#define BLUE 0x00FF0000
+#define CYAN 0x00FFFF00
+#define MAGENTA 0x00FF00FF
+#define BLACK 0x00000000
+#define WHITE 0x00FFFFFF
+#define GRAY 0x00808080
+#define LTGRAY 0x00C0C0C0
+#define DKGRAY 0x00404040
+
+
+
\ No newline at end of file
diff --git a/test/martin_ship2/widget.ic2 b/test/martin_ship2/widget.ic2
new file mode 100755
index 0000000..3e0e0d5
--- /dev/null
+++ b/test/martin_ship2/widget.ic2
Binary files differ
diff --git a/test/martin_ship2/widget.ic3 b/test/martin_ship2/widget.ic3
new file mode 100755
index 0000000..db642dc
--- /dev/null
+++ b/test/martin_ship2/widget.ic3
Binary files differ
diff --git a/test/martin_ship2/widget.ico b/test/martin_ship2/widget.ico
new file mode 100755
index 0000000..824d52d
--- /dev/null
+++ b/test/martin_ship2/widget.ico
Binary files differ
diff --git a/test/martin_ship2/widget.rc b/test/martin_ship2/widget.rc
new file mode 100755
index 0000000..5a86c23
--- /dev/null
+++ b/test/martin_ship2/widget.rc
@@ -0,0 +1,78 @@
+/**********************************************************************
+ * Copyright (c) 1991 by TRG ELECTRONIK *
+ * *
+ * widget.RC *
+ * widget RESSOURCES *
+ * *
+ **********************************************************************/
+
+#include <\BC\INCLUDE\WINDOWS.H>
+#include "widget.H"
+
+#define TABGRP WS_TABSTOP | WS_GROUP
+#define LBSTYLES WS_VSCROLL | WS_BORDER | WS_VISIBLE | LBS_SORT | TABGRP
+#define HSCROLL WS_VISIBLE | SBS_HORZ | SBS_TOPALIGN | TABGRP
+#define VSCROLL WS_VISIBLE | SBS_VERT | SBS_LEFTALIGN | TABGRP
+#define BLACKRECT SS_BLACKRECT | WS_VISIBLE | WS_GROUP
+#define WHITEFRAME SS_WHITEFRAME | WS_VISIBLE | WS_GROUP
+
+
+ICON_1 ICON widget.ICO
+ICON_2 ICON widget.IC2
+ICON_3 ICON widget.IC3
+
+MENU_1 MENU
+BEGIN
+ POPUP "&File"
+ BEGIN
+ MENUITEM "&New", MID_NEW
+ MENUITEM "&Open", MID_OPEN
+ MENUITEM "&Save", MID_SAVE
+ MENUITEM "Save &As", MID_SAVEAS
+ MENUITEM SEPARATOR
+ MENUITEM "&Quit!", MID_QUIT
+ END
+END
+
+
+
+
+ABOUT_Dlg DIALOG 100, 100, 154, 75
+STYLE WS_POPUP | WS_DLGFRAME
+BEGIN
+ ICON "widget" -1, 9, 23, 0, 0
+ ICON "DKICON2" -1, 30, 23, 0, 0
+ ICON "DKICON3" -1, 50, 23, 0, 0
+ CTEXT "About widget Inventory Controler" -1, 0, 14,154, 8
+ CTEXT "Version 0.50" -1, 30, 34, 94, 8
+ CTEXT "Copyright © 1991, TRG Electronik" -1, 0, 47,154, 9
+ DEFPUSHBUTTON "Ok" IDOK, 61, 59, 32, 14, WS_GROUP
+END
+
+
+LTEXTOK_Dlg DIALOG 100, 100, 300, 120
+STYLE WS_POPUP | WS_DLGFRAME
+BEGIN
+ LTEXT "", IDDTXT1, 20, 15,118, 12
+ LTEXT "", IDDTXT2, 20, 30,118, 25
+ LTEXT "", IDDTXT3, 20, 45,118, 35
+ LTEXT "", IDDTXT3, 20, 60,118, 35
+ DEFPUSHBUTTON "OK", IDOK, 150, 85, 40, 14, TABGRP
+END
+
+
+STRINGTABLE
+BEGIN
+IDDSTR1, "Wine Test Program"
+IDDSTR2, ""
+IDDSTR3, ""
+IDDSTR4, ""
+IDDSTR5, ""
+IDDSTR6, ""
+IDDSTR7, ""
+IDDSTR8, ""
+IDDSTR9, ""
+IDDSTR10, ""
+END
+
+
\ No newline at end of file
diff --git a/test/martin_ship4/widget.c b/test/martin_ship4/widget.c
new file mode 100755
index 0000000..4d2dfcf
--- /dev/null
+++ b/test/martin_ship4/widget.c
@@ -0,0 +1,649 @@
+/**********************************************************************
+ * Copyright (c) 1991 by TRG ELECTRONIK *
+ * *
+ * widget.C *
+ * widget Inventory Controler PART # 1 *
+ * *
+ **********************************************************************/
+
+#include <WINDOWS.H>
+#include "STDIO.h"
+#include "STDLIB.h"
+#include "STDARG.h"
+#include "STRING.H"
+
+#include "widget.H"
+#include "widget.VAR"
+#include "widget.P"
+
+#define NoREF(a) a=a
+
+HWND hWndBut;
+HWND hWndChk;
+HWND hWndRadio;
+HWND hWndLBox;
+HWND hWndLBox2;
+HWND hWndLBox3;
+HWND hWndLBox4;
+HWND hWndScrol;
+HWND hWndScro2;
+HWND hWndScro3;
+HWND hWndStat;
+HWND hWndEdit;
+HWND hWndCBox;
+int x, y;
+
+HBRUSH hREDBrush;
+HBRUSH hGREENBrush;
+HBRUSH hBLUEBrush;
+HBRUSH hGRAYBrush;
+HBITMAP hBitMap;
+HBITMAP hBitMap2;
+HBITMAP hBitMap3;
+BITMAP BitMap;
+
+/**********************************************************************/
+
+
+int PASCAL WinMain(HANDLE hInstance,HANDLE hPrevInstance,
+ LPSTR lpszCmdLine,int nCmdShow)
+{
+WNDCLASS wndClass;
+MSG msg;
+HWND hWnd;
+HDC hDC;
+char C[40];
+int X;
+NoREF(lpszCmdLine);
+if ( !hPrevInstance )
+ {
+ wndClass.style = CS_HREDRAW | CS_VREDRAW ;
+ wndClass.lpfnWndProc = (WNDPROC)WndProc;
+ wndClass.cbClsExtra = 0;
+ wndClass.cbWndExtra = 0;
+ wndClass.hInstance = hInstance;
+ wndClass.hIcon = LoadIcon(hInstance,(LPSTR)"ICON_1");
+ wndClass.hCursor = LoadCursor(NULL, IDC_ARROW );
+ wndClass.hbrBackground = GetStockObject(WHITE_BRUSH );
+ wndClass.lpszMenuName = szAppName;
+ wndClass.lpszClassName = szAppName;
+ if (!RegisterClass(&wndClass))
+ return FALSE;
+ }
+hWnd = CreateWindow(szAppName, "widget test program",
+ WS_POPUP | WS_CAPTION | WS_BORDER | WS_VISIBLE, 50, 50,
+ 400, 500, NULL, NULL, hInstance, NULL);
+hWndMain = hWnd;
+hInst = hInstance;
+hDCMain = GetDC(hWndMain);
+hREDBrush = CreateSOLIDBrush(0x000000FF);
+hGREENBrush = CreateSOLIDBrush(0x00007F00);
+hBLUEBrush = CreateSOLIDBrush(0x00FF0000);
+hGRAYBrush = CreateSOLIDBrush(0x00C0C0C0);
+
+InitWidgets();
+
+while (GetMessage(&msg, NULL, 0, 0))
+ {
+ TranslateMessage(&msg );
+ DispatchMessage(&msg );
+ }
+DeleteObject(hREDBrush);
+DeleteObject(hGREENBrush);
+DeleteObject(hBLUEBrush);
+DeleteObject(hGRAYBrush);
+if (hBitMap != NULL) DeleteObject(hBitMap);
+if (hBitMap2 != NULL) DeleteObject(hBitMap2);
+if (hBitMap3 != NULL) DeleteObject(hBitMap3);
+ReleaseDC(hWndMain, hDC);
+return(0);
+}
+
+
+void InitWidgets()
+{
+hWndBut = CreateWindow("BUTTON", "Button #1",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_PUSHBUTTON,
+ 230, 40, 80, 30, hWndMain, 1001, hInst, NULL);
+hWndScrol = CreateWindow("SCROLLBAR", "Scroll #1",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBS_VERT,
+ 200, 150, 15, 100, hWndMain, 1004, hInst, NULL);
+hWndScro2 = CreateWindow("SCROLLBAR", "Scroll #2",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBS_HORZ,
+ 50, 150, 100, 15, hWndMain, 1005, hInst, NULL);
+hWndScro3 = CreateWindow("SCROLLBAR", "Scroll #3",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBS_SIZEBOX,
+ 50, 180, 25, 25, hWndMain, 1006, hInst, NULL);
+x = y = 25;
+SetVertScroll(NULL, hWndScrol, 25, 0, 50);
+SetScrollRange(hWndScro2, SB_CTL, 0, 50, TRUE);
+SetScrollPos(hWndScro2, SB_CTL, 25, TRUE);
+hWndLBox = CreateWindow("LISTBOX", "",
+ WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_NOTIFY,
+ 230, 160, 150, 100, hWndMain, 1004, hInst, NULL);
+SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #1");
+hWndStat = CreateWindow("STATIC", "Static #1",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_LEFT,
+ 30, 120, 150, 20, hWndMain, 1011, hInst, NULL);
+SendMessage(hWndStat, WM_SETTEXT, 0, (LPARAM)"Static Left Text");
+hWndCBox = CreateWindow("COMBOBOX", "Combo #1",
+ WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | CBS_DROPDOWNLIST,
+ 230, 270, 150, 100, hWndMain, 1060, hInst, NULL);
+SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #1");
+SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #2");
+SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #3");
+SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #4");
+SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #5");
+SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #6");
+}
+
+
+
+long FAR PASCAL WndProc(HWND hWnd, unsigned Message, WORD wParam, LONG lParam)
+{
+int ShiftState;
+LPDRAWITEMSTRUCT dis;
+HDC hMemDC;
+HBRUSH hBrush;
+char C[128];
+ShiftState = GetKeyState(VK_SHIFT);
+switch(Message)
+ {
+ case WM_COMMAND:
+ if (LOWORD(lParam) != 0)
+ {
+ sprintf(C, "MAIN WM_COMMAND wParam=%X lParam=%lX !!!", wParam, lParam);
+ TextOut(hDCMain, 25, 280, C, strlen(C));
+ }
+ break;
+
+ case WM_KEYDOWN:
+ sprintf(C, "WM_KEYDOWN !!!");
+ TextOut(hDCMain, 25, 40, C, strlen(C));
+ KeyDown(hWnd, Message, wParam);
+ break;
+
+ case WM_CHAR:
+ sprintf(C, "WM_CHAR !!!");
+ TextOut(hDCMain, 25, 50, C, strlen(C));
+ break;
+
+ case WM_CTLCOLOR:
+ switch(HIWORD(lParam))
+ {
+ case CTLCOLOR_SCROLLBAR:
+ return(hBLUEBrush);
+ case CTLCOLOR_LISTBOX:
+ SetBkColor((HDC)wParam, 0x00C0C000);
+ SetTextColor((HDC)wParam, 0x00FF0000);
+ return(hGREENBrush);
+ case CTLCOLOR_STATIC:
+ SetBkColor((HDC)wParam, 0x00C0C0C0);
+ SetTextColor((HDC)wParam, 0x0000FFFF);
+ return(hREDBrush);
+ }
+ return((HBRUSH)NULL);
+
+ case WM_LBUTTONDOWN:
+ break;
+
+ case WM_LBUTTONUP:
+ break;
+
+ case WM_RBUTTONDOWN:
+ break;
+
+ case WM_RBUTTONUP:
+ break;
+
+ case WM_MOUSEMOVE:
+ break;
+
+ case WM_VSCROLL:
+ sprintf(C, "WM_VSCROLL %X %lX !!!", wParam, lParam);
+ TextOut(hDCMain, 25, 380, C, strlen(C));
+ Do_Dlg_VertScroll(hWnd, wParam, lParam, &y, 0, 50);
+ break;
+
+ case WM_HSCROLL:
+ sprintf(C, "WM_HSCROLL %X %lX !!!", wParam, lParam);
+ TextOut(hDCMain, 25, 380, C, strlen(C));
+ Do_Dlg_HorzScroll(hWnd, wParam, lParam, &x, 0, 50);
+ break;
+
+ case WM_DRAWITEM:
+ sprintf(C, "WM_DRAWITEM %X %lX !!!", wParam, lParam);
+ TextOut(hDCMain, 25, 380, C, strlen(C));
+ if (lParam == 0L) break;
+ if (wParam == 0) break;
+ dis = (LPDRAWITEMSTRUCT)lParam;
+ if ((dis->CtlType == ODT_LISTBOX) && (dis->CtlID == 1062)) {
+ hBrush = SelectObject(dis->hDC, GetStockObject(LTGRAY_BRUSH));
+ SelectObject(dis->hDC, hBrush);
+ FillRect(dis->hDC, &dis->rcItem, hBrush);
+ sprintf(C, "Item #%X", dis->itemID);
+ if (dis->itemData == NULL) break;
+ TextOut(dis->hDC, dis->rcItem.left,
+ dis->rcItem.top, C, strlen(C));
+ }
+ if ((dis->CtlType == ODT_LISTBOX) && (dis->CtlID == 1063)) {
+ hBrush = SelectObject(dis->hDC, GetStockObject(LTGRAY_BRUSH));
+ SelectObject(dis->hDC, hBrush);
+ FillRect(dis->hDC, &dis->rcItem, hBrush);
+ if (dis->itemData == NULL) break;
+ TextOut(dis->hDC, dis->rcItem.left, dis->rcItem.top,
+ (LPSTR)dis->itemData, lstrlen((LPSTR)dis->itemData));
+ }
+ if ((dis->CtlType == ODT_LISTBOX) && (dis->CtlID == 1064)) {
+ hBrush = SelectObject(dis->hDC, GetStockObject(LTGRAY_BRUSH));
+ SelectObject(dis->hDC, hBrush);
+ FillRect(dis->hDC, &dis->rcItem, hBrush);
+ hMemDC = CreateCompatibleDC(dis->hDC);
+ SelectObject(hMemDC,hBitMap);
+ BitBlt(dis->hDC, dis->rcItem.left, dis->rcItem.top,
+ BitMap.bmWidth, BitMap.bmHeight, hMemDC, 0, 0, SRCCOPY);
+ DeleteDC(hMemDC);
+ sprintf(C, "Item #%X", dis->itemID);
+ TextOut(dis->hDC, dis->rcItem.left + BitMap.bmWidth,
+ dis->rcItem.top, C, strlen(C));
+// if (dis->itemData == NULL) break;
+// TextOut(dis->hDC, dis->rcItem.left + BitMap.bmWidth,
+// dis->rcItem.top, (LPSTR)dis->itemData,
+// lstrlen((LPSTR)dis->itemData));
+ }
+ break;
+
+ case WM_PAINT:
+ DoPaint(hWnd);
+ break;
+
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+
+ default:
+ return DefWindowProc(hWnd, Message, wParam, lParam);
+ }
+return(0);
+}
+
+
+
+BOOL KeyDown(HWND hWnd, unsigned Message, WORD wParam)
+{
+WORD wRet;
+UINT uRet;
+DWORD dwRet;
+HDC hMemDC;
+char C[128];
+char C2[64];
+NoREF(hWnd);
+NoREF(Message);
+sprintf(C, "KeyDown %x !!!", wParam);
+TextOut(hDCMain, 25, 100, C, strlen(C));
+switch (wParam)
+ {
+ case VK_HOME: /* 'HOME' KEY */
+ break;
+ case VK_LEFT: /* 'LEFT' CURSOR KEY */
+ break;
+ case VK_RIGHT: /* 'RIGHT' CURSOR KEY */
+ break;
+ case VK_UP: /* 'UP' CURSOR KEY */
+ break;
+ case VK_DOWN: /* 'DOWN' CURSOR KEY */
+ break;
+ case VK_PRIOR: /* 'PGUP' CURSOR KEY */
+ break;
+ case VK_NEXT: /* 'PGDN' CURSOR KEY */
+ break;
+ case '1':
+ break;
+ case '2':
+ hWndStat = CreateWindow("STATIC", "Static #2",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_CENTER,
+ 30, 150, 150, 20, hWndMain, 1012, hInst, NULL);
+ SendMessage(hWndStat, WM_SETTEXT, 0, (LPARAM)"Static Center Text");
+ break;
+ case '3':
+ hWndStat = CreateWindow("STATIC", "Static #3",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT,
+ 30, 180, 150, 20, hWndMain, 1013, hInst, NULL);
+ SendMessage(hWndStat, WM_SETTEXT, 0, (LPARAM)"Static Right Text");
+ break;
+ case '4':
+ hWndStat = CreateWindow("STATIC", "Static #4",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_SIMPLE,
+ 30, 210, 150, 20, hWndMain, 1014, hInst, NULL);
+ SendMessage(hWndStat, WM_SETTEXT, 0, (LPARAM)"SS_SIMPLE");
+ break;
+ case '5':
+ hWndStat = CreateWindow("STATIC", "Static #5",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_GRAYRECT,
+ 30, 240, 150, 20, hWndMain, 1015, hInst, NULL);
+ SendMessage(hWndStat, WM_SETTEXT, 0, (LPARAM)"SS_GRAYRECT");
+ break;
+ case 'A':
+ hWndStat = CreateWindow("STATIC", "Static #6",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_BLACKRECT,
+ 30, 240, 150, 20, hWndMain, 1016, hInst, NULL);
+ SendMessage(hWndStat, WM_SETTEXT, 0, (LPARAM)"SS_BLACKRECT");
+ break;
+ case 'C':
+ if (hBitMap2 == NULL) {
+ hBitMap2 = LoadBitmap(hInst, "LBICON");
+ GetObject(hBitMap2, sizeof(BITMAP), (LPSTR)&BitMap);
+ }
+ hMemDC = CreateCompatibleDC(hDCMain);
+ SelectObject(hMemDC, hBitMap2);
+ BitBlt(hDCMain, 10, 10, BitMap.bmWidth,
+ BitMap.bmHeight, hMemDC, 0, 0, SRCCOPY);
+ DeleteDC(hMemDC);
+ sprintf(C, "DrawBitmap");
+ TextOut(hDCMain, 25, 320, C, strlen(C));
+ break;
+ case 'D':
+ if (hBitMap3 == NULL) {
+ hBitMap3 = LoadBitmap(hInst, MAKEINTRESOURCE(3333));
+ GetObject(hBitMap3, sizeof(BITMAP), (LPSTR)&BitMap);
+ }
+ hMemDC = CreateCompatibleDC(hDCMain);
+ SelectObject(hMemDC, hBitMap3);
+ BitBlt(hDCMain, 80, 10, BitMap.bmWidth,
+ BitMap.bmHeight, hMemDC, 0, 0, SRCCOPY);
+ DeleteDC(hMemDC);
+ sprintf(C, "DrawBitmap");
+ TextOut(hDCMain, 25, 320, C, strlen(C));
+ break;
+ case 'F':
+ MoveWindow(hWnd, 10, 10, 500, 600, TRUE);
+ break;
+ case 'G':
+ MoveWindow(hWndBut, 20, 20, 100, 20, TRUE);
+ break;
+ case 'H':
+ WinHelp(hWndMain, "toto.hlp", HELP_INDEX, 0L);
+ break;
+ case 'J':
+ WinExec("/D:/wine/widget.exe arg1 arg2 arg3 arg4 arg5 arg6", SW_NORMAL);
+ break;
+ case 'K':
+ break;
+ case 'Q':
+ hWndChk = CreateWindow("BUTTON", "CheckBox #1",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_CHECKBOX,
+ 30, 300, 120, 20, hWndMain, 1020, hInst, NULL);
+ break;
+ case 'W':
+ wRet = SendMessage(hWndChk , BM_GETCHECK, 0, 0L);
+ SendMessage(hWndChk , BM_SETCHECK, wRet, 0L);
+ break;
+ case 'E':
+ break;
+ case 'R':
+ hWndRadio = CreateWindow("BUTTON", "RadioBut #1",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_RADIOBUTTON,
+ 230, 120, 120, 20, hWndMain, 1003, hInst, NULL);
+ SendMessage(hWndRadio, BM_SETCHECK, TRUE, 0L);
+ break;
+ case 'T':
+ SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox Single item");
+ break;
+ case 'Y':
+ SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #2");
+ SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #3");
+ SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #4");
+ SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #5");
+ SendMessage(hWndLBox, LB_ADDSTRING, 0, (LPARAM)"ListBox item #6");
+ SendMessage(hWndLBox, LB_SETCURSEL, 3, 0L);
+ SendMessage(hWndLBox, LB_INSERTSTRING, 5, (LPARAM)"Item between 5 & 6");
+ wRet = SendMessage(hWndLBox, LB_FINDSTRING, -1, (LPARAM)"Item between 5 & 6");
+ sprintf(C, "LB_FINDSTRING returned #%u ", wRet);
+ TextOut(hDCMain, 25, 300, C, strlen(C));
+ wRet = SendMessage(hWndLBox, LB_GETCURSEL, 0, 0L);
+ sprintf(C, "LB_GETCURSEL returned #%u ", wRet);
+ TextOut(hDCMain, 25, 320, C, strlen(C));
+ break;
+ case 'U':
+ wRet = SendMessage(hWndLBox, LB_GETCURSEL, 0, 0L);
+ SendMessage(hWndLBox, LB_DELETESTRING, wRet, 0L);
+ SendMessage(hWndLBox, LB_SETCURSEL, wRet, 0L);
+ break;
+ case 'I':
+ SendMessage(hWndLBox, LB_RESETCONTENT, 0, 0L);
+ break;
+ case 'O':
+ C2[0] = '\0';
+ wRet = SendMessage(hWndLBox, LB_GETCURSEL, 0, 0L);
+ SendMessage(hWndLBox, LB_GETTEXT, wRet, (DWORD)C2);
+ sprintf(C, "LB_GETTEXT #%d returned '%s' ", wRet, C2);
+ TextOut(hDCMain, 25, 320, C, strlen(C));
+ break;
+ case 'P':
+ SendMessage(hWndLBox, LB_DIR, 0, (DWORD)"*.*");
+ break;
+ case 'Z':
+ ShowWindow(hWndScrol, SW_HIDE);
+ break;
+ case 'X':
+ ShowWindow(hWndScrol, SW_SHOW);
+ break;
+ case 'V':
+ MoveWindow(hWndScrol, 120, 150, 15, 60, TRUE);
+ break;
+ case 'B':
+ hWndCBox = CreateWindow("COMBOBOX", "Combo #2",
+ WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | CBS_DROPDOWN,
+ 30, 270, 150, 100, hWndMain, 1061, hInst, NULL);
+ SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #1");
+ SendMessage(hWndCBox, CB_ADDSTRING, 0, (LPARAM)"ComboBox item #2");
+ SendMessage(hWndCBox, CB_DIR, 0, (DWORD)"*.*");
+ break;
+ case 'N':
+ hWndLBox2 = CreateWindow("LISTBOX", "", WS_CHILD | WS_VISIBLE |
+ WS_BORDER | WS_VSCROLL | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY,
+// WS_BORDER | WS_VSCROLL | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | LBS_NOTIFY,
+ 30, 300, 150, 60, hWndMain, 1062, hInst, NULL);
+ SendMessage(hWndLBox2, LB_ADDSTRING, 0, (LPARAM)"DRAWFIXED #1");
+ SendMessage(hWndLBox2, LB_ADDSTRING, 0, (LPARAM)"DRAWFIXED #2");
+ SendMessage(hWndLBox2, LB_ADDSTRING, 0, (LPARAM)"DRAWFIXED #3");
+ SendMessage(hWndLBox2, LB_ADDSTRING, 0, (LPARAM)"DRAWFIXED #4");
+ SendMessage(hWndLBox2, LB_ADDSTRING, 0, (LPARAM)"DRAWFIXED #5");
+ SendMessage(hWndLBox2, LB_ADDSTRING, 0, (LPARAM)"DRAWFIXED #6");
+ break;
+ case 'M':
+ hWndLBox3 = CreateWindow("LISTBOX", "", WS_CHILD | WS_VISIBLE |
+ WS_BORDER | WS_VSCROLL | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY,
+// WS_BORDER | WS_VSCROLL | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | LBS_NOTIFY,
+ 230, 300, 150, 60, hWndMain, 1063, hInst, NULL);
+ SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #1");
+ SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #2");
+ SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #3");
+ SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #4");
+ SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #5");
+ SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #6");
+ SendMessage(hWndLBox3, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #7");
+ SendMessage(hWndLBox3, LB_SETITEMHEIGHT, 1, 10L);
+ SendMessage(hWndLBox3, LB_SETITEMHEIGHT, 2, 20L);
+ SendMessage(hWndLBox3, LB_SETITEMHEIGHT, 3, 30L);
+ SendMessage(hWndLBox3, LB_SETITEMHEIGHT, 4, 40L);
+ SendMessage(hWndLBox3, LB_SETITEMHEIGHT, 5, 50L);
+ break;
+ case 'L':
+ hBitMap = LoadBitmap(hInst, MAKEINTRESOURCE(3333));
+ GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&BitMap);
+ hWndLBox4 = CreateWindow("LISTBOX", "", WS_CHILD | WS_VISIBLE |
+ WS_BORDER | WS_VSCROLL | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | LBS_NOTIFY,
+ 230, 380, 150, 60, hWndMain, 1064, hInst, NULL);
+ SendMessage(hWndLBox4, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #1");
+ SendMessage(hWndLBox4, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #2");
+ SendMessage(hWndLBox4, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #3");
+ SendMessage(hWndLBox4, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #4");
+ SendMessage(hWndLBox4, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #5");
+ SendMessage(hWndLBox4, LB_ADDSTRING, 0, (LPARAM)"DRAWVARIABLE #6");
+ SendMessage(hWndLBox4, LB_SETITEMHEIGHT, 1, 10L);
+ SendMessage(hWndLBox4, LB_SETITEMHEIGHT, 2, 20L);
+ SendMessage(hWndLBox4, LB_SETITEMHEIGHT, 3, 30L);
+ SendMessage(hWndLBox4, LB_SETITEMHEIGHT, 4, 40L);
+ SendMessage(hWndLBox4, LB_SETITEMHEIGHT, 5, 50L);
+ break;
+
+ case VK_F10: /* 'F10' FUNCTION KEY */
+ break;
+ case VK_F11: /* 'F11' FUNCTION KEY */
+ break;
+ }
+return(TRUE);
+}
+
+
+
+void DoPaint(HWND hWnd)
+{
+HDC hDC;
+RECT rect;
+PAINTSTRUCT ps;
+char C[80];
+GetClientRect(hWnd, &rect);
+hDC = BeginPaint(hWnd, &ps);
+FillRect(hDC, &rect, GetStockObject(GRAY_BRUSH));
+InflateRect(&rect, -3, -3);
+FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH));
+InflateRect(&rect, -10, -10);
+FillRect(hDC, &rect, GetStockObject(WHITE_BRUSH));
+sprintf(C, "Wine Testing !!!");
+TextOut(hDC, 25, 25, C, strlen(C));
+ReleaseDC(hWnd,hDC);
+EndPaint(hWnd,&ps);
+}
+
+
+HBRUSH CreateLTGRAYBrush()
+{
+return(CreateSOLIDBrush(0x00C0C0C0));
+}
+
+
+
+HBRUSH CreateSOLIDBrush(COLORREF Color)
+{
+LOGBRUSH logGRAYBrush;
+logGRAYBrush.lbStyle = BS_SOLID;
+logGRAYBrush.lbColor = Color;
+logGRAYBrush.lbHatch = NULL;
+return(CreateBrushIndirect(&logGRAYBrush));
+}
+
+
+
+/**********************************************************************/
+
+
+void SetVertScroll(int hDlg, int hWndSCROLL, int VAL, int MIN, int MAX)
+{
+char C[12];
+SetScrollRange(hWndSCROLL, SB_CTL, -MAX, -MIN, FALSE);
+SetScrollPos(hWndSCROLL, SB_CTL, -VAL, TRUE);
+itoa(VAL, C, 10);
+//SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(hWndSCROLL) - IDDSCROLL1), C);
+}
+
+
+
+void SetHorzScroll(int hDlg, int hWndSCROLL, int VAL, int MIN, int MAX)
+{
+char C[12];
+SetScrollRange(hWndSCROLL, SB_CTL, MAX, MIN, FALSE);
+SetScrollPos(hWndSCROLL, SB_CTL, VAL, TRUE);
+itoa(VAL, C, 10);
+//SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(hWndSCROLL) - IDDSCROLL1), C);
+}
+
+
+
+void Do_Dlg_VertScroll(HWND hDlg, WORD wParam, DWORD lParam, int *V, int MIN, int MAX)
+{
+char C[12];
+int VAL;
+int VAL2;
+int Step = 100;
+if (MAX < 1000) Step = 10;
+if (MAX < 100) Step = MAX / 10;
+VAL = *(V);
+VAL2 = VAL;
+switch (wParam)
+ {
+ case SB_LINEUP:
+ VAL++;
+ break;
+ case SB_LINEDOWN:
+ VAL--;
+ break;
+ case SB_PAGEUP:
+ VAL += Step;
+ break;
+ case SB_PAGEDOWN:
+ VAL -= Step;
+ break;
+ case SB_THUMBTRACK:
+ case SB_THUMBPOSITION:
+ VAL = -(LOWORD(lParam));
+ break;
+ }
+if (VAL > MAX) VAL = MAX;
+if (VAL < MIN) VAL = MIN;
+if (VAL != VAL2)
+ {
+ SetScrollPos(HIWORD(lParam), SB_CTL, -VAL, TRUE);
+ ltoa(VAL, C, 10);
+// SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(HIWORD(lParam)) - IDDSCROLL1), C);
+ }
+*(V) = VAL;
+}
+
+
+void Do_Dlg_HorzScroll(HWND hDlg, WORD wParam, DWORD lParam, int *V, int MIN, int MAX)
+{
+char C[12];
+int VAL;
+int VAL2;
+int Step = 100;
+if (MAX < 1000) Step = 10;
+if (MAX < 100) Step = MAX / 10;
+VAL = *(V);
+VAL2 = VAL;
+switch (wParam)
+ {
+ case SB_LINEUP:
+ VAL--;
+ break;
+ case SB_LINEDOWN:
+ VAL++;
+ break;
+ case SB_PAGEUP:
+ VAL -= Step;
+ break;
+ case SB_PAGEDOWN:
+ VAL += Step;
+ break;
+ case SB_THUMBTRACK:
+ case SB_THUMBPOSITION:
+ VAL = (LOWORD(lParam));
+ break;
+ }
+if (VAL > MAX) VAL = MAX;
+if (VAL < MIN) VAL = MIN;
+if (VAL != VAL2)
+ {
+ SetScrollPos(HIWORD(lParam), SB_CTL, VAL, TRUE);
+ ltoa(VAL, C, 10);
+// SetDlgItemText(hDlg, (IDDTXT1 + GetDlgCtrlID(HIWORD(lParam)) - IDDSCROLL1), C);
+ }
+*(V) = VAL;
+}
+
+
+/**********************************************************************/
+
+
+
\ No newline at end of file
diff --git a/test/martin_ship4/widget.exe b/test/martin_ship4/widget.exe
new file mode 100755
index 0000000..91ecd00
--- /dev/null
+++ b/test/martin_ship4/widget.exe
Binary files differ
diff --git a/test/widget.exe b/test/widget.exe
new file mode 100755
index 0000000..89837d5
--- /dev/null
+++ b/test/widget.exe
Binary files differ
diff --git a/tools/Makefile b/tools/Makefile
index 8e5766f..f74628e 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -4,7 +4,7 @@
cc $(CFLAGS) -o build build.c
clean:
- rm -f *.o *~ build
+ rm -f *.o *~ build *#
depend:
$(CC) $(CFLAGS) -M *.c > .depend
diff --git a/tools/build.c b/tools/build.c
index d13c717..d596493 100644
--- a/tools/build.c
+++ b/tools/build.c
@@ -667,6 +667,35 @@
fprintf(fp, "_%s_Ordinal_%d:\n", UpperDLLName, i);
fprintf(fp, "\tandl\t$0x0000ffff,%%esp\n");
fprintf(fp, "\tandl\t$0x0000ffff,%%ebp\n");
+ fprintf(fp, "\tpushl\t$0\n"); /* cr2 */
+ fprintf(fp, "\tpushl\t$0\n"); /* oldmask */
+ fprintf(fp, "\tpushl\t$0\n"); /* i387 */
+ fprintf(fp, "\tpushw\t$0\n"); /* __ssh */
+ fprintf(fp, "\tpushw\t%%ss\n"); /* ss */
+ fprintf(fp, "\tpushl\t%%esp\n"); /* esp */
+ fprintf(fp, "\tpushfl\n"); /* eflags */
+ fprintf(fp, "\tpushw\t$0\n"); /* __csh */
+ fprintf(fp, "\tpushw\t%%cs\n"); /* cs */
+ fprintf(fp, "\tpushl\t$0\n"); /* eip */
+ fprintf(fp, "\tpushl\t$0\n"); /* err */
+ fprintf(fp, "\tpushl\t$0\n"); /* trapno */
+ fprintf(fp, "\tpushal\n"); /* AX, ... */
+ fprintf(fp, "\tpushw\t$0\n"); /* __dsh */
+ fprintf(fp, "\tpushw\t%%ds\n"); /* ds */
+ fprintf(fp, "\tpushw\t$0\n"); /* __esh */
+ fprintf(fp, "\tpushw\t%%es\n"); /* es */
+ fprintf(fp, "\tpushw\t$0\n"); /* __fsh */
+ fprintf(fp, "\tpushw\t%%fs\n"); /* fs */
+ fprintf(fp, "\tpushw\t$0\n"); /* __gsh */
+ fprintf(fp, "\tpushw\t%%gs\n"); /* gs */
+ fprintf(fp, "\tmovl\t%%ebp,%%eax\n");
+ fprintf(fp, "\tmovw\t%%esp,%%ebp\n");
+ fprintf(fp, "\tpushl\t88(%%ebp)\n");
+ fprintf(fp, "\tmovl\t%%eax,%%ebp\n");
+ fprintf(fp, "\tmovl\t$%d,%%eax\n", i);
+ fprintf(fp, "\tpushw\t$92\n");
+ fprintf(fp, "\tjmp\t_%s_Dispatch\n\n", UpperDLLName);
+#if 0
fprintf(fp, "\tpushw\t%%ax\n");
fprintf(fp, "\tpushw\t%%cx\n");
fprintf(fp, "\tpushw\t%%dx\n");
@@ -684,6 +713,7 @@
fprintf(fp, "\tmovl\t$%d,%%eax\n", i);
fprintf(fp, "\tpushw\t$24\n");
fprintf(fp, "\tjmp\t_%s_Dispatch\n\n", UpperDLLName);
+#endif
break;
case FUNCTYPE_PASCAL:
diff --git a/windows/Makefile b/windows/Makefile
index f7de172..812bd34 100644
--- a/windows/Makefile
+++ b/windows/Makefile
@@ -1,7 +1,8 @@
CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR)
OBJS=class.o dc.o dce.o event.o message.o win.o timer.o graphics.o \
- clipping.o mapping.o painting.o keyboard.o utility.o syscolor.o
+ clipping.o mapping.o painting.o keyboard.o utility.o syscolor.o \
+ defwnd.o defdlg.o dialog.o focus.o
default: windows.o
@@ -9,7 +10,7 @@
$(LD) -r -o windows.o $(OBJS)
clean:
- rm -f *.o *~ *.s dll_* *.a
+ rm -f *.o *~ *.s dll_* *.a *#
depend:
$(CC) $(CFLAGS) -M *.c > .depend
diff --git a/windows/defdlg.c b/windows/defdlg.c
new file mode 100644
index 0000000..8405dc3
--- /dev/null
+++ b/windows/defdlg.c
@@ -0,0 +1,76 @@
+/*
+ * Default dialog procedure
+ *
+ * Copyright 1993 Alexandre Julliard
+ */
+
+static char Copyright[] = "Copyright Alexandre Julliard, 1993";
+
+#include "windows.h"
+#include "dialog.h"
+#include "win.h"
+
+
+/***********************************************************************
+ * DefDlgProc (USER.308)
+ */
+LONG DefDlgProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam )
+{
+ DIALOGINFO * dlgInfo;
+ BOOL result = FALSE;
+ WND * wndPtr = WIN_FindWndPtr( hwnd );
+
+ if (!wndPtr) return 0;
+ dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
+
+#ifdef DEBUG_DIALOG
+ printf( "DefDlgProc: %d %04x %d %08x\n", hwnd, msg, wParam, lParam );
+#endif
+
+ dlgInfo->msgResult = 0;
+ if (dlgInfo->dlgProc)
+ {
+ /* Call dialog procedure */
+ result = (BOOL)CallWindowProc( dlgInfo->dlgProc, hwnd,
+ msg, wParam, lParam );
+
+ /* Check if window destroyed by dialog procedure */
+ wndPtr = WIN_FindWndPtr( hwnd );
+ if (!wndPtr) return result;
+ }
+
+ if (!result) switch(msg)
+ {
+ case WM_INITDIALOG:
+ break;
+
+ case WM_ERASEBKGND:
+ FillWindow( hwnd, hwnd, (HDC)wParam, (HBRUSH)CTLCOLOR_DLG );
+ return TRUE;
+
+ case WM_NCDESTROY:
+
+ /* Delete font */
+ if (dlgInfo->hUserFont)
+ {
+ DeleteObject( dlgInfo->hUserFont );
+ dlgInfo->hUserFont = 0;
+ }
+
+ /* Delete menu */
+ if (dlgInfo->hMenu)
+ {
+ DestroyMenu( dlgInfo->hMenu );
+ dlgInfo->hMenu = 0;
+ }
+
+ /* Window clean-up */
+ DefWindowProc( hwnd, msg, wParam, lParam );
+ break;
+
+ default:
+ return DefWindowProc( hwnd, msg, wParam, lParam );
+ }
+
+ return result;
+}
diff --git a/windows/defwnd.c b/windows/defwnd.c
new file mode 100644
index 0000000..3d3a280
--- /dev/null
+++ b/windows/defwnd.c
@@ -0,0 +1,151 @@
+/*
+ * Default window procedure
+ *
+ * Copyright 1993 Alexandre Julliard
+ */
+
+static char Copyright[] = "Copyright Alexandre Julliard, 1993";
+
+#include <X11/Intrinsic.h>
+#include <X11/Shell.h>
+
+#include "windows.h"
+#include "win.h"
+#include "class.h"
+#include "user.h"
+
+
+/***********************************************************************
+ * DefWindowProc (USER.107)
+ */
+LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam )
+{
+ WND * wndPtr;
+ CLASS * classPtr;
+ LPSTR textPtr;
+ int len;
+
+#ifdef DEBUG_MESSAGE
+ printf( "DefWindowProc: %d %d %d %08x\n", hwnd, msg, wParam, lParam );
+#endif
+
+ switch(msg)
+ {
+ case WM_NCCREATE:
+ {
+ CREATESTRUCT * createStruct = (CREATESTRUCT *)lParam;
+ wndPtr = WIN_FindWndPtr(hwnd);
+ if (createStruct->lpszName)
+ {
+ /* Allocate space for window text */
+ wndPtr->hText = USER_HEAP_ALLOC(GMEM_MOVEABLE,
+ strlen(createStruct->lpszName) + 1);
+ textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
+ strcpy(textPtr, createStruct->lpszName);
+ }
+ return 1;
+ }
+
+ case WM_CREATE:
+ return 0;
+
+ case WM_NCDESTROY:
+ {
+ wndPtr = WIN_FindWndPtr(hwnd);
+ if (wndPtr->hText) USER_HEAP_FREE(wndPtr->hText);
+ wndPtr->hText = 0;
+ return 0;
+ }
+
+ case WM_PAINT:
+ {
+ PAINTSTRUCT paintstruct;
+ BeginPaint( hwnd, &paintstruct );
+ EndPaint( hwnd, &paintstruct );
+ return 0;
+ }
+
+ case WM_CLOSE:
+ DestroyWindow( hwnd );
+ return 0;
+
+ case WM_ERASEBKGND:
+ case WM_ICONERASEBKGND:
+ {
+ if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 1;
+ if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return 1;
+ if (!classPtr->wc.hbrBackground) return 1;
+ FillWindow( GetParent(hwnd), hwnd, (HDC)wParam,
+ classPtr->wc.hbrBackground );
+ return 0;
+ }
+
+ case WM_GETDLGCODE:
+ return 0;
+
+ case WM_CTLCOLOR:
+ {
+ if (HIWORD(lParam) == CTLCOLOR_SCROLLBAR)
+ {
+ SetBkColor( (HDC)wParam, RGB(255, 255, 255) );
+ SetTextColor( (HDC)wParam, RGB(0, 0, 0) );
+/* hbr = sysClrObjects.hbrScrollbar;
+ UnrealizeObject(hbr); */
+ return GetStockObject(LTGRAY_BRUSH);
+ }
+ else
+ {
+ SetBkColor( (HDC)wParam, GetSysColor(COLOR_WINDOW) );
+ SetTextColor( (HDC)wParam, GetSysColor(COLOR_WINDOWTEXT) );
+/* hbr = sysClrObjects.hbrWindow; */
+ return GetStockObject(WHITE_BRUSH);
+ }
+ }
+
+ case WM_GETTEXT:
+ {
+ if (wParam)
+ {
+ wndPtr = WIN_FindWndPtr(hwnd);
+ if (wndPtr->hText)
+ {
+ textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
+ if ((int)wParam > (len = strlen(textPtr)))
+ {
+ strcpy((char *)lParam, textPtr);
+ return (DWORD)len;
+ }
+ }
+ lParam = (DWORD)NULL;
+ }
+ return (0L);
+ }
+
+ case WM_GETTEXTLENGTH:
+ {
+ wndPtr = WIN_FindWndPtr(hwnd);
+ if (wndPtr->hText)
+ {
+ textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
+ return (DWORD)strlen(textPtr);
+ }
+ return (0L);
+ }
+
+ case WM_SETTEXT:
+ {
+ wndPtr = WIN_FindWndPtr(hwnd);
+ if (wndPtr->hText)
+ USER_HEAP_FREE(wndPtr->hText);
+
+ wndPtr->hText = USER_HEAP_ALLOC(GMEM_MOVEABLE,
+ strlen((LPSTR)lParam) + 1);
+ textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
+ strcpy(textPtr, (LPSTR)lParam);
+ if (wndPtr->shellWidget)
+ XtVaSetValues( wndPtr->shellWidget, XtNtitle, textPtr, NULL );
+ return (0L);
+ }
+ }
+ return 0;
+}
diff --git a/windows/dialog.c b/windows/dialog.c
new file mode 100644
index 0000000..e60b62d
--- /dev/null
+++ b/windows/dialog.c
@@ -0,0 +1,639 @@
+/*
+ * Dialog functions
+ *
+ * Copyright 1993 Alexandre Julliard
+ */
+
+static char Copyright[] = "Copyright Alexandre Julliard, 1993";
+
+#include <stdlib.h>
+
+#include "windows.h"
+#include "dialog.h"
+#include "win.h"
+
+
+ /* Dialog base units */
+static WORD xBaseUnit = 0, yBaseUnit = 0;
+
+
+/***********************************************************************
+ * DIALOG_Init
+ *
+ * Initialisation of the dialog manager.
+ */
+BOOL DIALOG_Init()
+{
+ TEXTMETRIC tm;
+ HDC hdc;
+
+ /* Calculate the dialog base units */
+
+ if (!(hdc = GetDC( 0 ))) return FALSE;
+ GetTextMetrics( hdc, &tm );
+ ReleaseDC( 0, hdc );
+ xBaseUnit = tm.tmAveCharWidth;
+ yBaseUnit = tm.tmHeight;
+#ifdef DEBUG_DIALOG
+ printf( "DIALOG_Init: base units = %d,%d\n", xBaseUnit, yBaseUnit );
+#endif
+ return TRUE;
+}
+
+
+/***********************************************************************
+ * DIALOG_GetControl
+ *
+ * Return the class and text of the control pointed to by ptr,
+ * and return a pointer to the next control.
+ */
+static DLGCONTROLHEADER * DIALOG_GetControl( DLGCONTROLHEADER * ptr,
+ char ** class, char ** text )
+{
+ unsigned char * p = (unsigned char *)ptr;
+ p += 14; /* size of control header */
+ if (*p & 0x80)
+ {
+ switch(*p++)
+ {
+ case 0x80: *class = "BUTTON"; break;
+ case 0x81: *class = "EDIT"; break;
+ case 0x82: *class = "STATIC"; break;
+ case 0x83: *class = "LISTBOX"; break;
+ case 0x84: *class = "SCROLLBAR"; break;
+ case 0x85: *class = "COMBOBOX"; break;
+ default: *class = ""; break;
+ }
+ }
+ else
+ {
+ *class = p;
+ p += strlen(p) + 1;
+ }
+ *text = p;
+ p += strlen(p) + 2;
+ return (DLGCONTROLHEADER *)p;
+}
+
+
+/***********************************************************************
+ * DIALOG_ParseTemplate
+ *
+ * Fill a DLGTEMPLATE structure from the dialog template.
+ */
+static void DIALOG_ParseTemplate( LPCSTR template, DLGTEMPLATE * result )
+{
+ int i;
+ unsigned char * p = (unsigned char *)template;
+
+ result->header = (DLGTEMPLATEHEADER *)p;
+ p += 13;
+ result->menuName = p;
+ if (*p == 0xff) p += 3;
+ else p += strlen(p) + 1;
+
+ if (*p) result->className = p;
+ else result->className = DIALOG_CLASS_NAME;
+ p += strlen(p) + 1;
+
+ result->caption = p;
+ p += strlen(p) + 1;
+
+ if (result->header->style & DS_SETFONT)
+ {
+ result->pointSize = *(WORD *)p; p += sizeof(WORD);
+ result->faceName = p; p += strlen(p) + 1;
+ }
+ result->controls = NULL;
+ if (!result->header->nbItems) return;
+ result->controls = (DLGCONTROL *) malloc( result->header->nbItems * sizeof(DLGCONTROL) );
+ if (!result->controls) return;
+
+ for (i = 0; i < result->header->nbItems; i++)
+ {
+ result->controls[i].header = (DLGCONTROLHEADER *)p;
+ p = (char *)DIALOG_GetControl( result->controls[i].header,
+ &result->controls[i].class,
+ &result->controls[i].text );
+ }
+}
+
+
+/***********************************************************************
+ * DIALOG_DisplayTemplate
+ */
+#ifdef DEBUG_DIALOG
+static void DIALOG_DisplayTemplate( DLGTEMPLATE * result )
+{
+ int i;
+ DLGCONTROL * ctrl = result->controls;
+
+ printf( "DIALOG %d, %d, %d, %d\n", result->header->x, result->header->y,
+ result->header->cx, result->header->cy );
+ printf( " STYLE %08x\n", result->header->style );
+ printf( " CAPTION '%s'\n", result->caption );
+ printf( " CLASS '%s'\n", result->className );
+ if (result->menuName[0] == 0xff)
+ printf( " MENU %d\n", result->menuName[1] + 256*result->menuName[2] );
+ else printf( " MENU '%s'\n", result->menuName );
+ if (result->header->style & DS_SETFONT)
+ printf( " FONT %d,'%s'\n", result->pointSize, result->faceName );
+
+ printf( " BEGIN\n" );
+
+ for (i = 0; i < result->header->nbItems; i++, ctrl++)
+ {
+ printf( " %s '%s' %d, %d, %d, %d, %d, %08x\n",
+ ctrl->class, ctrl->text, ctrl->header->id,
+ ctrl->header->x, ctrl->header->y, ctrl->header->cx,
+ ctrl->header->cy, ctrl->header->style );
+ }
+
+ printf( " END\n" );
+}
+#endif /* DEBUG_DIALOG */
+
+
+/***********************************************************************
+ * CreateDialog (USER.89)
+ */
+HWND CreateDialog( HINSTANCE hInst, LPCSTR dlgTemplate,
+ HWND owner, FARPROC dlgProc )
+{
+ return CreateDialogParam( hInst, dlgTemplate, owner, dlgProc, 0 );
+}
+
+
+/***********************************************************************
+ * CreateDialogParam (USER.241)
+ */
+HWND CreateDialogParam( HINSTANCE hInst, LPCSTR dlgTemplate,
+ HWND owner, FARPROC dlgProc, LPARAM param )
+{
+ HWND hwnd = 0;
+ HANDLE hres, hmem;
+ LPCSTR data;
+ int size;
+
+#ifdef DEBUG_DIALOG
+ printf( "CreateDialogParam: %d,'%s',%d,%p,%d\n",
+ hInst, dlgTemplate, owner, dlgProc, param );
+#endif
+
+#if 0
+ if (!(hres = FindResource( hInst, dlgTemplate, RT_DIALOG ))) return 0;
+ if (!(hmem = LoadResource( hInst, hres ))) return 0;
+ if (!(data = LockResource( hmem ))) hwnd = 0;
+ else hwnd = CreateDialogIndirectParam(hInst, data, owner, dlgProc, param);
+ FreeResource( hmem );
+#else
+ hmem = RSC_LoadResource( hInst, dlgTemplate, 0x8005, &size );
+ data = (LPCSTR) GlobalLock( hmem );
+ hwnd = CreateDialogIndirectParam( hInst, data, owner, dlgProc, param );
+ GlobalFree( hmem );
+#endif
+ return hwnd;
+}
+
+
+/***********************************************************************
+ * CreateDialogIndirect (USER.219)
+ */
+HWND CreateDialogIndirect( HINSTANCE hInst, LPCSTR dlgTemplate,
+ HWND owner, FARPROC dlgProc )
+{
+ return CreateDialogIndirectParam( hInst, dlgTemplate, owner, dlgProc, 0 );
+}
+
+
+/***********************************************************************
+ * CreateDialogIndirectParam (USER.242)
+ */
+HWND CreateDialogIndirectParam( HINSTANCE hInst, LPCSTR dlgTemplate,
+ HWND owner, FARPROC dlgProc, LPARAM param )
+{
+ HMENU hMenu = 0;
+ HFONT hFont = 0;
+ HWND hwnd;
+ WND * wndPtr;
+ DLGTEMPLATE template;
+ DIALOGINFO * dlgInfo;
+ WORD xUnit = xBaseUnit;
+ WORD yUnit = yBaseUnit;
+
+ if (!dlgTemplate) return 0;
+ DIALOG_ParseTemplate( dlgTemplate, &template );
+
+#ifdef DEBUG_DIALOG
+ DIALOG_DisplayTemplate( &template );
+#endif
+
+ /* Load menu */
+
+ if (template.menuName[0])
+ {
+ if (template.menuName[0] != 0xff)
+ hMenu = LoadMenu( hInst, template.menuName );
+ else
+ hMenu = LoadMenu( hInst, MAKEINTRESOURCE( template.menuName[1] +
+ 256*template.menuName[2] ));
+ }
+
+ /* Create custom font if needed */
+
+ if (template.header->style & DS_SETFONT)
+ {
+ hFont = CreateFont( template.pointSize, 0, 0, 0, FW_DONTCARE,
+ FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
+ DEFAULT_QUALITY, FF_DONTCARE, template.faceName );
+ if (hFont)
+ {
+ TEXTMETRIC tm;
+ HFONT oldFont;
+ HDC hdc;
+
+ hdc = GetDC( 0 );
+ oldFont = SelectObject( hdc, hFont );
+ GetTextMetrics( hdc, &tm );
+ SelectObject( hdc, oldFont );
+ ReleaseDC( 0, hdc );
+ xUnit = tm.tmAveCharWidth;
+ yUnit = tm.tmHeight;
+ }
+ }
+
+ /* Create dialog main window */
+
+ hwnd = CreateWindow( template.className, template.caption,
+ template.header->style & ~WS_VISIBLE,
+ template.header->x * xUnit / 4,
+ template.header->y * yUnit / 8,
+ template.header->cx * xUnit / 4,
+ template.header->cy * yUnit / 8,
+ owner, hMenu, hInst,
+ NULL );
+ if (!hwnd)
+ {
+ if (hFont) DeleteObject( hFont );
+ if (hMenu) DestroyMenu( hMenu );
+ if (template.controls) free( template.controls );
+ return 0;
+ }
+
+ /* Create control windows */
+
+ if (hwnd && template.header->nbItems)
+ {
+ int i;
+ DLGCONTROL * ctrl = template.controls;
+ for (i = 0; i < template.header->nbItems; i++, ctrl++)
+ {
+ CreateWindowEx( WS_EX_NOPARENTNOTIFY,
+ ctrl->class, ctrl->text, ctrl->header->style,
+ ctrl->header->x * xUnit / 4,
+ ctrl->header->y * yUnit / 8,
+ ctrl->header->cx * xUnit / 4,
+ ctrl->header->cy * yUnit / 8,
+ hwnd, ctrl->header->id, hInst, NULL );
+ }
+ }
+
+ /* Initialise dialog extra data */
+
+ wndPtr = WIN_FindWndPtr( hwnd );
+ dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
+ dlgInfo->dlgProc = dlgProc;
+ dlgInfo->hUserFont = hFont;
+ dlgInfo->hMenu = hMenu;
+ dlgInfo->xBaseUnit = xUnit;
+ dlgInfo->yBaseUnit = yUnit;
+ dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd,
+ GetWindow(wndPtr->hwndChild, GW_HWNDLAST), FALSE );
+
+ /* Send initialisation messages and set focus */
+
+ if (dlgInfo->hUserFont)
+ SendMessage( hwnd, WM_SETFONT, dlgInfo->hUserFont, 0);
+ SendMessage( hwnd, WM_INITDIALOG, dlgInfo->hwndFocus, param );
+ if (SendMessage( hwnd, WM_INITDIALOG, dlgInfo->hwndFocus, param ))
+ SetFocus( dlgInfo->hwndFocus );
+
+ /* Display dialog */
+
+ if (template.header->style & WS_VISIBLE) ShowWindow( hwnd, SW_SHOW );
+
+ if (template.controls) free( template.controls );
+ return hwnd;
+}
+
+
+/***********************************************************************
+ * DialogBox (USER.87)
+ */
+int DialogBox( HINSTANCE hInst, LPCSTR dlgTemplate,
+ HWND owner, FARPROC dlgProc )
+{
+ HWND hwnd;
+ WND * wndPtr;
+ DIALOGINFO * dlgInfo;
+ MSG msg;
+ int retval;
+
+#ifdef DEBUG_DIALOG
+ printf( "DialogBox: %d,'%s',%d,%p\n", hInst, dlgTemplate, owner, dlgProc );
+#endif
+
+ hwnd = CreateDialog( hInst, dlgTemplate, owner, dlgProc );
+ if (!hwnd) return -1;
+ wndPtr = WIN_FindWndPtr( hwnd );
+ dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
+ while (GetMessage (&msg, 0, 0, 0))
+ {
+ if (!IsDialogMessage( hwnd, &msg))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ if (dlgInfo->fEnd) break;
+ }
+ retval = dlgInfo->msgResult;
+ DestroyWindow( hwnd );
+ return retval;
+}
+
+
+/***********************************************************************
+ * EndDialog (USER.88)
+ */
+void EndDialog( HWND hwnd, short retval )
+{
+ WND * wndPtr = WIN_FindWndPtr( hwnd );
+ DIALOGINFO * dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
+ dlgInfo->msgResult = retval;
+ dlgInfo->fEnd = TRUE;
+#ifdef DEBUG_DIALOG
+ printf( "EndDialog: %d %d\n", hwnd, retval );
+#endif
+}
+
+
+/***********************************************************************
+ * IsDialogMessage (USER.90)
+ */
+BOOL IsDialogMessage( HWND hwndDlg, LPMSG msg )
+{
+ WND * wndPtr;
+
+ if (!(wndPtr = WIN_FindWndPtr( hwndDlg ))) return FALSE;
+ if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd )) return FALSE;
+
+ if (msg->message != WM_KEYDOWN)
+ {
+ SendMessage( msg->hwnd, msg->message, msg->wParam, msg->lParam );
+ }
+ else
+ {
+ int dlgCode = SendMessage( msg->hwnd, WM_GETDLGCODE, 0, 0 );
+ /* Process key message */
+ /* .... */
+ }
+ return TRUE;
+}
+
+
+/****************************************************************
+ * GetDlgCtrlID (USER.277)
+ */
+int GetDlgCtrlID( HWND hwnd )
+{
+ WND *wndPtr = WIN_FindWndPtr(hwnd);
+ if (wndPtr) return wndPtr->wIDmenu;
+ else return 0;
+}
+
+
+/***********************************************************************
+ * GetDlgItem (USER.91)
+ */
+HWND GetDlgItem( HWND hwndDlg, WORD id )
+{
+ HWND curChild;
+ WND * childPtr;
+ WND * wndPtr;
+
+ if (!(wndPtr = WIN_FindWndPtr( hwndDlg ))) return 0;
+ curChild = wndPtr->hwndChild;
+ while(curChild)
+ {
+ childPtr = WIN_FindWndPtr( curChild );
+ if (childPtr->wIDmenu == id) return curChild;
+ curChild = childPtr->hwndNext;
+ }
+ return 0;
+}
+
+
+/*******************************************************************
+ * SendDlgItemMessage (USER.101)
+ */
+LONG SendDlgItemMessage(HWND hwnd, WORD id, UINT msg, WORD wParam, LONG lParam)
+{
+ HWND hwndCtrl = GetDlgItem( hwnd, id );
+ if (hwndCtrl) return SendMessage( hwndCtrl, msg, wParam, lParam );
+ else return 0;
+}
+
+
+/*******************************************************************
+ * SetDlgItemText (USER.92)
+ */
+void SetDlgItemText( HWND hwnd, WORD id, LPSTR lpString )
+{
+ SendDlgItemMessage( hwnd, id, WM_SETTEXT, 0, (DWORD)lpString );
+}
+
+
+/***********************************************************************
+ * GetDlgItemText (USER.93)
+ */
+int GetDlgItemText( HWND hwnd, WORD id, LPSTR str, WORD max )
+{
+ return (int)SendDlgItemMessage( hwnd, id, WM_GETTEXT, max, (DWORD)str );
+}
+
+
+/*******************************************************************
+ * SetDlgItemInt (USER.94)
+ */
+void SetDlgItemInt( HWND hwnd, WORD id, WORD value, BOOL fSigned )
+{
+ HANDLE hText = LocalAlloc( LMEM_MOVEABLE, 10 );
+ char * str = (char *) LocalLock( hText );
+
+ if (fSigned) sprintf( str, "%d", value );
+ else sprintf( str, "%u", value );
+ SendDlgItemMessage( hwnd, id, WM_SETTEXT, 0, (DWORD)str );
+ LocalUnlock( hText );
+ LocalFree( hText );
+}
+
+
+/***********************************************************************
+ * GetDlgItemInt (USER.95)
+ */
+WORD GetDlgItemInt( HWND hwnd, WORD id, BOOL * translated, BOOL fSigned )
+{
+ int len;
+ HANDLE hText;
+ long result;
+ char * str;
+
+ if (translated) *translated = FALSE;
+ if (!(len = SendDlgItemMessage( hwnd, id, WM_GETTEXTLENGTH, 0, 0 )))
+ return 0;
+ if (!(hText = LocalAlloc(LMEM_MOVEABLE, len+1 )))
+ return 0;
+ str = (char *) LocalLock( hText );
+ if (SendDlgItemMessage( hwnd, id, WM_GETTEXT, len+1, (DWORD)str ))
+ {
+ char * endptr;
+ result = strtol( str, &endptr, 10 );
+ if (endptr && (endptr != str)) /* Conversion was successful */
+ {
+ if (fSigned)
+ {
+ if ((result < -32767) || (result > 32767)) result = 0;
+ else if (translated) *translated = TRUE;
+ }
+ else
+ {
+ if ((result < 0) || (result > 65535)) result = 0;
+ else if (translated) *translated = TRUE;
+ }
+ }
+ }
+ LocalUnlock( hText );
+ LocalFree( hText );
+ return (WORD)result;
+}
+
+
+/***********************************************************************
+ * CheckDlgButton (USER.97)
+ */
+void CheckDlgButton( HWND hwnd, WORD id, WORD check )
+{
+ SendDlgItemMessage( hwnd, id, BM_SETCHECK, check, 0 );
+}
+
+
+/***********************************************************************
+ * IsDlgButtonChecked (USER.98)
+ */
+WORD IsDlgButtonChecked( HWND hwnd, WORD id )
+{
+ return (WORD)SendDlgItemMessage( hwnd, id, BM_GETCHECK, 0, 0 );
+}
+
+
+/***********************************************************************
+ * CheckRadioButton (USER.96)
+ */
+void CheckRadioButton( HWND hwndDlg, WORD firstID, WORD lastID, WORD checkID )
+{
+ HWND button = GetDlgItem( hwndDlg, firstID );
+ while (button != 0)
+ {
+ WND * wndPtr = WIN_FindWndPtr( button );
+ if (!wndPtr) break;
+ SendMessage( button, BM_SETCHECK, (wndPtr->wIDmenu == checkID), 0 );
+ if (wndPtr->wIDmenu == lastID) break;
+ button = wndPtr->hwndNext;
+ }
+}
+
+
+/***********************************************************************
+ * GetDialogBaseUnits (USER.243)
+ */
+DWORD GetDialogBaseUnits()
+{
+ return MAKELONG( xBaseUnit, yBaseUnit );
+}
+
+
+/***********************************************************************
+ * MapDialogRect (USER.103)
+ */
+void MapDialogRect( HWND hwnd, LPRECT rect )
+{
+ DIALOGINFO * dlgInfo;
+ WND * wndPtr = WIN_FindWndPtr( hwnd );
+ if (!wndPtr) return;
+ dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
+ rect->left = (rect->left * dlgInfo->xBaseUnit) / 4;
+ rect->right = (rect->right * dlgInfo->xBaseUnit) / 4;
+ rect->top = (rect->top * dlgInfo->yBaseUnit) / 8;
+ rect->bottom = (rect->bottom * dlgInfo->yBaseUnit) / 8;
+}
+
+
+/***********************************************************************
+ * GetNextDlgGroupItem (USER.227)
+ */
+HWND GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
+{
+ HWND hwnd, hwndLast;
+ WND * dlgPtr, * ctrlPtr, * wndPtr;
+
+ if (!(dlgPtr = WIN_FindWndPtr( hwndDlg ))) return 0;
+ if (!(ctrlPtr = WIN_FindWndPtr( hwndCtrl ))) return 0;
+ if (ctrlPtr->hwndParent != hwndDlg) return 0;
+
+ hwndLast = hwndCtrl;
+ hwnd = ctrlPtr->hwndNext;
+ while (1)
+ {
+ if (!hwnd) hwnd = dlgPtr->hwndChild;
+ if (hwnd == hwndCtrl) break;
+ wndPtr = WIN_FindWndPtr( hwnd );
+ if (wndPtr->dwStyle & WS_TABSTOP)
+ {
+ hwndLast = hwnd;
+ if (!fPrevious) break;
+ }
+ hwnd = wndPtr->hwndNext;
+ }
+ return hwndLast;
+ return 0;
+}
+
+
+/***********************************************************************
+ * GetNextDlgTabItem (USER.228)
+ */
+HWND GetNextDlgTabItem( HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
+{
+ HWND hwnd, hwndLast;
+ WND * dlgPtr, * ctrlPtr, * wndPtr;
+
+ if (!(dlgPtr = WIN_FindWndPtr( hwndDlg ))) return 0;
+ if (!(ctrlPtr = WIN_FindWndPtr( hwndCtrl ))) return 0;
+ if (ctrlPtr->hwndParent != hwndDlg) return 0;
+
+ hwndLast = hwndCtrl;
+ hwnd = ctrlPtr->hwndNext;
+ while (1)
+ {
+ if (!hwnd) hwnd = dlgPtr->hwndChild;
+ if (hwnd == hwndCtrl) break;
+ wndPtr = WIN_FindWndPtr( hwnd );
+ if (wndPtr->dwStyle & WS_TABSTOP)
+ {
+ hwndLast = hwnd;
+ if (!fPrevious) break;
+ }
+ hwnd = wndPtr->hwndNext;
+ }
+ return hwndLast;
+}
diff --git a/windows/event.c b/windows/event.c
index 138f057..f9c5e21 100644
--- a/windows/event.c
+++ b/windows/event.c
@@ -25,10 +25,13 @@
static void EVENT_mouse_motion();
static void EVENT_mouse_button();
static void EVENT_structure();
+static void EVENT_focus_change();
/* State variables */
static HWND captureWnd = 0;
+extern HWND hWndFocus;
+
/***********************************************************************
* EVENT_AddHandlers
*
@@ -46,6 +49,8 @@
EVENT_mouse_button, (XtPointer)hwnd );
XtAddEventHandler(w, StructureNotifyMask, FALSE,
EVENT_structure, (XtPointer)hwnd );
+ XtAddEventHandler(w, FocusChangeMask, FALSE,
+ EVENT_focus_change, (XtPointer)hwnd );
}
@@ -66,6 +71,8 @@
EVENT_mouse_button, (XtPointer)hwnd );
XtRemoveEventHandler(w, StructureNotifyMask, FALSE,
EVENT_structure, (XtPointer)hwnd );
+ XtRemoveEventHandler(w, FocusChangeMask, FALSE,
+ EVENT_focus_change, (XtPointer)hwnd );
}
@@ -115,10 +122,18 @@
Boolean *cont_dispatch )
{
MSG msg;
-
+
+ char Str[24];
+ XComposeStatus cs;
+ KeySym key;
+ int count = XLookupString(event, Str, 1, &key, &cs);
+ Str[count] = '\0';
+#ifdef DEBUG_KEY
+ printf("WM_KEY??? : count=%u / %X / '%s'\n",count, Str[0], Str);
+#endif
msg.hwnd = hwnd;
msg.message = (event->type == KeyRelease) ? WM_KEYUP : WM_KEYDOWN;
- msg.wParam = 0;
+ msg.wParam = Str[0];
msg.lParam = (event->x & 0xffff) | (event->y << 16);
msg.time = event->time;
msg.pt.x = event->x & 0xffff;
@@ -231,6 +246,47 @@
}
}
+
+/**********************************************************************
+ * EVENT_focus_change
+ *
+ * Handle an X FocusChange event
+ */
+static void EVENT_focus_change( Widget w, int hwnd, XEvent *event,
+ Boolean *cont_dispatch )
+{
+ MSG msg;
+
+ msg.hwnd = hwnd;
+ msg.time = GetTickCount();
+ msg.pt.x = 0;
+ msg.pt.y = 0;
+
+ switch(event->type)
+ {
+ case FocusIn:
+ {
+ msg.message = WM_SETFOCUS;
+ msg.wParam = hwnd;
+ hWndFocus = hwnd;
+
+ }
+ break;
+
+ case FocusOut:
+ {
+ if (hWndFocus)
+ {
+ msg.message = WM_KILLFOCUS;
+ msg.wParam = hwnd;
+ hWndFocus = 0;
+ }
+ }
+ }
+ MSG_AddMsg( &msg );
+}
+
+
/**********************************************************************
* SetCapture (USER.18)
*/
diff --git a/windows/focus.c b/windows/focus.c
new file mode 100644
index 0000000..ce1a91a2
--- /dev/null
+++ b/windows/focus.c
@@ -0,0 +1,52 @@
+/*
+ * Focus functions
+ *
+ * Copyright 1993 David Metcalfe
+ */
+
+static char Copyright[] = "Copyright David Metcalfe, 1993";
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include "win.h"
+#include "gdi.h"
+
+HWND hWndFocus = 0;
+
+
+/*****************************************************************
+ * SetFocus (USER.22)
+ */
+
+HWND SetFocus(HWND hwnd)
+{
+ HWND hWndPrevFocus;
+ WND *wndPtr;
+
+ hWndPrevFocus = hWndFocus;
+
+ if (hwnd == 0)
+ {
+ XSetInputFocus(XT_display, None, RevertToPointerRoot, CurrentTime);
+ }
+ else
+ {
+ wndPtr = WIN_FindWndPtr(hwnd);
+ XSetInputFocus(XT_display, XtWindow(wndPtr->winWidget),
+ RevertToParent, CurrentTime);
+ }
+
+ return hWndPrevFocus;
+}
+
+
+/*****************************************************************
+ * GetFocus (USER.23)
+ */
+
+HWND GetFocus(void)
+{
+ return hWndFocus;
+}
+
+
diff --git a/windows/graphics.c b/windows/graphics.c
index 338733a..a2a1e32 100644
--- a/windows/graphics.c
+++ b/windows/graphics.c
@@ -365,3 +365,79 @@
SelectObject( hdc, prevBrush );
return retval;
}
+
+
+/***********************************************************************
+ * DrawFocusRect (GDI.466)
+ */
+void DrawFocusRect( HDC hdc, LPRECT rc )
+{
+ HPEN hPen, hOldPen;
+ int oldDrawMode, oldBkMode;
+ int left, top, right, bottom;
+ DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
+ if (!dc) return;
+
+ left = XLPTODP( dc, rc->left );
+ top = YLPTODP( dc, rc->top );
+ right = XLPTODP( dc, rc->right );
+ bottom = YLPTODP( dc, rc->bottom );
+
+ hPen = CreatePen(PS_DOT, 1, GetSysColor(COLOR_WINDOWTEXT));
+ hOldPen = (HPEN)SelectObject(hdc, (HANDLE)hPen);
+/* oldDrawMode = SetROP2(hdc, R2_XORPEN); */
+ oldBkMode = SetBkMode(hdc, TRANSPARENT);
+
+ if (DC_SetupGCForPen( dc ))
+ XDrawRectangle( XT_display, dc->u.x.drawable, dc->u.x.gc,
+ left, top, right-left-1, bottom-top-1 );
+
+ SetBkMode(hdc, oldBkMode);
+/* SetROP2(hdc, oldDrawMode); */
+ SelectObject(hdc, (HANDLE)hOldPen);
+ DeleteObject((HANDLE)hPen);
+}
+
+
+/**********************************************************************
+ * Line (Not a MSWin Call)
+ */
+void Line(HDC hDC, int X1, int Y1, int X2, int Y2)
+{
+MoveTo(hDC, X1, Y1);
+LineTo(hDC, X2, Y2);
+}
+
+
+/**********************************************************************
+ * DrawReliefRect (Not a MSWin Call)
+ */
+ void DrawReliefRect(HDC hDC, RECT rect, int ThickNess, int Mode)
+{
+HPEN hWHITEPen;
+HPEN hDKGRAYPen;
+HPEN hOldPen;
+int OldColor;
+rect.right--; rect.bottom--;
+hDKGRAYPen = CreatePen(PS_SOLID, 1, 0x00808080L);
+hWHITEPen = GetStockObject(WHITE_PEN);
+hOldPen = SelectObject(hDC, hWHITEPen);
+while(ThickNess > 0) {
+ if (Mode == 0)
+ SelectObject(hDC, hWHITEPen);
+ else
+ SelectObject(hDC, hDKGRAYPen);
+ Line(hDC, rect.left, rect.top, rect.right, rect.top);
+ Line(hDC, rect.left, rect.top, rect.left, rect.bottom + 1);
+ if (Mode == 0)
+ SelectObject(hDC, hDKGRAYPen);
+ else
+ SelectObject(hDC, hWHITEPen);
+ Line(hDC, rect.right, rect.bottom, rect.left, rect.bottom);
+ Line(hDC, rect.right, rect.bottom, rect.right, rect.top - 1);
+ InflateRect(&rect, -1, -1);
+ ThickNess--;
+ }
+SelectObject(hDC, hOldPen);
+DeleteObject(hDKGRAYPen);
+}
diff --git a/windows/syscolor.c b/windows/syscolor.c
index 7594fd1..a3ca9ac 100644
--- a/windows/syscolor.c
+++ b/windows/syscolor.c
@@ -48,22 +48,15 @@
void SYSCOLOR_Init()
{
- Colormap map;
XColor color;
int i;
- if ((map == COLOR_WinColormap) == CopyFromParent)
- map = DefaultColormapOfScreen(XT_screen);
-
for (i = 0; i < NUM_SYS_COLORS; i++)
{
- if (XParseColor(XT_display, map, DefSysColors[i], &color))
+ if (XParseColor(XT_display, COLOR_WinColormap, DefSysColors[i], &color))
{
- if (XAllocColor(XT_display, map, &color))
- {
- SysColors[i] = RGB(color.red >> 8, color.green >> 8,
- color.blue >> 8);
- }
+ SysColors[i] = RGB(color.red >> 8, color.green >> 8,
+ color.blue >> 8);
}
}
}
@@ -88,28 +81,11 @@
void SetSysColors(int nChanges, LPINT lpSysColor, COLORREF *lpColorValues)
{
- Colormap map;
- XColor color;
- char colorStr[8];
int i;
- if ((map == COLOR_WinColormap) == CopyFromParent)
- map = DefaultColormapOfScreen(XT_screen);
-
for (i = 0; i < nChanges; i++)
{
- sprintf(colorStr, "#%2.2x%2.2x%2.2x", GetRValue(lpColorValues[i]),
- GetGValue(lpColorValues[i]), GetBValue(lpColorValues[i]));
-
- if (XParseColor(XT_display, map, colorStr, &color))
- {
- if (XAllocColor(XT_display, map, &color))
- {
- SysColors[lpSysColor[i]] = RGB(color.red >> 8,
- color.green >> 8,
- color.blue >> 8);
- }
- }
+ SysColors[lpSysColor[i]] = lpColorValues[i];
}
/* Send WM_SYSCOLORCHANGE message to all windows */
diff --git a/windows/utility.c b/windows/utility.c
index 3c20d87..ab189a0 100644
--- a/windows/utility.c
+++ b/windows/utility.c
@@ -9,6 +9,7 @@
*/
#include <stdio.h>
+#include <stdarg.h>
#include <ctype.h>
#include "windows.h"
@@ -270,6 +271,21 @@
return result;
};
+
+/**************************************************************************
+ * wsprintf [USER.420]
+ */
+int wsprintf(LPSTR lpOutput, LPSTR lpFormat, ...)
+{
+va_list valist;
+int ArgCnt;
+va_start(valist, lpFormat);
+ArgCnt = vsprintf(lpOutput, lpFormat, valist);
+va_end(valist);
+return (ArgCnt);
+}
+
+
/* wvsprintf() is an implementation of vsprintf(). This
* implementation converts the arguments to 32-bit integers and
* calls the standard library function vsprintf().
diff --git a/windows/win.c b/windows/win.c
index 4d517d3..3e50a37 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -17,12 +17,14 @@
#include "user.h"
extern Display * XT_display;
+extern Screen * XT_screen;
extern Colormap COLOR_WinColormap;
static HWND firstWindow = 0;
-void BUTTON_CreateButton(LPSTR className, LPSTR buttonLabel, HWND hwnd);
-
+void SCROLLBAR_CreateScrollBar(LPSTR className, LPSTR Label, HWND hwnd);
+void LISTBOX_CreateListBox(LPSTR className, LPSTR Label, HWND hwnd);
+void COMBOBOX_CreateComboBox(LPSTR className, LPSTR Label, HWND hwnd);
/***********************************************************************
* WIN_FindWndPtr
@@ -67,28 +69,61 @@
/***********************************************************************
+ * WIN_SendParentNotify
+ *
+ * Send a WM_PARENTNOTIFY to all ancestors of the given window, unless
+ * the window has the WS_EX_NOPARENTNOTIFY style.
+ */
+static void WIN_SendParentNotify( HWND hwnd, WND * wndPtr, WORD event )
+{
+ HWND current = wndPtr->hwndParent;
+
+ if (wndPtr->dwExStyle & WS_EX_NOPARENTNOTIFY) return;
+ while (current)
+ {
+ SendMessage( current, WM_PARENTNOTIFY,
+ event, MAKELONG( hwnd, wndPtr->wIDmenu ) );
+ current = GetParent( current );
+ }
+}
+
+
+/***********************************************************************
* CreateWindow (USER.41)
*/
HWND CreateWindow( LPSTR className, LPSTR windowName,
DWORD style, short x, short y, short width, short height,
HWND parent, HMENU menu, HANDLE instance, LPSTR data )
{
+ return CreateWindowEx( 0, className, windowName, style,
+ x, y, width, height, parent, menu, instance, data );
+}
+
+
+/***********************************************************************
+ * CreateWindowEx (USER.452)
+ */
+HWND CreateWindowEx( DWORD exStyle, LPSTR className, LPSTR windowName,
+ DWORD style, short x, short y, short width, short height,
+ HWND parent, HMENU menu, HANDLE instance, LPSTR data )
+{
HANDLE class, hwnd;
CLASS *classPtr;
WND *wndPtr, *parentPtr = NULL;
CREATESTRUCT *createStruct;
HANDLE hcreateStruct;
int wmcreate;
- LPSTR textPtr;
#ifdef DEBUG_WIN
- printf( "CreateWindow: %s %s %d,%d %dx%d\n", className, windowName, x, y, width, height );
+ printf( "CreateWindowEx: %s %s %d,%d %dx%d\n", className, windowName, x, y, width, height );
#endif
if (x == CW_USEDEFAULT) x = 0;
if (y == CW_USEDEFAULT) y = 0;
if (width == CW_USEDEFAULT) width = 600;
if (height == CW_USEDEFAULT) height = 400;
+ if (!width) width = 1;
+ if (!height) height = 1;
/* Find the parent and class */
@@ -127,9 +162,10 @@
wndPtr->hwndLastActive = 0;
wndPtr->lpfnWndProc = classPtr->wc.lpfnWndProc;
wndPtr->dwStyle = style;
- wndPtr->dwExStyle = 0;
+ wndPtr->dwExStyle = exStyle;
wndPtr->hmenuSystem = 0;
wndPtr->wIDmenu = menu;
+ wndPtr->hText = 0;
wndPtr->flags = 0;
if (classPtr->wc.cbWndExtra)
@@ -139,11 +175,6 @@
else wndPtr->hdc = 0;
classPtr->cWindows++;
- /* Create buffer for window text */
- wndPtr->hText = USER_HEAP_ALLOC(GMEM_MOVEABLE, strlen(windowName) + 1);
- textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
- strcpy(textPtr, windowName);
-
/* Insert the window in the linked list */
if (parent)
@@ -157,6 +188,21 @@
firstWindow = hwnd;
}
+ if (!strcasecmp(className, "SCROLLBAR"))
+ {
+ SCROLLBAR_CreateScrollBar(className, windowName, hwnd);
+ goto WinCreated;
+ }
+ if (!strcasecmp(className, "LISTBOX"))
+ {
+ LISTBOX_CreateListBox(className, windowName, hwnd);
+ goto WinCreated;
+ }
+ if (!strcasecmp(className, "COMBOBOX"))
+ {
+ COMBOBOX_CreateComboBox(className, windowName, hwnd);
+ goto WinCreated;
+ }
/* Create the widgets */
if (style & WS_CHILD)
@@ -164,19 +210,23 @@
wndPtr->shellWidget = 0;
if (style & (WS_BORDER | WS_DLGFRAME | WS_THICKFRAME))
{
+ int borderCol = 0;
+ if (COLOR_WinColormap == DefaultColormapOfScreen(XT_screen))
+ borderCol = BlackPixelOfScreen(XT_screen);
wndPtr->winWidget = XtVaCreateManagedWidget(className,
- coreWidgetClass,
+ compositeWidgetClass,
parentPtr->winWidget,
XtNx, x,
XtNy, y,
XtNwidth, width,
XtNheight, height,
+ XtNborderColor, borderCol,
NULL );
}
else
{
wndPtr->winWidget = XtVaCreateManagedWidget(className,
- coreWidgetClass,
+ compositeWidgetClass,
parentPtr->winWidget,
XtNx, x,
XtNy, y,
@@ -188,15 +238,13 @@
}
else
{
- wndPtr->shellWidget = XtVaAppCreateShell(className,
- windowName,
+ wndPtr->shellWidget = XtVaAppCreateShell(windowName,
+ className,
topLevelShellWidgetClass,
XT_display,
XtNx, x,
XtNy, y,
-#ifdef USE_PRIVATE_MAP
XtNcolormap, COLOR_WinColormap,
-#endif
NULL );
wndPtr->compositeWidget = XtVaCreateManagedWidget(className,
formWidgetClass,
@@ -245,6 +293,8 @@
}
}
+WinCreated:
+
/* Send the WM_CREATE message */
hcreateStruct = GlobalAlloc( GMEM_MOVEABLE, sizeof(CREATESTRUCT) );
@@ -262,8 +312,10 @@
createStruct->lpszClass = className;
createStruct->dwExStyle = 0;
- wmcreate = CallWindowProc( wndPtr->lpfnWndProc, hwnd,
- WM_CREATE, 0, (LONG) createStruct );
+ wmcreate = SendMessage( hwnd, WM_NCCREATE, 0, (LONG)createStruct );
+ if (!wmcreate) wmcreate = -1;
+ else wmcreate = SendMessage( hwnd, WM_CREATE, 0, (LONG)createStruct );
+
GlobalUnlock( hcreateStruct );
GlobalFree( hcreateStruct );
@@ -279,6 +331,7 @@
EVENT_AddHandlers( wndPtr->winWidget, hwnd );
if (style & WS_VISIBLE) ShowWindow( hwnd, SW_SHOW );
+ WIN_SendParentNotify( hwnd, wndPtr, WM_CREATE );
return hwnd;
}
@@ -287,35 +340,41 @@
*/
BOOL DestroyWindow( HWND hwnd )
{
- WND *wndPtr, *parentPtr;
+ WND * wndPtr;
+ HWND * curWndPtr;
CLASS * classPtr;
- wndPtr = WIN_FindWndPtr( hwnd );
- if (!wndPtr) return FALSE;
+ /* Initialisation */
- if (wndPtr->hwndParent)
- {
- parentPtr = WIN_FindWndPtr( wndPtr->hwndParent );
- printf( "INTERNAL ERROR: DestroyWindow: Invalid window parent\n" );
- return FALSE;
- }
-
- classPtr = CLASS_FindClassPtr( wndPtr->hClass );
- if (!classPtr)
- {
- printf( "INTERNAL ERROR: DestroyWindow: Invalid window class\n" );
- return FALSE;
- }
-
+ if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
+ if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return FALSE;
+ WIN_SendParentNotify( hwnd, wndPtr, WM_DESTROY );
+
+ /* Send destroy messages */
+
SendMessage( hwnd, WM_DESTROY, 0, 0 );
+ SendMessage( hwnd, WM_NCDESTROY, 0, 0 );
/* Destroy all children */
- /* ........... */
+ while (wndPtr->hwndChild) /* The child removes itself from the list */
+ DestroyWindow( wndPtr->hwndChild );
/* Remove the window from the linked list */
-
- /* ........... */
+
+ if (wndPtr->hwndParent)
+ {
+ WND * parentPtr = WIN_FindWndPtr( wndPtr->hwndParent );
+ curWndPtr = &parentPtr->hwndChild;
+ }
+ else curWndPtr = &firstWindow;
+
+ while (*curWndPtr != hwnd)
+ {
+ WND * curPtr = WIN_FindWndPtr( *curWndPtr );
+ curWndPtr = &curPtr->hwndNext;
+ }
+ *curWndPtr = wndPtr->hwndNext;
/* Destroy the window */
@@ -323,13 +382,35 @@
else XtDestroyWidget( wndPtr->winWidget );
if (wndPtr->hdc) DeleteDC( wndPtr->hdc );
classPtr->cWindows--;
- USER_HEAP_FREE(wndPtr->hText);
USER_HEAP_FREE( hwnd );
return TRUE;
}
/***********************************************************************
+ * GetWindowRect (USER.32)
+ */
+void GetWindowRect( HWND hwnd, LPRECT rect )
+{
+ int x, y, width, height;
+ WND * wndPtr = WIN_FindWndPtr( hwnd );
+
+ if (wndPtr)
+ {
+ XtVaGetValues(wndPtr->winWidget,
+ XtNx, &x, XtNy, &y,
+ XtNwidth, &width,
+ XtNheight, &height,
+ NULL );
+ rect->left = x & 0xffff;
+ rect->top = y & 0xffff;
+ rect->right = width & 0xffff;
+ rect->bottom = height & 0xffff;
+ }
+}
+
+
+/***********************************************************************
* GetClientRect (USER.33)
*/
void GetClientRect( HWND hwnd, LPRECT rect )
@@ -368,12 +449,60 @@
SendMessage( hwnd, WM_SIZE, SIZE_RESTORED,
(width & 0xffff) | (height << 16) );
SendMessage( hwnd, WM_SHOWWINDOW, TRUE, 0 );
+/*
+ printf("ShowWindow(%X, %X); !\n", hwnd, cmd);
+*/
+ switch(cmd)
+ {
+ case SW_HIDE:
+ XtSetMappedWhenManaged(wndPtr->winWidget, FALSE);
+ break;
+ case SW_SHOWNA:
+ case SW_SHOWMINNOACTIVE:
+ case SW_SHOWNOACTIVATE:
+ case SW_MINIMIZE:
+ case SW_MAXIMIZE:
+ case SW_SHOWMAXIMIZED:
+ case SW_SHOWMINIMIZED:
+ case SW_SHOW:
+ case SW_NORMAL:
+ case SW_SHOWNORMAL:
+ XtSetMappedWhenManaged(wndPtr->winWidget, TRUE);
+ break;
+ default:
+ break;
+ }
}
return TRUE;
}
/***********************************************************************
+ * MoveWindow (USER.56)
+ */
+void MoveWindow(HWND hWnd, short x, short y, short w, short h, BOOL bRepaint)
+{
+ WND * wndPtr = WIN_FindWndPtr( hWnd );
+ if (wndPtr)
+ {
+ wndPtr->rectClient.left = x;
+ wndPtr->rectClient.top = y;
+ wndPtr->rectClient.right = x + w;
+ wndPtr->rectClient.bottom = y + h;
+ XtVaSetValues(wndPtr->winWidget, XtNx, x, XtNy, y,
+ XtNwidth, w, XtNheight, h, NULL );
+ SendMessage(hWnd, WM_MOVE, 0, MAKELONG(x, y));
+ printf("MoveWindow(%X, %d, %d, %d, %d, %d); !\n",
+ hWnd, x, y, w, h, bRepaint);
+ if (bRepaint) {
+ InvalidateRect(hWnd, NULL, TRUE);
+ UpdateWindow(hWnd);
+ }
+ }
+}
+
+
+/***********************************************************************
* UpdateWindow (USER.124)
*/
void UpdateWindow( HWND hwnd )
@@ -441,6 +570,42 @@
}
+/***********************************************************************
+ * SetWindowPos (USER.232)
+ */
+void SetWindowPos(HWND hWnd, HWND hWndInsertAfter, short x, short y, short w, short h, WORD wFlag)
+{
+ WND * wndPtr = WIN_FindWndPtr( hWnd );
+ if (wndPtr)
+ {
+ if ((wFlag & SWP_NOMOVE) == 0) {
+ wndPtr->rectClient.left = x;
+ wndPtr->rectClient.top = y;
+ XtVaSetValues(wndPtr->winWidget, XtNx, x, XtNy, y, NULL );
+ }
+ if ((wFlag & SWP_NOSIZE) == 0) {
+ wndPtr->rectClient.right = x + w;
+ wndPtr->rectClient.bottom = y + h;
+ XtVaSetValues(wndPtr->winWidget, XtNwidth, w, XtNheight, h, NULL );
+ }
+ if ((wFlag & SWP_NOREDRAW) == 0) {
+ InvalidateRect(hWnd, NULL, TRUE);
+ UpdateWindow(hWnd);
+ }
+ if ((wFlag & SWP_HIDEWINDOW) == SWP_HIDEWINDOW)
+ ShowWindow(hWnd, SW_HIDE);
+ if ((wFlag & SWP_SHOWWINDOW) == SWP_SHOWWINDOW)
+ ShowWindow(hWnd, SW_SHOW);
+/*
+ if ((wFlag & SWP_NOACTIVATE) == 0)
+ SetActiveWindow(hWnd);
+*/
+ printf("SetWindowPos(%X, %X, %d, %d, %d, %d, %X); !\n",
+ hWnd, hWndInsertAfter, x, y, w, h, wFlag);
+ }
+}
+
+
/**********************************************************************
* GetDesktopWindow (USER.286)
*/
@@ -502,7 +667,7 @@
{
case GWL_STYLE: return wndPtr->dwStyle;
case GWL_EXSTYLE: return wndPtr->dwExStyle;
- case GWL_WNDPROC: return wndPtr->lpfnWndProc;
+ case GWL_WNDPROC: return (LONG)wndPtr->lpfnWndProc;
}
return 0;
}
@@ -521,7 +686,7 @@
{
case GWL_STYLE: ptr = &wndPtr->dwStyle;
case GWL_EXSTYLE: ptr = &wndPtr->dwExStyle;
- case GWL_WNDPROC: ptr = &wndPtr->lpfnWndProc;
+ case GWL_WNDPROC: ptr = (LONG *)(&wndPtr->lpfnWndProc);
default: return 0;
}
retval = *ptr;
@@ -533,32 +698,16 @@
/*****************************************************************
* GetParent (USER.46)
*/
-
HWND GetParent(HWND hwnd)
{
WND *wndPtr = WIN_FindWndPtr(hwnd);
- HWND hwndParent = wndPtr->hwndParent;
- GlobalUnlock(hwnd);
- return hwndParent;
-}
-
-/****************************************************************
- * GetDlgCtrlID (USER.277)
- */
-
-int GetDlgCtrlID(HWND hwnd)
-{
- WND *wndPtr = WIN_FindWndPtr(hwnd);
- int ctrlID = wndPtr->wIDmenu;
- GlobalUnlock(hwnd);
- return ctrlID;
+ return wndPtr->hwndParent;
}
/*******************************************************************
* GetWindowText (USER.36)
*/
-
int GetWindowText(HWND hwnd, LPSTR lpString, int nMaxCount)
{
return (int)SendMessage(hwnd, WM_GETTEXT, (WORD)nMaxCount,
@@ -566,9 +715,16 @@
}
/*******************************************************************
+ * SetWindowText (USER.37)
+ */
+void SetWindowText(HWND hwnd, LPSTR lpString)
+{
+ SendMessage(hwnd, WM_SETTEXT, (WORD)NULL, (DWORD)lpString);
+}
+
+/*******************************************************************
* GetWindowTextLength (USER.38)
*/
-
int GetWindowTextLength(HWND hwnd)
{
return (int)SendMessage(hwnd, WM_GETTEXTLENGTH, (WORD)NULL,
@@ -576,3 +732,103 @@
}
+/*******************************************************************
+ * IsChild (USER.48)
+ */
+BOOL IsChild( HWND parent, HWND child )
+{
+ HWND curChild;
+ WND * parentPtr;
+ WND * childPtr;
+
+ if (!(parentPtr = WIN_FindWndPtr( parent ))) return FALSE;
+ curChild = parentPtr->hwndChild;
+
+ while (curChild)
+ {
+ if (curChild == child) return TRUE;
+ if (IsChild( curChild, child )) return TRUE;
+ if (!(childPtr = WIN_FindWndPtr( curChild ))) return FALSE;
+ curChild = childPtr->hwndNext;
+ }
+ return FALSE;
+}
+
+
+/*******************************************************************
+ * GetTopWindow (USER.229)
+ */
+HWND GetTopWindow( HWND hwnd )
+{
+ WND * wndPtr = WIN_FindWndPtr( hwnd );
+ if (wndPtr) return wndPtr->hwndChild;
+ else return 0;
+}
+
+
+/*******************************************************************
+ * GetWindow (USER.262)
+ */
+HWND GetWindow( HWND hwnd, WORD rel )
+{
+ WND * wndPtr = WIN_FindWndPtr( hwnd );
+ if (!wndPtr) return 0;
+ switch(rel)
+ {
+ case GW_HWNDFIRST:
+ if (wndPtr->hwndParent)
+ {
+ WND * parentPtr = WIN_FindWndPtr( wndPtr->hwndParent );
+ return parentPtr->hwndChild;
+ }
+ else return firstWindow;
+
+ case GW_HWNDLAST:
+ while (wndPtr->hwndNext)
+ {
+ hwnd = wndPtr->hwndNext;
+ wndPtr = WIN_FindWndPtr( hwnd );
+ }
+ return hwnd;
+
+ case GW_HWNDNEXT:
+ return wndPtr->hwndNext;
+
+ case GW_HWNDPREV:
+ {
+ HWND hwndPrev;
+
+ if (wndPtr->hwndParent)
+ {
+ WND * parentPtr = WIN_FindWndPtr( wndPtr->hwndParent );
+ hwndPrev = parentPtr->hwndChild;
+ }
+ else hwndPrev = firstWindow;
+ if (hwndPrev == hwnd) return 0;
+ while (hwndPrev)
+ {
+ wndPtr = WIN_FindWndPtr( hwndPrev );
+ if (wndPtr->hwndNext == hwnd) break;
+ hwndPrev = wndPtr->hwndNext;
+ }
+ return hwndPrev;
+ }
+
+ case GW_OWNER:
+ return wndPtr->hwndOwner;
+
+ case GW_CHILD:
+ return wndPtr->hwndChild;
+ }
+ return 0;
+}
+
+
+/*******************************************************************
+ * GetNextWindow (USER.230)
+ */
+HWND GetNextWindow( HWND hwnd, WORD flag )
+{
+ if ((flag != GW_HWNDNEXT) && (flag != GW_HWNDPREV)) return 0;
+ return GetWindow( hwnd, flag );
+}