3 /////////////////////////////////////////////////////////////////////////////
5 // Copyright (c) 2002 David Ward
7 /////////////////////////////////////////////////////////////////////////////
12 #define _ATL_APARTMENT_THREADED
15 //You may derive a class from CComModule and use it if you want to override something,
17 //but do not change the name of _Module
19 extern CComModule _Module
;
23 #include "../AppSettings.h"
24 #include "../DasherAction.h"
25 #include "../../DasherCore/DasherTypes.h"
33 class CDasherInterfaceBase
;
49 class CEdit
: public ATL::CWindowImpl
<CEdit
>
53 CEdit(CAppSettings
*pAppSettings
);
56 HWND
Create(HWND hParent
, bool bNewWithDate
);
58 // Superclass the built-in EDIT window class
59 DECLARE_WND_SUPERCLASS(NULL
, _T("EDIT") )
61 BEGIN_MSG_MAP( CEdit
)
62 MESSAGE_HANDLER(WM_LBUTTONDOWN
, OnLButtonDown
)
63 MESSAGE_HANDLER(WM_LBUTTONUP
, OnLButtonUp
)
64 MESSAGE_HANDLER(WM_CHAR
, OnChar
)
65 MESSAGE_HANDLER(WM_KEYDOWN
, OnKeyDown
)
66 MESSAGE_HANDLER(WM_KEYUP
, OnKeyUp
)
67 MESSAGE_HANDLER(WM_COMMAND
, OnCommand
)
71 HRESULT
OnLButtonDown(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
);
72 HRESULT
OnLButtonUp(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
);
73 HRESULT
OnChar(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
);
74 HRESULT
OnKeyDown(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
);
75 HRESULT
OnKeyUp(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
);
76 HRESULT
OnCommand(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
);
79 void Move(int x
, int y
, int Width
, int Height
);
85 // As EN_UPDATE message go to parent, need this. void UserSave(HANDLE FileHandle);
86 void UserOpen(HANDLE FileHandle
);
88 void Move(int iDirection
, int iDist
);
89 void Delete(int iDirection
, int iDist
);
90 void SetKeyboardTarget(HWND hwnd
);
92 // Overriding file virtual functions
93 //void TimeStampNewFiles(bool Value);
94 void New(const std::string
& filename
);
95 bool Open(const std::string
& filename
);
96 bool OpenAppendMode(const std::string
& filename
);
97 bool SaveAs(const std::string
& filename
);
99 // Functions for Windows GUI to call
102 void OpenAppendMode();
104 std::string
Import();
105 void SetDirty(); // Parent window gets notification Edit window has changed.
114 void SetEncoding(Dasher::Opts::FileEncodingFormats Encoding
);
115 void SetFont(std::string Name
, long Size
);
117 void SetInterface(Dasher::CDasherInterfaceBase
* DasherInterface
);
119 // write some buffered output to file
120 void write_to_file();
122 // get the context from the current cursor position with max history
123 void get_new_context(std::string
& str
, int max
);
125 // called when characters fall of the LHS of the screen
126 void output(const std::string
& sText
);
130 // remove the previous character
132 void deletetext(const std::string
& sText
);
135 void speak(int what
);
138 //void SetEditCanvas(CCanvas* canvas) {Canvas=canvas;}
140 void SetNewWithDate(bool bNewWithDate
);
142 void HandleEvent(Dasher::CEvent
*pEvent
);
146 LRESULT
WndProc(HWND Window
, UINT message
, WPARAM wParam
, LPARAM lParam
);
149 void HandleEditEvent(Dasher::CEvent
*pEvent
);
152 Dasher::CDasherInterfaceBase
*m_pDasherInterface
;
158 bool m_bForwardKeyboard
;
160 HANDLE FileHandle
; // Keeping a lock on files makes File I/O safer,
161 // especially for the append mode!
162 CFilenameGUI
*m_FilenameGUI
;
166 void TNew(const Tstring
& filename
);
167 bool TOpen(const Tstring
& filename
);
168 bool TOpenAppendMode(const Tstring
& filename
);
169 bool TSaveAs(const Tstring
& filename
);
172 std::string m_FontName
;
175 std::string m_Output
; // UTF-8 to go to training file
176 UINT CodePage
; // for font and possible for finding the encoding
177 Dasher::Opts::FileEncodingFormats m_Encoding
; // file encoding option (may say to use codepage or user setting)
191 void InsertText(Tstring InsertText
); // add symbol to edit control
193 CAppSettings
*m_pAppSettings
;
198 CDasherAction
*m_pActionSpeech
;
202 #endif /* #ifndef __Edit_h__ */