Update of /cvsroot/mahogany/M/src/modules
In directory sc8-pr-cvs1:/tmp/cvs-serv1788/src/modules

Modified Files:
        BareBonesEditor.cpp 
Log Message:
fixed showing text in non default encoding (although the worst bug was in wxMSW 
itself, not here)

Index: BareBonesEditor.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/BareBonesEditor.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -b -u -2 -r1.12 -r1.13
--- BareBonesEditor.cpp 18 Sep 2003 16:31:00 -0000      1.12
+++ BareBonesEditor.cpp 19 Sep 2003 22:37:20 -0000      1.13
@@ -128,4 +128,7 @@
    wxListCtrl *m_attachments;
 
+   // the encoding to use for the text in the control (and the font)
+   wxFontEncoding m_encoding;
+
    int m_getNextAttachement;
 };
@@ -669,6 +672,7 @@
                                    wxDefaultPosition,wxDefaultSize,
                                    // use wxTE_RICH to allow for more than 64Kb
-                                   // of text under Win9x
-                                   wxTE_MULTILINE | wxTE_RICH)
+                                   // of text under Win9x and wxTE_RICH2 for
+                                   // better charset support (also for Win32)
+                                   wxTE_MULTILINE | wxTE_RICH2)
 {
    m_editor = editor;
@@ -714,4 +718,7 @@
 {
    m_textControl = NULL;
+
+   m_encoding = wxFONTENCODING_SYSTEM;
+
    m_getNextAttachement = -1;
 }
@@ -843,21 +850,5 @@
 void BareBonesEditor::SetEncoding(wxFontEncoding encoding)
 {
-   const wxFont& previous = m_textControl->GetFont();
-#if 0 // FIXME: wxGtk2.4/wxFont::SetEncoding doesn't work for some reason
-   wxFont next(previous);
-   next.SetEncoding(encoding);
-#else
-   wxFont next(
-      previous.GetPointSize(),
-      previous.GetFamily(),
-      previous.GetStyle(),
-      previous.GetWeight(),
-      previous.GetUnderlined(),
-      previous.GetFaceName(),
-      encoding
-   );
-#endif
-   if ( next.Ok() )
-      m_textControl->SetFont(next);
+   m_encoding = encoding;
 }
 
@@ -933,6 +924,6 @@
 // ----------------------------------------------------------------------------
 
-void BareBonesEditor::InsertAttachment(
-   const wxBitmap& icon, EditorContentPart *mc)
+void
+BareBonesEditor::InsertAttachment(const wxBitmap& icon, EditorContentPart *mc)
 {
    wxListItem item;
@@ -948,14 +939,51 @@
 }
 
-void BareBonesEditor::InsertText(const String& text, InsertMode insMode)
+void BareBonesEditor::InsertText(const String& textOrig, InsertMode insMode)
 {
-   if(insMode == Insert_Replace)
-      m_textControl->Clear();
-   m_textControl->Freeze();
    // Translate CRLF to LF. Internal strings should have only LF, but
    // obviously they don't. All strings returned from c-client have CRLF
    // and not all code translates it to LF, so we have to do it here.
-   m_textControl->WriteText(strutil_enforceLF(text));
-   m_textControl->Thaw();
+   //
+   // VZ: this really shouldn't be necessary and it could be a big performance
+   //     problem with huge messages (FIXME)
+   String text(strutil_enforceLF(textOrig));
+
+
+   // we may have to translate the text in another encoding if exactly this one
+   // is not available (but equivalent one is)
+   if ( EnsureAvailableTextEncoding(&m_encoding, &text, true /* may ask */) )
+   {
+      wxFont fontOld = m_textControl->GetFont();
+#if 0 // FIXME: wxGtk2.4/wxFont::SetEncoding doesn't work for some reason
+      wxFont fontNew(fontOld);
+      fontNew.SetEncoding(m_encoding);
+#else
+      wxFont fontNew(
+         fontOld.GetPointSize(),
+         fontOld.GetFamily(),
+         fontOld.GetStyle(),
+         fontOld.GetWeight(),
+         fontOld.GetUnderlined(),
+         fontOld.GetFaceName(),
+         m_encoding
+      );
+#endif
+
+      if ( fontNew.Ok() )
+      {
+         m_textControl->SetFont(fontNew);
+      }
+   }
+   //else: don't change the font, encoding is not supported anyhow
+
+
+   if ( insMode == Insert_Replace )
+   {
+      m_textControl->SetValue(text);
+   }
+   else // Insert_Append
+   {
+      m_textControl->AppendText(text);
+   }
 }
 
@@ -967,10 +995,12 @@
 {
    m_getNextAttachement = 0;
+
    // Translate LF to CRLF. All internal strings should have only LF, but
    // due to long bug tradition, many strings that contain messages have
    // CRLF newlines. They are passed to c-client, which expects CRLF, so
    // think twice before changing it.
-   return new EditorContentPart(strutil_enforceCRLF(
-      m_textControl->GetValue()));
+   //
+   // VZ: see above (FIXME)
+   return new EditorContentPart(strutil_enforceCRLF(m_textControl->GetValue()));
 }
 



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to