Пример #1
0
bool wxTextAreaBase::DoLoadFile(const wxString& filename, int WXUNUSED(fileType))
{
#if wxUSE_FFILE
    wxFFile file(filename);
    if ( file.IsOpened() )
    {
        wxString text;
        if ( file.ReadAll(&text) )
        {
            SetValue(text);

            DiscardEdits();
            m_filename = filename;

            return true;
        }
    }
#else
    (void)filename;   // avoid compiler warning about unreferenced parameter
#endif // wxUSE_FFILE

    wxLogError(_("File couldn't be loaded."));

    return false;
}
Пример #2
0
void wxTextCtrl::DoSetValue(const wxString& value, 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 ( (value.length() > 0x400) || (value != GetValue()) )
    {
        DoWriteText(value, flags);

        // for compatibility, don't move the cursor when doing SetValue()
        SetInsertionPoint(0);
    }
    else // same text
    {
        // still send an event for consistency
        if ( flags & SetValue_SendEvent )
            SendUpdateEvent();
    }

    // we should reset the modified flag even if the value didn't really change

    // mark the control as being not dirty - we changed its text, not the
    // user
    DiscardEdits();
}
Пример #3
0
bool wxTextCtrlBase::SaveFile(const wxString& filename)
{
    wxString filenameToUse = filename.empty() ? m_filename : filename;
    if ( filenameToUse.empty() )
    {
        // what kind of message to give? is it an error or a program bug?
        wxLogDebug(wxT("Can't save textctrl to file without filename."));

        return false;
    }

#if wxUSE_FFILE
    wxFFile file(filenameToUse, _T("w"));
    if ( file.IsOpened() && file.Write(GetValue()) )
    {
        // it's not modified any longer
        DiscardEdits();

        // if it worked, save for future calls
        m_filename = filenameToUse;

        return true;
    }
#endif // wxUSE_FFILE

    wxLogError(_("The text couldn't be saved."));

    return false;
}
Пример #4
0
bool wxTextCtrlBase::DoLoadFile(const wxString& filename, int fileType)
{
    if ( wxTextAreaBase::DoLoadFile(filename, fileType) )
    {
        DiscardEdits();
        m_filename = filename;
        return true;
    }
    wxLogError(_("File couldn't be loaded."));
    return false;
}
Пример #5
0
bool wxTextCtrlBase::DoSaveFile(const wxString& filename, int fileType)
{
    if ( wxTextAreaBase::DoSaveFile(filename, fileType) )
    {
        // if it worked, save for future calls
        m_filename = filename;

        // it's not modified any longer
        DiscardEdits();

        return true;
    }
    return false;
}
Пример #6
0
bool wxTextAreaBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType))
{
#if wxUSE_FFILE
    wxFFile file(filename, wxT("w"));
    if ( file.IsOpened() && file.Write(GetValue(), *wxConvCurrent) )
    {
        // if it worked, save for future calls
        m_filename = filename;

        // it's not modified any longer
        DiscardEdits();

        return true;
    }
#endif // wxUSE_FFILE

    return false;
}
Пример #7
0
bool wxTextCtrlBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType))
{
#if wxUSE_FFILE
    wxFFile file(filename, _T("w"));
    if ( file.IsOpened() && file.Write(GetValue()) )
    {
        // if it worked, save for future calls
        m_filename = filename;

        // it's not modified any longer
        DiscardEdits();

        return true;
    }
#endif // wxUSE_FFILE

    wxLogError(_("The text couldn't be saved."));

    return false;
}
Пример #8
0
bool wxTextAreaBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType))
{
#if wxUSE_FFILE
    wxFFile file(filename, wxT("w"));
    if ( file.IsOpened() && file.Write(GetValue()) )
    {
        // if it worked, save for future calls
        m_filename = filename;

        // it's not modified any longer
        DiscardEdits();

        return true;
    }
#else
    (void)filename;   // avoid compiler warning about unreferenced parameter
#endif // wxUSE_FFILE

    return false;
}
Пример #9
0
bool wxTextCtrlBase::DoLoadFile(const wxString& filename, int WXUNUSED(fileType))
{
#if wxUSE_FFILE
    wxFFile file(filename);
    if ( file.IsOpened() )
    {
        wxString text;
        if ( file.ReadAll(&text) )
        {
            SetValue(text);

            DiscardEdits();

            m_filename = filename;

            return true;
        }
    }

    wxLogError(_("File couldn't be loaded."));
#endif // wxUSE_FFILE

    return false;
}