]> git.saurik.com Git - wxWidgets.git/blame - src/os2/textctrl.cpp
no message
[wxWidgets.git] / src / os2 / textctrl.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: textctrl.cpp
3// Purpose: wxTextCtrl
d90895ac 4// Author: David Webster
0e320a79 5// Modified by:
d90895ac 6// Created: 10/17/99
0e320a79 7// RCS-ID: $Id$
d90895ac
DW
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
d90895ac
DW
12// ----------------------------------------------------------------------------
13// headers
14// ----------------------------------------------------------------------------
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifndef WX_PRECOMP
20 #include "wx/textctrl.h"
19193a2c 21 #include "wx/scrolwin.h"
d90895ac
DW
22 #include "wx/settings.h"
23 #include "wx/brush.h"
24 #include "wx/utils.h"
25 #include "wx/log.h"
0e320a79
DW
26#endif
27
d90895ac
DW
28#if wxUSE_CLIPBOARD
29 #include "wx/app.h"
30 #include "wx/clipbrd.h"
31#endif
0e320a79 32
d90895ac
DW
33#include "wx/textfile.h"
34
35#include "wx/os2/private.h"
36
37#include <string.h>
38#include <stdlib.h>
39#include <sys/types.h>
0e320a79 40
d90895ac
DW
41#if wxUSE_IOSTREAMH
42# include <fstream.h>
0e320a79 43#else
d90895ac 44# include <fstream>
0e320a79
DW
45#endif
46
19193a2c 47#if !defined(MLE_INDEX)
a92d9721
SN
48#define MLE_INDEX 0
49#define MLE_RGB 1
50#endif
51
d90895ac
DW
52
53// ----------------------------------------------------------------------------
54// event tables and other macros
55// ----------------------------------------------------------------------------
56
0e320a79
DW
57IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
58
59BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
d90895ac
DW
60 EVT_CHAR(wxTextCtrl::OnChar)
61 EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
62
0e320a79
DW
63 EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
64 EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
65 EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
66 EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
67 EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
68
69 EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
70 EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
71 EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
72 EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
73 EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
74END_EVENT_TABLE()
0e320a79 75
d90895ac
DW
76
77// ============================================================================
78// implementation
79// ============================================================================
80
81// ----------------------------------------------------------------------------
82// creation
83// ----------------------------------------------------------------------------
84
0e320a79 85wxTextCtrl::wxTextCtrl()
0e320a79 86{
0e320a79
DW
87}
88
3bd418ca
DW
89bool wxTextCtrl::Create(
90 wxWindow* pParent
91, wxWindowID vId
92, const wxString& rsValue
93, const wxPoint& rPos
94, const wxSize& rSize
95, long lStyle
5d4b632b 96#if wxUSE_VALIDATORS
3bd418ca 97, const wxValidator& rValidator
5d4b632b 98#endif
3bd418ca
DW
99, const wxString& rsName
100)
101{
39c26ef2
DW
102 HWND hParent;
103 int nTempy;
3bd418ca
DW
104 //
105 // Base initialization
106 //
107 if ( !CreateBase( pParent
108 ,vId
109 ,rPos
110 ,rSize
111 ,lStyle
112#if wxUSE_VALIDATORS
113 ,rValidator
114#endif
115 ,rsName
116 ))
d90895ac 117 return FALSE;
0e320a79 118
45bfc84b 119 wxPoint vPos = rPos; // The OS/2 position
5d44b24e 120 SWP vSwp;
45bfc84b 121
3bd418ca 122 if (pParent )
45bfc84b 123 {
3bd418ca 124 pParent->AddChild(this);
45bfc84b 125 }
0e320a79 126
3bd418ca 127 m_windowStyle = lStyle;
d90895ac 128
3bd418ca
DW
129 long lSstyle = WS_VISIBLE | WS_TABSTOP;
130
131 //
132 // Single and multiline edit fields are two different controls in PM
133 //
d90895ac
DW
134 if ( m_windowStyle & wxTE_MULTILINE )
135 {
9c88ff79 136 lSstyle |= MLS_BORDER | MLS_WORDWRAP;
3bd418ca 137 m_bIsMLE = TRUE;
d90895ac 138
d90895ac 139 if ((m_windowStyle & wxTE_NO_VSCROLL) == 0)
3bd418ca
DW
140 lSstyle |= MLS_VSCROLL;
141 if (m_windowStyle & wxHSCROLL)
142 lSstyle |= MLS_HSCROLL;
143 if (m_windowStyle & wxTE_READONLY)
144 lSstyle |= MLS_READONLY;
d90895ac 145 }
0e320a79 146 else
3bd418ca 147 {
987da0d4 148 lSstyle |= ES_LEFT | ES_AUTOSCROLL | ES_MARGIN;
3bd418ca
DW
149
150 if (m_windowStyle & wxHSCROLL)
151 lSstyle |= ES_AUTOSCROLL;
152 if (m_windowStyle & wxTE_READONLY)
153 lSstyle |= ES_READONLY;
154 if (m_windowStyle & wxTE_PASSWORD) // hidden input
155 lSstyle |= ES_UNREADABLE;
156 }
5d44b24e 157
3bd418ca
DW
158 if (m_bIsMLE)
159 {
160 m_hWnd = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
161 ,WC_MLE // Window class
162 ,(PSZ)rsValue.c_str() // Initial Text
163 ,(ULONG)lSstyle // Style flags
716ed225
DW
164 ,(LONG)0 // X pos of origin
165 ,(LONG)0 // Y pos of origin
166 ,(LONG)0 // field width
167 ,(LONG)0 // field height
3bd418ca
DW
168 ,(HWND)GetHwndOf(pParent) // owner window handle (same as parent
169 ,HWND_TOP // initial z position
170 ,(ULONG)vId // Window identifier
171 ,NULL // no control data
172 ,NULL // no Presentation parameters
173 );
174 }
175 else
176 {
177 m_hWnd = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
178 ,WC_ENTRYFIELD // Window class
179 ,(PSZ)rsValue.c_str() // Initial Text
180 ,(ULONG)lSstyle // Style flags
716ed225
DW
181 ,(LONG)0 // X pos of origin
182 ,(LONG)0 // Y pos of origin
183 ,(LONG)0 // field width
184 ,(LONG)0 // field height
3bd418ca
DW
185 ,(HWND)GetHwndOf(pParent) // owner window handle (same as parent
186 ,HWND_TOP // initial z position
187 ,(ULONG)vId // Window identifier
188 ,NULL // no control data
189 ,NULL // no Presentation parameters
190 );
191 }
192
193 if (m_hWnd == 0)
194 {
195 return FALSE;
196 }
197
d90895ac
DW
198 SubclassWin(GetHWND());
199
3bd418ca
DW
200 //
201 // Set font, position, size and initial value
202 //
2c1e8f2e
DW
203 wxFont* pTextFont = new wxFont( 10
204 ,wxMODERN
205 ,wxNORMAL
206 ,wxNORMAL
207 );
208 SetFont(*pTextFont);
3bd418ca
DW
209 if (!rsValue.IsEmpty())
210 {
211 SetValue(rsValue);
212 }
213 SetupColours();
5d44b24e
DW
214 //
215 // If X and/or Y are not zero the difference is the compensation value
216 // for margins for OS/2 controls.
217 //
218 ::WinQueryWindowPos(m_hWnd, &vSwp);
219 SetXComp(vSwp.x);
220 SetYComp(vSwp.y);
39c26ef2
DW
221 SetSize( vPos.x
222 ,vPos.y
3bd418ca
DW
223 ,rSize.x
224 ,rSize.y
225 );
b3260bce 226 delete pTextFont;
0e320a79 227 return TRUE;
3bd418ca 228} // end of wxTextCtrl::Create
0e320a79 229
3bd418ca 230//
d90895ac 231// Make sure the window style (etc.) reflects the HWND style (roughly)
3bd418ca 232//
d90895ac
DW
233void wxTextCtrl::AdoptAttributesFromHWND()
234{
3bd418ca
DW
235 HWND hWnd = GetHwnd();
236 LONG lStyle = ::WinQueryWindowULong(hWnd, QWL_STYLE);
d90895ac 237
3bd418ca 238 wxWindow::AdoptAttributesFromHWND();
d90895ac 239
3bd418ca
DW
240 if (m_bIsMLE)
241 {
242 m_windowStyle |= wxTE_MULTILINE;
243 if (lStyle & MLS_READONLY)
244 m_windowStyle |= wxTE_READONLY;
245 }
246 else
247 {
248 if (lStyle & ES_UNREADABLE)
249 m_windowStyle |= wxTE_PASSWORD;
250 if (lStyle & ES_READONLY)
251 m_windowStyle |= wxTE_READONLY;
252 }
c4955899 253} // end of wxTextCtrl::AdoptAttributesFromHWND
d90895ac
DW
254
255void wxTextCtrl::SetupColours()
256{
c4955899
DW
257 wxColour vBkgndColour;
258
a756f210 259 vBkgndColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
c4955899 260 SetBackgroundColour(vBkgndColour);
d90895ac 261 SetForegroundColour(GetParent()->GetForegroundColour());
9c88ff79
DW
262 if (m_bIsMLE)
263 {
264 ::WinSendMsg( GetHwnd()
265 ,MLM_SETTEXTCOLOR
266 ,(MPARAM)GetParent()->GetForegroundColour().GetPixel()
267 ,(MPARAM)MLE_RGB
268 );
269 }
c4955899 270} // end of wxTextCtrl::SetupColours
d90895ac
DW
271
272// ----------------------------------------------------------------------------
273// set/get the controls text
274// ----------------------------------------------------------------------------
275
0e320a79
DW
276wxString wxTextCtrl::GetValue() const
277{
c4955899
DW
278 wxString sStr = wxGetWindowText(GetHWND());
279 char* zStr = (char*)sStr.c_str();
d90895ac 280
c4955899
DW
281 for ( ; *zStr; zStr++ )
282 {
283 //
284 // this will replace \r\n with just \n
285 //
286 if (*zStr == '\n')
287 *zStr = '\0';
288 if (*zStr == '\r')
289 *zStr = '\n';
290 }
291 sStr = zStr;
292 return sStr;
293} // end of wxTextCtrl::GetValue
0e320a79 294
c4955899
DW
295void wxTextCtrl::SetValue(
296 const wxString& rsValue
297)
0e320a79 298{
c4955899
DW
299 //
300 // If the text is long enough, it's faster to just set it instead of first
301 // comparing it with the old one (chances are that it will be different
302 // anyhow, this comparison is there to avoid flicker for small single-line
303 // edit controls mostly)
304 //
305 if ((rsValue.length() > 0x400) || (rsValue != GetValue()))
306 {
307 ::WinSetWindowText(GetHwnd(), rsValue.c_str());
308 AdjustSpaceLimit();
309 }
310} // end of wxTextCtrl::SetValue
d90895ac 311
c4955899
DW
312void wxTextCtrl::WriteText(
313 const wxString& rsValue
314)
315{
b3260bce
DW
316 if (m_bIsMLE)
317 ::WinSendMsg(GetHwnd(), MLM_INSERT, MPARAM((PCHAR)rsValue.c_str()), MPARAM(0));
318 else
319 ::WinSetWindowText(GetHwnd(), rsValue.c_str());
d90895ac 320 AdjustSpaceLimit();
c4955899 321} // end of wxTextCtrl::WriteText
0e320a79 322
c4955899
DW
323void wxTextCtrl::AppendText(
324 const wxString& rsText
325)
d90895ac 326{
d90895ac 327 SetInsertionPointEnd();
c4955899
DW
328 WriteText(rsText);
329} // end of wxTextCtrl::AppendText
d90895ac
DW
330
331void wxTextCtrl::Clear()
332{
c4955899
DW
333 ::WinSetWindowText(GetHwnd(), "");
334} // end of wxTextCtrl::Clear
d90895ac
DW
335
336// ----------------------------------------------------------------------------
0e320a79 337// Clipboard operations
d90895ac
DW
338// ----------------------------------------------------------------------------
339
0e320a79
DW
340void wxTextCtrl::Copy()
341{
d90895ac
DW
342 if (CanCopy())
343 {
344 HWND hWnd = GetHwnd();
3bd418ca
DW
345 if (m_bIsMLE)
346 ::WinSendMsg(hWnd, MLM_COPY, 0, 0);
347 else
348 ::WinSendMsg(hWnd, EM_COPY, 0, 0);
d90895ac 349 }
3bd418ca 350} // end of wxTextCtrl::Copy
0e320a79
DW
351
352void wxTextCtrl::Cut()
353{
d90895ac
DW
354 if (CanCut())
355 {
356 HWND hWnd = GetHwnd();
3bd418ca
DW
357
358 if (m_bIsMLE)
359 ::WinSendMsg(hWnd, MLM_CUT, 0, 0);
360 else
361 ::WinSendMsg(hWnd, EM_CUT, 0, 0);
d90895ac 362 }
c4955899 363} // end of wxTextCtrl::Cut
0e320a79
DW
364
365void wxTextCtrl::Paste()
366{
d90895ac
DW
367 if (CanPaste())
368 {
c4955899
DW
369 HWND hWnd = GetHwnd();
370
371 ::WinSendMsg(hWnd, EM_PASTE, 0, 0);
d90895ac 372 }
c4955899 373} // end of wxTextCtrl::Paste
d90895ac
DW
374
375bool wxTextCtrl::CanCopy() const
376{
c4955899 377 //
d90895ac 378 // Can copy if there's a selection
c4955899
DW
379 //
380 long lFrom = 0L;
381 long lTo = 0L;
382
383 GetSelection(&lFrom, &lTo);
384 return (lFrom != lTo);
385} // end of wxTextCtrl::CanCopy
d90895ac
DW
386
387bool wxTextCtrl::CanCut() const
388{
c4955899 389 //
d90895ac 390 // Can cut if there's a selection
c4955899
DW
391 //
392 long lFrom = 0L;
393 long lTo = 0L;
394
395 GetSelection(&lFrom, &lTo);
396 return (lFrom != lTo);
397} // end of wxTextCtrl::CanCut
d90895ac
DW
398
399bool wxTextCtrl::CanPaste() const
400{
3bd418ca
DW
401 bool bIsTextAvailable = FALSE;
402
d90895ac
DW
403 if (!IsEditable())
404 return FALSE;
405
3bd418ca
DW
406 //
407 // Check for straight text on clipboard
408 //
409 if (::WinOpenClipbrd(vHabmain))
d90895ac 410 {
3bd418ca
DW
411 bIsTextAvailable = (::WinQueryClipbrdData(vHabmain, CF_TEXT) != 0);
412 ::WinCloseClipbrd(vHabmain);
d90895ac 413 }
3bd418ca
DW
414 return bIsTextAvailable;
415} // end of wxTextCtrl::CanPaste
0e320a79 416
d90895ac
DW
417// ----------------------------------------------------------------------------
418// Accessors
419// ----------------------------------------------------------------------------
420
c4955899
DW
421void wxTextCtrl::SetEditable(
422 bool bEditable
423)
0e320a79 424{
c4955899
DW
425 HWND hWnd = GetHwnd();
426
427 if (m_bIsMLE)
428 ::WinSendMsg(hWnd, MLM_SETREADONLY, MPFROMLONG(!bEditable), (MPARAM)0);
429 else
430 ::WinSendMsg(hWnd, EM_SETREADONLY, MPFROMLONG(!bEditable), (MPARAM)0);
431} // end of wxTextCtrl::SetEditable
0e320a79 432
c4955899
DW
433void wxTextCtrl::SetInsertionPoint(
434 long lPos
435)
0e320a79 436{
c4955899
DW
437 HWND hWnd = GetHwnd();
438
439 if (m_bIsMLE)
440 ::WinSendMsg(hWnd, MLM_SETSEL, (MPARAM)lPos, (MPARAM)lPos);
441 else
442 ::WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lPos, (USHORT)lPos), (MPARAM)0);
443} // end of wxTextCtrl::SetInsertionPoint
0e320a79
DW
444
445void wxTextCtrl::SetInsertionPointEnd()
446{
c4955899
DW
447 long lPos = GetLastPosition();
448
449 SetInsertionPoint(lPos);
450} // end of wxTextCtrl::SetInsertionPointEnd
0e320a79
DW
451
452long wxTextCtrl::GetInsertionPoint() const
453{
3bd418ca
DW
454 WXDWORD dwPos = 0L;
455
456 if (m_bIsMLE)
457 dwPos = (WXDWORD)::WinSendMsg(GetHwnd(), MLM_QUERYSEL, (MPARAM)MLFQS_MINSEL, 0);
458 else
459 {
460 dwPos = (WXDWORD)::WinSendMsg(GetHwnd(), EM_QUERYSEL, 0, 0);
461 dwPos = SHORT1FROMMP((MPARAM)dwPos); // the first 16 bit value is the min pos
462 }
463 return (dwPos & 0xFFFF);
464} // end of wxTextCtrl::GetInsertionPoint
0e320a79
DW
465
466long wxTextCtrl::GetLastPosition() const
467{
3bd418ca
DW
468 HWND hWnd = GetHwnd();
469 long lCharIndex;
470 long lLineLength;
0e320a79 471
3bd418ca
DW
472 if (m_bIsMLE)
473 {
474 lCharIndex = 0;
d90895ac 475
3bd418ca
DW
476 //
477 // This just gets the total text length. The last will be this value
478 //
479 lLineLength = (long)::WinSendMsg(hWnd, MLM_QUERYTEXTLENGTH, 0, 0);
480 }
481 else
482 {
483 WNDPARAMS vParams;
484
485 lCharIndex = 0;
486 vParams.fsStatus = WPM_CCHTEXT;
487 if (::WinSendMsg( GetHwnd()
488 ,WM_QUERYWINDOWPARAMS
489 ,&vParams
490 ,0
491 ))
492 {
493 lLineLength = (long)vParams.cchText;
494 }
495 else
496 lLineLength = 0;
497 }
498 return(lCharIndex + lLineLength);
499} // end of wxTextCtrl::GetLastPosition
0e320a79 500
d90895ac
DW
501// If the return values from and to are the same, there is no
502// selection.
c4955899
DW
503void wxTextCtrl::GetSelection(
504 long* plFrom
505, long* plTo
506) const
0e320a79 507{
c4955899 508 WXDWORD dwPos;
0e320a79 509
c4955899
DW
510 if (m_bIsMLE)
511 dwPos = (WXDWORD)::WinSendMsg(GetHwnd(), MLM_QUERYSEL, (MPARAM)MLFQS_MINSEL, 0);
512 else
513 {
514 dwPos = (WXDWORD)::WinSendMsg(GetHwnd(), EM_QUERYSEL, 0, 0);
515 }
516 *plFrom = SHORT1FROMMP((MPARAM)dwPos); // the first 16 bit value is the min pos
517 *plTo = SHORT2FROMMP((MPARAM)dwPos); // the first 16 bit value is the min pos
518} // end of wxTextCtrl::GetSelection
0e320a79 519
d90895ac
DW
520bool wxTextCtrl::IsEditable() const
521{
c4955899
DW
522 if (m_bIsMLE)
523 return((bool)LONGFROMMR(::WinSendMsg(GetHwnd(), MLM_QUERYREADONLY, 0, 0)));
524 else
525 return((bool)LONGFROMMR(::WinSendMsg(GetHwnd(), EM_QUERYREADONLY, 0, 0)));
526} // end of wxTextCtrl::IsEditable
0e320a79 527
d90895ac
DW
528// ----------------------------------------------------------------------------
529// Editing
530// ----------------------------------------------------------------------------
531
c4955899
DW
532void wxTextCtrl::Replace(
533 long lFrom
534, long lTo
535, const wxString& rsValue
536)
0e320a79 537{
d90895ac 538#if wxUSE_CLIPBOARD
c4955899
DW
539 HWND hWnd = GetHwnd();
540 long lFromChar = lFrom;
541 long lToChar = lTo;
0e320a79 542
c4955899 543 //
d90895ac 544 // Set selection and remove it
c4955899
DW
545 //
546 if (m_bIsMLE)
547 {
548 ::WinSendMsg(hWnd, MLM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), 0);
549 ::WinSendMsg(hWnd, MLM_CUT, 0, 0);
550 }
551 else
552 {
553 ::WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), 0);
554 ::WinSendMsg(hWnd, EM_CUT, 0, 0);
555 }
0e320a79 556
c4955899 557 //
d90895ac 558 // Now replace with 'value', by pasting.
c4955899
DW
559 //
560 wxSetClipboardData(wxDF_TEXT, (wxObject *) (const wxChar *)rsValue, 0, 0);
0e320a79 561
d90895ac 562 // Paste into edit control
c4955899
DW
563 if (m_bIsMLE)
564 ::WinSendMsg(hWnd, MLM_PASTE, (MPARAM)0, (MPARAM)0);
565 else
566 ::WinSendMsg(hWnd, EM_PASTE, (MPARAM)0, (MPARAM)0);
d90895ac
DW
567#else
568 wxFAIL_MSG("wxTextCtrl::Replace not implemented if wxUSE_CLIPBOARD is 0.");
569#endif
c4955899 570} // end of wxTextCtrl::Replace
0e320a79 571
c4955899
DW
572void wxTextCtrl::Remove(
573 long lFrom
574, long lTo
575)
0e320a79 576{
c4955899
DW
577 HWND hWnd = GetHwnd();
578 long lFromChar = lFrom;
579 long lToChar = lTo;
d90895ac 580
c4955899
DW
581 if (m_bIsMLE)
582 {
583 ::WinSendMsg(hWnd, MLM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), 0);
584 ::WinSendMsg(hWnd, MLM_CUT, 0, 0);
585 }
586 else
587 {
588 ::WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), 0);
589 ::WinSendMsg(hWnd, EM_CUT, 0, 0);
590 }
591} // end of wxTextCtrl::Remove
0e320a79 592
c4955899
DW
593void wxTextCtrl::SetSelection(
594 long lFrom
595, long lTo
596)
0e320a79 597{
c4955899
DW
598 HWND hWnd = GetHwnd();
599 long lFromChar = lFrom;
600 long lToChar = lTo;
d90895ac 601
c4955899
DW
602 //
603 // If from and to are both -1, it means (in wxWindows) that all text should
d90895ac 604 // be selected. Translate into Windows convention
c4955899
DW
605 //
606 if ((lFrom == -1L) && (lTo == -1L))
d90895ac 607 {
c4955899
DW
608 lFromChar = 0L;
609 lToChar = -1L;
d90895ac 610 }
c4955899
DW
611 if (m_bIsMLE)
612 ::WinSendMsg(hWnd, MLM_SETSEL, (MPARAM)lFromChar, (MPARAM)lToChar);
613 else
614 ::WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lFromChar, (USHORT)lToChar), (MPARAM)0);
615} // end of wxTextCtrl::SetSelection
d90895ac 616
c4955899
DW
617bool wxTextCtrl::LoadFile(
618 const wxString& rsFile
619)
0e320a79 620{
c4955899 621 if ( wxTextCtrlBase::LoadFile(rsFile) )
d90895ac 622 {
c4955899
DW
623 //
624 // Update the size limit if needed
625 //
d90895ac 626 AdjustSpaceLimit();
d90895ac
DW
627 return TRUE;
628 }
d90895ac 629 return FALSE;
c4955899 630} // end of wxTextCtrl::LoadFile
0e320a79
DW
631
632bool wxTextCtrl::IsModified() const
633{
c4955899
DW
634 bool bRc;
635
636 if (m_bIsMLE)
637 bRc = (bool)LONGFROMMR(::WinSendMsg(GetHwnd(), MLM_QUERYCHANGED, 0, 0));
638 else
639 bRc = (bool)LONGFROMMR(::WinSendMsg(GetHwnd(), EM_QUERYCHANGED, 0, 0));
640 return bRc;
641} // end of wxTextCtrl::IsModified
0e320a79 642
3bd418ca 643//
0e320a79 644// Makes 'unmodified'
3bd418ca 645//
0e320a79
DW
646void wxTextCtrl::DiscardEdits()
647{
3bd418ca
DW
648 if (m_bIsMLE)
649 ::WinSendMsg(GetHwnd(), MLM_SETCHANGED, MPFROMLONG(FALSE), 0);
650 else
651 //
652 // EM controls do not have a SETCHANGED but issuing a query should reset it
653 //
654 ::WinSendMsg(GetHwnd(), EM_QUERYCHANGED, 0, 0);
655} // end of wxTextCtrl::DiscardEdits
0e320a79
DW
656
657int wxTextCtrl::GetNumberOfLines() const
658{
c4955899 659 int nNumLines;
0e320a79 660
c4955899
DW
661 if (m_bIsMLE)
662 nNumLines = (int)::WinSendMsg(GetHwnd(), MLM_QUERYLINECOUNT, 0, 0);
663 else
664 nNumLines = 1;
665 return nNumLines;
666} // end of wxTextCtrl::GetNumberOfLines
d90895ac 667
c4955899
DW
668long wxTextCtrl::XYToPosition(
669 long lX
670, long lY
671) const
672{
673 HWND hWnd = GetHwnd();
674 long lCharIndex = 0L;
675 long lLen;
0e320a79 676
c4955899
DW
677 if (m_bIsMLE)
678 {
679 lLen = (long)::WinSendMsg(GetHwnd(), MLM_QUERYLINELENGTH, 0, 0);
680 lCharIndex = ((lLen * lY) + lX);
681 }
682 else
683 lCharIndex = lX;
684 return lCharIndex;
685} // end of wxTextCtrl::XYToPosition
686
687bool wxTextCtrl::PositionToXY(
688 long lPos
689, long* plX
690, long* plY
691) const
0e320a79 692{
c4955899
DW
693 HWND hWnd = GetHwnd();
694 long nLineNo = -1;
695 long lCharIndex = 0;
d90895ac 696
c4955899
DW
697 if (m_bIsMLE)
698 nLineNo = (long)::WinSendMsg(hWnd, MLM_LINEFROMCHAR, (MPARAM)lPos, 0);
699 else
700 nLineNo = 0;
d90895ac 701
c4955899 702 if (nLineNo == -1)
d90895ac
DW
703 {
704 // no such line
705 return FALSE;
706 }
707
c4955899 708 //
d90895ac 709 // This gets the char index for the _beginning_ of this line
c4955899
DW
710 //
711 long lLineWidth;
712
713 if (m_bIsMLE)
714 {
715 lLineWidth = (long)::WinSendMsg(hWnd, MLM_QUERYLINELENGTH, (MPARAM)0, (MPARAM)0);
716 lCharIndex = (nLineNo + 1) * lLineWidth;
717 }
718 else
719 {
720 WNDPARAMS vParams;
721
722 vParams.fsStatus = WPM_CCHTEXT;
723 if (::WinSendMsg( hWnd
724 ,WM_QUERYWINDOWPARAMS
725 ,&vParams
726 ,0
727 ))
728 {
729 lCharIndex = vParams.cchText;
730 }
731 else
732 lCharIndex = 32;
733 }
734
735 if (lCharIndex == -1)
d90895ac
DW
736 {
737 return FALSE;
738 }
739
c4955899
DW
740 //
741 // The X position must therefore be the difference between pos and charIndex
742 //
743 if (plX)
744 *plX = lPos - lCharIndex;
745 if (plY)
746 *plY = nLineNo;
d90895ac
DW
747
748 return TRUE;
c4955899 749} // end of wxTextCtrl::PositionToXY
0e320a79 750
c4955899
DW
751void wxTextCtrl::ShowPosition(
752 long lPos
753)
0e320a79 754{
c4955899
DW
755 HWND hWnd = GetHwnd();
756 long lCurrentLineLineNo = 0L;
d90895ac
DW
757
758 // To scroll to a position, we pass the number of lines and characters
759 // to scroll *by*. This means that we need to:
760 // (1) Find the line position of the current line.
761 // (2) Find the line position of pos.
762 // (3) Scroll by (pos - current).
763 // For now, ignore the horizontal scrolling.
764
c4955899 765 //
d90895ac
DW
766 // Is this where scrolling is relative to - the line containing the caret?
767 // Or is the first visible line??? Try first visible line.
c4955899
DW
768 //
769 if (m_bIsMLE)
770 {
771 //
772 // In PM this is the actual char position
773 //
774 lCurrentLineLineNo = (long)::WinSendMsg(hWnd, MLM_QUERYFIRSTCHAR, (MPARAM)0, (MPARAM)0);
d90895ac 775
c4955899
DW
776 //
777 // This will cause a scroll to the selected position
778 //
779 ::WinSendMsg(hWnd, MLM_SETSEL, (MPARAM)lCurrentLineLineNo, (MPARAM)lCurrentLineLineNo);
780 }
781} // end of wxTextCtrl::ShowPosition
0e320a79 782
3bd418ca
DW
783int wxTextCtrl::GetLineLength(
784 long lLineNo
785) const
0e320a79 786{
3bd418ca 787 long lLen = 0L;
d90895ac 788
3bd418ca
DW
789 if (m_bIsMLE)
790 lLen = (long)::WinSendMsg(GetHwnd(), MLM_QUERYLINELENGTH, 0, 0);
791 else
792 {
793 WNDPARAMS vParams;
794
795 vParams.fsStatus = WPM_CCHTEXT;
796 if (::WinSendMsg( GetHwnd()
797 ,WM_QUERYWINDOWPARAMS
798 ,&vParams
799 ,0
800 ))
801 {
802 lLen = vParams.cchText;
803 }
804 else
805 lLen = 32;
806 }
807 return lLen;
c4955899 808} // end ofwxTextCtrl::GetLineLength
0e320a79 809
c4955899
DW
810wxString wxTextCtrl::GetLineText(
811 long lLineNo
812) const
0e320a79 813{
c4955899
DW
814 long lLen = (long)GetLineLength((long)lLineNo) + 1;
815 wxString sStr;
816 char* zBuf;
0e320a79 817
c4955899
DW
818 //
819 // There must be at least enough place for the length WORD in the
820 // buffer
821 //
822 lLen += sizeof(WORD);
823 zBuf = new char[lLen];
824 if (m_bIsMLE)
825 {
826 long lIndex;
827 long lBuflen;
828 long lCopied;
0e320a79 829
c4955899
DW
830 lLen = (long)::WinSendMsg(GetHwnd(), MLM_QUERYLINELENGTH, 0, 0);
831 lIndex = lLen * lLineNo;
0e320a79 832
c4955899
DW
833 ::WinSendMsg(GetHwnd(), MLM_SETSEL, (MPARAM)lIndex, (MPARAM)lIndex);
834 ::WinSendMsg(GetHwnd(), MLM_SETIMPORTEXPORT, MPFROMP(zBuf), MPFROMSHORT((USHORT)sizeof(zBuf)));
835 lBuflen = (long)::WinSendMsg(GetHwnd(), MLM_QUERYFORMATTEXTLENGTH, MPFROMLONG(lIndex), MPFROMLONG(-1));
836 lCopied = (long)::WinSendMsg(GetHwnd(), MLM_EXPORT, MPFROMP(&lIndex), MPFROMP(&lBuflen));
837 zBuf[lCopied] = '\0';
838 }
839 else
840 {
841 WNDPARAMS vParams;
842
843 vParams.fsStatus = WPM_CCHTEXT;
844 if (::WinSendMsg( GetHwnd()
845 ,WM_QUERYWINDOWPARAMS
846 ,&vParams
847 ,0
848 ))
849 memcpy(zBuf, vParams.pszText, vParams.cchText);
850 zBuf[vParams.cchText] = '\0';
851 }
852 sStr = zBuf;
853 delete [] zBuf;
854 return sStr;
855} // end of wxTextCtrl::GetLineText
0e320a79 856
d90895ac 857// ----------------------------------------------------------------------------
0e320a79 858// Undo/redo
d90895ac
DW
859// ----------------------------------------------------------------------------
860
0e320a79
DW
861void wxTextCtrl::Undo()
862{
d90895ac
DW
863 if (CanUndo())
864 {
c4955899
DW
865 if (m_bIsMLE)
866 ::WinSendMsg(GetHwnd(), MLM_UNDO, 0, 0);
867 // Simple entryfields cannot be undone
d90895ac 868 }
c4955899 869} // end of wxTextCtrl::Undo
0e320a79
DW
870
871void wxTextCtrl::Redo()
872{
d90895ac
DW
873 if (CanRedo())
874 {
c4955899
DW
875 if (m_bIsMLE)
876 ::WinSendMsg(GetHwnd(), MLM_UNDO, 0, 0);
877 // Simple entryfields cannot be undone
d90895ac 878 }
c4955899 879} // end of wxTextCtrl::Redo
0e320a79
DW
880
881bool wxTextCtrl::CanUndo() const
882{
3bd418ca
DW
883 bool bOk;
884
885 if (m_bIsMLE)
886 bOk = (::WinSendMsg(GetHwnd(), MLM_QUERYUNDO, 0, 0) != 0);
887 else
888 bOk = FALSE; // can't undo regular edit fields in PM
889 return bOk;
890} // end of wxTextCtrl::CanUndo
0e320a79
DW
891
892bool wxTextCtrl::CanRedo() const
893{
3bd418ca
DW
894 bool bOk;
895
896 if (m_bIsMLE)
897 bOk = (::WinSendMsg(GetHwnd(), MLM_QUERYUNDO, 0, 0) != 0);
898 else
899 bOk = FALSE; // can't undo regular edit fields in PM
900 return bOk;
901} // end of wxTextCtrl::CanRedo
0e320a79 902
d90895ac
DW
903// ----------------------------------------------------------------------------
904// implemenation details
905// ----------------------------------------------------------------------------
0e320a79 906
c4955899
DW
907void wxTextCtrl::Command(
908 wxCommandEvent& rEvent
909)
0e320a79 910{
c4955899
DW
911 SetValue(rEvent.GetString());
912 ProcessCommand (rEvent);
913} // end of wxTextCtrl::Command
0e320a79 914
c4955899
DW
915void wxTextCtrl::OnDropFiles(
916 wxDropFilesEvent& rEvent
917)
0e320a79
DW
918{
919 // By default, load the first file into the text window.
c4955899 920 if (rEvent.GetNumberOfFiles() > 0)
0e320a79 921 {
c4955899 922 LoadFile(rEvent.GetFiles()[0]);
0e320a79 923 }
c4955899
DW
924} // end of wxTextCtrl::OnDropFiles
925
926WXHBRUSH wxTextCtrl::OnCtlColor(
927 WXHDC hWxDC
928, WXHWND hWnd
929, WXUINT uCtlColor
930, WXUINT uMessage
931, WXWPARAM wParam
932, WXLPARAM lParam
933)
d90895ac 934{
c4955899
DW
935 HPS hPS = (HPS)hWxDC;
936 wxBrush* pBrush = NULL;
937 wxColour vColBack = GetBackgroundColour();
938 wxColour vColFore = GetForegroundColour();
939 wxBrush* pBackgroundBrush = wxTheBrushList->FindOrCreateBrush( GetBackgroundColour()
940 ,wxSOLID
941 );
942
943 if (m_bUseCtl3D)
944 {
945 HBRUSH hBrush = NULLHANDLE;
0e320a79 946
c4955899
DW
947 return hBrush;
948 }
949 if (GetParent()->GetTransparentBackground())
950 ::GpiSetBackMix(hPS, BM_LEAVEALONE);
951 else
952 ::GpiSetBackMix(hPS, BM_OVERPAINT);
953 if (!IsEnabled() && (GetWindowStyle() & wxTE_MULTILINE) == 0)
a756f210 954 vColBack = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
c4955899
DW
955 ::GpiSetBackColor(hPS, vColBack.GetPixel());
956 ::GpiSetColor(hPS, vColFore.GetPixel());
957 return (WXHBRUSH)pBackgroundBrush->GetResourceHandle();
958} // end of wxTextCtrl::OnCtlColor
959
54ffa107
DW
960bool wxTextCtrl::OS2ShouldPreProcessMessage(
961 WXMSG* pMsg
962)
963{
964 return wxControl::OS2ShouldPreProcessMessage(pMsg);
965} // end of wxTextCtrl::OS2ShouldPreProcessMessage
966
c4955899
DW
967void wxTextCtrl::OnChar(
968 wxKeyEvent& rEvent
969)
0e320a79 970{
c4955899 971 switch (rEvent.KeyCode())
d90895ac 972 {
d90895ac
DW
973 case WXK_RETURN:
974 if ( !(m_windowStyle & wxTE_MULTILINE) )
975 {
c4955899
DW
976 wxCommandEvent vEvent(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
977
978 vEvent.SetEventObject(this);
979 if ( GetEventHandler()->ProcessEvent(vEvent))
d90895ac
DW
980 return;
981 }
982 //else: multiline controls need Enter for themselves
983
984 break;
985
986 case WXK_TAB:
987 // always produce navigation event - even if we process TAB
988 // ourselves the fact that we got here means that the user code
989 // decided to skip processing of this TAB - probably to let it
990 // do its default job.
991 //
992 // NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is
993 // handled by Windows
994 {
c4955899 995 wxNavigationKeyEvent vEventNav;
d90895ac 996
c4955899
DW
997 vEventNav.SetDirection(!rEvent.ShiftDown());
998 vEventNav.SetWindowChange(FALSE);
999 vEventNav.SetEventObject(this);
1000
1001 if ( GetEventHandler()->ProcessEvent(vEventNav) )
d90895ac
DW
1002 return;
1003 }
1004 break;
d90895ac 1005 }
c4955899
DW
1006 rEvent.Skip();
1007} // end of wxTextCtrl::OnChar
0e320a79 1008
c4955899
DW
1009bool wxTextCtrl::OS2Command(
1010 WXUINT uParam
1011, WXWORD WXUNUSED(vId)
1012)
0e320a79 1013{
c4955899 1014 switch (uParam)
d90895ac 1015 {
d90895ac
DW
1016 case EN_SETFOCUS:
1017 case EN_KILLFOCUS:
1018 {
c4955899
DW
1019 wxFocusEvent vEvent( uParam == EN_KILLFOCUS ? wxEVT_KILL_FOCUS
1020 : wxEVT_SET_FOCUS
1021 ,m_windowId
1022 );
1023
1024 vEvent.SetEventObject(this);
1025 GetEventHandler()->ProcessEvent(vEvent);
d90895ac
DW
1026 }
1027 break;
1028
1029 case EN_CHANGE:
1030 {
c4955899
DW
1031 wxCommandEvent vEvent( wxEVT_COMMAND_TEXT_UPDATED
1032 ,m_windowId
1033 );
1034
1035 InitCommandEvent(vEvent);
1036 vEvent.SetString((char*)GetValue().c_str());
1037 ProcessCommand(vEvent);
d90895ac
DW
1038 }
1039 break;
1040
c4955899
DW
1041 case EN_OVERFLOW:
1042 //
1043 // The text size limit has been hit - increase it
1044 //
d90895ac
DW
1045 AdjustSpaceLimit();
1046 break;
1047
c4955899
DW
1048 case EN_SCROLL:
1049 case EN_INSERTMODETOGGLE:
1050 case EN_MEMERROR:
1051 return FALSE;
d90895ac
DW
1052 default:
1053 return FALSE;
1054 }
1055
c4955899
DW
1056 //
1057 // Processed
1058 //
d90895ac 1059 return TRUE;
c4955899 1060} // end of wxTextCtrl::OS2Command
0e320a79 1061
d90895ac 1062void wxTextCtrl::AdjustSpaceLimit()
0e320a79 1063{
3bd418ca
DW
1064 unsigned int uLen = 0;
1065 unsigned int uLimit = 0;
d90895ac 1066
3bd418ca
DW
1067 uLen = ::WinQueryWindowTextLength(GetHwnd());
1068 if (m_bIsMLE)
1069 {
1070 uLimit = (unsigned int)::WinSendMsg( GetHwnd()
1071 ,MLM_QUERYTEXTLIMIT
1072 ,0
1073 ,0
1074 );
1075 }
1076 else
1077 {
1078 ENTRYFDATA* pEfd;
1079 WNDPARAMS vParams;
1080
1081 vParams.fsStatus = WPM_CBCTLDATA;
1082 vParams.cbCtlData = sizeof(ENTRYFDATA);
1083
1084 if (::WinSendMsg( GetHwnd()
1085 ,WM_QUERYWINDOWPARAMS
1086 ,&vParams
1087 ,0
1088 ))
1089 {
1090 pEfd = (ENTRYFDATA*)vParams.pCtlData;
1091 uLimit = (unsigned int)pEfd->cchEditLimit;
1092 }
d90895ac 1093 else
3bd418ca 1094 uLimit = 32; //PM's default
d90895ac 1095 }
3bd418ca
DW
1096 if (uLen >= uLimit)
1097 {
1098 uLimit = uLen + 0x8000; // 32Kb
1099 if (uLimit > 0xffff)
1100 {
1101 uLimit = 0L;
1102 }
1103 if (m_bIsMLE)
1104 ::WinSendMsg(GetHwnd(), MLM_SETTEXTLIMIT, MPFROMLONG(uLimit), 0);
1105 else
1106 ::WinSendMsg(GetHwnd(), EM_SETTEXTLIMIT, MPFROMLONG(uLimit), 0);
1107 }
1108} // end of wxTextCtrl::AdjustSpaceLimit
0e320a79 1109
d90895ac 1110bool wxTextCtrl::AcceptsFocus() const
0e320a79 1111{
c4955899
DW
1112 //
1113 // We don't want focus if we can't be edited
1114 //
d90895ac 1115 return IsEditable() && wxControl::AcceptsFocus();
c4955899 1116} // end of wxTextCtrl::Command
0e320a79 1117
e78c4d50 1118wxSize wxTextCtrl::DoGetBestSize() const
0e320a79 1119{
c4955899
DW
1120 int nCx;
1121 int nCy;
0e320a79 1122
c4955899 1123 wxGetCharSize(GetHWND(), &nCx, &nCy, (wxFont*)&GetFont());
d90895ac 1124
c4955899 1125 int wText = DEFAULT_ITEM_WIDTH;
987da0d4 1126 int hText = (EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * .8);
c4955899
DW
1127
1128 if (m_windowStyle & wxTE_MULTILINE)
d90895ac 1129 {
239c2e96 1130 hText *= wxMax(GetNumberOfLines(), 5);
d90895ac
DW
1131 }
1132 //else: for single line control everything is ok
d90895ac 1133 return wxSize(wText, hText);
c4955899 1134} // end of wxTextCtrl::DoGetBestSize
0e320a79 1135
d90895ac
DW
1136// ----------------------------------------------------------------------------
1137// standard handlers for standard edit menu events
1138// ----------------------------------------------------------------------------
1139
c4955899
DW
1140void wxTextCtrl::OnCut(
1141 wxCommandEvent& rEvent
1142)
0e320a79
DW
1143{
1144 Cut();
c4955899 1145} // end of wxTextCtrl::OnCut
0e320a79 1146
c4955899
DW
1147void wxTextCtrl::OnCopy(
1148 wxCommandEvent& rEvent
1149)
0e320a79
DW
1150{
1151 Copy();
c4955899 1152} // end of wxTextCtrl::OnCopy
0e320a79 1153
c4955899
DW
1154void wxTextCtrl::OnPaste(
1155 wxCommandEvent& rEvent
1156)
0e320a79
DW
1157{
1158 Paste();
c4955899 1159} // end of wxTextCtrl::OnPaste
0e320a79 1160
c4955899
DW
1161void wxTextCtrl::OnUndo(
1162 wxCommandEvent& rEvent
1163)
0e320a79
DW
1164{
1165 Undo();
c4955899 1166} // end of wxTextCtrl::OnUndo
0e320a79 1167
c4955899
DW
1168void wxTextCtrl::OnRedo(
1169 wxCommandEvent& rEvent
1170)
0e320a79
DW
1171{
1172 Redo();
c4955899 1173} // end of wxTextCtrl::OnRedo
0e320a79 1174
c4955899
DW
1175void wxTextCtrl::OnUpdateCut(
1176 wxUpdateUIEvent& rEvent
1177)
0e320a79 1178{
c4955899
DW
1179 rEvent.Enable(CanCut());
1180} // end of wxTextCtrl::OnUpdateCut
0e320a79 1181
c4955899
DW
1182void wxTextCtrl::OnUpdateCopy(
1183 wxUpdateUIEvent& rEvent
1184)
0e320a79 1185{
c4955899
DW
1186 rEvent.Enable(CanCopy());
1187} // end of wxTextCtrl::OnUpdateCopy
0e320a79 1188
c4955899
DW
1189void wxTextCtrl::OnUpdatePaste(
1190 wxUpdateUIEvent& rEvent
1191)
0e320a79 1192{
c4955899
DW
1193 rEvent.Enable(CanPaste());
1194} // end of wxTextCtrl::OnUpdatePaste
0e320a79 1195
c4955899
DW
1196void wxTextCtrl::OnUpdateUndo(
1197 wxUpdateUIEvent& rEvent
1198)
0e320a79 1199{
c4955899
DW
1200 rEvent.Enable(CanUndo());
1201} // end of wxTextCtrl::OnUpdateUndo
1202
1203void wxTextCtrl::OnUpdateRedo(
1204 wxUpdateUIEvent& rEvent
1205)
1206{
1207 rEvent.Enable(CanRedo());
1208} // end of wxTextCtrl::OnUpdateRedo
0e320a79 1209
c4955899
DW
1210bool wxTextCtrl::SetBackgroundColour(
1211 const wxColour& rColour
1212)
0e320a79 1213{
c4955899
DW
1214 if (m_bIsMLE)
1215 ::WinSendMsg(GetHwnd(), MLM_SETBACKCOLOR, (MPARAM)rColour.GetPixel(), MLE_INDEX);
1216 return TRUE;
1217} // end of wxTextCtrl::SetBackgroundColour
1218
1219bool wxTextCtrl::SetForegroundColour(
1220 const wxColour& rColour
1221)
1222{
1223 if (m_bIsMLE)
1224 ::WinSendMsg(GetHwnd(), MLM_SETTEXTCOLOR, (MPARAM)rColour.GetPixel(), MLE_INDEX);
1225 return TRUE;
1226} // end of wxTextCtrl::SetForegroundColour
d90895ac 1227
39c26ef2
DW
1228bool wxTextCtrl::SetStyle(
1229 long lStart
1230, long lEnd
1231, const wxTextAttr& rStyle
1232)
1233{
1234 HWND hWnd = GetHwnd();
1235
1236 if (lStart > lEnd)
1237 {
1238 long lTmp = lStart;
1239
1240 lStart = lEnd;
1241 lEnd = lTmp;
1242 }
1243
1244 //
1245 // We can only change the format of the selection, so select the range we
1246 // want and restore the old selection later
1247 //
1248 long lStartOld;
1249 long lEndOld;
1250
1251 GetSelection( &lStartOld
1252 ,&lEndOld
1253 );
1254
1255 //
1256 // But do we really have to change the selection?
1257 //
1258 bool bChangeSel = lStart != lStartOld ||
1259 lEnd != lEndOld;
1260
1261 if (bChangeSel)
1262 {
1263 if (m_bIsMLE)
1264 ::WinSendMsg(hWnd, MLM_SETSEL, MPFROM2SHORT((USHORT)lStart, (USHORT)lEnd), 0);
1265 else
1266 ::WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lStart, (USHORT)lEnd), 0);
1267 }
1268
1269 //
1270 // TODO:: finish this part
1271 //
1272 return TRUE;
1273} // end of wxTextCtrl::SetStyle
1274