1. Harm's patch for AppendText()

2. Kbd processing seems to work (dlg navigation keys, wxTE_PROCESS_TAB &c)
3. controls sample updated to use AppendText() and test kbd navigation


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1571 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-02-02 22:23:44 +00:00
parent abaa293664
commit 5fb9fcfc01
4 changed files with 101 additions and 61 deletions

View File

@@ -125,6 +125,9 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
long msStyle = ES_LEFT | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
if (m_windowStyle & wxTE_MULTILINE)
{
wxASSERT_MSG( !(m_windowStyle & wxTE_PROCESS_ENTER),
"wxTE_PROCESS_ENTER style is ignored for multiline controls" );
msStyle |= ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL ; // WS_BORDER
m_windowStyle |= wxTE_PROCESS_ENTER;
}
@@ -630,9 +633,14 @@ void wxTextCtrl::WriteText(const wxString& text)
delete[] newtext;
}
void wxTextCtrl::AppendText(const wxString& text)
{
SetInsertionPointEnd();
WriteText(text);
}
void wxTextCtrl::Clear()
{
// SendMessage((HWND) GetHWND(), WM_SETTEXT, 0, (LPARAM)"");
SetWindowText((HWND) GetHWND(), "");
}
@@ -809,7 +817,7 @@ int wxTextCtrl::overflow(int c)
txt[plen] = (char)c; // append c
txt[plen+xtra] = '\0'; // append '\0' or overwrite c
// If the put area already contained \0, output will be truncated there
WriteText(txt);
AppendText(txt);
delete[] txt;
}
@@ -874,15 +882,15 @@ int wxTextCtrl::underflow()
wxTextCtrl& wxTextCtrl::operator<<(const wxString& s)
{
WriteText(s);
return *this;
AppendText(s);
return *this;
}
wxTextCtrl& wxTextCtrl::operator<<(float f)
{
wxString str;
str.Printf("%.2f", f);
WriteText(str);
AppendText(str);
return *this;
}
@@ -890,7 +898,7 @@ wxTextCtrl& wxTextCtrl::operator<<(double d)
{
wxString str;
str.Printf("%.2f", d);
WriteText(str);
AppendText(str);
return *this;
}
@@ -898,7 +906,7 @@ wxTextCtrl& wxTextCtrl::operator<<(int i)
{
wxString str;
str.Printf("%d", i);
WriteText(str);
AppendText(str);
return *this;
}
@@ -906,7 +914,7 @@ wxTextCtrl& wxTextCtrl::operator<<(long i)
{
wxString str;
str.Printf("%ld", i);
WriteText(str);
AppendText(str);
return *this;
}
@@ -916,7 +924,7 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c)
buf[0] = c;
buf[1] = 0;
WriteText(buf);
AppendText(buf);
return *this;
}
@@ -969,23 +977,32 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
case WXK_RETURN:
wxASSERT_MSG( m_windowStyle & wxTE_PROCESS_ENTER,
"this text ctrl should never receive return" );
if ( m_windowStyle & wxTE_MULTILINE == 0 )
{
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
event.SetEventObject( this );
if ( GetEventHandler()->ProcessEvent(event) )
return;
}
//else: multiline controls need Enter for themselves
break;
case WXK_TAB:
// only produce navigation event if we don't process TAB ourself
if ( !(m_windowStyle & wxTE_PROCESS_TAB) )
// only produce navigation event if we don't process TAB ourself or
// if it's a Shift-Tab keypress (we assume nobody will ever need
// this key combo for himself)
//
// NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is
// handled by Windows
if ( event.ShiftDown() || !(m_windowStyle & wxTE_PROCESS_TAB) )
{
wxNavigationKeyEvent event;
event.SetDirection(!(::GetKeyState(VK_SHIFT) & 0x100));
event.SetWindowChange(FALSE);
event.SetEventObject(this);
wxNavigationKeyEvent eventNav;
eventNav.SetDirection(!event.ShiftDown());
eventNav.SetWindowChange(FALSE);
eventNav.SetEventObject(this);
if ( GetEventHandler()->ProcessEvent(event) )
if ( GetEventHandler()->ProcessEvent(eventNav) )
return;
}
}

View File

@@ -1201,7 +1201,6 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
break;
}
#if 0
case WM_KEYDOWN:
{
MSWOnKeyDown((WORD) wParam, lParam);
@@ -1224,7 +1223,6 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
return Default();
break;
}
#endif
case WM_KEYUP:
{
@@ -1933,7 +1931,7 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
bool bCtrlDown = (::GetKeyState(VK_CONTROL) & 0x100) != 0;
// WM_GETDLGCODE: if the control wants it for itself, don't process it
// (except for Ctrl-Tab combination which is always processed)
// (except for Ctrl-Tab/Enter combinations which are always processed)
LONG lDlgCode = 0;
if ( bProcess && !bCtrlDown ) {
lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0);
@@ -1973,10 +1971,19 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
if ( !GetDefaultItem() ) {
// but if there is not it makes sense to make it work
// like a TAB
if ( bCtrlDown || (lDlgCode & DLGC_WANTMESSAGE == 0) )
{
// nothing to do - all variables are already set
// nothing to do - all variables are already set
break;
break;
}
else
{
// control wants to process Enter itself, don't
// call IsDialogMessage() which would interpret
// it
return FALSE;
}
}
//else: fall through and don't process the message