#include <stdlib.h>
#if wxUSE_IOSTREAMH
-#include <fstream.h>
+# include <fstream.h>
#else
-#include <fstream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
+# include <fstream>
#endif
#include <sys/types.h>
const wxValidator& validator,
const wxString& name)
{
- m_fileName = "";
SetName(name);
SetValidator(validator);
if (parent) parent->AddChild(this);
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;
}
wxCHECK_MSG( m_hWnd, FALSE, "Failed to create text ctrl" );
-#if CTL3D
+#if wxUSE_CTL3D
if ( want3D )
{
Ctl3dSubclassCtl((HWND)m_hWnd);
SetWindowText((HWND) GetHWND(), (const char *)value);
}
-void wxTextCtrl::SetSize(int x, int y, int width, int height, int sizeFlags)
+void wxTextCtrl::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
int currentX, currentY;
GetPosition(¤tX, ¤tY);
void wxTextCtrl::Replace(long from, long to, const wxString& value)
{
+#if wxUSE_CLIPBOARD
HWND hWnd = (HWND) GetHWND();
long fromChar = from;
long toChar = to;
// Paste into edit control
SendMessage(hWnd, WM_PASTE, (WPARAM)0, (LPARAM)0L);
+#else
+ wxFAIL_MSG("wxTextCtrl::Replace not implemented if wxUSE_CLIPBOARD is 0.");
+#endif
}
void wxTextCtrl::Remove(long from, long to)
delete[] newtext;
}
+void wxTextCtrl::AppendText(const wxString& text)
+{
+ SetInsertionPointEnd();
+ WriteText(text);
+}
+
void wxTextCtrl::Clear()
{
-// SendMessage((HWND) GetHWND(), WM_SETTEXT, 0, (LPARAM)"");
SetWindowText((HWND) GetHWND(), "");
}
int linesToScroll = specifiedLineLineNo - currentLineLineNo;
-/*
- wxDebugMsg("Caret line: %d; Current visible line: %d; Specified line: %d; lines to scroll: %d\n",
- currentLineLineNo1, currentLineLineNo, specifiedLineLineNo, linesToScroll);
-*/
-
if (linesToScroll != 0)
(void)SendMessage(hWnd, EM_LINESCROLL, (WPARAM)0, (LPARAM)MAKELPARAM(linesToScroll, 0));
}
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;
}
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;
}
{
wxString str;
str.Printf("%.2f", d);
- WriteText(str);
+ AppendText(str);
return *this;
}
{
wxString str;
str.Printf("%d", i);
- WriteText(str);
+ AppendText(str);
return *this;
}
{
wxString str;
str.Printf("%ld", i);
- WriteText(str);
+ AppendText(str);
return *this;
}
buf[0] = c;
buf[1] = 0;
- WriteText(buf);
+ AppendText(buf);
return *this;
}
WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
-#if CTL3D
+#if wxUSE_CTL3D
if ( m_useCtl3D )
{
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
case '\\':
{
char c = (char)event.KeyCode();
- *this << c;
+ WriteText(c);
}
break;
case WXK_RETURN:
+ {
+/* Oh yes it will, because we also specify DLGC_WANTCHARS
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;
}
+ break;
}
// don't just call event.Skip() because this will cause TABs and ENTERs
// be passed upwards and we don't always want this - instead process it
// right here
Default();
+// event.Skip();
}
long wxTextCtrl::MSWGetDlgCode()