mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
Making dflat32 a dll. Its a little broken ATM.
svn path=/trunk/; revision=2789
This commit is contained in:
parent
fabd313f2a
commit
63e2886299
13 changed files with 2720 additions and 0 deletions
34
rosapps/lib/dflat32/Makefile
Normal file
34
rosapps/lib/dflat32/Makefile
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
|
||||||
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
TARGET_DEFONLY = yes
|
||||||
|
|
||||||
|
TARGET_TYPE = dynlink
|
||||||
|
|
||||||
|
TARGET_NAME = dflat32
|
||||||
|
|
||||||
|
TARGET_LFLAGS =
|
||||||
|
|
||||||
|
TARGET_SDKLIBS =
|
||||||
|
|
||||||
|
TARGET_GCCLIBS =
|
||||||
|
|
||||||
|
TARGET_BASE = 0x98000000
|
||||||
|
|
||||||
|
TARGET_CFLAGS = # -pipe -O2 -Wall -Wstrict-prototypes -fno-builtin -DDBG
|
||||||
|
|
||||||
|
TARGET_OBJECTS = \
|
||||||
|
clipbord.o \
|
||||||
|
config.o \
|
||||||
|
console.o \
|
||||||
|
dllmain.o \
|
||||||
|
dfalloc.o \
|
||||||
|
message.o \
|
||||||
|
rect.o \
|
||||||
|
stubs.o \
|
||||||
|
video.o \
|
||||||
|
window.o
|
||||||
|
|
||||||
|
include $(PATH_TO_TOP)/rules.mak
|
||||||
|
|
||||||
|
include $(TOOLS_PATH)/helper.mk
|
58
rosapps/lib/dflat32/clipbord.c
Normal file
58
rosapps/lib/dflat32/clipbord.c
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/* ----------- clipbord.c ------------
|
||||||
|
* Clipbord funcations.
|
||||||
|
*
|
||||||
|
* sedwards
|
||||||
|
*/
|
||||||
|
#include <dflat32\dflat.h>
|
||||||
|
|
||||||
|
char *Clipboard;
|
||||||
|
unsigned ClipboardLength;
|
||||||
|
|
||||||
|
void CopyTextToClipboard(char *text)
|
||||||
|
{
|
||||||
|
ClipboardLength = strlen(text);
|
||||||
|
Clipboard = DFrealloc(Clipboard, ClipboardLength);
|
||||||
|
memmove(Clipboard, text, ClipboardLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CopyToClipboard(DFWINDOW wnd)
|
||||||
|
{
|
||||||
|
if (TextBlockMarked(wnd)) {
|
||||||
|
char *bbl=TextLine(wnd,wnd->BlkBegLine)+wnd->BlkBegCol;
|
||||||
|
char *bel=TextLine(wnd,wnd->BlkEndLine)+wnd->BlkEndCol;
|
||||||
|
ClipboardLength = (int) (bel - bbl);
|
||||||
|
Clipboard = DFrealloc(Clipboard, ClipboardLength);
|
||||||
|
memmove(Clipboard, bbl, ClipboardLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClearClipboard(void)
|
||||||
|
{
|
||||||
|
if (Clipboard != NULL) {
|
||||||
|
free(Clipboard);
|
||||||
|
Clipboard = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL PasteText(DFWINDOW wnd, char *SaveTo, unsigned len)
|
||||||
|
{
|
||||||
|
if (SaveTo != NULL && len > 0) {
|
||||||
|
unsigned plen = strlen(wnd->text) + len;
|
||||||
|
|
||||||
|
if (plen <= wnd->MaxTextLength) {
|
||||||
|
if (plen+1 > wnd->textlen) {
|
||||||
|
wnd->text = DFrealloc(wnd->text, plen+3);
|
||||||
|
wnd->textlen = plen+1;
|
||||||
|
}
|
||||||
|
memmove(CurrChar+len, CurrChar, strlen(CurrChar)+1);
|
||||||
|
memmove(CurrChar, SaveTo, len);
|
||||||
|
BuildTextPointers(wnd);
|
||||||
|
wnd->TextChanged = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
515
rosapps/lib/dflat32/config.c
Normal file
515
rosapps/lib/dflat32/config.c
Normal file
|
@ -0,0 +1,515 @@
|
||||||
|
/* ------------- config.c ------------- */
|
||||||
|
|
||||||
|
#include <dflat32/dflat.h>
|
||||||
|
|
||||||
|
/* ----- default colors for color video system ----- */
|
||||||
|
unsigned char color[CLASSCOUNT] [4] [2] = {
|
||||||
|
/* ------------ NORMAL ------------ */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ---------- APPLICATION --------- */
|
||||||
|
{{LIGHTGRAY, BLUE}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ TEXTBOX ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ LISTBOX ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ----------- EDITBOX ------------ */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ---------- MENUBAR ------------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{BLACK, CYAN}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{DARKGRAY, RED}}, /* HILITE_COLOR
|
||||||
|
Inactive, Shortcut (both FG) */
|
||||||
|
|
||||||
|
/* ---------- POPDOWNMENU --------- */
|
||||||
|
{{BLACK, CYAN}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{BLACK, CYAN}, /* FRAME_COLOR */
|
||||||
|
{DARKGRAY, RED}}, /* HILITE_COLOR
|
||||||
|
Inactive ,Shortcut (both FG) */
|
||||||
|
|
||||||
|
#ifdef INCLUDE_PICTUREBOX
|
||||||
|
/* ------------ PICTUREBOX ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ------------- DIALOG ----------- */
|
||||||
|
{{LIGHTGRAY, BLUE}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ BOX --------------- */
|
||||||
|
{{LIGHTGRAY, BLUE}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ BUTTON ------------ */
|
||||||
|
{{BLACK, CYAN}, /* STD_COLOR */
|
||||||
|
{WHITE, CYAN}, /* SELECT_COLOR */
|
||||||
|
{BLACK, CYAN}, /* FRAME_COLOR */
|
||||||
|
{DARKGRAY, RED}}, /* HILITE_COLOR
|
||||||
|
Inactive ,Shortcut (both FG) */
|
||||||
|
/* ------------ COMBOBOX ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------- TEXT ----------- */
|
||||||
|
{{0xff, 0xff}, /* STD_COLOR */
|
||||||
|
{0xff, 0xff}, /* SELECT_COLOR */
|
||||||
|
{0xff, 0xff}, /* FRAME_COLOR */
|
||||||
|
{0xff, 0xff}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------- RADIOBUTTON ----------- */
|
||||||
|
{{LIGHTGRAY, BLUE}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------- CHECKBOX ----------- */
|
||||||
|
{{LIGHTGRAY, BLUE}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ SPINBUTTON ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ----------- ERRORBOX ----------- */
|
||||||
|
{{YELLOW, RED}, /* STD_COLOR */
|
||||||
|
{YELLOW, RED}, /* SELECT_COLOR */
|
||||||
|
{YELLOW, RED}, /* FRAME_COLOR */
|
||||||
|
{YELLOW, RED}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ----------- MESSAGEBOX --------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ----------- HELPBOX ------------ */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLUE}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{WHITE, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ---------- STATUSBAR ------------- */
|
||||||
|
{{BLACK, CYAN}, /* STD_COLOR */
|
||||||
|
{BLACK, CYAN}, /* SELECT_COLOR */
|
||||||
|
{BLACK, CYAN}, /* FRAME_COLOR */
|
||||||
|
{BLACK, CYAN}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ---------- TITLEBAR ------------ */
|
||||||
|
{{BLACK, CYAN}, /* STD_COLOR */
|
||||||
|
{BLACK, CYAN}, /* SELECT_COLOR */
|
||||||
|
{BLACK, CYAN}, /* FRAME_COLOR */
|
||||||
|
{WHITE, CYAN}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ DUMMY ------------- */
|
||||||
|
{{GREEN, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{GREEN, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{GREEN, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{GREEN, LIGHTGRAY}} /* HILITE_COLOR */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ----- default colors for mono video system ----- */
|
||||||
|
unsigned char bw[CLASSCOUNT] [4] [2] = {
|
||||||
|
/* ------------ NORMAL ------------ */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ---------- APPLICATION --------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ TEXTBOX ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ LISTBOX ----------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ----------- EDITBOX ------------ */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ---------- MENUBAR ------------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{DARKGRAY, WHITE}}, /* HILITE_COLOR
|
||||||
|
Inactive, Shortcut (both FG) */
|
||||||
|
|
||||||
|
/* ---------- POPDOWNMENU --------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{DARKGRAY, WHITE}}, /* HILITE_COLOR
|
||||||
|
Inactive ,Shortcut (both FG) */
|
||||||
|
|
||||||
|
#ifdef INCLUDE_PICTUREBOX
|
||||||
|
/* ------------ PICTUREBOX ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ------------- DIALOG ----------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ BOX --------------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ BUTTON ------------ */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{WHITE, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{DARKGRAY, WHITE}}, /* HILITE_COLOR
|
||||||
|
Inactive ,Shortcut (both FG) */
|
||||||
|
/* ------------ COMBOBOX ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------- TEXT ----------- */
|
||||||
|
{{0xff, 0xff}, /* STD_COLOR */
|
||||||
|
{0xff, 0xff}, /* SELECT_COLOR */
|
||||||
|
{0xff, 0xff}, /* FRAME_COLOR */
|
||||||
|
{0xff, 0xff}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------- RADIOBUTTON ----------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------- CHECKBOX ----------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ SPINBUTTON ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ----------- ERRORBOX ----------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ----------- MESSAGEBOX --------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ----------- HELPBOX ------------ */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{WHITE, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{WHITE, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ---------- STATUSBAR ------------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ---------- TITLEBAR ------------ */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ DUMMY ------------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}} /* HILITE_COLOR */
|
||||||
|
};
|
||||||
|
/* ----- default colors for reverse mono video ----- */
|
||||||
|
unsigned char reverse[CLASSCOUNT] [4] [2] = {
|
||||||
|
/* ------------ NORMAL ------------ */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ---------- APPLICATION --------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ TEXTBOX ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ LISTBOX ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ----------- EDITBOX ------------ */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ---------- MENUBAR ------------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{DARKGRAY, WHITE}}, /* HILITE_COLOR
|
||||||
|
Inactive, Shortcut (both FG) */
|
||||||
|
|
||||||
|
/* ---------- POPDOWNMENU --------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{DARKGRAY, WHITE}}, /* HILITE_COLOR
|
||||||
|
Inactive ,Shortcut (both FG) */
|
||||||
|
|
||||||
|
#ifdef INCLUDE_PICTUREBOX
|
||||||
|
/* ------------ PICTUREBOX ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ------------- DIALOG ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ BOX --------------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ BUTTON ------------ */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{WHITE, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{DARKGRAY, WHITE}}, /* HILITE_COLOR
|
||||||
|
Inactive ,Shortcut (both FG) */
|
||||||
|
/* ------------ COMBOBOX ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------- TEXT ----------- */
|
||||||
|
{{0xff, 0xff}, /* STD_COLOR */
|
||||||
|
{0xff, 0xff}, /* SELECT_COLOR */
|
||||||
|
{0xff, 0xff}, /* FRAME_COLOR */
|
||||||
|
{0xff, 0xff}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------- RADIOBUTTON ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------- CHECKBOX ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ SPINBUTTON ----------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ----------- ERRORBOX ----------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ----------- MESSAGEBOX --------- */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ----------- HELPBOX ------------ */
|
||||||
|
{{BLACK, LIGHTGRAY}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{BLACK, LIGHTGRAY}, /* FRAME_COLOR */
|
||||||
|
{WHITE, LIGHTGRAY}},/* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ---------- STATUSBAR ------------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ---------- TITLEBAR ------------ */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}}, /* HILITE_COLOR */
|
||||||
|
|
||||||
|
/* ------------ DUMMY ------------- */
|
||||||
|
{{LIGHTGRAY, BLACK}, /* STD_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* SELECT_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}, /* FRAME_COLOR */
|
||||||
|
{LIGHTGRAY, BLACK}} /* HILITE_COLOR */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------ default configuration values ------- */
|
||||||
|
CONFIG cfg = {
|
||||||
|
VERSION,
|
||||||
|
TRUE, /* Editor Insert Mode */
|
||||||
|
4, /* Editor tab stops */
|
||||||
|
TRUE, /* Editor word wrap */
|
||||||
|
#ifdef INCLUDE_WINDOWOPTIONS
|
||||||
|
TRUE, /* Application Border */
|
||||||
|
TRUE, /* Application Title */
|
||||||
|
TRUE, /* Status Bar */
|
||||||
|
TRUE, /* Textured application window */
|
||||||
|
#endif
|
||||||
|
// 25, /* Number of screen lines */
|
||||||
|
"Lpt1", /* Printer Port */
|
||||||
|
66, /* Lines per printer page */
|
||||||
|
80, /* characters per printer line */
|
||||||
|
6, /* Left printer margin */
|
||||||
|
70, /* Right printer margin */
|
||||||
|
3, /* Top printer margin */
|
||||||
|
55 /* Bottom printer margin */
|
||||||
|
};
|
||||||
|
|
||||||
|
char **Argv;
|
||||||
|
void BuildFileName(char *path, char *ext)
|
||||||
|
{
|
||||||
|
extern char **Argv;
|
||||||
|
char *cp;
|
||||||
|
|
||||||
|
strcpy(path, Argv[0]);
|
||||||
|
cp = strrchr(path, '\\');
|
||||||
|
if (cp == NULL)
|
||||||
|
cp = path;
|
||||||
|
else
|
||||||
|
cp++;
|
||||||
|
strcpy(cp, DFlatApplication);
|
||||||
|
strcat(cp, ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE *OpenConfig(char *mode)
|
||||||
|
{
|
||||||
|
char path[64];
|
||||||
|
BuildFileName(path, ".cfg");
|
||||||
|
return fopen(path, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------ load a configuration file from disk ------- */
|
||||||
|
BOOL LoadConfig(void)
|
||||||
|
{
|
||||||
|
static BOOL ConfigLoaded = FALSE;
|
||||||
|
if (ConfigLoaded == FALSE) {
|
||||||
|
FILE *fp = OpenConfig("rb");
|
||||||
|
if (fp != NULL) {
|
||||||
|
fread(cfg.version, sizeof cfg.version+1, 1, fp);
|
||||||
|
if (strcmp(cfg.version, VERSION) == 0) {
|
||||||
|
fseek(fp, 0L, SEEK_SET);
|
||||||
|
fread(&cfg, sizeof(CONFIG), 1, fp);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
char path[64];
|
||||||
|
BuildFileName(path, ".cfg");
|
||||||
|
fclose(fp);
|
||||||
|
unlink(path);
|
||||||
|
strcpy(cfg.version, VERSION);
|
||||||
|
}
|
||||||
|
ConfigLoaded = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ConfigLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------ save a configuration file to disk ------- */
|
||||||
|
void SaveConfig(void)
|
||||||
|
{
|
||||||
|
FILE *fp = OpenConfig("wb");
|
||||||
|
if (fp != NULL) {
|
||||||
|
fwrite(&cfg, sizeof(CONFIG), 1, fp);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------- set window colors --------- */
|
||||||
|
void SetStandardColor(DFWINDOW wnd)
|
||||||
|
{
|
||||||
|
foreground = WndForeground(wnd);
|
||||||
|
background = WndBackground(wnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetReverseColor(DFWINDOW wnd)
|
||||||
|
{
|
||||||
|
foreground = SelectForeground(wnd);
|
||||||
|
background = SelectBackground(wnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
217
rosapps/lib/dflat32/console.c
Normal file
217
rosapps/lib/dflat32/console.c
Normal file
|
@ -0,0 +1,217 @@
|
||||||
|
/* ----------- console.c ---------- */
|
||||||
|
|
||||||
|
//#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include <dflat32/dflat.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* ----- table of alt keys for finding shortcut keys ----- */
|
||||||
|
#if 0
|
||||||
|
static int altconvert[] = {
|
||||||
|
ALT_A,ALT_B,ALT_C,ALT_D,ALT_E,ALT_F,ALT_G,ALT_H,
|
||||||
|
ALT_I,ALT_J,ALT_K,ALT_L,ALT_M,ALT_N,ALT_O,ALT_P,
|
||||||
|
ALT_Q,ALT_R,ALT_S,ALT_T,ALT_U,ALT_V,ALT_W,ALT_X,
|
||||||
|
ALT_Y,ALT_Z,ALT_0,ALT_1,ALT_2,ALT_3,ALT_4,ALT_5,
|
||||||
|
ALT_6,ALT_7,ALT_8,ALT_9
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static COORD cursorpos[MAXSAVES];
|
||||||
|
static CONSOLE_CURSOR_INFO cursorinfo[MAXSAVES];
|
||||||
|
static int cs = 0;
|
||||||
|
|
||||||
|
|
||||||
|
void SwapCursorStack(void)
|
||||||
|
{
|
||||||
|
if (cs > 1)
|
||||||
|
{
|
||||||
|
COORD coord;
|
||||||
|
CONSOLE_CURSOR_INFO csi;
|
||||||
|
|
||||||
|
coord = cursorpos[cs-2];
|
||||||
|
cursorpos[cs-2] = cursorpos[cs-1];
|
||||||
|
cursorpos[cs-1] = coord;
|
||||||
|
|
||||||
|
memcpy (&csi,
|
||||||
|
&cursorinfo[cs-2],
|
||||||
|
sizeof(CONSOLE_CURSOR_INFO));
|
||||||
|
memcpy (&cursorinfo[cs-2],
|
||||||
|
&cursorinfo[cs-1],
|
||||||
|
sizeof(CONSOLE_CURSOR_INFO));
|
||||||
|
memcpy (&cursorinfo[cs-1],
|
||||||
|
&csi,
|
||||||
|
sizeof(CONSOLE_CURSOR_INFO));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ---- Read a keystroke ---- */
|
||||||
|
void GetKey (PINPUT_RECORD lpBuffer)
|
||||||
|
{
|
||||||
|
HANDLE hInput;
|
||||||
|
DWORD dwRead;
|
||||||
|
|
||||||
|
hInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// WaitForSingleObject (hInput, INFINITE);
|
||||||
|
ReadConsoleInput (hInput, lpBuffer, 1, &dwRead);
|
||||||
|
if ((lpBuffer->EventType == KEY_EVENT) &&
|
||||||
|
(lpBuffer->Event.KeyEvent.bKeyDown == TRUE))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- read the keyboard shift status --------- */
|
||||||
|
|
||||||
|
int getshift(void)
|
||||||
|
{
|
||||||
|
// regs.h.ah = 2;
|
||||||
|
// int86(KEYBRD, ®s, ®s);
|
||||||
|
// return regs.h.al;
|
||||||
|
/* FIXME */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -------- sound a buzz tone ---------- */
|
||||||
|
void beep(void)
|
||||||
|
{
|
||||||
|
Beep(440, 50);
|
||||||
|
// MessageBeep (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------ position the cursor ------ */
|
||||||
|
void cursor(int x, int y)
|
||||||
|
{
|
||||||
|
COORD coPos;
|
||||||
|
|
||||||
|
coPos.X = (USHORT)x;
|
||||||
|
coPos.Y = (USHORT)y;
|
||||||
|
SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), coPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------- get the current cursor position ------- */
|
||||||
|
void curr_cursor(int *x, int *y)
|
||||||
|
//VOID GetCursorXY (PSHORT x, PSHORT y)
|
||||||
|
{
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
|
||||||
|
GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &csbi);
|
||||||
|
|
||||||
|
*x = (int)csbi.dwCursorPosition.X;
|
||||||
|
*y = (int)csbi.dwCursorPosition.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------ save the current cursor configuration ------ */
|
||||||
|
void savecursor(void)
|
||||||
|
{
|
||||||
|
if (cs < MAXSAVES)
|
||||||
|
{
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
|
||||||
|
GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &csbi);
|
||||||
|
cursorpos[cs].X = csbi.dwCursorPosition.X;
|
||||||
|
cursorpos[cs].Y = csbi.dwCursorPosition.Y;
|
||||||
|
|
||||||
|
GetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE),
|
||||||
|
&(cursorinfo[cs]));
|
||||||
|
|
||||||
|
cs++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- restore the saved cursor configuration ---- */
|
||||||
|
void restorecursor(void)
|
||||||
|
{
|
||||||
|
if (cs)
|
||||||
|
{
|
||||||
|
--cs;
|
||||||
|
SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE),
|
||||||
|
cursorpos[cs]);
|
||||||
|
SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE),
|
||||||
|
&(cursorinfo[cs]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------ make a normal cursor ------ */
|
||||||
|
void normalcursor(void)
|
||||||
|
{
|
||||||
|
CONSOLE_CURSOR_INFO csi;
|
||||||
|
|
||||||
|
csi.bVisible = TRUE;
|
||||||
|
csi.dwSize = 5;
|
||||||
|
SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE),
|
||||||
|
&csi);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------ hide the cursor ------ */
|
||||||
|
void hidecursor(void)
|
||||||
|
{
|
||||||
|
CONSOLE_CURSOR_INFO csi;
|
||||||
|
|
||||||
|
GetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE),
|
||||||
|
&csi);
|
||||||
|
csi.bVisible = FALSE;
|
||||||
|
SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE),
|
||||||
|
&csi);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------ unhide the cursor ------ */
|
||||||
|
void unhidecursor(void)
|
||||||
|
{
|
||||||
|
CONSOLE_CURSOR_INFO csi;
|
||||||
|
|
||||||
|
GetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE),
|
||||||
|
&csi);
|
||||||
|
csi.bVisible = TRUE;
|
||||||
|
SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE),
|
||||||
|
&csi);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set the cursor size (in percent) */
|
||||||
|
void set_cursor_size (unsigned t)
|
||||||
|
{
|
||||||
|
CONSOLE_CURSOR_INFO csi;
|
||||||
|
|
||||||
|
GetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE),
|
||||||
|
&csi);
|
||||||
|
|
||||||
|
if (t < 2)
|
||||||
|
csi.dwSize = 2;
|
||||||
|
else if (t > 90)
|
||||||
|
csi.dwSize = 90;
|
||||||
|
else
|
||||||
|
csi.dwSize = t;
|
||||||
|
SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE),
|
||||||
|
&csi);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------ convert an Alt+ key to its letter equivalent ----- */
|
||||||
|
int AltConvert(int c)
|
||||||
|
{
|
||||||
|
return c;
|
||||||
|
#if 0
|
||||||
|
int i, a = 0;
|
||||||
|
for (i = 0; i < 36; i++)
|
||||||
|
if (c == altconvert[i])
|
||||||
|
break;
|
||||||
|
if (i < 26)
|
||||||
|
a = 'a' + i;
|
||||||
|
else if (i < 36)
|
||||||
|
a = '0' + i - 26;
|
||||||
|
return a;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
76
rosapps/lib/dflat32/dfalloc.c
Normal file
76
rosapps/lib/dflat32/dfalloc.c
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
/* ---------- dfalloc.c ----------
|
||||||
|
* This seems simple enough, if a AllocationError occors
|
||||||
|
* then try to handle it in a somewhat clean fashion.
|
||||||
|
*
|
||||||
|
* Dont ask I didnt write it. - sedwards
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* #define WIN32_LEAN_AND_MEAN Removed for ROS */
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <dflat32/dflat.h>
|
||||||
|
|
||||||
|
static void AllocationError(void)
|
||||||
|
{
|
||||||
|
static BOOL OnceIn = FALSE;
|
||||||
|
extern jmp_buf AllocError;
|
||||||
|
extern BOOL AllocTesting;
|
||||||
|
static char *ErrMsg[] = {
|
||||||
|
"ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿",
|
||||||
|
"³ Out of Memory! ³",
|
||||||
|
"RÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄU"
|
||||||
|
};
|
||||||
|
int x, y;
|
||||||
|
CHAR_INFO savbuf[54];
|
||||||
|
DFRECT rc = {30,11,47,13};
|
||||||
|
INPUT_RECORD ir;
|
||||||
|
|
||||||
|
if (!OnceIn)
|
||||||
|
{
|
||||||
|
OnceIn = TRUE;
|
||||||
|
/* ------ close all windows ------ */
|
||||||
|
DfSendMessage(ApplicationWindow, CLOSE_WINDOW, 0, 0);
|
||||||
|
GetVideo(rc, savbuf);
|
||||||
|
for (x = 0; x < 18; x++)
|
||||||
|
{
|
||||||
|
for (y = 0; y < 3; y++)
|
||||||
|
{
|
||||||
|
int c = (255 & (*(*(ErrMsg+y)+x))) | 0x7000;
|
||||||
|
PutVideoChar(x+rc.lf, y+rc.tp, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GetKey(&ir);
|
||||||
|
StoreVideo(rc, savbuf);
|
||||||
|
if (AllocTesting)
|
||||||
|
longjmp(AllocError, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void *DFcalloc(size_t nitems, size_t size)
|
||||||
|
{
|
||||||
|
void *rtn = calloc(nitems, size);
|
||||||
|
if (size && rtn == NULL)
|
||||||
|
AllocationError();
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *DFmalloc(size_t size)
|
||||||
|
{
|
||||||
|
void *rtn = malloc(size);
|
||||||
|
if (size && rtn == NULL)
|
||||||
|
AllocationError();
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *DFrealloc(void *block, size_t size)
|
||||||
|
{
|
||||||
|
void *rtn;
|
||||||
|
|
||||||
|
rtn = realloc(block, size);
|
||||||
|
if (size && rtn == NULL)
|
||||||
|
AllocationError();
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
68
rosapps/lib/dflat32/dflat32.def
Normal file
68
rosapps/lib/dflat32/dflat32.def
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
;
|
||||||
|
; ReactOS dflat32 COnsole Windowing Library
|
||||||
|
;
|
||||||
|
LIBRARY DFLAT32.DLL
|
||||||
|
|
||||||
|
EXPORTS
|
||||||
|
AllocError ; dfalloc.c
|
||||||
|
AltConvert ; console.c
|
||||||
|
beep ; console.c
|
||||||
|
cursor ; console.c
|
||||||
|
curr_cursor ; console.c
|
||||||
|
CopyTextToClipboard ; clipbord.c
|
||||||
|
CopyToClipboard ; clipbord.c
|
||||||
|
ClearClipboard ; clipbord.c
|
||||||
|
DFcalloc ; dfalloc.c
|
||||||
|
DFmalloc ; dfalloc.c
|
||||||
|
DFrealloc ; dfalloc.c
|
||||||
|
GetKey ; console.c
|
||||||
|
getshift ; console.c
|
||||||
|
hidecursor ; console.c
|
||||||
|
normalcursor ; console.c
|
||||||
|
PasteText ; clipbord.c
|
||||||
|
restorecursor ; console.c
|
||||||
|
savecursor ; console.c
|
||||||
|
set_cursor_size ; console.c
|
||||||
|
SetStandardColor ; config.c
|
||||||
|
SetReverseColor ; config.c
|
||||||
|
SwapCursorStack ; console.c
|
||||||
|
unhidecursor ; console.c
|
||||||
|
; Update this stuff below from message.c
|
||||||
|
DfDispatchMessage ; message.c
|
||||||
|
handshake ; message.c
|
||||||
|
DfSendMessage ; message.c
|
||||||
|
DfPostMessage ; message.c
|
||||||
|
DfTerminate ; message.c
|
||||||
|
DfInitialize ; message.c
|
||||||
|
DfGetScreenWidth ; message.c
|
||||||
|
DfGetScreenHeight ; message.c
|
||||||
|
; Update this stuff below from Rect.c
|
||||||
|
subRectangle
|
||||||
|
ClientRect
|
||||||
|
RelativeWindowRect
|
||||||
|
ClipRectangle
|
||||||
|
; stuff from video.c
|
||||||
|
GetVideo
|
||||||
|
StoreVideo
|
||||||
|
GetVideoChar
|
||||||
|
PutVideoChar
|
||||||
|
CharInView
|
||||||
|
wputch
|
||||||
|
wputs
|
||||||
|
scroll_window
|
||||||
|
; stuff from window.c
|
||||||
|
DfCreateWindow
|
||||||
|
AddTitle
|
||||||
|
InsertTitle
|
||||||
|
writeline
|
||||||
|
AdjustRectangle
|
||||||
|
DisplayTitle
|
||||||
|
PaintShadow
|
||||||
|
RepaintBorder
|
||||||
|
ClearWindow
|
||||||
|
LineLength
|
||||||
|
InitWindowColors
|
||||||
|
PutWindowChar
|
||||||
|
PutWindowLine
|
||||||
|
; exports from the stubs
|
||||||
|
classdefs
|
43
rosapps/lib/dflat32/dflat32.rc
Normal file
43
rosapps/lib/dflat32/dflat32.rc
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#include <defines.h>
|
||||||
|
#include <reactos/resource.h>
|
||||||
|
|
||||||
|
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||||
|
|
||||||
|
/* Version information. */
|
||||||
|
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
|
||||||
|
PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
|
||||||
|
FILEFLAGSMASK 0x3fL
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS 0x1L
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS 0x40004L
|
||||||
|
FILETYPE 0x2L
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "040904b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "CompanyName", RES_STR_COMPANY_NAME
|
||||||
|
VALUE "FileDescription", "dflat32 console windowing library\0"
|
||||||
|
VALUE "FileVersion", RES_STR_PRODUCT_VERSION
|
||||||
|
VALUE "InternalName", "dflat32\0"
|
||||||
|
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
|
||||||
|
VALUE "OriginalCopyright", "?"
|
||||||
|
VALUE "OriginalFilename", "dflat32.dll\0"
|
||||||
|
VALUE "ProductName", RES_STR_PRODUCT_NAME
|
||||||
|
VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x409, 1200
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/* EOF */
|
24
rosapps/lib/dflat32/dllmain.c
Normal file
24
rosapps/lib/dflat32/dllmain.c
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ReactOS DFLAT32.DLL
|
||||||
|
*/
|
||||||
|
#include <windows.h>
|
||||||
|
BOOLEAN __stdcall DllMain(
|
||||||
|
PVOID hinstDll,
|
||||||
|
ULONG dwReason,
|
||||||
|
PVOID reserved)
|
||||||
|
{
|
||||||
|
switch (dwReason)
|
||||||
|
{
|
||||||
|
case DLL_PROCESS_ATTACH:
|
||||||
|
break;
|
||||||
|
case DLL_THREAD_ATTACH:
|
||||||
|
break;
|
||||||
|
case DLL_THREAD_DETACH:
|
||||||
|
break;
|
||||||
|
case DLL_PROCESS_DETACH:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return (TRUE);
|
||||||
|
}
|
||||||
|
/* EOF */
|
687
rosapps/lib/dflat32/message.c
Normal file
687
rosapps/lib/dflat32/message.c
Normal file
|
@ -0,0 +1,687 @@
|
||||||
|
/* --------- message.c ----------
|
||||||
|
* Message Que code for all events that dflat32
|
||||||
|
* should know how to handle.
|
||||||
|
*
|
||||||
|
* You understand this? Good I'm glad one of us
|
||||||
|
* does. - sedwards 3-24-02
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <dflat32/dflat.h>
|
||||||
|
#include <dflat32/system.h>
|
||||||
|
|
||||||
|
static int handshaking = 0;
|
||||||
|
|
||||||
|
BOOL AllocTesting = FALSE;
|
||||||
|
jmp_buf AllocError;
|
||||||
|
BOOL AltDown = FALSE;
|
||||||
|
|
||||||
|
/* ---------- event queue ---------- */
|
||||||
|
static struct events
|
||||||
|
{
|
||||||
|
DFMESSAGE event;
|
||||||
|
int mx;
|
||||||
|
int my;
|
||||||
|
} EventQueue[MAXMESSAGES];
|
||||||
|
|
||||||
|
/* ---------- message queue --------- */
|
||||||
|
static struct msgs
|
||||||
|
{
|
||||||
|
DFWINDOW wnd;
|
||||||
|
DFMESSAGE msg;
|
||||||
|
PARAM p1;
|
||||||
|
PARAM p2;
|
||||||
|
} MsgQueue[MAXMESSAGES];
|
||||||
|
|
||||||
|
static int EventQueueOnCtr;
|
||||||
|
static int EventQueueOffCtr;
|
||||||
|
static int EventQueueCtr;
|
||||||
|
|
||||||
|
static int MsgQueueOnCtr;
|
||||||
|
static int MsgQueueOffCtr;
|
||||||
|
static int MsgQueueCtr;
|
||||||
|
|
||||||
|
|
||||||
|
DFWINDOW CaptureMouse;
|
||||||
|
DFWINDOW CaptureKeyboard;
|
||||||
|
static BOOL NoChildCaptureMouse;
|
||||||
|
static BOOL NoChildCaptureKeyboard;
|
||||||
|
|
||||||
|
static int doubletimer = -1;
|
||||||
|
static int delaytimer = -1;
|
||||||
|
static int clocktimer = -1;
|
||||||
|
|
||||||
|
static DFWINDOW Cwnd;
|
||||||
|
|
||||||
|
static char ermsg[] = "Error accessing drive x";
|
||||||
|
|
||||||
|
|
||||||
|
static void StopMsg(void)
|
||||||
|
{
|
||||||
|
ClearClipboard();
|
||||||
|
ClearDialogBoxes();
|
||||||
|
restorecursor();
|
||||||
|
unhidecursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
SHORT DfGetScreenHeight (void)
|
||||||
|
{
|
||||||
|
return sScreenHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHORT DfGetScreenWidth (void)
|
||||||
|
{
|
||||||
|
return sScreenWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------ initialize the message system --------- */
|
||||||
|
BOOL DfInitialize (VOID)
|
||||||
|
{
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
|
||||||
|
AllocTesting = TRUE;
|
||||||
|
if (setjmp(AllocError) != 0)
|
||||||
|
{
|
||||||
|
StopMsg();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get input and output handles */
|
||||||
|
hInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||||
|
hOutput = GetStdHandle (STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
|
/* get screen size */
|
||||||
|
GetConsoleScreenBufferInfo (hOutput, &csbi);
|
||||||
|
sScreenHeight = (csbi.srWindow.Bottom - csbi.srWindow.Top) + 1;
|
||||||
|
sScreenWidth = (csbi.srWindow.Right - csbi.srWindow.Left) + 1;
|
||||||
|
|
||||||
|
/* enable mouse events */
|
||||||
|
SetConsoleMode (hInput, ENABLE_MOUSE_INPUT);
|
||||||
|
|
||||||
|
savecursor();
|
||||||
|
hidecursor();
|
||||||
|
|
||||||
|
CaptureMouse = NULL;
|
||||||
|
CaptureKeyboard = NULL;
|
||||||
|
NoChildCaptureMouse = FALSE;
|
||||||
|
NoChildCaptureKeyboard = FALSE;
|
||||||
|
MsgQueueOnCtr = 0;
|
||||||
|
MsgQueueOffCtr = 0;
|
||||||
|
MsgQueueCtr = 0;
|
||||||
|
EventQueueOnCtr = 0;
|
||||||
|
EventQueueOffCtr = 0;
|
||||||
|
EventQueueCtr = 0;
|
||||||
|
DfPostMessage (NULL, DFM_START, 0, 0);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DfTerminate (void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----- post an event and parameters to event queue ---- */
|
||||||
|
static void PostEvent(DFMESSAGE event, int p1, int p2)
|
||||||
|
{
|
||||||
|
if (EventQueueCtr != MAXMESSAGES) {
|
||||||
|
EventQueue[EventQueueOnCtr].event = event;
|
||||||
|
EventQueue[EventQueueOnCtr].mx = p1;
|
||||||
|
EventQueue[EventQueueOnCtr].my = p2;
|
||||||
|
if (++EventQueueOnCtr == MAXMESSAGES)
|
||||||
|
EventQueueOnCtr = 0;
|
||||||
|
EventQueueCtr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------ collect mouse, clock, and keyboard events ----- */
|
||||||
|
static void collect_events(void)
|
||||||
|
{
|
||||||
|
static int OldShiftKeys = 0;
|
||||||
|
int sk = 0;
|
||||||
|
|
||||||
|
#ifdef TIMER_AVAILABLE
|
||||||
|
static BOOL flipflop = FALSE;
|
||||||
|
static char timestr[9];
|
||||||
|
struct tm *now;
|
||||||
|
int hr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HANDLE hInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||||
|
INPUT_RECORD ir;
|
||||||
|
DWORD dwRead;
|
||||||
|
int c;
|
||||||
|
|
||||||
|
#ifdef TIMER_AVAILABLE
|
||||||
|
/* -------- test for a clock event (one/second) ------- */
|
||||||
|
if (timed_out(clocktimer))
|
||||||
|
{
|
||||||
|
/* ----- get the current time ----- */
|
||||||
|
time_t t = time(NULL);
|
||||||
|
now = localtime(&t);
|
||||||
|
hr = now->tm_hour > 12 ?
|
||||||
|
now->tm_hour - 12 :
|
||||||
|
now->tm_hour;
|
||||||
|
if (hr == 0)
|
||||||
|
hr = 12;
|
||||||
|
sprintf(timestr, "%2d:%02d", hr, now->tm_min);
|
||||||
|
strcpy(timestr+5, now->tm_hour > 11 ? "pm " : "am ");
|
||||||
|
/* ------- blink the : at one-second intervals ----- */
|
||||||
|
if (flipflop)
|
||||||
|
*(timestr+2) = ' ';
|
||||||
|
flipflop ^= TRUE;
|
||||||
|
/* -------- reset the timer -------- */
|
||||||
|
set_timer(clocktimer, 1);
|
||||||
|
/* -------- post the clock event -------- */
|
||||||
|
PostEvent(CLOCKTICK, (PARAM)timestr, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// WaitForSingleObject (hInput, INFINITE);
|
||||||
|
ReadConsoleInput (hInput, &ir, 1, &dwRead);
|
||||||
|
|
||||||
|
if ((ir.EventType == KEY_EVENT) &&
|
||||||
|
(ir.Event.KeyEvent.bKeyDown == TRUE))
|
||||||
|
{
|
||||||
|
/* handle key down events */
|
||||||
|
|
||||||
|
/* handle shift state changes */
|
||||||
|
if (ir.Event.KeyEvent.dwControlKeyState &
|
||||||
|
(LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED))
|
||||||
|
{
|
||||||
|
sk |= ALTKEY;
|
||||||
|
}
|
||||||
|
if (ir.Event.KeyEvent.dwControlKeyState &
|
||||||
|
(LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
|
||||||
|
{
|
||||||
|
sk |= CTRLKEY;
|
||||||
|
}
|
||||||
|
if (ir.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED)
|
||||||
|
{
|
||||||
|
sk |= LEFTSHIFT + RIGHTSHIFT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sk != OldShiftKeys)
|
||||||
|
{
|
||||||
|
OldShiftKeys = sk;
|
||||||
|
/* the shift status changed */
|
||||||
|
PostEvent(SHIFT_CHANGED, sk, 0);
|
||||||
|
#if 0
|
||||||
|
if (sk & ALTKEY)
|
||||||
|
AltDown = TRUE;
|
||||||
|
else
|
||||||
|
AltDown = FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ir.Event.KeyEvent.uChar.AsciiChar == 0)
|
||||||
|
{
|
||||||
|
switch (ir.Event.KeyEvent.wVirtualKeyCode)
|
||||||
|
{
|
||||||
|
case VK_F1:
|
||||||
|
c = F1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VK_F4:
|
||||||
|
if (sk & ALTKEY)
|
||||||
|
c = ALT_F4;
|
||||||
|
else if (sk & CTRLKEY)
|
||||||
|
c = CTRL_F4;
|
||||||
|
else
|
||||||
|
c = F4;
|
||||||
|
|
||||||
|
case VK_F10:
|
||||||
|
c = F10;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VK_UP:
|
||||||
|
c = UP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VK_DOWN:
|
||||||
|
c = DN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VK_LEFT:
|
||||||
|
c = BS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VK_RIGHT:
|
||||||
|
c = FWD;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VK_INSERT:
|
||||||
|
c = INS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VK_DELETE:
|
||||||
|
c = DEL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VK_HOME:
|
||||||
|
c = HOME;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VK_END:
|
||||||
|
c = END;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VK_PRIOR:
|
||||||
|
c = PGUP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VK_NEXT:
|
||||||
|
c = PGDN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* special handling of SHIFT+TAB */
|
||||||
|
if (ir.Event.KeyEvent.uChar.AsciiChar == VK_TAB &&
|
||||||
|
(ir.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED))
|
||||||
|
c = SHIFT_HT;
|
||||||
|
else
|
||||||
|
c = ir.Event.KeyEvent.uChar.AsciiChar;
|
||||||
|
}
|
||||||
|
|
||||||
|
PostEvent (KEYBOARD, c, sk);
|
||||||
|
}
|
||||||
|
else if (ir.EventType == MOUSE_EVENT)
|
||||||
|
{
|
||||||
|
/* handle mouse events */
|
||||||
|
if (ir.Event.MouseEvent.dwEventFlags == MOUSE_MOVED)
|
||||||
|
{
|
||||||
|
PostEvent (MOUSE_MOVED,
|
||||||
|
ir.Event.MouseEvent.dwMousePosition.X,
|
||||||
|
ir.Event.MouseEvent.dwMousePosition.Y);
|
||||||
|
}
|
||||||
|
else if (ir.Event.MouseEvent.dwEventFlags == DOUBLE_CLICK)
|
||||||
|
{
|
||||||
|
if (ir.Event.MouseEvent.dwButtonState ==
|
||||||
|
FROM_LEFT_1ST_BUTTON_PRESSED)
|
||||||
|
{
|
||||||
|
PostEvent (DOUBLE_CLICK,
|
||||||
|
ir.Event.MouseEvent.dwMousePosition.X,
|
||||||
|
ir.Event.MouseEvent.dwMousePosition.Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ir.Event.MouseEvent.dwEventFlags == 0)
|
||||||
|
{
|
||||||
|
/* single click */
|
||||||
|
if (ir.Event.MouseEvent.dwButtonState ==
|
||||||
|
FROM_LEFT_1ST_BUTTON_PRESSED)
|
||||||
|
{
|
||||||
|
PostEvent (LEFT_BUTTON,
|
||||||
|
ir.Event.MouseEvent.dwMousePosition.X,
|
||||||
|
ir.Event.MouseEvent.dwMousePosition.Y);
|
||||||
|
}
|
||||||
|
else if (ir.Event.MouseEvent.dwButtonState ==
|
||||||
|
RIGHTMOST_BUTTON_PRESSED)
|
||||||
|
{
|
||||||
|
PostEvent (RIGHT_BUTTON,
|
||||||
|
ir.Event.MouseEvent.dwMousePosition.X,
|
||||||
|
ir.Event.MouseEvent.dwMousePosition.Y);
|
||||||
|
}
|
||||||
|
else if (ir.Event.MouseEvent.dwButtonState == 0)
|
||||||
|
{
|
||||||
|
PostEvent (DFM_BUTTON_RELEASED,
|
||||||
|
ir.Event.MouseEvent.dwMousePosition.X,
|
||||||
|
ir.Event.MouseEvent.dwMousePosition.Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ----- post a message and parameters to msg queue ---- */
|
||||||
|
void DfPostMessage(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
|
||||||
|
{
|
||||||
|
if (msg == ENDDIALOG)
|
||||||
|
{
|
||||||
|
msg++;
|
||||||
|
--msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MsgQueueCtr != MAXMESSAGES)
|
||||||
|
{
|
||||||
|
MsgQueue[MsgQueueOnCtr].wnd = wnd;
|
||||||
|
MsgQueue[MsgQueueOnCtr].msg = msg;
|
||||||
|
MsgQueue[MsgQueueOnCtr].p1 = p1;
|
||||||
|
MsgQueue[MsgQueueOnCtr].p2 = p2;
|
||||||
|
if (++MsgQueueOnCtr == MAXMESSAGES)
|
||||||
|
MsgQueueOnCtr = 0;
|
||||||
|
MsgQueueCtr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------- send a message to a window ----------- */
|
||||||
|
int DfSendMessage(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
|
||||||
|
{
|
||||||
|
int rtn = TRUE, x, y;
|
||||||
|
|
||||||
|
#ifdef INCLUDE_LOGGING
|
||||||
|
LogMessages(wnd, msg, p1, p2);
|
||||||
|
#endif
|
||||||
|
if (wnd != NULL)
|
||||||
|
switch (msg) {
|
||||||
|
case PAINT:
|
||||||
|
case BORDER:
|
||||||
|
/* ------- don't send these messages unless the
|
||||||
|
window is visible -------- */
|
||||||
|
if (isVisible(wnd))
|
||||||
|
rtn = (*wnd->wndproc)(wnd, msg, p1, p2);
|
||||||
|
break;
|
||||||
|
case RIGHT_BUTTON:
|
||||||
|
case LEFT_BUTTON:
|
||||||
|
case DOUBLE_CLICK:
|
||||||
|
case DFM_BUTTON_RELEASED:
|
||||||
|
/* --- don't send these messages unless the
|
||||||
|
window is visible or has captured the mouse -- */
|
||||||
|
if (isVisible(wnd) || wnd == CaptureMouse)
|
||||||
|
rtn = (*wnd->wndproc)(wnd, msg, p1, p2);
|
||||||
|
break;
|
||||||
|
case KEYBOARD:
|
||||||
|
case SHIFT_CHANGED:
|
||||||
|
/* ------- don't send these messages unless the
|
||||||
|
window is visible or has captured the keyboard -- */
|
||||||
|
if (!(isVisible(wnd) || wnd == CaptureKeyboard))
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
rtn = (*wnd->wndproc)(wnd, msg, p1, p2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* ----- window processor returned true or the message was sent
|
||||||
|
to no window at all (NULL) ----- */
|
||||||
|
if (rtn != FALSE) {
|
||||||
|
/* --------- process messages that a window sends to the
|
||||||
|
system itself ---------- */
|
||||||
|
switch (msg) {
|
||||||
|
case DFM_STOP:
|
||||||
|
StopMsg();
|
||||||
|
break;
|
||||||
|
/* ------- clock messages --------- */
|
||||||
|
case CAPTURE_CLOCK:
|
||||||
|
Cwnd = wnd;
|
||||||
|
set_timer(clocktimer, 0);
|
||||||
|
break;
|
||||||
|
case RELEASE_CLOCK:
|
||||||
|
Cwnd = NULL;
|
||||||
|
disable_timer(clocktimer);
|
||||||
|
break;
|
||||||
|
/* -------- keyboard messages ------- */
|
||||||
|
case KEYBOARD_CURSOR:
|
||||||
|
if (wnd == NULL)
|
||||||
|
cursor((int)p1, (int)p2);
|
||||||
|
else if (wnd == inFocus)
|
||||||
|
cursor(GetClientLeft(wnd)+(int)p1,
|
||||||
|
GetClientTop(wnd)+(int)p2);
|
||||||
|
break;
|
||||||
|
case CAPTURE_KEYBOARD:
|
||||||
|
if (p2)
|
||||||
|
((DFWINDOW)p2)->PrevKeyboard=CaptureKeyboard;
|
||||||
|
else
|
||||||
|
wnd->PrevKeyboard = CaptureKeyboard;
|
||||||
|
CaptureKeyboard = wnd;
|
||||||
|
NoChildCaptureKeyboard = (int)p1;
|
||||||
|
break;
|
||||||
|
case RELEASE_KEYBOARD:
|
||||||
|
if (wnd != NULL)
|
||||||
|
{
|
||||||
|
if (CaptureKeyboard == wnd || (int)p1)
|
||||||
|
CaptureKeyboard = wnd->PrevKeyboard;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DFWINDOW twnd = CaptureKeyboard;
|
||||||
|
while (twnd != NULL)
|
||||||
|
{
|
||||||
|
if (twnd->PrevKeyboard == wnd)
|
||||||
|
{
|
||||||
|
twnd->PrevKeyboard = wnd->PrevKeyboard;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
twnd = twnd->PrevKeyboard;
|
||||||
|
}
|
||||||
|
if (twnd == NULL)
|
||||||
|
CaptureKeyboard = NULL;
|
||||||
|
}
|
||||||
|
wnd->PrevKeyboard = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
CaptureKeyboard = NULL;
|
||||||
|
NoChildCaptureKeyboard = FALSE;
|
||||||
|
break;
|
||||||
|
case CURRENT_KEYBOARD_CURSOR:
|
||||||
|
curr_cursor(&x, &y);
|
||||||
|
*(int*)p1 = x;
|
||||||
|
*(int*)p2 = y;
|
||||||
|
break;
|
||||||
|
case SAVE_CURSOR:
|
||||||
|
savecursor();
|
||||||
|
break;
|
||||||
|
case RESTORE_CURSOR:
|
||||||
|
restorecursor();
|
||||||
|
break;
|
||||||
|
case HIDE_CURSOR:
|
||||||
|
normalcursor();
|
||||||
|
hidecursor();
|
||||||
|
break;
|
||||||
|
case SHOW_CURSOR:
|
||||||
|
if (p1)
|
||||||
|
set_cursor_size(100);
|
||||||
|
else
|
||||||
|
set_cursor_size(5);
|
||||||
|
unhidecursor();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CAPTURE_MOUSE:
|
||||||
|
if (p2)
|
||||||
|
((DFWINDOW)p2)->PrevMouse = CaptureMouse;
|
||||||
|
else
|
||||||
|
wnd->PrevMouse = CaptureMouse;
|
||||||
|
CaptureMouse = wnd;
|
||||||
|
NoChildCaptureMouse = (int)p1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RELEASE_MOUSE:
|
||||||
|
if (wnd != NULL)
|
||||||
|
{
|
||||||
|
if (CaptureMouse == wnd || (int)p1)
|
||||||
|
CaptureMouse = wnd->PrevMouse;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DFWINDOW twnd = CaptureMouse;
|
||||||
|
while (twnd != NULL)
|
||||||
|
{
|
||||||
|
if (twnd->PrevMouse == wnd)
|
||||||
|
{
|
||||||
|
twnd->PrevMouse = wnd->PrevMouse;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
twnd = twnd->PrevMouse;
|
||||||
|
}
|
||||||
|
if (twnd == NULL)
|
||||||
|
CaptureMouse = NULL;
|
||||||
|
}
|
||||||
|
wnd->PrevMouse = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
CaptureMouse = NULL;
|
||||||
|
NoChildCaptureMouse = FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DFRECT VisibleRect(DFWINDOW wnd)
|
||||||
|
{
|
||||||
|
DFRECT rc = WindowRect(wnd);
|
||||||
|
if (!TestAttribute(wnd, NOCLIP))
|
||||||
|
{
|
||||||
|
DFWINDOW pwnd = GetParent(wnd);
|
||||||
|
DFRECT prc;
|
||||||
|
prc = ClientRect(pwnd);
|
||||||
|
while (pwnd != NULL)
|
||||||
|
{
|
||||||
|
if (TestAttribute(pwnd, NOCLIP))
|
||||||
|
break;
|
||||||
|
rc = subRectangle(rc, prc);
|
||||||
|
if (!ValidRect(rc))
|
||||||
|
break;
|
||||||
|
if ((pwnd = GetParent(pwnd)) != NULL)
|
||||||
|
prc = ClientRect(pwnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----- find window that mouse coordinates are in --- */
|
||||||
|
static DFWINDOW inWindow(DFWINDOW wnd, int x, int y)
|
||||||
|
{
|
||||||
|
DFWINDOW Hit = NULL;
|
||||||
|
while (wnd != NULL) {
|
||||||
|
if (isVisible(wnd)) {
|
||||||
|
DFWINDOW wnd1;
|
||||||
|
DFRECT rc = VisibleRect(wnd);
|
||||||
|
if (InsideRect(x, y, rc))
|
||||||
|
Hit = wnd;
|
||||||
|
if ((wnd1 = inWindow(LastWindow(wnd), x, y)) != NULL)
|
||||||
|
Hit = wnd1;
|
||||||
|
if (Hit != NULL)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
wnd = PrevWindow(wnd);
|
||||||
|
}
|
||||||
|
return Hit;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DFWINDOW MouseWindow(int x, int y)
|
||||||
|
{
|
||||||
|
/* get the window in which a mouse event occurred */
|
||||||
|
DFWINDOW Mwnd = inWindow(ApplicationWindow, x, y);
|
||||||
|
|
||||||
|
/* ---- process mouse captures ----- */
|
||||||
|
if (CaptureMouse != NULL)
|
||||||
|
{
|
||||||
|
if (NoChildCaptureMouse ||
|
||||||
|
Mwnd == NULL ||
|
||||||
|
!isAncestor(Mwnd, CaptureMouse))
|
||||||
|
Mwnd = CaptureMouse;
|
||||||
|
}
|
||||||
|
return Mwnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void handshake(void)
|
||||||
|
{
|
||||||
|
handshaking++;
|
||||||
|
DfDispatchMessage ();
|
||||||
|
--handshaking;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ---- dispatch messages to the message proc function ---- */
|
||||||
|
BOOL DfDispatchMessage (void)
|
||||||
|
{
|
||||||
|
DFWINDOW Mwnd, Kwnd;
|
||||||
|
|
||||||
|
/* -------- collect mouse and keyboard events ------- */
|
||||||
|
collect_events();
|
||||||
|
|
||||||
|
/* --------- dequeue and process events -------- */
|
||||||
|
while (EventQueueCtr > 0)
|
||||||
|
{
|
||||||
|
struct events ev;
|
||||||
|
|
||||||
|
ev = EventQueue[EventQueueOffCtr];
|
||||||
|
if (++EventQueueOffCtr == MAXMESSAGES)
|
||||||
|
EventQueueOffCtr = 0;
|
||||||
|
--EventQueueCtr;
|
||||||
|
|
||||||
|
/* get the window in which a keyboard event occurred */
|
||||||
|
Kwnd = inFocus;
|
||||||
|
|
||||||
|
/* process keyboard captures */
|
||||||
|
if (CaptureKeyboard != NULL)
|
||||||
|
{
|
||||||
|
if (Kwnd == NULL ||
|
||||||
|
NoChildCaptureKeyboard ||
|
||||||
|
!isAncestor(Kwnd, CaptureKeyboard))
|
||||||
|
Kwnd = CaptureKeyboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* send mouse and keyboard messages to the
|
||||||
|
window that should get them */
|
||||||
|
switch (ev.event)
|
||||||
|
{
|
||||||
|
case SHIFT_CHANGED:
|
||||||
|
case KEYBOARD:
|
||||||
|
if (!handshaking)
|
||||||
|
DfSendMessage(Kwnd, ev.event, ev.mx, ev.my);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LEFT_BUTTON:
|
||||||
|
if (!handshaking)
|
||||||
|
{
|
||||||
|
Mwnd = MouseWindow(ev.mx, ev.my);
|
||||||
|
if (!CaptureMouse ||
|
||||||
|
(!NoChildCaptureMouse &&
|
||||||
|
isAncestor(Mwnd, CaptureMouse)))
|
||||||
|
{
|
||||||
|
if (Mwnd != inFocus)
|
||||||
|
DfSendMessage(Mwnd, SETFOCUS, TRUE, 0);
|
||||||
|
DfSendMessage(Mwnd, LEFT_BUTTON, ev.mx, ev.my);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DFM_BUTTON_RELEASED:
|
||||||
|
case DOUBLE_CLICK:
|
||||||
|
case RIGHT_BUTTON:
|
||||||
|
if (handshaking)
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MOUSE_MOVED:
|
||||||
|
Mwnd = MouseWindow(ev.mx, ev.my);
|
||||||
|
DfSendMessage(Mwnd, ev.event, ev.mx, ev.my);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CLOCKTICK:
|
||||||
|
DfSendMessage(Cwnd, ev.event, ev.mx, ev.my);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------ dequeue and process messages ----- */
|
||||||
|
while (MsgQueueCtr > 0)
|
||||||
|
{
|
||||||
|
struct msgs mq;
|
||||||
|
|
||||||
|
mq = MsgQueue[MsgQueueOffCtr];
|
||||||
|
|
||||||
|
if (++MsgQueueOffCtr == MAXMESSAGES)
|
||||||
|
MsgQueueOffCtr = 0;
|
||||||
|
--MsgQueueCtr;
|
||||||
|
|
||||||
|
DfSendMessage (mq.wnd, mq.msg, mq.p1, mq.p2);
|
||||||
|
if (mq.msg == ENDDIALOG)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (mq.msg == DFM_STOP)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
106
rosapps/lib/dflat32/rect.c
Normal file
106
rosapps/lib/dflat32/rect.c
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
/* ------------- rect.c --------------- */
|
||||||
|
|
||||||
|
#include <dflat32/dflat.h>
|
||||||
|
|
||||||
|
/* --- Produce the vector end points produced by the overlap
|
||||||
|
of two other vectors --- */
|
||||||
|
static void subVector(int *v1, int *v2,
|
||||||
|
int t1, int t2, int o1, int o2)
|
||||||
|
{
|
||||||
|
*v1 = *v2 = -1;
|
||||||
|
if (within(o1, t1, t2)) {
|
||||||
|
*v1 = o1;
|
||||||
|
if (within(o2, t1, t2))
|
||||||
|
*v2 = o2;
|
||||||
|
else
|
||||||
|
*v2 = t2;
|
||||||
|
}
|
||||||
|
else if (within(o2, t1, t2)) {
|
||||||
|
*v2 = o2;
|
||||||
|
if (within(o1, t1, t2))
|
||||||
|
*v1 = o1;
|
||||||
|
else
|
||||||
|
*v1 = t1;
|
||||||
|
}
|
||||||
|
else if (within(t1, o1, o2)) {
|
||||||
|
*v1 = t1;
|
||||||
|
if (within(t2, o1, o2))
|
||||||
|
*v2 = t2;
|
||||||
|
else
|
||||||
|
*v2 = o2;
|
||||||
|
}
|
||||||
|
else if (within(t2, o1, o2)) {
|
||||||
|
*v2 = t2;
|
||||||
|
if (within(t1, o1, o2))
|
||||||
|
*v1 = t1;
|
||||||
|
else
|
||||||
|
*v1 = o1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Return the rectangle produced by the overlap
|
||||||
|
of two other rectangles ---- */
|
||||||
|
DFRECT subRectangle(DFRECT r1, DFRECT r2)
|
||||||
|
{
|
||||||
|
DFRECT r = {0,0,0,0};
|
||||||
|
subVector((int *) &RectLeft(r), (int *) &RectRight(r),
|
||||||
|
RectLeft(r1), RectRight(r1),
|
||||||
|
RectLeft(r2), RectRight(r2));
|
||||||
|
subVector((int *) &RectTop(r), (int *) &RectBottom(r),
|
||||||
|
RectTop(r1), RectBottom(r1),
|
||||||
|
RectTop(r2), RectBottom(r2));
|
||||||
|
if (RectRight(r) == -1 || RectTop(r) == -1)
|
||||||
|
RectRight(r) =
|
||||||
|
RectLeft(r) =
|
||||||
|
RectTop(r) =
|
||||||
|
RectBottom(r) = 0;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------- return the client rectangle of a window ------ */
|
||||||
|
DFRECT ClientRect(void *wnd)
|
||||||
|
{
|
||||||
|
DFRECT rc;
|
||||||
|
|
||||||
|
if (wnd == NULL)
|
||||||
|
{
|
||||||
|
RectLeft(rc) = 1; // GetClientLeft((DFWINDOW)wnd);
|
||||||
|
RectTop(rc) = 2; // GetClientTop((DFWINDOW)wnd);
|
||||||
|
RectRight(rc) = DfGetScreenWidth () - 2; // GetClientRight((DFWINDOW)wnd);
|
||||||
|
RectBottom(rc) = DfGetScreenHeight () - 2; // GetClientBottom((DFWINDOW)wnd);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
RectLeft(rc) = GetClientLeft((DFWINDOW)wnd);
|
||||||
|
RectTop(rc) = GetClientTop((DFWINDOW)wnd);
|
||||||
|
RectRight(rc) = GetClientRight((DFWINDOW)wnd);
|
||||||
|
RectBottom(rc) = GetClientBottom((DFWINDOW)wnd);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----- return the rectangle relative to
|
||||||
|
its window's screen position -------- */
|
||||||
|
DFRECT RelativeWindowRect(void *wnd, DFRECT rc)
|
||||||
|
{
|
||||||
|
RectLeft(rc) -= GetLeft((DFWINDOW)wnd);
|
||||||
|
RectRight(rc) -= GetLeft((DFWINDOW)wnd);
|
||||||
|
RectTop(rc) -= GetTop((DFWINDOW)wnd);
|
||||||
|
RectBottom(rc) -= GetTop((DFWINDOW)wnd);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----- clip a rectangle to the parents of the window ----- */
|
||||||
|
DFRECT ClipRectangle(void *wnd, DFRECT rc)
|
||||||
|
{
|
||||||
|
DFRECT sr;
|
||||||
|
RectLeft(sr) = RectTop(sr) = 0;
|
||||||
|
RectRight(sr) = DfGetScreenWidth()-1;
|
||||||
|
RectBottom(sr) = DfGetScreenHeight()-1;
|
||||||
|
if (!TestAttribute((DFWINDOW)wnd, NOCLIP))
|
||||||
|
while ((wnd = GetParent((DFWINDOW)wnd)) != NULL)
|
||||||
|
rc = subRectangle(rc, ClientRect(wnd));
|
||||||
|
return subRectangle(rc, sr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
48
rosapps/lib/dflat32/stubs.c
Normal file
48
rosapps/lib/dflat32/stubs.c
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#include <dflat32/dflat.h>
|
||||||
|
|
||||||
|
DFWINDOW ApplicationWindow; //applicat.c
|
||||||
|
|
||||||
|
void ClearDialogBoxes(void) // no clue
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// from normal.c
|
||||||
|
|
||||||
|
/* -------- array of class definitions -------- */
|
||||||
|
CLASSDEFS classdefs[] = {
|
||||||
|
#undef ClassDef
|
||||||
|
#define ClassDef(c,b,p,a) {b,p,a},
|
||||||
|
// #include <dflat32/classes.h>
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOL isAncestor(DFWINDOW wnd, DFWINDOW awnd)
|
||||||
|
{
|
||||||
|
while (wnd != NULL) {
|
||||||
|
if (wnd == awnd)
|
||||||
|
return TRUE;
|
||||||
|
wnd = GetParent(wnd);
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL isVisible(DFWINDOW wnd)
|
||||||
|
{
|
||||||
|
while (wnd != NULL) {
|
||||||
|
if (isHidden(wnd))
|
||||||
|
return FALSE;
|
||||||
|
wnd = GetParent(wnd);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BuildTextPointers(DFWINDOW wnd)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// log.c
|
||||||
|
void LogMessages (DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
|
||||||
|
{
|
||||||
|
}
|
323
rosapps/lib/dflat32/video.c
Normal file
323
rosapps/lib/dflat32/video.c
Normal file
|
@ -0,0 +1,323 @@
|
||||||
|
/* --------------------- video.c -------------------- */
|
||||||
|
|
||||||
|
#include <dflat32/dflat.h>
|
||||||
|
|
||||||
|
#define clr(fg,bg) ((fg)|((bg)<<4))
|
||||||
|
|
||||||
|
BOOL ClipString;
|
||||||
|
|
||||||
|
/* -- read a rectangle of video memory into a save buffer -- */
|
||||||
|
void GetVideo(DFRECT rc, PCHAR_INFO bf)
|
||||||
|
{
|
||||||
|
COORD Size;
|
||||||
|
COORD Pos;
|
||||||
|
SMALL_RECT Rect;
|
||||||
|
|
||||||
|
Size.X = RectRight(rc) - RectLeft(rc) + 1;
|
||||||
|
Size.Y = RectBottom(rc) - RectTop(rc) + 1;
|
||||||
|
|
||||||
|
Pos.X = 0;
|
||||||
|
Pos.Y = 0;
|
||||||
|
|
||||||
|
Rect.Left = RectLeft(rc);
|
||||||
|
Rect.Top = RectTop(rc);
|
||||||
|
Rect.Right = RectRight(rc);
|
||||||
|
Rect.Bottom = RectBottom(rc);
|
||||||
|
|
||||||
|
ReadConsoleOutput (GetStdHandle (STD_OUTPUT_HANDLE),
|
||||||
|
bf,
|
||||||
|
Size,
|
||||||
|
Pos,
|
||||||
|
&Rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -- write a rectangle of video memory from a save buffer -- */
|
||||||
|
void StoreVideo(DFRECT rc, PCHAR_INFO bf)
|
||||||
|
{
|
||||||
|
COORD Size;
|
||||||
|
COORD Pos;
|
||||||
|
SMALL_RECT Rect;
|
||||||
|
|
||||||
|
Size.X = RectRight(rc) - RectLeft(rc) + 1;
|
||||||
|
Size.Y = RectBottom(rc) - RectTop(rc) + 1;
|
||||||
|
|
||||||
|
Pos.X = 0;
|
||||||
|
Pos.Y = 0;
|
||||||
|
|
||||||
|
Rect.Left = RectLeft(rc);
|
||||||
|
Rect.Top = RectTop(rc);
|
||||||
|
Rect.Right = RectRight(rc);
|
||||||
|
Rect.Bottom = RectBottom(rc);
|
||||||
|
|
||||||
|
WriteConsoleOutput (GetStdHandle (STD_OUTPUT_HANDLE),
|
||||||
|
bf,
|
||||||
|
Size,
|
||||||
|
Pos,
|
||||||
|
&Rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------- read a character of video memory ------- */
|
||||||
|
char GetVideoChar(int x, int y)
|
||||||
|
{
|
||||||
|
COORD pos;
|
||||||
|
DWORD dwRead;
|
||||||
|
char ch;
|
||||||
|
|
||||||
|
pos.X = x;
|
||||||
|
pos.Y = y;
|
||||||
|
|
||||||
|
ReadConsoleOutputCharacter (GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
|
&ch,
|
||||||
|
1,
|
||||||
|
pos,
|
||||||
|
&dwRead);
|
||||||
|
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------- write a character of video memory ------- */
|
||||||
|
void PutVideoChar(int x, int y, int ch)
|
||||||
|
{
|
||||||
|
COORD pos;
|
||||||
|
DWORD dwWritten;
|
||||||
|
|
||||||
|
if (x < sScreenWidth && y < sScreenHeight)
|
||||||
|
{
|
||||||
|
pos.X = x;
|
||||||
|
pos.Y = y;
|
||||||
|
|
||||||
|
WriteConsoleOutputCharacter (GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
|
(char *)&ch,
|
||||||
|
1,
|
||||||
|
pos,
|
||||||
|
&dwWritten);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CharInView(DFWINDOW wnd, int x, int y)
|
||||||
|
{
|
||||||
|
DFWINDOW nwnd = NextWindow(wnd);
|
||||||
|
DFWINDOW pwnd;
|
||||||
|
DFRECT rc;
|
||||||
|
int x1 = GetLeft(wnd)+x;
|
||||||
|
int y1 = GetTop(wnd)+y;
|
||||||
|
|
||||||
|
if (!TestAttribute(wnd, VISIBLE))
|
||||||
|
return FALSE;
|
||||||
|
if (!TestAttribute(wnd, NOCLIP))
|
||||||
|
{
|
||||||
|
DFWINDOW wnd1 = GetParent(wnd);
|
||||||
|
while (wnd1 != NULL)
|
||||||
|
{
|
||||||
|
/* clip character to parent's borders */
|
||||||
|
if (!TestAttribute(wnd1, VISIBLE))
|
||||||
|
return FALSE;
|
||||||
|
if (!InsideRect(x1, y1, ClientRect(wnd1)))
|
||||||
|
return FALSE;
|
||||||
|
wnd1 = GetParent(wnd1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (nwnd != NULL)
|
||||||
|
{
|
||||||
|
if (!isHidden(nwnd) && !isAncestor(wnd, nwnd))
|
||||||
|
{
|
||||||
|
rc = WindowRect(nwnd);
|
||||||
|
if (TestAttribute(nwnd, SHADOW))
|
||||||
|
{
|
||||||
|
RectBottom(rc)++;
|
||||||
|
RectRight(rc)++;
|
||||||
|
}
|
||||||
|
if (!TestAttribute(nwnd, NOCLIP))
|
||||||
|
{
|
||||||
|
pwnd = nwnd;
|
||||||
|
while (GetParent(pwnd))
|
||||||
|
{
|
||||||
|
pwnd = GetParent(pwnd);
|
||||||
|
rc = subRectangle(rc, ClientRect(pwnd));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (InsideRect(x1,y1,rc))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
nwnd = NextWindow(nwnd);
|
||||||
|
}
|
||||||
|
return (x1 < sScreenWidth && y1 < sScreenHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------- write a character to a window ------- */
|
||||||
|
void wputch(DFWINDOW wnd, int c, int x, int y)
|
||||||
|
{
|
||||||
|
if (CharInView(wnd, x, y))
|
||||||
|
{
|
||||||
|
DWORD dwWritten;
|
||||||
|
COORD pos;
|
||||||
|
WORD Attr;
|
||||||
|
|
||||||
|
pos.X = GetLeft(wnd)+x;
|
||||||
|
pos.Y = GetTop(wnd)+y;
|
||||||
|
|
||||||
|
Attr = clr(foreground, background);
|
||||||
|
|
||||||
|
WriteConsoleOutputAttribute (GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
|
&Attr,
|
||||||
|
1,
|
||||||
|
pos,
|
||||||
|
&dwWritten);
|
||||||
|
|
||||||
|
WriteConsoleOutputCharacter (GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
|
(char *)&c,
|
||||||
|
1,
|
||||||
|
pos,
|
||||||
|
&dwWritten);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------- write a string to a window ---------- */
|
||||||
|
void wputs(DFWINDOW wnd, void *s, int x, int y)
|
||||||
|
{
|
||||||
|
|
||||||
|
int x1 = GetLeft(wnd)+x;
|
||||||
|
int x2 = x1;
|
||||||
|
int y1 = GetTop(wnd)+y;
|
||||||
|
|
||||||
|
if (x1 < sScreenWidth && y1 < sScreenHeight && isVisible(wnd))
|
||||||
|
{
|
||||||
|
char ln[200];
|
||||||
|
WORD attr[200];
|
||||||
|
char *cp = ln;
|
||||||
|
WORD *ap = attr;
|
||||||
|
unsigned char *str = s;
|
||||||
|
int fg = foreground;
|
||||||
|
int bg = background;
|
||||||
|
int len;
|
||||||
|
int off = 0;
|
||||||
|
while (*str)
|
||||||
|
{
|
||||||
|
if (*str == CHANGECOLOR)
|
||||||
|
{
|
||||||
|
str++;
|
||||||
|
foreground = (*str++) & 0x7f;
|
||||||
|
background = (*str++) & 0x7f;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*str == RESETCOLOR)
|
||||||
|
{
|
||||||
|
foreground = fg & 0x7f;
|
||||||
|
background = bg & 0x7f;
|
||||||
|
str++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*cp = (*str & 255);
|
||||||
|
*ap = (WORD)clr(foreground, background);
|
||||||
|
// *cp1 = (*str & 255) | (clr(foreground, background) << 8);
|
||||||
|
// if (ClipString)
|
||||||
|
// if (!CharInView(wnd, x, y))
|
||||||
|
// *cp1 = peek(video_address, vad(x2,y1));
|
||||||
|
cp++;
|
||||||
|
ap++;
|
||||||
|
str++;
|
||||||
|
x++;
|
||||||
|
x2++;
|
||||||
|
}
|
||||||
|
foreground = fg;
|
||||||
|
background = bg;
|
||||||
|
len = (int)(cp-ln);
|
||||||
|
if (x1+len > sScreenWidth)
|
||||||
|
len = sScreenWidth-x1;
|
||||||
|
|
||||||
|
if (!ClipString && !TestAttribute(wnd, NOCLIP))
|
||||||
|
{
|
||||||
|
/* -- clip the line to within ancestor windows -- */
|
||||||
|
DFRECT rc = WindowRect(wnd);
|
||||||
|
DFWINDOW nwnd = GetParent(wnd);
|
||||||
|
while (len > 0 && nwnd != NULL)
|
||||||
|
{
|
||||||
|
if (!isVisible(nwnd))
|
||||||
|
{
|
||||||
|
len = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
rc = subRectangle(rc, ClientRect(nwnd));
|
||||||
|
nwnd = GetParent(nwnd);
|
||||||
|
}
|
||||||
|
while (len > 0 && !InsideRect(x1+off,y1,rc))
|
||||||
|
{
|
||||||
|
off++;
|
||||||
|
--len;
|
||||||
|
}
|
||||||
|
if (len > 0)
|
||||||
|
{
|
||||||
|
x2 = x1+len-1;
|
||||||
|
while (len && !InsideRect(x2,y1,rc))
|
||||||
|
{
|
||||||
|
--x2;
|
||||||
|
--len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (len > 0)
|
||||||
|
{
|
||||||
|
COORD pos;
|
||||||
|
DWORD dwWritten;
|
||||||
|
|
||||||
|
pos.X = x1;
|
||||||
|
pos.Y = y1;
|
||||||
|
|
||||||
|
WriteConsoleOutputAttribute (GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
|
attr,
|
||||||
|
len,
|
||||||
|
pos,
|
||||||
|
&dwWritten);
|
||||||
|
|
||||||
|
WriteConsoleOutputCharacter (GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
|
ln,
|
||||||
|
len,
|
||||||
|
pos,
|
||||||
|
&dwWritten);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------- scroll the window. d: 1 = up, 0 = dn ---------- */
|
||||||
|
void scroll_window(DFWINDOW wnd, DFRECT rc, int d)
|
||||||
|
{
|
||||||
|
if (RectTop(rc) != RectBottom(rc))
|
||||||
|
{
|
||||||
|
CHAR_INFO ciFill;
|
||||||
|
SMALL_RECT rcScroll;
|
||||||
|
SMALL_RECT rcClip;
|
||||||
|
COORD pos;
|
||||||
|
|
||||||
|
ciFill.Attributes = clr(WndForeground(wnd),WndBackground(wnd));
|
||||||
|
ciFill.Char.AsciiChar = ' ';
|
||||||
|
|
||||||
|
rcScroll.Left = RectLeft(rc);
|
||||||
|
rcScroll.Right = RectRight(rc);
|
||||||
|
rcScroll.Top = RectTop(rc);
|
||||||
|
rcScroll.Bottom = RectBottom(rc);
|
||||||
|
|
||||||
|
rcClip = rcScroll;
|
||||||
|
|
||||||
|
pos.X = RectLeft(rc);
|
||||||
|
|
||||||
|
if (d == 0)
|
||||||
|
{
|
||||||
|
/* scroll 1 line down */
|
||||||
|
pos.Y = RectTop(rc)+1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* scroll 1 line up */
|
||||||
|
pos.Y = RectTop(rc)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScrollConsoleScreenBuffer (GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
|
&rcScroll,
|
||||||
|
&rcClip,
|
||||||
|
pos,
|
||||||
|
&ciFill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
521
rosapps/lib/dflat32/window.c
Normal file
521
rosapps/lib/dflat32/window.c
Normal file
|
@ -0,0 +1,521 @@
|
||||||
|
/* ---------- window.c ------------- */
|
||||||
|
|
||||||
|
#include <dflat32/dflat.h>
|
||||||
|
|
||||||
|
DFWINDOW inFocus = NULL;
|
||||||
|
|
||||||
|
int foreground, background; /* current video colors */
|
||||||
|
|
||||||
|
static void TopLine(DFWINDOW, int, DFRECT);
|
||||||
|
|
||||||
|
/* --------- create a window ------------ */
|
||||||
|
DFWINDOW DfCreateWindow(
|
||||||
|
DFCLASS class, /* class of this window */
|
||||||
|
char *ttl, /* title or NULL */
|
||||||
|
int left, int top, /* upper left coordinates */
|
||||||
|
int height, int width, /* dimensions */
|
||||||
|
void *extension, /* pointer to additional data */
|
||||||
|
DFWINDOW parent, /* parent of this window */
|
||||||
|
int (*wndproc)(struct window *,enum messages,PARAM,PARAM),
|
||||||
|
int attrib) /* window attribute */
|
||||||
|
{
|
||||||
|
DFWINDOW wnd = DFcalloc(1, sizeof(struct window));
|
||||||
|
if (wnd != NULL) {
|
||||||
|
int base;
|
||||||
|
/* ----- height, width = -1: fill the screen ------- */
|
||||||
|
if (height == -1)
|
||||||
|
height = sScreenHeight;
|
||||||
|
if (width == -1)
|
||||||
|
width = sScreenWidth;
|
||||||
|
/* ----- coordinates -1, -1 = center the window ---- */
|
||||||
|
if (left == -1)
|
||||||
|
wnd->rc.lf = (sScreenWidth-width)/2;
|
||||||
|
else
|
||||||
|
wnd->rc.lf = left;
|
||||||
|
if (top == -1)
|
||||||
|
wnd->rc.tp = (sScreenHeight-height)/2;
|
||||||
|
else
|
||||||
|
wnd->rc.tp = top;
|
||||||
|
wnd->attrib = attrib;
|
||||||
|
if (ttl != NULL)
|
||||||
|
AddAttribute(wnd, HASTITLEBAR);
|
||||||
|
if (wndproc == NULL)
|
||||||
|
wnd->wndproc = classdefs[class].wndproc;
|
||||||
|
else
|
||||||
|
wnd->wndproc = wndproc;
|
||||||
|
/* ---- derive attributes of base classes ---- */
|
||||||
|
base = class;
|
||||||
|
while (base != -1) {
|
||||||
|
AddAttribute(wnd, classdefs[base].attrib);
|
||||||
|
base = classdefs[base].base;
|
||||||
|
}
|
||||||
|
if (parent)
|
||||||
|
{
|
||||||
|
if (!TestAttribute(wnd, NOCLIP))
|
||||||
|
{
|
||||||
|
/* -- keep upper left within borders of parent - */
|
||||||
|
wnd->rc.lf = max(wnd->rc.lf,GetClientLeft(parent));
|
||||||
|
wnd->rc.tp = max(wnd->rc.tp,GetClientTop(parent));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
parent = ApplicationWindow;
|
||||||
|
|
||||||
|
wnd->class = class;
|
||||||
|
wnd->extension = extension;
|
||||||
|
wnd->rc.rt = GetLeft(wnd)+width-1;
|
||||||
|
wnd->rc.bt = GetTop(wnd)+height-1;
|
||||||
|
wnd->ht = height;
|
||||||
|
wnd->wd = width;
|
||||||
|
if (ttl != NULL)
|
||||||
|
InsertTitle(wnd, ttl);
|
||||||
|
wnd->parent = parent;
|
||||||
|
wnd->oldcondition = wnd->condition = ISRESTORED;
|
||||||
|
wnd->RestoredRC = wnd->rc;
|
||||||
|
InitWindowColors(wnd);
|
||||||
|
DfSendMessage(wnd, CREATE_WINDOW, 0, 0);
|
||||||
|
if (isVisible(wnd))
|
||||||
|
DfSendMessage(wnd, SHOW_WINDOW, 0, 0);
|
||||||
|
}
|
||||||
|
return wnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------- add a title to a window --------- */
|
||||||
|
void AddTitle(DFWINDOW wnd, char *ttl)
|
||||||
|
{
|
||||||
|
InsertTitle(wnd, ttl);
|
||||||
|
DfSendMessage(wnd, BORDER, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----- insert a title into a window ---------- */
|
||||||
|
void InsertTitle(DFWINDOW wnd, char *ttl)
|
||||||
|
{
|
||||||
|
wnd->title=DFrealloc(wnd->title,strlen(ttl)+1);
|
||||||
|
strcpy(wnd->title, ttl);
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned char line[300];
|
||||||
|
|
||||||
|
/* ------ write a line to video window client area ------ */
|
||||||
|
void writeline(DFWINDOW wnd, char *str, int x, int y, BOOL pad)
|
||||||
|
{
|
||||||
|
char *cp;
|
||||||
|
int len;
|
||||||
|
int dif;
|
||||||
|
char wline[200];
|
||||||
|
|
||||||
|
memset(wline, 0, 200);
|
||||||
|
len = LineLength(str);
|
||||||
|
dif = strlen(str) - len;
|
||||||
|
strncpy(wline, str, ClientWidth(wnd) + dif);
|
||||||
|
if (pad) {
|
||||||
|
cp = wline+strlen(wline);
|
||||||
|
while (len++ < ClientWidth(wnd)-x)
|
||||||
|
*cp++ = ' ';
|
||||||
|
}
|
||||||
|
wputs(wnd, wline, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
DFRECT AdjustRectangle(DFWINDOW wnd, DFRECT rc)
|
||||||
|
{
|
||||||
|
/* -------- adjust the rectangle ------- */
|
||||||
|
if (TestAttribute(wnd, HASBORDER)) {
|
||||||
|
if (RectLeft(rc) == 0)
|
||||||
|
--rc.rt;
|
||||||
|
else if (RectLeft(rc) < RectRight(rc) &&
|
||||||
|
RectLeft(rc) < WindowWidth(wnd)+1)
|
||||||
|
--rc.lf;
|
||||||
|
}
|
||||||
|
if (TestAttribute(wnd, HASBORDER | HASTITLEBAR)) {
|
||||||
|
if (RectTop(rc) == 0)
|
||||||
|
--rc.bt;
|
||||||
|
else if (RectTop(rc) < RectBottom(rc) &&
|
||||||
|
RectTop(rc) < WindowHeight(wnd)+1)
|
||||||
|
--rc.tp;
|
||||||
|
}
|
||||||
|
RectRight(rc) = max(RectLeft(rc),
|
||||||
|
min(RectRight(rc),WindowWidth(wnd)));
|
||||||
|
RectBottom(rc) = max(RectTop(rc),
|
||||||
|
min(RectBottom(rc),WindowHeight(wnd)));
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------- display a window's title --------- */
|
||||||
|
void DisplayTitle(DFWINDOW wnd, DFRECT *rcc)
|
||||||
|
{
|
||||||
|
if (GetTitle(wnd) != NULL)
|
||||||
|
{
|
||||||
|
int tlen = min((int)strlen(GetTitle(wnd)), (int)WindowWidth(wnd)-2);
|
||||||
|
int tend = WindowWidth(wnd)-3-BorderAdj(wnd);
|
||||||
|
DFRECT rc;
|
||||||
|
|
||||||
|
if (rcc == NULL)
|
||||||
|
rc = RelativeWindowRect(wnd, WindowRect(wnd));
|
||||||
|
else
|
||||||
|
rc = *rcc;
|
||||||
|
rc = AdjustRectangle(wnd, rc);
|
||||||
|
|
||||||
|
if (DfSendMessage(wnd, TITLE, (PARAM) rcc, 0))
|
||||||
|
{
|
||||||
|
if (wnd == inFocus)
|
||||||
|
{
|
||||||
|
foreground = cfg.clr[TITLEBAR] [HILITE_COLOR] [FG];
|
||||||
|
background = cfg.clr[TITLEBAR] [HILITE_COLOR] [BG];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreground = cfg.clr[TITLEBAR] [STD_COLOR] [FG];
|
||||||
|
background = cfg.clr[TITLEBAR] [STD_COLOR] [BG];
|
||||||
|
}
|
||||||
|
memset(line,' ',WindowWidth(wnd));
|
||||||
|
#ifdef INCLUDE_MINIMIZE
|
||||||
|
if (wnd->condition != ISMINIMIZED)
|
||||||
|
#endif
|
||||||
|
strncpy (line + ((WindowWidth(wnd)-2 - tlen) / 2),
|
||||||
|
wnd->title, tlen);
|
||||||
|
if (TestAttribute(wnd, CONTROLBOX))
|
||||||
|
line[2-BorderAdj(wnd)] = CONTROLBOXCHAR;
|
||||||
|
if (TestAttribute(wnd, MINMAXBOX))
|
||||||
|
{
|
||||||
|
switch (wnd->condition)
|
||||||
|
{
|
||||||
|
case ISRESTORED:
|
||||||
|
#ifdef INCLUDE_MAXIMIZE
|
||||||
|
line[tend+1] = MAXPOINTER;
|
||||||
|
#endif
|
||||||
|
#ifdef INCLUDE_MINIMIZE
|
||||||
|
line[tend] = MINPOINTER;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
#ifdef INCLUDE_MINIMIZE
|
||||||
|
case ISMINIMIZED:
|
||||||
|
line[tend+1] = MAXPOINTER;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef INCLUDE_MAXIMIZE
|
||||||
|
case ISMAXIMIZED:
|
||||||
|
#ifdef INCLUDE_MINIMIZE
|
||||||
|
line[tend] = MINPOINTER;
|
||||||
|
#endif
|
||||||
|
#ifdef INCLUDE_RESTORE
|
||||||
|
line[tend+1] = RESTOREPOINTER;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
line[RectRight(rc)+1] = line[tend+3] = '\0';
|
||||||
|
if (wnd != inFocus)
|
||||||
|
ClipString++;
|
||||||
|
writeline(wnd, line+RectLeft(rc),
|
||||||
|
RectLeft(rc)+BorderAdj(wnd),
|
||||||
|
0,
|
||||||
|
FALSE);
|
||||||
|
ClipString = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- display right border shadow character of a window --- */
|
||||||
|
static void shadow_char(DFWINDOW wnd, int y)
|
||||||
|
{
|
||||||
|
int fg = foreground;
|
||||||
|
int bg = background;
|
||||||
|
int x = WindowWidth(wnd);
|
||||||
|
char c = videochar(GetLeft(wnd)+x, GetTop(wnd)+y);
|
||||||
|
|
||||||
|
if (TestAttribute(wnd, SHADOW) == 0)
|
||||||
|
return;
|
||||||
|
foreground = DARKGRAY;
|
||||||
|
background = BLACK;
|
||||||
|
wputch(wnd, c, x, y);
|
||||||
|
foreground = fg;
|
||||||
|
background = bg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- display the bottom border shadow line for a window -- */
|
||||||
|
static void shadowline(DFWINDOW wnd, DFRECT rc)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int y = GetBottom(wnd)+1;
|
||||||
|
int fg = foreground;
|
||||||
|
int bg = background;
|
||||||
|
|
||||||
|
if ((TestAttribute(wnd, SHADOW)) == 0)
|
||||||
|
return;
|
||||||
|
for (i = 0; i < WindowWidth(wnd)+1; i++)
|
||||||
|
line[i] = videochar(GetLeft(wnd)+i, y);
|
||||||
|
line[i] = '\0';
|
||||||
|
foreground = DARKGRAY;
|
||||||
|
background = BLACK;
|
||||||
|
line[RectRight(rc)+1] = '\0';
|
||||||
|
if (RectLeft(rc) == 0)
|
||||||
|
rc.lf++;
|
||||||
|
ClipString++;
|
||||||
|
wputs(wnd, line+RectLeft(rc), RectLeft(rc),
|
||||||
|
WindowHeight(wnd));
|
||||||
|
--ClipString;
|
||||||
|
foreground = fg;
|
||||||
|
background = bg;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DFRECT ParamRect(DFWINDOW wnd, DFRECT *rcc)
|
||||||
|
{
|
||||||
|
DFRECT rc;
|
||||||
|
if (rcc == NULL) {
|
||||||
|
rc = RelativeWindowRect(wnd, WindowRect(wnd));
|
||||||
|
if (TestAttribute(wnd, SHADOW)) {
|
||||||
|
rc.rt++;
|
||||||
|
rc.bt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
rc = *rcc;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PaintShadow(DFWINDOW wnd)
|
||||||
|
{
|
||||||
|
int y;
|
||||||
|
DFRECT rc = ParamRect(wnd, NULL);
|
||||||
|
for (y = 1; y < WindowHeight(wnd); y++)
|
||||||
|
shadow_char(wnd, y);
|
||||||
|
shadowline(wnd, rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------- display a window's border ----- */
|
||||||
|
void RepaintBorder(DFWINDOW wnd, DFRECT *rcc)
|
||||||
|
{
|
||||||
|
int y;
|
||||||
|
char lin, side, ne, nw, se, sw;
|
||||||
|
DFRECT rc, clrc;
|
||||||
|
|
||||||
|
if (!TestAttribute(wnd, HASBORDER))
|
||||||
|
return;
|
||||||
|
rc = ParamRect(wnd, rcc);
|
||||||
|
clrc = AdjustRectangle(wnd, rc);
|
||||||
|
|
||||||
|
if (wnd == inFocus) {
|
||||||
|
lin = FOCUS_LINE;
|
||||||
|
side = FOCUS_SIDE;
|
||||||
|
ne = FOCUS_NE;
|
||||||
|
nw = FOCUS_NW;
|
||||||
|
se = FOCUS_SE;
|
||||||
|
sw = FOCUS_SW;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lin = LINE;
|
||||||
|
side = SIDE;
|
||||||
|
ne = NE;
|
||||||
|
nw = NW;
|
||||||
|
se = SE;
|
||||||
|
sw = SW;
|
||||||
|
}
|
||||||
|
line[WindowWidth(wnd)] = '\0';
|
||||||
|
/* ---------- window title ------------ */
|
||||||
|
if (TestAttribute(wnd, HASTITLEBAR))
|
||||||
|
if (RectTop(rc) == 0)
|
||||||
|
if (RectLeft(rc) < WindowWidth(wnd)-BorderAdj(wnd))
|
||||||
|
DisplayTitle(wnd, &rc);
|
||||||
|
foreground = FrameForeground(wnd);
|
||||||
|
background = FrameBackground(wnd);
|
||||||
|
/* -------- top frame corners --------- */
|
||||||
|
if (RectTop(rc) == 0) {
|
||||||
|
if (RectLeft(rc) == 0)
|
||||||
|
wputch(wnd, nw, 0, 0);
|
||||||
|
if (RectLeft(rc) < WindowWidth(wnd)) {
|
||||||
|
if (RectRight(rc) >= WindowWidth(wnd)-1)
|
||||||
|
wputch(wnd, ne, WindowWidth(wnd)-1, 0);
|
||||||
|
TopLine(wnd, lin, clrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------- window body ------------ */
|
||||||
|
for (y = RectTop(rc); y <= RectBottom(rc); y++) {
|
||||||
|
char ch;
|
||||||
|
if (y == 0 || y >= WindowHeight(wnd)-1)
|
||||||
|
continue;
|
||||||
|
if (RectLeft(rc) == 0)
|
||||||
|
wputch(wnd, side, 0, y);
|
||||||
|
if (RectLeft(rc) < WindowWidth(wnd) &&
|
||||||
|
RectRight(rc) >= WindowWidth(wnd)-1) {
|
||||||
|
if (TestAttribute(wnd, VSCROLLBAR))
|
||||||
|
ch = ( y == 1 ? UPSCROLLBOX :
|
||||||
|
y == WindowHeight(wnd)-2 ?
|
||||||
|
DOWNSCROLLBOX :
|
||||||
|
y-1 == wnd->VScrollBox ?
|
||||||
|
SCROLLBOXCHAR :
|
||||||
|
SCROLLBARCHAR );
|
||||||
|
else
|
||||||
|
ch = side;
|
||||||
|
wputch(wnd, ch, WindowWidth(wnd)-1, y);
|
||||||
|
}
|
||||||
|
if (RectRight(rc) == WindowWidth(wnd))
|
||||||
|
shadow_char(wnd, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RectTop(rc) <= WindowHeight(wnd)-1 &&
|
||||||
|
RectBottom(rc) >= WindowHeight(wnd)-1) {
|
||||||
|
/* -------- bottom frame corners ---------- */
|
||||||
|
if (RectLeft(rc) == 0)
|
||||||
|
wputch(wnd, sw, 0, WindowHeight(wnd)-1);
|
||||||
|
if (RectLeft(rc) < WindowWidth(wnd) &&
|
||||||
|
RectRight(rc) >= WindowWidth(wnd)-1)
|
||||||
|
wputch(wnd, se, WindowWidth(wnd)-1,
|
||||||
|
WindowHeight(wnd)-1);
|
||||||
|
|
||||||
|
|
||||||
|
if (wnd->StatusBar == NULL) {
|
||||||
|
/* ----------- bottom line ------------- */
|
||||||
|
memset(line,lin,WindowWidth(wnd)-1);
|
||||||
|
if (TestAttribute(wnd, HSCROLLBAR)) {
|
||||||
|
line[0] = LEFTSCROLLBOX;
|
||||||
|
line[WindowWidth(wnd)-3] = RIGHTSCROLLBOX;
|
||||||
|
memset(line+1, SCROLLBARCHAR, WindowWidth(wnd)-4);
|
||||||
|
line[wnd->HScrollBox] = SCROLLBOXCHAR;
|
||||||
|
}
|
||||||
|
line[WindowWidth(wnd)-2] = line[RectRight(rc)] = '\0';
|
||||||
|
if (RectLeft(rc) != RectRight(rc) ||
|
||||||
|
(RectLeft(rc) && RectLeft(rc) < WindowWidth(wnd)-1))
|
||||||
|
{
|
||||||
|
if (wnd != inFocus)
|
||||||
|
ClipString++;
|
||||||
|
writeline(wnd,
|
||||||
|
line+(RectLeft(clrc)),
|
||||||
|
RectLeft(clrc)+1,
|
||||||
|
WindowHeight(wnd)-1,
|
||||||
|
FALSE);
|
||||||
|
ClipString = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (RectRight(rc) == WindowWidth(wnd))
|
||||||
|
shadow_char(wnd, WindowHeight(wnd)-1);
|
||||||
|
}
|
||||||
|
if (RectBottom(rc) == WindowHeight(wnd))
|
||||||
|
/* ---------- bottom shadow ------------- */
|
||||||
|
shadowline(wnd, rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TopLine(DFWINDOW wnd, int lin, DFRECT rc)
|
||||||
|
{
|
||||||
|
if (TestAttribute(wnd, HASMENUBAR))
|
||||||
|
return;
|
||||||
|
if (TestAttribute(wnd, HASTITLEBAR) && GetTitle(wnd))
|
||||||
|
return;
|
||||||
|
if (RectLeft(rc) == 0) {
|
||||||
|
RectLeft(rc) += BorderAdj(wnd);
|
||||||
|
RectRight(rc) += BorderAdj(wnd);
|
||||||
|
}
|
||||||
|
if (RectRight(rc) < WindowWidth(wnd)-1)
|
||||||
|
RectRight(rc)++;
|
||||||
|
|
||||||
|
if (RectLeft(rc) < RectRight(rc)) {
|
||||||
|
/* ----------- top line ------------- */
|
||||||
|
memset(line,lin,WindowWidth(wnd)-1);
|
||||||
|
if (TestAttribute(wnd, CONTROLBOX)) {
|
||||||
|
strncpy(line+1, " ", 3);
|
||||||
|
*(line+2) = CONTROLBOXCHAR;
|
||||||
|
}
|
||||||
|
line[RectRight(rc)] = '\0';
|
||||||
|
writeline(wnd, line+RectLeft(rc),
|
||||||
|
RectLeft(rc), 0, FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------ clear the data space of a window -------- */
|
||||||
|
void ClearWindow(DFWINDOW wnd, DFRECT *rcc, int clrchar)
|
||||||
|
{
|
||||||
|
if (isVisible(wnd)) {
|
||||||
|
int y;
|
||||||
|
DFRECT rc;
|
||||||
|
|
||||||
|
if (rcc == NULL)
|
||||||
|
rc = RelativeWindowRect(wnd, WindowRect(wnd));
|
||||||
|
else
|
||||||
|
rc = *rcc;
|
||||||
|
|
||||||
|
if (RectLeft(rc) == 0)
|
||||||
|
RectLeft(rc) = BorderAdj(wnd);
|
||||||
|
if (RectRight(rc) > WindowWidth(wnd)-1)
|
||||||
|
RectRight(rc) = WindowWidth(wnd)-1;
|
||||||
|
SetStandardColor(wnd);
|
||||||
|
memset(line, clrchar, sizeof line);
|
||||||
|
line[RectRight(rc)+1] = '\0';
|
||||||
|
for (y = RectTop(rc); y <= RectBottom(rc); y++)
|
||||||
|
{
|
||||||
|
if (y < TopBorderAdj(wnd) ||
|
||||||
|
y > ClientHeight(wnd)+
|
||||||
|
(TestAttribute(wnd, HASMENUBAR) ? 1 : 0))
|
||||||
|
continue;
|
||||||
|
writeline(wnd,
|
||||||
|
line+(RectLeft(rc)),
|
||||||
|
RectLeft(rc),
|
||||||
|
y,
|
||||||
|
FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------ compute the logical line length of a window ------ */
|
||||||
|
int LineLength(char *ln)
|
||||||
|
{
|
||||||
|
int len = strlen(ln);
|
||||||
|
char *cp = ln;
|
||||||
|
while ((cp = strchr(cp, CHANGECOLOR)) != NULL)
|
||||||
|
{
|
||||||
|
cp++;
|
||||||
|
len -= 3;
|
||||||
|
}
|
||||||
|
cp = ln;
|
||||||
|
while ((cp = strchr(cp, RESETCOLOR)) != NULL)
|
||||||
|
{
|
||||||
|
cp++;
|
||||||
|
--len;
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitWindowColors(DFWINDOW wnd)
|
||||||
|
{
|
||||||
|
int fbg,col;
|
||||||
|
int cls = GetClass(wnd);
|
||||||
|
/* window classes without assigned colors inherit parent's colors */
|
||||||
|
if (cfg.clr[cls][0][0] == 0xff && GetParent(wnd) != NULL)
|
||||||
|
cls = GetClass(GetParent(wnd));
|
||||||
|
/* ---------- set the colors ---------- */
|
||||||
|
for (fbg = 0; fbg < 2; fbg++)
|
||||||
|
for (col = 0; col < 4; col++)
|
||||||
|
wnd->WindowColors[col][fbg] = cfg.clr[cls][col][fbg];
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutWindowChar(DFWINDOW wnd, char c, int x, int y)
|
||||||
|
{
|
||||||
|
if (x < ClientWidth(wnd) && y < ClientHeight(wnd))
|
||||||
|
wputch(wnd, c, x+BorderAdj(wnd), y+TopBorderAdj(wnd));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutWindowLine(DFWINDOW wnd, void *s, int x, int y)
|
||||||
|
{
|
||||||
|
int saved = FALSE;
|
||||||
|
int sv = 0;
|
||||||
|
|
||||||
|
if (x < ClientWidth(wnd) && y < ClientHeight(wnd))
|
||||||
|
{
|
||||||
|
char *en = (char *)s+ClientWidth(wnd)-x;
|
||||||
|
if ((int)(strlen(s)+x) > (int)ClientWidth(wnd))
|
||||||
|
{
|
||||||
|
sv = *en;
|
||||||
|
*en = '\0';
|
||||||
|
saved = TRUE;
|
||||||
|
}
|
||||||
|
ClipString++;
|
||||||
|
wputs(wnd, s, x+BorderAdj(wnd), y+TopBorderAdj(wnd));
|
||||||
|
--ClipString;
|
||||||
|
if (saved)
|
||||||
|
*en = sv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
Loading…
Reference in a new issue