]> git.saurik.com Git - wxWidgets.git/commitdiff
rtf cut&paste works now, html export fixed
authorKarsten Ballüder <ballueder@usa.net>
Wed, 1 Dec 1999 18:05:54 +0000 (18:05 +0000)
committerKarsten Ballüder <ballueder@usa.net>
Wed, 1 Dec 1999 18:05:54 +0000 (18:05 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4788 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/richedit/TODO
samples/richedit/wxLayout.cpp
samples/richedit/wxllist.cpp
samples/richedit/wxllist.h
samples/richedit/wxlparser.cpp
samples/richedit/wxlparser.h
samples/richedit/wxlwindow.cpp
samples/richedit/wxlwindow.h

index f9036040e907a865c16bc3907328419d692d5d8c..fb8971ba9485acea6e8ff448d3b9fd0940b614c7 100644 (file)
@@ -2,9 +2,6 @@
 BUGS
 =====================================================================
 
 BUGS
 =====================================================================
 
-- dmalloc shows duplicate deletion after merging two lines and
-  deleting the second half
-
 - word wrap for objects with lots of non-space needs to search in positive
   direction if begin of first object is reached
 
 - word wrap for objects with lots of non-space needs to search in positive
   direction if begin of first object is reached
 
@@ -13,26 +10,14 @@ TODO
 
 - use printsetup margins
 
 
 - use printsetup margins
 
-- merge RecalulateXXX and Layout() into one
-
   - UNDO!!
   - replacement of llist in window
 
   - UNDO!!
   - replacement of llist in window
 
-Improve speed! (See layout problem below!)
-
-  - wxlwindow needs to shrink scrollbar range when window contents get removed
-  - When selecting with the mouse, scroll window if pointer is outside.
-
-
-
-- The import of a private data object does not work yet, we need to get
-  the objects back from the string.
-  
 - update rectangle (needs support in wxllist and wxWindows)
   --> needs a bit of fixing still
       some code bits are commented out in wxlwindow.cpp
       offset handling seems a bit dodgy, white shadow to top/left of cursor
 
 - update rectangle (needs support in wxllist and wxWindows)
   --> needs a bit of fixing still
       some code bits are commented out in wxlwindow.cpp
       offset handling seems a bit dodgy, white shadow to top/left of cursor
 
-  - DragNDrop
-  - Update docs, do full rtf/html editing. 
-  - Verify/fix html export.
+- add wxHTML parser to import HTML
+- add some kind of callback for objects with userdata
+- use wxTempFile to get rid of temporary image files
index 15d14b81eeca21722357d98acc1a789620c55333..d650aea0ae54663a202e20765922fc815a38ebf2 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "wxLayout.h"
 #include <wx/textfile.h>
 
 #include "wxLayout.h"
 #include <wx/textfile.h>
+#include <wx/image.h>
 
 #include <iostream.h>
 
 
 #include <iostream.h>
 
@@ -40,7 +41,7 @@ enum ids
     ID_PRINT_SETUP, ID_PAGE_SETUP, ID_PREVIEW, ID_PRINT_PS,
     ID_PRINT_SETUP_PS, ID_PAGE_SETUP_PS,ID_PREVIEW_PS,
     ID_WRAP, ID_NOWRAP, ID_PASTE, ID_COPY, ID_CUT,
     ID_PRINT_SETUP, ID_PAGE_SETUP, ID_PREVIEW, ID_PRINT_PS,
     ID_PRINT_SETUP_PS, ID_PAGE_SETUP_PS,ID_PREVIEW_PS,
     ID_WRAP, ID_NOWRAP, ID_PASTE, ID_COPY, ID_CUT,
-    ID_PASTE_PRIMARY,
+    ID_COPY_PRIMARY, ID_PASTE_PRIMARY,
     ID_FIND,
     ID_WXLAYOUT_DEBUG, ID_QUIT, ID_CLICK, ID_HTML, ID_TEXT,
     ID_TEST, ID_LINEBREAKS_TEST, ID_LONG_TEST, ID_URL_TEST
     ID_FIND,
     ID_WXLAYOUT_DEBUG, ID_QUIT, ID_CLICK, ID_HTML, ID_TEXT,
     ID_TEST, ID_LINEBREAKS_TEST, ID_LONG_TEST, ID_URL_TEST
@@ -105,10 +106,11 @@ MyFrame::MyFrame(void) :
    edit_menu->AppendSeparator();
    edit_menu->Append(ID_COPY, "&Copy", "Copy text to clipboard.");
    edit_menu->Append(ID_CUT, "Cu&t", "Cut text to clipboard.");
    edit_menu->AppendSeparator();
    edit_menu->Append(ID_COPY, "&Copy", "Copy text to clipboard.");
    edit_menu->Append(ID_CUT, "Cu&t", "Cut text to clipboard.");
-#ifdef __WXGTK__
    edit_menu->Append(ID_PASTE,"&Paste", "Paste text from clipboard.");
    edit_menu->Append(ID_PASTE,"&Paste", "Paste text from clipboard.");
-#endif
+#ifdef __WXGTK__
+   edit_menu->Append(ID_COPY_PRIMARY, "C&opy primary", "Copy text to primary selecton.");
    edit_menu->Append(ID_PASTE_PRIMARY,"&Paste primary", "Paste text from primary selection.");
    edit_menu->Append(ID_PASTE_PRIMARY,"&Paste primary", "Paste text from primary selection.");
+#endif
    edit_menu->Append(ID_FIND, "&Find", "Find text.");
    menu_bar->Append(edit_menu, "&Edit" );
 
    edit_menu->Append(ID_FIND, "&Find", "Find text.");
    menu_bar->Append(edit_menu, "&Edit" );
 
@@ -283,17 +285,23 @@ void MyFrame::OnCommand( wxCommandEvent &event )
       cerr << "Received click event." << endl;
       break;
    case ID_PASTE:
       cerr << "Received click event." << endl;
       break;
    case ID_PASTE:
-      m_lwin->Paste();
+      m_lwin->Paste(TRUE);
       m_lwin->Refresh(FALSE);
       break;
 #ifdef __WXGTK__
    case ID_PASTE_PRIMARY:
       m_lwin->Refresh(FALSE);
       break;
 #ifdef __WXGTK__
    case ID_PASTE_PRIMARY:
-      m_lwin->Paste(TRUE);
+      // text only from primary:
+      m_lwin->Paste(FALSE, TRUE);
+      m_lwin->Refresh(FALSE);
+      break;
+   case ID_COPY_PRIMARY:
+      // copy text-only to primary selection:
+      m_lwin->Copy(FALSE,FALSE,TRUE);
       m_lwin->Refresh(FALSE);
       break;
 #endif
    case ID_COPY:
       m_lwin->Refresh(FALSE);
       break;
 #endif
    case ID_COPY:
-      m_lwin->Copy();
+      m_lwin->Copy(TRUE,TRUE,FALSE);
       m_lwin->Refresh(FALSE);
       break;
    case ID_CUT:
       m_lwin->Refresh(FALSE);
       break;
    case ID_CUT:
@@ -311,13 +319,14 @@ void MyFrame::OnCommand( wxCommandEvent &event )
       wxLayoutExportObject *export0;
       wxLayoutExportStatus status(m_lwin->GetLayoutList());
 
       wxLayoutExportObject *export0;
       wxLayoutExportStatus status(m_lwin->GetLayoutList());
 
+      cout << "<HTML>" << endl;
       while((export0 = wxLayoutExport( &status,
                                       WXLO_EXPORT_AS_HTML)) != NULL)
       {
          if(export0->type == WXLO_EXPORT_HTML)
             cout << *(export0->content.text);
          else
       while((export0 = wxLayoutExport( &status,
                                       WXLO_EXPORT_AS_HTML)) != NULL)
       {
          if(export0->type == WXLO_EXPORT_HTML)
             cout << *(export0->content.text);
          else
-            cout << "<!--UNKNOWN OBJECT>";
+            ; // ignore itcout << "<!--UNKNOWN OBJECT>";
          delete export0;
       }
    }
          delete export0;
       }
    }
@@ -506,6 +515,7 @@ MyApp::MyApp(void) :
 bool MyApp::OnInit(void)
 {
    wxFrame *frame = new MyFrame();
 bool MyApp::OnInit(void)
 {
    wxFrame *frame = new MyFrame();
+   wxInitAllImageHandlers();
    frame->Show( TRUE );
 //   wxSetAFMPath("/usr/local/src/wxWindows/misc/afm/");
    return TRUE;
    frame->Show( TRUE );
 //   wxSetAFMPath("/usr/local/src/wxWindows/misc/afm/");
    return TRUE;
index 32224783f211e6ed57695b1d81d617114f593898..2aafe648eb640597ab16bdd07ba1de3137b5c9e9 100644 (file)
@@ -448,6 +448,8 @@ wxLayoutObjectIcon::Copy(void)
 wxLayoutObjectIcon::wxLayoutObjectIcon(wxBitmap *icon)
 {
    m_Icon = icon;
 wxLayoutObjectIcon::wxLayoutObjectIcon(wxBitmap *icon)
 {
    m_Icon = icon;
+   if(! m_Icon)
+      m_Icon = new wxIcon;
 }
 
 void
 }
 
 void
@@ -524,12 +526,19 @@ wxLayoutObjectCmd::wxLayoutObjectCmd(int family, int size, int style, int
    m_StyleInfo = new wxLayoutStyleInfo(family, size,style,weight,underline,fg,bg);
 }
 
    m_StyleInfo = new wxLayoutStyleInfo(family, size,style,weight,underline,fg,bg);
 }
 
+wxLayoutObjectCmd::wxLayoutObjectCmd(const wxLayoutStyleInfo &si)
+
+{
+   m_StyleInfo = new wxLayoutStyleInfo;
+   *m_StyleInfo = si;
+}
+
 wxLayoutObject *
 wxLayoutObjectCmd::Copy(void)
 {
    wxLayoutObjectCmd *obj = new wxLayoutObjectCmd(
 wxLayoutObject *
 wxLayoutObjectCmd::Copy(void)
 {
    wxLayoutObjectCmd *obj = new wxLayoutObjectCmd(
-      m_StyleInfo->size,
       m_StyleInfo->family,
       m_StyleInfo->family,
+      m_StyleInfo->size,
       m_StyleInfo->style,
       m_StyleInfo->weight,
       m_StyleInfo->underline,
       m_StyleInfo->style,
       m_StyleInfo->weight,
       m_StyleInfo->underline,
@@ -545,8 +554,8 @@ void
 wxLayoutObjectCmd::Write(wxString &ostr)
 {
    ostr << WXLO_TYPE_CMD << '\n'
 wxLayoutObjectCmd::Write(wxString &ostr)
 {
    ostr << WXLO_TYPE_CMD << '\n'
-        << m_StyleInfo->size << '\n'
         << m_StyleInfo->family << '\n'
         << m_StyleInfo->family << '\n'
+        << m_StyleInfo->size << '\n'
         << m_StyleInfo->style << '\n'
         << m_StyleInfo->weight << '\n'
         << m_StyleInfo->underline << '\n'
         << m_StyleInfo->style << '\n'
         << m_StyleInfo->weight << '\n'
         << m_StyleInfo->underline << '\n'
@@ -573,10 +582,10 @@ wxLayoutObjectCmd::Read(wxString &istr)
 
    wxString tmp;
    ReadString(tmp, istr);
 
    wxString tmp;
    ReadString(tmp, istr);
-   sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->size);
-   ReadString(tmp, istr);
    sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->family);
    ReadString(tmp, istr);
    sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->family);
    ReadString(tmp, istr);
+   sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->size);
+   ReadString(tmp, istr);
    sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->style);
    ReadString(tmp, istr);
    sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->weight);
    sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->style);
    ReadString(tmp, istr);
    sscanf(tmp.c_str(),"%d", &obj->m_StyleInfo->weight);
@@ -1571,12 +1580,20 @@ wxLayoutList::InternalClear(void)
 void
 wxLayoutList::Read(wxString &istr)
 {
 void
 wxLayoutList::Read(wxString &istr)
 {
+   /* In order to handle input of formatted string "nicely", we need
+      to restore our current font settings after the string. So first
+      of all, we create a StyleInfo structure with our current
+      settings. */
+   wxLayoutStyleInfo current_si = GetStyleInfo();
+
    while(istr.Length())
    {
       wxLayoutObject *obj = wxLayoutObject::Read(istr);
       if(obj)
          Insert(obj);
    }
    while(istr.Length())
    {
       wxLayoutObject *obj = wxLayoutObject::Read(istr);
       if(obj)
          Insert(obj);
    }
+   /* Now we use the current_si to restore our last font settings: */
+   Insert(new wxLayoutObjectCmd(current_si));
 }
 
 
 }
 
 
@@ -2891,11 +2908,13 @@ wxLayoutList::ApplyStyle(wxLayoutStyleInfo const &si, wxDC &dc)
    if(si.m_fg_valid)
    {
       m_CurrentStyleInfo.m_fg = si.m_fg;
    if(si.m_fg_valid)
    {
       m_CurrentStyleInfo.m_fg = si.m_fg;
+      m_CurrentStyleInfo.m_fg_valid = true;
       dc.SetTextForeground(m_CurrentStyleInfo.m_fg);
    }
    if(si.m_bg_valid)
    {
       m_CurrentStyleInfo.m_bg = si.m_bg;
       dc.SetTextForeground(m_CurrentStyleInfo.m_fg);
    }
    if(si.m_bg_valid)
    {
       m_CurrentStyleInfo.m_bg = si.m_bg;
+      m_CurrentStyleInfo.m_bg_valid = true;
       dc.SetTextBackground(m_CurrentStyleInfo.m_bg);
    }
 }
       dc.SetTextBackground(m_CurrentStyleInfo.m_bg);
    }
 }
index 1446ebf3a07683467333d5e6b1bd6898973b128c..71e7d381aeae23767acca1f5f7c9664a2e7ca02d 100644 (file)
@@ -421,6 +421,7 @@ public:
                      int underline = -1,
                      wxColour *fg = NULL,
                      wxColour *bg = NULL);
                      int underline = -1,
                      wxColour *fg = NULL,
                      wxColour *bg = NULL);
+   wxLayoutObjectCmd(const wxLayoutStyleInfo &si);
    ~wxLayoutObjectCmd();
    /** Stores the current style in the styleinfo structure */
    wxLayoutStyleInfo * GetStyle(void) const;
    ~wxLayoutObjectCmd();
    /** Stores the current style in the styleinfo structure */
    wxLayoutStyleInfo * GetStyle(void) const;
index 1089a458852415fdcfc49f13075b09289760476c..d666c16fa2ffb85b4670a4ce9c736a0ab6d23f6a 100644 (file)
@@ -73,7 +73,8 @@ void wxLayoutImportText(wxLayoutList *list, wxString const &str)
 
 static
 wxString wxLayoutExportCmdAsHTML(wxLayoutObjectCmd const & cmd,
 
 static
 wxString wxLayoutExportCmdAsHTML(wxLayoutObjectCmd const & cmd,
-                                 wxLayoutStyleInfo *styleInfo)
+                                 wxLayoutStyleInfo *styleInfo,
+                                 bool firstTime)
 {
    static char buffer[20];
    wxString html;
 {
    static char buffer[20];
    wxString html;
@@ -128,7 +129,7 @@ wxString wxLayoutExportCmdAsHTML(wxLayoutObjectCmd const & cmd,
 
    html +=">";
 
 
    html +=">";
 
-   if(styleInfo != NULL)
+   if(styleInfo != NULL && ! firstTime)
       html ="</font>"+html; // terminate any previous font command
 
    if((si->weight == wxBOLD) && ( (!styleInfo) || (styleInfo->weight != wxBOLD)))
       html ="</font>"+html; // terminate any previous font command
 
    if((si->weight == wxBOLD) && ( (!styleInfo) || (styleInfo->weight != wxBOLD)))
@@ -164,6 +165,7 @@ wxLayoutExportStatus::wxLayoutExportStatus(wxLayoutList *list)
    m_si = list->GetDefaultStyleInfo();
    m_line = list->GetFirstLine();
    m_iterator = m_line->GetFirstObject();
    m_si = list->GetDefaultStyleInfo();
    m_line = list->GetFirstLine();
    m_iterator = m_line->GetFirstObject();
+   m_FirstTime = TRUE;
 }
 
 
 }
 
 
@@ -220,7 +222,7 @@ wxLayoutExportObject *wxLayoutExport(wxLayoutExportStatus *status,
    {
       while(status->m_iterator == NULLIT)
       {
    {
       while(status->m_iterator == NULLIT)
       {
-         if(flags & WXLO_EXPORT_AS_HTML)
+         if(mode & WXLO_EXPORT_AS_HTML)
             *str += "<br>";
          if(flags & WXLO_EXPORT_WITH_CRLF)
             *str += "\r\n";
             *str += "<br>";
          if(flags & WXLO_EXPORT_WITH_CRLF)
             *str += "\r\n";
@@ -245,15 +247,16 @@ wxLayoutExportObject *wxLayoutExport(wxLayoutExportStatus *status,
          break;
       case WXLO_TYPE_CMD:
          if(mode == WXLO_EXPORT_AS_HTML)
          break;
       case WXLO_TYPE_CMD:
          if(mode == WXLO_EXPORT_AS_HTML)
-            *str += wxLayoutExportCmdAsHTML(*(wxLayoutObjectCmd const
-                                              *)*status->m_iterator, & status->m_si);
+            *str += wxLayoutExportCmdAsHTML(
+               *(wxLayoutObjectCmd const *)*status->m_iterator,
+               & status->m_si, status->m_FirstTime);
+         status->m_FirstTime = FALSE;
          break;
       default:  // ignore icons
          ;
       }
       status->m_iterator++;
    }
          break;
       default:  // ignore icons
          ;
       }
       status->m_iterator++;
    }
-
    exp->type = (mode == WXLO_EXPORT_AS_HTML)
       ?  WXLO_EXPORT_HTML : WXLO_EXPORT_TEXT;
    exp->content.text = str;
    exp->type = (mode == WXLO_EXPORT_AS_HTML)
       ?  WXLO_EXPORT_HTML : WXLO_EXPORT_TEXT;
    exp->content.text = str;
index a594885d08c74ea74edab7cc25a2b0712f03fab1..129100dd30e983fb2af087229297b35589362bbf 100644 (file)
@@ -59,12 +59,13 @@ struct wxLayoutExportStatus
    wxLayoutLine      * m_line;
    wxLOiterator        m_iterator;
    wxLayoutStyleInfo   m_si;
    wxLayoutLine      * m_line;
    wxLOiterator        m_iterator;
    wxLayoutStyleInfo   m_si;
+   bool                m_FirstTime;
 };
 
 #ifdef OS_WIN
 };
 
 #ifdef OS_WIN
-    #define WXLO_DEFAULT_EXPORT_MODE WXLO_EXPORT_WITH_CRLF
+#   define WXLO_DEFAULT_EXPORT_MODE WXLO_EXPORT_WITH_CRLF
 #else // Unix
 #else // Unix
-    #define WXLO_DEFAULT_EXPORT_MODE WXLO_EXPORT_WITH_LF_ONLY
+#   define WXLO_DEFAULT_EXPORT_MODE WXLO_EXPORT_WITH_LF_ONLY
 #endif // Win/Unix
 
 /// import text into a wxLayoutList (including linefeeds):
 #endif // Win/Unix
 
 /// import text into a wxLayoutList (including linefeeds):
index 1fdba74348f16d0c17ac94735aaa45c3131dc075..0993e2ca99f2ecc1a2193826672fd668bacb1b43 100644 (file)
@@ -88,8 +88,6 @@ static const int Y_SCROLL_PAGE = 20;
 
 
 
 
 
 
-#define wxUSE_PRIVATE_CLIPBOARD_FORMAT 0
-
 // ----------------------------------------------------------------------------
 // event tables
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // event tables
 // ----------------------------------------------------------------------------
@@ -564,7 +562,7 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
          {
          case 'c':
             // this should work even in read-only mode
          {
          case 'c':
             // this should work even in read-only mode
-            Copy();
+            Copy(TRUE, TRUE);
             break;
          case 's': // search
             Find("");
             break;
          case 's': // search
             Find("");
@@ -629,11 +627,10 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
                SetDirty();
                break;
             case 'c':
                SetDirty();
                break;
             case 'c':
-               Copy();
+               Copy(TRUE, TRUE);
                break;
             case 'v':
                break;
             case 'v':
-               // if SHIFT is down, use primary selection
-               Paste( event.ShiftDown() );
+               Paste( TRUE );
                break;
             case 'x':
                Cut();
                break;
             case 'x':
                Cut();
@@ -717,8 +714,15 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
                   )
                {
                   if(m_WrapMargin > 0 && isspace(keyCode))
                   )
                {
                   if(m_WrapMargin > 0 && isspace(keyCode))
-                     m_llist->WrapLine(m_WrapMargin);
-                  m_llist->Insert((char)keyCode);
+                  {
+                     bool wrapped = m_llist->WrapLine(m_WrapMargin);
+                     // don´t insert space as first thing in line
+                     // after wrapping:
+                     if(! wrapped || m_llist->GetCursorPos().x != 0)
+                        m_llist->Insert((char)keyCode);
+                  }
+                  else
+                     m_llist->Insert((char)keyCode);
                   SetDirty();
                }
                else
                   SetDirty();
                }
                else
@@ -1071,26 +1075,47 @@ wxLayoutWindow::ResizeScrollbars(bool exact)
 // ----------------------------------------------------------------------------
 
 void
 // ----------------------------------------------------------------------------
 
 void
-wxLayoutWindow::Paste(bool primary)
+wxLayoutWindow::Paste(bool usePrivate, bool primary)
 {
    // this only has an effect under X11:
 {
    // this only has an effect under X11:
-   if(primary) wxTheClipboard->UsePrimarySelection();
+   wxTheClipboard->UsePrimarySelection(primary);
    // Read some text
    if (wxTheClipboard->Open())
    {
    // Read some text
    if (wxTheClipboard->Open())
    {
-#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
-      wxLayoutDataObject wxldo;
-      if (wxTheClipboard->IsSupported( wxldo.GetFormat() ))
+      if(usePrivate)
       {
       {
-         if(wxTheClipboard->GetData(wxldo))
+         wxLayoutDataObject wxldo;
+         if (wxTheClipboard->IsSupported( wxldo.GetFormat() ))
          {
          {
-            wxString str = wxldo.GetLayoutData();
-            m_llist->Read(str);
-            RequestUpdate();
+            if(wxTheClipboard->GetData(wxldo))
+            {
+               wxTheClipboard->Close();
+               wxString str = wxldo.GetLayoutData();
+               m_llist->Read(str);
+               SetDirty();
+               RequestUpdate();
+               return;
+            }
          }
       }
          }
       }
-      else
-#endif
+      wxTextDataObject data;
+      if (wxTheClipboard->IsSupported( data.GetFormat() )
+          && wxTheClipboard->GetData(data) )
+      {
+         wxTheClipboard->Close();
+         wxString text = data.GetText();
+         wxLayoutImportText( m_llist, text);
+         SetDirty();
+         RequestUpdate();
+         return;
+      }
+   }
+   // if everything failed we can still try the primary:
+   wxTheClipboard->Close();
+   if(! primary) // not tried before
+   {
+      wxTheClipboard->UsePrimarySelection();
+      if (wxTheClipboard->Open())
       {
          wxTextDataObject data;
          if (wxTheClipboard->IsSupported( data.GetFormat() )
       {
          wxTextDataObject data;
          if (wxTheClipboard->IsSupported( data.GetFormat() )
@@ -1099,14 +1124,15 @@ wxLayoutWindow::Paste(bool primary)
             wxString text = data.GetText();
             wxLayoutImportText( m_llist, text);
             SetDirty();
             wxString text = data.GetText();
             wxLayoutImportText( m_llist, text);
             SetDirty();
+            RequestUpdate();
          }
          }
+         wxTheClipboard->Close();
       }
       }
-      wxTheClipboard->Close();
    }
 }
 
 bool
    }
 }
 
 bool
-wxLayoutWindow::Copy(bool invalidate)
+wxLayoutWindow::Copy(bool invalidate, bool privateFormat, bool primary)
 {
    // Calling GetSelection() will automatically do an EndSelection()
    // on the list, but we need to take a note of it, too:
 {
    // Calling GetSelection() will automatically do an EndSelection()
    // on the list, but we need to take a note of it, too:
@@ -1142,15 +1168,28 @@ wxLayoutWindow::Copy(bool invalidate)
          text = text.Mid(0,len-1);
    }
 
          text = text.Mid(0,len-1);
    }
 
+#if 0
+if(! primary) // always copy as text-only to primary selection
+   {
+      wxTheClipboard->UsePrimarySelection();
+      if (wxTheClipboard->Open())
+      {
+         wxTextDataObject *data = new wxTextDataObject( text );
+         wxTheClipboard->SetData( data );
+         wxTheClipboard->Close();
+      }
+   }
+#endif
+
+   wxTheClipboard->UsePrimarySelection(primary);
    if (wxTheClipboard->Open())
    {
       wxTextDataObject *data = new wxTextDataObject( text );
       bool rc;
 
    if (wxTheClipboard->Open())
    {
       wxTextDataObject *data = new wxTextDataObject( text );
       bool rc;
 
-      rc = wxTheClipboard->SetData( data );
-#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
-      rc |= wxTheClipboard->SetData( wldo );
-#endif
+         rc = wxTheClipboard->SetData( data );
+      if(privateFormat)
+         rc |= wxTheClipboard->SetData( wldo );
       wxTheClipboard->Close();
       return rc;
    }
       wxTheClipboard->Close();
       return rc;
    }
@@ -1161,9 +1200,9 @@ wxLayoutWindow::Copy(bool invalidate)
 }
 
 bool
 }
 
 bool
-wxLayoutWindow::Cut(void)
+wxLayoutWindow::Cut(bool privateFormat, bool usePrimary)
 {
 {
-   if(Copy(false)) // do not invalidate selection after copy
+   if(Copy(false, privateFormat, usePrimary)) // do not invalidate selection after copy
    {
       m_llist->DeleteSelection();
       SetDirty();
    {
       m_llist->DeleteSelection();
       SetDirty();
index 4ad20e8fce12d9e711ce27f7589e65adf388fcde..fa0ba4b2911404e63aabe7969503a9b327a9cbf0 100644 (file)
@@ -95,13 +95,13 @@ public:
       m_CursorVisibility = visibility; return v;}
 
    /// Pastes text from clipboard.
       m_CursorVisibility = visibility; return v;}
 
    /// Pastes text from clipboard.
-   void Paste(bool usePrimarySelection = FALSE);
+   void Paste(bool privateFormat = FALSE, bool usePrimarySelection = FALSE);
    /** Copies selection to clipboard.
        @param invalidate used internally, see wxllist.h for details
    */
    /** Copies selection to clipboard.
        @param invalidate used internally, see wxllist.h for details
    */
-   bool Copy(bool invalidate = true);
+   bool Copy(bool invalidate = true, bool privateFormat = FALSE, bool primary = FALSE);
    /// Copies selection to clipboard and deletes it.
    /// Copies selection to clipboard and deletes it.
-   bool Cut(void);
+   bool Cut(bool privateFormat = FALSE, bool usePrimary = FALSE);
    //@}
 
    /// find string in buffer
    //@}
 
    /// find string in buffer