Still working on making dflat32 a dll. Alot of this will be cleaned up in the

next few weeks. I'm going through the DFLAT api doc and fixing the export
names and then going to try to build a simple hello dflat application.

svn path=/trunk/; revision=2844
This commit is contained in:
Steven Edwards 2002-04-14 10:15:06 +00:00
parent 531d8f275d
commit 81345fd691
37 changed files with 7650 additions and 132 deletions

View file

@ -18,15 +18,41 @@ TARGET_BASE = 0x98000000
TARGET_CFLAGS = # -pipe -O2 -Wall -Wstrict-prototypes -fno-builtin -DDBG
TARGET_OBJECTS = \
applicat.o \
box.o \
checkbox.o \
clipbord.o \
config.o \
console.o \
dllmain.o \
decomp.o \
dfalloc.o \
dialbox.o \
dialogs.o \
dllmain.o \
editbox.o \
lists.o \
helpbox.o \
listbox.o \
log.o \
message.o \
menu.o \
menubar.o \
menus.o \
msgbox.o \
normal.o \
pictbox.o \
popdown.o \
keys.o \
radio.o \
rect.o \
spinbutt.o \
statbar.o \
stubs.o\
sysmenu.o \
text.o \
textbox.o \
video.o \
watch.o \
window.o
include $(PATH_TO_TOP)/rules.mak

View file

@ -0,0 +1,622 @@
/* ------------- applicat.c ------------- */
#include "dflat32/dflat.h"
static BOOL DisplayModified = FALSE;
DFWINDOW ApplicationWindow;
extern DBOX Display;
extern DBOX Windows;
#ifdef INCLUDE_LOGGING
extern DBOX Log;
#endif
#ifdef INCLUDE_SHELLDOS
static void ShellDOS(DFWINDOW);
#endif
static void DfCreateMenu(DFWINDOW);
static void CreateStatusBar(DFWINDOW);
static void SelectColors(DFWINDOW);
#ifdef INCLUDE_WINDOWOPTIONS
static void SelectTexture(void);
static void SelectBorder(DFWINDOW);
static void SelectTitle(DFWINDOW);
static void SelectStatusBar(DFWINDOW);
#endif
static DFWINDOW oldFocus;
#ifdef INCLUDE_MULTI_WINDOWS
static void CloseAll(DFWINDOW, int);
static void MoreWindows(DFWINDOW);
static void ChooseWindow(DFWINDOW, int);
static int WindowSel;
static char Menus[9][26] =
{
"~1. ",
"~2. ",
"~3. ",
"~4. ",
"~5. ",
"~6. ",
"~7. ",
"~8. ",
"~9. "
};
#endif
/* --------------- CREATE_WINDOW Message -------------- */
static int CreateWindowMsg(DFWINDOW wnd)
{
int rtn;
ApplicationWindow = wnd;
#ifdef INCLUDE_WINDOWOPTIONS
if (cfg.Border)
SetCheckBox(&Display, ID_BORDER);
if (cfg.Title)
SetCheckBox(&Display, ID_TITLE);
if (cfg.StatusBar)
SetCheckBox(&Display, ID_STATUSBAR);
if (cfg.Texture)
SetCheckBox(&Display, ID_TEXTURE);
#endif
SelectColors(wnd);
#ifdef INCLUDE_WINDOWOPTIONS
SelectBorder(wnd);
SelectTitle(wnd);
SelectStatusBar(wnd);
#endif
rtn = BaseWndProc(APPLICATION, wnd, CREATE_WINDOW, 0, 0);
if (wnd->extension != NULL)
DfCreateMenu(wnd);
CreateStatusBar(wnd);
return rtn;
}
/* --------- ADDSTATUS Message ---------- */
static void AddStatusMsg(DFWINDOW wnd, PARAM p1)
{
if (wnd->StatusBar != NULL) {
if (p1 && *(char *)p1)
DfSendMessage(wnd->StatusBar, SETTEXT, p1, 0);
else
DfSendMessage(wnd->StatusBar, CLEARTEXT, 0, 0);
DfSendMessage(wnd->StatusBar, PAINT, 0, 0);
}
}
/* -------- SETFOCUS Message -------- */
static void SetFocusMsg(DFWINDOW wnd, BOOL p1)
{
if (p1)
DfSendMessage(inFocus, SETFOCUS, FALSE, 0);
inFocus = p1 ? wnd : NULL;
if (isVisible(wnd))
DfSendMessage(wnd, BORDER, 0, 0);
else
DfSendMessage(wnd, SHOW_WINDOW, 0, 0);
}
/* ------- SIZE Message -------- */
static void SizeMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
BOOL WasVisible;
WasVisible = isVisible(wnd);
if (WasVisible)
DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
if (p1-GetLeft(wnd) < 30)
p1 = GetLeft(wnd) + 30;
BaseWndProc(APPLICATION, wnd, DFM_SIZE, p1, p2);
DfCreateMenu(wnd);
CreateStatusBar(wnd);
if (WasVisible)
DfSendMessage(wnd, SHOW_WINDOW, 0, 0);
}
/* ----------- KEYBOARD Message ------------ */
static int KeyboardMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
if (WindowMoving || WindowSizing || (int) p1 == F1)
return BaseWndProc(APPLICATION, wnd, KEYBOARD, p1, p2);
switch ((int) p1) {
case ALT_F4:
DfPostMessage(wnd, CLOSE_WINDOW, 0, 0);
return TRUE;
#ifdef INCLUDE_MULTI_WINDOWS
case ALT_F6:
SetNextFocus();
return TRUE;
#endif
case ALT_HYPHEN:
BuildSystemMenu(wnd);
return TRUE;
default:
break;
}
DfPostMessage(wnd->MenuBarWnd, KEYBOARD, p1, p2);
return TRUE;
}
/* --------- SHIFT_CHANGED Message -------- */
static void ShiftChangedMsg(DFWINDOW wnd, PARAM p1)
{
extern BOOL AltDown;
if ((int)p1 & ALTKEY)
AltDown = TRUE;
else if (AltDown) {
AltDown = FALSE;
if (wnd->MenuBarWnd != inFocus)
DfSendMessage(NULL, HIDE_CURSOR, 0, 0);
DfSendMessage(wnd->MenuBarWnd, KEYBOARD, F10, 0);
}
}
/* -------- COMMAND Message ------- */
static void CommandMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
switch ((int)p1) {
case ID_HELP:
DisplayHelp(wnd, DFlatApplication);
break;
case ID_HELPHELP:
DisplayHelp(wnd, "HelpHelp");
break;
case ID_EXTHELP:
DisplayHelp(wnd, "ExtHelp");
break;
case ID_KEYSHELP:
DisplayHelp(wnd, "KeysHelp");
break;
case ID_HELPINDEX:
DisplayHelp(wnd, "HelpIndex");
break;
#ifdef TESTING_DFLAT
case ID_LOADHELP:
LoadHelpFile();
break;
#endif
#ifdef INCLUDE_LOGGING
case ID_LOG:
MessageLog(wnd);
break;
#endif
#ifdef INCLUDE_SHELLDOS
case ID_DOS:
ShellDOS(wnd);
break;
#endif
case ID_EXIT:
case ID_SYSCLOSE:
DfPostMessage(wnd, CLOSE_WINDOW, 0, 0);
break;
case ID_DISPLAY:
if (DfDialogBox(wnd, &Display, TRUE, NULL)) {
if (inFocus == wnd->MenuBarWnd || inFocus == wnd->StatusBar)
oldFocus = ApplicationWindow;
else
oldFocus = inFocus;
DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
SelectColors(wnd);
#ifdef INCLUDE_WINDOWOPTIONS
SelectBorder(wnd);
SelectTitle(wnd);
SelectStatusBar(wnd);
SelectTexture();
#endif
DfCreateMenu(wnd);
CreateStatusBar(wnd);
DfSendMessage(wnd, SHOW_WINDOW, 0, 0);
DfSendMessage(oldFocus, SETFOCUS, TRUE, 0);
}
break;
case ID_SAVEOPTIONS:
SaveConfig();
break;
#ifdef INCLUDE_MULTI_WINDOWS
case ID_WINDOW:
ChooseWindow(wnd, (int)p2-2);
break;
case ID_CLOSEALL:
CloseAll(wnd, FALSE);
break;
case ID_MOREWINDOWS:
MoreWindows(wnd);
break;
#endif
#ifdef INCLUDE_RESTORE
case ID_SYSRESTORE:
#endif
case ID_SYSMOVE:
case ID_SYSSIZE:
#ifdef INCLUDE_MINIMIZE
case ID_SYSMINIMIZE:
#endif
#ifdef INCLUDE_MAXIMIZE
case ID_SYSMAXIMIZE:
#endif
BaseWndProc(APPLICATION, wnd, DFM_COMMAND, p1, p2);
break;
default:
if (inFocus != wnd->MenuBarWnd && inFocus != wnd)
DfPostMessage(inFocus, DFM_COMMAND, p1, p2);
break;
}
}
/* --------- CLOSE_WINDOW Message -------- */
static int CloseWindowMsg(DFWINDOW wnd)
{
int rtn;
#ifdef INCLUDE_MULTI_WINDOWS
CloseAll(wnd, TRUE);
WindowSel = 0;
#endif
DfPostMessage(NULL, DFM_STOP, 0, 0);
rtn = BaseWndProc(APPLICATION, wnd, CLOSE_WINDOW, 0, 0);
UnLoadHelpFile();
DisplayModified = FALSE;
ApplicationWindow = NULL;
return rtn;
}
/* --- APPLICATION Window Class window processing module --- */
int ApplicationProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
switch (msg)
{
case CREATE_WINDOW:
return CreateWindowMsg(wnd);
case DFM_HIDE_WINDOW:
if (wnd == inFocus)
inFocus = NULL;
break;
case ADDSTATUS:
AddStatusMsg(wnd, p1);
return TRUE;
case SETFOCUS:
if ((int)p1 == (inFocus != wnd)) {
SetFocusMsg(wnd, (BOOL) p1);
return TRUE;
}
break;
case DFM_SIZE:
SizeMsg(wnd, p1, p2);
return TRUE;
#ifdef INCLUDE_MINIMIZE
case MINIMIZE:
return TRUE;
#endif
case KEYBOARD:
return KeyboardMsg(wnd, p1, p2);
case SHIFT_CHANGED:
ShiftChangedMsg(wnd, p1);
return TRUE;
case PAINT:
if (isVisible(wnd)) {
#ifdef INCLUDE_WINDOWOPTIONS
int cl = cfg.Texture ? APPLCHAR : ' ';
#else
int cl = APPLCHAR;
#endif
ClearWindow(wnd, (DFRECT *)p1, cl);
}
return TRUE;
case DFM_COMMAND:
CommandMsg(wnd, p1, p2);
return TRUE;
case CLOSE_WINDOW:
return CloseWindowMsg(wnd);
default:
break;
}
return BaseWndProc(APPLICATION, wnd, msg, p1, p2);
}
#ifdef INCLUDE_SHELLDOS
static void SwitchCursor(void)
{
DfSendMessage(NULL, SAVE_CURSOR, 0, 0);
SwapCursorStack();
DfSendMessage(NULL, RESTORE_CURSOR, 0, 0);
}
/* ------- Shell out to DOS ---------- */
static void ShellDOS(DFWINDOW wnd)
{
oldFocus = inFocus;
DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
SwitchCursor();
printf("To return to %s, execute the DOS exit command.",
DFlatApplication);
fflush(stdout);
_spawnl(P_WAIT, getenv("COMSPEC"), " ", NULL);
SwitchCursor();
DfSendMessage(wnd, SHOW_WINDOW, 0, 0);
DfSendMessage(oldFocus, SETFOCUS, TRUE, 0);
}
#endif
/* -------- Create the menu bar -------- */
static void DfCreateMenu(DFWINDOW wnd)
{
AddAttribute(wnd, HASMENUBAR);
if (wnd->MenuBarWnd != NULL)
DfSendMessage(wnd->MenuBarWnd, CLOSE_WINDOW, 0, 0);
wnd->MenuBarWnd = DfCreateWindow(MENUBAR,
NULL,
GetClientLeft(wnd),
GetClientTop(wnd)-1,
1,
ClientWidth(wnd),
NULL,
wnd,
NULL,
0);
DfSendMessage(wnd->MenuBarWnd,BUILDMENU,
(PARAM)wnd->extension,0);
AddAttribute(wnd->MenuBarWnd, VISIBLE);
}
/* ----------- Create the status bar ------------- */
static void CreateStatusBar(DFWINDOW wnd)
{
if (wnd->StatusBar != NULL) {
DfSendMessage(wnd->StatusBar, CLOSE_WINDOW, 0, 0);
wnd->StatusBar = NULL;
}
if (TestAttribute(wnd, HASSTATUSBAR)) {
wnd->StatusBar = DfCreateWindow(STATUSBAR,
NULL,
GetClientLeft(wnd),
GetBottom(wnd),
1,
ClientWidth(wnd),
NULL,
wnd,
NULL,
0);
AddAttribute(wnd->StatusBar, VISIBLE);
}
}
#ifdef INCLUDE_MULTI_WINDOWS
/* -------- return the name of a document window ------- */
static char *WindowName(DFWINDOW wnd)
{
if (GetTitle(wnd) == NULL)
{
if (GetClass(wnd) == DIALOG)
return ((DBOX *)(wnd->extension))->HelpName;
else
return "Untitled";
}
else
return GetTitle(wnd);
}
/* ----------- Prepare the Window menu ------------ */
void PrepWindowMenu(void *w, struct Menu *mnu)
{
DFWINDOW wnd = w;
struct PopDown *p0 = mnu->Selections;
struct PopDown *pd = mnu->Selections + 2;
struct PopDown *ca = mnu->Selections + 13;
int MenuNo = 0;
DFWINDOW cwnd;
mnu->Selection = 0;
oldFocus = NULL;
if (GetClass(wnd) != APPLICATION)
{
oldFocus = wnd;
/* point to the APPLICATION window */
if (ApplicationWindow == NULL)
return;
cwnd = FirstWindow(ApplicationWindow);
/* get the first 9 document windows */
while (cwnd != NULL && MenuNo < 9)
{
if (GetClass(cwnd) != MENUBAR &&
GetClass(cwnd) != STATUSBAR)
{
/* add the document window to the menu */
strncpy (Menus[MenuNo]+4, WindowName(cwnd), 20);
pd->SelectionTitle = Menus[MenuNo];
if (cwnd == oldFocus)
{
/* mark the current document */
pd->Attrib |= CHECKED;
mnu->Selection = MenuNo+2;
}
else
pd->Attrib &= ~CHECKED;
pd++;
MenuNo++;
}
cwnd = NextWindow(cwnd);
}
}
if (MenuNo)
p0->SelectionTitle = "~Close all";
else
p0->SelectionTitle = NULL;
if (MenuNo >= 9)
{
*pd++ = *ca;
if (mnu->Selection == 0)
mnu->Selection = 11;
}
pd->SelectionTitle = NULL;
}
/* window processing module for the More Windows dialog box */
static int WindowPrep(DFWINDOW wnd,DFMESSAGE msg,PARAM p1,PARAM p2)
{
switch (msg) {
case INITIATE_DIALOG: {
DFWINDOW wnd1;
DFWINDOW cwnd = ControlWindow(&Windows,ID_WINDOWLIST);
int sel = 0;
if (cwnd == NULL)
return FALSE;
wnd1 = FirstWindow(ApplicationWindow);
while (wnd1 != NULL) {
if (wnd1 != wnd && GetClass(wnd1) != MENUBAR &&
GetClass(wnd1) != STATUSBAR) {
if (wnd1 == oldFocus)
WindowSel = sel;
DfSendMessage(cwnd, ADDTEXT,
(PARAM) WindowName(wnd1), 0);
sel++;
}
wnd1 = NextWindow(wnd1);
}
DfSendMessage(cwnd, LB_SETSELECTION, WindowSel, 0);
AddAttribute(cwnd, VSCROLLBAR);
DfPostMessage(cwnd, SHOW_WINDOW, 0, 0);
break;
}
case DFM_COMMAND:
switch ((int) p1) {
case ID_OK:
if ((int)p2 == 0)
WindowSel = DfSendMessage(
ControlWindow(&Windows,
ID_WINDOWLIST),
LB_CURRENTSELECTION, 0, 0);
break;
case ID_WINDOWLIST:
if ((int) p2 == LB_CHOOSE)
DfSendMessage(wnd, DFM_COMMAND, ID_OK, 0);
break;
default:
break;
}
break;
default:
break;
}
return DefaultWndProc(wnd, msg, p1, p2);
}
/* ---- the More Windows command on the Window menu ---- */
static void MoreWindows(DFWINDOW wnd)
{
if (DfDialogBox(wnd, &Windows, TRUE, WindowPrep))
ChooseWindow(wnd, WindowSel);
}
/* ----- user chose a window from the Window menu
or the More Window dialog box ----- */
static void ChooseWindow(DFWINDOW wnd, int WindowNo)
{
DFWINDOW cwnd = FirstWindow(wnd);
while (cwnd != NULL)
{
if (GetClass(cwnd) != MENUBAR &&
GetClass(cwnd) != STATUSBAR)
if (WindowNo-- == 0)
break;
cwnd = NextWindow(cwnd);
}
if (cwnd != NULL) {
DfSendMessage(cwnd, SETFOCUS, TRUE, 0);
if (cwnd->condition == ISMINIMIZED)
DfSendMessage(cwnd, RESTORE, 0, 0);
}
}
/* ----- Close all document windows ----- */
static void CloseAll(DFWINDOW wnd, int closing)
{
DFWINDOW wnd1, wnd2;
DfSendMessage(wnd, SETFOCUS, TRUE, 0);
wnd1 = LastWindow(wnd);
while (wnd1 != NULL)
{
wnd2 = PrevWindow(wnd1);
if (GetClass(wnd1) != MENUBAR && GetClass(wnd1) != STATUSBAR)
{
ClearVisible(wnd1);
DfSendMessage(wnd1, CLOSE_WINDOW, 0, 0);
}
wnd1 = wnd2;
}
if (!closing)
DfSendMessage(wnd, PAINT, 0, 0);
}
#endif /* #ifdef INCLUDE_MULTI_WINDOWS */
static void DoWindowColors(DFWINDOW wnd)
{
DFWINDOW cwnd;
InitWindowColors(wnd);
cwnd = FirstWindow(wnd);
while (cwnd != NULL)
{
DoWindowColors(cwnd);
if (GetClass(cwnd) == TEXT && GetText(cwnd) != NULL)
DfSendMessage(cwnd, CLEARTEXT, 0, 0);
cwnd = NextWindow(cwnd);
}
}
/* set up colors for the application window */
static void SelectColors(DFWINDOW wnd)
{
memcpy(cfg.clr, color, sizeof color);
DoWindowColors(wnd);
}
#ifdef INCLUDE_WINDOWOPTIONS
/* ----- select the screen texture ----- */
static void SelectTexture(void)
{
cfg.Texture = CheckBoxSetting(&Display, ID_TEXTURE);
}
/* -- select whether the application screen has a border -- */
static void SelectBorder(DFWINDOW wnd)
{
cfg.Border = CheckBoxSetting(&Display, ID_BORDER);
if (cfg.Border)
AddAttribute(wnd, HASBORDER);
else
ClearAttribute(wnd, HASBORDER);
}
/* select whether the application screen has a status bar */
static void SelectStatusBar(DFWINDOW wnd)
{
cfg.StatusBar = CheckBoxSetting(&Display, ID_STATUSBAR);
if (cfg.StatusBar)
AddAttribute(wnd, HASSTATUSBAR);
else
ClearAttribute(wnd, HASSTATUSBAR);
}
/* select whether the application screen has a title bar */
static void SelectTitle(DFWINDOW wnd)
{
cfg.Title = CheckBoxSetting(&Display, ID_TITLE);
if (cfg.Title)
AddAttribute(wnd, HASTITLEBAR);
else
ClearAttribute(wnd, HASTITLEBAR);
}
#endif
/* EOF */

44
rosapps/lib/dflat32/box.c Normal file
View file

@ -0,0 +1,44 @@
/* ----------- box.c ------------ */
#include "dflat32/dflat.h"
int BoxProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
int rtn;
DFWINDOW oldFocus;
CTLWINDOW *ct = GetControl(wnd);
static BOOL SettingFocus = FALSE;
if (ct != NULL)
{
switch (msg)
{
case SETFOCUS:
SettingFocus = isVisible(wnd);
rtn = BaseWndProc(BOX, wnd, msg, p1, p2);
SettingFocus = FALSE;
return rtn;
case PAINT:
return FALSE;
case LEFT_BUTTON:
case DFM_BUTTON_RELEASED:
return DfSendMessage(GetParent(wnd), msg, p1, p2);
case BORDER:
if (SettingFocus)
return TRUE;
oldFocus = inFocus;
inFocus = NULL;
rtn = BaseWndProc(BOX, wnd, msg, p1, p2);
inFocus = oldFocus;
if (ct != NULL)
if (ct->itext != NULL)
writeline(wnd, ct->itext, 1, 0, FALSE);
return rtn;
default:
break;
}
}
return BaseWndProc(BOX, wnd, msg, p1, p2);
}
/* EOF */

View file

@ -0,0 +1,49 @@
/* -------------- checkbox.c ------------ */
#include "dflat32/dflat.h"
int CheckBoxProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
int rtn;
CTLWINDOW *ct = GetControl(wnd);
if (ct != NULL) {
switch (msg) {
case SETFOCUS:
if (!(int)p1)
DfSendMessage(NULL, HIDE_CURSOR, 0, 0);
case MOVE:
rtn = BaseWndProc(CHECKBOX, wnd, msg, p1, p2);
SetFocusCursor(wnd);
return rtn;
case PAINT: {
char cb[] = "[ ]";
if (ct->setting)
cb[1] = 'X';
DfSendMessage(wnd, CLEARTEXT, 0, 0);
DfSendMessage(wnd, ADDTEXT, (PARAM) cb, 0);
SetFocusCursor(wnd);
break;
}
case KEYBOARD:
if ((int)p1 != ' ')
break;
case LEFT_BUTTON:
ct->setting ^= ON;
DfSendMessage(wnd, PAINT, 0, 0);
return TRUE;
default:
break;
}
}
return BaseWndProc(CHECKBOX, wnd, msg, p1, p2);
}
BOOL CheckBoxSetting(DBOX *db, enum commands cmd)
{
CTLWINDOW *ct = FindCommand(db, cmd, CHECKBOX);
if (ct != NULL)
return (ct->isetting == ON);
return FALSE;
}
/* EOF */

View file

@ -1,9 +1,5 @@
/* ----------- clipbord.c ------------
* Clipbord funcations.
*
* sedwards
*/
#include <dflat32\dflat.h>
/* ----------- clipbord.c ------------ */
#include "dflat32/dflat.h"
char *Clipboard;
unsigned ClipboardLength;

View file

@ -1,6 +1,6 @@
/* ------------- config.c ------------- */
#include <dflat32/dflat.h>
#include "dflat32/dflat.h"
/* ----- default colors for color video system ----- */
unsigned char color[CLASSCOUNT] [4] [2] = {
@ -440,7 +440,6 @@ CONFIG cfg = {
55 /* Bottom printer margin */
};
char **Argv;
void BuildFileName(char *path, char *ext)
{
extern char **Argv;

View file

@ -4,7 +4,7 @@
#include <windows.h>
#include <dflat32/dflat.h>
#include "dflat32/dflat.h"
/* ----- table of alt keys for finding shortcut keys ----- */

View file

@ -0,0 +1,134 @@
/* ------------------- decomp.c -------------------- */
/*
* Decompress the application.HLP file
* or load the application.TXT file if the .HLP file
* does not exist
*/
#include "dflat32/dflat.h"
#include "dflat32/htree.h"
static int in8;
static int ct8 = 8;
static FILE *fi;
static BYTECOUNTER bytectr;
static int LoadingASCII;
struct htr *HelpTree;
static int root;
/* ------- open the help database file -------- */
FILE *OpenHelpFile(void)
{
char *cp;
int treect, i;
char helpname[65];
/* -------- get the name of the help file ---------- */
BuildFileName(helpname, ".hlp");
LoadingASCII = FALSE;
if ((fi = fopen(helpname, "rb")) == NULL) {
/* ---- no .hlp file, look for .txt file ---- */
if ((cp = strrchr(helpname, '.')) != NULL) {
strcpy(cp, ".TXT");
fi = fopen(helpname, "rt");
}
if (fi == NULL)
return NULL;
LoadingASCII = TRUE;
}
if (!LoadingASCII && HelpTree == NULL) {
/* ----- read the byte count ------ */
fread(&bytectr, sizeof bytectr, 1, fi);
/* ----- read the frequency count ------ */
fread(&treect, sizeof treect, 1, fi);
/* ----- read the root offset ------ */
fread(&root, sizeof root, 1, fi);
HelpTree = DFcalloc(treect-256, sizeof(struct htr));
/* ---- read in the tree --- */
for (i = 0; i < treect-256; i++) {
fread(&HelpTree[i].left, sizeof(int), 1, fi);
fread(&HelpTree[i].right, sizeof(int), 1, fi);
}
}
return fi;
}
/* ----- read a line of text from the help database ----- */
void *GetHelpLine(char *line)
{
int h;
if (LoadingASCII) {
void *hp;
do
hp = fgets(line, 160, fi);
while (*line == ';');
return hp;
}
*line = '\0';
while (TRUE) {
/* ----- decompress a line from the file ------ */
h = root;
/* ----- walk the Huffman tree ----- */
while (h > 255) {
/* --- h is a node pointer --- */
if (ct8 == 8) {
/* --- read 8 bits of compressed data --- */
if ((in8 = fgetc(fi)) == EOF) {
*line = '\0';
return NULL;
}
ct8 = 0;
}
/* -- point to left or right node based on msb -- */
if (in8 & 0x80)
h = HelpTree[h-256].left;
else
h = HelpTree[h-256].right;
/* --- shift the next bit in --- */
in8 <<= 1;
ct8++;
}
/* --- h < 255 = decompressed character --- */
if (h == '\r')
continue; /* skip the '\r' character */
/* --- put the character in the buffer --- */
*line++ = h;
/* --- if '\n', end of line --- */
if (h == '\n')
break;
}
*line = '\0'; /* null-terminate the line */
return line;
}
/* --- compute the database file byte and bit position --- */
void HelpFilePosition(long *offset, int *bit)
{
*offset = ftell(fi);
if (LoadingASCII)
*bit = 0;
else {
if (ct8 < 8)
--*offset;
*bit = ct8;
}
}
/* -- position the database to the specified byte and bit -- */
void SeekHelpLine(long offset, int bit)
{
int i;
fseek(fi, offset, 0);
if (!LoadingASCII) {
ct8 = bit;
if (ct8 < 8) {
in8 = fgetc(fi);
for (i = 0; i < bit; i++)
in8 <<= 1;
}
}
}

View file

@ -1,15 +1,9 @@
/* ---------- 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 */
/* ---------- dfalloc.c ---------- */
//#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <dflat32/dflat.h>
#include "dflat32/dflat.h"
static void AllocationError(void)
{

View file

@ -1,68 +1,115 @@
;
; ReactOS dflat32 COnsole Windowing Library
; 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
DfCreateWindow
DfInitialize ;message.c
DfPostMessage ;message.c
DfSendMessage ;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
TestCriticalError ;stubs.c
;DefaultWndProc
;BaseWndProc
;WindowHeight
;WindowWidth
;ClientWidth
;ClientHeight
;GetTop
;GetBottom
;GetLeft
;GetRight
;GetClientTop
;GetClientBottom
;GetClientLeft
;GetClientRight
;GetParent
;FirstWindow
;LastWindow
;NextWindow
;PrevWindow
CharInView
wputch
wputs
scroll_window
; stuff from window.c
DfCreateWindow
;TopBorderAdj
;BorderAdj
;GetTitle
AddTitle
InsertTitle
writeline
AdjustRectangle
DisplayTitle
PaintShadow
RepaintBorder
ClearWindow
LineLength
InitWindowColors
PutWindowChar
;GetClass
;GetAttribute
;AddAttribute
;ClearAttribute
;TestAttribute
isVisible ;normal.o
;GetText
;GetTextLines
;TextLine
;SetProtected
isActive
GetCommandText
ActivateCommand
DeactivateCommand
GetCommandToggle
SetCommandToggle
ClearCommandToggle
InvertCommandToggle
ItemSelected
;DialogBox
ControlWindow
;MessageBox
;CancelBox
;ErrorMessage
;TestErrorMessage
;YesNoBox
MomentaryMessage
InputBox
;SliderBox
RadioButtonSetting
;EnableButton
;DisableButton
;ButtonEnabled
PutItemText
;PutComboListText
GetItemText
;GetEditBoxText
;GetComboBoxText
;SetEditBoxText
;SetComboBoxText
;GetDlgText
;SetDlgText
;GetDlgTextBox
;SetDlgTextBox
;SetCheckBox
;ClearCheckBox
CheckBoxSetting
;SetDlgTitle
LoadHelpFile
DisplayHelp ;helpbox.o
;HelpComment
UnLoadHelpFile ;helpbox.o
;SearchText
;ReplaceText
;SearchNext
WriteTextLine
PutWindowLine
; exports from the stubs
classdefs
PutWindowChar
DrawVector
DrawBox
DrawBar
;WindowClientColor
;WindowReverseColor
;WindowFrameColor
;WindowHighlightColor
MarkTextBlock
;ClearTextBlock
CopyToClipboard ;clipbord.o
CopyTextToClipboard ;clipbord.o
PasteText ;clipbord.o
ClearClipboard ;clipbord.o
WatchIcon ;watch.o
;
;
;
; Everything below here is not part of the dflat32 api (documentation)
DfTerminate
LoadConfig

View file

@ -0,0 +1,792 @@
/* ----------------- dialbox.c -------------- */
#include "dflat32/dflat.h"
static int inFocusCommand(DBOX *);
static void dbShortcutKeys(DBOX *, int);
static int ControlProc(DFWINDOW, DFMESSAGE, PARAM, PARAM);
static void FirstFocus(DBOX *db);
static void NextFocus(DBOX *db);
static void PrevFocus(DBOX *db);
static CTLWINDOW *AssociatedControl(DBOX *, enum commands);
static BOOL SysMenuOpen;
static DBOX **dbs = NULL;
static int dbct = 0;
/* --- clear all heap allocations to control text fields --- */
void ClearDialogBoxes(void)
{
int i;
for (i = 0; i < dbct; i++)
{
CTLWINDOW *ct = (*(dbs+i))->ctl;
while (ct->class)
{
if ((ct->class == EDITBOX ||
ct->class == COMBOBOX) &&
ct->itext != NULL)
{
free(ct->itext);
}
ct++;
}
}
if (dbs != NULL)
{
free(dbs);
dbs = NULL;
}
dbct = 0;
}
/* -------- CREATE_WINDOW Message --------- */
static int CreateWindowMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
DBOX *db = wnd->extension;
CTLWINDOW *ct = db->ctl;
DFWINDOW cwnd;
int rtn, i;
/* ---- build a table of processed dialog boxes ---- */
for (i = 0; i < dbct; i++)
if (db == dbs[i])
break;
if (i == dbct) {
dbs = DFrealloc(dbs, sizeof(DBOX *) * (dbct+1));
*(dbs + dbct++) = db;
}
rtn = BaseWndProc(DIALOG, wnd, CREATE_WINDOW, p1, p2);
ct = db->ctl;
while (ct->class) {
int attrib = 0;
if (TestAttribute(wnd, NOCLIP))
attrib |= NOCLIP;
if (wnd->Modal)
attrib |= SAVESELF;
ct->setting = ct->isetting;
if (ct->class == EDITBOX && ct->dwnd.h > 1)
attrib |= (MULTILINE | HASBORDER);
else if ((ct->class == LISTBOX || ct->class == TEXTBOX) &&
ct->dwnd.h > 2)
attrib |= HASBORDER;
cwnd = DfCreateWindow(ct->class,
ct->dwnd.title,
ct->dwnd.x+GetClientLeft(wnd),
ct->dwnd.y+GetClientTop(wnd),
ct->dwnd.h,
ct->dwnd.w,
ct,
wnd,
ControlProc,
attrib);
if ((ct->class == EDITBOX ||
ct->class == COMBOBOX) &&
ct->itext != NULL)
DfSendMessage(cwnd, SETTEXT, (PARAM) ct->itext, 0);
ct++;
}
return rtn;
}
/* -------- LEFT_BUTTON Message --------- */
static BOOL LeftButtonMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
DBOX *db = wnd->extension;
CTLWINDOW *ct = db->ctl;
if (WindowSizing || WindowMoving)
return TRUE;
if (HitControlBox(wnd, p1-GetLeft(wnd), p2-GetTop(wnd))) {
DfPostMessage(wnd, KEYBOARD, ' ', ALTKEY);
return TRUE;
}
while (ct->class) {
DFWINDOW cwnd = ct->wnd;
if (ct->class == COMBOBOX) {
if (p2 == GetTop(cwnd)) {
if (p1 == GetRight(cwnd)+1) {
DfSendMessage(cwnd, LEFT_BUTTON, p1, p2);
return TRUE;
}
}
if (GetClass(inFocus) == LISTBOX)
DfSendMessage(wnd, SETFOCUS, TRUE, 0);
}
else if (ct->class == SPINBUTTON) {
if (p2 == GetTop(cwnd)) {
if (p1 == GetRight(cwnd)+1 ||
p1 == GetRight(cwnd)+2) {
DfSendMessage(cwnd, LEFT_BUTTON, p1, p2);
return TRUE;
}
}
}
ct++;
}
return FALSE;
}
/* -------- KEYBOARD Message --------- */
static BOOL KeyboardMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
DBOX *db = wnd->extension;
CTLWINDOW *ct;
if (WindowMoving || WindowSizing)
return FALSE;
switch ((int)p1) {
case F1:
ct = GetControl(inFocus);
if (ct != NULL)
if (DisplayHelp(wnd, ct->help))
return TRUE;
break;
case SHIFT_HT:
case BS:
case UP:
PrevFocus(db);
break;
case ALT_F6:
case '\t':
case FWD:
case DN:
NextFocus(db);
break;
case ' ':
if (((int)p2 & ALTKEY) &&
TestAttribute(wnd, CONTROLBOX)) {
SysMenuOpen = TRUE;
BuildSystemMenu(wnd);
}
break;
case CTRL_F4:
case ESC:
DfSendMessage(wnd, DFM_COMMAND, ID_CANCEL, 0);
break;
default:
/* ------ search all the shortcut keys ----- */
dbShortcutKeys(db, (int) p1);
break;
}
return wnd->Modal;
}
/* -------- COMMAND Message --------- */
static BOOL CommandMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
DBOX *db = wnd->extension;
switch ((int) p1) {
case ID_OK:
case ID_CANCEL:
if ((int)p2 != 0)
return TRUE;
wnd->ReturnCode = (int) p1;
if (wnd->Modal)
DfPostMessage(wnd, ENDDIALOG, 0, 0);
else
DfSendMessage(wnd, CLOSE_WINDOW, TRUE, 0);
return TRUE;
case ID_HELP:
if ((int)p2 != 0)
return TRUE;
return DisplayHelp(wnd, db->HelpName);
default:
break;
}
return FALSE;
}
/* ----- window-processing module, DIALOG window class ----- */
int DialogProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
int rtn;
DBOX *db = wnd->extension;
switch (msg) {
case CREATE_WINDOW:
return CreateWindowMsg(wnd, p1, p2);
case SHIFT_CHANGED:
if (wnd->Modal)
return TRUE;
break;
case LEFT_BUTTON:
if (LeftButtonMsg(wnd, p1, p2))
return TRUE;
break;
case KEYBOARD:
if (KeyboardMsg(wnd, p1, p2))
return TRUE;
break;
case CLOSE_POPDOWN:
SysMenuOpen = FALSE;
break;
case LB_SELECTION:
case LB_CHOOSE:
if (SysMenuOpen)
return TRUE;
DfSendMessage(wnd, DFM_COMMAND, inFocusCommand(db), msg);
break;
case DFM_COMMAND:
if (CommandMsg(wnd, p1, p2))
return TRUE;
break;
case PAINT:
p2 = TRUE;
break;
case MOVE:
case DFM_SIZE:
rtn = BaseWndProc(DIALOG, wnd, msg, p1, p2);
if (wnd->dfocus != NULL)
DfSendMessage(wnd->dfocus, SETFOCUS, TRUE, 0);
return rtn;
case CLOSE_WINDOW:
if (!p1)
{
DfSendMessage(wnd, DFM_COMMAND, ID_CANCEL, 0);
return TRUE;
}
break;
default:
break;
}
return BaseWndProc(DIALOG, wnd, msg, p1, p2);
}
/* ------- create and execute a dialog box ---------- */
BOOL DfDialogBox(DFWINDOW wnd, DBOX *db, BOOL Modal,
int (*wndproc)(struct window *, enum messages, PARAM, PARAM))
{
BOOL rtn;
int x = db->dwnd.x, y = db->dwnd.y;
DFWINDOW DialogWnd;
if (!Modal && wnd != NULL)
{
x += GetLeft(wnd);
y += GetTop(wnd);
}
DialogWnd = DfCreateWindow(DIALOG,
db->dwnd.title,
x, y,
db->dwnd.h,
db->dwnd.w,
db,
wnd,
wndproc,
Modal ? SAVESELF : 0);
DialogWnd->Modal = Modal;
FirstFocus(db);
DfPostMessage(DialogWnd, INITIATE_DIALOG, 0, 0);
if (Modal)
{
DfSendMessage(DialogWnd, CAPTURE_MOUSE, 0, 0);
DfSendMessage(DialogWnd, CAPTURE_KEYBOARD, 0, 0);
while (DfDispatchMessage ())
;
rtn = DialogWnd->ReturnCode == ID_OK;
DfSendMessage(DialogWnd, RELEASE_MOUSE, 0, 0);
DfSendMessage(DialogWnd, RELEASE_KEYBOARD, 0, 0);
DfSendMessage(DialogWnd, CLOSE_WINDOW, TRUE, 0);
return rtn;
}
return FALSE;
}
/* ----- return command code of in-focus control window ---- */
static int inFocusCommand(DBOX *db)
{
CTLWINDOW *ct = db->ctl;
while (ct->class) {
if (ct->wnd == inFocus)
return ct->command;
ct++;
}
return -1;
}
/* -------- find a specified control structure ------- */
CTLWINDOW *FindCommand(DBOX *db, enum commands cmd, int class)
{
CTLWINDOW *ct = db->ctl;
while (ct->class)
{
if (ct->class == class)
if (cmd == ct->command)
return ct;
ct++;
}
return NULL;
}
/* ---- return the window handle of a specified command ---- */
DFWINDOW ControlWindow(DBOX *db, enum commands cmd)
{
CTLWINDOW *ct = db->ctl;
while (ct->class)
{
if (ct->class != TEXT && cmd == ct->command)
return ct->wnd;
ct++;
}
return NULL;
}
/* --- return a pointer to the control structure that matches a window --- */
CTLWINDOW *WindowControl(DBOX *db, DFWINDOW wnd)
{
CTLWINDOW *ct = db->ctl;
while (ct->class)
{
if (ct->wnd == wnd)
return ct;
ct++;
}
return NULL;
}
/* ---- set a control ON or OFF ----- */
void ControlSetting(DBOX *db, enum commands cmd,
int class, int setting)
{
CTLWINDOW *ct = FindCommand(db, cmd, class);
if (ct != NULL) {
ct->isetting = setting;
if (ct->wnd != NULL)
ct->setting = setting;
}
}
/* ---- return pointer to the text of a control window ---- */
char *GetDlgTextString(DBOX *db,enum commands cmd,DFCLASS class)
{
CTLWINDOW *ct = FindCommand(db, cmd, class);
if (ct != NULL)
return ct->itext;
else
return NULL;
}
/* ------- set the text of a control specification ------ */
void SetDlgTextString(DBOX *db, enum commands cmd,
char *text, DFCLASS class)
{
CTLWINDOW *ct = FindCommand(db, cmd, class);
if (ct != NULL) {
ct->itext = DFrealloc(ct->itext, strlen(text)+1);
strcpy(ct->itext, text);
}
}
/* ------- set the text of a control window ------ */
void PutItemText(DFWINDOW wnd, enum commands cmd, char *text)
{
CTLWINDOW *ct = FindCommand(wnd->extension, cmd, EDITBOX);
if (ct == NULL)
ct = FindCommand(wnd->extension, cmd, TEXTBOX);
if (ct == NULL)
ct = FindCommand(wnd->extension, cmd, COMBOBOX);
if (ct == NULL)
ct = FindCommand(wnd->extension, cmd, LISTBOX);
if (ct == NULL)
ct = FindCommand(wnd->extension, cmd, SPINBUTTON);
if (ct == NULL)
ct = FindCommand(wnd->extension, cmd, TEXT);
if (ct != NULL) {
DFWINDOW cwnd = (DFWINDOW) (ct->wnd);
switch (ct->class) {
case COMBOBOX:
case EDITBOX:
DfSendMessage(cwnd, CLEARTEXT, 0, 0);
DfSendMessage(cwnd, ADDTEXT, (PARAM) text, 0);
if (!isMultiLine(cwnd))
DfSendMessage(cwnd, PAINT, 0, 0);
break;
case LISTBOX:
case TEXTBOX:
case SPINBUTTON:
DfSendMessage(cwnd, ADDTEXT, (PARAM) text, 0);
break;
case TEXT: {
DfSendMessage(cwnd, CLEARTEXT, 0, 0);
DfSendMessage(cwnd, ADDTEXT, (PARAM) text, 0);
DfSendMessage(cwnd, PAINT, 0, 0);
break;
}
default:
break;
}
}
}
/* ------- get the text of a control window ------ */
void GetItemText(DFWINDOW wnd, enum commands cmd,
char *text, int len)
{
CTLWINDOW *ct = FindCommand(wnd->extension, cmd, EDITBOX);
unsigned char *cp;
if (ct == NULL)
ct = FindCommand(wnd->extension, cmd, COMBOBOX);
if (ct == NULL)
ct = FindCommand(wnd->extension, cmd, TEXTBOX);
if (ct == NULL)
ct = FindCommand(wnd->extension, cmd, TEXT);
if (ct != NULL) {
DFWINDOW cwnd = (DFWINDOW) (ct->wnd);
if (cwnd != NULL) {
switch (ct->class) {
case TEXT:
if (GetText(cwnd) != NULL) {
cp = strchr(GetText(cwnd), '\n');
if (cp != NULL)
len = (int) (cp - GetText(cwnd));
strncpy(text, GetText(cwnd), len);
*(text+len) = '\0';
}
break;
case TEXTBOX:
if (GetText(cwnd) != NULL)
strncpy(text, GetText(cwnd), len);
break;
case COMBOBOX:
case EDITBOX:
DfSendMessage(cwnd,GETTEXT,(PARAM)text,len);
break;
default:
break;
}
}
}
}
/* ------- set the text of a listbox control window ------ */
void GetDlgListText(DFWINDOW wnd, char *text, enum commands cmd)
{
CTLWINDOW *ct = FindCommand(wnd->extension, cmd, LISTBOX);
int sel = DfSendMessage(ct->wnd, LB_CURRENTSELECTION, 0, 0);
DfSendMessage(ct->wnd, DFM_LB_GETTEXT, (PARAM) text, sel);
}
/* -- find control structure associated with text control -- */
static CTLWINDOW *AssociatedControl(DBOX *db,enum commands Tcmd)
{
CTLWINDOW *ct = db->ctl;
while (ct->class) {
if (ct->class != TEXT)
if (ct->command == Tcmd)
break;
ct++;
}
return ct;
}
/* --- process dialog box shortcut keys --- */
static void dbShortcutKeys(DBOX *db, int ky)
{
CTLWINDOW *ct;
int ch = AltConvert(ky);
if (ch != 0) {
ct = db->ctl;
while (ct->class) {
char *cp = ct->itext;
while (cp && *cp) {
if (*cp == SHORTCUTCHAR &&
tolower(*(cp+1)) == ch) {
if (ct->class == TEXT)
ct = AssociatedControl(db, ct->command);
if (ct->class == RADIOBUTTON)
SetRadioButton(db, ct);
else if (ct->class == CHECKBOX) {
ct->setting ^= ON;
DfSendMessage(ct->wnd, PAINT, 0, 0);
}
else if (ct->class) {
DfSendMessage(ct->wnd, SETFOCUS, TRUE, 0);
if (ct->class == BUTTON)
DfSendMessage(ct->wnd,KEYBOARD,'\r',0);
}
return;
}
cp++;
}
ct++;
}
}
}
/* --- dynamically add or remove scroll bars
from a control window ---- */
void SetScrollBars(DFWINDOW wnd)
{
int oldattr = GetAttribute(wnd);
if (wnd->wlines > ClientHeight(wnd))
AddAttribute(wnd, VSCROLLBAR);
else
ClearAttribute(wnd, VSCROLLBAR);
if (wnd->textwidth > ClientWidth(wnd))
AddAttribute(wnd, HSCROLLBAR);
else
ClearAttribute(wnd, HSCROLLBAR);
if (GetAttribute(wnd) != oldattr)
DfSendMessage(wnd, BORDER, 0, 0);
}
/* ------- CREATE_WINDOW Message (Control) ----- */
static void CtlCreateWindowMsg(DFWINDOW wnd)
{
CTLWINDOW *ct;
ct = wnd->ct = wnd->extension;
wnd->extension = NULL;
if (ct != NULL)
ct->wnd = wnd;
}
/* ------- KEYBOARD Message (Control) ----- */
static BOOL CtlKeyboardMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
CTLWINDOW *ct = GetControl(wnd);
switch ((int) p1) {
case F1:
if (WindowMoving || WindowSizing)
break;
if (!DisplayHelp(wnd, ct->help))
DfSendMessage(GetParent(wnd),DFM_COMMAND,ID_HELP,0);
return TRUE;
case ' ':
if (!((int)p2 & ALTKEY))
break;
case ALT_F6:
case CTRL_F4:
case ALT_F4:
DfPostMessage(GetParent(wnd), KEYBOARD, p1, p2);
return TRUE;
default:
break;
}
if (GetClass(wnd) == EDITBOX)
if (isMultiLine(wnd))
return FALSE;
switch ((int) p1) {
case UP:
if (!isDerivedFrom(wnd, LISTBOX)) {
p1 = CTRL_FIVE;
p2 = LEFTSHIFT;
}
break;
case BS:
if (!isDerivedFrom(wnd, EDITBOX)) {
p1 = CTRL_FIVE;
p2 = LEFTSHIFT;
}
break;
case DN:
if (!isDerivedFrom(wnd, LISTBOX) &&
!isDerivedFrom(wnd, COMBOBOX))
p1 = '\t';
break;
case FWD:
if (!isDerivedFrom(wnd, EDITBOX))
p1 = '\t';
break;
case '\r':
if (isDerivedFrom(wnd, EDITBOX))
if (isMultiLine(wnd))
break;
if (isDerivedFrom(wnd, BUTTON))
break;
DfSendMessage(GetParent(wnd), DFM_COMMAND, ID_OK, 0);
return TRUE;
default:
break;
}
return FALSE;
}
/* ------- CLOSE_WINDOW Message (Control) ----- */
static void CtlCloseWindowMsg(DFWINDOW wnd)
{
CTLWINDOW *ct = GetControl(wnd);
if (ct != NULL) {
ct->wnd = NULL;
if (GetParent(wnd)->ReturnCode == ID_OK) {
if (ct->class == EDITBOX || ct->class == COMBOBOX) {
if (wnd->TextChanged) {
ct->itext=DFrealloc(ct->itext,strlen(wnd->text)+1);
strcpy(ct->itext, wnd->text);
if (!isMultiLine(wnd)) {
char *cp = ct->itext+strlen(ct->itext)-1;
if (*cp == '\n')
*cp = '\0';
}
}
}
else if (ct->class == RADIOBUTTON || ct->class == CHECKBOX)
ct->isetting = ct->setting;
}
}
}
static void FixColors(DFWINDOW wnd)
{
CTLWINDOW *ct = wnd->ct;
if (ct->class != BUTTON)
{
if (ct->class != SPINBUTTON && ct->class != COMBOBOX)
{
wnd->WindowColors[FRAME_COLOR][FG] =
GetParent(wnd)->WindowColors[FRAME_COLOR][FG];
wnd->WindowColors[FRAME_COLOR][BG] =
GetParent(wnd)->WindowColors[FRAME_COLOR][BG];
if (ct->class != EDITBOX && ct->class != LISTBOX)
{
wnd->WindowColors[STD_COLOR][FG] =
GetParent(wnd)->WindowColors[STD_COLOR][FG];
wnd->WindowColors[STD_COLOR][BG] =
GetParent(wnd)->WindowColors[STD_COLOR][BG];
}
}
}
}
/* -- generic window processor used by dialog box controls -- */
static int ControlProc(DFWINDOW wnd,DFMESSAGE msg,PARAM p1,PARAM p2)
{
DBOX *db;
if (wnd == NULL)
return FALSE;
db = GetParent(wnd) ? GetParent(wnd)->extension : NULL;
switch (msg) {
case CREATE_WINDOW:
CtlCreateWindowMsg(wnd);
break;
case KEYBOARD:
if (CtlKeyboardMsg(wnd, p1, p2))
return TRUE;
break;
case PAINT:
FixColors(wnd);
if (GetClass(wnd) == EDITBOX ||
GetClass(wnd) == LISTBOX ||
GetClass(wnd) == TEXTBOX)
SetScrollBars(wnd);
break;
case BORDER:
FixColors(wnd);
if (GetClass(wnd) == EDITBOX) {
DFWINDOW oldFocus = inFocus;
inFocus = NULL;
DefaultWndProc(wnd, msg, p1, p2);
inFocus = oldFocus;
return TRUE;
}
break;
case SETFOCUS: {
DFWINDOW pwnd = GetParent(wnd);
if (p1)
{
DefaultWndProc(wnd, msg, p1, p2);
if (pwnd != NULL)
{
pwnd->dfocus = wnd;
DfSendMessage(pwnd, DFM_COMMAND,
inFocusCommand(db), ENTERFOCUS);
}
return TRUE;
}
else
DfSendMessage(pwnd, DFM_COMMAND,
inFocusCommand(db), LEAVEFOCUS);
break;
}
case CLOSE_WINDOW:
CtlCloseWindowMsg(wnd);
break;
default:
break;
}
return DefaultWndProc(wnd, msg, p1, p2);
}
/* ---- change the focus to the first control --- */
static void FirstFocus(DBOX *db)
{
CTLWINDOW *ct = db->ctl;
if (ct != NULL)
{
while (ct->class == TEXT || ct->class == BOX) {
ct++;
if (ct->class == 0)
return;
}
DfSendMessage(ct->wnd, SETFOCUS, TRUE, 0);
}
}
/* ---- change the focus to the next control --- */
static void NextFocus(DBOX *db)
{
CTLWINDOW *ct = WindowControl(db, inFocus);
int looped = 0;
if (ct != NULL)
{
do
{
ct++;
if (ct->class == 0)
{
if (looped)
return;
looped++;
ct = db->ctl;
}
} while (ct->class == TEXT || ct->class == BOX);
DfSendMessage(ct->wnd, SETFOCUS, TRUE, 0);
}
}
/* ---- change the focus to the previous control --- */
static void PrevFocus(DBOX *db)
{
CTLWINDOW *ct = WindowControl(db, inFocus);
int looped = 0;
if (ct != NULL)
{
do
{
if (ct == db->ctl)
{
if (looped)
return;
looped++;
while (ct->class)
ct++;
}
--ct;
} while (ct->class == TEXT || ct->class == BOX);
DfSendMessage(ct->wnd, SETFOCUS, TRUE, 0);
}
}
void SetFocusCursor(DFWINDOW wnd)
{
if (wnd == inFocus)
{
DfSendMessage(NULL, SHOW_CURSOR, 0, 0);
DfSendMessage(wnd, KEYBOARD_CURSOR, 1, 0);
}
}
/* EOF */

View file

@ -0,0 +1,160 @@
/* ----------- dialogs.c --------------- */
#include "dflat32/dflat.h"
/* -------------- the File Open dialog box --------------- */
DIALOGBOX( FileOpen )
DB_TITLE( "Open File", -1,-1,19,48)
CONTROL(TEXT, "~Filename", 2, 1, 1, 8, ID_FILENAME)
CONTROL(EDITBOX, NULL, 13, 1, 1,29, ID_FILENAME)
CONTROL(TEXT, "Directory:", 2, 3, 1,10, 0)
CONTROL(TEXT, NULL, 13, 3, 1,28, ID_PATH)
CONTROL(TEXT, "F~iles", 2, 5, 1, 5, ID_FILES)
CONTROL(LISTBOX, NULL, 2, 6,11,16, ID_FILES)
CONTROL(TEXT, "~Directories", 19, 5, 1,11, ID_DRIVE)
CONTROL(LISTBOX, NULL, 19, 6,11,16, ID_DRIVE)
CONTROL(BUTTON, " ~OK ", 36, 7, 1, 8, ID_OK)
CONTROL(BUTTON, " ~Cancel ", 36,10, 1, 8, ID_CANCEL)
CONTROL(BUTTON, " ~Help ", 36,13, 1, 8, ID_HELP)
ENDDB
/* -------------- the Save As dialog box --------------- */
DIALOGBOX( SaveAs )
DB_TITLE( "Save As", -1,-1,19,48)
CONTROL(TEXT, "~Filename", 2, 1, 1, 8, ID_FILENAME)
CONTROL(EDITBOX, NULL, 13, 1, 1,29, ID_FILENAME)
CONTROL(TEXT, "Directory:", 2, 3, 1,10, 0)
CONTROL(TEXT, NULL, 13, 3, 1,28, ID_PATH)
CONTROL(TEXT, "~Directories",2, 5, 1,11, ID_DRIVE)
CONTROL(LISTBOX, NULL, 2, 6,11,16, ID_DRIVE)
CONTROL(BUTTON, " ~OK ", 36, 7, 1, 8, ID_OK)
CONTROL(BUTTON, " ~Cancel ", 36,10, 1, 8, ID_CANCEL)
CONTROL(BUTTON, " ~Help ", 36,13, 1, 8, ID_HELP)
ENDDB
/* -------------- The Printer Setup dialog box ------------------ */
DIALOGBOX( PrintSetup )
DB_TITLE( "Printer Setup", -1, -1, 17, 32)
CONTROL(BOX, "Margins", 2, 3, 9, 26, 0 )
CONTROL(TEXT, "~Port:", 4, 1, 1, 5, ID_PRINTERPORT)
CONTROL(COMBOBOX, NULL, 12, 1, 8, 9, ID_PRINTERPORT)
CONTROL(TEXT, "~Left:", 6, 4, 1, 5, ID_LEFTMARGIN)
CONTROL(SPINBUTTON, NULL, 17, 4, 1, 6, ID_LEFTMARGIN)
CONTROL(TEXT, "~Right:", 6, 6, 1, 6, ID_RIGHTMARGIN)
CONTROL(SPINBUTTON, NULL, 17, 6, 1, 6, ID_RIGHTMARGIN)
CONTROL(TEXT, "~Top:", 6, 8, 1, 4, ID_TOPMARGIN)
CONTROL(SPINBUTTON, NULL, 17, 8, 1, 6, ID_TOPMARGIN)
CONTROL(TEXT, "~Bottom:", 6, 10, 1, 7, ID_BOTTOMMARGIN)
CONTROL(SPINBUTTON, NULL, 17, 10, 1, 6, ID_BOTTOMMARGIN)
CONTROL(BUTTON, " ~OK ", 1, 13, 1, 8, ID_OK)
CONTROL(BUTTON, " ~Cancel ", 11, 13, 1, 8, ID_CANCEL)
CONTROL(BUTTON, " ~Help ", 21, 13, 1, 8, ID_HELP)
ENDDB
/* -------------- the Search Text dialog box --------------- */
DIALOGBOX( SearchTextDB )
DB_TITLE( "Search Text", -1,-1,9,48)
CONTROL(TEXT, "~Search for:", 2, 1, 1, 11, ID_SEARCHFOR)
CONTROL(EDITBOX, NULL, 14, 1, 1, 29, ID_SEARCHFOR)
CONTROL(TEXT, "~Match upper/lower case:", 2, 3, 1, 23, ID_MATCHCASE)
CONTROL(CHECKBOX, NULL, 26, 3, 1, 3, ID_MATCHCASE)
CONTROL(BUTTON, " ~OK ", 7, 5, 1, 8, ID_OK)
CONTROL(BUTTON, " ~Cancel ", 19, 5, 1, 8, ID_CANCEL)
CONTROL(BUTTON, " ~Help ", 31, 5, 1, 8, ID_HELP)
ENDDB
/* -------------- the Replace Text dialog box --------------- */
DIALOGBOX( ReplaceTextDB )
DB_TITLE( "Replace Text", -1,-1,12,50)
CONTROL(TEXT, "~Search for:", 2, 1, 1, 11, ID_SEARCHFOR)
CONTROL(EDITBOX, NULL, 16, 1, 1, 29, ID_SEARCHFOR)
CONTROL(TEXT, "~Replace with:", 2, 3, 1, 13, ID_REPLACEWITH)
CONTROL(EDITBOX, NULL, 16, 3, 1, 29, ID_REPLACEWITH)
CONTROL(TEXT, "~Match upper/lower case:", 2, 5, 1, 23, ID_MATCHCASE)
CONTROL(CHECKBOX, NULL, 26, 5, 1, 3, ID_MATCHCASE)
CONTROL(TEXT, "Replace ~Every Match:", 2, 6, 1, 23, ID_REPLACEALL)
CONTROL(CHECKBOX, NULL, 26, 6, 1, 3, ID_REPLACEALL)
CONTROL(BUTTON, " ~OK ", 7, 8, 1, 8, ID_OK)
CONTROL(BUTTON, " ~Cancel ", 20, 8, 1, 8, ID_CANCEL)
CONTROL(BUTTON, " ~Help ", 33, 8, 1, 8, ID_HELP)
ENDDB
/* -------------- generic message dialog box --------------- */
DIALOGBOX( MsgBox )
DB_TITLE( NULL, -1,-1, 0, 0)
CONTROL(TEXT, NULL, 1, 1, 0, 0, 0)
CONTROL(BUTTON, NULL, 0, 0, 1, 8, ID_OK)
CONTROL(0, NULL, 0, 0, 1, 8, ID_CANCEL)
ENDDB
/* ----------- InputBox Dialog Box ------------ */
DIALOGBOX( InputBoxDB )
DB_TITLE( NULL, -1,-1, 9, 0)
CONTROL(TEXT, NULL, 1, 1, 1, 0, 0)
CONTROL(EDITBOX, NULL, 1, 3, 1, 0, ID_INPUTTEXT)
CONTROL(BUTTON, " ~OK ", 0, 5, 1, 8, ID_OK)
CONTROL(BUTTON, " ~Cancel ", 0, 5, 1, 8, ID_CANCEL)
ENDDB
/* ----------- SliderBox Dialog Box ------------- */
DIALOGBOX( SliderBoxDB )
DB_TITLE( NULL, -1,-1, 9, 0)
CONTROL(TEXT, NULL, 0, 1, 1, 0, 0)
CONTROL(TEXT, NULL, 0, 3, 1, 0, 0)
CONTROL(BUTTON, " Cancel ", 0, 5, 1, 8, ID_CANCEL)
ENDDB
/* ------------ Display dialog box -------------- */
DIALOGBOX( Display )
DB_TITLE( "Display", -1, -1, 12, 35)
CONTROL(BOX, "Window", 7, 1, 6,20, 0)
CONTROL(CHECKBOX, NULL, 9, 2, 1, 3, ID_TITLE)
CONTROL(TEXT, "~Title", 15, 2, 1, 5, ID_TITLE)
CONTROL(CHECKBOX, NULL, 9, 3, 1, 3, ID_BORDER)
CONTROL(TEXT, "~Border", 15, 3, 1, 6, ID_BORDER)
CONTROL(CHECKBOX, NULL, 9, 4, 1, 3, ID_STATUSBAR)
CONTROL(TEXT, "~Status bar",15, 4, 1,10, ID_STATUSBAR)
CONTROL(CHECKBOX, NULL, 9, 5, 1, 3, ID_TEXTURE)
CONTROL(TEXT, "Te~xture", 15, 5, 1, 7, ID_TEXTURE)
CONTROL(BUTTON, " ~OK ", 2, 8,1,8,ID_OK)
CONTROL(BUTTON, " ~Cancel ", 12, 8,1,8,ID_CANCEL)
CONTROL(BUTTON, " ~Help ", 22, 8,1,8,ID_HELP)
ENDDB
/* ------------ Windows dialog box -------------- */
DIALOGBOX( Windows )
DB_TITLE( "Windows", -1, -1, 19, 24)
CONTROL(LISTBOX, NULL, 1, 1,11,20, ID_WINDOWLIST)
CONTROL(BUTTON, " ~OK ", 2, 13, 1, 8, ID_OK)
CONTROL(BUTTON, " ~Cancel ", 12, 13, 1, 8, ID_CANCEL)
CONTROL(BUTTON, " ~Help ", 7, 15, 1, 8, ID_HELP)
ENDDB
#ifdef INCLUDE_LOGGING
/* ------------ Message Log dialog box -------------- */
DIALOGBOX( Log )
DB_TITLE( "D-Flat Message Log", -1, -1, 18, 41)
CONTROL(TEXT, "~Messages", 10, 1, 1, 8, ID_LOGLIST)
CONTROL(LISTBOX, NULL, 1, 2, 14, 26, ID_LOGLIST)
CONTROL(TEXT, "~Logging:", 29, 4, 1, 10, ID_LOGGING)
CONTROL(CHECKBOX, NULL, 31, 5, 1, 3, ID_LOGGING)
CONTROL(BUTTON, " ~OK ", 29, 7, 1, 8, ID_OK)
CONTROL(BUTTON, " ~Cancel ", 29, 10, 1, 8, ID_CANCEL)
CONTROL(BUTTON, " ~Help ", 29, 13, 1, 8, ID_HELP)
ENDDB
#endif
/* ------------ the Help window dialog box -------------- */
DIALOGBOX( HelpBox )
DB_TITLE( NULL, -1, -1, 0, 45)
CONTROL(TEXTBOX, NULL, 1, 1, 0, 40, ID_HELPTEXT)
CONTROL(BUTTON, " ~Close ", 0, 0, 1, 8, ID_CANCEL)
CONTROL(BUTTON, " ~Back ", 10, 0, 1, 8, ID_BACK)
CONTROL(BUTTON, "<< ~Prev ", 20, 0, 1, 8, ID_PREV)
CONTROL(BUTTON, " ~Next >>", 30, 0, 1, 8, ID_NEXT)
ENDDB
/* EOF */

View file

@ -1,7 +1,7 @@
/*
*
* ReactOS DFLAT32.DLL
*/
#include <windows.h>
BOOLEAN __stdcall DllMain(
PVOID hinstDll,

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,717 @@
/* ------------ helpbox.c ----------- */
#include "dflat32/dflat.h"
#include "dflat32/htree.h"
extern DBOX HelpBox;
/* -------- strings of D-Flat classes for calling default
help text collections -------- */
char *ClassNames[] = {
#undef ClassDef
#define ClassDef(c,b,p,a) #c,
#include "dflat32/classes.h"
NULL
};
#define MAXHEIGHT (DfGetScreenHeight()-10)
/* --------- linked list of help text collections -------- */
struct helps {
char *hname;
char *NextName;
char *PrevName;
long hptr;
int bit;
int hheight;
int hwidth;
DFWINDOW hwnd;
struct helps *NextHelp;
};
static struct helps *FirstHelp;
static struct helps *LastHelp;
static struct helps *ThisHelp;
/* --- linked stack of help windows that have beed used --- */
struct HelpStack {
char *hname;
struct HelpStack *PrevStack;
};
static struct HelpStack *LastStack;
static struct HelpStack *ThisStack;
/* --- linked list of keywords in the current help
text collection (listhead is in window) -------- */
struct keywords {
char *hname;
int lineno;
int off1, off2, off3;
int isDefinition;
struct keywords *nextword;
struct keywords *prevword;
};
static FILE *helpfp;
static char hline [160];
static BOOL Helping;
static void SelectHelp(DFWINDOW, char *);
static void ReadHelp(DFWINDOW);
static void FindHelp(char *);
static void FindHelpWindow(DFWINDOW);
static void DisplayDefinition(DFWINDOW, char *);
static void BestFit(DFWINDOW, DIALOGWINDOW *);
/* ------------- CREATE_WINDOW message ------------ */
static void CreateWindowMsg(DFWINDOW wnd)
{
Helping = TRUE;
GetClass(wnd) = HELPBOX;
InitWindowColors(wnd);
if (ThisHelp != NULL)
ThisHelp->hwnd = wnd;
}
/* ------------- COMMAND message ------------ */
static BOOL CommandMsg(DFWINDOW wnd, PARAM p1)
{
switch ((int)p1) {
case ID_CANCEL:
ThisStack = LastStack;
while (ThisStack != NULL) {
LastStack = ThisStack->PrevStack;
if (ThisStack->hname != NULL)
free(ThisStack->hname);
free(ThisStack);
ThisStack = LastStack;
}
break;
case ID_PREV:
FindHelpWindow(wnd);
if (ThisHelp != NULL)
SelectHelp(wnd, ThisHelp->PrevName);
return TRUE;
case ID_NEXT:
FindHelpWindow(wnd);
if (ThisHelp != NULL)
SelectHelp(wnd, ThisHelp->NextName);
return TRUE;
case ID_BACK:
if (LastStack != NULL) {
if (LastStack->PrevStack != NULL) {
ThisStack = LastStack->PrevStack;
if (LastStack->hname != NULL)
free(LastStack->hname);
free(LastStack);
LastStack = ThisStack;
SelectHelp(wnd, ThisStack->hname);
}
}
return TRUE;
default:
break;
}
return FALSE;
}
/* ------------- KEYBOARD message ------------ */
static BOOL KeyboardMsg(DFWINDOW wnd, PARAM p1)
{
DFWINDOW cwnd;
struct keywords *thisword;
static char HelpName[50];
cwnd = ControlWindow(wnd->extension, ID_HELPTEXT);
if (cwnd == NULL || inFocus != cwnd)
return FALSE;
thisword = cwnd->thisword;
switch ((int)p1) {
case '\r':
if (thisword != NULL) {
if (thisword->isDefinition)
DisplayDefinition(GetParent(wnd),
thisword->hname);
else {
strncpy(HelpName, thisword->hname,
sizeof HelpName);
SelectHelp(wnd, HelpName);
}
}
return TRUE;
case '\t':
if (thisword == NULL)
thisword = cwnd->firstword;
else {
if (thisword->nextword == NULL)
thisword = cwnd->firstword;
else
thisword = thisword->nextword;
}
break;
case SHIFT_HT:
if (thisword == NULL)
thisword = cwnd->lastword;
else {
if (thisword->prevword == NULL)
thisword = cwnd->lastword;
else
thisword = thisword->prevword;
}
break;
default:
thisword = NULL;
break;
}
if (thisword != NULL) {
cwnd->thisword = thisword;
if (thisword->lineno < cwnd->wtop ||
thisword->lineno >=
cwnd->wtop + ClientHeight(cwnd)) {
int distance = ClientHeight(cwnd)/2;
do {
cwnd->wtop = thisword->lineno-distance;
distance /= 2;
}
while (cwnd->wtop < 0);
}
DfSendMessage(cwnd, PAINT, 0, 0);
return TRUE;
}
return FALSE;
}
/* ---- window processing module for the HELPBOX ------- */
int HelpBoxProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
DBOX *db = wnd->extension;
switch (msg) {
case CREATE_WINDOW:
CreateWindowMsg(wnd);
break;
case INITIATE_DIALOG:
ReadHelp(wnd);
break;
case DFM_COMMAND:
if (p2 != 0)
break;
if (CommandMsg(wnd, p1))
return TRUE;
break;
case KEYBOARD:
if (WindowMoving)
break;
if (KeyboardMsg(wnd, p1))
return TRUE;
break;
case CLOSE_WINDOW:
if (db != NULL) {
if (db->dwnd.title != NULL) {
free(db->dwnd.title);
db->dwnd.title = NULL;
}
}
FindHelpWindow(wnd);
if (ThisHelp != NULL)
ThisHelp->hwnd = NULL;
Helping = FALSE;
break;
default:
break;
}
return BaseWndProc(HELPBOX, wnd, msg, p1, p2);
}
/* ----- select a new help window from its name ----- */
static void SelectHelp(DFWINDOW wnd, char *hname)
{
if (hname != NULL) {
DFWINDOW pwnd = GetParent(wnd);
DfPostMessage(wnd, ENDDIALOG, 0, 0);
DfPostMessage(pwnd, DISPLAY_HELP, (PARAM) hname, 0);
}
}
/* ---- PAINT message for the helpbox text editbox ---- */
static int PaintMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
struct keywords *thisword;
int rtn;
if (wnd->thisword != NULL) {
DFWINDOW pwnd = GetParent(wnd);
char *cp;
thisword = wnd->thisword;
cp = TextLine(wnd, thisword->lineno);
cp += thisword->off1;
*(cp+1) =
(pwnd->WindowColors[SELECT_COLOR][FG] & 255) | 0x80;
*(cp+2) =
(pwnd->WindowColors[SELECT_COLOR][BG] & 255) | 0x80;
rtn = DefaultWndProc(wnd, PAINT, p1, p2);
*(cp+1) =
(pwnd->WindowColors[HILITE_COLOR][FG] & 255) | 0x80;
*(cp+2) =
(pwnd->WindowColors[HILITE_COLOR][BG] & 255) | 0x80;
return rtn;
}
return DefaultWndProc(wnd, PAINT, p1, p2);
}
/* ---- LEFT_BUTTON message for the helpbox text editbox ---- */
static int LeftButtonMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
struct keywords *thisword;
int rtn, mx, my;
rtn = DefaultWndProc(wnd, LEFT_BUTTON, p1, p2);
mx = (int)p1 - GetClientLeft(wnd);
my = (int)p2 - GetClientTop(wnd);
my += wnd->wtop;
thisword = wnd->firstword;
while (thisword != NULL) {
if (my == thisword->lineno) {
if (mx >= thisword->off2 &&
mx < thisword->off3) {
wnd->thisword = thisword;
DfSendMessage(wnd, PAINT, 0, 0);
if (thisword->isDefinition) {
DFWINDOW pwnd = GetParent(wnd);
if (pwnd != NULL)
DisplayDefinition(GetParent(pwnd),
thisword->hname);
}
break;
}
}
thisword = thisword->nextword;
}
return rtn;
}
/* --- window processing module for HELPBOX's text EDITBOX -- */
int HelpTextProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
struct keywords *thisword;
switch (msg) {
case PAINT:
return PaintMsg(wnd, p1, p2);
case LEFT_BUTTON:
return LeftButtonMsg(wnd, p1, p2);
case DOUBLE_CLICK:
DfPostMessage(wnd, KEYBOARD, '\r', 0);
break;
case CLOSE_WINDOW:
thisword = wnd->firstword;
while (thisword != NULL) {
struct keywords *nextword = thisword->nextword;
if (thisword->hname != NULL)
free(thisword->hname);
free(thisword);
thisword = nextword;
}
break;
default:
break;
}
return DefaultWndProc(wnd, msg, p1, p2);
}
/* -------- read the help text into the editbox ------- */
static void ReadHelp(DFWINDOW wnd)
{
DFWINDOW cwnd = ControlWindow(wnd->extension, ID_HELPTEXT);
int linectr = 0;
if (cwnd == NULL)
return;
cwnd->wndproc = HelpTextProc;
/* ----- read the help text ------- */
while (TRUE) {
unsigned char *cp = hline, *cp1;
int colorct = 0;
if (GetHelpLine(hline) == NULL)
break;
if (*hline == '<')
break;
hline[strlen(hline)-1] = '\0';
/* --- add help text to the help window --- */
while (cp != NULL) {
if ((cp = strchr(cp, '[')) != NULL) {
/* ----- hit a new key word ----- */
struct keywords *thisword;
if (*(cp+1) != '.' && *(cp+1) != '*') {
cp++;
continue;
}
thisword = DFcalloc(1, sizeof(struct keywords));
if (cwnd->firstword == NULL)
cwnd->firstword = thisword;
if (cwnd->lastword != NULL) {
((struct keywords *)
(cwnd->lastword))->nextword = thisword;
thisword->prevword = cwnd->lastword;
}
cwnd->lastword = thisword;
thisword->lineno = cwnd->wlines;
thisword->off1 = (int) ((int)cp - (int)hline);
thisword->off2 = thisword->off1 - colorct * 4;
thisword->isDefinition = *(cp+1) == '*';
colorct++;
*cp++ = CHANGECOLOR;
*cp++ =
(wnd->WindowColors [HILITE_COLOR] [FG] & 255) | 0x80;
*cp++ =
(wnd->WindowColors [HILITE_COLOR] [BG] & 255) | 0x80;
cp1 = cp;
if ((cp = strchr(cp, ']')) != NULL) {
if (thisword != NULL)
thisword->off3 =
thisword->off2 + (int) (cp - cp1);
*cp++ = RESETCOLOR;
}
if ((cp = strchr(cp, '<')) != NULL) {
char *cp1 = strchr(cp, '>');
if (cp1 != NULL) {
int len = (int) ((int)cp1 - (int)cp);
thisword->hname = DFcalloc(1, len);
strncpy(thisword->hname, cp+1, len-1);
memmove(cp, cp1+1, strlen(cp1));
}
}
}
}
PutItemText(wnd, ID_HELPTEXT, hline);
/* -- display help text as soon as window is full -- */
if (++linectr == ClientHeight(cwnd))
DfSendMessage(cwnd, PAINT, 0, 0);
if (linectr > ClientHeight(cwnd) &&
!TestAttribute(cwnd, VSCROLLBAR)) {
AddAttribute(cwnd, VSCROLLBAR);
DfSendMessage(cwnd, BORDER, 0, 0);
}
}
}
/* ---- compute the displayed length of a help text line --- */
static int HelpLength(char *s)
{
int len = strlen(s);
char *cp = strchr(s, '[');
while (cp != NULL) {
len -= 4;
cp = strchr(cp+1, '[');
}
cp = strchr(s, '<');
while (cp != NULL) {
char *cp1 = strchr(cp, '>');
if (cp1 != NULL)
len -= (int) (cp1-cp)+1;
cp = strchr(cp1, '<');
}
return len;
}
/* ----------- load the help text file ------------ */
void LoadHelpFile()
{
char *cp;
if (Helping)
return;
UnLoadHelpFile();
if ((helpfp = OpenHelpFile()) == NULL)
return;
*hline = '\0';
while (*hline != '<') {
if (GetHelpLine(hline) == NULL) {
fclose(helpfp);
return;
}
}
while (*hline == '<') {
if (strncmp(hline, "<end>", 5) == 0)
break;
/* -------- parse the help window's text name ----- */
if ((cp = strchr(hline, '>')) != NULL) {
ThisHelp = DFcalloc(1, sizeof(struct helps));
if (FirstHelp == NULL)
FirstHelp = ThisHelp;
*cp = '\0';
ThisHelp->hname=DFmalloc(strlen(hline+1)+1);
strcpy(ThisHelp->hname, hline+1);
HelpFilePosition(&ThisHelp->hptr, &ThisHelp->bit);
if (GetHelpLine(hline) == NULL)
break;
/* ------- build the help linked list entry --- */
while (*hline == '[') {
HelpFilePosition(&ThisHelp->hptr,
&ThisHelp->bit);
/* ---- parse the <<prev button pointer ---- */
if (strncmp(hline, "[<<]", 4) == 0) {
char *cp = strchr(hline+4, '<');
if (cp != NULL) {
char *cp1 = strchr(cp, '>');
if (cp1 != NULL) {
int len = (int) (cp1-cp);
ThisHelp->PrevName=DFcalloc(1,len);
strncpy(ThisHelp->PrevName,
cp+1,len-1);
}
}
if (GetHelpLine(hline) == NULL)
break;
continue;
}
/* ---- parse the next>> button pointer ---- */
else if (strncmp(hline, "[>>]", 4) == 0) {
char *cp = strchr(hline+4, '<');
if (cp != NULL) {
char *cp1 = strchr(cp, '>');
if (cp1 != NULL) {
int len = (int) (cp1-cp);
ThisHelp->NextName=DFcalloc(1,len);
strncpy(ThisHelp->NextName,
cp+1,len-1);
}
}
if (GetHelpLine(hline) == NULL)
break;
continue;
}
else
break;
}
ThisHelp->hheight = 0;
ThisHelp->hwidth = 0;
ThisHelp->NextHelp = NULL;
/* ------ append entry to the linked list ------ */
if (LastHelp != NULL)
LastHelp->NextHelp = ThisHelp;
LastHelp = ThisHelp;
}
/* -------- move to the next <helpname> token ------ */
if (GetHelpLine(hline) == NULL)
strcpy(hline, "<end>");
while (*hline != '<') {
ThisHelp->hwidth =
max(ThisHelp->hwidth, HelpLength(hline));
ThisHelp->hheight++;
if (GetHelpLine(hline) == NULL)
strcpy(hline, "<end>");
}
}
fclose(helpfp);
}
/* ------ free the memory used by the help file table ------ */
void UnLoadHelpFile(void)
{
while (FirstHelp != NULL) {
ThisHelp = FirstHelp;
if (ThisHelp->hname != NULL)
free(ThisHelp->hname);
if (ThisHelp->PrevName != NULL)
free(ThisHelp->PrevName);
if (ThisHelp->NextName != NULL)
free(ThisHelp->NextName);
FirstHelp = ThisHelp->NextHelp;
free(ThisHelp);
}
ThisHelp = LastHelp = NULL;
free(HelpTree);
HelpTree = NULL;
}
/* ---------- display a specified help text ----------- */
BOOL DisplayHelp(DFWINDOW wnd, char *Help)
{
BOOL rtn = FALSE;
if (Helping)
return TRUE;
wnd->isHelping++;
FindHelp(Help);
if (ThisHelp != NULL) {
if (LastStack == NULL ||
stricmp(Help, LastStack->hname)) {
/* ---- add the window to the history stack ---- */
ThisStack = DFcalloc(1,sizeof(struct HelpStack));
ThisStack->hname = DFmalloc(strlen(Help)+1);
if (ThisStack->hname != NULL)
strcpy(ThisStack->hname, Help);
ThisStack->PrevStack = LastStack;
LastStack = ThisStack;
}
if ((helpfp = OpenHelpFile()) != NULL) {
DBOX *db;
int offset, i;
db = DFcalloc(1,sizeof HelpBox);
memcpy(db, &HelpBox, sizeof HelpBox);
/* -- seek to the first line of the help text -- */
SeekHelpLine(ThisHelp->hptr, ThisHelp->bit);
/* ----- read the title ----- */
GetHelpLine(hline);
hline[strlen(hline)-1] = '\0';
db->dwnd.title = DFmalloc(strlen(hline)+1);
strcpy(db->dwnd.title, hline);
/* ----- set the height and width ----- */
db->dwnd.h = min(ThisHelp->hheight, MAXHEIGHT)+7;
db->dwnd.w = max(45, ThisHelp->hwidth+6);
/* ------ position the help window ----- */
BestFit(wnd, &db->dwnd);
/* ------- position the command buttons ------ */
db->ctl[0].dwnd.w = max(40, ThisHelp->hwidth+2);
db->ctl[0].dwnd.h =
min(ThisHelp->hheight, MAXHEIGHT)+2;
offset = (db->dwnd.w-40) / 2;
for (i = 1; i < 5; i++) {
db->ctl[i].dwnd.y =
min(ThisHelp->hheight, MAXHEIGHT)+3;
db->ctl[i].dwnd.x += offset;
}
/* ---- disable ineffective buttons ---- */
if (ThisStack != NULL)
if (ThisStack->PrevStack == NULL)
DisableButton(db, ID_BACK);
if (ThisHelp->NextName == NULL)
DisableButton(db, ID_NEXT);
if (ThisHelp->PrevName == NULL)
DisableButton(db, ID_PREV);
/* ------- display the help window ----- */
DfDialogBox(NULL, db, TRUE, HelpBoxProc);
free(db);
fclose(helpfp);
rtn = TRUE;
}
}
--wnd->isHelping;
return rtn;
}
/* ------- display a definition window --------- */
static void DisplayDefinition(DFWINDOW wnd, char *def)
{
DFWINDOW dwnd;
DFWINDOW hwnd = wnd;
int y;
if (GetClass(wnd) == POPDOWNMENU)
hwnd = GetParent(wnd);
y = GetClass(hwnd) == MENUBAR ? 2 : 1;
FindHelp(def);
if (ThisHelp != NULL) {
if ((helpfp = OpenHelpFile()) != NULL) {
dwnd = DfCreateWindow(
TEXTBOX,
NULL,
GetClientLeft(hwnd),
GetClientTop(hwnd)+y,
min(ThisHelp->hheight, MAXHEIGHT)+3,
ThisHelp->hwidth+2,
NULL,
wnd,
NULL,
HASBORDER | NOCLIP | SAVESELF);
if (dwnd != NULL) {
/* ----- read the help text ------- */
SeekHelpLine(ThisHelp->hptr, ThisHelp->bit);
while (TRUE) {
if (GetHelpLine(hline) == NULL)
break;
if (*hline == '<')
break;
hline[strlen(hline)-1] = '\0';
DfSendMessage(dwnd,ADDTEXT,(PARAM)hline,0);
}
DfSendMessage(dwnd, SHOW_WINDOW, 0, 0);
DfSendMessage(NULL, WAITKEYBOARD, 0, 0);
DfSendMessage(NULL, WAITMOUSE, 0, 0);
DfSendMessage(dwnd, CLOSE_WINDOW, 0, 0);
}
fclose(helpfp);
}
}
}
/* ------ compare help names with wild cards ----- */
static BOOL wildcmp(char *s1, char *s2)
{
while (*s1 || *s2) {
if (tolower(*s1) != tolower(*s2))
if (*s1 != '?' && *s2 != '?')
return TRUE;
s1++, s2++;
}
return FALSE;
}
/* --- ThisHelp = the help window matching specified name --- */
static void FindHelp(char *Help)
{
ThisHelp = FirstHelp;
while (ThisHelp != NULL) {
if (wildcmp(Help, ThisHelp->hname) == FALSE)
break;
ThisHelp = ThisHelp->NextHelp;
}
}
/* --- ThisHelp = the help window matching specified wnd --- */
static void FindHelpWindow(DFWINDOW wnd)
{
ThisHelp = FirstHelp;
while (ThisHelp != NULL) {
if (wnd == ThisHelp->hwnd)
break;
ThisHelp = ThisHelp->NextHelp;
}
}
static int OverLap(int a, int b)
{
int ov = a - b;
if (ov < 0)
ov = 0;
return ov;
}
/* ----- compute the best location for a help dialogbox ----- */
static void BestFit(DFWINDOW wnd, DIALOGWINDOW *dwnd)
{
int above, below, right, left;
if (GetClass(wnd) == MENUBAR ||
GetClass(wnd) == APPLICATION) {
dwnd->x = dwnd->y = -1;
return;
}
/* --- compute above overlap ---- */
above = OverLap(dwnd->h, GetTop(wnd));
/* --- compute below overlap ---- */
below = OverLap(GetBottom(wnd), DfGetScreenHeight()-dwnd->h);
/* --- compute right overlap ---- */
right = OverLap(GetRight(wnd), DfGetScreenWidth()-dwnd->w);
/* --- compute left overlap ---- */
left = OverLap(dwnd->w, GetLeft(wnd));
if (above < below)
dwnd->y = max(0, GetTop(wnd)-dwnd->h-2);
else
dwnd->y = min(DfGetScreenHeight()-dwnd->h, GetBottom(wnd)+2);
if (right < left)
dwnd->x = min(GetRight(wnd)+2, DfGetScreenWidth()-dwnd->w);
else
dwnd->x = max(0, GetLeft(wnd)-dwnd->w-2);
if (dwnd->x == GetRight(wnd)+2 ||
dwnd->x == GetLeft(wnd)-dwnd->w-2)
dwnd->y = -1;
if (dwnd->y ==GetTop(wnd)-dwnd->h-2 ||
dwnd->y == GetBottom(wnd)+2)
dwnd->x = -1;
}
/* EOF */

View file

@ -0,0 +1,86 @@
/* ------------- keys.c ----------- */
#include <stdio.h>
#include "dflat32/keys.h"
struct keys keys[] = {
{F1, "F1"},
{F2, "F2"},
{F3, "F3"},
{F4, "F4"},
{F5, "F5"},
{F6, "F6"},
{F7, "F7"},
{F8, "F8"},
{F9, "F9"},
{F10, "F10"},
{CTRL_F1, "Ctrl+F1"},
{CTRL_F2, "Ctrl+F2"},
{CTRL_F3, "Ctrl+F3"},
{CTRL_F4, "Ctrl+F4"},
{CTRL_F5, "Ctrl+F5"},
{CTRL_F6, "Ctrl+F6"},
{CTRL_F7, "Ctrl+F7"},
{CTRL_F8, "Ctrl+F8"},
{CTRL_F9, "Ctrl+F9"},
{CTRL_F10, "Ctrl+F10"},
{ALT_F1, "Alt+F1"},
{ALT_F2, "Alt+F2"},
{ALT_F3, "Alt+F3"},
{ALT_F4, "Alt+F4"},
{ALT_F5, "Alt+F5"},
{ALT_F6, "Alt+F6"},
{ALT_F7, "Alt+F7"},
{ALT_F8, "Alt+F8"},
{ALT_F9, "Alt+F9"},
{ALT_F10, "Alt+F10"},
{HOME, "Home"},
{UP, "Up"},
{PGUP, "PgUp"},
{BS, "BS"},
{END, "End"},
{DN, "Dn"},
{PGDN, "PgDn"},
{INS, "Ins"},
{DEL, "Del"},
{CTRL_HOME, "Ctrl+Home"},
{CTRL_PGUP, "Ctrl+PgUp"},
{CTRL_BS, "Ctrl+BS"},
{CTRL_END, "Ctrl+End"},
{CTRL_PGDN, "Ctrl+PgDn"},
{SHIFT_HT, "Shift+Tab"},
{ALT_BS, "Alt+BS"},
{ALT_DEL, "Alt+Del"},
{SHIFT_DEL, "Shift+Del"},
{SHIFT_INS, "Shift+Ins"},
{CTRL_INS, "Ctrl+Ins"},
{ALT_A, "Alt+A"},
{ALT_B, "Alt+B"},
{ALT_C, "Alt+C"},
{ALT_D, "Alt+D"},
{ALT_E, "Alt+E"},
{ALT_F, "Alt+F"},
{ALT_G, "Alt+G"},
{ALT_H, "Alt+H"},
{ALT_I, "Alt+I"},
{ALT_J, "Alt+J"},
{ALT_K, "Alt+K"},
{ALT_L, "Alt+L"},
{ALT_M, "Alt+M"},
{ALT_N, "Alt+N"},
{ALT_O, "Alt+O"},
{ALT_P, "Alt+P"},
{ALT_Q, "Alt+Q"},
{ALT_R, "Alt+R"},
{ALT_S, "Alt+S"},
{ALT_T, "Alt+T"},
{ALT_U, "Alt+U"},
{ALT_V, "Alt+V"},
{ALT_W, "Alt+W"},
{ALT_X, "Alt+X"},
{ALT_Y, "Alt+Y"},
{ALT_Z, "Alt+Z"},
{-1, NULL}
};
/* EOF */

View file

@ -0,0 +1,469 @@
/* ------------- listbox.c ------------ */
#include "dflat32/dflat.h"
#ifdef INCLUDE_EXTENDEDSELECTIONS
static int ExtendSelections(DFWINDOW, int, int);
static void TestExtended(DFWINDOW, PARAM);
static void ClearAllSelections(DFWINDOW);
static void SetSelection(DFWINDOW, int);
static void FlipSelection(DFWINDOW, int);
static void ClearSelection(DFWINDOW, int);
#else
#define TestExtended(w,p) /**/
#endif
static void ChangeSelection(DFWINDOW, int, int);
static void WriteSelection(DFWINDOW, int, int, DFRECT *);
static BOOL SelectionInWindow(DFWINDOW, int);
static int py = -1; /* the previous y mouse coordinate */
#ifdef INCLUDE_EXTENDEDSELECTIONS
/* --------- SHIFT_F8 Key ------------ */
static void AddModeKey(DFWINDOW wnd)
{
if (isMultiLine(wnd)) {
wnd->AddMode ^= TRUE;
DfSendMessage(GetParent(wnd), ADDSTATUS,
wnd->AddMode ? ((PARAM) "Add Mode") : 0, 0);
}
}
#endif
/* --------- UP (Up Arrow) Key ------------ */
static void UpKey(DFWINDOW wnd, PARAM p2)
{
if (wnd->selection > 0) {
if (wnd->selection == wnd->wtop) {
BaseWndProc(LISTBOX, wnd, KEYBOARD, UP, p2);
DfPostMessage(wnd, LB_SELECTION, wnd->selection-1,
isMultiLine(wnd) ? p2 : FALSE);
}
else {
int newsel = wnd->selection-1;
if (wnd->wlines == ClientHeight(wnd))
while (*TextLine(wnd, newsel) == LINE)
--newsel;
DfPostMessage(wnd, LB_SELECTION, newsel,
#ifdef INCLUDE_EXTENDEDSELECTIONS
isMultiLine(wnd) ? p2 :
#endif
FALSE);
}
}
}
/* --------- DN (Down Arrow) Key ------------ */
static void DnKey(DFWINDOW wnd, PARAM p2)
{
if (wnd->selection < wnd->wlines-1) {
if (wnd->selection == wnd->wtop+ClientHeight(wnd)-1) {
BaseWndProc(LISTBOX, wnd, KEYBOARD, DN, p2);
DfPostMessage(wnd, LB_SELECTION, wnd->selection+1,
isMultiLine(wnd) ? p2 : FALSE);
}
else {
int newsel = wnd->selection+1;
if (wnd->wlines == ClientHeight(wnd))
while (*TextLine(wnd, newsel) == LINE)
newsel++;
DfPostMessage(wnd, LB_SELECTION, newsel,
#ifdef INCLUDE_EXTENDEDSELECTIONS
isMultiLine(wnd) ? p2 :
#endif
FALSE);
}
}
}
/* --------- HOME and PGUP Keys ------------ */
static void HomePgUpKey(DFWINDOW wnd, PARAM p1, PARAM p2)
{
BaseWndProc(LISTBOX, wnd, KEYBOARD, p1, p2);
DfPostMessage(wnd, LB_SELECTION, wnd->wtop,
#ifdef INCLUDE_EXTENDEDSELECTIONS
isMultiLine(wnd) ? p2 :
#endif
FALSE);
}
/* --------- END and PGDN Keys ------------ */
static void EndPgDnKey(DFWINDOW wnd, PARAM p1, PARAM p2)
{
int bot;
BaseWndProc(LISTBOX, wnd, KEYBOARD, p1, p2);
bot = wnd->wtop+ClientHeight(wnd)-1;
if (bot > wnd->wlines-1)
bot = wnd->wlines-1;
DfPostMessage(wnd, LB_SELECTION, bot,
#ifdef INCLUDE_EXTENDEDSELECTIONS
isMultiLine(wnd) ? p2 :
#endif
FALSE);
}
#ifdef INCLUDE_EXTENDEDSELECTIONS
/* --------- Space Bar Key ------------ */
static void SpacebarKey(DFWINDOW wnd, PARAM p2)
{
if (isMultiLine(wnd)) {
int sel = DfSendMessage(wnd, LB_CURRENTSELECTION, 0, 0);
if (sel != -1) {
if (wnd->AddMode)
FlipSelection(wnd, sel);
if (ItemSelected(wnd, sel)) {
if (!((int) p2 & (LEFTSHIFT | RIGHTSHIFT)))
wnd->AnchorPoint = sel;
ExtendSelections(wnd, sel, (int) p2);
}
else
wnd->AnchorPoint = -1;
DfSendMessage(wnd, PAINT, 0, 0);
}
}
}
#endif
/* --------- Enter ('\r') Key ------------ */
static void EnterKey(DFWINDOW wnd)
{
if (wnd->selection != -1) {
DfSendMessage(wnd, LB_SELECTION, wnd->selection, TRUE);
DfSendMessage(wnd, LB_CHOOSE, wnd->selection, 0);
}
}
/* --------- All Other Key Presses ------------ */
static void KeyPress(DFWINDOW wnd, PARAM p1, PARAM p2)
{
int sel = wnd->selection+1;
while (sel < wnd->wlines) {
char *cp = TextLine(wnd, sel);
if (cp == NULL)
break;
#ifdef INCLUDE_EXTENDEDSELECTIONS
if (isMultiLine(wnd))
cp++;
#endif
/* --- special for directory list box --- */
if (*cp == '[')
cp++;
if (tolower(*cp) == (int)p1) {
DfSendMessage(wnd, LB_SELECTION, sel,
isMultiLine(wnd) ? p2 : FALSE);
if (!SelectionInWindow(wnd, sel)) {
wnd->wtop = sel-ClientHeight(wnd)+1;
DfSendMessage(wnd, PAINT, 0, 0);
}
break;
}
sel++;
}
}
/* --------- KEYBOARD Message ------------ */
static int KeyboardMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
switch ((int) p1) {
#ifdef INCLUDE_EXTENDEDSELECTIONS
case SHIFT_F8:
AddModeKey(wnd);
return TRUE;
#endif
case UP:
TestExtended(wnd, p2);
UpKey(wnd, p2);
return TRUE;
case DN:
TestExtended(wnd, p2);
DnKey(wnd, p2);
return TRUE;
case PGUP:
case HOME:
TestExtended(wnd, p2);
HomePgUpKey(wnd, p1, p2);
return TRUE;
case PGDN:
case END:
TestExtended(wnd, p2);
EndPgDnKey(wnd, p1, p2);
return TRUE;
#ifdef INCLUDE_EXTENDEDSELECTIONS
case ' ':
SpacebarKey(wnd, p2);
break;
#endif
case '\r':
EnterKey(wnd);
return TRUE;
default:
KeyPress(wnd, p1, p2);
break;
}
return FALSE;
}
/* ------- LEFT_BUTTON Message -------- */
static int LeftButtonMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
int my = (int) p2 - GetTop(wnd);
if (my >= wnd->wlines-wnd->wtop)
my = wnd->wlines - wnd->wtop;
if (!InsideRect(p1, p2, ClientRect(wnd)))
return FALSE;
if (wnd->wlines && my != py) {
int sel = wnd->wtop+my-1;
#ifdef INCLUDE_EXTENDEDSELECTIONS
int sh = getshift();
if (!(sh & (LEFTSHIFT | RIGHTSHIFT))) {
if (!(sh & CTRLKEY))
ClearAllSelections(wnd);
wnd->AnchorPoint = sel;
DfSendMessage(wnd, PAINT, 0, 0);
}
#endif
DfSendMessage(wnd, LB_SELECTION, sel, TRUE);
py = my;
}
return TRUE;
}
/* ------------- DOUBLE_CLICK Message ------------ */
static int DoubleClickMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
if (WindowMoving || WindowSizing)
return FALSE;
if (wnd->wlines) {
DFRECT rc = ClientRect(wnd);
BaseWndProc(LISTBOX, wnd, DOUBLE_CLICK, p1, p2);
if (InsideRect(p1, p2, rc))
DfSendMessage(wnd, LB_CHOOSE, wnd->selection, 0);
}
return TRUE;
}
/* ------------ ADDTEXT Message -------------- */
static int AddTextMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
int rtn = BaseWndProc(LISTBOX, wnd, ADDTEXT, p1, p2);
if (wnd->selection == -1)
DfSendMessage(wnd, LB_SETSELECTION, 0, 0);
#ifdef INCLUDE_EXTENDEDSELECTIONS
if (*(char *)p1 == LISTSELECTOR)
wnd->SelectCount++;
#endif
return rtn;
}
/* --------- GETTEXT Message ------------ */
static void GetTextMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
if ((int)p2 != -1) {
char *cp1 = (char *)p1;
char *cp2 = TextLine(wnd, (int)p2);
while (cp2 && *cp2 && *cp2 != '\n')
*cp1++ = *cp2++;
*cp1 = '\0';
}
}
/* --------- LISTBOX Window Processing Module ------------ */
int ListBoxProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
switch (msg) {
case CREATE_WINDOW:
BaseWndProc(LISTBOX, wnd, msg, p1, p2);
wnd->selection = -1;
#ifdef INCLUDE_EXTENDEDSELECTIONS
wnd->AnchorPoint = -1;
#endif
return TRUE;
case KEYBOARD:
if (WindowMoving || WindowSizing)
break;
if (KeyboardMsg(wnd, p1, p2))
return TRUE;
break;
case LEFT_BUTTON:
if (LeftButtonMsg(wnd, p1, p2) == TRUE)
return TRUE;
break;
case DOUBLE_CLICK:
if (DoubleClickMsg(wnd, p1, p2))
return TRUE;
break;
case DFM_BUTTON_RELEASED:
if (WindowMoving || WindowSizing || VSliding)
break;
py = -1;
return TRUE;
case ADDTEXT:
return AddTextMsg(wnd, p1, p2);
case DFM_LB_GETTEXT:
GetTextMsg(wnd, p1, p2);
return TRUE;
case CLEARTEXT:
wnd->selection = -1;
#ifdef INCLUDE_EXTENDEDSELECTIONS
wnd->AnchorPoint = -1;
#endif
wnd->SelectCount = 0;
break;
case PAINT:
BaseWndProc(LISTBOX, wnd, msg, p1, p2);
WriteSelection(wnd, wnd->selection, TRUE, (DFRECT *)p1);
return TRUE;
case SCROLL:
case HORIZSCROLL:
case SCROLLPAGE:
case HORIZPAGE:
case SCROLLDOC:
BaseWndProc(LISTBOX, wnd, msg, p1, p2);
WriteSelection(wnd,wnd->selection,TRUE,NULL);
return TRUE;
case LB_CHOOSE:
DfSendMessage(GetParent(wnd), LB_CHOOSE, p1, p2);
return TRUE;
case LB_SELECTION:
ChangeSelection(wnd, (int) p1, (int) p2);
DfSendMessage(GetParent(wnd), LB_SELECTION,
wnd->selection, 0);
return TRUE;
case LB_CURRENTSELECTION:
return wnd->selection;
case LB_SETSELECTION:
ChangeSelection(wnd, (int) p1, 0);
return TRUE;
#ifdef INCLUDE_EXTENDEDSELECTIONS
case CLOSE_WINDOW:
if (isMultiLine(wnd) && wnd->AddMode) {
wnd->AddMode = FALSE;
DfSendMessage(GetParent(wnd), ADDSTATUS, 0, 0);
}
break;
#endif
default:
break;
}
return BaseWndProc(LISTBOX, wnd, msg, p1, p2);
}
static BOOL SelectionInWindow(DFWINDOW wnd, int sel)
{
return (wnd->wlines && sel >= wnd->wtop &&
sel < wnd->wtop+ClientHeight(wnd));
}
static void WriteSelection(DFWINDOW wnd, int sel,
int reverse, DFRECT *rc)
{
if (isVisible(wnd))
if (SelectionInWindow(wnd, sel))
WriteTextLine(wnd, rc, sel, reverse);
}
#ifdef INCLUDE_EXTENDEDSELECTIONS
/* ----- Test for extended selections in the listbox ----- */
static void TestExtended(DFWINDOW wnd, PARAM p2)
{
if (isMultiLine(wnd) && !wnd->AddMode &&
!((int) p2 & (LEFTSHIFT | RIGHTSHIFT))) {
if (wnd->SelectCount > 1) {
ClearAllSelections(wnd);
DfSendMessage(wnd, PAINT, 0, 0);
}
}
}
/* ----- Clear selections in the listbox ----- */
static void ClearAllSelections(DFWINDOW wnd)
{
if (isMultiLine(wnd) && wnd->SelectCount > 0) {
int sel;
for (sel = 0; sel < wnd->wlines; sel++)
ClearSelection(wnd, sel);
}
}
/* ----- Invert a selection in the listbox ----- */
static void FlipSelection(DFWINDOW wnd, int sel)
{
if (isMultiLine(wnd)) {
if (ItemSelected(wnd, sel))
ClearSelection(wnd, sel);
else
SetSelection(wnd, sel);
}
}
static int ExtendSelections(DFWINDOW wnd, int sel, int shift)
{
if (shift & (LEFTSHIFT | RIGHTSHIFT) &&
wnd->AnchorPoint != -1) {
int i = sel;
int j = wnd->AnchorPoint;
int rtn;
if (j > i)
swap(i,j);
rtn = i - j;
while (j <= i)
SetSelection(wnd, j++);
return rtn;
}
return 0;
}
static void SetSelection(DFWINDOW wnd, int sel)
{
if (isMultiLine(wnd) && !ItemSelected(wnd, sel)) {
char *lp = TextLine(wnd, sel);
*lp = LISTSELECTOR;
wnd->SelectCount++;
}
}
static void ClearSelection(DFWINDOW wnd, int sel)
{
if (isMultiLine(wnd) && ItemSelected(wnd, sel)) {
char *lp = TextLine(wnd, sel);
*lp = ' ';
--wnd->SelectCount;
}
}
BOOL ItemSelected(DFWINDOW wnd, int sel)
{
if (sel != -1 && isMultiLine(wnd) && sel < wnd->wlines) {
char *cp = TextLine(wnd, sel);
return (int)((*cp) & 255) == LISTSELECTOR;
}
return FALSE;
}
#endif
static void ChangeSelection(DFWINDOW wnd,int sel,int shift)
{
if (sel != wnd->selection) {
#ifdef INCLUDE_EXTENDEDSELECTIONS
if (isMultiLine(wnd)) {
int sels;
if (!wnd->AddMode)
ClearAllSelections(wnd);
sels = ExtendSelections(wnd, sel, shift);
if (sels > 1)
DfSendMessage(wnd, PAINT, 0, 0);
if (sels == 0 && !wnd->AddMode) {
ClearSelection(wnd, wnd->selection);
SetSelection(wnd, sel);
wnd->AnchorPoint = sel;
}
}
#endif
WriteSelection(wnd, wnd->selection, FALSE, NULL);
wnd->selection = sel;
WriteSelection(wnd, sel, TRUE, NULL);
}
}
/* EOF */

149
rosapps/lib/dflat32/lists.c Normal file
View file

@ -0,0 +1,149 @@
/* --------------- lists.c -------------- */
#include "dflat32/dflat.h"
/* ----- set focus to the next sibling ----- */
void SetNextFocus (void)
{
if (inFocus != NULL)
{
DFWINDOW wnd1 = inFocus, pwnd;
while (TRUE)
{
pwnd = GetParent(wnd1);
if (NextWindow(wnd1) != NULL)
wnd1 = NextWindow(wnd1);
else if (pwnd != NULL)
wnd1 = FirstWindow(pwnd);
if (wnd1 == NULL || wnd1 == inFocus)
{
wnd1 = pwnd;
break;
}
if (GetClass(wnd1) == STATUSBAR || GetClass(wnd1) == MENUBAR)
continue;
if (isVisible(wnd1))
break;
}
if (wnd1 != NULL)
{
while (wnd1->childfocus != NULL)
wnd1 = wnd1->childfocus;
if (wnd1->condition != ISCLOSING)
DfSendMessage(wnd1, SETFOCUS, TRUE, 0);
}
}
}
/* ----- set focus to the previous sibling ----- */
void SetPrevFocus(void)
{
if (inFocus != NULL)
{
DFWINDOW wnd1 = inFocus, pwnd;
while (TRUE)
{
pwnd = GetParent(wnd1);
if (PrevWindow(wnd1) != NULL)
wnd1 = PrevWindow(wnd1);
else if (pwnd != NULL)
wnd1 = LastWindow(pwnd);
if (wnd1 == NULL || wnd1 == inFocus)
{
wnd1 = pwnd;
break;
}
if (GetClass(wnd1) == STATUSBAR)
continue;
if (isVisible(wnd1))
break;
}
if (wnd1 != NULL)
{
while (wnd1->childfocus != NULL)
wnd1 = wnd1->childfocus;
if (wnd1->condition != ISCLOSING)
DfSendMessage(wnd1, SETFOCUS, TRUE, 0);
}
}
}
/* ------- move a window to the end of its parents list ----- */
void ReFocus(DFWINDOW wnd)
{
if (GetParent(wnd) != NULL)
{
RemoveWindow(wnd);
AppendWindow(wnd);
ReFocus(GetParent(wnd));
}
}
/* ---- remove a window from the linked list ---- */
void RemoveWindow(DFWINDOW wnd)
{
if (wnd != NULL)
{
DFWINDOW pwnd = GetParent(wnd);
if (PrevWindow(wnd) != NULL)
NextWindow(PrevWindow(wnd)) = NextWindow(wnd);
if (NextWindow(wnd) != NULL)
PrevWindow(NextWindow(wnd)) = PrevWindow(wnd);
if (pwnd != NULL)
{
if (wnd == FirstWindow(pwnd))
FirstWindow(pwnd) = NextWindow(wnd);
if (wnd == LastWindow(pwnd))
LastWindow(pwnd) = PrevWindow(wnd);
}
}
}
/* ---- append a window to the linked list ---- */
void AppendWindow(DFWINDOW wnd)
{
if (wnd != NULL)
{
DFWINDOW pwnd = GetParent(wnd);
if (pwnd != NULL)
{
if (FirstWindow(pwnd) == NULL)
{
FirstWindow(pwnd) = wnd;
LastWindow(pwnd) = wnd;
PrevWindow(wnd) = NULL;
}
else
{
NextWindow(LastWindow(pwnd)) = wnd;
PrevWindow(wnd) = LastWindow(pwnd);
LastWindow(pwnd) = wnd;
}
}
NextWindow(wnd) = NULL;
}
}
/*
* if document windows and statusbar or menubar get the focus,
* pass it on
*/
void SkipApplicationControls(void)
{
BOOL EmptyAppl = FALSE;
int ct = 0;
while (!EmptyAppl && inFocus != NULL)
{
DFCLASS cl = GetClass(inFocus);
if (cl == MENUBAR || cl == STATUSBAR)
{
SetPrevFocus();
EmptyAppl = (cl == MENUBAR && ct++);
}
else
break;
}
}
/* EOF */

75
rosapps/lib/dflat32/log.c Normal file
View file

@ -0,0 +1,75 @@
/* ------------ log .c ------------ */
#include "dflat32/dflat.h"
#ifdef INCLUDE_LOGGING
static char *message[] = {
#undef DFlatMsg
#define DFlatMsg(m) " " #m,
#include "dflat32/dflatmsg.h"
NULL
};
static FILE *logfile = NULL;
extern DBOX Log;
void LogMessages (DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
if (logfile != NULL && message[msg][0] != ' ')
fprintf(logfile,
"%-20.20s %-12.12s %-20.20s, %5.5ld, %5.5ld\n",
wnd ? (GetTitle(wnd) ? GetTitle(wnd) : "") : "",
wnd ? ClassNames[GetClass(wnd)] : "",
message[msg]+1, p1, p2);
}
static int LogProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
DFWINDOW cwnd = ControlWindow(&Log, ID_LOGLIST);
char **mn = message;
switch (msg) {
case INITIATE_DIALOG:
AddAttribute(cwnd, MULTILINE | VSCROLLBAR);
while (*mn) {
DfSendMessage(cwnd, ADDTEXT, (PARAM) (*mn), 0);
mn++;
}
DfSendMessage(cwnd, SHOW_WINDOW, 0, 0);
break;
case DFM_COMMAND:
if ((int) p1 == ID_OK) {
int item;
int tl = GetTextLines(cwnd);
for (item = 0; item < tl; item++)
if (ItemSelected(cwnd, item))
mn[item][0] = LISTSELECTOR;
}
break;
default:
break;
}
return DefaultWndProc(wnd, msg, p1, p2);
}
void MessageLog(DFWINDOW wnd)
{
if (DfDialogBox(wnd, &Log, TRUE, LogProc))
{
if (CheckBoxSetting(&Log, ID_LOGGING))
{
logfile = fopen("DFLAT.LOG", "wt");
SetCommandToggle(&MainMenu, ID_LOG);
}
else if (logfile != NULL)
{
fclose(logfile);
logfile = NULL;
ClearCommandToggle(&MainMenu, ID_LOG);
}
}
}
#endif
/* EOF */

View file

@ -0,0 +1,85 @@
/* ------------- menu.c ------------- */
#include "dflat32/dflat.h"
static struct PopDown *FindCmd(MBAR *mn, int cmd)
{
MENU *mnu = mn->PullDown;
while (mnu->Title != (void *)-1) {
struct PopDown *pd = mnu->Selections;
while (pd->SelectionTitle != NULL) {
if (pd->ActionId == cmd)
return pd;
pd++;
}
mnu++;
}
return NULL;
}
char *GetCommandText(MBAR *mn, int cmd)
{
struct PopDown *pd = FindCmd(mn, cmd);
if (pd != NULL)
return pd->SelectionTitle;
return NULL;
}
BOOL isCascadedCommand(MBAR *mn, int cmd)
{
struct PopDown *pd = FindCmd(mn, cmd);
if (pd != NULL)
return pd->Attrib & CASCADED;
return FALSE;
}
void ActivateCommand(MBAR *mn, int cmd)
{
struct PopDown *pd = FindCmd(mn, cmd);
if (pd != NULL)
pd->Attrib &= ~INACTIVE;
}
void DeactivateCommand(MBAR *mn, int cmd)
{
struct PopDown *pd = FindCmd(mn, cmd);
if (pd != NULL)
pd->Attrib |= INACTIVE;
}
BOOL isActive(MBAR *mn, int cmd)
{
struct PopDown *pd = FindCmd(mn, cmd);
if (pd != NULL)
return !(pd->Attrib & INACTIVE);
return FALSE;
}
BOOL GetCommandToggle(MBAR *mn, int cmd)
{
struct PopDown *pd = FindCmd(mn, cmd);
if (pd != NULL)
return (pd->Attrib & CHECKED) != 0;
return FALSE;
}
void SetCommandToggle(MBAR *mn, int cmd)
{
struct PopDown *pd = FindCmd(mn, cmd);
if (pd != NULL)
pd->Attrib |= CHECKED;
}
void ClearCommandToggle(MBAR *mn, int cmd)
{
struct PopDown *pd = FindCmd(mn, cmd);
if (pd != NULL)
pd->Attrib &= ~CHECKED;
}
void InvertCommandToggle(MBAR *mn, int cmd)
{
struct PopDown *pd = FindCmd(mn, cmd);
if (pd != NULL)
pd->Attrib ^= CHECKED;
}

View file

@ -0,0 +1,432 @@
/* ---------------- menubar.c ------------------ */
#include "dflat32/dflat.h"
static void reset_menubar(DFWINDOW);
static struct {
int x1, x2; /* position in menu bar */
char sc; /* shortcut key value */
} menu[10];
static int mctr;
MBAR *ActiveMenuBar;
static MENU *ActiveMenu;
static DFWINDOW mwnd;
static BOOL Selecting;
static DFWINDOW Cascaders[MAXCASCADES];
static int casc;
static DFWINDOW GetDocFocus(void);
/* ----------- SETFOCUS Message ----------- */
static int SetFocusMsg(DFWINDOW wnd, PARAM p1)
{
int rtn;
rtn = BaseWndProc(MENUBAR, wnd, SETFOCUS, p1, 0);
if (!(int)p1)
DfSendMessage(GetParent(wnd), ADDSTATUS, 0, 0);
return rtn;
}
/* --------- BUILDMENU Message --------- */
static void BuildMenuMsg(DFWINDOW wnd, PARAM p1)
{
int offset = 3;
reset_menubar(wnd);
mctr = 0;
ActiveMenuBar = (MBAR *) p1;
ActiveMenu = ActiveMenuBar->PullDown;
while (ActiveMenu->Title != NULL &&
ActiveMenu->Title != (void*)-1)
{
char *cp;
if (strlen(GetText(wnd)+offset) <
strlen(ActiveMenu->Title)+3)
break;
GetText(wnd) = DFrealloc(GetText(wnd),
strlen(GetText(wnd))+5);
memmove(GetText(wnd) + offset+4, GetText(wnd) + offset,
strlen(GetText(wnd))-offset+1);
CopyCommand(GetText(wnd)+offset,ActiveMenu->Title,FALSE,
wnd->WindowColors [STD_COLOR] [BG]);
menu[mctr].x1 = offset;
offset += strlen(ActiveMenu->Title) + (3+MSPACE);
menu[mctr].x2 = offset-MSPACE;
cp = strchr(ActiveMenu->Title, SHORTCUTCHAR);
if (cp)
menu[mctr].sc = tolower(*(cp+1));
mctr++;
ActiveMenu++;
}
ActiveMenu = ActiveMenuBar->PullDown;
}
/* ---------- PAINT Message ---------- */
static void PaintMsg(DFWINDOW wnd)
{
if (Selecting)
return;
if (wnd == inFocus)
DfSendMessage(GetParent(wnd), ADDSTATUS, 0, 0);
SetStandardColor(wnd);
wputs(wnd, GetText(wnd), 0, 0);
if (ActiveMenuBar == NULL)
return;
if (ActiveMenuBar->ActiveSelection != -1 &&
(wnd == inFocus || mwnd != NULL)) {
char *sel, *cp;
int offset, offset1;
sel = DFmalloc(200);
offset=menu[ActiveMenuBar->ActiveSelection].x1;
offset1=menu[ActiveMenuBar->ActiveSelection].x2;
GetText(wnd)[offset1] = '\0';
SetReverseColor(wnd);
memset(sel, '\0', 200);
strcpy(sel, GetText(wnd)+offset);
cp = strchr(sel, CHANGECOLOR);
if (cp != NULL)
*(cp + 2) = background | 0x80;
wputs(wnd, sel,
offset-ActiveMenuBar->ActiveSelection*4, 0);
GetText(wnd)[offset1] = ' ';
if (mwnd == NULL && wnd == inFocus) {
char *st = ActiveMenu
[ActiveMenuBar->ActiveSelection].StatusText;
if (st != NULL)
DfSendMessage(GetParent(wnd), ADDSTATUS,
(PARAM)st, 0);
}
free(sel);
}
}
/* ------------ KEYBOARD Message ------------- */
static void KeyboardMsg(DFWINDOW wnd, PARAM p1)
{
MENU *mnu;
int sel;
if (mwnd == NULL)
{
/* ----- search for menu bar shortcut keys ---- */
int c = tolower((int)p1);
int a = AltConvert((int)p1);
int j;
for (j = 0; j < mctr; j++) {
if ((inFocus == wnd && menu[j].sc == c) ||
(a && menu[j].sc == a)) {
DfSendMessage(wnd, SETFOCUS, TRUE, 0);
DfSendMessage(wnd, MB_SELECTION, j, 0);
return;
}
}
}
/* -------- search for accelerator keys -------- */
mnu = ActiveMenu;
while (mnu->Title != (void *)-1) {
struct PopDown *pd = mnu->Selections;
if (mnu->PrepMenu)
(*(mnu->PrepMenu))(GetDocFocus(), mnu);
while (pd->SelectionTitle != NULL) {
if (pd->Accelerator == (int) p1) {
if (pd->Attrib & INACTIVE)
beep();
else {
if (pd->Attrib & TOGGLE)
pd->Attrib ^= CHECKED;
DfSendMessage(GetDocFocus(),
SETFOCUS, TRUE, 0);
DfPostMessage(GetParent(wnd),
DFM_COMMAND, pd->ActionId, 0);
}
return;
}
pd++;
}
mnu++;
}
switch ((int)p1)
{
case F1:
if (ActiveMenu == NULL || ActiveMenuBar == NULL)
break;
sel = ActiveMenuBar->ActiveSelection;
if (sel == -1)
{
BaseWndProc(MENUBAR, wnd, KEYBOARD, F1, 0);
return;
}
mnu = ActiveMenu+sel;
if (mwnd == NULL ||
mnu->Selections[0].SelectionTitle == NULL)
{
DisplayHelp(wnd,mnu->Title+1);
return;
}
break;
case '\r':
if (mwnd == NULL &&
ActiveMenuBar->ActiveSelection != -1)
DfSendMessage(wnd, MB_SELECTION,
ActiveMenuBar->ActiveSelection, 0);
break;
case F10:
if (wnd != inFocus && mwnd == NULL) {
DfSendMessage(wnd, SETFOCUS, TRUE, 0);
if ( ActiveMenuBar->ActiveSelection == -1)
ActiveMenuBar->ActiveSelection = 0;
DfSendMessage(wnd, PAINT, 0, 0);
break;
}
/* ------- fall through ------- */
case ESC:
if (inFocus == wnd && mwnd == NULL) {
ActiveMenuBar->ActiveSelection = -1;
DfSendMessage(GetDocFocus(),SETFOCUS,TRUE,0);
DfSendMessage(wnd, PAINT, 0, 0);
}
break;
case FWD:
ActiveMenuBar->ActiveSelection++;
if (ActiveMenuBar->ActiveSelection == mctr)
ActiveMenuBar->ActiveSelection = 0;
if (mwnd != NULL)
DfSendMessage(wnd, MB_SELECTION,
ActiveMenuBar->ActiveSelection, 0);
else
DfSendMessage(wnd, PAINT, 0, 0);
break;
case BS:
if (ActiveMenuBar->ActiveSelection == 0 ||
ActiveMenuBar->ActiveSelection == -1)
ActiveMenuBar->ActiveSelection = mctr;
--ActiveMenuBar->ActiveSelection;
if (mwnd != NULL)
DfSendMessage(wnd, MB_SELECTION,
ActiveMenuBar->ActiveSelection, 0);
else
DfSendMessage(wnd, PAINT, 0, 0);
break;
default:
break;
}
}
/* --------------- LEFT_BUTTON Message ---------- */
static void LeftButtonMsg(DFWINDOW wnd, PARAM p1)
{
int i;
int mx = (int) p1 - GetLeft(wnd);
/* --- compute the selection that the left button hit --- */
for (i = 0; i < mctr; i++)
if (mx >= menu[i].x1-4*i &&
mx <= menu[i].x2-4*i-5)
break;
if (i < mctr)
if (i != ActiveMenuBar->ActiveSelection || mwnd == NULL)
DfSendMessage(wnd, MB_SELECTION, i, 0);
}
/* -------------- MB_SELECTION Message -------------- */
static void SelectionMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
int wd, mx, my;
MENU *mnu;
if (!p2)
{
ActiveMenuBar->ActiveSelection = -1;
DfSendMessage(wnd, PAINT, 0, 0);
}
Selecting = TRUE;
mnu = ActiveMenu+(int)p1;
if (mnu->PrepMenu != NULL)
(*(mnu->PrepMenu))(GetDocFocus(), mnu);
wd = MenuWidth(mnu->Selections);
if (p2)
{
int brd = GetRight(wnd);
mx = GetLeft(mwnd) + WindowWidth(mwnd) - 1;
if (mx + wd > brd)
mx = brd - wd;
my = GetTop(mwnd) + mwnd->selection;
}
else
{
int offset = menu[(int)p1].x1 - 4 * (int)p1;
if (mwnd != NULL)
DfSendMessage(mwnd, CLOSE_WINDOW, 0, 0);
ActiveMenuBar->ActiveSelection = (int) p1;
if (offset > WindowWidth(wnd)-wd)
offset = WindowWidth(wnd)-wd;
mx = GetLeft(wnd)+offset;
my = GetTop(wnd)+1;
}
mwnd = DfCreateWindow(POPDOWNMENU, NULL,
mx, my,
MenuHeight(mnu->Selections),
wd,
NULL,
wnd,
NULL,
SHADOW);
if (!p2)
{
Selecting = FALSE;
DfSendMessage(wnd, PAINT, 0, 0);
Selecting = TRUE;
}
if (mnu->Selections[0].SelectionTitle != NULL)
{
DfSendMessage(mwnd, BUILD_SELECTIONS, (PARAM) mnu, 0);
DfSendMessage(mwnd, SETFOCUS, TRUE, 0);
DfSendMessage(mwnd, SHOW_WINDOW, 0, 0);
}
Selecting = FALSE;
}
/* --------- COMMAND Message ---------- */
static void CommandMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
if (p1 == ID_HELP)
{
BaseWndProc(MENUBAR, wnd, DFM_COMMAND, p1, p2);
return;
}
if (isCascadedCommand(ActiveMenuBar, (int)p1))
{
/* find the cascaded menu based on command id in p1 */
MENU *mnu = ActiveMenu+mctr;
while (mnu->Title != (void *)-1) {
if (mnu->CascadeId == (int) p1) {
if (casc < MAXCASCADES) {
Cascaders[casc++] = mwnd;
DfSendMessage(wnd, MB_SELECTION,
(PARAM)(mnu-ActiveMenu), TRUE);
}
break;
}
mnu++;
}
}
else {
if (mwnd != NULL)
DfSendMessage(mwnd, CLOSE_WINDOW, 0, 0);
DfSendMessage(GetDocFocus(), SETFOCUS, TRUE, 0);
DfPostMessage(GetParent(wnd), DFM_COMMAND, p1, p2);
}
}
/* --------------- CLOSE_POPDOWN Message --------------- */
static void ClosePopdownMsg(DFWINDOW wnd)
{
if (casc > 0)
DfSendMessage(Cascaders[--casc], CLOSE_WINDOW, 0, 0);
else
{
mwnd = NULL;
ActiveMenuBar->ActiveSelection = -1;
if (!Selecting)
{
DfSendMessage(GetDocFocus(), SETFOCUS, TRUE, 0);
DfSendMessage(wnd, PAINT, 0, 0);
}
}
}
/* ---------------- CLOSE_WINDOW Message --------------- */
static void CloseWindowMsg(DFWINDOW wnd)
{
if (GetText(wnd) != NULL)
{
free(GetText(wnd));
GetText(wnd) = NULL;
}
mctr = 0;
ActiveMenuBar->ActiveSelection = -1;
ActiveMenu = NULL;
ActiveMenuBar = NULL;
}
/* --- Window processing module for MENUBAR window class --- */
int MenuBarProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
int rtn;
switch (msg) {
case CREATE_WINDOW:
reset_menubar(wnd);
break;
case SETFOCUS:
return SetFocusMsg(wnd, p1);
case BUILDMENU:
BuildMenuMsg(wnd, p1);
break;
case PAINT:
if (!isVisible(wnd) || GetText(wnd) == NULL)
break;
PaintMsg(wnd);
return FALSE;
case BORDER:
if (mwnd == NULL)
DfSendMessage(wnd, PAINT, 0, 0);
return TRUE;
case KEYBOARD:
KeyboardMsg(wnd, p1);
return TRUE;
case LEFT_BUTTON:
LeftButtonMsg(wnd, p1);
return TRUE;
case MB_SELECTION:
SelectionMsg(wnd, p1, p2);
break;
case DFM_COMMAND:
CommandMsg(wnd, p1, p2);
return TRUE;
case INSIDE_WINDOW:
return InsideRect(p1, p2, WindowRect(wnd));
case CLOSE_POPDOWN:
ClosePopdownMsg(wnd);
return TRUE;
case CLOSE_WINDOW:
CloseWindowMsg(wnd);
rtn = BaseWndProc(MENUBAR, wnd, msg, p1, p2);
return rtn;
default:
break;
}
return BaseWndProc(MENUBAR, wnd, msg, p1, p2);
}
/* ------------- reset the MENUBAR -------------- */
static void reset_menubar(DFWINDOW wnd)
{
GetText(wnd) = DFrealloc(GetText(wnd), DfGetScreenWidth()+5);
memset(GetText(wnd), ' ', DfGetScreenWidth());
*(GetText(wnd)+WindowWidth(wnd)) = '\0';
}
static DFWINDOW GetDocFocus(void)
{
DFWINDOW wnd = ApplicationWindow;
if (wnd != NULL)
{
wnd = LastWindow(wnd);
while (wnd != NULL &&
(GetClass(wnd) == MENUBAR ||
GetClass(wnd) == STATUSBAR))
wnd = PrevWindow(wnd);
if (wnd != NULL)
{
while (wnd->childfocus != NULL)
wnd = wnd->childfocus;
}
}
return wnd ? wnd : ApplicationWindow;
}
/* EOF */

126
rosapps/lib/dflat32/menus.c Normal file
View file

@ -0,0 +1,126 @@
/* -------------- menus.c ------------- */
#include "dflat32/dflat.h"
/* --------------------- the main menu --------------------- */
DEFMENU(MainMenu)
/* --------------- the File popdown menu ----------------*/
POPDOWN( "~File", PrepFileMenu, "Read/write/print files. Go to DOS" )
SELECTION( "~New", ID_NEW, 0, 0 )
SELECTION( "~Open...", ID_OPEN, 0, 0 )
SEPARATOR
SELECTION( "~Save", ID_SAVE, ALT_S, INACTIVE)
SELECTION( "Save ~as...", ID_SAVEAS, 0, INACTIVE)
SELECTION( "D~elete", ID_DELETEFILE, 0, INACTIVE)
SEPARATOR
SELECTION( "~Print", ID_PRINT, 0, INACTIVE)
SELECTION( "P~rinter setup...", ID_PRINTSETUP, 0, 0 )
SEPARATOR
SELECTION( "~DOS", ID_DOS, 0, 0 )
SELECTION( "E~xit", ID_EXIT, ALT_X, 0 )
ENDPOPDOWN
/* --------------- the Edit popdown menu ----------------*/
POPDOWN( "~Edit", PrepEditMenu, "Clipboard, delete text, paragraph" )
SELECTION( "~Undo", ID_UNDO, ALT_BS, INACTIVE)
SEPARATOR
SELECTION( "Cu~t", ID_CUT, SHIFT_DEL, INACTIVE)
SELECTION( "~Copy", ID_COPY, CTRL_INS, INACTIVE)
SELECTION( "~Paste", ID_PASTE, SHIFT_INS, INACTIVE)
SEPARATOR
SELECTION( "Cl~ear", ID_CLEAR, 0, INACTIVE)
SELECTION( "~Delete", ID_DELETETEXT, DEL, INACTIVE)
SEPARATOR
SELECTION( "Pa~ragraph", ID_PARAGRAPH, ALT_P,INACTIVE)
ENDPOPDOWN
/* --------------- the Search popdown menu ----------------*/
POPDOWN( "~Search", PrepSearchMenu, "Search and replace" )
SELECTION( "~Search...", ID_SEARCH, 0, INACTIVE)
SELECTION( "~Replace...",ID_REPLACE, 0, INACTIVE)
SELECTION( "~Next", ID_SEARCHNEXT, F3, INACTIVE)
ENDPOPDOWN
/* ------------ the Utilities popdown menu --------------- */
POPDOWN( "~Utilities", NULL, "Utility programs" )
SELECTION( "~Calendar", ID_CALENDAR, 0, 0)
// SELECTION( "~Bar chart", ID_BARCHART, 0, 0)
ENDPOPDOWN
/* ------------- the Options popdown menu ---------------*/
POPDOWN( "~Options", NULL, "Editor and display options" )
SELECTION( "~Display...", ID_DISPLAY, 0, 0 )
SEPARATOR
#ifdef INCLUDE_LOGGING
SELECTION( "~Log messages", ID_LOG, ALT_L, 0 )
SEPARATOR
#endif
SELECTION( "~Insert", ID_INSERT, INS, TOGGLE)
SELECTION( "~Word wrap", ID_WRAP, 0, TOGGLE)
SELECTION( "~Tabs ( )", ID_TABS, 0, CASCADED)
SEPARATOR
SELECTION( "~Save options", ID_SAVEOPTIONS, 0, 0 )
ENDPOPDOWN
/* --------------- the Window popdown menu --------------*/
POPDOWN( "~Window", PrepWindowMenu, "Select/close document windows" )
SELECTION( NULL, ID_CLOSEALL, 0, 0)
SEPARATOR
SELECTION( NULL, ID_WINDOW, 0, 0 )
SELECTION( NULL, ID_WINDOW, 0, 0 )
SELECTION( NULL, ID_WINDOW, 0, 0 )
SELECTION( NULL, ID_WINDOW, 0, 0 )
SELECTION( NULL, ID_WINDOW, 0, 0 )
SELECTION( NULL, ID_WINDOW, 0, 0 )
SELECTION( NULL, ID_WINDOW, 0, 0 )
SELECTION( NULL, ID_WINDOW, 0, 0 )
SELECTION( NULL, ID_WINDOW, 0, 0 )
SELECTION( NULL, ID_WINDOW, 0, 0 )
SELECTION( NULL, ID_WINDOW, 0, 0 )
SELECTION( "~More Windows...", ID_MOREWINDOWS, 0, 0)
SELECTION( NULL, ID_WINDOW, 0, 0 )
ENDPOPDOWN
/* --------------- the Help popdown menu ----------------*/
POPDOWN( "~Help", NULL, "Get help" )
SELECTION( "~Help for help...", ID_HELPHELP, 0, 0 )
SELECTION( "~Extended help...", ID_EXTHELP, 0, 0 )
SELECTION( "~Keys help...", ID_KEYSHELP, 0, 0 )
SELECTION( "Help ~index...", ID_HELPINDEX, 0, 0 )
SEPARATOR
SELECTION( "~About...", ID_ABOUT, 0, 0 )
#ifdef TESTING_DFLAT
SEPARATOR
SELECTION( "~Reload help database",ID_LOADHELP,0, 0 )
#endif
ENDPOPDOWN
/* ----- cascaded pulldown from Tabs... above ----- */
CASCADED_POPDOWN( ID_TABS, NULL )
SELECTION( "~2 tab stops", ID_TAB2, 0, 0)
SELECTION( "~4 tab stops", ID_TAB4, 0, 0)
SELECTION( "~6 tab stops", ID_TAB6, 0, 0)
SELECTION( "~8 tab stops", ID_TAB8, 0, 0)
ENDPOPDOWN
ENDMENU
/* ------------- the System Menu --------------------- */
DEFMENU(SystemMenu)
POPDOWN("System Menu", NULL, NULL)
#ifdef INCLUDE_RESTORE
SELECTION("~Restore", ID_SYSRESTORE, 0, 0 )
#endif
SELECTION("~Move", ID_SYSMOVE, 0, 0 )
SELECTION("~Size", ID_SYSSIZE, 0, 0 )
#ifdef INCLUDE_MINIMIZE
SELECTION("Mi~nimize", ID_SYSMINIMIZE, 0, 0 )
#endif
#ifdef INCLUDE_MAXIMIZE
SELECTION("Ma~ximize", ID_SYSMAXIMIZE, 0, 0 )
#endif
SEPARATOR
SELECTION("~Close", ID_SYSCLOSE, CTRL_F4, 0 )
ENDPOPDOWN
ENDMENU

View file

@ -1,13 +1,7 @@
/* --------- 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
*/
/* --------- message.c ---------- */
#include <dflat32/dflat.h>
#include <dflat32/system.h>
#include "dflat32/dflat.h"
#include "dflat32/system.h"
static int handshaking = 0;

View file

@ -0,0 +1,216 @@
/* ------------------ msgbox.c ------------------ */
#include "dflat32/dflat.h"
extern DBOX MsgBox;
extern DBOX InputBoxDB;
DFWINDOW CancelWnd;
static int ReturnValue;
int MessageBoxProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
switch (msg) {
case CREATE_WINDOW:
GetClass(wnd) = MESSAGEBOX;
InitWindowColors(wnd);
ClearAttribute(wnd, CONTROLBOX);
break;
case KEYBOARD:
if (p1 == '\r' || p1 == ESC)
ReturnValue = (int)p1;
break;
default:
break;
}
return BaseWndProc(MESSAGEBOX, wnd, msg, p1, p2);
}
int YesNoBoxProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
switch (msg) {
case CREATE_WINDOW:
GetClass(wnd) = MESSAGEBOX;
InitWindowColors(wnd);
ClearAttribute(wnd, CONTROLBOX);
break;
case KEYBOARD: {
int c = tolower((int)p1);
if (c == 'y')
DfSendMessage(wnd, DFM_COMMAND, ID_OK, 0);
else if (c == 'n')
DfSendMessage(wnd, DFM_COMMAND, ID_CANCEL, 0);
break;
}
default:
break;
}
return BaseWndProc(MESSAGEBOX, wnd, msg, p1, p2);
}
int ErrorBoxProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
switch (msg) {
case CREATE_WINDOW:
GetClass(wnd) = ERRORBOX;
InitWindowColors(wnd);
break;
case KEYBOARD:
if (p1 == '\r' || p1 == ESC)
ReturnValue = (int)p1;
break;
default:
break;
}
return BaseWndProc(ERRORBOX, wnd, msg, p1, p2);
}
int CancelBoxProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
switch (msg) {
case CREATE_WINDOW:
CancelWnd = wnd;
DfSendMessage(wnd, CAPTURE_MOUSE, 0, 0);
DfSendMessage(wnd, CAPTURE_KEYBOARD, 0, 0);
break;
case DFM_COMMAND:
if ((int) p1 == ID_CANCEL && (int) p2 == 0)
DfSendMessage(GetParent(wnd), msg, p1, p2);
return TRUE;
case CLOSE_WINDOW:
CancelWnd = NULL;
DfSendMessage(wnd, RELEASE_MOUSE, 0, 0);
DfSendMessage(wnd, RELEASE_KEYBOARD, 0, 0);
p1 = TRUE;
break;
default:
break;
}
return BaseWndProc(MESSAGEBOX, wnd, msg, p1, p2);
}
void CloseCancelBox(void)
{
if (CancelWnd != NULL)
DfSendMessage(CancelWnd, CLOSE_WINDOW, 0, 0);
}
static char *InputText;
static int TextLength;
int InputBoxProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
int rtn;
switch (msg) {
case CREATE_WINDOW:
rtn = DefaultWndProc(wnd, msg, p1, p2);
DfSendMessage(ControlWindow(&InputBoxDB,ID_INPUTTEXT),
SETTEXTLENGTH, TextLength, 0);
return rtn;
case DFM_COMMAND:
if ((int) p1 == ID_OK && (int) p2 == 0)
GetItemText(wnd, ID_INPUTTEXT,
InputText, TextLength);
break;
default:
break;
}
return DefaultWndProc(wnd, msg, p1, p2);
}
BOOL InputBox(DFWINDOW wnd,char *ttl,char *msg,char *text,int len)
{
InputText = text;
TextLength = len;
InputBoxDB.dwnd.title = ttl;
InputBoxDB.dwnd.w = 4 +
max(20, max(len, max((int)strlen(ttl), (int)strlen(msg))));
InputBoxDB.ctl[1].dwnd.x = (InputBoxDB.dwnd.w-2-len)/2;
InputBoxDB.ctl[0].dwnd.w = strlen(msg);
InputBoxDB.ctl[0].itext = msg;
InputBoxDB.ctl[1].dwnd.w = len;
InputBoxDB.ctl[2].dwnd.x = (InputBoxDB.dwnd.w - 20) / 2;
InputBoxDB.ctl[3].dwnd.x = InputBoxDB.ctl[2].dwnd.x + 10;
InputBoxDB.ctl[2].isetting = ON;
InputBoxDB.ctl[3].isetting = ON;
return DfDialogBox(wnd, &InputBoxDB, TRUE, InputBoxProc);
}
BOOL GenericMessage(DFWINDOW wnd,char *ttl,char *msg,int buttonct,
int (*wndproc)(struct window *,enum messages,PARAM,PARAM),
char *b1, char *b2, int c1, int c2, int isModal)
{
BOOL rtn;
MsgBox.dwnd.title = ttl;
MsgBox.ctl[0].dwnd.h = MsgHeight(msg);
if (ttl)
MsgBox.ctl[0].dwnd.w = max(max(MsgWidth(msg),
(int)(buttonct*8 + buttonct + 2)), (int)strlen(ttl)+2);
else
MsgBox.ctl[0].dwnd.w = max(MsgWidth(msg), (int)(buttonct*8 + buttonct + 2));
MsgBox.dwnd.h = MsgBox.ctl[0].dwnd.h+6;
MsgBox.dwnd.w = MsgBox.ctl[0].dwnd.w+4;
if (buttonct == 1)
MsgBox.ctl[1].dwnd.x = (MsgBox.dwnd.w - 10) / 2;
else {
MsgBox.ctl[1].dwnd.x = (MsgBox.dwnd.w - 20) / 2;
MsgBox.ctl[2].dwnd.x = MsgBox.ctl[1].dwnd.x + 10;
MsgBox.ctl[2].class = BUTTON;
}
MsgBox.ctl[1].dwnd.y = MsgBox.dwnd.h - 4;
MsgBox.ctl[2].dwnd.y = MsgBox.dwnd.h - 4;
MsgBox.ctl[0].itext = msg;
MsgBox.ctl[1].itext = b1;
MsgBox.ctl[2].itext = b2;
MsgBox.ctl[1].command = c1;
MsgBox.ctl[2].command = c2;
MsgBox.ctl[1].isetting = ON;
MsgBox.ctl[2].isetting = ON;
rtn = DfDialogBox(wnd, &MsgBox, isModal, wndproc);
MsgBox.ctl[2].class = 0;
return rtn;
}
DFWINDOW MomentaryMessage(char *msg)
{
DFWINDOW wnd = DfCreateWindow(
TEXTBOX,
NULL,
-1,-1,MsgHeight(msg)+2,MsgWidth(msg)+2,
NULL,NULL,NULL,
HASBORDER | SHADOW | SAVESELF);
DfSendMessage(wnd, SETTEXT, (PARAM) msg, 0);
WindowClientColor(wnd, WHITE, GREEN);
WindowFrameColor(wnd, WHITE, GREEN);
DfSendMessage (wnd, SHOW_WINDOW, 0, 0);
return wnd;
}
int MsgHeight(char *msg)
{
int h = 1;
while ((msg = strchr(msg, '\n')) != NULL)
{
h++;
msg++;
}
return min(h, DfGetScreenHeight ()-10);
}
int MsgWidth(char *msg)
{
int w = 0;
char *cp = msg;
while ((cp = strchr(msg, '\n')) != NULL)
{
w = max(w, (int) (cp-msg));
msg = cp+1;
}
return min(max((int)strlen(msg), (int)w), DfGetScreenWidth()-10);
}
/* EOF */

1085
rosapps/lib/dflat32/normal.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,284 @@
/* -------------- pictbox.c -------------- */
#include "dflat32/dflat.h"
typedef struct {
enum VectTypes vt;
DFRECT rc;
} VECT;
unsigned char CharInWnd[] = "ijڿÙÀÅôÁÂ";
unsigned char VectCvt[3][11][2][4] = {
{ /* --- first character in collision vector --- */
/* ( drawing Ä ) ( drawing ³ ) */
{{"ÄÄÄ"}, {"ÚÃÀ"}},
{{"Ú¿"}, {"³³³"}},
{{"ÚÂÂ"}, {"ÚÃÃ"}},
{{"¿¿¿"}, {"¿¿¿"}},
{{"ÙÙÙ"}, {"ÙÙÙ"}},
{{"ÀÁÁ"}, {"ÃÃÀ"}},
{{"ÅÅÅ"}, {"ÅÅÅ"}},
{{"ÃÅÅ"}, {"ÃÃÃ"}},
{{"´´´"}, {"´´´"}},
{{"ÁÁÁ"}, {"ÁÁÁ"}},
{{"ÂÂÂ"}, {"ÂÅÅ"}} },
{ /* --- middle character in collision vector --- */
/* ( drawing Ä ) ( drawing ³ ) */
{{"ÄÄÄ"}, {"ÂÅÁ"}},
{{"ÃÅ´"}, {"³³³"}},
{{"ÚÚÚ"}, {"ÚÚÚ"}},
{{"¿¿¿"}, {"¿¿¿"}},
{{"ÙÙÙ"}, {"ÙÙÙ"}},
{{"ÀÀÀ"}, {"ÀÀÀ"}},
{{"ÅÅÅ"}, {"ÅÅÅ"}},
{{"ÃÃÃ"}, {"ÃÃÃ"}},
{{"ÅÅ´"}, {"´´´"}},
{{"ÁÁÁ"}, {"ÅÅÁ"}},
{{"ÂÂÂ"}, {"ÂÂÂ"}} },
{ /* --- last character in collision vector --- */
/* ( drawing Ä ) ( drawing ³ ) */
{{"ÄÄÄ"}, {"¿´Ù"}},
{{"ÀÁÙ"}, {"³³³"}},
{{"ÚÚÚ"}, {"ÚÚÚ"}},
{{"¿"}, {"¿´´"}},
{{"ÁÁÙ"}, {"´´Ù"}},
{{"ÀÀÀ"}, {"ÀÀÀ"}},
{{"ÅÅÅ"}, {"ÅÅÅ"}},
{{"ÃÃÃ"}, {"ÃÃÃ"}},
{{"ÅÅ´"}, {"´´´"}},
{{"ÁÁÁ"}, {"ÅÅÁ"}},
{{"ÂÂÂ"}, {"ÂÂÂ"}} }
};
/* -- compute whether character is first, middle, or last -- */
static int FindVector(DFWINDOW wnd, DFRECT rc, int x, int y)
{
DFRECT rcc;
VECT *vc = wnd->VectorList;
int i, coll = -1;
for (i = 0; i < wnd->VectorCount; i++) {
if ((vc+i)->vt == VECTOR) {
rcc = (vc+i)->rc;
/* --- skip the colliding vector --- */
if (rcc.lf == rc.lf && rcc.rt == rc.rt &&
rcc.tp == rc.tp && rc.bt == rcc.bt)
continue;
if (rcc.tp == rcc.bt) {
/* ---- horizontal vector,
see if character is in it --- */
if (rc.lf+x >= rcc.lf && rc.lf+x <= rcc.rt &&
rc.tp+y == rcc.tp) {
/* --- it is --- */
if (rc.lf+x == rcc.lf)
coll = 0;
else if (rc.lf+x == rcc.rt)
coll = 2;
else
coll = 1;
}
}
else {
/* ---- vertical vector,
see if character is in it --- */
if (rc.tp+y >= rcc.tp && rc.tp+y <= rcc.bt &&
rc.lf+x == rcc.lf) {
/* --- it is --- */
if (rc.tp+y == rcc.tp)
coll = 0;
else if (rc.tp+y == rcc.bt)
coll = 2;
else
coll = 1;
}
}
}
}
return coll;
}
static void PaintVector(DFWINDOW wnd, DFRECT rc)
{
int i, xi, yi, len;
unsigned int ch, nc;
unsigned int newch;
static int cw, fml, vertvect, coll;
if (rc.rt == rc.lf) {
/* ------ vertical vector ------- */
nc = '³';
vertvect = 1;
len = rc.bt-rc.tp+1;
}
else {
/* ------ horizontal vector ------- */
nc = 'Ä';
vertvect = 0;
len = rc.rt-rc.lf+1;
}
for (i = 0; i < len; i++) {
newch = nc;
xi = yi = 0;
if (vertvect)
yi = i;
else
xi = i;
ch = videochar(GetClientLeft(wnd)+rc.lf+xi,
GetClientTop(wnd)+rc.tp+yi);
for (cw = 0; cw < sizeof(CharInWnd); cw++) {
if (ch == CharInWnd[cw]) {
/* ---- hit another vector character ---- */
if ((coll=FindVector(wnd, rc, xi, yi)) != -1) {
/* compute first/middle/last subscript */
if (i == len-1)
fml = 2;
else if (i == 0)
fml = 0;
else
fml = 1;
newch = VectCvt[coll][cw][vertvect][fml];
}
}
}
PutWindowChar(wnd, newch, rc.lf+xi, rc.tp+yi);
}
}
static void PaintBar(DFWINDOW wnd, DFRECT rc, enum VectTypes vt)
{
int i, vertbar, len;
unsigned int tys[] = {219, 178, 177, 176};
/* unsigned int tys[] = {'Û', '²', '±', '°'};
*/
unsigned int nc = tys[vt-1];
if (rc.rt == rc.lf) {
/* ------ vertical bar ------- */
vertbar = 1;
len = rc.bt-rc.tp+1;
}
else {
/* ------ horizontal bar ------- */
vertbar = 0;
len = rc.rt-rc.lf+1;
}
for (i = 0; i < len; i++) {
int xi = 0, yi = 0;
if (vertbar)
yi = i;
else
xi = i;
PutWindowChar(wnd, nc, rc.lf+xi, rc.tp+yi);
}
}
static void PaintMsg(DFWINDOW wnd)
{
int i;
VECT *vc = wnd->VectorList;
for (i = 0; i < wnd->VectorCount; i++) {
if (vc->vt == VECTOR)
PaintVector(wnd, vc->rc);
else
PaintBar(wnd, vc->rc, vc->vt);
vc++;
}
}
static void DrawVectorMsg(DFWINDOW wnd,PARAM p1,enum VectTypes vt)
{
if (p1) {
VECT vc;
wnd->VectorList = DFrealloc(wnd->VectorList,
sizeof(VECT) * (wnd->VectorCount + 1));
vc.vt = vt;
vc.rc = *(DFRECT *)p1;
*(((VECT *)(wnd->VectorList))+wnd->VectorCount)=vc;
wnd->VectorCount++;
}
}
static void DrawBoxMsg(DFWINDOW wnd, PARAM p1)
{
if (p1) {
DFRECT rc = *(DFRECT *)p1;
rc.bt = rc.tp;
DfSendMessage(wnd, DRAWVECTOR, (PARAM) &rc, TRUE);
rc = *(DFRECT *)p1;
rc.lf = rc.rt;
DfSendMessage(wnd, DRAWVECTOR, (PARAM) &rc, FALSE);
rc = *(DFRECT *)p1;
rc.tp = rc.bt;
DfSendMessage(wnd, DRAWVECTOR, (PARAM) &rc, TRUE);
rc = *(DFRECT *)p1;
rc.rt = rc.lf;
DfSendMessage(wnd, DRAWVECTOR, (PARAM) &rc, FALSE);
}
}
int PictureProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
switch (msg) {
case PAINT:
BaseWndProc(PICTUREBOX, wnd, msg, p1, p2);
PaintMsg(wnd);
return TRUE;
case DRAWVECTOR:
DrawVectorMsg(wnd, p1, VECTOR);
return TRUE;
case DRAWBOX:
DrawBoxMsg(wnd, p1);
return TRUE;
case DRAWBAR:
DrawVectorMsg(wnd, p1, (enum VectTypes)p2);
return TRUE;
case CLOSE_WINDOW:
if (wnd->VectorList != NULL)
free(wnd->VectorList);
break;
default:
break;
}
return BaseWndProc(PICTUREBOX, wnd, msg, p1, p2);
}
static DFRECT PictureRect(int x, int y, int len, int hv)
{
DFRECT rc;
rc.lf = rc.rt = x;
rc.tp = rc.bt = y;
if (hv)
/* ---- horizontal vector ---- */
rc.rt += len-1;
else
/* ---- vertical vector ---- */
rc.bt += len-1;
return rc;
}
void DrawVector(DFWINDOW wnd, int x, int y, int len, int hv)
{
DFRECT rc = PictureRect(x,y,len,hv);
DfSendMessage(wnd, DRAWVECTOR, (PARAM) &rc, 0);
}
void DrawBox(DFWINDOW wnd, int x, int y, int ht, int wd)
{
DFRECT rc;
rc.lf = x;
rc.tp = y;
rc.rt = x+wd-1;
rc.bt = y+ht-1;
DfSendMessage(wnd, DRAWBOX, (PARAM) &rc, 0);
}
void DrawBar(DFWINDOW wnd,enum VectTypes vt,
int x,int y,int len,int hv)
{
DFRECT rc = PictureRect(x,y,len,hv);
DfSendMessage(wnd, DRAWBAR, (PARAM) &rc, (PARAM) vt);
}
/* EOF */

View file

@ -0,0 +1,396 @@
/* ------------- popdown.c ----------- */
#include "dflat32/dflat.h"
static int SelectionWidth(struct PopDown *);
static int py = -1;
/* ------------ CREATE_WINDOW Message ------------- */
static int CreateWindowMsg(DFWINDOW wnd)
{
int rtn, adj;
ClearAttribute (wnd,
HASTITLEBAR |
VSCROLLBAR |
MOVEABLE |
SIZEABLE |
HSCROLLBAR);
/* ------ adjust to keep popdown on screen ----- */
adj = DfGetScreenHeight()-1-wnd->rc.bt;
if (adj < 0)
{
wnd->rc.tp += adj;
wnd->rc.bt += adj;
}
adj = DfGetScreenWidth()-1-wnd->rc.rt;
if (adj < 0)
{
wnd->rc.lf += adj;
wnd->rc.rt += adj;
}
rtn = BaseWndProc(POPDOWNMENU, wnd, CREATE_WINDOW, 0, 0);
DfSendMessage(wnd, CAPTURE_MOUSE, 0, 0);
DfSendMessage(wnd, CAPTURE_KEYBOARD, 0, 0);
DfSendMessage(NULL, SAVE_CURSOR, 0, 0);
DfSendMessage(NULL, HIDE_CURSOR, 0, 0);
wnd->oldFocus = inFocus;
inFocus = wnd;
return rtn;
}
/* --------- LEFT_BUTTON Message --------- */
static void LeftButtonMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
int my = (int) p2 - GetTop(wnd);
if (InsideRect(p1, p2, ClientRect(wnd))) {
if (my != py) {
DfSendMessage(wnd, LB_SELECTION,
(PARAM) wnd->wtop+my-1, TRUE);
py = my;
}
}
else if ((int)p2 == GetTop(GetParent(wnd)))
if (GetClass(GetParent(wnd)) == MENUBAR)
DfPostMessage(GetParent(wnd), LEFT_BUTTON, p1, p2);
}
/* -------- BUTTON_RELEASED Message -------- */
static BOOL ButtonReleasedMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
py = -1;
if (InsideRect((int)p1, (int)p2, ClientRect(wnd))) {
int sel = (int)p2 - GetClientTop(wnd);
if (*TextLine(wnd, sel) != LINE)
DfSendMessage(wnd, LB_CHOOSE, wnd->selection, 0);
}
else {
DFWINDOW pwnd = GetParent(wnd);
if (GetClass(pwnd) == MENUBAR && (int)p2==GetTop(pwnd))
return FALSE;
if ((int)p1 == GetLeft(pwnd)+2)
return FALSE;
DfSendMessage(wnd, CLOSE_WINDOW, 0, 0);
return TRUE;
}
return FALSE;
}
/* --------- PAINT Message -------- */
static void PaintMsg(DFWINDOW wnd)
{
int wd;
unsigned char sep[80], *cp = sep;
unsigned char sel[80];
struct PopDown *ActivePopDown;
struct PopDown *pd1;
ActivePopDown = pd1 = wnd->mnu->Selections;
wd = MenuWidth(ActivePopDown)-2;
while (wd--)
*cp++ = LINE;
*cp = '\0';
DfSendMessage(wnd, CLEARTEXT, 0, 0);
wnd->selection = wnd->mnu->Selection;
while (pd1->SelectionTitle != NULL) {
if (*pd1->SelectionTitle == LINE)
DfSendMessage(wnd, ADDTEXT, (PARAM) sep, 0);
else {
int len;
memset(sel, '\0', sizeof sel);
if (pd1->Attrib & INACTIVE)
/* ------ inactive menu selection ----- */
sprintf(sel, "%c%c%c",
CHANGECOLOR,
wnd->WindowColors [HILITE_COLOR] [FG]|0x80,
wnd->WindowColors [STD_COLOR] [BG]|0x80);
strcat(sel, " ");
if (pd1->Attrib & CHECKED)
/* ---- paint the toggle checkmark ---- */
sel[strlen(sel)-1] = CHECKMARK;
len=CopyCommand(sel+strlen(sel),pd1->SelectionTitle,
pd1->Attrib & INACTIVE,
wnd->WindowColors [STD_COLOR] [BG]);
if (pd1->Accelerator) {
/* ---- paint accelerator key ---- */
int i;
int wd1 = 2+SelectionWidth(ActivePopDown) -
strlen(pd1->SelectionTitle);
for (i = 0; keys[i].keylabel; i++) {
if (keys[i].keycode == pd1->Accelerator) {
while (wd1--)
strcat(sel, " ");
sprintf(sel+strlen(sel), "[%s]",
keys[i].keylabel);
break;
}
}
}
if (pd1->Attrib & CASCADED) {
/* ---- paint cascaded menu token ---- */
if (!pd1->Accelerator) {
wd = MenuWidth(ActivePopDown)-len+1;
while (wd--)
strcat(sel, " ");
}
sel[strlen(sel)-1] = CASCADEPOINTER;
}
else
strcat(sel, " ");
strcat(sel, " ");
sel[strlen(sel)-1] = RESETCOLOR;
DfSendMessage(wnd, ADDTEXT, (PARAM) sel, 0);
}
pd1++;
}
}
/* ---------- BORDER Message ----------- */
static int BorderMsg(DFWINDOW wnd)
{
int i, rtn = TRUE;
DFWINDOW currFocus;
if (wnd->mnu != NULL) {
currFocus = inFocus;
inFocus = NULL;
rtn = BaseWndProc(POPDOWNMENU, wnd, BORDER, 0, 0);
inFocus = currFocus;
for (i = 0; i < ClientHeight(wnd); i++) {
if (*TextLine(wnd, i) == LINE) {
wputch(wnd, LEDGE, 0, i+1);
wputch(wnd, REDGE, WindowWidth(wnd)-1, i+1);
}
}
}
return rtn;
}
/* -------------- LB_CHOOSE Message -------------- */
static void LBChooseMsg(DFWINDOW wnd, PARAM p1)
{
struct PopDown *ActivePopDown = wnd->mnu->Selections;
if (ActivePopDown != NULL) {
int *attr = &(ActivePopDown+(int)p1)->Attrib;
wnd->mnu->Selection = (int)p1;
if (!(*attr & INACTIVE)) {
if (*attr & TOGGLE)
*attr ^= CHECKED;
DfPostMessage(GetParent(wnd), DFM_COMMAND,
(ActivePopDown+(int)p1)->ActionId, p1);
}
else
beep();
}
}
/* ---------- KEYBOARD Message --------- */
static BOOL KeyboardMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
{
struct PopDown *ActivePopDown = wnd->mnu->Selections;
if (wnd->mnu != NULL)
{
if (ActivePopDown != NULL)
{
int c = (int)p1;
int sel = 0;
int a;
struct PopDown *pd = ActivePopDown;
if ((c & OFFSET) == 0)
c = tolower(c);
a = AltConvert(c);
while (pd->SelectionTitle != NULL)
{
char *cp = strchr(pd->SelectionTitle, SHORTCUTCHAR);
/* FIXME: AltConvert bug !! */
if ((cp && tolower(*(cp+1)) == c) ||
// (a && tolower(*(cp+1)) == a) ||
pd->Accelerator == c)
{
DfPostMessage(wnd, LB_SELECTION, sel, 0);
DfPostMessage(wnd, LB_CHOOSE, sel, TRUE);
return TRUE;
}
pd++;
sel++;
}
}
}
switch ((int)p1)
{
case F1:
if (ActivePopDown == NULL)
DfSendMessage(GetParent(wnd), KEYBOARD, p1, p2);
else
DisplayHelp(wnd,
(ActivePopDown+wnd->selection)->help);
return TRUE;
case ESC:
DfSendMessage(wnd, CLOSE_WINDOW, 0, 0);
return TRUE;
case FWD:
case BS:
if (GetClass(GetParent(wnd)) == MENUBAR)
DfPostMessage(GetParent(wnd), KEYBOARD, p1, p2);
return TRUE;
case UP:
if (wnd->selection == 0) {
if (wnd->wlines == ClientHeight(wnd)) {
DfPostMessage(wnd, LB_SELECTION,
wnd->wlines-1, FALSE);
return TRUE;
}
}
break;
case DN:
if (wnd->selection == wnd->wlines-1) {
if (wnd->wlines == ClientHeight(wnd)) {
DfPostMessage(wnd, LB_SELECTION, 0, FALSE);
return TRUE;
}
}
break;
case HOME:
case END:
case '\r':
break;
default:
return TRUE;
}
return FALSE;
}
/* ----------- CLOSE_WINDOW Message ---------- */
static int CloseWindowMsg(DFWINDOW wnd)
{
int rtn;
DFWINDOW pwnd = GetParent(wnd);
DfSendMessage(wnd, RELEASE_MOUSE, 0, 0);
DfSendMessage(wnd, RELEASE_KEYBOARD, 0, 0);
DfSendMessage(NULL, RESTORE_CURSOR, 0, 0);
inFocus = wnd->oldFocus;
rtn = BaseWndProc(POPDOWNMENU, wnd, CLOSE_WINDOW, 0, 0);
DfSendMessage(pwnd, CLOSE_POPDOWN, 0, 0);
return rtn;
}
/* - Window processing module for POPDOWNMENU window class - */
int PopDownProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
switch (msg) {
case CREATE_WINDOW:
return CreateWindowMsg(wnd);
case LEFT_BUTTON:
LeftButtonMsg(wnd, p1, p2);
return FALSE;
case DOUBLE_CLICK:
return TRUE;
case LB_SELECTION:
if (*TextLine(wnd, (int)p1) == LINE)
return TRUE;
wnd->mnu->Selection = (int)p1;
break;
case DFM_BUTTON_RELEASED:
if (ButtonReleasedMsg(wnd, p1, p2))
return TRUE;
break;
case BUILD_SELECTIONS:
wnd->mnu = (void *) p1;
wnd->selection = wnd->mnu->Selection;
break;
case PAINT:
if (wnd->mnu == NULL)
return TRUE;
PaintMsg(wnd);
break;
case BORDER:
return BorderMsg(wnd);
case LB_CHOOSE:
LBChooseMsg(wnd, p1);
return TRUE;
case KEYBOARD:
if (KeyboardMsg(wnd, p1, p2))
return TRUE;
break;
case CLOSE_WINDOW:
return CloseWindowMsg(wnd);
default:
break;
}
return BaseWndProc(POPDOWNMENU, wnd, msg, p1, p2);
}
/* --------- compute menu height -------- */
int MenuHeight(struct PopDown *pd)
{
int ht = 0;
while (pd[ht].SelectionTitle != NULL)
ht++;
return ht+2;
}
/* --------- compute menu width -------- */
int MenuWidth(struct PopDown *pd)
{
int wd = 0, i;
int len = 0;
wd = SelectionWidth(pd);
while (pd->SelectionTitle != NULL) {
if (pd->Accelerator) {
for (i = 0; keys[i].keylabel; i++)
if (keys[i].keycode == pd->Accelerator) {
len = max(len, (int)(2+strlen(keys[i].keylabel)));
break;
}
}
if (pd->Attrib & CASCADED)
len = max(len, 2);
pd++;
}
return wd+5+len;
}
/* ---- compute the maximum selection width in a menu ---- */
static int SelectionWidth(struct PopDown *pd)
{
int wd = 0;
while (pd->SelectionTitle != NULL) {
int len = strlen(pd->SelectionTitle)-1;
wd = max(wd, len);
pd++;
}
return wd;
}
/* ----- copy a menu command to a display buffer ---- */
int CopyCommand(unsigned char *dest, unsigned char *src,
int skipcolor, int bg)
{
unsigned char *d = dest;
while (*src && *src != '\n') {
if (*src == SHORTCUTCHAR) {
src++;
if (!skipcolor) {
*dest++ = CHANGECOLOR;
*dest++ = cfg.clr[POPDOWNMENU]
[HILITE_COLOR] [BG] | 0x80;
*dest++ = bg | 0x80;
*dest++ = *src++;
*dest++ = RESETCOLOR;
}
}
else
*dest++ = *src++;
}
return (int) (dest - d);
}
/* EOF */

116
rosapps/lib/dflat32/radio.c Normal file
View file

@ -0,0 +1,116 @@
/* -------- radio.c -------- */
#include "dflat32/dflat.h"
static CTLWINDOW *rct[MAXRADIOS];
int RadioButtonProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
int rtn;
DBOX *db = GetParent(wnd)->extension;
CTLWINDOW *ct = GetControl(wnd);
if (ct != NULL) {
switch (msg) {
case SETFOCUS:
if (!(int)p1)
DfSendMessage(NULL, HIDE_CURSOR, 0, 0);
case MOVE:
rtn = BaseWndProc(RADIOBUTTON,wnd,msg,p1,p2);
SetFocusCursor(wnd);
return rtn;
case PAINT: {
char rb[] = "( )";
if (ct->setting)
rb[1] = 7;
DfSendMessage(wnd, CLEARTEXT, 0, 0);
DfSendMessage(wnd, ADDTEXT, (PARAM) rb, 0);
SetFocusCursor(wnd);
break;
}
case KEYBOARD:
if ((int)p1 != ' ')
break;
case LEFT_BUTTON:
SetRadioButton(db, ct);
break;
default:
break;
}
}
return BaseWndProc(RADIOBUTTON, wnd, msg, p1, p2);
}
static BOOL Setting = TRUE;
void SetRadioButton(DBOX *db, CTLWINDOW *ct)
{
Setting = FALSE;
PushRadioButton(db, ct->command);
Setting = TRUE;
}
void PushRadioButton(DBOX *db, enum commands cmd)
{
CTLWINDOW *ctt = db->ctl;
CTLWINDOW *ct = FindCommand(db, cmd, RADIOBUTTON);
int i;
if (ct == NULL)
return;
/* --- clear all the radio buttons
in this group on the dialog box --- */
/* -------- build a table of all radio buttons at the
same x vector ---------- */
for (i = 0; i < MAXRADIOS; i++)
rct[i] = NULL;
while (ctt->class) {
if (ctt->class == RADIOBUTTON)
if (ct->dwnd.x == ctt->dwnd.x)
rct[ctt->dwnd.y] = ctt;
ctt++;
}
/* ----- find the start of the radiobutton group ---- */
i = ct->dwnd.y;
while (i >= 0 && rct[i] != NULL)
--i;
/* ---- ignore everthing before the group ------ */
while (i >= 0)
rct[i--] = NULL;
/* ----- find the end of the radiobutton group ---- */
i = ct->dwnd.y;
while (i < MAXRADIOS && rct[i] != NULL)
i++;
/* ---- ignore everthing past the group ------ */
while (i < MAXRADIOS)
rct[i++] = NULL;
for (i = 0; i < MAXRADIOS; i++) {
if (rct[i] != NULL) {
int wason = rct[i]->setting;
rct[i]->setting = OFF;
if (Setting)
rct[i]->isetting = OFF;
if (wason)
DfSendMessage(rct[i]->wnd, PAINT, 0, 0);
}
}
/* ----- set the specified radio button on ----- */
ct->setting = ON;
if (Setting)
ct->isetting = ON;
DfSendMessage(ct->wnd, PAINT, 0, 0);
}
BOOL RadioButtonSetting(DBOX *db, enum commands cmd)
{
CTLWINDOW *ct = FindCommand(db, cmd, RADIOBUTTON);
if (ct != NULL)
return (ct->setting == ON);
return FALSE;
}
/* EOF */

View file

@ -1,6 +1,6 @@
/* ------------- rect.c --------------- */
#include <dflat32/dflat.h>
#include "dflat32/dflat.h"
/* --- Produce the vector end points produced by the overlap
of two other vectors --- */

View file

@ -0,0 +1,48 @@
/* ------------ spinbutt.c ------------- */
#include "dflat32/dflat.h"
int SpinButtonProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
int rtn;
CTLWINDOW *ct = GetControl(wnd);
if (ct != NULL) {
switch (msg) {
case CREATE_WINDOW:
wnd->wd -= 2;
wnd->rc.rt -= 2;
break;
case SETFOCUS:
rtn = BaseWndProc(SPINBUTTON, wnd, msg, p1, p2);
if (!(int)p1)
DfSendMessage(NULL, HIDE_CURSOR, 0, 0);
SetFocusCursor(wnd);
return rtn;
case PAINT:
foreground = WndBackground(wnd);
background = WndForeground(wnd);
wputch(wnd,UPSCROLLBOX,WindowWidth(wnd), 0);
wputch(wnd,DOWNSCROLLBOX,WindowWidth(wnd)+1,0);
SetFocusCursor(wnd);
break;
case LEFT_BUTTON:
if (p1 == GetRight(wnd) + 1)
DfSendMessage(wnd, KEYBOARD, UP, 0);
else if (p1 == GetRight(wnd) + 2)
DfSendMessage(wnd, KEYBOARD, DN, 0);
if (wnd != inFocus)
DfSendMessage(wnd, SETFOCUS, TRUE, 0);
return TRUE;
case LB_SETSELECTION:
rtn = BaseWndProc(SPINBUTTON, wnd, msg, p1, p2);
wnd->wtop = (int) p1;
DfSendMessage(wnd, PAINT, 0, 0);
return rtn;
default:
break;
}
}
return BaseWndProc(SPINBUTTON, wnd, msg, p1, p2);
}
/* EOF */

View file

@ -0,0 +1,53 @@
/* ---------------- statbar.c -------------- */
#include "dflat32/dflat.h"
int StatusBarProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
char *statusbar;
switch (msg) {
case CREATE_WINDOW:
case MOVE:
DfSendMessage(wnd, CAPTURE_CLOCK, 0, 0);
break;
case KEYBOARD:
if ((int)p1 == CTRL_F4)
return TRUE;
break;
case PAINT:
if (!isVisible(wnd))
break;
statusbar = DFcalloc(1, WindowWidth(wnd)+1);
memset(statusbar, ' ', WindowWidth(wnd));
*(statusbar+WindowWidth(wnd)) = '\0';
strncpy(statusbar+1, "F1=Help Ý FreeDos Edit", 22);
if (wnd->text) {
int len = min((int)strlen(wnd->text), (int)(WindowWidth(wnd)-17));
if (len > 0) {
int off=(WindowWidth(wnd)-len)/2;
strncpy(statusbar+off, wnd->text, len);
}
}
if (wnd->TimePosted)
*(statusbar+WindowWidth(wnd)-8) = '\0';
SetStandardColor(wnd);
PutWindowLine(wnd, statusbar, 0, 0);
free(statusbar);
return TRUE;
case BORDER:
return TRUE;
case CLOCKTICK:
SetStandardColor(wnd);
PutWindowLine(wnd, (char *)p1, WindowWidth(wnd)-8, 0);
wnd->TimePosted = TRUE;
return TRUE;
case CLOSE_WINDOW:
DfSendMessage(NULL, RELEASE_CLOCK, 0, 0);
break;
default:
break;
}
return BaseWndProc(STATUSBAR, wnd, msg, p1, p2);
}
/* EOF */

View file

@ -1,48 +1,28 @@
#include <dflat32/dflat.h>
#include "dflat32/dflat.h"
DFWINDOW ApplicationWindow; //applicat.c
void ClearDialogBoxes(void) // no clue
int TestCriticalError(void)
{
}
// from normal.c
/* These are functions that are supposed to be part of the application
* not part of the dflat32.dll
*
* - Fixme
*/
/* -------- array of class definitions -------- */
CLASSDEFS classdefs[] = {
#undef ClassDef
#define ClassDef(c,b,p,a) {b,p,a},
// #include <dflat32/classes.h>
};
char DFlatApplication[] = "none"; //edit.c
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)
void PrepFileMenu(void *w, struct Menu *mnu) //edit.c
{
}
// log.c
void LogMessages (DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
void PrepSearchMenu(void *w, struct Menu *mnu) //edit.c
{
}
void PrepEditMenu(void *w, struct Menu *mnu) //edit.c
{
}
char **Argv; //edit.c

View file

@ -0,0 +1,108 @@
/* ------------- sysmenu.c ------------ */
#include "dflat32/dflat.h"
int SystemMenuProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
int mx, my;
DFWINDOW wnd1;
switch (msg) {
case CREATE_WINDOW:
wnd->holdmenu = ActiveMenuBar;
ActiveMenuBar = &SystemMenu;
SystemMenu.PullDown[0].Selection = 0;
break;
case LEFT_BUTTON:
wnd1 = GetParent(wnd);
mx = (int) p1 - GetLeft(wnd1);
my = (int) p2 - GetTop(wnd1);
if (HitControlBox(wnd1, mx, my))
return TRUE;
break;
case LB_CHOOSE:
DfPostMessage(wnd, CLOSE_WINDOW, 0, 0);
break;
case DOUBLE_CLICK:
if (p2 == GetTop(GetParent(wnd))) {
DfPostMessage(GetParent(wnd), msg, p1, p2);
DfSendMessage(wnd, CLOSE_WINDOW, TRUE, 0);
}
return TRUE;
case SHIFT_CHANGED:
return TRUE;
case CLOSE_WINDOW:
ActiveMenuBar = wnd->holdmenu;
break;
default:
break;
}
return DefaultWndProc(wnd, msg, p1, p2);
}
/* ------- Build a system menu -------- */
void BuildSystemMenu(DFWINDOW wnd)
{
int lf, tp, ht, wd;
DFWINDOW SystemMenuWnd;
SystemMenu.PullDown[0].Selections[6].Accelerator =
(GetClass(wnd) == APPLICATION) ? ALT_F4 : CTRL_F4;
lf = GetLeft(wnd)+1;
tp = GetTop(wnd)+1;
ht = MenuHeight(SystemMenu.PullDown[0].Selections);
wd = MenuWidth(SystemMenu.PullDown[0].Selections);
if (lf+wd > DfGetScreenWidth()-1)
lf = (DfGetScreenWidth()-1) - wd;
if (tp+ht > DfGetScreenHeight()-2)
tp = (DfGetScreenHeight()-2) - ht;
SystemMenuWnd = DfCreateWindow(POPDOWNMENU, NULL,
lf,tp,ht,wd,NULL,wnd,SystemMenuProc, 0);
#ifdef INCLUDE_RESTORE
if (wnd->condition == ISRESTORED)
DeactivateCommand(&SystemMenu, ID_SYSRESTORE);
else
ActivateCommand(&SystemMenu, ID_SYSRESTORE);
#endif
if (TestAttribute(wnd, MOVEABLE)
#ifdef INCLUDE_MAXIMIZE
&& wnd->condition != ISMAXIMIZED
#endif
)
ActivateCommand(&SystemMenu, ID_SYSMOVE);
else
DeactivateCommand(&SystemMenu, ID_SYSMOVE);
if (wnd->condition != ISRESTORED ||
TestAttribute(wnd, SIZEABLE) == FALSE)
DeactivateCommand(&SystemMenu, ID_SYSSIZE);
else
ActivateCommand(&SystemMenu, ID_SYSSIZE);
#ifdef INCLUDE_MINIMIZE
if (wnd->condition == ISMINIMIZED ||
TestAttribute(wnd, MINMAXBOX) == FALSE)
DeactivateCommand(&SystemMenu, ID_SYSMINIMIZE);
else
ActivateCommand(&SystemMenu, ID_SYSMINIMIZE);
#endif
#ifdef INCLUDE_MAXIMIZE
if (wnd->condition != ISRESTORED ||
TestAttribute(wnd, MINMAXBOX) == FALSE)
DeactivateCommand(&SystemMenu, ID_SYSMAXIMIZE);
else
ActivateCommand(&SystemMenu, ID_SYSMAXIMIZE);
#endif
DfSendMessage(SystemMenuWnd, BUILD_SELECTIONS,
(PARAM) &SystemMenu.PullDown[0], 0);
DfSendMessage(SystemMenuWnd, SETFOCUS, TRUE, 0);
DfSendMessage(SystemMenuWnd, SHOW_WINDOW, 0, 0);
}
/* EOF */

View file

@ -0,0 +1,65 @@
/* -------------- text.c -------------- */
#include "dflat32/dflat.h"
int TextProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
int i, len;
CTLWINDOW *ct = GetControl(wnd);
char *cp, *cp2 = ct->itext;
char *ptr;
switch (msg)
{
case SETFOCUS:
return TRUE;
case LEFT_BUTTON:
return TRUE;
case PAINT:
if (ct == NULL ||
ct->itext == NULL ||
GetText(wnd) != NULL)
break;
len = min(ct->dwnd.h, MsgHeight(cp2));
ptr = DFmalloc (strlen (cp2) + 1);
strcpy (ptr, cp2);
cp = ptr;
for (i = 0; i < len; i++)
{
int mlen;
char *txt = cp;
char *cp1 = cp;
char *np = strchr(cp, '\n');
if (np != NULL)
*np = '\0';
mlen = strlen(cp);
while ((cp1=strchr(cp1,SHORTCUTCHAR)) != NULL)
{
mlen += 3;
cp1++;
}
if (np != NULL)
*np = '\n';
txt = DFmalloc(mlen+1);
CopyCommand(txt, cp, FALSE, WndBackground(wnd));
txt[mlen] = '\0';
DfSendMessage(wnd, ADDTEXT, (PARAM)txt, 0);
if ((cp = strchr(cp, '\n')) != NULL)
cp++;
free(txt);
}
free (ptr);
break;
default:
break;
}
return BaseWndProc(TEXT, wnd, msg, p1, p2);
}
/* EOF */

View file

@ -1,6 +1,6 @@
/* --------------------- video.c -------------------- */
#include <dflat32/dflat.h>
#include "dflat32/dflat.h"
#define clr(fg,bg) ((fg)|((bg)<<4))

View file

@ -0,0 +1,58 @@
/* ----------- watch.c ----------- */
#include "dflat32/dflat.h"
int WatchIconProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
{
int rtn;
switch (msg) {
case CREATE_WINDOW:
rtn = DefaultWndProc(wnd, msg, p1, p2);
DfSendMessage(wnd, CAPTURE_MOUSE, 0, 0);
DfSendMessage(wnd, CAPTURE_KEYBOARD, 0, 0);
return rtn;
case PAINT:
SetStandardColor(wnd);
writeline(wnd, " R ", 1, 1, FALSE);
return TRUE;
case BORDER:
rtn = DefaultWndProc(wnd, msg, p1, p2);
writeline(wnd, "Í", 2, 0, FALSE);
return rtn;
case MOUSE_MOVED:
DfSendMessage(wnd, DFM_HIDE_WINDOW, 0, 0);
DfSendMessage(wnd, MOVE, p1, p2);
DfSendMessage(wnd, SHOW_WINDOW, 0, 0);
return TRUE;
case CLOSE_WINDOW:
DfSendMessage(wnd, RELEASE_MOUSE, 0, 0);
DfSendMessage(wnd, RELEASE_KEYBOARD, 0, 0);
break;
default:
break;
}
return DefaultWndProc(wnd, msg, p1, p2);
}
DFWINDOW WatchIcon(void)
{
int mx, my;
DFWINDOW wnd;
/* this won't work !! */
// DfSendMessage(NULL, DFM_CURRENT_MOUSE_CURSOR,
// (PARAM) &mx, (PARAM) &my);
mx = 0;//SCREENWIDTH / 2;
mx = 0;//SCREENHEIGHT / 2;
wnd = DfCreateWindow(
BOX,
NULL,
mx, my, 3, 5,
NULL,NULL,
WatchIconProc,
VISIBLE | HASBORDER | SHADOW | SAVESELF);
return wnd;
}
/* EOF */

View file

@ -1,6 +1,6 @@
/* ---------- window.c ------------- */
#include <dflat32/dflat.h>
#include "dflat32/dflat.h"
DFWINDOW inFocus = NULL;