⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dflat.h

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 H
📖 第 1 页 / 共 2 页
字号:
/* ------------- dflat.h ----------- */
#ifndef DFLAT_H
#define DFLAT_H

//#ifdef BUILD_FULL_DFLAT
#define INCLUDE_MULTI_WINDOWS
#define INCLUDE_LOGGING
#define INCLUDE_SHELLDOS
#define INCLUDE_WINDOWOPTIONS
#define INCLUDE_PICTUREBOX
#define INCLUDE_MINIMIZE
#define INCLUDE_MAXIMIZE
#define INCLUDE_RESTORE
#define INCLUDE_EXTENDEDSELECTIONS
//#endif

#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dos.h>
#include <process.h>
#include <conio.h>
#include <ctype.h>
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <setjmp.h>

#ifndef DF_VERSION
#define DF_VERSION "Beta Version 0.3"
#endif

void *DfCalloc(size_t, size_t);
void *DfMalloc(size_t);
void *DfRealloc(void *, size_t);


#define DF_MAXMESSAGES 50
#define DF_DELAYTICKS 1
#define DF_FIRSTDELAY 7
#define DF_DOUBLETICKS 5

#define DF_MAXTEXTLEN 65000U /* maximum text buffer            */
#define DF_EDITLEN     1024  /* starting length for multiliner */
#define DF_ENTRYLEN     256  /* starting length for one-liner  */
#define DF_GROWLENGTH    64  /* buffers grow by this much      */

#include "system.h"
#include "config.h"
#include "rect.h"
#include "menu.h"
#include "keys.h"
#include "commands.h"
#include "dialbox.h"

/* ------ integer type for message parameters ----- */
typedef long DF_PARAM;

enum DfCondition
{
    DF_SRESTORED, DF_ISMINIMIZED, DF_ISMAXIMIZED, DF_ISCLOSING
};

typedef struct DfWindow
{
	DFCLASS class;		/* window class                  */
	char *title;		/* window title                  */
	int (*wndproc)(struct DfWindow *, enum DfMessages, DF_PARAM, DF_PARAM);

	/* ----------------- window colors -------------------- */
	char WindowColors[4][2];

	/* ---------------- window dimensions ----------------- */
	DFRECT rc;		/* window coordinates (0/0 to 79/24) */
	int ht, wd;		/* window height and width       */
	DFRECT RestoredRC;	/* restored condition rect       */

	/* -------------- linked list pointers ---------------- */
	struct DfWindow *parent;      /* parent window            */
	struct DfWindow *firstchild;  /* first child this parent  */
	struct DfWindow *lastchild;   /* last child this parent   */
	struct DfWindow *nextsibling; /* next sibling             */
	struct DfWindow *prevsibling; /* previous sibling         */
	struct DfWindow *childfocus;	/* child that ha(s/d) focus */

	int attrib;                 /* Window attributes        */
	PCHAR_INFO videosave;       /* video save buffer        */
	enum DfCondition condition;   /* Restored, Maximized,
	                               Minimized, Closing       */
	enum DfCondition oldcondition;/* previous condition       */
	int restored_attrib;        /* attributes when restored */
	void *extension;      /* menus, dialogs, documents, etc */
	struct DfWindow *PrevMouse;
	struct DfWindow *PrevKeyboard;
	struct DfWindow *MenuBarWnd;/* menu bar                   */
	struct DfWindow *StatusBar; /* status bar                 */
	int isHelping;		/* > 0 when help is being displayed */

	/* ----------------- text box fields ------------------ */
	int wlines;     /* number of lines of text              */
	int wtop;       /* text line that is on the top display */
	char *text;     /* window text                     */
	unsigned int textlen;  /* text length                   */
	int wleft;      /* left position in window viewport     */
	int textwidth;  /* width of longest line in textbox     */
	int BlkBegLine; /* beginning line of marked block       */
	int BlkBegCol;  /* beginning column of marked block     */
	int BlkEndLine; /* ending line of marked block          */
	int BlkEndCol;  /* ending column of marked block        */
	int HScrollBox; /* position of horizontal scroll box    */
	int VScrollBox; /* position of vertical scroll box      */
	unsigned int *TextPointers; /* -> list of line offsets	*/

	/* ----------------- list box fields ------------------ */
	int selection;  /* current selection                    */
	BOOL AddMode;   /* adding extended selections mode      */
	int AnchorPoint;/* anchor point for extended selections */
	int SelectCount;/* count of selected items              */

	/* ----------------- edit box fields ------------------ */
	int CurrCol;      /* Current column                     */
	int CurrLine;     /* Current line                       */
	int WndRow;       /* Current window row                 */
	BOOL TextChanged; /* TRUE if text has changed           */
	char *DeletedText;          /* for undo                 */
	unsigned DeletedLength; /* Length of deleted field      */
	BOOL InsertMode;   /* TRUE or FALSE for text insert     */
	BOOL WordWrapMode; /* TRUE or FALSE for word wrap       */
	unsigned int MaxTextLength; /* maximum text length      */

	/* ---------------- dialog box fields ----------------- */
	int ReturnCode;		/* return code from a dialog box */
	BOOL Modal;		/* True if a modeless dialog box */
	DF_CTLWINDOW *ct;		/* control structure             */
	struct DfWindow *dfocus;	/* control window that has focus */
	/* -------------- popdownmenu fields ------------------ */
	DF_MENU *mnu;		/* points to menu structure             */
	DF_MBAR *holdmenu;		/* previous active menu                 */
	struct DfWindow *oldFocus;

	/* --------------- help box fields -------------------- */
	void *firstword; /* -> first in list of key words       */
	void *lastword;  /* -> last in list of key words        */
	void *thisword;  /* -> current in list of key words     */
	/* -------------- status bar fields ------------------- */
	BOOL TimePosted; /* True if time has been posted        */
#ifdef INCLUDE_PICTUREBOX
	/* ------------- picture box fields ------------------- */
	int VectorCount;  /* number of vectors in vector list   */
	void *VectorList; /* list of picture box vectors        */
#endif
} * DFWINDOW;

#include "classdef.h"
#include "video.h"

void DfLogMessages (DFWINDOW, DFMESSAGE, DF_PARAM, DF_PARAM);
void DfMessageLog(DFWINDOW);
/* ------- window methods ----------- */
#define DF_ICONHEIGHT 3
#define DF_ICONWIDTH  10
#define DfWindowHeight(w)      ((w)->ht)
#define DfWindowWidth(w)       ((w)->wd)
#define DfBorderAdj(w)         (DfTestAttribute(w,DF_HASBORDER)?1:0)
#define DfBottomBorderAdj(w)   (DfTestAttribute(w,DF_HASSTATUSBAR)?1:DfBorderAdj(w))
#define DfTopBorderAdj(w)      ((DfTestAttribute(w,DF_HASTITLEBAR) &&   \
                              DfTestAttribute(w,DF_HASMENUBAR)) ?  \
                              2 : (DfTestAttribute(w,DF_HASTITLEBAR | \
                              DF_HASMENUBAR | DF_HASBORDER) ? 1 : 0))
#define DfClientWidth(w)       (DfWindowWidth(w)-DfBorderAdj(w)*2)
#define DfClientHeight(w)      (DfWindowHeight(w)-DfTopBorderAdj(w)-\
                              DfBottomBorderAdj(w))
#define DfWindowRect(w)        ((w)->rc)
#define DfGetTop(w)            (DfRectTop(DfWindowRect(w)))
#define DfGetBottom(w)         (DfRectBottom(DfWindowRect(w)))
#define DfGetLeft(w)           (DfRectLeft(DfWindowRect(w)))
#define DfGetRight(w)          (DfRectRight(DfWindowRect(w)))
#define DfGetClientTop(w)      (DfGetTop(w)+DfTopBorderAdj(w))
#define DfGetClientBottom(w)   (DfGetBottom(w)-DfBottomBorderAdj(w))
#define DfGetClientLeft(w)     (DfGetLeft(w)+DfBorderAdj(w))
#define DfGetClientRight(w)    (DfGetRight(w)-DfBorderAdj(w))
#define DfGetTitle(w)          ((w)->title)
#define DfGetParent(w)         ((w)->parent)
#define DfFirstWindow(w)       ((w)->firstchild)
#define DfLastWindow(w)        ((w)->lastchild)
#define DfNextWindow(w)        ((w)->nextsibling)
#define DfPrevWindow(w)        ((w)->prevsibling)
#define DfGetClass(w)          ((w)->class)
#define DfGetAttribute(w)      ((w)->attrib)
#define DfAddAttribute(w,a)    (DfGetAttribute(w) |= a)
#define DfClearAttribute(w,a)  (DfGetAttribute(w) &= ~(a))
#define DfTestAttribute(w,a)   (DfGetAttribute(w) & (a))
#define isHidden(w)          (!(DfGetAttribute(w) & DF_VISIBLE))
#define DfSetVisible(w)        (DfGetAttribute(w) |= DF_VISIBLE)
#define DfClearVisible(w)      (DfGetAttribute(w) &= ~DF_VISIBLE)
#define DfGotoXY(w,x,y) DfCursor(w->rc.lf+(x)+1,w->rc.tp+(y)+1)
BOOL DfIsVisible(DFWINDOW);
DFWINDOW DfDfCreateWindow(DFCLASS,char *,int,int,int,int,void*,DFWINDOW,
       int (*)(struct DfWindow *,enum DfMessages,DF_PARAM,DF_PARAM),int);
void DfAddTitle(DFWINDOW, char *);
void DfInsertTitle(DFWINDOW, char *);
void DfDisplayTitle(DFWINDOW, DFRECT *);
void DfRepaintBorder(DFWINDOW, DFRECT *);
void DfPaintShadow(DFWINDOW);
void DfClearWindow(DFWINDOW, DFRECT *, int);
void DfWriteLine(DFWINDOW, char *, int, int, BOOL);
void DfInitWindowColors(DFWINDOW);

void DfSetNextFocus(void);
void DfSetPrevFocus(void);
void DfRemoveWindow(DFWINDOW);
void DfAppendWindow(DFWINDOW);
void DfReFocus(DFWINDOW);
void DfSkipApplicationControls(void);

BOOL DfCharInView(DFWINDOW, int, int);
void DfCreatePath(char *, char *, int, int);
#define DfSwapVideoBuffer(wnd, ish, fh) swapvideo(wnd, wnd->videosave, ish, fh)
int DfLineLength(char *);
DFRECT DfAdjustRectangle(DFWINDOW, DFRECT);
BOOL DfIsDerivedFrom(DFWINDOW, DFCLASS);
DFWINDOW DfGetAncestor(DFWINDOW);
void DfPutWindowChar(DFWINDOW,char,int,int);
void DfPutWindowLine(DFWINDOW, void *,int,int);
#define DfBaseWndProc(class,wnd,msg,p1,p2)    \
    (*DfClassDefs[(DfClassDefs[class].base)].wndproc)(wnd,msg,p1,p2)
#define DfDefaultWndProc(wnd,msg,p1,p2)         \
	(DfClassDefs[wnd->class].wndproc == NULL) ? \
	DfBaseWndProc(wnd->class,wnd,msg,p1,p2) :	  \
    (*DfClassDefs[wnd->class].wndproc)(wnd,msg,p1,p2)
struct DfLinkedList    {
    DFWINDOW DfFirstWindow;
    DFWINDOW DfLastWindow;
};
extern DFWINDOW DfApplicationWindow;
extern DFWINDOW DfInFocus;
extern DFWINDOW DfCaptureMouse;
extern DFWINDOW DfCaptureKeyboard;
extern int DfForeground, DfBackground;
extern BOOL DfWindowMoving;
extern BOOL DfWindowSizing;
extern BOOL DfVSliding;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -