+
+void
+wxLayoutWindow::Paste(void)
+{
+ // Read some text
+ if (wxTheClipboard->Open())
+ {
+#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
+ wxLayoutDataObject wxldo;
+ if (wxTheClipboard->IsSupported( wxldo.GetFormat() ))
+ {
+ wxTheClipboard->GetData(&wxldo);
+ {
+ }
+ //FIXME: missing functionality m_llist->Insert(wxldo.GetList());
+ }
+ else
+#endif
+ {
+ wxTextDataObject data;
+ if (wxTheClipboard->IsSupported( data.GetFormat() ))
+ {
+ wxTheClipboard->GetData(&data);
+ wxString text = data.GetText();
+ wxLayoutImportText( m_llist, text);
+ }
+ }
+ wxTheClipboard->Close();
+ }
+#if 0
+ /* My attempt to get the primary selection, but it does not
+ work. :-( */
+ if(text.Length() == 0)
+ {
+ wxTextCtrl tmp_tctrl(this,-1);
+ tmp_tctrl.Paste();
+ text += tmp_tctrl.GetValue();
+ }
+#endif
+}
+
+bool
+wxLayoutWindow::Copy(bool invalidate)
+{
+ // Calling GetSelection() will automatically do an EndSelection()
+ // on the list, but we need to take a note of it, too:
+ if(m_Selecting)
+ {
+ m_Selecting = false;
+ m_llist->EndSelection();
+ }
+
+ wxLayoutDataObject wldo;
+ wxLayoutList *llist = m_llist->GetSelection(&wldo, invalidate);
+ if(! llist)
+ return FALSE;
+ // Export selection as text:
+ wxString text;
+ wxLayoutExportObject *export;
+ wxLayoutExportStatus status(llist);
+ while((export = wxLayoutExport( &status, WXLO_EXPORT_AS_TEXT)) != NULL)
+ {
+ if(export->type == WXLO_EXPORT_TEXT)
+ text << *(export->content.text);
+ delete export;
+ }
+ delete llist;
+
+ // The exporter always appends a newline, so we chop it off if it
+ // is there:
+ {
+ size_t len = text.Length();
+ if(len > 2 && text[len-2] == '\r') // Windows
+ text = text.Mid(0,len-2);
+ else if(len > 1 && text[len-1] == '\n')
+ text = text.Mid(0,len-1);
+ }
+
+
+ if (wxTheClipboard->Open())
+ {
+ wxTextDataObject *data = new wxTextDataObject( text );
+ bool rc = wxTheClipboard->SetData( data );
+#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
+ rc |= wxTheClipboard->AddData( &wldo );
+#endif
+ wxTheClipboard->Close();
+ return rc;
+ }
+ return FALSE;
+}
+
+bool
+wxLayoutWindow::Cut(void)
+{
+ if(Copy(false)) // do not invalidate selection after copy
+ {
+ m_llist->DeleteSelection();
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+bool
+wxLayoutWindow::Find(const wxString &needle,
+ wxPoint * fromWhere)
+{
+ wxPoint found;
+
+ if(fromWhere == NULL)
+ found = m_llist->FindText(needle, m_llist->GetCursorPos());
+ else
+ found = m_llist->FindText(needle, *fromWhere);
+ if(found.x != -1)
+ {
+ if(fromWhere)
+ {
+ *fromWhere = found;
+ fromWhere->x ++;
+ }
+ m_llist->MoveCursorTo(found);
+ ScrollToCursor();
+ return true;
+ }
+ return false;
+}
+
+wxMenu *
+wxLayoutWindow::MakeFormatMenu()
+{
+ wxMenu *m = new wxMenu(_("Layout Menu"));
+
+ m->Append(WXLOWIN_MENU_LARGER ,_("&Larger"),_("Switch to larger font."), false);
+ m->Append(WXLOWIN_MENU_SMALLER ,_("&Smaller"),_("Switch to smaller font."), false);
+ m->AppendSeparator();
+ m->Append(WXLOWIN_MENU_UNDERLINE_ON, _("&Underline on"),_("Activate underline mode."), false);
+ m->Append(WXLOWIN_MENU_UNDERLINE_OFF,_("&Underline off"),_("Deactivate underline mode."), false);
+ m->Append(WXLOWIN_MENU_BOLD_ON ,_("&Bold on"),_("Activate bold mode."), false);
+ m->Append(WXLOWIN_MENU_BOLD_OFF ,_("&Bold off"),_("Deactivate bold mode."), false);
+ m->Append(WXLOWIN_MENU_ITALICS_ON ,_("&Italics on"),_("Activate italics mode."), false);
+ m->Append(WXLOWIN_MENU_ITALICS_OFF ,_("&Italics off"),_("Deactivate italics mode."), false);
+ m->AppendSeparator();
+ m->Append(WXLOWIN_MENU_ROMAN ,_("&Roman"),_("Switch to roman font."), false);
+ m->Append(WXLOWIN_MENU_TYPEWRITER,_("&Typewriter"),_("Switch to typewriter font."), false);
+ m->Append(WXLOWIN_MENU_SANSSERIF ,_("&Sans Serif"),_("Switch to sans serif font."), false);
+ return m;
+}
+
+void wxLayoutWindow::OnMenu(wxCommandEvent& event)
+{
+ switch (event.GetId())
+ {
+ case WXLOWIN_MENU_LARGER:
+ m_llist->SetFontLarger(); break;
+ case WXLOWIN_MENU_SMALLER:
+ m_llist->SetFontSmaller(); break;
+ case WXLOWIN_MENU_UNDERLINE_ON:
+ m_llist->SetFontUnderline(true); break;
+ case WXLOWIN_MENU_UNDERLINE_OFF:
+ m_llist->SetFontUnderline(false); break;
+ case WXLOWIN_MENU_BOLD_ON:
+ m_llist->SetFontWeight(wxBOLD); break;
+ case WXLOWIN_MENU_BOLD_OFF:
+ m_llist->SetFontWeight(wxNORMAL); break;
+ case WXLOWIN_MENU_ITALICS_ON:
+ m_llist->SetFontStyle(wxITALIC); break;
+ case WXLOWIN_MENU_ITALICS_OFF:
+ m_llist->SetFontStyle(wxNORMAL); break;
+ case WXLOWIN_MENU_ROMAN:
+ m_llist->SetFontFamily(wxROMAN); break;
+ case WXLOWIN_MENU_TYPEWRITER:
+ m_llist->SetFontFamily(wxFIXED); break;
+ case WXLOWIN_MENU_SANSSERIF:
+ m_llist->SetFontFamily(wxSWISS); break;
+ }
+}
+
+void
+wxLayoutWindow::OnSetFocus(wxFocusEvent &ev)
+{
+ m_HaveFocus = true;
+//FIXME: need argument DoPaint(); // to repaint the cursor
+}
+
+void
+wxLayoutWindow::OnKillFocus(wxFocusEvent &ev)
+{
+ m_HaveFocus = false;
+//FIXME: need argument DoPaint(); // to repaint the cursor
+}