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 // Validator was set in CreateBase
119 //SetValidator(validator);
121 parent
->AddChild(this);
126 // translate wxWin style flags to MSW ones, checking for consistency while
128 long msStyle
= ES_LEFT
| WS_VISIBLE
| WS_CHILD
| WS_TABSTOP
;
129 if ( m_windowStyle
& wxTE_MULTILINE
)
131 wxASSERT_MSG( !(m_windowStyle
& wxTE_PROCESS_ENTER
),
132 T("wxTE_PROCESS_ENTER style is ignored for multiline "
133 "text controls (they always process it)") );
135 msStyle
|= ES_MULTILINE
| ES_WANTRETURN
;
136 if ((m_windowStyle
& wxTE_NO_VSCROLL
) == 0)
137 msStyle
|= WS_VSCROLL
;
138 m_windowStyle
|= wxTE_PROCESS_ENTER
;
141 msStyle
|= ES_AUTOHSCROLL
;
143 if (m_windowStyle
& wxHSCROLL
)
144 msStyle
|= (WS_HSCROLL
| ES_AUTOHSCROLL
);
146 if (m_windowStyle
& wxTE_READONLY
)
147 msStyle
|= ES_READONLY
;
149 if (m_windowStyle
& wxHSCROLL
)
150 msStyle
|= (WS_HSCROLL
| ES_AUTOHSCROLL
);
151 if (m_windowStyle
& wxTE_PASSWORD
) // hidden input
152 msStyle
|= ES_PASSWORD
;
154 // we always want the characters and the arrows
155 m_lDlgCode
= DLGC_WANTCHARS
| DLGC_WANTARROWS
;
157 // we may have several different cases:
158 // 1. normal case: both TAB and ENTER are used for dialog navigation
159 // 2. ctrl which wants TAB for itself: ENTER is used to pass to the next
160 // control in the dialog
161 // 3. ctrl which wants ENTER for itself: TAB is used for dialog navigation
162 // 4. ctrl which wants both TAB and ENTER: Ctrl-ENTER is used to pass to
164 if ( m_windowStyle
& wxTE_PROCESS_ENTER
)
165 m_lDlgCode
|= DLGC_WANTMESSAGE
;
166 if ( m_windowStyle
& wxTE_PROCESS_TAB
)
167 m_lDlgCode
|= DLGC_WANTTAB
;
169 // do create the control - either an EDIT or RICHEDIT
170 const wxChar
*windowClass
= T("EDIT");
173 if ( m_windowStyle
& wxTE_RICH
)
175 msStyle
|= ES_AUTOVSCROLL
;
177 windowClass
= T("RICHEDIT");
184 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
);
186 // Even with extended styles, need to combine with WS_BORDER for them to
188 if ( want3D
|| wxStyleHasBorder(m_windowStyle
) )
189 msStyle
|= WS_BORDER
;
191 // NB: don't use pos and size as CreateWindowEx arguments because they
192 // might be -1 in which case we should use the default values (and
193 // SetSize called below takes care of it)
194 m_hWnd
= (WXHWND
)::CreateWindowEx(exStyle
,
204 wxCHECK_MSG( m_hWnd
, FALSE
, T("Failed to create text ctrl") );
209 Ctl3dSubclassCtl(GetHwnd());
217 // Have to enable events
218 ::SendMessage(GetHwnd(), EM_SETEVENTMASK
, 0,
219 ENM_CHANGE
| ENM_DROPFILES
| ENM_SELCHANGE
| ENM_UPDATE
);
223 SubclassWin(GetHWND());
225 // set font, position, size and initial value
226 wxFont
& fontParent
= parent
->GetFont();
227 if ( fontParent
.Ok() )
233 SetFont(wxSystemSettings::GetSystemFont(wxSYS_SYSTEM_FONT
));
236 // Causes a crash for Symantec C++ and WIN32 for some reason
237 #if !(defined(__SC__) && defined(__WIN32__))
238 if ( !value
.IsEmpty() )
244 SetSize(pos
.x
, pos
.y
, size
.x
, size
.y
);
249 // Make sure the window style (etc.) reflects the HWND style (roughly)
250 void wxTextCtrl::AdoptAttributesFromHWND()
252 wxWindow::AdoptAttributesFromHWND();
254 HWND hWnd
= GetHwnd();
255 long style
= GetWindowLong(hWnd
, GWL_STYLE
);
257 // retrieve the style to see whether this is an edit or richedit ctrl
261 GetClassName(hWnd
, buf
, WXSIZEOF(buf
));
263 if ( wxStricmp(buf
, T("EDIT")) == 0 )
267 #endif // wxUSE_RICHEDIT
269 if (style
& ES_MULTILINE
)
270 m_windowStyle
|= wxTE_MULTILINE
;
271 if (style
& ES_PASSWORD
)
272 m_windowStyle
|= wxTE_PASSWORD
;
273 if (style
& ES_READONLY
)
274 m_windowStyle
|= wxTE_READONLY
;
275 if (style
& ES_WANTRETURN
)
276 m_windowStyle
|= wxTE_PROCESS_ENTER
;
279 void wxTextCtrl::SetupColours()
281 // FIXME why is bg colour not inherited from parent?
282 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW
));
283 SetForegroundColour(GetParent()->GetForegroundColour());
286 // ----------------------------------------------------------------------------
287 // set/get the controls text
288 // ----------------------------------------------------------------------------
290 wxString
wxTextCtrl::GetValue() const
292 return wxGetWindowText(GetHWND());
295 void wxTextCtrl::SetValue(const wxString
& value
)
297 wxString valueDos
= wxTextFile::Translate(value
, wxTextFileType_Dos
);
299 SetWindowText(GetHwnd(), valueDos
);
304 void wxTextCtrl::WriteText(const wxString
& value
)
306 wxString valueDos
= wxTextFile::Translate(value
, wxTextFileType_Dos
);
308 SendMessage(GetHwnd(), EM_REPLACESEL
, 0, (LPARAM
)valueDos
.c_str());
313 void wxTextCtrl::AppendText(const wxString
& text
)
315 SetInsertionPointEnd();
319 void wxTextCtrl::Clear()
321 SetWindowText(GetHwnd(), T(""));
324 // ----------------------------------------------------------------------------
325 // Clipboard operations
326 // ----------------------------------------------------------------------------
328 void wxTextCtrl::Copy()
332 HWND hWnd
= GetHwnd();
333 SendMessage(hWnd
, WM_COPY
, 0, 0L);
337 void wxTextCtrl::Cut()
341 HWND hWnd
= GetHwnd();
342 SendMessage(hWnd
, WM_CUT
, 0, 0L);
346 void wxTextCtrl::Paste()
350 HWND hWnd
= GetHwnd();
351 SendMessage(hWnd
, WM_PASTE
, 0, 0L);
355 bool wxTextCtrl::CanCopy() const
357 // Can copy if there's a selection
359 GetSelection(& from
, & to
);
363 bool wxTextCtrl::CanCut() const
365 // Can cut if there's a selection
367 GetSelection(& from
, & to
);
371 bool wxTextCtrl::CanPaste() const
376 int dataFormat
= 0; // 0 == any format
377 return (::SendMessage( GetHwnd(), EM_CANPASTE
, (WPARAM
) (UINT
) dataFormat
, 0) != 0);
383 // Standard edit control: check for straight text on clipboard
384 bool isTextAvailable
= FALSE
;
385 if ( ::OpenClipboard(GetHwndOf(wxTheApp
->GetTopWindow())) )
387 isTextAvailable
= (::IsClipboardFormatAvailable(CF_TEXT
) != 0);
391 return isTextAvailable
;
394 // ----------------------------------------------------------------------------
396 // ----------------------------------------------------------------------------
398 void wxTextCtrl::SetEditable(bool editable
)
400 HWND hWnd
= GetHwnd();
401 SendMessage(hWnd
, EM_SETREADONLY
, (WPARAM
)!editable
, (LPARAM
)0L);
404 void wxTextCtrl::SetInsertionPoint(long pos
)
406 HWND hWnd
= GetHwnd();
414 SendMessage(hWnd
, EM_EXSETSEL
, 0, (LPARAM
) &range
);
415 SendMessage(hWnd
, EM_SCROLLCARET
, (WPARAM
)0, (LPARAM
)0);
418 #endif // wxUSE_RICHEDIT
420 SendMessage(hWnd
, EM_SETSEL
, pos
, pos
);
421 SendMessage(hWnd
, EM_SCROLLCARET
, (WPARAM
)0, (LPARAM
)0);
424 SendMessage(hWnd
, EM_SETSEL
, 0, MAKELPARAM(pos
, pos
));
427 static const char *nothing
= "";
428 SendMessage(hWnd
, EM_REPLACESEL
, 0, (LPARAM
)nothing
);
431 void wxTextCtrl::SetInsertionPointEnd()
433 long pos
= GetLastPosition();
434 SetInsertionPoint(pos
);
437 long wxTextCtrl::GetInsertionPoint() const
445 SendMessage(GetHwnd(), EM_EXGETSEL
, 0, (LPARAM
) &range
);
450 DWORD Pos
= (DWORD
)SendMessage(GetHwnd(), EM_GETSEL
, 0, 0L);
454 long wxTextCtrl::GetLastPosition() const
456 HWND hWnd
= GetHwnd();
458 // Will always return a number > 0 (according to docs)
459 int noLines
= (int)SendMessage(hWnd
, EM_GETLINECOUNT
, (WPARAM
)0, (LPARAM
)0L);
461 // This gets the char index for the _beginning_ of the last line
462 int charIndex
= (int)SendMessage(hWnd
, EM_LINEINDEX
, (WPARAM
)(noLines
-1), (LPARAM
)0L);
464 // Get number of characters in the last line. We'll add this to the character
465 // index for the last line, 1st position.
466 int lineLength
= (int)SendMessage(hWnd
, EM_LINELENGTH
, (WPARAM
)charIndex
, (LPARAM
)0L);
468 return (long)(charIndex
+ lineLength
);
471 // If the return values from and to are the same, there is no
473 void wxTextCtrl::GetSelection(long* from
, long* to
) const
479 ::SendMessage(GetHwnd(), EM_EXGETSEL
, 0, (LPARAM
) (CHARRANGE
*) & charRange
);
481 *from
= charRange
.cpMin
;
482 *to
= charRange
.cpMax
;
487 DWORD dwStart
, dwEnd
;
488 WPARAM wParam
= (WPARAM
) (DWORD
*) & dwStart
; // receives starting position
489 LPARAM lParam
= (LPARAM
) (DWORD
*) & dwEnd
; // receives ending position
491 ::SendMessage(GetHwnd(), EM_GETSEL
, wParam
, lParam
);
497 bool wxTextCtrl::IsEditable() const
499 long style
= ::GetWindowLong(GetHwnd(), GWL_STYLE
);
501 return ((style
& ES_READONLY
) == 0);
504 // ----------------------------------------------------------------------------
506 // ----------------------------------------------------------------------------
508 void wxTextCtrl::Replace(long from
, long to
, const wxString
& value
)
511 HWND hWnd
= GetHwnd();
512 long fromChar
= from
;
515 // Set selection and remove it
517 SendMessage(hWnd
, EM_SETSEL
, fromChar
, toChar
);
519 SendMessage(hWnd
, EM_SETSEL
, (WPARAM
)0, (LPARAM
)MAKELONG(fromChar
, toChar
));
521 SendMessage(hWnd
, WM_CUT
, (WPARAM
)0, (LPARAM
)0);
523 // Now replace with 'value', by pasting.
524 wxSetClipboardData(wxDF_TEXT
, (wxObject
*) (const wxChar
*)value
, 0, 0);
526 // Paste into edit control
527 SendMessage(hWnd
, WM_PASTE
, (WPARAM
)0, (LPARAM
)0L);
529 wxFAIL_MSG("wxTextCtrl::Replace not implemented if wxUSE_CLIPBOARD is 0.");
533 void wxTextCtrl::Remove(long from
, long to
)
535 HWND hWnd
= GetHwnd();
536 long fromChar
= from
;
539 // Cut all selected text
541 SendMessage(hWnd
, EM_SETSEL
, fromChar
, toChar
);
543 SendMessage(hWnd
, EM_SETSEL
, (WPARAM
)0, (LPARAM
)MAKELONG(fromChar
, toChar
));
545 SendMessage(hWnd
, WM_CUT
, (WPARAM
)0, (LPARAM
)0);
548 void wxTextCtrl::SetSelection(long from
, long to
)
550 HWND hWnd
= GetHwnd();
551 long fromChar
= from
;
554 // if from and to are both -1, it means (in wxWindows) that all text should
555 // be selected. Translate into Windows convention
556 if ((from
== -1) && (to
== -1))
563 SendMessage(hWnd
, EM_SETSEL
, (WPARAM
)fromChar
, (LPARAM
)toChar
);
564 SendMessage(hWnd
, EM_SCROLLCARET
, (WPARAM
)0, (LPARAM
)0);
566 // WPARAM is 0: selection is scrolled into view
567 SendMessage(hWnd
, EM_SETSEL
, (WPARAM
)0, (LPARAM
)MAKELONG(fromChar
, toChar
));
571 bool wxTextCtrl::LoadFile(const wxString
& file
)
573 if ( wxTextCtrlBase::LoadFile(file
) )
575 // update the size limit if needed
584 bool wxTextCtrl::IsModified() const
586 return (SendMessage(GetHwnd(), EM_GETMODIFY
, 0, 0) != 0);
589 // Makes 'unmodified'
590 void wxTextCtrl::DiscardEdits()
592 SendMessage(GetHwnd(), EM_SETMODIFY
, FALSE
, 0L);
595 int wxTextCtrl::GetNumberOfLines() const
597 return (int)SendMessage(GetHwnd(), EM_GETLINECOUNT
, (WPARAM
)0, (LPARAM
)0);
600 long wxTextCtrl::XYToPosition(long x
, long y
) const
602 HWND hWnd
= GetHwnd();
604 // This gets the char index for the _beginning_ of this line
605 int charIndex
= (int)SendMessage(hWnd
, EM_LINEINDEX
, (WPARAM
)y
, (LPARAM
)0);
606 return (long)(x
+ charIndex
);
609 bool wxTextCtrl::PositionToXY(long pos
, long *x
, long *y
) const
611 HWND hWnd
= GetHwnd();
613 // This gets the line number containing the character
618 lineNo
= (int)SendMessage(hWnd
, EM_EXLINEFROMCHAR
, 0, (LPARAM
)pos
);
621 #endif // wxUSE_RICHEDIT
622 lineNo
= (int)SendMessage(hWnd
, EM_LINEFROMCHAR
, (WPARAM
)pos
, 0);
630 // This gets the char index for the _beginning_ of this line
631 int charIndex
= (int)SendMessage(hWnd
, EM_LINEINDEX
, (WPARAM
)lineNo
, (LPARAM
)0);
632 if ( charIndex
== -1 )
637 // The X position must therefore be the different between pos and charIndex
639 *x
= (long)(pos
- charIndex
);
646 void wxTextCtrl::ShowPosition(long pos
)
648 HWND hWnd
= GetHwnd();
650 // To scroll to a position, we pass the number of lines and characters
651 // to scroll *by*. This means that we need to:
652 // (1) Find the line position of the current line.
653 // (2) Find the line position of pos.
654 // (3) Scroll by (pos - current).
655 // For now, ignore the horizontal scrolling.
657 // Is this where scrolling is relative to - the line containing the caret?
658 // Or is the first visible line??? Try first visible line.
659 // int currentLineLineNo1 = (int)SendMessage(hWnd, EM_LINEFROMCHAR, (WPARAM)-1, (LPARAM)0L);
661 int currentLineLineNo
= (int)SendMessage(hWnd
, EM_GETFIRSTVISIBLELINE
, (WPARAM
)0, (LPARAM
)0L);
663 int specifiedLineLineNo
= (int)SendMessage(hWnd
, EM_LINEFROMCHAR
, (WPARAM
)pos
, (LPARAM
)0L);
665 int linesToScroll
= specifiedLineLineNo
- currentLineLineNo
;
667 if (linesToScroll
!= 0)
668 (void)SendMessage(hWnd
, EM_LINESCROLL
, (WPARAM
)0, (LPARAM
)linesToScroll
);
671 int wxTextCtrl::GetLineLength(long lineNo
) const
673 long charIndex
= XYToPosition(0, lineNo
);
674 int len
= (int)SendMessage(GetHwnd(), EM_LINELENGTH
, charIndex
, 0);
678 wxString
wxTextCtrl::GetLineText(long lineNo
) const
680 size_t len
= (size_t)GetLineLength(lineNo
) + 1;
681 char *buf
= (char *)malloc(len
);
683 int noChars
= (int)SendMessage(GetHwnd(), EM_GETLINE
, lineNo
, (LPARAM
)buf
);
693 // ----------------------------------------------------------------------------
695 // ----------------------------------------------------------------------------
697 void wxTextCtrl::Undo()
701 ::SendMessage(GetHwnd(), EM_UNDO
, 0, 0);
705 void wxTextCtrl::Redo()
709 // Same as Undo, since Undo undoes the undo, i.e. a redo.
710 ::SendMessage(GetHwnd(), EM_UNDO
, 0, 0);
714 bool wxTextCtrl::CanUndo() const
716 return (::SendMessage(GetHwnd(), EM_CANUNDO
, 0, 0) != 0);
719 bool wxTextCtrl::CanRedo() const
721 return (::SendMessage(GetHwnd(), EM_CANUNDO
, 0, 0) != 0);
724 // ----------------------------------------------------------------------------
725 // implemenation details
726 // ----------------------------------------------------------------------------
728 void wxTextCtrl::Command(wxCommandEvent
& event
)
730 SetValue(event
.GetString());
731 ProcessCommand (event
);
734 void wxTextCtrl::OnDropFiles(wxDropFilesEvent
& event
)
736 // By default, load the first file into the text window.
737 if (event
.GetNumberOfFiles() > 0)
739 LoadFile(event
.GetFiles()[0]);
743 WXHBRUSH
wxTextCtrl::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
744 WXUINT message
, WXWPARAM wParam
,
750 HBRUSH hbrush
= Ctl3dCtlColorEx(message
, wParam
, lParam
);
751 return (WXHBRUSH
) hbrush
;
756 SetBkMode(hdc
, GetParent()->GetTransparentBackground() ? TRANSPARENT
759 ::SetBkColor(hdc
, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
760 ::SetTextColor(hdc
, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
762 wxBrush
*backgroundBrush
= wxTheBrushList
->FindOrCreateBrush(GetBackgroundColour(), wxSOLID
);
764 return (WXHBRUSH
) backgroundBrush
->GetResourceHandle();
767 void wxTextCtrl::OnChar(wxKeyEvent
& event
)
769 switch ( event
.KeyCode() )
772 if ( !(m_windowStyle
& wxTE_MULTILINE
) )
774 wxCommandEvent
event(wxEVT_COMMAND_TEXT_ENTER
, m_windowId
);
775 event
.SetEventObject( this );
776 if ( GetEventHandler()->ProcessEvent(event
) )
779 //else: multiline controls need Enter for themselves
784 // always produce navigation event - even if we process TAB
785 // ourselves the fact that we got here means that the user code
786 // decided to skip processing of this TAB - probably to let it
787 // do its default job.
789 // NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is
790 // handled by Windows
792 wxNavigationKeyEvent eventNav
;
793 eventNav
.SetDirection(!event
.ShiftDown());
794 eventNav
.SetWindowChange(FALSE
);
795 eventNav
.SetEventObject(this);
797 if ( GetEventHandler()->ProcessEvent(eventNav
) )
807 // don't just call event.Skip() because this will cause TABs and ENTERs
808 // be passed upwards and we don't always want this - instead process it
815 bool wxTextCtrl::MSWCommand(WXUINT param
, WXWORD
WXUNUSED(id
))
822 wxFocusEvent
event(param
== EN_KILLFOCUS
? wxEVT_KILL_FOCUS
825 event
.SetEventObject( this );
826 GetEventHandler()->ProcessEvent(event
);
832 wxCommandEvent
event(wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
833 wxString
val(GetValue());
835 event
.m_commandString
= WXSTRINGCAST val
;
836 event
.SetEventObject( this );
837 ProcessCommand(event
);
842 // the text size limit has been hit - increase it
846 // the other notification messages are not processed
859 void wxTextCtrl::AdjustSpaceLimit()
862 unsigned int len
= ::GetWindowTextLength(GetHwnd()),
863 limit
= ::SendMessage(GetHwnd(), EM_GETLIMITTEXT
, 0, 0);
866 limit
= len
+ 0x8000; // 32Kb
869 if ( m_isRich
|| limit
> 0xffff )
871 if ( limit
> 0xffff )
873 ::SendMessage(GetHwnd(), EM_LIMITTEXT
, 0, limit
);
875 ::SendMessage(GetHwnd(), EM_LIMITTEXT
, limit
, 0);
880 bool wxTextCtrl::AcceptsFocus() const
882 // we don't want focus if we can't be edited
883 return IsEditable() && wxControl::AcceptsFocus();
886 wxSize
wxTextCtrl::DoGetBestSize()
889 wxGetCharSize(GetHWND(), &cx
, &cy
, &GetFont());
891 int wText
= DEFAULT_ITEM_WIDTH
;
893 int hText
= EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy
);
894 if ( m_windowStyle
& wxTE_MULTILINE
)
896 hText
*= wxMin(GetNumberOfLines(), 5);
898 //else: for single line control everything is ok
900 return wxSize(wText
, hText
);
903 // ----------------------------------------------------------------------------
904 // standard handlers for standard edit menu events
905 // ----------------------------------------------------------------------------
907 void wxTextCtrl::OnCut(wxCommandEvent
& event
)
912 void wxTextCtrl::OnCopy(wxCommandEvent
& event
)
917 void wxTextCtrl::OnPaste(wxCommandEvent
& event
)
922 void wxTextCtrl::OnUndo(wxCommandEvent
& event
)
927 void wxTextCtrl::OnRedo(wxCommandEvent
& event
)
932 void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent
& event
)
934 event
.Enable( CanCut() );
937 void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent
& event
)
939 event
.Enable( CanCopy() );
942 void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent
& event
)
944 event
.Enable( CanPaste() );
947 void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent
& event
)
949 event
.Enable( CanUndo() );
952 void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent
& event
)
954 event
.Enable( CanRedo() );