1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
17 #pragma implementation "textctrl.h"
20 // ----------------------------------------------------------------------------
22 // ----------------------------------------------------------------------------
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
32 #include "wx/textctrl.h"
33 #include "wx/settings.h"
41 #include "wx/clipbrd.h"
44 #include "wx/textfile.h"
48 #include "wx/msw/private.h"
52 #include <sys/types.h>
60 #if wxUSE_RICHEDIT && (!defined(__GNUWIN32__) || defined(wxUSE_NORLANDER_HEADERS))
64 #if !USE_SHARED_LIBRARY
66 // ----------------------------------------------------------------------------
67 // event tables and other macros
68 // ----------------------------------------------------------------------------
70 IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl
, wxControl
)
72 BEGIN_EVENT_TABLE(wxTextCtrl
, wxControl
)
73 EVT_CHAR(wxTextCtrl::OnChar
)
74 EVT_DROP_FILES(wxTextCtrl::OnDropFiles
)
76 EVT_MENU(wxID_CUT
, wxTextCtrl::OnCut
)
77 EVT_MENU(wxID_COPY
, wxTextCtrl::OnCopy
)
78 EVT_MENU(wxID_PASTE
, wxTextCtrl::OnPaste
)
79 EVT_MENU(wxID_UNDO
, wxTextCtrl::OnUndo
)
80 EVT_MENU(wxID_REDO
, wxTextCtrl::OnRedo
)
82 EVT_UPDATE_UI(wxID_CUT
, wxTextCtrl::OnUpdateCut
)
83 EVT_UPDATE_UI(wxID_COPY
, wxTextCtrl::OnUpdateCopy
)
84 EVT_UPDATE_UI(wxID_PASTE
, wxTextCtrl::OnUpdatePaste
)
85 EVT_UPDATE_UI(wxID_UNDO
, wxTextCtrl::OnUpdateUndo
)
86 EVT_UPDATE_UI(wxID_REDO
, wxTextCtrl::OnUpdateRedo
)
89 #endif // USE_SHARED_LIBRARY
91 // ============================================================================
93 // ============================================================================
95 // ----------------------------------------------------------------------------
97 // ----------------------------------------------------------------------------
99 wxTextCtrl::wxTextCtrl()
106 bool wxTextCtrl::Create(wxWindow
*parent
, wxWindowID id
,
107 const wxString
& value
,
111 const wxValidator
& validator
,
112 const wxString
& name
)
114 // base initialization
115 if ( !CreateBase(parent
, id
, pos
, size
, style
, validator
, name
) )
118 SetValidator(validator
);
120 parent
->AddChild(this);
125 // translate wxWin style flags to MSW ones, checking for consistency while
127 long msStyle
= ES_LEFT
| WS_VISIBLE
| WS_CHILD
| WS_TABSTOP
;
128 if ( m_windowStyle
& wxTE_MULTILINE
)
130 wxASSERT_MSG( !(m_windowStyle
& wxTE_PROCESS_ENTER
),
131 _T("wxTE_PROCESS_ENTER style is ignored for multiline "
132 "text controls (they always process it)") );
134 msStyle
|= ES_MULTILINE
| ES_WANTRETURN
;
135 if ((m_windowStyle
& wxTE_NO_VSCROLL
) == 0)
136 msStyle
|= WS_VSCROLL
;
137 m_windowStyle
|= wxTE_PROCESS_ENTER
;
140 msStyle
|= ES_AUTOHSCROLL
;
142 if (m_windowStyle
& wxHSCROLL
)
143 msStyle
|= (WS_HSCROLL
| ES_AUTOHSCROLL
);
145 if (m_windowStyle
& wxTE_READONLY
)
146 msStyle
|= ES_READONLY
;
148 if (m_windowStyle
& wxHSCROLL
)
149 msStyle
|= (WS_HSCROLL
| ES_AUTOHSCROLL
);
150 if (m_windowStyle
& wxTE_PASSWORD
) // hidden input
151 msStyle
|= ES_PASSWORD
;
153 // we always want the characters and the arrows
154 m_lDlgCode
= DLGC_WANTCHARS
| DLGC_WANTARROWS
;
156 // we may have several different cases:
157 // 1. normal case: both TAB and ENTER are used for dialog navigation
158 // 2. ctrl which wants TAB for itself: ENTER is used to pass to the next
159 // control in the dialog
160 // 3. ctrl which wants ENTER for itself: TAB is used for dialog navigation
161 // 4. ctrl which wants both TAB and ENTER: Ctrl-ENTER is used to pass to
163 if ( m_windowStyle
& wxTE_PROCESS_ENTER
)
164 m_lDlgCode
|= DLGC_WANTMESSAGE
;
165 if ( m_windowStyle
& wxTE_PROCESS_TAB
)
166 m_lDlgCode
|= DLGC_WANTTAB
;
168 // do create the control - either an EDIT or RICHEDIT
169 const wxChar
*windowClass
= _T("EDIT");
172 if ( m_windowStyle
& wxTE_RICH
)
174 msStyle
|= ES_AUTOVSCROLL
;
176 windowClass
= _T("RICHEDIT");
183 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
);
185 // Even with extended styles, need to combine with WS_BORDER for them to
187 if ( want3D
|| wxStyleHasBorder(m_windowStyle
) )
188 msStyle
|= WS_BORDER
;
190 // NB: don't use pos and size as CreateWindowEx arguments because they
191 // might be -1 in which case we should use the default values (and
192 // SetSize called below takes care of it)
193 m_hWnd
= (WXHWND
)::CreateWindowEx(exStyle
,
203 wxCHECK_MSG( m_hWnd
, FALSE
, _T("Failed to create text ctrl") );
208 Ctl3dSubclassCtl(GetHwnd());
216 // Have to enable events
217 ::SendMessage(GetHwnd(), EM_SETEVENTMASK
, 0,
218 ENM_CHANGE
| ENM_DROPFILES
| ENM_SELCHANGE
| ENM_UPDATE
);
222 SubclassWin(GetHWND());
224 // set font, position, size and initial value
225 wxFont
& fontParent
= parent
->GetFont();
226 if ( fontParent
.Ok() )
232 SetFont(wxSystemSettings::GetSystemFont(wxSYS_SYSTEM_FONT
));
235 // Causes a crash for Symantec C++ and WIN32 for some reason
236 #if !(defined(__SC__) && defined(__WIN32__))
237 if ( !value
.IsEmpty() )
243 SetSize(pos
.x
, pos
.y
, size
.x
, size
.y
);
248 // Make sure the window style (etc.) reflects the HWND style (roughly)
249 void wxTextCtrl::AdoptAttributesFromHWND()
251 wxWindow::AdoptAttributesFromHWND();
253 HWND hWnd
= GetHwnd();
254 long style
= GetWindowLong(hWnd
, GWL_STYLE
);
256 // retrieve the style to see whether this is an edit or richedit ctrl
260 GetClassName(hWnd
, buf
, WXSIZEOF(buf
));
262 if ( wxStricmp(buf
, _T("EDIT")) == 0 )
266 #endif // wxUSE_RICHEDIT
268 if (style
& ES_MULTILINE
)
269 m_windowStyle
|= wxTE_MULTILINE
;
270 if (style
& ES_PASSWORD
)
271 m_windowStyle
|= wxTE_PASSWORD
;
272 if (style
& ES_READONLY
)
273 m_windowStyle
|= wxTE_READONLY
;
274 if (style
& ES_WANTRETURN
)
275 m_windowStyle
|= wxTE_PROCESS_ENTER
;
278 void wxTextCtrl::SetupColours()
280 // FIXME why is bg colour not inherited from parent?
281 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW
));
282 SetForegroundColour(GetParent()->GetForegroundColour());
285 // ----------------------------------------------------------------------------
286 // set/get the controls text
287 // ----------------------------------------------------------------------------
289 wxString
wxTextCtrl::GetValue() const
291 return wxGetWindowText(GetHWND());
294 void wxTextCtrl::SetValue(const wxString
& value
)
296 wxString valueDos
= wxTextFile::Translate(value
, wxTextFileType_Dos
);
298 SetWindowText(GetHwnd(), valueDos
);
303 void wxTextCtrl::WriteText(const wxString
& value
)
305 wxString valueDos
= wxTextFile::Translate(value
, wxTextFileType_Dos
);
307 SendMessage(GetHwnd(), EM_REPLACESEL
, 0, (LPARAM
)valueDos
.c_str());
312 void wxTextCtrl::AppendText(const wxString
& text
)
314 SetInsertionPointEnd();
318 void wxTextCtrl::Clear()
320 SetWindowText(GetHwnd(), _T(""));
323 // ----------------------------------------------------------------------------
324 // Clipboard operations
325 // ----------------------------------------------------------------------------
327 void wxTextCtrl::Copy()
331 HWND hWnd
= GetHwnd();
332 SendMessage(hWnd
, WM_COPY
, 0, 0L);
336 void wxTextCtrl::Cut()
340 HWND hWnd
= GetHwnd();
341 SendMessage(hWnd
, WM_CUT
, 0, 0L);
345 void wxTextCtrl::Paste()
349 HWND hWnd
= GetHwnd();
350 SendMessage(hWnd
, WM_PASTE
, 0, 0L);
354 bool wxTextCtrl::CanCopy() const
356 // Can copy if there's a selection
358 GetSelection(& from
, & to
);
362 bool wxTextCtrl::CanCut() const
364 // Can cut if there's a selection
366 GetSelection(& from
, & to
);
370 bool wxTextCtrl::CanPaste() const
375 int dataFormat
= 0; // 0 == any format
376 return (::SendMessage( GetHwnd(), EM_CANPASTE
, (WPARAM
) (UINT
) dataFormat
, 0) != 0);
382 // Standard edit control: check for straight text on clipboard
383 bool isTextAvailable
= FALSE
;
384 if ( ::OpenClipboard(GetHwndOf(wxTheApp
->GetTopWindow())) )
386 isTextAvailable
= (::IsClipboardFormatAvailable(CF_TEXT
) != 0);
390 return isTextAvailable
;
393 // ----------------------------------------------------------------------------
395 // ----------------------------------------------------------------------------
397 void wxTextCtrl::SetEditable(bool editable
)
399 HWND hWnd
= GetHwnd();
400 SendMessage(hWnd
, EM_SETREADONLY
, (WPARAM
)!editable
, (LPARAM
)0L);
403 void wxTextCtrl::SetInsertionPoint(long pos
)
405 HWND hWnd
= GetHwnd();
413 SendMessage(hWnd
, EM_EXSETSEL
, 0, (LPARAM
) &range
);
414 SendMessage(hWnd
, EM_SCROLLCARET
, (WPARAM
)0, (LPARAM
)0);
417 #endif // wxUSE_RICHEDIT
419 SendMessage(hWnd
, EM_SETSEL
, pos
, pos
);
420 SendMessage(hWnd
, EM_SCROLLCARET
, (WPARAM
)0, (LPARAM
)0);
423 SendMessage(hWnd
, EM_SETSEL
, 0, MAKELPARAM(pos
, pos
));
426 static const char *nothing
= "";
427 SendMessage(hWnd
, EM_REPLACESEL
, 0, (LPARAM
)nothing
);
430 void wxTextCtrl::SetInsertionPointEnd()
432 long pos
= GetLastPosition();
433 SetInsertionPoint(pos
);
436 long wxTextCtrl::GetInsertionPoint() const
444 SendMessage(GetHwnd(), EM_EXGETSEL
, 0, (LPARAM
) &range
);
449 DWORD Pos
= (DWORD
)SendMessage(GetHwnd(), EM_GETSEL
, 0, 0L);
453 long wxTextCtrl::GetLastPosition() const
455 HWND hWnd
= GetHwnd();
457 // Will always return a number > 0 (according to docs)
458 int noLines
= (int)SendMessage(hWnd
, EM_GETLINECOUNT
, (WPARAM
)0, (LPARAM
)0L);
460 // This gets the char index for the _beginning_ of the last line
461 int charIndex
= (int)SendMessage(hWnd
, EM_LINEINDEX
, (WPARAM
)(noLines
-1), (LPARAM
)0L);
463 // Get number of characters in the last line. We'll add this to the character
464 // index for the last line, 1st position.
465 int lineLength
= (int)SendMessage(hWnd
, EM_LINELENGTH
, (WPARAM
)charIndex
, (LPARAM
)0L);
467 return (long)(charIndex
+ lineLength
);
470 // If the return values from and to are the same, there is no
472 void wxTextCtrl::GetSelection(long* from
, long* to
) const
478 ::SendMessage(GetHwnd(), EM_EXGETSEL
, 0, (LPARAM
) (CHARRANGE
*) & charRange
);
480 *from
= charRange
.cpMin
;
481 *to
= charRange
.cpMax
;
486 DWORD dwStart
, dwEnd
;
487 WPARAM wParam
= (WPARAM
) (DWORD
*) & dwStart
; // receives starting position
488 LPARAM lParam
= (LPARAM
) (DWORD
*) & dwEnd
; // receives ending position
490 ::SendMessage(GetHwnd(), EM_GETSEL
, wParam
, lParam
);
496 bool wxTextCtrl::IsEditable() const
498 long style
= ::GetWindowLong(GetHwnd(), GWL_STYLE
);
500 return ((style
& ES_READONLY
) == 0);
503 // ----------------------------------------------------------------------------
505 // ----------------------------------------------------------------------------
507 void wxTextCtrl::Replace(long from
, long to
, const wxString
& value
)
510 HWND hWnd
= GetHwnd();
511 long fromChar
= from
;
514 // Set selection and remove it
516 SendMessage(hWnd
, EM_SETSEL
, fromChar
, toChar
);
518 SendMessage(hWnd
, EM_SETSEL
, (WPARAM
)0, (LPARAM
)MAKELONG(fromChar
, toChar
));
520 SendMessage(hWnd
, WM_CUT
, (WPARAM
)0, (LPARAM
)0);
522 // Now replace with 'value', by pasting.
523 wxSetClipboardData(wxDF_TEXT
, (wxObject
*) (const wxChar
*)value
, 0, 0);
525 // Paste into edit control
526 SendMessage(hWnd
, WM_PASTE
, (WPARAM
)0, (LPARAM
)0L);
528 wxFAIL_MSG("wxTextCtrl::Replace not implemented if wxUSE_CLIPBOARD is 0.");
532 void wxTextCtrl::Remove(long from
, long to
)
534 HWND hWnd
= GetHwnd();
535 long fromChar
= from
;
538 // Cut all selected text
540 SendMessage(hWnd
, EM_SETSEL
, fromChar
, toChar
);
542 SendMessage(hWnd
, EM_SETSEL
, (WPARAM
)0, (LPARAM
)MAKELONG(fromChar
, toChar
));
544 SendMessage(hWnd
, WM_CUT
, (WPARAM
)0, (LPARAM
)0);
547 void wxTextCtrl::SetSelection(long from
, long to
)
549 HWND hWnd
= GetHwnd();
550 long fromChar
= from
;
553 // if from and to are both -1, it means (in wxWindows) that all text should
554 // be selected. Translate into Windows convention
555 if ((from
== -1) && (to
== -1))
562 SendMessage(hWnd
, EM_SETSEL
, (WPARAM
)fromChar
, (LPARAM
)toChar
);
563 SendMessage(hWnd
, EM_SCROLLCARET
, (WPARAM
)0, (LPARAM
)0);
565 // WPARAM is 0: selection is scrolled into view
566 SendMessage(hWnd
, EM_SETSEL
, (WPARAM
)0, (LPARAM
)MAKELONG(fromChar
, toChar
));
570 bool wxTextCtrl::LoadFile(const wxString
& file
)
572 if ( wxTextCtrlBase::LoadFile(file
) )
574 // update the size limit if needed
583 bool wxTextCtrl::IsModified() const
585 return (SendMessage(GetHwnd(), EM_GETMODIFY
, 0, 0) != 0);
588 // Makes 'unmodified'
589 void wxTextCtrl::DiscardEdits()
591 SendMessage(GetHwnd(), EM_SETMODIFY
, FALSE
, 0L);
594 int wxTextCtrl::GetNumberOfLines() const
596 return (int)SendMessage(GetHwnd(), EM_GETLINECOUNT
, (WPARAM
)0, (LPARAM
)0);
599 long wxTextCtrl::XYToPosition(long x
, long y
) const
601 HWND hWnd
= GetHwnd();
603 // This gets the char index for the _beginning_ of this line
604 int charIndex
= (int)SendMessage(hWnd
, EM_LINEINDEX
, (WPARAM
)y
, (LPARAM
)0);
605 return (long)(x
+ charIndex
);
608 bool wxTextCtrl::PositionToXY(long pos
, long *x
, long *y
) const
610 HWND hWnd
= GetHwnd();
612 // This gets the line number containing the character
617 lineNo
= (int)SendMessage(hWnd
, EM_EXLINEFROMCHAR
, 0, (LPARAM
)pos
);
620 #endif // wxUSE_RICHEDIT
621 lineNo
= (int)SendMessage(hWnd
, EM_LINEFROMCHAR
, (WPARAM
)pos
, 0);
629 // This gets the char index for the _beginning_ of this line
630 int charIndex
= (int)SendMessage(hWnd
, EM_LINEINDEX
, (WPARAM
)lineNo
, (LPARAM
)0);
631 if ( charIndex
== -1 )
636 // The X position must therefore be the different between pos and charIndex
638 *x
= (long)(pos
- charIndex
);
645 void wxTextCtrl::ShowPosition(long pos
)
647 HWND hWnd
= GetHwnd();
649 // To scroll to a position, we pass the number of lines and characters
650 // to scroll *by*. This means that we need to:
651 // (1) Find the line position of the current line.
652 // (2) Find the line position of pos.
653 // (3) Scroll by (pos - current).
654 // For now, ignore the horizontal scrolling.
656 // Is this where scrolling is relative to - the line containing the caret?
657 // Or is the first visible line??? Try first visible line.
658 // int currentLineLineNo1 = (int)SendMessage(hWnd, EM_LINEFROMCHAR, (WPARAM)-1, (LPARAM)0L);
660 int currentLineLineNo
= (int)SendMessage(hWnd
, EM_GETFIRSTVISIBLELINE
, (WPARAM
)0, (LPARAM
)0L);
662 int specifiedLineLineNo
= (int)SendMessage(hWnd
, EM_LINEFROMCHAR
, (WPARAM
)pos
, (LPARAM
)0L);
664 int linesToScroll
= specifiedLineLineNo
- currentLineLineNo
;
666 if (linesToScroll
!= 0)
667 (void)SendMessage(hWnd
, EM_LINESCROLL
, (WPARAM
)0, (LPARAM
)linesToScroll
);
670 int wxTextCtrl::GetLineLength(long lineNo
) const
672 long charIndex
= XYToPosition(0, lineNo
);
673 int len
= (int)SendMessage(GetHwnd(), EM_LINELENGTH
, charIndex
, 0);
677 wxString
wxTextCtrl::GetLineText(long lineNo
) const
679 size_t len
= (size_t)GetLineLength(lineNo
) + 1;
680 char *buf
= (char *)malloc(len
);
682 int noChars
= (int)SendMessage(GetHwnd(), EM_GETLINE
, lineNo
, (LPARAM
)buf
);
692 // ----------------------------------------------------------------------------
694 // ----------------------------------------------------------------------------
696 void wxTextCtrl::Undo()
700 ::SendMessage(GetHwnd(), EM_UNDO
, 0, 0);
704 void wxTextCtrl::Redo()
708 // Same as Undo, since Undo undoes the undo, i.e. a redo.
709 ::SendMessage(GetHwnd(), EM_UNDO
, 0, 0);
713 bool wxTextCtrl::CanUndo() const
715 return (::SendMessage(GetHwnd(), EM_CANUNDO
, 0, 0) != 0);
718 bool wxTextCtrl::CanRedo() const
720 return (::SendMessage(GetHwnd(), EM_CANUNDO
, 0, 0) != 0);
723 // ----------------------------------------------------------------------------
724 // implemenation details
725 // ----------------------------------------------------------------------------
727 void wxTextCtrl::Command(wxCommandEvent
& event
)
729 SetValue(event
.GetString());
730 ProcessCommand (event
);
733 void wxTextCtrl::OnDropFiles(wxDropFilesEvent
& event
)
735 // By default, load the first file into the text window.
736 if (event
.GetNumberOfFiles() > 0)
738 LoadFile(event
.GetFiles()[0]);
742 WXHBRUSH
wxTextCtrl::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
743 WXUINT message
, WXWPARAM wParam
,
749 HBRUSH hbrush
= Ctl3dCtlColorEx(message
, wParam
, lParam
);
750 return (WXHBRUSH
) hbrush
;
755 SetBkMode(hdc
, GetParent()->GetTransparentBackground() ? TRANSPARENT
758 ::SetBkColor(hdc
, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
759 ::SetTextColor(hdc
, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
761 wxBrush
*backgroundBrush
= wxTheBrushList
->FindOrCreateBrush(GetBackgroundColour(), wxSOLID
);
763 return (WXHBRUSH
) backgroundBrush
->GetResourceHandle();
766 void wxTextCtrl::OnChar(wxKeyEvent
& event
)
768 switch ( event
.KeyCode() )
771 if ( !(m_windowStyle
& wxTE_MULTILINE
) )
773 wxCommandEvent
event(wxEVT_COMMAND_TEXT_ENTER
, m_windowId
);
774 event
.SetEventObject( this );
775 if ( GetEventHandler()->ProcessEvent(event
) )
778 //else: multiline controls need Enter for themselves
783 // always produce navigation event - even if we process TAB
784 // ourselves the fact that we got here means that the user code
785 // decided to skip processing of this TAB - probably to let it
786 // do its default job.
788 // NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is
789 // handled by Windows
791 wxNavigationKeyEvent eventNav
;
792 eventNav
.SetDirection(!event
.ShiftDown());
793 eventNav
.SetWindowChange(FALSE
);
794 eventNav
.SetEventObject(this);
796 if ( GetEventHandler()->ProcessEvent(eventNav
) )
806 // don't just call event.Skip() because this will cause TABs and ENTERs
807 // be passed upwards and we don't always want this - instead process it
814 bool wxTextCtrl::MSWCommand(WXUINT param
, WXWORD
WXUNUSED(id
))
821 wxFocusEvent
event(param
== EN_KILLFOCUS
? wxEVT_KILL_FOCUS
824 event
.SetEventObject( this );
825 GetEventHandler()->ProcessEvent(event
);
831 wxCommandEvent
event(wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
832 wxString
val(GetValue());
834 event
.m_commandString
= WXSTRINGCAST val
;
835 event
.SetEventObject( this );
836 ProcessCommand(event
);
841 // the text size limit has been hit - increase it
845 // the other notification messages are not processed
858 void wxTextCtrl::AdjustSpaceLimit()
861 unsigned int len
= ::GetWindowTextLength(GetHwnd()),
862 limit
= ::SendMessage(GetHwnd(), EM_GETLIMITTEXT
, 0, 0);
865 limit
= len
+ 0x8000; // 32Kb
868 if ( m_isRich
|| limit
> 0xffff )
870 if ( limit
> 0xffff )
872 ::SendMessage(GetHwnd(), EM_LIMITTEXT
, 0, limit
);
874 ::SendMessage(GetHwnd(), EM_LIMITTEXT
, limit
, 0);
879 bool wxTextCtrl::AcceptsFocus() const
881 // we don't want focus if we can't be edited
882 return IsEditable() && wxControl::AcceptsFocus();
885 wxSize
wxTextCtrl::DoGetBestSize()
888 wxGetCharSize(GetHWND(), &cx
, &cy
, &GetFont());
890 int wText
= DEFAULT_ITEM_WIDTH
;
892 int hText
= EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy
);
893 if ( m_windowStyle
& wxTE_MULTILINE
)
895 hText
*= wxMin(GetNumberOfLines(), 5);
897 //else: for single line control everything is ok
899 return wxSize(wText
, hText
);
902 // ----------------------------------------------------------------------------
903 // standard handlers for standard edit menu events
904 // ----------------------------------------------------------------------------
906 void wxTextCtrl::OnCut(wxCommandEvent
& event
)
911 void wxTextCtrl::OnCopy(wxCommandEvent
& event
)
916 void wxTextCtrl::OnPaste(wxCommandEvent
& event
)
921 void wxTextCtrl::OnUndo(wxCommandEvent
& event
)
926 void wxTextCtrl::OnRedo(wxCommandEvent
& event
)
931 void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent
& event
)
933 event
.Enable( CanCut() );
936 void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent
& event
)
938 event
.Enable( CanCopy() );
941 void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent
& event
)
943 event
.Enable( CanPaste() );
946 void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent
& event
)
948 event
.Enable( CanUndo() );
951 void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent
& event
)
953 event
.Enable( CanRedo() );