home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
NOTEPAD2.ZIP
/
MTYPES.H
< prev
next >
Wrap
C/C++ Source or Header
|
1989-02-08
|
13KB
|
328 lines
/*
* mtypes.h -- Types for the MLE
*
* Created by Microsoft Corporation, 1989
*/
/***********************************************************************
* Measurements
***********************************************************************/
#ifndef MLE
typedef LONG IPT; // insertion point in text (between two chars)
typedef SHORT LINE; // line number
#endif
typedef IPT FAR *PIPT;
typedef SHORT PIX; // pixel offset
typedef PIX FAR *PPIX;
typedef USHORT OFFSET; // offset within a segment or a piece
typedef OFFSET FAR *POFFSET;
/***********************************************************************
* Piece Management
***********************************************************************/
/* Segment record: used to track information about segments containing
* piece information.
*/
typedef struct _SEGDESC {
OFFSET cchLen;
SEL sel;
OFFSET cchFree;
struct _PIECE FAR *pprPhysLast;
struct _SEGDESC FAR *psdNext;
struct _SEGDESC FAR *psdPrev;
} SEGDESC;
typedef SEGDESC FAR *PSEGDESC;
/*
* Piece manager tuning parameters
*/
// GrowSize -- minimum amount by which segments should be grown during
// an ExtendSpace operation
#define PIECE_GROWSIZE (ULONG)16384
// MaxSegSize -- maximum size a segment is allowed to grow to before
// another segment must be used. Is equal to 64K-1 so
// it can be represented in a USHORT.
#define PIECE_MAXSEGSIZE (ULONG)65535
// MinCreate and MaxCreate are used during InsEndChars. When a piece
// runs out of room, then a new piece of size MinCreate <= size <= MaxCreate
// will be created. MinCreate should be set so that it is reasonably likely
// that future insertions will not need to create new space; MaxCreate should
// be small enough so that fragmentation doesn't get too bad.
#define PIECE_MINCREATE PIECE_GROWSIZE
#define PIECE_MAXCREATE PIECE_MAXSEGSIZE
// MinDelete -- when a deletion causes a free space of size >= MinDelete,
// the associated segment is bubbled to the front of the
// segment list.
#define PIECE_MINDELETE 512
/*
* Piece record: used to connect chunks of text. Chunks never extend
* beyond paragraph boundaries. There is one sequence of chunks, defined
* by the TextNext/TextPrev list, that defines the contents of a paragraph.
* In addition pieces are linked in physical order (to accomodate the
* PieceMemory manager.
* Note that a piece record really only serves to mark the existence
* of the actual piece.
*/
struct _PIECE {
struct _PIECE FAR *pprTextNext; // next and previous in text order
struct _PIECE FAR *pprTextPrev;
CHAR FAR *pchText; // actual piece
OFFSET cchText; // amount of valid text in piece
OFFSET cchUnused; // amt of unused space in piece
struct _PIECE FAR *pprPhysNext; // next/prev in phys memory order
struct _PIECE FAR *pprPhysPrev;
PSEGDESC psd; // descriptor for containing segment
};
typedef struct _PIECE PIECE;
typedef PIECE FAR *PPR;
typedef PPR FAR *PPPR;
/*
* Marker Piece record: used to insert special markers into the text stream.
* In particular, marks beginnings of lines. Combined into the heterogeneous
* text-order list with Piece records (above); marker records can be
* identified by a NULL value for pchText. The text manager only maintains
* the marker's order in the text list; it may dispose of the marker at will
* (unless the marker is locked)
* and may create new markers as text is changed. Whenever the text manager
* creates a marker, it will set cchValid to zero; the display manager
* must then not rely on the values it is responsible for setting.
* The text manager is also responsible for shortening cchValid whenever
* text changes.
*/
struct _MARKERPIECE {
PIECE pr; // general piece fields
BOOL fLocked; // true => cannot be deleted
USHORT fFlags; // attribute flags
LINE sScreenLine; // screen line number
IPT cchLine; // line length in chars
IPT cchValid; // count of drawn chars
PIX pixLine; // line length in pixels
PIX pixValid; // pix index of first invalid char
IPT cchBegin; // char index of first inversion
IPT cchEnd; // char index of last inversion
};
typedef struct _MARKERPIECE MARKERPIECE;
typedef MARKERPIECE FAR *PMR;
typedef PMR FAR *PPMR;
// Marker flags
#define MARKER_BOT 0x0001 // beginning of text
#define MARKER_LB 0x0002 // line break
#define MARKER_EOT 0x0004 // end of text
#define MARKER_SLB 0x0008 // soft line break
#define MARKER_SPILL 0x0010 // spill line break (broken word)
#define MARKER_DISPLAY 0x0020 // display position marker
#define MARKER_ANY 0xffff // matches any marker
#define MARKER_LINE 0x001f // matches any line marker
#define MARKER_NOTLINE 0xffe0 // matches anything but a line
#define MARKER_HARDLINE (MARKER_BOT | MARKER_LB | MARKER_EOT)
#define MARKER_SOFTLINE (MARKER_SLB | MARKER_SPILL)
/***********************************************************************
* Text Management
***********************************************************************/
// CCHDEFAULTMAX -- unless the app specifies otherwise, this is the default
// size the MLE will configure itself for. Note that a nonpositive max will
// imply no predefined limit.
#define CCHDEFAULTMAX PIECE_MINCREATE
// DEFAULT_TABSIZE -- # of average char widths per tab stop
#define DEFAULT_TABSIZE 8
/***********************************************************************
* Memory Management
***********************************************************************/
// Segment sizes that can be allocated
// must be 2**i
#define SEG8K (ULONG)8192
#define SEG16K (ULONG)16384
#define SEG32K (ULONG)32768
#define SEG64K (ULONG)65536
#define STORE_INITSIZE SEG8K
#define STORE_MAXSEG (SEG64K-1)
/*
* Segment header -- defines the size and contents of a segment
*/
typedef struct _seghdr {
SEL this;
struct _seghdr FAR *next;
struct _seghdr FAR *prev;
LONG size;
} SEGHDR;
typedef SEGHDR FAR *PSEGHDR;
#define SEGHDROF(sel) (PSEGHDR)(MAKEP(sel,0))
/*
* free block -- links together free spots in a segment
*/
typedef struct _freeblock {
BYTE tag;
struct _freeblock FAR *next;
struct _freeblock FAR *prev;
} FREEBLOCK;
typedef FREEBLOCK FAR *PFREEBLOCK;
#define PFB_TAGRESERVED (UCHAR)0x70 // tag & this indicates block reserved
#define PFB_TAGSIZE (UCHAR)0x0f // 4 bits representing size
// (2**field+1)
#define freeblock_size(pfb) (IndexToSize(((pfb)->tag)&PFB_TAGSIZE))
/***********************************************************************
* Buffer Manager Types
***********************************************************************/
/***********************************************************************
* Display manager types
***********************************************************************/
// character rounding modes
#define ROUND_CLOSEST 0
#define ROUND_UP 1
#define ROUND_DOWN 2
// font identifiers
#define SPECIAL_FONT_SETID 1L // User-selected font id
#define DUMMY_FONT_SETID 2L // Dummy id to test the pfattrs
// character width table size and base
#define MAXCHAR 256L // maximum character code (used as
// size of character width table)
#define MINCHAR 0L // minimum character code
// minimum margins, in characters. The numerator/denominator form is used
// to save floating point ops.
//
// Apparent margins may actually be greater; e.g., if the window is
// 5.5 chars high after the minimum margins are subtracted, only 5
// lines are displayed, and the extra half line of space is distributed
// between the top and bottom margins.
#define MARG_LFTNUM 1
#define MARG_LFTDEN 1 /* Left Margin is 1.0 ACW */
#define MARG_RGTNUM 1
#define MARG_RGTDEN 1 /* Right Margin is 1.0 ACW */
#define MARG_TOPNUM 1
#define MARG_TOPDEN 2 /* Top Margin is 0.5 MBE */
#define MARG_BOTNUM 1
#define MARG_BOTDEN 2 /* Bottom Margin is 0.5 MBE */
// maximum number of lines allowed on the screen
// defines size of line validation array
#define DISPLAY_MAXLINES 250
// maximum pixel width of the display. When not in word-wrap mode, lines
// which exceed BREAKPIX will be broken arbitrarily so that the pixel length
// is less than MAXPIX.
#define DISPLAY_BREAKPIX 32000
#define DISPLAY_MAXPIX 32700
// number of average character widths to scroll when mouse clicks
// occur left or right of the window or in response to a scroll bar
// col-left or col-right
#define DISPLAY_SCROLLACWS 2
// character to be drawn when a newline character is encountered
#define DISPLAY_NEWLINECHAR ' '
/***********************************************************************
* Global state info
***********************************************************************/
/*
* PED -- pointer to the edit record; defines all permanent state
* information for a window
*/
typedef struct _ed {
// Generally global stuff
HWND hwnd; // handle of window associated with edit ctl
USHORT idChild; // child ID of edit window
ULONG flStyle; // edit window style bits
// Memory Manager Fields
PSEGHDR selHead, selTail; // list of segments
PFREEBLOCK pfbHead, pfbTail; // free list
// Text Manager Fields
BOOL fChanged; // set => change since last query
PPR pprHead, pprTail; // text-order piece list
IPT iptCursor, iptAnchor;
BOOL fWordWrap; // set => word wrap is on
IPT iptMac; // greatest existing ipt
IPT iptMax; // greatest allowable ipt
// Piece Manager Fields
PSEGDESC psdCurrent; // head of piece segment list
PSEGDESC psdLast; // tail of piece segment list
// Display Manager Fields
BOOL fFocus; // set => window has focus
HPS hps; // presentation space for text
RECTL rclWnd; // entire area of window
BOOL fHSizeDelta; // Horiz size chg since last refresh
BOOL fVSizeDelta; // Vert size chg since last refresh
BOOL fScrollDelta; // Scrolling has changed
RECTL rclText; // area text can be drawn in
LINE lyWndSize; // number of lines on screen
PPMR papmrValid; // array of line validation pointers
PIX pixCurMax; // max found width of document
PIX AveCharWidth; // average character width, pixels
PIX pixMaxChar; // character widths for estimating
PIX pixMinChar; // display areas
PIX yCharPels; // maxbaselineextent of font
PIX yDescPels; // descender below baseline
PIX hScroll; // current horiz scroll, in pixels
USHORT iHSlider, iVSlider; // horiz & vert slider positions
IPT iptFVL; // ipt just before first vis line
PMR pmrFVL; // marker for beginning of display
HRGN hrgnT; // scratch region associated with hps
LONG FAR *pcwt; // pointer to character width table
PIX TabSize; // tab size, in ave char widths
PFATTRS pfattrs; // current font attributes
BOOL fFattrDelta; // fattrs changed since last redraw
BOOL fSelDelta; // selection changed since last redraw
BOOL fExistsCursor; // TRUE => window has a cursor
BOOL fInvert; // TRUE => ps is in inverted color
// Mouse Manager Fields
BOOL fMouseDown; // set => button 1 held down
BOOL fMouseScroll; // set => mouse scroll timer on
// Keyboard Handler Fields
BOOL fTyping; // set => user can type into window
// Buffer Manager Fields
PCHAR pchBlockBuf; // buffer for block transfers
USHORT usBufLength; // length of buffer
USHORT usBlockType; // import/export format
} ED;
typedef ED FAR *PED;