git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4788
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
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
-- 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
#include "wxLayout.h"
#include <wx/textfile.h>
#include "wxLayout.h"
#include <wx/textfile.h>
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_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
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.");
edit_menu->Append(ID_PASTE,"&Paste", "Paste text from clipboard.");
edit_menu->Append(ID_PASTE,"&Paste", "Paste text from clipboard.");
+#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.");
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" );
cerr << "Received click event." << endl;
break;
case ID_PASTE:
cerr << "Received click event." << endl;
break;
case ID_PASTE:
m_lwin->Refresh(FALSE);
break;
#ifdef __WXGTK__
case ID_PASTE_PRIMARY:
m_lwin->Refresh(FALSE);
break;
#ifdef __WXGTK__
case ID_PASTE_PRIMARY:
+ // 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(TRUE,TRUE,FALSE);
m_lwin->Refresh(FALSE);
break;
case ID_CUT:
m_lwin->Refresh(FALSE);
break;
case ID_CUT:
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>";
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;
wxLayoutObjectIcon::wxLayoutObjectIcon(wxBitmap *icon)
{
m_Icon = icon;
wxLayoutObjectIcon::wxLayoutObjectIcon(wxBitmap *icon)
{
m_Icon = icon;
+ if(! m_Icon)
+ m_Icon = new wxIcon;
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->style,
m_StyleInfo->weight,
m_StyleInfo->underline,
m_StyleInfo->style,
m_StyleInfo->weight,
m_StyleInfo->underline,
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'
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);
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));
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);
}
}
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;
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;
+ 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)))
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();
{
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";
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;
wxLayoutLine * m_line;
wxLOiterator m_iterator;
wxLayoutStyleInfo m_si;
wxLayoutLine * m_line;
wxLOiterator m_iterator;
wxLayoutStyleInfo m_si;
- #define WXLO_DEFAULT_EXPORT_MODE WXLO_EXPORT_WITH_CRLF
+# define WXLO_DEFAULT_EXPORT_MODE WXLO_EXPORT_WITH_CRLF
- #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):
-#define wxUSE_PRIVATE_CLIPBOARD_FORMAT 0
-
// ----------------------------------------------------------------------------
// event tables
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// event tables
// ----------------------------------------------------------------------------
{
case 'c':
// this should work even in read-only mode
{
case 'c':
// this should work even in read-only mode
break;
case 's': // search
Find("");
break;
case 's': // search
Find("");
SetDirty();
break;
case 'c':
SetDirty();
break;
case 'c':
- // if SHIFT is down, use primary selection
- Paste( event.ShiftDown() );
)
{
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);
// ----------------------------------------------------------------------------
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(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;
+ }
+ 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() )
wxString text = data.GetText();
wxLayoutImportText( m_llist, text);
SetDirty();
wxString text = data.GetText();
wxLayoutImportText( m_llist, text);
SetDirty();
+ wxTheClipboard->Close();
- wxTheClipboard->Close();
-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:
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;
}
-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();
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(bool privateFormat = FALSE, bool usePrimary = FALSE);
//@}
/// find string in buffer
//@}
/// find string in buffer