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