26 #include "LinkPropDlg.h"
30 LinkPropDlgDef::LinkPropDlgDef(wxWindow* parent, wxWindowID
id,
31 const wxString& title,
const wxPoint& pos,
32 const wxSize& size,
long style) {
35 wxDialog::Create(parent,
id, title, pos, size, wstyle);
37 wxFont* qFont = GetOCPNScaledFont(_(
"Dialog"));
40 this->SetSizeHints(wxDefaultSize, wxDefaultSize);
42 wxBoxSizer* bSizerMain;
43 bSizerMain =
new wxBoxSizer(wxVERTICAL);
45 wxStaticBoxSizer* sbSizerLnkProp;
46 sbSizerLnkProp =
new wxStaticBoxSizer(
47 new wxStaticBox(
this, wxID_ANY, _(
"Link")), wxVERTICAL);
49 m_staticTextLinkDesc =
new wxStaticText(
this, wxID_ANY, _(
"Link description"),
50 wxDefaultPosition, wxDefaultSize, 0);
51 m_staticTextLinkDesc->Wrap(-1);
52 sbSizerLnkProp->Add(m_staticTextLinkDesc, 0, wxALL, 5);
54 m_textCtrlLinkDescription =
new wxTextCtrl(
55 this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
56 sbSizerLnkProp->Add(m_textCtrlLinkDescription, 0, wxALL | wxEXPAND, 5);
58 m_staticTextLinkUrl =
new wxStaticText(
this, wxID_ANY, _(
"URL"),
59 wxDefaultPosition, wxDefaultSize, 0);
60 m_staticTextLinkUrl->Wrap(-1);
61 sbSizerLnkProp->Add(m_staticTextLinkUrl, 0, wxALL, 5);
63 m_textCtrlLinkUrl =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString,
64 wxDefaultPosition, wxDefaultSize, 0);
65 sbSizerLnkProp->Add(m_textCtrlLinkUrl, 0, wxALL | wxEXPAND, 5);
67 m_buttonBrowseLocal =
new wxButton(
this, wxID_ANY, _(
"Local file..."),
68 wxDefaultPosition, wxDefaultSize, 0);
69 sbSizerLnkProp->Add(m_buttonBrowseLocal, 0, wxALL, 5);
71 bSizerMain->Add(sbSizerLnkProp, 1, wxALL | wxEXPAND, 5);
73 m_sdbSizerButtons =
new wxStdDialogButtonSizer();
74 m_sdbSizerButtonsOK =
new wxButton(
this, wxID_OK);
75 m_sdbSizerButtons->AddButton(m_sdbSizerButtonsOK);
76 m_sdbSizerButtonsCancel =
new wxButton(
this, wxID_CANCEL, _(
"Cancel"));
77 m_sdbSizerButtons->AddButton(m_sdbSizerButtonsCancel);
78 m_sdbSizerButtons->Realize();
80 bSizerMain->Add(m_sdbSizerButtons, 0, wxALL | wxEXPAND, 5);
82 this->SetSizer(bSizerMain);
89 m_buttonBrowseLocal->Connect(
90 wxEVT_COMMAND_BUTTON_CLICKED,
91 wxCommandEventHandler(LinkPropDlgDef::OnLocalFileClick), NULL,
this);
92 m_sdbSizerButtonsCancel->Connect(
93 wxEVT_COMMAND_BUTTON_CLICKED,
94 wxCommandEventHandler(LinkPropDlgDef::OnCancelClick), NULL,
this);
95 m_sdbSizerButtonsOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
96 wxCommandEventHandler(LinkPropDlgDef::OnOkClick),
100 LinkPropDlgDef::~LinkPropDlgDef() {
102 m_buttonBrowseLocal->Disconnect(
103 wxEVT_COMMAND_BUTTON_CLICKED,
104 wxCommandEventHandler(LinkPropDlgDef::OnLocalFileClick), NULL,
this);
105 m_sdbSizerButtonsCancel->Disconnect(
106 wxEVT_COMMAND_BUTTON_CLICKED,
107 wxCommandEventHandler(LinkPropDlgDef::OnCancelClick), NULL,
this);
108 m_sdbSizerButtonsOK->Disconnect(
109 wxEVT_COMMAND_BUTTON_CLICKED,
110 wxCommandEventHandler(LinkPropDlgDef::OnOkClick), NULL,
this);
113 LinkPropImpl::LinkPropImpl(wxWindow* parent, wxWindowID
id,
114 const wxString& title,
const wxPoint& pos,
115 const wxSize& size,
long style)
121 void LinkPropImpl::OnLocalFileClick(wxCommandEvent& event) {
122 wxString filename = wxFileSelector(_(
"Choose a file"));
123 if (!filename.empty()) {
124 wxString url = wxFileSystem::FileNameToURL(filename);
125 url.Replace(_T(
"%3A"), _T(
":"));
127 m_textCtrlLinkUrl->SetValue(url);
131 void LinkPropImpl::OnOkClick(wxCommandEvent& event) {
132 if (m_textCtrlLinkUrl->GetValue() == wxEmptyString)
133 OCPNMessageBox(NULL, _(
"Link not complete, can't be saved."),
134 _(
"OpenCPN Info"), wxICON_HAND);
General purpose GUI support.