{
#if wxUSE_RICHEDIT
m_verRichEdit = 0;
-#endif
+
+ m_suppressNextUpdate = FALSE;
+#endif // wxUSE_RICHEDIT
}
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
#if wxUSE_RICHEDIT
if ( IsRich() )
{
- // enable the events we're interested in: we want to get EN_CHANGE and
- // EN_UPDATE as for the normal controls
- LPARAM mask = ENM_CHANGE | ENM_UPDATE;
+ // enable the events we're interested in: we want to get EN_CHANGE as
+ // for the normal controls
+ LPARAM mask = ENM_CHANGE;
if ( GetRichVersion() == 1 )
{
extern long wxEncodingToCodepage(wxFontEncoding encoding); // from utils.cpp
+#ifdef __WXWINE__
+bool wxTextCtrl::StreamIn(const wxString& value,
+ wxFontEncoding WXUNUSED(encoding),
+ bool selectionOnly)
+{
+ return FALSE;
+}
+#else
+
#if wxUSE_UNICODE_MSLU
bool wxTextCtrl::StreamIn(const wxString& value,
wxFontEncoding WXUNUSED(encoding),
return TRUE;
}
+#endif
+ // __WXWINE__
+
#endif // wxUSE_RICHEDIT
void wxTextCtrl::WriteText(const wxString& value)
}
#endif // wxUSE_UNICODE_MSLU
-#if !wxUSE_UNICODE
+#if !wxUSE_UNICODE && !defined(__WXWINE__)
// next check if the text we're inserting must be shown in a non
// default charset -- this only works for RichEdit > 1.0
if ( GetRichVersion() > 1 )
if ( !done )
#endif // wxUSE_RICHEDIT
{
- if ( !selectionOnly )
+#if wxUSE_RICHEDIT
+ // rich edit text control sends us 2 EN_CHANGE events when we send
+ // WM_SETTEXT to it, we have to suppress one of them to make wxTextCtrl
+ // behaviour consistent
+ if ( IsRich() )
{
- //SetSelection(-1, -1);
- // This eliminates an annoying flashing effect
- // when replacing all text.
- Clear();
+ m_suppressNextUpdate = TRUE;
}
+#endif // wxUSE_RICHEDIT
- ::SendMessage(GetHwnd(), EM_REPLACESEL, 0, (LPARAM)valueDos.c_str());
+ ::SendMessage(GetHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT,
+ 0, (LPARAM)valueDos.c_str());
}
AdjustSpaceLimit();
void wxTextCtrl::Clear()
{
::SetWindowText(GetHwnd(), wxT(""));
+
+#if wxUSE_RICHEDIT
+ if ( !IsRich() )
+#endif // wxUSE_RICHEDIT
+ {
+ // rich edit controls send EN_UPDATE from WM_SETTEXT handler themselves
+ // but the normal ones don't -- make Clear() behaviour consistent by
+ // always sending this event
+ SendUpdateEvent();
+ }
}
#ifdef __WIN32__
}
else // no Alt
{
- if ( wxIsCtrlDown() )
+ // we want to process some Ctrl-foo and Shift-bar but no key
+ // combinations without either Ctrl or Shift nor with both of them
+ // pressed
+ const int ctrl = wxIsCtrlDown(),
+ shift = wxIsShiftDown();
+ switch ( ctrl + shift )
{
- switch ( vkey )
- {
- case 'C':
- case 'V':
- case 'X':
- case VK_INSERT:
- case VK_DELETE:
- case VK_HOME:
- case VK_END:
- return FALSE;
- }
- }
- else if ( wxIsShiftDown() )
- {
- if ( vkey == VK_INSERT || vkey == VK_DELETE )
- return FALSE;
+ default:
+ wxFAIL_MSG( _T("how many modifiers have we got?") );
+ // fall through
+
+ case 0:
+ case 2:
+ break;
+
+ case 1:
+ // either Ctrl or Shift pressed
+ if ( ctrl )
+ {
+ switch ( vkey )
+ {
+ case 'C':
+ case 'V':
+ case 'X':
+ case VK_INSERT:
+ case VK_DELETE:
+ case VK_HOME:
+ case VK_END:
+ return FALSE;
+ }
+ }
+ else // Shift is pressed
+ {
+ if ( vkey == VK_INSERT || vkey == VK_DELETE )
+ return FALSE;
+ }
}
}
}
// text control event processing
// ----------------------------------------------------------------------------
+bool wxTextCtrl::SendUpdateEvent()
+{
+ // is event reporting suspended?
+ if ( m_suppressNextUpdate )
+ {
+ // do process the next one
+ m_suppressNextUpdate = FALSE;
+
+ return FALSE;
+ }
+
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, GetId());
+ InitCommandEvent(event);
+ event.SetString(GetValue());
+
+ return ProcessCommand(event);
+}
+
bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
{
- switch (param)
+ switch ( param )
{
case EN_SETFOCUS:
case EN_KILLFOCUS:
wxFocusEvent event(param == EN_KILLFOCUS ? wxEVT_KILL_FOCUS
: wxEVT_SET_FOCUS,
m_windowId);
- event.SetEventObject( this );
+ event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event);
}
break;
case EN_CHANGE:
- {
- wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
- InitCommandEvent(event);
- event.SetString(GetValue());
- ProcessCommand(event);
- }
+ SendUpdateEvent();
break;
case EN_MAXTEXT:
- // the text size limit has been hit - increase it
+ // the text size limit has been hit -- try to increase it
if ( !AdjustSpaceLimit() )
{
wxCommandEvent event(wxEVT_COMMAND_TEXT_MAXLEN, m_windowId);
}
break;
- // the other notification messages are not processed
- case EN_UPDATE:
- case EN_ERRSPACE:
- case EN_HSCROLL:
- case EN_VSCROLL:
- return FALSE;
-
+ // the other edit notification messages are not processed
default:
return FALSE;
}
bool wxTextCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
{
+#ifndef __WXWINE__
NMHDR *hdr = (NMHDR* )lParam;
switch ( hdr->code )
{
- case EN_MSGFILTER:
+ case EN_MSGFILTER:
{
const MSGFILTER *msgf = (MSGFILTER *)lParam;
UINT msg = msgf->msg;
}
return TRUE;
}
-
+#endif
+
// not processed, leave it to the base class
return wxTextCtrlBase::MSWOnNotify(idCtrl, lParam, result);
}
// styling support for rich edit controls
// ----------------------------------------------------------------------------
+#if wxUSE_RICHEDIT
+
bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
{
+#ifdef __WXWINE__
+ return FALSE;
+#else
if ( !IsRich() )
{
// can't do it with normal text control
}
return ok;
+#endif
}
+bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style)
+{
+ if ( !wxTextCtrlBase::SetDefaultStyle(style) )
+ return FALSE;
+
+ // we have to do this or the style wouldn't apply for the text typed by the
+ // user
+ long posLast = GetLastPosition();
+ SetStyle(posLast, posLast, m_defaultStyle);
+
+ return TRUE;
+}
+
+#endif
+
// ----------------------------------------------------------------------------
// wxRichEditModule
// ----------------------------------------------------------------------------