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:
@@ -6,7 +6,7 @@
|
|||||||
// Created: 01/02/97
|
// Created: 01/02/97
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart
|
// Copyright: (c) Julian Smart
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_TEXTCTRL_H_
|
#ifndef _WX_TEXTCTRL_H_
|
||||||
@@ -51,7 +51,7 @@ class WXDLLEXPORT wxTextCtrl: public wxControl
|
|||||||
|
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
|
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// creation
|
// creation
|
||||||
// --------
|
// --------
|
||||||
@@ -68,14 +68,14 @@ public:
|
|||||||
{
|
{
|
||||||
Create(parent, id, value, pos, size, style, validator, name);
|
Create(parent, id, value, pos, size, style, validator, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Create(wxWindow *parent, wxWindowID id,
|
bool Create(wxWindow *parent, wxWindowID id,
|
||||||
const wxString& value = wxEmptyString,
|
const wxString& value = wxEmptyString,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize, long style = wxTE_PROCESS_TAB,
|
const wxSize& size = wxDefaultSize, long style = wxTE_PROCESS_TAB,
|
||||||
const wxValidator& validator = wxDefaultValidator,
|
const wxValidator& validator = wxDefaultValidator,
|
||||||
const wxString& name = wxTextCtrlNameStr);
|
const wxString& name = wxTextCtrlNameStr);
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
// ---------
|
// ---------
|
||||||
virtual wxString GetValue() const ;
|
virtual wxString GetValue() const ;
|
||||||
@@ -91,12 +91,12 @@ public:
|
|||||||
void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
|
void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
|
||||||
{ wxWindow::SetSize(rect, sizeFlags); }
|
{ wxWindow::SetSize(rect, sizeFlags); }
|
||||||
void SetSize(const wxSize& size) { wxWindow::SetSize(size); }
|
void SetSize(const wxSize& size) { wxWindow::SetSize(size); }
|
||||||
|
|
||||||
// Clipboard operations
|
// Clipboard operations
|
||||||
virtual void Copy();
|
virtual void Copy();
|
||||||
virtual void Cut();
|
virtual void Cut();
|
||||||
virtual void Paste();
|
virtual void Paste();
|
||||||
|
|
||||||
virtual void SetInsertionPoint(long pos);
|
virtual void SetInsertionPoint(long pos);
|
||||||
virtual void SetInsertionPointEnd();
|
virtual void SetInsertionPointEnd();
|
||||||
virtual long GetInsertionPoint() const ;
|
virtual long GetInsertionPoint() const ;
|
||||||
@@ -105,42 +105,43 @@ public:
|
|||||||
virtual void Remove(long from, long to);
|
virtual void Remove(long from, long to);
|
||||||
virtual void SetSelection(long from, long to);
|
virtual void SetSelection(long from, long to);
|
||||||
virtual void SetEditable(bool editable);
|
virtual void SetEditable(bool editable);
|
||||||
|
|
||||||
// streambuf implementation
|
// streambuf implementation
|
||||||
#ifndef NO_TEXT_WINDOW_STREAM
|
#ifndef NO_TEXT_WINDOW_STREAM
|
||||||
int overflow(int i);
|
int overflow(int i);
|
||||||
int sync();
|
int sync();
|
||||||
int underflow();
|
int underflow();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxTextCtrl& operator<<(const wxString& s);
|
wxTextCtrl& operator<<(const wxString& s);
|
||||||
wxTextCtrl& operator<<(int i);
|
wxTextCtrl& operator<<(int i);
|
||||||
wxTextCtrl& operator<<(long i);
|
wxTextCtrl& operator<<(long i);
|
||||||
wxTextCtrl& operator<<(float f);
|
wxTextCtrl& operator<<(float f);
|
||||||
wxTextCtrl& operator<<(double d);
|
wxTextCtrl& operator<<(double d);
|
||||||
wxTextCtrl& operator<<(const char c);
|
wxTextCtrl& operator<<(const char c);
|
||||||
|
|
||||||
virtual bool LoadFile(const wxString& file);
|
virtual bool LoadFile(const wxString& file);
|
||||||
virtual bool SaveFile(const wxString& file);
|
virtual bool SaveFile(const wxString& file);
|
||||||
virtual void WriteText(const wxString& text);
|
virtual void WriteText(const wxString& text);
|
||||||
|
virtual void AppendText(const wxString& text);
|
||||||
virtual void DiscardEdits();
|
virtual void DiscardEdits();
|
||||||
virtual bool IsModified() const;
|
virtual bool IsModified() const;
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY
|
#if WXWIN_COMPATIBILITY
|
||||||
inline bool Modified() const { return IsModified(); }
|
inline bool Modified() const { return IsModified(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual long XYToPosition(long x, long y) const ;
|
virtual long XYToPosition(long x, long y) const ;
|
||||||
virtual void PositionToXY(long pos, long *x, long *y) const ;
|
virtual void PositionToXY(long pos, long *x, long *y) const ;
|
||||||
virtual void ShowPosition(long pos);
|
virtual void ShowPosition(long pos);
|
||||||
virtual void Clear();
|
virtual void Clear();
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
// ---------
|
// ---------
|
||||||
void OnDropFiles(wxDropFilesEvent& event);
|
void OnDropFiles(wxDropFilesEvent& event);
|
||||||
void OnChar(wxKeyEvent& event); // Process 'enter' if required
|
void OnChar(wxKeyEvent& event); // Process 'enter' if required
|
||||||
void OnEraseBackground(wxEraseEvent& event);
|
void OnEraseBackground(wxEraseEvent& event);
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
// --------------
|
// --------------
|
||||||
virtual void Command(wxCommandEvent& event);
|
virtual void Command(wxCommandEvent& event);
|
||||||
@@ -154,18 +155,18 @@ public:
|
|||||||
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||||
WXUINT message, WXWPARAM wParam,
|
WXUINT message, WXWPARAM wParam,
|
||||||
WXLPARAM lParam);
|
WXLPARAM lParam);
|
||||||
|
|
||||||
virtual void AdoptAttributesFromHWND();
|
virtual void AdoptAttributesFromHWND();
|
||||||
virtual void SetupColours();
|
virtual void SetupColours();
|
||||||
virtual long MSWGetDlgCode();
|
virtual long MSWGetDlgCode();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if wxUSE_RICHEDIT
|
#if wxUSE_RICHEDIT
|
||||||
bool m_isRich; // Are we using rich text edit to implement this?
|
bool m_isRich; // Are we using rich text edit to implement this?
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxString m_fileName;
|
wxString m_fileName;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -63,7 +63,7 @@ public:
|
|||||||
const wxPoint &pos, const wxSize &size, int style = 0)
|
const wxPoint &pos, const wxSize &size, int style = 0)
|
||||||
: wxTextCtrl(parent, id, value, pos, size, style) { }
|
: wxTextCtrl(parent, id, value, pos, size, style) { }
|
||||||
|
|
||||||
void OnChar(wxKeyEvent& event);
|
void OnKeyDown(wxKeyEvent& event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
@@ -125,6 +125,7 @@ class MyFrame: public wxFrame
|
|||||||
void OnQuit(wxCommandEvent& event);
|
void OnQuit(wxCommandEvent& event);
|
||||||
void OnAbout(wxCommandEvent& event);
|
void OnAbout(wxCommandEvent& event);
|
||||||
void OnIdle( wxIdleEvent& event );
|
void OnIdle( wxIdleEvent& event );
|
||||||
|
void OnSize( wxSizeEvent& event );
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
@@ -176,10 +177,10 @@ bool MyApp::OnInit(void)
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(MyTextCtrl, wxTextCtrl)
|
BEGIN_EVENT_TABLE(MyTextCtrl, wxTextCtrl)
|
||||||
EVT_CHAR(MyTextCtrl::OnChar)
|
EVT_KEY_DOWN(MyTextCtrl::OnKeyDown)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
void MyTextCtrl::OnChar(wxKeyEvent& event)
|
void MyTextCtrl::OnKeyDown(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
switch ( event.KeyCode() )
|
switch ( event.KeyCode() )
|
||||||
{
|
{
|
||||||
@@ -314,8 +315,9 @@ BEGIN_EVENT_TABLE(MyPanel, wxPanel)
|
|||||||
EVT_BUTTON (ID_MOVE_END_ENTRY, MyPanel::OnMoveToEndOfEntry)
|
EVT_BUTTON (ID_MOVE_END_ENTRY, MyPanel::OnMoveToEndOfEntry)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
|
MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
||||||
wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) )
|
: m_notebook(NULL), m_text(NULL),
|
||||||
|
wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) )
|
||||||
{
|
{
|
||||||
// SetBackgroundColour("cadet blue");
|
// SetBackgroundColour("cadet blue");
|
||||||
|
|
||||||
@@ -432,7 +434,10 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
|
|||||||
panel = new wxPanel(m_notebook);
|
panel = new wxPanel(m_notebook);
|
||||||
m_textentry = new MyTextCtrl( panel, -1, "Write text here.", wxPoint(10,10), wxSize(320,28),
|
m_textentry = new MyTextCtrl( panel, -1, "Write text here.", wxPoint(10,10), wxSize(320,28),
|
||||||
wxTE_PROCESS_ENTER);
|
wxTE_PROCESS_ENTER);
|
||||||
(*m_textentry) << " More text.";
|
(*m_textentry) << " More text."; // this text is appended
|
||||||
|
m_textentry->SetInsertionPoint(0);
|
||||||
|
m_textentry->WriteText("Less text."); // this text is prepended
|
||||||
|
|
||||||
m_multitext = new MyTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(320,70),
|
m_multitext = new MyTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(320,70),
|
||||||
wxTE_MULTILINE );
|
wxTE_MULTILINE );
|
||||||
(*m_multitext) << " More text.\nPress function keys to test different \nwxTextCtrl functions.";
|
(*m_multitext) << " More text.\nPress function keys to test different \nwxTextCtrl functions.";
|
||||||
@@ -608,16 +613,16 @@ void MyPanel::OnPageChanged( wxNotebookEvent &event )
|
|||||||
|
|
||||||
void MyPanel::OnListBox( wxCommandEvent &event )
|
void MyPanel::OnListBox( wxCommandEvent &event )
|
||||||
{
|
{
|
||||||
m_text->WriteText( "ListBox selection string is: " );
|
m_text->AppendText( "ListBox selection string is: " );
|
||||||
m_text->WriteText( event.GetString() );
|
m_text->AppendText( event.GetString() );
|
||||||
m_text->WriteText( "\n" );
|
m_text->AppendText( "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyPanel::OnListBoxDoubleClick( wxCommandEvent &event )
|
void MyPanel::OnListBoxDoubleClick( wxCommandEvent &event )
|
||||||
{
|
{
|
||||||
m_text->WriteText( "ListBox double click string is: " );
|
m_text->AppendText( "ListBox double click string is: " );
|
||||||
m_text->WriteText( event.GetString() );
|
m_text->AppendText( event.GetString() );
|
||||||
m_text->WriteText( "\n" );
|
m_text->AppendText( "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyPanel::OnListBoxButtons( wxCommandEvent &event )
|
void MyPanel::OnListBoxButtons( wxCommandEvent &event )
|
||||||
@@ -626,7 +631,7 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event )
|
|||||||
{
|
{
|
||||||
case ID_LISTBOX_ENABLE:
|
case ID_LISTBOX_ENABLE:
|
||||||
{
|
{
|
||||||
m_text->WriteText("Checkbox clicked.\n");
|
m_text->AppendText("Checkbox clicked.\n");
|
||||||
wxCheckBox *cb = (wxCheckBox*)event.GetEventObject();
|
wxCheckBox *cb = (wxCheckBox*)event.GetEventObject();
|
||||||
if (event.GetInt())
|
if (event.GetInt())
|
||||||
cb->SetToolTip( "Click to enable listbox" );
|
cb->SetToolTip( "Click to enable listbox" );
|
||||||
@@ -672,9 +677,9 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event )
|
|||||||
|
|
||||||
void MyPanel::OnChoice( wxCommandEvent &event )
|
void MyPanel::OnChoice( wxCommandEvent &event )
|
||||||
{
|
{
|
||||||
m_text->WriteText( "Choice selection string is: " );
|
m_text->AppendText( "Choice selection string is: " );
|
||||||
m_text->WriteText( event.GetString() );
|
m_text->AppendText( event.GetString() );
|
||||||
m_text->WriteText( "\n" );
|
m_text->AppendText( "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyPanel::OnChoiceButtons( wxCommandEvent &event )
|
void MyPanel::OnChoiceButtons( wxCommandEvent &event )
|
||||||
@@ -722,9 +727,9 @@ void MyPanel::OnChoiceButtons( wxCommandEvent &event )
|
|||||||
|
|
||||||
void MyPanel::OnCombo( wxCommandEvent &event )
|
void MyPanel::OnCombo( wxCommandEvent &event )
|
||||||
{
|
{
|
||||||
m_text->WriteText( "ComboBox selection string is: " );
|
m_text->AppendText( "ComboBox selection string is: " );
|
||||||
m_text->WriteText( event.GetString() );
|
m_text->AppendText( event.GetString() );
|
||||||
m_text->WriteText( "\n" );
|
m_text->AppendText( "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyPanel::OnComboButtons( wxCommandEvent &event )
|
void MyPanel::OnComboButtons( wxCommandEvent &event )
|
||||||
@@ -772,9 +777,9 @@ void MyPanel::OnComboButtons( wxCommandEvent &event )
|
|||||||
|
|
||||||
void MyPanel::OnRadio( wxCommandEvent &event )
|
void MyPanel::OnRadio( wxCommandEvent &event )
|
||||||
{
|
{
|
||||||
m_text->WriteText( "RadioBox selection string is: " );
|
m_text->AppendText( "RadioBox selection string is: " );
|
||||||
m_text->WriteText( event.GetString() );
|
m_text->AppendText( event.GetString() );
|
||||||
m_text->WriteText( "\n" );
|
m_text->AppendText( "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyPanel::OnRadioButtons( wxCommandEvent &event )
|
void MyPanel::OnRadioButtons( wxCommandEvent &event )
|
||||||
@@ -834,13 +839,14 @@ MyPanel::~MyPanel()
|
|||||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
EVT_MENU(MINIMAL_QUIT, MyFrame::OnQuit)
|
EVT_MENU(MINIMAL_QUIT, MyFrame::OnQuit)
|
||||||
EVT_MENU(MINIMAL_ABOUT, MyFrame::OnAbout)
|
EVT_MENU(MINIMAL_ABOUT, MyFrame::OnAbout)
|
||||||
|
EVT_SIZE(MyFrame::OnSize)
|
||||||
EVT_IDLE(MyFrame::OnIdle)
|
EVT_IDLE(MyFrame::OnIdle)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
|
MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
|
||||||
: wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
|
: wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
|
||||||
{
|
{
|
||||||
CreateStatusBar();
|
CreateStatusBar(2);
|
||||||
|
|
||||||
(void)new MyPanel( this, 10, 10, 300, 100 );
|
(void)new MyPanel( this, 10, 10, 300, 100 );
|
||||||
}
|
}
|
||||||
@@ -856,6 +862,15 @@ void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
|
|||||||
dialog.ShowModal();
|
dialog.ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnSize( wxSizeEvent& event )
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
msg.Printf("%dx%d", event.GetSize().x, event.GetSize().y);
|
||||||
|
SetStatusText(msg, 1);
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) )
|
void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
// track the window which has the focus in the status bar
|
// track the window which has the focus in the status bar
|
||||||
|
@@ -125,6 +125,9 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
long msStyle = ES_LEFT | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
|
long msStyle = ES_LEFT | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
|
||||||
if (m_windowStyle & wxTE_MULTILINE)
|
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
|
msStyle |= ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL ; // WS_BORDER
|
||||||
m_windowStyle |= wxTE_PROCESS_ENTER;
|
m_windowStyle |= wxTE_PROCESS_ENTER;
|
||||||
}
|
}
|
||||||
@@ -630,9 +633,14 @@ void wxTextCtrl::WriteText(const wxString& text)
|
|||||||
delete[] newtext;
|
delete[] newtext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxTextCtrl::AppendText(const wxString& text)
|
||||||
|
{
|
||||||
|
SetInsertionPointEnd();
|
||||||
|
WriteText(text);
|
||||||
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Clear()
|
void wxTextCtrl::Clear()
|
||||||
{
|
{
|
||||||
// SendMessage((HWND) GetHWND(), WM_SETTEXT, 0, (LPARAM)"");
|
|
||||||
SetWindowText((HWND) GetHWND(), "");
|
SetWindowText((HWND) GetHWND(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -809,7 +817,7 @@ int wxTextCtrl::overflow(int c)
|
|||||||
txt[plen] = (char)c; // append c
|
txt[plen] = (char)c; // append c
|
||||||
txt[plen+xtra] = '\0'; // append '\0' or overwrite c
|
txt[plen+xtra] = '\0'; // append '\0' or overwrite c
|
||||||
// If the put area already contained \0, output will be truncated there
|
// If the put area already contained \0, output will be truncated there
|
||||||
WriteText(txt);
|
AppendText(txt);
|
||||||
delete[] txt;
|
delete[] txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -874,15 +882,15 @@ int wxTextCtrl::underflow()
|
|||||||
|
|
||||||
wxTextCtrl& wxTextCtrl::operator<<(const wxString& s)
|
wxTextCtrl& wxTextCtrl::operator<<(const wxString& s)
|
||||||
{
|
{
|
||||||
WriteText(s);
|
AppendText(s);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxTextCtrl& wxTextCtrl::operator<<(float f)
|
wxTextCtrl& wxTextCtrl::operator<<(float f)
|
||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
str.Printf("%.2f", f);
|
str.Printf("%.2f", f);
|
||||||
WriteText(str);
|
AppendText(str);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -890,7 +898,7 @@ wxTextCtrl& wxTextCtrl::operator<<(double d)
|
|||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
str.Printf("%.2f", d);
|
str.Printf("%.2f", d);
|
||||||
WriteText(str);
|
AppendText(str);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -898,7 +906,7 @@ wxTextCtrl& wxTextCtrl::operator<<(int i)
|
|||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
str.Printf("%d", i);
|
str.Printf("%d", i);
|
||||||
WriteText(str);
|
AppendText(str);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -906,7 +914,7 @@ wxTextCtrl& wxTextCtrl::operator<<(long i)
|
|||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
str.Printf("%ld", i);
|
str.Printf("%ld", i);
|
||||||
WriteText(str);
|
AppendText(str);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -916,7 +924,7 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c)
|
|||||||
|
|
||||||
buf[0] = c;
|
buf[0] = c;
|
||||||
buf[1] = 0;
|
buf[1] = 0;
|
||||||
WriteText(buf);
|
AppendText(buf);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -969,23 +977,32 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
wxASSERT_MSG( m_windowStyle & wxTE_PROCESS_ENTER,
|
wxASSERT_MSG( m_windowStyle & wxTE_PROCESS_ENTER,
|
||||||
"this text ctrl should never receive return" );
|
"this text ctrl should never receive return" );
|
||||||
|
if ( m_windowStyle & wxTE_MULTILINE == 0 )
|
||||||
{
|
{
|
||||||
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
|
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
|
||||||
event.SetEventObject( this );
|
event.SetEventObject( this );
|
||||||
if ( GetEventHandler()->ProcessEvent(event) )
|
if ( GetEventHandler()->ProcessEvent(event) )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//else: multiline controls need Enter for themselves
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case WXK_TAB:
|
case WXK_TAB:
|
||||||
// only produce navigation event if we don't process TAB ourself
|
// only produce navigation event if we don't process TAB ourself or
|
||||||
if ( !(m_windowStyle & wxTE_PROCESS_TAB) )
|
// 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;
|
wxNavigationKeyEvent eventNav;
|
||||||
event.SetDirection(!(::GetKeyState(VK_SHIFT) & 0x100));
|
eventNav.SetDirection(!event.ShiftDown());
|
||||||
event.SetWindowChange(FALSE);
|
eventNav.SetWindowChange(FALSE);
|
||||||
event.SetEventObject(this);
|
eventNav.SetEventObject(this);
|
||||||
|
|
||||||
if ( GetEventHandler()->ProcessEvent(event) )
|
if ( GetEventHandler()->ProcessEvent(eventNav) )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1201,7 +1201,6 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
{
|
{
|
||||||
MSWOnKeyDown((WORD) wParam, lParam);
|
MSWOnKeyDown((WORD) wParam, lParam);
|
||||||
@@ -1224,7 +1223,6 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
|
|||||||
return Default();
|
return Default();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
{
|
{
|
||||||
@@ -1933,7 +1931,7 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
|
|||||||
bool bCtrlDown = (::GetKeyState(VK_CONTROL) & 0x100) != 0;
|
bool bCtrlDown = (::GetKeyState(VK_CONTROL) & 0x100) != 0;
|
||||||
|
|
||||||
// WM_GETDLGCODE: if the control wants it for itself, don't process it
|
// 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;
|
LONG lDlgCode = 0;
|
||||||
if ( bProcess && !bCtrlDown ) {
|
if ( bProcess && !bCtrlDown ) {
|
||||||
lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0);
|
lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0);
|
||||||
@@ -1973,10 +1971,19 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
|
|||||||
if ( !GetDefaultItem() ) {
|
if ( !GetDefaultItem() ) {
|
||||||
// but if there is not it makes sense to make it work
|
// but if there is not it makes sense to make it work
|
||||||
// like a TAB
|
// 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
|
//else: fall through and don't process the message
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user