28LinkPropDlgDef::LinkPropDlgDef(wxWindow* parent, wxWindowID
id,
29 const wxString& title,
const wxPoint& pos,
30 const wxSize& size,
long style) {
33 wxDialog::Create(parent,
id, title, pos, size, wstyle);
38 this->SetSizeHints(wxDefaultSize, wxDefaultSize);
40 wxBoxSizer* bSizerMain;
41 bSizerMain =
new wxBoxSizer(wxVERTICAL);
43 wxStaticBoxSizer* sbSizerLnkProp;
44 sbSizerLnkProp =
new wxStaticBoxSizer(
45 new wxStaticBox(
this, wxID_ANY, _(
"Link")), wxVERTICAL);
47 m_staticTextLinkDesc =
new wxStaticText(
this, wxID_ANY, _(
"Link description"),
48 wxDefaultPosition, wxDefaultSize, 0);
49 m_staticTextLinkDesc->Wrap(-1);
50 sbSizerLnkProp->Add(m_staticTextLinkDesc, 0, wxALL, 5);
52 m_textCtrlLinkDescription =
53 new wxTextCtrl(
this, wxID_ANY,
"", wxDefaultPosition, wxDefaultSize, 0);
54 sbSizerLnkProp->Add(m_textCtrlLinkDescription, 0, wxALL | wxEXPAND, 5);
56 m_staticTextLinkUrl =
new wxStaticText(
this, wxID_ANY, _(
"URL"),
57 wxDefaultPosition, wxDefaultSize, 0);
58 m_staticTextLinkUrl->Wrap(-1);
59 sbSizerLnkProp->Add(m_staticTextLinkUrl, 0, wxALL, 5);
62 new wxTextCtrl(
this, wxID_ANY,
"", wxDefaultPosition, wxDefaultSize, 0);
63 sbSizerLnkProp->Add(m_textCtrlLinkUrl, 0, wxALL | wxEXPAND, 5);
65 m_buttonBrowseLocal =
new wxButton(
this, wxID_ANY, _(
"Local file..."),
66 wxDefaultPosition, wxDefaultSize, 0);
67 sbSizerLnkProp->Add(m_buttonBrowseLocal, 0, wxALL, 5);
69 bSizerMain->Add(sbSizerLnkProp, 1, wxALL | wxEXPAND, 5);
71 m_sdbSizerButtons =
new wxStdDialogButtonSizer();
72 m_sdbSizerButtonsOK =
new wxButton(
this, wxID_OK);
73 m_sdbSizerButtons->AddButton(m_sdbSizerButtonsOK);
74 m_sdbSizerButtonsCancel =
new wxButton(
this, wxID_CANCEL, _(
"Cancel"));
75 m_sdbSizerButtons->AddButton(m_sdbSizerButtonsCancel);
76 m_sdbSizerButtons->Realize();
78 bSizerMain->Add(m_sdbSizerButtons, 0, wxALL | wxEXPAND, 5);
80 this->SetSizer(bSizerMain);
87 m_buttonBrowseLocal->Connect(
88 wxEVT_COMMAND_BUTTON_CLICKED,
89 wxCommandEventHandler(LinkPropDlgDef::OnLocalFileClick), NULL,
this);
90 m_sdbSizerButtonsCancel->Connect(
91 wxEVT_COMMAND_BUTTON_CLICKED,
92 wxCommandEventHandler(LinkPropDlgDef::OnCancelClick), NULL,
this);
93 m_sdbSizerButtonsOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
94 wxCommandEventHandler(LinkPropDlgDef::OnOkClick),
98LinkPropDlgDef::~LinkPropDlgDef() {
100 m_buttonBrowseLocal->Disconnect(
101 wxEVT_COMMAND_BUTTON_CLICKED,
102 wxCommandEventHandler(LinkPropDlgDef::OnLocalFileClick), NULL,
this);
103 m_sdbSizerButtonsCancel->Disconnect(
104 wxEVT_COMMAND_BUTTON_CLICKED,
105 wxCommandEventHandler(LinkPropDlgDef::OnCancelClick), NULL,
this);
106 m_sdbSizerButtonsOK->Disconnect(
107 wxEVT_COMMAND_BUTTON_CLICKED,
108 wxCommandEventHandler(LinkPropDlgDef::OnOkClick), NULL,
this);
111LinkPropImpl::LinkPropImpl(wxWindow* parent, wxWindowID
id,
112 const wxString& title,
const wxPoint& pos,
113 const wxSize& size,
long style)
119void LinkPropImpl::OnLocalFileClick(wxCommandEvent& event) {
120 wxString filename = wxFileSelector(_(
"Choose a file"));
121 if (!filename.empty()) {
122 wxString url = wxFileSystem::FileNameToURL(filename);
123 url.Replace(
"%3A",
":");
125 m_textCtrlLinkUrl->SetValue(url);
129void LinkPropImpl::OnOkClick(wxCommandEvent& event) {
130 if (m_textCtrlLinkUrl->GetValue() ==
"")
131 OCPNMessageBox(NULL, _(
"Link not complete, can't be saved."),
132 _(
"OpenCPN Info"), wxICON_HAND);
wxFont * GetOCPNScaledFont(wxString item, int default_size)
Retrieves a font from FontMgr, optionally scaled for physical readability.
General purpose GUI support.
Hyperlink properties dialog.