00001 #ifndef GENERATING_DOXYGEN_OUTPUT
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef INC_MGUI_COLOREDW_H
00052 #define INC_MGUI_COLOREDW_H
00053
00054
00055
00056
00057
00058
00059
00060 #if !defined(_COLORIZED_VIEW_) && defined(WIN32_MFC)
00061 #define _COLORIZED_VIEW_
00062
00063 #include <mgui/colorizr.h>
00064 #include <mgui/scripttx.h>
00065 #include <mgui/undofram.h>
00066
00067 class ColorEditWnd : public CWnd
00068 {
00069
00070 public:
00071
00072 DECLARE_DYNAMIC(ColorEditWnd);
00073
00074 ColorEditWnd();
00075
00076 ColorEditWnd(CWnd * parent,
00077 const CRect & rect,
00078 int nID,
00079
00080
00081 int iTabSize,
00082 int iFontSize,
00083 const CString& csFontName);
00084
00085
00086 void Create(CWnd * parent,
00087 const CRect & rect,
00088 int nID,
00089
00090
00091 int iTabSize,
00092 int iFontSize,
00093 const CString& csFontName);
00094
00095
00096
00097
00098
00099 void UseKeyboardAccelerators(bool b) {m_bUseKBAccel = b;}
00100
00101 public:
00102
00103
00104 void Reset();
00105
00106
00107
00108 void LoadText(const char *pInText);
00109
00110
00111 void UnloadText(CString &pText) const;
00112
00113
00114
00115 _inline int GetLineCount() {return GetTextSize();}
00116
00117
00118
00119
00120 void SetCursorPos(CPoint pos);
00121 void SetAnchorPos(CPoint pos);
00122
00123 _inline CPoint GetCursorPos() {return CursorPos();}
00124 _inline CPoint GetAnchorPos() {return AnchorPos();}
00125
00126
00127 void SetSelection(int charPos1, int line1, int charPos2, int line2);
00128 void ReplaceSelText(const char *pText);
00129
00130
00131 void ScrollToLine(int iLine);
00132
00133
00134 void ScrollToCursor();
00135
00136
00137 CString GetLine(int iLine) const {return GetTextLine(iLine);}
00138
00139
00140 void SetLine(const char *pText, int iLine);
00141
00142
00143
00144 CRect GetLineRect(int iLine) const;
00145
00146
00147 CRect GetLineRect(int iLine1, int iLine2) const;
00148
00149
00150 int VisibleLines() const;
00151
00152
00153 int LastVisibleLine() const;
00154 int FirstVisibleLine() const;
00155
00156
00157 int VisibleColumns() const;
00158
00159
00160
00161
00162
00163 void DoCut();
00164
00165
00166 void DoCopy();
00167
00168
00169 void DoPaste();
00170
00171
00172 void DoUndo();
00173
00174
00175 void DoRedo();
00176
00177
00178 void SetCharXSpacing(int i);
00179
00180
00181 void SetCharYSpacing(int i);
00182
00183
00184
00185
00186 void SetColorizer(CColorizer * pColorizer);
00187
00188
00189 void SetBackgroundColor(COLORREF clr);
00190 void SetHighlightColor(COLORREF clr);
00191 void SetHighlightTextColor(COLORREF clr);
00192
00193
00194 void SetReadOnly(bool b) {m_bReadOnly = b;}
00195
00196 void ClearUndoHistory();
00197
00198 public:
00199 virtual ~ColorEditWnd();
00200
00201 private:
00202 #ifndef GENERATING_DOXYGEN_OUTPUT
00203
00204 void ClipAnchorPosition(int &x, int &y);
00205 void ClipCursorPosition(int &x, int &y);
00206 void ClipAnchorPosition(CPoint &p);
00207 void ClipCursorPosition(CPoint &p);
00208
00209
00210 _inline void _SetAnchorPosX(int x) {m_anchorPos.x = x;}
00211 _inline void _SetAnchorPosY(int y) {m_anchorPos.y = y;}
00212 _inline void _SetAnchorPos(CPoint pt) {m_anchorPos = pt;}
00213 _inline void _SetAnchorPos(int x, int y) {m_anchorPos.x = x; m_anchorPos.y = y;}
00214
00215
00216 _inline void _SetCursorPosX(int x) {m_cursorPos.x = x;}
00217 _inline void _SetCursorPosY(int y) {m_cursorPos.y = y;}
00218 _inline void _SetCursorPos(CPoint pt) {m_cursorPos = pt;}
00219 _inline void _SetCursorPos(int x, int y) {m_cursorPos.x= x; m_cursorPos.y = y;}
00220
00221 _inline CPoint CursorPos() const {return m_cursorPos;}
00222 _inline int CursorPosX() const {return m_cursorPos.x;}
00223 _inline int CursorPosY() const {return m_cursorPos.y;}
00224
00225 _inline CPoint AnchorPos() const {return m_anchorPos;}
00226 _inline int AnchorPosX() const {return m_anchorPos.x;}
00227 _inline int AnchorPosY() const {return m_anchorPos.y;}
00228
00229
00230 _inline int GetTextSize() const {return m_text._GetSize();}
00231
00232
00233 _inline CString GetTextLine(int i) const {return m_text._GetLine(i);}
00234
00235
00236
00237
00238 void InsertTextLine(const CString &line,
00239 int i,
00240 bool bUpdate=TRUE,
00241 bool bNoUndo = false);
00242
00243
00244 void InsertText(CString &pString);
00245
00246
00247 void InsertChar(int pChar, bool pUpdate = TRUE);
00248
00249
00250 void InsertString(CString &pString, bool pUpdate = TRUE);
00251
00252
00253 void InsertTab();
00254
00255
00256 void SetTextLine(const CString &line, int i, bool bNoUndo = false, bool pUpdate = TRUE);
00257
00258
00259 void RemoveTextLine(int i, bool bNoUndo = false, bool pUpdate = TRUE);
00260
00261
00262 void RemoveAllText();
00263
00264 void _ReplaceSelText(const char *pText);
00265
00266 CString MakeTab(int iCursorXPos) const;
00267
00268
00269 void DeleteNextChar();
00270 void DeletePrevChar();
00271
00272
00273 void DoEnter();
00274
00275
00276 bool IsSelected(int pX,int pY);
00277 bool Selected();
00278 void UpdateAnchor(bool pTestShift);
00279 void RemoveSelected();
00280
00281
00282 void UpdateScrollSizes();
00283
00284 CPoint GetDeviceScrollPosition() const;
00285 CPoint GetScrollPosition() const;
00286
00287
00288 void DrawCurrentLine();
00289 void DrawLine(int pLine);
00290 CPoint DrawLine(CDC *pDC, const CString &line, int lineidx, int y);
00291 void DrawCursor(CDC * pDC, bool pShow);
00292 void DrawCursor(bool pShow);
00293
00294 void ShiftDisplay(int dx, int dy);
00295
00296
00297
00298 void StartUndoFrame();
00299 void EndUndoFrame();
00300 void ClearUndoStack(undostack &inStack);
00301 void DoUndoRedo(undostack &inStack, undostack& outStack);
00302
00303 void StartAction();
00304 void EndAction();
00305
00306
00307 void NotifyParent(UINT msg);
00308
00309
00310 int m_iCharDX;
00311 int m_iCharDY;
00312 int m_iTabSize;
00313 HCURSOR m_cursor;
00314 CFont cfont;
00315
00316
00317 long m_iFirstCharacter;
00318 long m_iFirstLine;
00319
00320
00321 CPoint m_anchorPos;
00322 CPoint m_cursorPos;
00323
00324
00325 COLORREF m_backgroundColor;
00326 COLORREF m_hilightColor;
00327 COLORREF m_hilightTextColor;
00328
00329
00330 CScriptText m_text;
00331
00332 bool m_bMaintainIndent;
00333
00334 bool m_bIsSelected;
00335 bool m_bLBDown;
00336 bool m_bCaretOn;
00337 CPoint m_startPointDrag;
00338 bool m_bUseKBAccel;
00339
00340
00341
00342
00343
00344
00345
00346 CUndoFrame m_currentUndoFrame;
00347
00348
00349 undostack m_undoStack;
00350
00351
00352
00353 undostack m_redoStack;
00354
00355 UINT m_ID;
00356
00357 bool m_bReadOnly;
00358 public:
00359
00360
00361 public:
00362 virtual BOOL PreTranslateMessage(MSG* pMsg);
00363
00364
00365
00366 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
00367 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
00368 afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
00369 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00370 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
00371 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00372 afx_msg void OnPaint();
00373 afx_msg void OnSize(UINT nType, int cx, int cy);
00374 afx_msg UINT OnGetDlgCode();
00375 afx_msg void OnVScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar );
00376 afx_msg void OnHScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar );
00377 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
00378 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
00379 afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
00380 afx_msg BOOL OnMouseWheel( UINT nFlags, short zDelta, CPoint pt );
00381 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
00382 afx_msg void OnUpdateCopy(CCmdUI* pCmdUI);
00383 afx_msg void OnUpdateCut(CCmdUI* pCmdUI);
00384 afx_msg void OnUpdatePaste(CCmdUI* pCmdUI);
00385 afx_msg void OnUpdateSelectall(CCmdUI* pCmdUI);
00386 afx_msg void OnUpdateUndo(CCmdUI* pCmdUI);
00387 afx_msg void OnUpdateRedo(CCmdUI* pCmdUI);
00388 afx_msg void OnCopy();
00389 afx_msg void OnCut();
00390 afx_msg void OnPaste();
00391 afx_msg void OnSelectall();
00392 afx_msg void OnUndo();
00393 afx_msg void OnRedo();
00394 afx_msg void OnKillFocus(CWnd* pNewWnd);
00395 afx_msg void OnSetFocus( CWnd* pOldWnd );
00396 afx_msg void OnLButtonDblClk( UINT, CPoint );
00397
00398 DECLARE_MESSAGE_MAP()
00399 #endif
00400 };
00401
00402
00403
00404 #endif
00405 #endif
00406
00407 #endif