Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
SimpleLed.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Frameworks_Led_SimpleLed_h_
5#define _Stroika_Frameworks_Led_SimpleLed_h_ 1
6
7/*
8@MODULE: SimpleLed
9@DESCRIPTION:
10 <p>Simple wrappers on the word processing classes and line editing classes to make it a bit easier to
11 instantiate a Led editor. Using these has some costs - however - as it removes some opportunities to customize exactly
12 what you build into your Led-based editor. Still - its a very helpful way to get started using Led.</p>
13 */
14
15#if !defined(__PowerPlant__) && !defined(_MFC_VER) && !defined(_WIN32)
16#error "This file provides a simple to use wrapper on one of the above class libraries"
17#error "But you don't seem to be using any of them. Be sure to set the proper defines"
18#error "if you ARE in fact using one of the supported class libraries."
19#endif
20
21#include "Stroika/Frameworks/StroikaPreComp.h"
22
23#include "ChunkedArrayTextStore.h"
24#include "Command.h"
25#include "SimpleTextInteractor.h"
26#include "WordProcessor.h"
27
28#if defined(__PowerPlant__)
29#include "Led_PP.h"
30#elif defined(_MFC_VER)
31#include "Led_MFC.h"
32#include "Led_MFC_WordProcessor.h"
33#elif defined(_WIN32)
34#include "Platform/Windows.h"
35#endif
36
37#include "WordProcessor.h"
38
39namespace Stroika::Frameworks::Led {
40
41 DISABLE_COMPILER_MSC_WARNING_START (4250) // inherits via dominance warning
42 /*
43 @CLASS: SimpleLedWordProcessor
44 @BASES: @'Led_MFC', @'Led_PP', @'WordProcessor'
45 @DESCRIPTION: <p>Led is a concrete editor class. You can directly instantiate and use this one.
46 Or mix and match various component classes to make your own editor with the features
47 you need. This is really only intended for use as a 'quick start' to using Led. You will probably
48 want to directly use the base classes of Led, or various other components directly, once you get
49 the hang of using Led.</p>
50 <P>NB: if you are using PowerPlant, be sure to somehow arrange for "PP_Prefix.h" to be included before
51 this file is (since thats where __PowerPlant__ is defined). Typically this will be done via the precompiled
52 header prefix file.</p>
53 */
54 class SimpleLedWordProcessor
55#if defined(__PowerPlant__)
56 : public Led_PPView_X<WordProcessor, Led_PPView_Traits_Default>
57#elif defined(_MFC_VER)
58 : public Led_MFC_X<WordProcessor>
59#elif defined(_WIN32)
60 : public Platform::Led_Win32_SimpleWndProc_Helper<Platform::Led_Win32_Helper<WordProcessor>>
61#endif
62 {
63 private:
64#if defined(__PowerPlant__)
65 using inherited = Led_PPView_X<WordProcessor, Led_PPView_Traits_Default>;
66#elif defined(_MFC_VER)
67 using inherited = Led_MFC_X<WordProcessor>;
68#elif defined(_WIN32)
69 using inherited = Platform::Led_Win32_SimpleWndProc_Helper<Platform::Led_Win32_Helper<WordProcessor>>;
70#endif
71 public:
72 SimpleLedWordProcessor ();
73 ~SimpleLedWordProcessor ();
74
75#if qCannotSafelyCallLotsOfComplexVirtMethodCallsInsideCTORDTOR
76 public:
77#if defined(_MFC_VER)
78 virtual void OnInitialUpdate () override;
79 virtual void PostNcDestroy () override;
80#elif defined(_WIN32)
81 virtual LRESULT OnCreate_Msg (LPCREATESTRUCT createStruct) override;
82 virtual void OnNCDestroy_Msg () override;
83#endif
84#endif
85
86 private:
87 enum {
88 kMaxUndoLevels = 5
89 };
90 ChunkedArrayTextStore fTextStore;
91 MultiLevelUndoCommandHandler fCommandHandler;
92
93#if defined(_MFC_VER)
94 protected:
95 DECLARE_MESSAGE_MAP ()
96 DECLARE_DYNCREATE (SimpleLedWordProcessor)
97#endif
98 };
99
100 DISABLE_COMPILER_MSC_WARNING_END (4250)
101
102 DISABLE_COMPILER_MSC_WARNING_START (4250) // inherits via dominance warning
103 /*
104 @CLASS: SimpleLedLineEditor
105 @BASES: @'Led_MFC', @'Led_PP', @'SimpleTextInteractor'
106 @DESCRIPTION: <p>Led is a concrete editor class. You can directly instantiate and use this one.
107 Or mix and match various component classes to make your own editor with the features
108 you need. This is really only intended for use as a 'quick start' to using Led. You will probably
109 want to directly use the base classes of Led, or various other components directly, once you get
110 the hang of using Led.</p>
111 <P>NB: if you are using PowerPlant, be sure to somehow arrange for "PP_Prefix.h" to be included before
112 this file is (since thats where __PowerPlant__ is defined). Typically this will be done via the precompiled
113 header prefix file.</p>
114 */
115 class SimpleLedLineEditor
116#if defined(__PowerPlant__)
117 : public Led_PPView_X<SimpleTextInteractor, Led_PPView_Traits_Default>
118#elif defined(_MFC_VER)
119 : public Led_MFC_X<SimpleTextInteractor>
120#elif defined(_WIN32)
121 : public Platform::Led_Win32_SimpleWndProc_Helper<Platform::Led_Win32_Helper<SimpleTextInteractor>>
122#endif
123 {
124 private:
125#if defined(__PowerPlant__)
126 using inherited = Led_PPView_X<SimpleTextInteractor, Led_PPView_Traits_Default>;
127#elif defined(_MFC_VER)
128 using inherited = Led_MFC_X<SimpleTextInteractor>;
129#elif defined(_WIN32)
130 using inherited = Platform::Led_Win32_SimpleWndProc_Helper<Platform::Led_Win32_Helper<SimpleTextInteractor>>;
131#endif
132 public:
133 SimpleLedLineEditor ();
134 ~SimpleLedLineEditor ();
135
136#if qCannotSafelyCallLotsOfComplexVirtMethodCallsInsideCTORDTOR
137 public:
138#if defined(_MFC_VER)
139 virtual void OnInitialUpdate () override;
140 virtual void PostNcDestroy () override;
141#elif defined(_WIN32)
142 virtual LRESULT OnCreate_Msg (LPCREATESTRUCT createStruct) override;
143 virtual void OnNCDestroy_Msg () override;
144#endif
145#endif
146
147 private:
148 enum {
149 kMaxUndoLevels = 5
150 };
151 ChunkedArrayTextStore fTextStore;
152 MultiLevelUndoCommandHandler fCommandHandler;
153
154#if defined(_MFC_VER)
155 protected:
156 DECLARE_MESSAGE_MAP ()
157 DECLARE_DYNCREATE (SimpleLedLineEditor)
158#endif
159 };
160 DISABLE_COMPILER_MSC_WARNING_END (4250)
161
162 DISABLE_COMPILER_MSC_WARNING_START (4250) // inherits via dominance warning
163 /*
164 @CLASS: LedDialogText
165 @BASES: @'SimpleLedWordProcessor'
166 @DESCRIPTION: <p>Very similar to class @'Led'. But with a few class-library-specific twists to make it easier
167 to embed the Led view into a dialog. Not really needed. But if you are having trouble getting your Led-based
168 view working in a dialog, you may want to try, or at least look at this code.</p>
169 <p>PROBABLY SHOULD RE-IMPLEMENT THIS to be more like a textedit box. Make WordWrap optional. For MFC - use
170 CWND instead of CView. Actually TEST it and make clear where/why its useful (UNICODE for one thing).
171 </p>
172 */
173 class LedDialogText : public SimpleLedWordProcessor {
174 private:
175 using inherited = SimpleLedWordProcessor;
176
177 public:
178 LedDialogText ();
179
180#if qStroika_Foundation_Common_Platform_Windows && defined(_MFC_VER)
181 public:
182 virtual void PostNcDestroy () override;
183 virtual int OnMouseActivate (CWnd* pDesktopWnd, UINT nHitTest, UINT message) override;
184#endif
185
186#if qStroika_Foundation_Common_Platform_Windows && defined(_MFC_VER)
187 protected:
188 DECLARE_MESSAGE_MAP ()
189 DECLARE_DYNCREATE (LedDialogText)
190#endif
191 };
192 DISABLE_COMPILER_MSC_WARNING_END (4250)
193
194}
195
196/*
197 ********************************************************************************
198 ***************************** Implementation Details ***************************
199 ********************************************************************************
200 */
201#include "SimpleLed.inl"
202
203#endif /*_Stroika_Frameworks_Led_SimpleLed_h_*/