Stroika Library 3.0d18
 
Loading...
Searching...
No Matches
ActiveLedIt/Sources/LedItView.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef __LedItView_h__
5#define __LedItView_h__ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9DISABLE_COMPILER_MSC_WARNING_START (5054)
10#include <afxctl.h>
11DISABLE_COMPILER_MSC_WARNING_END (5054)
12
13#include <atlbase.h>
14
15#include "Stroika/Frameworks/Led/ChunkedArrayTextStore.h"
16#include "Stroika/Frameworks/Led/Platform/MFC_WordProcessor.h"
17#include "Stroika/Frameworks/Led/WordProcessor.h"
18
19#include "ActiveLedItConfig.h"
20#include "Resource.h"
21
22using namespace Stroika::Foundation;
23using namespace Stroika::Frameworks::Led;
24using namespace Stroika::Frameworks::Led::Platform;
25
26class LedItViewController {
27public:
28 LedItViewController ();
29 virtual ~LedItViewController () = default;
30
31public:
32 virtual void OnBrowseHelpCommand () = 0;
33 virtual void OnAboutBoxCommand () = 0;
34 virtual void ForceUIActive () = 0;
35 virtual void FireOLEEvent (DISPID eventID) = 0;
36 virtual void FireOLEEvent (DISPID dispid, BYTE* pbParams, ...) = 0;
37#if qFunnyDisplayInDesignMode
38 virtual bool IsInDesignMode () const = 0;
39 virtual bool DrawExtraDesignModeBorder () const = 0;
40#endif
41 virtual HMENU GenerateContextMenu () = 0;
42
43public:
44 nonvirtual void FireKeyDown (USHORT* pnChar, short nShiftState);
45 nonvirtual void FireKeyUp (USHORT* pnChar, short nShiftState);
46 nonvirtual void FireKeyPress (USHORT* pnChar);
47 nonvirtual void FireMouseDown (short nButton, short nShiftState, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y);
48 nonvirtual void FireMouseUp (short nButton, short nShiftState, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y);
49 nonvirtual void FireMouseMove (short nButton, short nShiftState, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y);
50 nonvirtual void FireClick ();
51 nonvirtual void FireDblClick ();
52 virtual void FireUpdateUserCommand (const wstring& internalCmdName, VARIANT_BOOL* enabled, VARIANT_BOOL* checked, wstring* name) = 0;
53 virtual void FireUserCommand (const wstring& internalCmdName) = 0;
54
55public:
56 ChunkedArrayTextStore fTextStore;
57 MultiLevelUndoCommandHandler fCommandHandler;
58 shared_ptr<HidableTextMarkerOwner> fHidableTextDatabase;
59};
60
61using LedItViewAlmostBASE = Led_MFC_ExceptionHandlerHelper<Led_MFC_X<WordProcessor>>;
62
63DISABLE_COMPILER_MSC_WARNING_START (4250) // inherits via dominance warning
64
65class LedItView : public WordProcessorCommonCommandHelper_MFC<LedItViewAlmostBASE> {
66private:
67 using inherited = WordProcessorCommonCommandHelper_MFC<LedItViewAlmostBASE>;
68
69public:
70 LedItView ();
71
72public:
73 nonvirtual void SetController (LedItViewController* controller);
74
75private:
76 LedItViewController* fController;
77
78public:
79 virtual ~LedItView ();
80
81public:
82 nonvirtual bool GetSupportContextMenu () const;
83 nonvirtual void SetSupportContextMenu (bool allowContextMenu);
84
85private:
86 bool fSupportContextMenu;
87
88public:
89 nonvirtual bool GetHideDisabledContextMenuItems () const;
90 nonvirtual void SetHideDisabledContextMenuItems (bool hideDisabledContextMenuItems);
91
92private:
93 bool fHideDisabledContextMenuItems;
94
95public:
96 nonvirtual bool GetWrapToWindow () const;
97 nonvirtual void SetWrapToWindow (bool wrapToWindow);
98
99private:
100 bool fWrapToWindow;
101
102public:
103 nonvirtual long GetMaxLength () const;
104 nonvirtual void SetMaxLength (long maxLength);
105
106private:
107 long fMaxLength;
108
109public:
110 virtual void GetLayoutMargins (RowReference row, CoordinateType* lhs, CoordinateType* rhs) const override;
111 virtual void SetWindowRect (const Led_Rect& windowRect) override;
112
113public:
114 nonvirtual DistanceType CalculateFarthestRightMarginInWindow () const;
115
116protected:
117 afx_msg int OnMouseActivate (CWnd* pDesktopWnd, UINT nHitTest, UINT message);
118
119public:
120 virtual void PostNcDestroy () override;
121 afx_msg void OnInitMenuPopup (CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
122 afx_msg void OnContextMenu (CWnd* /*pWnd*/, CPoint /*point*/);
123
124 // Reflect events (call FireEvent) for these events. Must be done here cuz COleControl code for same doesn't
125 // work cuz our focus (LedItView) isn't the same as the COleControl).
126public:
127 afx_msg void OnSysKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags);
128 afx_msg void OnSysKeyUp (UINT nChar, UINT nRepCnt, UINT nFlags);
129 afx_msg void OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags);
130 afx_msg void OnKeyUp (UINT nChar, UINT nRepCnt, UINT nFlags);
131 virtual void OnTypedNormalCharacter (Led_tChar theChar, bool optionPressed, bool shiftPressed, bool commandPressed, bool controlPressed,
132 bool altKeyPressed) override;
133 afx_msg void OnLButtonDown (UINT nFlags, CPoint oPoint);
134 afx_msg void OnLButtonUp (UINT nFlags, CPoint oPoint);
135 afx_msg void OnLButtonDblClk (UINT nFlags, CPoint oPoint);
136 afx_msg void OnRButtonDown (UINT nFlags, CPoint oPoint);
137 afx_msg void OnRButtonUp (UINT nFlags, CPoint oPoint);
138 afx_msg void OnMouseMove (UINT nFlags, CPoint oPoint);
139
140public:
141 afx_msg void OnPasteAsTextCommand ();
142 afx_msg void OnUpdatePasteAsTextCommand (CCmdUI* pCmdUI);
143
144public:
145 afx_msg void OnOLEUserCommand (UINT nID);
146 afx_msg void OnUpdateOLEUserCommand (CCmdUI* pCmdUI);
147
148protected:
149 virtual SearchParameters GetSearchParameters () const override;
150 virtual void SetSearchParameters (const SearchParameters& sp) override;
151
152public:
153 virtual void SetSelection (size_t start, size_t end) override;
154 using TextInteractor::SetSelection;
155
156protected:
157 virtual void AboutToUpdateText (const UpdateInfo& updateInfo) override;
158
159public:
160 virtual void EraseBackground (Tablet* tablet, const Led_Rect& subsetToDraw, bool printing) override;
161
162public:
163 bool fEnableAutoChangesBackgroundColor;
164
165public:
166 nonvirtual long OLE_FindReplace (long searchFrom, const Led_tString& findText, const Led_tString& replaceText, BOOL wrapSearch,
167 BOOL wholeWordSearch, BOOL caseSensativeSearch);
168
169public:
170 bool fInDrawMetaFileMode;
171
172public:
173 nonvirtual void UpdateScrollBars ();
174
175protected:
176 afx_msg void OnBrowseHelpCommand ();
177 afx_msg void OnCheckForUpdatesWebPageCommand ();
178 afx_msg void OnAboutBoxCommand ();
179
180public:
181 afx_msg void OnFilePrintOnce ();
182 afx_msg void OnFilePrint ();
183 afx_msg void OnFilePrintSetup ();
184
185private:
186 nonvirtual void DoPrintHelper (bool showPrintDlg);
187
188 DECLARE_MESSAGE_MAP ()
189
190#ifdef _DEBUG
191public:
192 virtual void AssertValid () const override;
193 virtual void Dump (CDumpContext& dc) const override;
194#endif
195};
196DISABLE_COMPILER_MSC_WARNING_END (4250) // inherits via dominance warning
197
198/*
199 ********************************************************************************
200 ***************************** Implementation Details ***************************
201 ********************************************************************************
202 */
203
204// class LedItViewController
205inline void LedItViewController::FireKeyDown (USHORT* pnChar, short nShiftState)
206{
207 FireOLEEvent (DISPID_KEYDOWN, EVENT_PARAM (VTS_PI2 VTS_I2), pnChar, nShiftState);
208}
209inline void LedItViewController::FireKeyUp (USHORT* pnChar, short nShiftState)
210{
211 FireOLEEvent (DISPID_KEYUP, EVENT_PARAM (VTS_PI2 VTS_I2), pnChar, nShiftState);
212}
213inline void LedItViewController::FireKeyPress (USHORT* pnChar)
214{
215 FireOLEEvent (DISPID_KEYPRESS, EVENT_PARAM (VTS_PI2), pnChar);
216}
217inline void LedItViewController::FireMouseDown (short nButton, short nShiftState, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y)
218{
219 FireOLEEvent (DISPID_MOUSEDOWN, EVENT_PARAM (VTS_I2 VTS_I2 VTS_XPOS_PIXELS VTS_YPOS_PIXELS), nButton, nShiftState, x, y);
220}
221inline void LedItViewController::FireMouseUp (short nButton, short nShiftState, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y)
222{
223 FireOLEEvent (DISPID_MOUSEUP, EVENT_PARAM (VTS_I2 VTS_I2 VTS_XPOS_PIXELS VTS_YPOS_PIXELS), nButton, nShiftState, x, y);
224}
225inline void LedItViewController::FireMouseMove (short nButton, short nShiftState, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y)
226{
227 FireOLEEvent (DISPID_MOUSEMOVE, EVENT_PARAM (VTS_I2 VTS_I2 VTS_XPOS_PIXELS VTS_YPOS_PIXELS), nButton, nShiftState, x, y);
228}
229inline void LedItViewController::FireClick ()
230{
231 FireOLEEvent (DISPID_CLICK, EVENT_PARAM (VTS_NONE));
232}
233inline void LedItViewController::FireDblClick ()
234{
235 FireOLEEvent (DISPID_DBLCLICK, EVENT_PARAM (VTS_NONE));
236}
237
238// class LedItView
239inline bool LedItView::GetWrapToWindow () const
240{
241 return fWrapToWindow;
242}
243inline bool LedItView::GetSupportContextMenu () const
244{
245 return fSupportContextMenu;
246}
247inline bool LedItView::GetHideDisabledContextMenuItems () const
248{
249 return fHideDisabledContextMenuItems;
250}
251inline long LedItView::GetMaxLength () const
252{
253 return fMaxLength;
254}
255
256#endif /*__LedItView_h__*/