Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

321 lines
14 KiB

  1. /*++ BUILD Version: 0001
  2. *
  3. * WOW v1.0
  4. *
  5. * Copyright (c) 1991, Microsoft Corporation
  6. *
  7. * EDIT.H
  8. *
  9. * History:
  10. * Created 28-May-1991 by Jeff Parsons (jeffpar)
  11. * Copied from WIN31 and edited (as little as possible) for WOW16
  12. --*/
  13. /****************************************************************************/
  14. /* */
  15. /* EDIT.H - */
  16. /* */
  17. /* Edit Control Defines and Procedures */
  18. /* */
  19. /****************************************************************************/
  20. #include "combcom.h"
  21. /* NOTE: Text handle is sized as multiple of this constant
  22. * (should be power of 2).
  23. */
  24. #define CCHALLOCEXTRA 0x20
  25. /* Maximum width in pixels for a line/rectangle */
  26. #define MAXPIXELWIDTH 30000
  27. /* Limit multiline edit controls to at most 1024 characters on a single line.
  28. * We will force a wrap if the user exceeds this limit.
  29. */
  30. #define MAXLINELENGTH 1024
  31. #define ES_FMTMASK 0x00000003L
  32. /* Allow an initial maximum of 30000 characters in all edit controls since
  33. * some apps will run into unsigned problems otherwise. If apps know about
  34. * the 64K limit, they can set the limit themselves.
  35. */
  36. #define MAXTEXT 30000
  37. #define BACKSPACE 0x08
  38. #define TAB 0x09
  39. /* Key modifiers which have been pressed. Code in KeyDownHandler and
  40. CharHandler depend on these exact values. */
  41. #define NONEDOWN 0 /* Neither shift nor control down */
  42. #define CTRLDOWN 1 /* Control key only down */
  43. #define SHFTDOWN 2 /* Shift key only down */
  44. #define SHCTDOWN 3 /* Shift and control keys down = CTRLDOWN + SHFTDOWN */
  45. #define NOMODIFY 4 /* Neither shift nor control down */
  46. /* Types of undo supported in this ped */
  47. #define UNDO_NONE 0 /* We can't undo the last operation. */
  48. #define UNDO_INSERT 1 /* We can undo the user's insertion of characters */
  49. #define UNDO_DELETE 2 /* We can undo the user's deletion of characters */
  50. typedef struct tagED
  51. {
  52. HANDLE hText; /* Block of text we are editing */
  53. ICH cchAlloc; /* Number of chars we have allocated for hText
  54. */
  55. ICH cchTextMax; /* Max number bytes allowed in edit control
  56. */
  57. ICH cch; /* Current number of bytes of actual text
  58. */
  59. int cLines; /* Number of lines of text */
  60. ICH ichMinSel; /* Selection extent. MinSel is first selected
  61. char */
  62. ICH ichMaxSel; /* MaxSel is first unselected character */
  63. ICH ichCaret; /* Caret location. Caret is on left side of
  64. char */
  65. int iCaretLine; /* The line the caret is on. So that if word
  66. * wrapping, we can tell if the caret is at end
  67. * of a line of at beginning of next line...
  68. */
  69. ICH screenStart; /* Index of left most character displayed on
  70. * screen for sl ec and index of top most line
  71. * for multiline edit controls
  72. */
  73. int ichLinesOnScreen; /* Number of lines we can display on screen */
  74. WORD xOffset; /* x (horizontal) scroll position in pixels
  75. * (for multiline text horizontal scroll bar)
  76. */
  77. WORD charPasswordChar; /* If non null, display this character instead
  78. * of the real text. So that we can implement
  79. * hidden text fields.
  80. */
  81. WORD cPasswordCharWidth;/* Width of password char */
  82. HWND hwnd; /* Window for this edit control */
  83. RECT rcFmt; /* Client rectangle */
  84. HWND hwndParent; /* Parent of this edit control window */
  85. /* These vars allow us to automatically scroll
  86. * when the user holds the mouse at the bottom
  87. * of the multiline edit control window.
  88. */
  89. POINT ptPrevMouse; /* Previous point for the mouse for system
  90. * timer.
  91. */
  92. WORD prevKeys; /* Previous key state for the mouse */
  93. WORD fSingle : 1; /* Single line edit control? (or multiline) */
  94. WORD fNoRedraw : 1; /* Redraw in response to a change? */
  95. WORD fMouseDown : 1; /* Is mouse button down? when moving mouse */
  96. WORD fFocus : 1; /* Does ec have the focus ? */
  97. WORD fDirty : 1; /* Modify flag for the edit control */
  98. WORD fDisabled : 1; /* Window disabled? */
  99. WORD fNonPropFont : 1; /* Fixed width font? */
  100. WORD fBorder : 1; /* Draw a border? */
  101. WORD fAutoVScroll : 1; /* Automatically scroll vertically */
  102. WORD fAutoHScroll : 1; /* Automatically scroll horizontally */
  103. WORD fNoHideSel : 1; /* Hide sel when we lose focus? */
  104. #ifdef FE_SB
  105. WORD fDBCS : 1; /* Are we use DBCS font set for editing? */
  106. #else
  107. WORD fKanji : 1;
  108. #endif
  109. WORD fFmtLines : 1; /* For multiline only. Do we insert CR CR LF at
  110. * word wrap breaks?
  111. */
  112. WORD fWrap : 1; /* Do word wrapping? */
  113. WORD fCalcLines : 1; /* Recalc ped->chLines array? (recalc line
  114. * breaks?)
  115. */
  116. WORD fEatNextChar : 1; /* Hack for ALT-NUMPAD stuff with combo boxes.
  117. * If numlock is up, we want to eat the next
  118. * character generated by the keyboard driver
  119. * if user enter num pad ascii value...
  120. */
  121. WORD fStripCRCRLF :1; /* CRCRLFs have been added to text. Strip them
  122. * before doing any internal edit control
  123. * stuff
  124. */
  125. WORD fInDialogBox :1; /* True if the ml edit control is in a dialog
  126. * box and we have to specially treat TABS and
  127. * ENTER
  128. */
  129. WORD fReadOnly :1; /* Is this a read only edit control? Only
  130. * allow scrolling, selecting and copying.
  131. */
  132. WORD fCaretHidden :1; /* This indicates whether the caret is
  133. * currently hidden because the width or height
  134. * of the edit control is too small to show it.
  135. */
  136. int *chLines; /* index of the start of each line */
  137. WORD format; /* Left, center, or right justify multiline
  138. * text.
  139. */
  140. LPSTR (FAR *lpfnNextWord)(); /* Next word function */
  141. ICH maxPixelWidth; /* Width (in pixels) of longest line */
  142. WORD undoType; /* Current type of undo we support */
  143. HANDLE hDeletedText; /* Handle to text which has been deleted (for
  144. undo)
  145. */
  146. ICH ichDeleted; /* Starting index from which text was deleted*/
  147. ICH cchDeleted; /* Count of deleted characters in buffer */
  148. ICH ichInsStart; /* Starting index from which text was
  149. inserted */
  150. ICH ichInsEnd; /* Ending index of inserted text */
  151. HANDLE hFont; /* Handle to the font for this edit control.
  152. Null if system font.
  153. */
  154. int aveCharWidth; /* Ave width of a character in the hFont */
  155. int lineHeight; /* Height of a line in the hFont */
  156. int charOverhang; /* Overhang associated with the hFont */
  157. int cxSysCharWidth; /* System font ave width */
  158. int cySysCharHeight; /* System font height */
  159. HWND listboxHwnd; /* ListBox hwnd. Non null if we are a combo
  160. box */
  161. int *pTabStops; /* Points to an array of tab stops; First
  162. * element contains the number of elements in
  163. * the array
  164. */
  165. HANDLE charWidthBuffer;
  166. HBRUSH hbrHiliteBk; /* Hilite background color brush. */
  167. DWORD rgbHiliteBk; /* Hilite background color */
  168. DWORD rgbHiliteText; /* Hilite Text color */
  169. #ifdef FE_SB
  170. BYTE charSet; /* Character set for current selected font */
  171. HANDLE hDBCSVector; /* Handle to the DBCS vector table */
  172. BYTE DBCSVector[8]; /* DBCS vector table which contains flag
  173. * to detect lead byte of DBC.
  174. */
  175. #endif
  176. } ED;
  177. typedef ED *PED;
  178. /* The following structure is used to store a selection block; In Multiline
  179. * edit controls, "StPos" and "EndPos" fields contain the Starting and Ending
  180. * lines of the block. In Single line edit controls, "StPos" and "EndPos"
  181. * contain the Starting and Ending character positions of the block;
  182. */
  183. typedef struct tagBLOCK
  184. {
  185. ICH StPos;
  186. ICH EndPos;
  187. } BLOCK;
  188. typedef BLOCK FAR *LPBLOCK;
  189. BOOL FAR PASCAL ECNcCreate(HWND, LPCREATESTRUCT);
  190. BOOL FAR PASCAL ECCreate(HWND, PED, LPCREATESTRUCT);
  191. LONG FAR PASCAL ECWord(PED, ICH, BOOL); /* no register for PED */
  192. ICH FAR PASCAL ECFindTab(LPSTR, register ICH);
  193. void FAR PASCAL ECNcDestroyHandler(HWND, register PED, WORD, LONG);
  194. BOOL FAR PASCAL ECSetText(register PED, LPSTR);
  195. void FAR PASCAL ECSetPasswordChar(register PED, WORD);
  196. ICH FAR PASCAL ECCchInWidth(register PED, HDC, LPSTR, register ICH, unsigned int);
  197. void FAR PASCAL ECEmptyUndo(register PED);
  198. BOOL FAR PASCAL ECInsertText(register PED, LPSTR, ICH);
  199. ICH FAR PASCAL ECDeleteText(register PED);
  200. void FAR PASCAL ECNotifyParent(register PED, short);
  201. void FAR PASCAL ECSetEditClip(register PED, HDC);
  202. HDC FAR PASCAL ECGetEditDC(register PED, BOOL);
  203. void FAR PASCAL ECReleaseEditDC(register PED, HDC, BOOL);
  204. void FAR PASCAL ECCreateHandler(register PED);
  205. ICH FAR PASCAL ECGetTextHandler(register PED, register ICH, LPSTR);
  206. void FAR PASCAL ECSetFont(register PED, HANDLE, BOOL);
  207. ICH FAR PASCAL ECCopyHandler(register PED);
  208. BOOL FAR PASCAL ECCalcChangeSelection(PED, ICH, ICH, LPBLOCK, LPBLOCK);
  209. void NEAR PASCAL ECFindXORblks(LPBLOCK, LPBLOCK, LPBLOCK, LPBLOCK);
  210. LONG FAR PASCAL ECTabTheTextOut(HDC, int, int, LPSTR, int, PED, int, BOOL);
  211. /****************************************************************************/
  212. /* Multi-Line Support Routines */
  213. /****************************************************************************/
  214. ICH FAR PASCAL MLInsertText(PED, LPSTR, WORD, BOOL);
  215. BOOL FAR PASCAL MLEnsureCaretVisible(register PED);
  216. void NEAR PASCAL MLDrawText(register PED, HDC, ICH, ICH);
  217. void NEAR PASCAL MLDrawLine(register PED, HDC, int, ICH, int, BOOL);
  218. void NEAR PASCAL MLPaintABlock(PED, HDC, int, int);
  219. int NEAR PASCAL GetBlkEndLine(int, int, BOOL FAR *, int, int);
  220. LONG FAR PASCAL MLBuildchLines(register PED, int, int, BOOL);
  221. void NEAR PASCAL MLShiftchLines(register PED, register int, int);
  222. BOOL NEAR PASCAL MLInsertchLine(register PED, int, ICH, BOOL);
  223. void FAR PASCAL MLSetCaretPosition(register PED,HDC);
  224. LONG NEAR PASCAL MLIchToXYPos(register PED, HDC, ICH, BOOL);
  225. int FAR PASCAL MLIchToLineHandler(register PED, ICH);
  226. void NEAR PASCAL MLRepaintChangedSelection(PED, HDC, ICH, ICH);
  227. void NEAR PASCAL MLMouseMotionHandler(PED, WORD, WORD, POINT);
  228. ICH FAR PASCAL MLLineLength(register PED, int);
  229. void FAR PASCAL MLStripCrCrLf(register PED);
  230. BOOL FAR PASCAL MLSetTextHandler(register PED, LPSTR);
  231. int FAR PASCAL MLCalcXOffset(register PED, HDC, int);
  232. BOOL FAR PASCAL MLUndoHandler(register PED);
  233. LONG FAR PASCAL MLEditWndProc(HWND, register PED, WORD, register WORD, LONG);
  234. void FAR PASCAL MLCharHandler(PED, WORD, int);
  235. void FAR PASCAL MLSetSelectionHandler(register PED, ICH, ICH);
  236. LONG FAR PASCAL MLCreateHandler(HWND, PED, LPCREATESTRUCT);
  237. BOOL FAR PASCAL MLInsertCrCrLf(register PED);
  238. void FAR PASCAL MLSetHandleHandler(register PED, HANDLE);
  239. LONG FAR PASCAL MLGetLineHandler(register PED, WORD, ICH, LPSTR);
  240. ICH FAR PASCAL MLLineIndexHandler(register PED, register int);
  241. ICH FAR PASCAL MLLineLengthHandler(register PED, ICH);
  242. void FAR PASCAL MLSizeHandler(register PED);
  243. void FAR PASCAL MLChangeSelection(register PED, HDC, ICH, ICH);
  244. void FAR PASCAL MLSetRectHandler(register PED, LPRECT);
  245. BOOL FAR PASCAL MLExpandTabs(register PED);
  246. BOOL FAR PASCAL MLSetTabStops(PED, int, LPINT);
  247. int FAR PASCAL MLThumbPosFromPed(register PED, BOOL);
  248. /****************************************************************************/
  249. /* Single Line Support Routines */
  250. /****************************************************************************/
  251. void NEAR PASCAL SLReplaceSelHandler(register PED, LPSTR);
  252. BOOL FAR PASCAL SLUndoHandler(register PED);
  253. void FAR PASCAL SLSetCaretPosition(register PED, HDC);
  254. int NEAR PASCAL SLIchToLeftXPos(register PED, HDC, ICH);
  255. void FAR PASCAL SLChangeSelection(register PED, HDC, ICH, ICH);
  256. void NEAR PASCAL SLDrawText(register PED, register HDC, ICH);
  257. void NEAR PASCAL SLDrawLine(register PED, register HDC, ICH, int, BOOL);
  258. int NEAR PASCAL SLGetBlkEnd(PED, ICH, ICH, BOOL FAR *);
  259. BOOL FAR PASCAL SLScrollText(register PED, HDC);
  260. void FAR PASCAL SLSetSelectionHandler(register PED,ICH, ICH);
  261. ICH FAR PASCAL SLInsertText(register PED, LPSTR, register ICH);
  262. ICH NEAR PASCAL SLPasteText(register PED);
  263. void FAR PASCAL SLCharHandler(register PED, WORD, int);
  264. void NEAR PASCAL SLKeyUpHandler(register PED, WORD);
  265. void NEAR PASCAL SLKeyDownHandler(register PED, WORD, int);
  266. ICH NEAR PASCAL SLMouseToIch(register PED, HDC, POINT);
  267. void NEAR PASCAL SLMouseMotionHandler(register PED, WORD, WORD, POINT);
  268. LONG FAR PASCAL SLCreateHandler(HWND, PED, LPCREATESTRUCT);
  269. void FAR PASCAL SLSizeHandler(register PED);
  270. void NEAR PASCAL SLPaintHandler(register PED, HDC);
  271. BOOL FAR PASCAL SLSetTextHandler(register PED, LPSTR);
  272. void NEAR PASCAL SLSetFocusHandler(register PED);
  273. void NEAR PASCAL SLKillFocusHandler(register PED, HWND);
  274. LONG FAR PASCAL SLEditWndProc(HWND, register PED, WORD, register WORD, LONG);
  275. /****************************************************************************/
  276. /* EditWndProc() */
  277. /****************************************************************************/
  278. LONG FAR PASCAL EditWndProc(HWND, WORD, register WORD, LONG);
  279. #ifdef FE_SB
  280. /****************************************************************************/
  281. /* DBCS Support Routines */
  282. /****************************************************************************/
  283. int FAR PASCAL DBCSCombine( HWND, int );
  284. ICH FAR PASCAL ECAdjustIch( PED, LPSTR, ICH );
  285. VOID FAR PASCAL ECGetDBCSVector( PED );
  286. LPSTR FAR PASCAL ECAnsiNext( PED, LPSTR );
  287. LPSTR FAR PASCAL ECAnsiPrev( PED, LPSTR, LPSTR );
  288. BOOL FAR PASCAL ECIsDBCSLeadByte( PED, BYTE );
  289. #endif