virtual void Undo();
virtual void Redo();
+ //Editing functions
+ virtual void SetEditable(bool enable = true);
+ virtual bool IsEditable();
+
/** FIXME: hack to work around signals being received too early */
bool m_ready;
virtual void Undo();
virtual void Redo();
+ //Editing functions
+ virtual void SetEditable(bool enable = true);
+ virtual bool IsEditable();
+
// ---- IE-specific methods
// FIXME: I seem to be able to access remote webpages even in offline mode...
virtual void Cut();
virtual void Copy();
virtual void Paste();
+
+ //Editing functions
+ void SetEditable(bool enable = true);
+ bool IsEditable();
// ---- methods not from the parent (common) interface
wxString GetSelectedText();
void SetScrollPos(int pos);
int GetScrollPos();
- void MakeEditable(bool enable = true);
- bool IsEditable();
-
wxString GetSelection();
bool CanIncreaseTextSize();
SetPage(stream.GetString(), baseUrl);
}
+ virtual void SetEditable(bool enable = true) = 0;
+ virtual bool IsEditable() = 0;
+
// TODO:
// wxString GetSelection(); // maybe?
// void SetSelection(...); // maybe?
- // void MakeEditable(bool enable = true); // maybe?
- // bool IsEditable(); // maybe?
-
// void EnableJavascript(bool enabled); // maybe?
// wxString RunScript(const wxString& javascript); // maybe?
/**
Returns whether the web control is currently busy (e.g. loading a page).
*/
- virtual bool IsBusy() = 0;
+ virtual bool IsBusy() = 0;
+
+ /**
+ Returns whether the web control is currently editable
+ */
+ virtual bool IsEditable() = 0;
/**
Load a web page from a URL
@param flags A bit array that may optionally contain reload options.
*/
virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT) = 0;
+
+ /**
+ Set the editable property of the web control. Enabling allows the user
+ to edit the page even if the @c contenteditable attribute is not set.
+ The exact capabilities vary with the backend being used.
+ */
+ virtual void SetEditable(bool enable = true) = 0;
/**
Set the displayed page source to the contents of the given string.
void OnPaste(wxCommandEvent& evt);
void OnUndo(wxCommandEvent& evt);
void OnRedo(wxCommandEvent& evt);
+ void OnMode(wxCommandEvent& evt);
private:
wxTextCtrl* m_url;
wxMenuItem* m_edit_paste;
wxMenuItem* m_edit_undo;
wxMenuItem* m_edit_redo;
+ wxMenuItem* m_edit_mode;
wxTimer* m_timer;
int m_animation_angle;
editmenu->AppendSeparator();
m_edit_undo = editmenu->Append(wxID_ANY, _("Undo"));
m_edit_redo = editmenu->Append(wxID_ANY, _("Redo"));
+ editmenu->AppendSeparator();
+ m_edit_mode = editmenu->AppendCheckItem(wxID_ANY, _("Edit Mode"));
m_tools_menu->AppendSeparator();
m_tools_menu->AppendSubMenu(editmenu, "Edit");
wxCommandEventHandler(WebFrame::OnUndo), NULL, this );
Connect(m_edit_redo->GetId(), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(WebFrame::OnRedo), NULL, this );
+ Connect(m_edit_mode->GetId(), wxEVT_COMMAND_MENU_SELECTED,
+ wxCommandEventHandler(WebFrame::OnMode), NULL, this );
}
void WebFrame::OnAnimationTimer(wxTimerEvent& evt)
m_browser->Redo();
}
+void WebFrame::OnMode(wxCommandEvent& evt)
+{
+ m_browser->SetEditable(m_edit_mode->IsChecked());
+}
+
+
/**
* Callback invoked when there is a request to load a new page (for instance
* when the user clicks a link)
*/
}
+void wxWebViewWebKit::SetEditable(bool enable)
+{
+ webkit_web_view_set_editable(WEBKIT_WEB_VIEW(web_view), enable);
+}
+
+bool wxWebViewWebKit::IsEditable()
+{
+ return webkit_web_view_get_editable(WEBKIT_WEB_VIEW(web_view));
+}
+
// static
wxVisualAttributes
wxWebViewWebKit::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
ExecCommand("Redo");
}
+void wxWebViewIE::SetEditable(bool enable)
+{
+ IHTMLDocument2* document = GetDocument();
+ if( enable )
+ document->put_designMode(SysAllocString(L"On"));
+ else
+ document->put_designMode(SysAllocString(L"Off"));
+}
+
+bool wxWebViewIE::IsEditable()
+{
+ IHTMLDocument2* document = GetDocument();
+ BSTR mode;
+ document->get_designMode(&mode);
+ if(wxString(mode) == "On")
+ return true;
+ else
+ return false;
+}
+
bool wxWebViewIE::CanExecCommand(wxString command)
{
IHTMLDocument2* document = GetDocument();
[op runOperation];
}
-void wxWebViewWebKit::MakeEditable(bool enable)
+void wxWebViewWebKit::SetEditable(bool enable)
{
if ( !m_webView )
return;
CPPUNIT_TEST( HistoryEnable );
CPPUNIT_TEST( HistoryClear );
CPPUNIT_TEST( HistoryList );
+ CPPUNIT_TEST( Editable );
CPPUNIT_TEST_SUITE_END();
void Title();
void HistoryEnable();
void HistoryClear();
void HistoryList();
+ void Editable();
void LoadUrl(const wxString& url, int times = 1);
wxWebView* m_browser;
CPPUNIT_ASSERT_EQUAL(2, m_browser->GetBackwardHistory().size());
}
+void WebTestCase::Editable()
+{
+ CPPUNIT_ASSERT(!m_browser->IsEditable());
+
+ m_browser->SetEditable(true);
+
+ CPPUNIT_ASSERT(m_browser->IsEditable());
+
+ m_browser->SetEditable(false);
+
+ CPPUNIT_ASSERT(!m_browser->IsEditable());
+}
+
#endif //wxUSE_WEB