28#include "S57QueryDialog.h"
31#include <wx/textwrapper.h>
32#include "color_types.h"
34extern ColorScheme global_color_scheme;
36extern int g_S57_dialog_sx;
37extern int g_S57_dialog_sy;
38extern int g_S57_extradialog_sx;
39extern int g_S57_extradialog_sy;
40extern bool g_bresponsive;
48 Wrap(win, text, widthMax);
50 wxString
const& GetWrapped()
const {
return m_wrapped; }
51 int const GetLineCount()
const {
return m_lineCount; }
52 wxArrayString GetLineArray() {
return m_array; }
55 virtual void OnOutputLine(
const wxString& line) {
59 virtual void OnNewLine() {
67 wxArrayString m_array;
73EVT_SIZE(S57QueryDialog::OnSize)
74EVT_CLOSE(S57QueryDialog::OnClose)
75EVT_HTML_LINK_CLICKED(wxID_ANY, S57QueryDialog::OnHtmlLinkClicked)
76EVT_CHAR_HOOK(S57QueryDialog::OnKey)
82 const wxString& caption,
const wxPoint& pos,
83 const wxSize& size,
long style) {
85 Create(parent,
id, caption, pos, size, style);
88S57QueryDialog::~S57QueryDialog() {
89 g_S57_dialog_sx = GetSize().x;
90 g_S57_dialog_sy = GetSize().y;
91 m_btnOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED,
92 wxCommandEventHandler(S57QueryDialog::OnOKClick), NULL,
96void S57QueryDialog::Init() {}
98bool S57QueryDialog::Create(wxWindow* parent, wxWindowID
id,
99 const wxString& caption,
const wxPoint& pos,
100 const wxSize& size,
long style) {
107 long wstyle = wxDEFAULT_FRAME_STYLE | wxFRAME_FLOAT_ON_PARENT;
109 if ((global_color_scheme != GLOBAL_COLOR_SCHEME_DAY) &&
110 (global_color_scheme != GLOBAL_COLOR_SCHEME_RGB))
111 wstyle |= (wxNO_BORDER);
113 if (!wxFrame::Create(parent,
id, caption, pos, size, wstyle))
return false;
115 wxFont* dFont = GetOCPNScaledFont(_(
"ObjectQuery"));
138void S57QueryDialog::RecalculateSize(
void) {
141 wxSize esize = m_createsize;
143 esize = GetParent()->GetClientSize();
146 wxSize dsize = GetParent()->GetClientSize();
147 esize.y = wxMin(esize.y, dsize.y - (1 * GetCharHeight()));
148 esize.x = wxMin(esize.x, dsize.x - (1 * GetCharHeight()));
151 wxSize fsize = GetSize();
152 fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
153 fsize.x = wxMin(fsize.x, dsize.x - (2 * GetCharHeight()));
159void S57QueryDialog::CreateControls() {
160 wxBoxSizer* topSizer =
new wxBoxSizer(wxVERTICAL);
163 long style = wxHW_SCROLLBAR_AUTO;
164 if (g_btouch) style |= wxHW_NO_SELECTION;
167 new wxHtmlWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
169 m_phtml->SetBorders(5);
171 m_phtml->SetMinSize(wxSize(100, 100));
172 topSizer->Add(m_phtml, 1, wxBOTTOM | wxEXPAND, 10);
174 topSizer->FitInside(
this);
176 m_btnOK =
new wxButton(
this, wxID_OK);
177 m_btnOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
178 wxCommandEventHandler(S57QueryDialog::OnOKClick), NULL,
180 topSizer->Add(m_btnOK, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 5);
183void S57QueryDialog::SetColorScheme(
void) {
185 wxColor bg = GetBackgroundColour();
186 m_phtml->SetBackgroundColour(bg);
193 wxBitmap tbm(GetSize().x, GetSize().y, -1);
196 tdc.SetBackground(bg);
198 m_phtml->SetBackgroundImage(tbm);
202void S57QueryDialog::OnKey(wxKeyEvent& ke) {
203 if (ke.GetKeyCode() == WXK_ESCAPE)
209void S57QueryDialog::SetHTMLPage(wxString& page) {
210 m_phtml->SetPage(page);
214void S57QueryDialog::OnSize(wxSizeEvent& event) {
215 g_S57_dialog_sx = GetSize().x;
216 g_S57_dialog_sy = GetSize().y;
217 wxFrame::OnSize(event);
220void S57QueryDialog::OnClose(wxCloseEvent& event) {
221 g_S57_dialog_sx = GetSize().x;
222 g_S57_dialog_sy = GetSize().y;
224 g_pObjectQueryDialog = NULL;
227void S57QueryDialog::OnHtmlLinkClicked(wxHtmlLinkEvent& event) {
229 GetParent(), wxID_ANY, _(
"Extra Object Info"),
230 wxPoint(GetPosition().x + 20, GetPosition().y + 20),
231 wxSize(g_S57_extradialog_sx, g_S57_extradialog_sy));
234 wxFileName filen(event.GetLinkInfo().GetHref());
235 wxString Extensions = wxString(
"txt,html,rtf");
237 if (Extensions.Find(filen.GetExt().Lower()) == wxNOT_FOUND)
238 ExtraObjInfoDlg->m_phtml->LoadPage(event.GetLinkInfo().GetHref());
240 wxTextFile txf(filen.GetFullPath());
244 str = txf.GetFirstLine();
247 m_phtml->GetSize().x * 9 / 10);
248 contents += wrapper.GetWrapped();
251 str = txf.GetNextLine();
252 }
while (!txf.Eof());
254 ExtraObjInfoDlg->m_phtml->SetPage(contents);
258 ExtraObjInfoDlg->SetColorScheme();
260#ifdef __OCPN__ANDROID__
261 ExtraObjInfoDlg->SetSize(GetSize().x - 40, GetSize().y - 40);
264 ExtraObjInfoDlg->Show(
true);
272EVT_SIZE(S57ExtraQueryInfoDlg::OnSize)
273EVT_CLOSE(S57ExtraQueryInfoDlg::OnClose)
279 const wxString& caption,
281 const wxSize& size,
long style) {
283 Create(parent,
id, caption, pos, size, style);
285bool S57ExtraQueryInfoDlg::Create(wxWindow* parent, wxWindowID
id,
286 const wxString& caption,
const wxPoint& pos,
287 const wxSize& size,
long style) {
294 long wstyle = wxDEFAULT_FRAME_STYLE | wxFRAME_FLOAT_ON_PARENT;
296 if ((global_color_scheme != GLOBAL_COLOR_SCHEME_DAY) &&
297 (global_color_scheme != GLOBAL_COLOR_SCHEME_RGB))
298 wstyle |= (wxNO_BORDER);
300 if (!wxFrame::Create(parent,
id, caption, pos, size, wstyle))
return false;
302 wxFont* dFont = GetOCPNScaledFont(_(
"ObjectQuery"));
310S57ExtraQueryInfoDlg::~S57ExtraQueryInfoDlg() {
311 g_S57_extradialog_sx = GetSize().x;
312 g_S57_extradialog_sy = GetSize().y;
315void S57ExtraQueryInfoDlg::OnSize(wxSizeEvent& event) {
316 g_S57_extradialog_sx = GetSize().x;
317 g_S57_extradialog_sy = GetSize().y;
318 wxFrame::OnSize(event);
321void S57ExtraQueryInfoDlg::OnClose(wxCloseEvent& event) {
322 g_S57_extradialog_sx = GetSize().x;
323 g_S57_extradialog_sy = GetSize().y;
S57QueryDialog()
Constructors.