Пример #1
0
void wxTextCtrl::DoWriteText(const wxString& value, int flags)
{
    bool selectionOnly = (flags & SetValue_SelectionOnly) != 0;
    wxString valueDos;
    if ( m_windowStyle & wxTE_MULTILINE )
        valueDos = wxTextFile::Translate(value, wxTextFileType_Dos);
    else
        valueDos = value;

    // in some cases we get 2 EN_CHANGE notifications after the SendMessage
    // call below which is confusing for the client code and so should be
    // avoided
    //
    if ( selectionOnly && HasSelection() )
    {
        m_suppressNextUpdate = true;
    }

    ::SendMessage(GetBuddyHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT,
                  0, (LPARAM)valueDos.c_str());

    if ( !selectionOnly && !( flags & SetValue_SendEvent ) )
    {
        // Windows already sends an update event for single-line
        // controls.
        if ( m_windowStyle & wxTE_MULTILINE )
            SendUpdateEvent();
    }

    AdjustSpaceLimit();
}
Пример #2
0
bool wxTextCtrl::OS2Command(
  WXUINT                            uParam
, WXWORD                            WXUNUSED(vId)
)
{
    switch (uParam)
    {
        case EN_SETFOCUS:
        case EN_KILLFOCUS:
            {
                wxFocusEvent        vEvent( uParam == EN_KILLFOCUS ? wxEVT_KILL_FOCUS
                                                                   : wxEVT_SET_FOCUS
                                           ,m_windowId
                                          );

                vEvent.SetEventObject(this);
                GetEventHandler()->ProcessEvent(vEvent);
            }
            break;

        case EN_CHANGE:
            {
                if (m_bSkipUpdate)
                {
                    m_bSkipUpdate = false;
                    break;
                }

                wxCommandEvent      vEvent( wxEVT_COMMAND_TEXT_UPDATED
                                           ,m_windowId
                                          );

                InitCommandEvent(vEvent);
                ProcessCommand(vEvent);
            }
            break;

        case EN_OVERFLOW:
            //
            // The text size limit has been hit - increase it
            //
            AdjustSpaceLimit();
            break;

        case EN_SCROLL:
        case EN_INSERTMODETOGGLE:
        case EN_MEMERROR:
            return false;
        default:
            return false;
    }

    //
    // Processed
    //
    return true;
} // end of wxTextCtrl::OS2Command
Пример #3
0
void wxTextCtrl::WriteText(
  const wxString&                   rsValue
)
{
    if (m_bIsMLE)
        ::WinSendMsg(GetHwnd(), MLM_INSERT, MPARAM((PCHAR)rsValue.c_str()), MPARAM(0));
    else
        ::WinSetWindowText(GetHwnd(), (PSZ)rsValue.c_str());
    AdjustSpaceLimit();
} // end of wxTextCtrl::WriteText
Пример #4
0
bool wxTextCtrl::LoadFile(const wxString& file)
{
    if ( wxTextCtrlBase::LoadFile(file) )
    {
        // update the size limit if needed
        AdjustSpaceLimit();

        return true;
    }

    return false;
}
Пример #5
0
bool wxTextCtrl::DoLoadFile(
  const wxString&                   rsFile,
  int                               fileType
)
{
    if ( wxTextCtrlBase::DoLoadFile(rsFile, fileType) )
    {
        //
        // Update the size limit if needed
        //
        AdjustSpaceLimit();
        return true;
    }
    return false;
} // end of wxTextCtrl::DoLoadFile
Пример #6
0
void wxTextCtrl::DoSetValue(
  const wxString&                   rsValue,
  int flags
)
{
    //
    // If the text is long enough, it's faster to just set it instead of first
    // comparing it with the old one (chances are that it will be different
    // anyhow, this comparison is there to avoid flicker for small single-line
    // edit controls mostly)
    //
    if ((rsValue.length() > 0x400) || (rsValue != GetValue()))
    {
        if ( flags & SetValue_SendEvent )
            m_bSkipUpdate = true;

        ::WinSetWindowText(GetHwnd(), (PSZ)rsValue.c_str());
        AdjustSpaceLimit();
    }
} // end of wxTextCtrl::SetValue
Пример #7
0
bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
{
    switch ( param )
    {
        case EN_SETFOCUS:
        case EN_KILLFOCUS:
            {
                wxFocusEvent event(param == EN_KILLFOCUS ? wxEVT_KILL_FOCUS
                                                         : wxEVT_SET_FOCUS,
                                   m_windowId);
                event.SetEventObject(this);
                GetEventHandler()->ProcessEvent(event);
            }
            break;

        case EN_CHANGE:
            SendUpdateEvent();
            break;

        case EN_MAXTEXT:
            // the text size limit has been hit -- try to increase it
            if ( !AdjustSpaceLimit() )
            {
                wxCommandEvent event(wxEVT_COMMAND_TEXT_MAXLEN, m_windowId);
                InitCommandEvent(event);
                event.SetString(GetValue());
                ProcessCommand(event);
            }
            break;

            // the other edit notification messages are not processed
        default:
            return false;
    }

    // processed
    return true;
}