diff --git a/clientgui/DlgItemProperties.cpp b/clientgui/DlgItemProperties.cpp index 6a4f348d11..63be556f21 100644 --- a/clientgui/DlgItemProperties.cpp +++ b/clientgui/DlgItemProperties.cpp @@ -62,9 +62,10 @@ CDlgItemProperties::CDlgItemProperties(wxWindow* parent) : m_bSizer1 = new wxBoxSizer( wxVERTICAL ); const long style = wxBORDER_NONE; - m_txtInformation = wxWebView::New( this, wxID_ANY, wxWebViewDefaultURLStr, wxDefaultPosition, wxDefaultSize, wxWebViewBackendDefault, style ); - m_txtInformation->EnableContextMenu( false ); - + m_txtInformation = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style, wxEmptyString ); + m_txtInformation->Bind(wxEVT_LEFT_DOWN, &CDlgItemProperties::OnMouseButtonEvent, this); + m_txtInformation->Bind(wxEVT_LEFT_UP, &CDlgItemProperties::OnMouseButtonEvent, this); + m_bSizer1->Add( m_txtInformation, 1, wxEXPAND | wxALL, 5 ); wxBoxSizer *bSizer2 = new wxBoxSizer(wxHORIZONTAL); @@ -75,6 +76,7 @@ CDlgItemProperties::CDlgItemProperties(wxWindow* parent) : m_pCopySelectedButton = new wxButton(this, ID_COPYSELECTED, _("Copy &Selected"), wxDefaultPosition, wxDefaultSize); bSizer2->Add(m_pCopySelectedButton, 0, wxALIGN_BOTTOM | wxALIGN_CENTER_HORIZONTAL | wxALL, 5); + m_pCopySelectedButton->Enable(false); m_btnClose = new wxButton( this, wxID_OK, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 ); m_btnClose->SetDefault(); @@ -522,53 +524,27 @@ wxString CDlgItemProperties::FormatApplicationName(RESULT* result ) { void CDlgItemProperties::renderInfos() { wxString str_bg; str_bg.Printf(wxT("#%x"), this->GetBackgroundColour().GetRGB()); - wxFont font = this->GetFont(); - wxString font_name = font.GetFaceName(); - wxString font_size; - font_size.Printf(wxT("%d"), font.GetPointSize()); std::string content; content += ""; - content += ""; - content += ""; - content += ""; - content += ""; - content += ""; + content += ""; + content += "
"; for (size_t i = 0; i < m_items.size(); ++i) { if (m_items[i].item_type == ItemTypeSection) { content += ""; - content += ""; content += ""; } else if (m_items[i].item_type == ItemTypeProperty) { content += ""; - content += ""; - content += ""; content += ""; } @@ -576,7 +552,7 @@ void CDlgItemProperties::renderInfos() { content += "
"; - content += ""; + content += ""; content += ""; content += m_items[i].name; content += ""; - content += ""; content += "
"; - content += ""; + content += ""; content += m_items[i].name; - content += ""; content += ""; - content += ""; + content += ""; content += m_items[i].value; - content += ""; content += "
"; content += ""; content += ""; - m_txtInformation->SetPage(wxString(content), ""); + m_txtInformation->SetPage(content); } @@ -590,20 +566,23 @@ void CDlgItemProperties::addProperty(const wxString& name, const wxString& value m_items.push_back(ITEM(ItemTypeProperty, name, value)); } -void CDlgItemProperties::OnCopySelected( wxCommandEvent& ) { - if (m_txtInformation->HasSelection()) { - m_txtInformation->Copy(); - } else { - if (wxTheClipboard->Open()) { - wxTheClipboard->Clear(); - wxTheClipboard->SetData(new wxTextDataObject(wxEmptyString)); - wxTheClipboard->Close(); - } +void CDlgItemProperties::copyTextToClipboard(const wxString& text) { + if (wxTheClipboard->Open()) { + wxTheClipboard->Clear(); + wxTheClipboard->SetData(new wxTextDataObject(text)); + wxTheClipboard->Close(); } } -void CDlgItemProperties::OnCopyAll( wxCommandEvent& ) { - m_txtInformation->SelectAll(); - m_txtInformation->Copy(); - m_txtInformation->ClearSelection(); +void CDlgItemProperties::OnMouseButtonEvent(wxMouseEvent& event) { + m_pCopySelectedButton->Enable(m_txtInformation->SelectionToText() != wxEmptyString); + event.Skip(); +} + +void CDlgItemProperties::OnCopySelected( wxCommandEvent& ) { + copyTextToClipboard(m_txtInformation->SelectionToText()); +} + +void CDlgItemProperties::OnCopyAll( wxCommandEvent& ) { + copyTextToClipboard(m_txtInformation->ToText()); } diff --git a/clientgui/DlgItemProperties.h b/clientgui/DlgItemProperties.h index 52fd4682d4..d5e3a4c8f0 100644 --- a/clientgui/DlgItemProperties.h +++ b/clientgui/DlgItemProperties.h @@ -23,19 +23,11 @@ #pragma interface "DlgItemProperties.cpp" #endif -#include - -#include -#include #include -#include -#include -#include -#include #include #include #include -#include +#include #include "MainDocument.h" @@ -68,13 +60,15 @@ private: void renderInfos(); void addSection(const wxString& title); void addProperty(const wxString& name, const wxString& value); + void copyTextToClipboard(const wxString& text); + void OnMouseButtonEvent(wxMouseEvent& event); protected: wxBoxSizer* m_bSizer1; wxButton* m_btnClose; wxButton* m_pCopySelectedButton; wxButton* m_pCopyAllButton; wxString m_strBaseConfigLocation; - wxWebView* m_txtInformation; + wxHtmlWindow* m_txtInformation; }; #endif