wxWebView,how to set the text style
wxWebView,how to set the text style
I need to do a edit box, which can display rich content,so I set the wxWebView editor state, it works, but do not know how to change the text style, such as: bold font, set the font color ...
thanks in advance!
thanks in advance!
Re: wxWebView,how to set the text style
I'm not sure wxWebView is the best choice for this. Have you checked wxRichTextCtrl?
Use the source, Luke!
Re: wxWebView,how to set the text style
yea, I tried it. But can not meet my needs,because the pasted things are not formatted(font and color and other styles).
And I found that many clients are using html editing, like my uploaded attachments
Thanks.
And I found that many clients are using html editing, like my uploaded attachments
Thanks.
Re: wxWebView,how to set the text style
After looking through the sources, i have to say that there is practically no support for edit mode in the public wxWebView API. If you need a Windows solution only, it might be possible to access the underlying MSHTML control directly, but you'll have to build all edit controls yourself and then send the commands to the MSHTML control.
Here are the possible commands:
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
The needed methods in wxWebViewIE are all private, e.g.
It'll probably take some effort to make this work, i'm not sure it's worth it.
Here are the possible commands:
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
The needed methods in wxWebViewIE are all private, e.g.
Code: Select all
wxCOMPtr<IHTMLDocument2> wxWebViewIE::GetDocument() const
void wxWebViewIE::ExecCommand(wxString command)
Use the source, Luke!
Re: wxWebView,how to set the text style
Ok, it looks complicated, then i want to achieve the current needs, how should i do?
I have no clue now。
I have no clue now。
Re: wxWebView,how to set the text style
Hi,
Use wxRichTextCtrl or just wxTextCtrl.
If you need to do the C&P, it is much easier to modify the content of this control with attributes.
Check the appropriate samples on how to do that.
Thank you.
Use wxRichTextCtrl or just wxTextCtrl.
If you need to do the C&P, it is much easier to modify the content of this control with attributes.
Check the appropriate samples on how to do that.
Thank you.
Re: wxWebView,how to set the text style
I used wxRichTextCtrl before, but found that the content from the clipboard pasted no format, and even can not copy the form, pictures.
Observe that a lot of this similar client, using the cef3 (Chrome browser)
Observe that a lot of this similar client, using the cef3 (Chrome browser)
Re: wxWebView,how to set the text style
Hi, I use an intuitive "Kompozer" where I set everything I need (table...etc.) and then convert the html code to c ++. If you want. I'll send a sample.
Re: wxWebView,how to set the text style
Hi, I use an intuitive "Kompozer" where I set everything I need (table...etc.) and then convert the html code to c ++. If you want. I'll send a sample.
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: wxWebView,how to set the text style
While am not sure about if you can copy the underlying buffer of the selection (which contains styling info) but am sure you can paste HTML and preserve the format. Just Bind your function to OnPaste and read html text on clipboard. Then use wxRTC styling to match the HTML tags (eg text between <b> and </b> apply bold. The plot thickens when you have to deal with HTML attributes and CSS. But you can ignore them if you wishwxKevin wrote:yea, I tried it. But can not meet my needs,because the pasted things are not formatted(font and color and other styles).
And I found that many clients are using html editing, like my uploaded attachments
Thanks.
That is all a theory that need to be tested (Assumption here is you can copy HTML to clipbboad with styles as text).
All in all I don't think there is a ready-made widget in wx for your task.
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: wxWebView,how to set the text style
Hello. I use successfully Kompozer ver. 0.8.b3. There I visually design a page: font size,font color (and background), table, indent - just everything. On the "Source Code" tab, I copy this into my function and modify the code so that it is usable for viewing (in the MyFrame constructor):
The itself modified code in my funcion (void MyFrame::OnXXX(wxCommandEvent & event) {//} has the following shape (for illustration):
Code: Select all
fragment from ctor MyFrame...)
m_browser = wxWebView::New(m_panel60, wxID_ANY, wxEmptyString);
vTopSizer60->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
m_browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewArchiveHandler("wxfs")));
m_browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewFSHandler("memory")));
The itself modified code in my funcion (void MyFrame::OnXXX(wxCommandEvent & event) {//} has the following shape (for illustration):
Code: Select all
m_pageHTML.append( "<!DOCTYPE html PUBLIC '""-//W3C//DTD HTML 4.01 Transitional//EN""'>"
"<html>"
"<head>"
"<meta http-equiv='""content-type""' content='""text/html; charset=UTF-8""'>"
"<title>rozpocet</title>"
"</head>"
"<body>"
"<div align='""center""'>"
"<table style='""width: 100%; text-align: left; margin-left: auto; margin-right: auto;""' border='""0""' cellpadding='""0""' cellspacing='""0""'>"
"<tbody>"
"<tr>"
"<td style='""background-color: rgb(102, 255, 255); width: 160px;""' colspan='""1""' rowspan='""1""'><font color='""#3333ff""'><span style='""font-weight: bold; color: rgb(0, 0, 153);""'>"
"</span><big style='""color: rgb(0, 0, 153);""'><big style=""'font-weight: bold;""'>"+m_userdata12+":</big></big><br></font></td>"
"<td style='""vertical-align: top; color: rgb(0, 0, 153); background-color: rgb(102, 255, 255);""'><big style='""font-weight: bold;""'><big>"wxT("Výkaz výměr - rozpočet")"</big></big><br></td>"
"</tr>"
"</tbody>"
"</table>"
"<br>"
"<table style='""border-style: solid; border-color: blue;""' bgcolor='""#ffffff""' border='""1""' cellspacing='""0""' frame='""box""' rules='""none""' width='""100%""'>"
"<tbody>"
"<tr>"
"<td valign='""top""'><table style='""width: 100%;""' border='""0""' cellpadding='""2""' cellspacing='""2""' frame='""border""'>"
"<tbody>"
"<tr>"
"<td valign='""top""' width='""160""'><font color='""#3333ff""'><b><font size='""3""'>"wxT("Akce:")"</font></b><font size='""3""'><br></font></font></td>"
"<td colspan='""5""' rowspan='""1""' valign='""top""'><font size='""3""'>"+m_userdata09+"<br></font></td>"
"</tr>"
"<tr>"
"<td valign='""top""' width='""160""'><font color='""#3333ff""'><b><font size='""3""'>"wxT("Místo:")"</font></b><font size='""3""'><br></font></font></td>"
"<td colspan='""5""' rowspan='""1""' valign='""top""'><font size='""3""'>"+m_userdata10+"<br></font></td>"
"</tr>"
...
Re: wxWebView,how to set the text style
Thanks, I have used other methods