1 
2 #ifndef _RICH_TEXT_EDIT_DLG_
3 #define _RICH_TEXT_EDIT_DLG_
4 #include "afxcmn.h"
5 
6 // rich_text_edit_dlg dialog
7 
8 class custom_rich_edit: public CRichEditCtrl
9 {
10 public:
11     custom_rich_edit();
~custom_rich_edit()12     ~custom_rich_edit() {};
13 
14 
15 public:
16     DECLARE_MESSAGE_MAP()
17     afx_msg void OnKillFocus(CWnd* pNewWnd);
18     afx_msg void OnSetFocus(CWnd* pOldWnd);
19 
20 private:
21     long mSelStart;
22     long mSelEnd;
23 };
24 
25 class text_edit_button_frame : public CWnd
26 {
27 public:
28     text_edit_button_frame(widget_info *info, CWnd *pParent);
29     ~text_edit_button_frame();
30 
31     afx_msg BOOL OnEraseBkgnd(CDC* pDC);
32     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
33     afx_msg void OnSize(UINT nType, int cx, int cy);
34     afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
35 
36     afx_msg void OnClickBold();
37     afx_msg void OnClickItalic();
38     afx_msg void OnClickUnderline();
39     afx_msg void OnClickLeftAlign();
40     afx_msg void OnClickCenterAlign();
41     afx_msg void OnClickRightAlign();
42     afx_msg void OnClickHighlightColor();
43     afx_msg void OnClickTextColor();
44     afx_msg void OnChangeFont();
45     afx_msg void OnChangeTextColor();
46     afx_msg void OnChangeHighlightColor();
47 
48 protected:
49     DECLARE_MESSAGE_MAP()
50 
51 private:
52     CString InitResList(CComboBox *box, int res_type, int sel_res_id);
53 
54 private:
55     custom_bitmap_button mBtnBold;
56     custom_bitmap_button mBtnItalic;
57     custom_bitmap_button mBtnUnderline;
58     custom_bitmap_button mBtnLeftAlign;
59     custom_bitmap_button mBtnCenterAlign;
60     custom_bitmap_button mBtnRightAlign;
61     express_combobox mFontBox;
62     express_combobox mHighlightColorBox;
63     express_combobox mTextColorBox;
64     CStatic mFontLable;
65     CStatic mHighlightColorLable;
66     CStatic mTextColorLable;
67     color_box_button mHighlightColorButton;
68     color_box_button mTextColorButton;
69     CString mHighlightColorName;
70     CString mTextColorName;
71     CString mFontName;
72 
73     int mLableWidth;
74     int mColorButtonWidth;
75     widget_info* mpInfo;
76 };
77 
78 class rich_text_preview_win : public CWnd
79 {
80 public:
81     rich_text_preview_win(widget_info *info, CWnd *parent);
82     ~rich_text_preview_win();
83 
84 public:
85     DECLARE_MESSAGE_MAP()
86     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
87     afx_msg void OnSize(UINT nType, int cx, int cy);
88     afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
89     afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
90     afx_msg void OnPaint();
91 
92 public:
93     void CreateDisplay();
94     void MakeWidgetPreview();
95     void DeleteWidgetString();
96     void UpdateRichText(CString &richtext);
97 
98 protected:
99     CScrollHelper *m_scroll_helper;
100     GX_DISPLAY  *mpDisplay;
101     GX_WIDGET *mpWidget;
102     GX_CANVAS   *mpCanvas;
103     GX_WINDOW_ROOT *mpRoot;
104     UCHAR *mpMem;
105     widget_info *mpInfo;
106     GX_BMP_INFO  m_bitmap;
107 };
108 
109 class rich_text_edit_dlg : public express_dialog
110 {
111     DECLARE_DYNAMIC(rich_text_edit_dlg)
112 
113 public:
114     rich_text_edit_dlg(widget_info *info, CWnd* pParent = NULL);   // standard constructor
115     virtual ~rich_text_edit_dlg();
116 
117 // Dialog Data
118     enum { IDD = IDD_RICH_TEXT_EDIT_DLG };
119 
120 protected:
121     void PositionChildren();
122 
123     DECLARE_MESSAGE_MAP()
124 public:
125     virtual BOOL OnInitDialog();
126     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
127     afx_msg void OnSize(UINT nType, int cx, int cy);
128     afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
129 
130 public:
131     void RichEditInit();
132     void OnChangeRichText();
133     void InsertTag(CString& tag_start, CString& tag_end);
134     void SetSelectedBold();
135     void SetSelectedItalic();
136     void SetSelectedUnderline();
137     void SetSelectedLeftAlign();
138     void SetSelectedCenterAlign();
139     void SetSelectedRightAlign();
140     void SetSelectedHighlightColor(CString &id_name);
141     void SetSelectedTextColor(CString &id_name);
142     void SetSelectedFont(CString &id_name);
143     LRESULT OnTestMessage(WPARAM wParam, LPARAM lParam);
144 #if 0
145     void FormatRichText();
146 #endif
147     virtual BOOL PreTranslateMessage(MSG* pMsg);
148     virtual void OnOK();
149     COLORREF MakeColorRef(int color_id);
150 
151     CString GetText();
152 
153 private:
154     custom_rich_edit mRichEdit;
155 
156     text_edit_button_frame *mpButtonFrame;
157     rich_text_preview_win  *mpPreview;
158     widget_info *mpInfo;
159     studiox_project *mpProject;
160     int mDisplay;
161     palette_info mPalette;
162 
163     LOGFONT lf;
164 
165     int mMenubarHeight;
166     int mMinDlgWidth;
167     CString mText;
168 
169     IRichEditOle *mpIRich;
170     ITextDocument *mpIDoc;
171 };
172 
173 #endif
174