29#include <wx/tokenzr.h>
32#include <wx/statline.h>
33#include "conn_params_panel.h"
35#include "ocpn_plugin.h"
37#include "color_handler.h"
39#if !wxUSE_XLOCALE && wxCHECK_VERSION(3, 0, 0)
40#define wxAtoi(arg) atoi(arg)
48 : wxStaticText(parent, wxID_ANY,
"") {
49 font = parent->GetFont();
53 Connect(wxEVT_LEFT_DOWN,
54 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
58 void SetLabel(
const wxString& label) {
59 wxStaticText::SetLabel(label);
61 auto size = dc.GetTextExtent(label).Scale(1.1, 1.1);
71extern "C" bool GetGlobalColor(wxString colorName, wxColour *pcolour);
74EVT_PAINT(ConnectionParamsPanel::OnPaint)
75EVT_ERASE_BACKGROUND(ConnectionParamsPanel::OnEraseBackground)
79 wxWindow *parent, wxWindowID
id, const wxPoint &pos, const wxSize &size,
81 : wxPanel(parent,
id, pos, size, wxBORDER_NONE) {
82 m_pContainer = pContainer;
83 m_pConnectionParams = p_itemConnectionParams;
86 wxFont *dFont = GetOCPNScaledFont_PlugIn(_(
"Dialog"));
89 int refHeight = GetCharHeight();
94 Connect(wxEVT_LEFT_DOWN,
95 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
this);
99ConnectionParamsPanel::~ConnectionParamsPanel() {
100 if (m_pConnectionParams) m_pConnectionParams->m_optionsPanel =
nullptr;
103void ConnectionParamsPanel::OnSelected(wxMouseEvent &event) {
106 m_pContainer->SetSelectedConnectionPanel(
this);
109 m_pContainer->SetSelectedConnectionPanel(NULL);
113void ConnectionParamsPanel::SetSelected(
bool selected) {
114 m_bSelected = selected;
116 int refHeight = GetCharHeight();
119 m_boxColour = GetDialogColor(DLG_HIGHLIGHT);
121 m_boxColour = GetDialogColor(DLG_BACKGROUND);
124 wxWindowList kids = GetChildren();
125 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
126 wxWindowListNode *node = kids.Item(i);
127 wxWindow *win = node->GetData();
128 win->SetBackgroundColour(m_boxColour);
131 GetSizer()->Layout();
135void ConnectionParamsPanel::OnEnableCBClick(wxCommandEvent &event) {
137 m_pContainer->EnableConnection(m_pConnectionParams, event.IsChecked());
141void ConnectionParamsPanel::CreateControls(
void) {
142 int metric = GetCharHeight();
144 wxFont *dFont = GetOCPNScaledFont_PlugIn(_(
"Dialog"));
145 double font_size = dFont->GetPointSize() * 17 / 16;
146 wxFont *bFont = wxTheFontList->FindOrCreateFont(
147 font_size, dFont->GetFamily(), dFont->GetStyle(), wxFONTWEIGHT_BOLD);
149 wxBoxSizer *mainSizer =
new wxBoxSizer(wxVERTICAL);
152 mainSizer->AddSpacer(metric);
154 wxBoxSizer *panelSizer =
new wxBoxSizer(wxHORIZONTAL);
155 mainSizer->Add(panelSizer, 0, wxLEFT, 5);
157 mainSizer->AddSpacer(metric);
160 wxBoxSizer *enableSizer =
new wxBoxSizer(wxVERTICAL);
161 panelSizer->Add(enableSizer, 1);
163 m_cbEnable =
new wxCheckBox(
this, wxID_ANY, _(
"Enable"));
165 wxEVT_COMMAND_CHECKBOX_CLICKED,
166 wxCommandEventHandler(ConnectionParamsPanel::OnEnableCBClick), NULL,
168 m_cbEnable->SetValue(m_pConnectionParams->bEnabled);
170 enableSizer->Add(m_cbEnable, 1, wxLEFT | wxEXPAND, metric);
173 wxBoxSizer *parmSizer =
new wxBoxSizer(wxVERTICAL);
174 panelSizer->Add(parmSizer, 5);
176 if (m_pConnectionParams->Type == SERIAL) {
177 wxFlexGridSizer *serialGrid =
new wxFlexGridSizer(2, 7, 0, metric / 2);
178 serialGrid->SetFlexibleDirection(wxHORIZONTAL);
179 parmSizer->Add(serialGrid, 0, wxALIGN_LEFT);
181 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
183 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
184 serialGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
185 t1->Connect(wxEVT_LEFT_DOWN,
186 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
189 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
190 serialGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
191 t3->Connect(wxEVT_LEFT_DOWN,
192 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
195 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
196 serialGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
197 t5->Connect(wxEVT_LEFT_DOWN,
198 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
201 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _(
"Protocol"));
202 serialGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
203 t11->Connect(wxEVT_LEFT_DOWN,
204 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
207 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _(
"Serial Port"));
208 serialGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
209 t13->Connect(wxEVT_LEFT_DOWN,
210 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
213 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _(
"Baudrate"));
214 serialGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
215 t15->Connect(wxEVT_LEFT_DOWN,
216 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
219 wxStaticText *t17 =
new wxStaticText(
this, wxID_ANY, _(
"List position"));
220 serialGrid->Add(t17, 0, wxALIGN_CENTER_HORIZONTAL);
221 t17->Connect(wxEVT_LEFT_DOWN,
222 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
227 serialGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
230 serialGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
233 serialGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
236 switch (m_pConnectionParams->Protocol) {
244 proto = _(
"Undefined");
249 serialGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
252 serialGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
254 auto baudRate = wxString::Format(
"%d", m_pConnectionParams->Baudrate);
256 serialGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
258 auto priority = wxString::Format(
"%d", m_pConnectionParams->Priority);
260 serialGrid->Add(t18, 0, wxALIGN_CENTER_HORIZONTAL);
262 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
263 wxDefaultSize, wxLI_HORIZONTAL);
264 parmSizer->Add(line, 0, wxEXPAND);
265 line->Connect(wxEVT_LEFT_DOWN,
266 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
269 t21 =
new wxStaticText(
this, wxID_ANY,
270 _(
"Comment: ") + m_pConnectionParams->UserComment);
271 parmSizer->Add(t21, 0);
272 t21->Connect(wxEVT_LEFT_DOWN,
273 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
278 else if (m_pConnectionParams->Type == NETWORK) {
279 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
281 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 7, 0, metric / 2);
282 netGrid->SetFlexibleDirection(wxHORIZONTAL);
283 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
285 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
286 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
287 t1->Connect(wxEVT_LEFT_DOWN,
288 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
291 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
292 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
293 t3->Connect(wxEVT_LEFT_DOWN,
294 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
297 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
298 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
299 t5->Connect(wxEVT_LEFT_DOWN,
300 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
303 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _(
"Protocol"));
304 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
305 t11->Connect(wxEVT_LEFT_DOWN,
306 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
309 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _(
"Network Address"));
310 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
311 t13->Connect(wxEVT_LEFT_DOWN,
312 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
315 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _(
"Network Port"));
316 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
317 t15->Connect(wxEVT_LEFT_DOWN,
318 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
321 wxStaticText *t17 =
new wxStaticText(
this, wxID_ANY, _(
"List position"));
322 netGrid->Add(t17, 0, wxALIGN_CENTER_HORIZONTAL);
323 t17->Connect(wxEVT_LEFT_DOWN,
324 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
328 t2 =
new wxStaticText(
this, wxID_ANY, _(
"Network"));
330 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
331 t2->Connect(wxEVT_LEFT_DOWN,
332 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
335 t4 =
new wxStaticText(
this, wxID_ANY, _T(
""));
336 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
337 t4->Connect(wxEVT_LEFT_DOWN,
338 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
341 t6 =
new wxStaticText(
this, wxID_ANY, ioDir);
343 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
344 t6->Connect(wxEVT_LEFT_DOWN,
345 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
349 switch (m_pConnectionParams->NetProtocol) {
360 proto = _T(
"Signal K");
363 proto = _(
"Undefined");
367 t12 =
new wxStaticText(
this, wxID_ANY, proto);
368 t12->SetFont(*bFont);
369 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
370 t12->Connect(wxEVT_LEFT_DOWN,
371 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
374 wxString address = m_pConnectionParams->NetworkAddress;
375 t14 =
new wxStaticText(
this, wxID_ANY, address);
376 t14->SetFont(*bFont);
377 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
378 t14->Connect(wxEVT_LEFT_DOWN,
379 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
383 port.Printf(_T(
"%d"), m_pConnectionParams->NetworkPort);
384 t16 =
new wxStaticText(
this, wxID_ANY, port);
385 t16->SetFont(*bFont);
386 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
387 t16->Connect(wxEVT_LEFT_DOWN,
388 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
392 priority.Printf(_T(
"%d"), m_pConnectionParams->Priority);
393 t18 =
new wxStaticText(
this, wxID_ANY, priority);
394 t18->SetFont(*bFont);
395 netGrid->Add(t18, 0, wxALIGN_CENTER_HORIZONTAL);
396 t18->Connect(wxEVT_LEFT_DOWN,
397 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
400 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
401 wxDefaultSize, wxLI_HORIZONTAL);
402 parmSizer->Add(line, 0, wxEXPAND);
403 line->Connect(wxEVT_LEFT_DOWN,
404 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
407 t21 =
new wxStaticText(
this, wxID_ANY,
408 _(
"Comment: ") + m_pConnectionParams->UserComment);
409 parmSizer->Add(t21, 0);
410 t21->Connect(wxEVT_LEFT_DOWN,
411 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
415 else if (m_pConnectionParams->Type == INTERNAL_GPS) {
416 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
418 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 7, 0, metric / 2);
419 netGrid->SetFlexibleDirection(wxHORIZONTAL);
420 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
422 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
423 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
424 t1->Connect(wxEVT_LEFT_DOWN,
425 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
428 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
429 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
430 t3->Connect(wxEVT_LEFT_DOWN,
431 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
434 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
435 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
436 t5->Connect(wxEVT_LEFT_DOWN,
437 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
440 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _T(
""));
441 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
442 t11->Connect(wxEVT_LEFT_DOWN,
443 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
446 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _T(
""));
447 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
448 t13->Connect(wxEVT_LEFT_DOWN,
449 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
452 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _T(
""));
453 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
454 t15->Connect(wxEVT_LEFT_DOWN,
455 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
458 wxStaticText *t17 =
new wxStaticText(
this, wxID_ANY, _(
"List position"));
459 netGrid->Add(t17, 0, wxALIGN_CENTER_HORIZONTAL);
460 t17->Connect(wxEVT_LEFT_DOWN,
461 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
465 t2 =
new wxStaticText(
this, wxID_ANY, _(
"Built-in GPS"));
467 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
468 t2->Connect(wxEVT_LEFT_DOWN,
469 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
472 t4 =
new wxStaticText(
this, wxID_ANY, _T(
""));
473 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
474 t4->Connect(wxEVT_LEFT_DOWN,
475 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
478 t6 =
new wxStaticText(
this, wxID_ANY, ioDir);
480 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
481 t6->Connect(wxEVT_LEFT_DOWN,
482 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
485 wxString proto = _T(
"");
487 t12 =
new wxStaticText(
this, wxID_ANY, proto);
488 t12->SetFont(*bFont);
489 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
490 t12->Connect(wxEVT_LEFT_DOWN,
491 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
495 t14 =
new wxStaticText(
this, wxID_ANY, address);
496 t14->SetFont(*bFont);
497 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
498 t14->Connect(wxEVT_LEFT_DOWN,
499 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
503 t16 =
new wxStaticText(
this, wxID_ANY, port);
504 t16->SetFont(*bFont);
505 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
506 t16->Connect(wxEVT_LEFT_DOWN,
507 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
511 priority.Printf(_T(
"%d"), m_pConnectionParams->Priority);
512 t18 =
new wxStaticText(
this, wxID_ANY, priority);
513 t18->SetFont(*bFont);
514 netGrid->Add(t18, 0, wxALIGN_CENTER_HORIZONTAL);
515 t18->Connect(wxEVT_LEFT_DOWN,
516 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
519 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
520 wxDefaultSize, wxLI_HORIZONTAL);
521 parmSizer->Add(line, 0, wxEXPAND);
522 line->Connect(wxEVT_LEFT_DOWN,
523 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
526 t21 =
new wxStaticText(
this, wxID_ANY,
527 _(
"Comment: ") + m_pConnectionParams->UserComment);
528 parmSizer->Add(t21, 0);
529 t21->Connect(wxEVT_LEFT_DOWN,
530 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
533 }
else if (m_pConnectionParams->Type == INTERNAL_BT) {
534 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
536 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 7, 0, metric / 2);
537 netGrid->SetFlexibleDirection(wxHORIZONTAL);
538 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
540 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
541 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
542 t1->Connect(wxEVT_LEFT_DOWN,
543 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
546 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
547 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
548 t3->Connect(wxEVT_LEFT_DOWN,
549 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
552 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
553 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
554 t5->Connect(wxEVT_LEFT_DOWN,
555 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
558 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _T(
""));
559 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
560 t11->Connect(wxEVT_LEFT_DOWN,
561 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
564 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _T(
""));
565 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
566 t13->Connect(wxEVT_LEFT_DOWN,
567 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
570 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _T(
""));
571 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
572 t15->Connect(wxEVT_LEFT_DOWN,
573 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
576 wxStaticText *t17 =
new wxStaticText(
this, wxID_ANY, _(
"List position"));
577 netGrid->Add(t17, 0, wxALIGN_CENTER_HORIZONTAL);
578 t17->Connect(wxEVT_LEFT_DOWN,
579 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
583 t2 =
new wxStaticText(
this, wxID_ANY, _(
"Built-in Bluetooth"));
585 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
586 t2->Connect(wxEVT_LEFT_DOWN,
587 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
590 t4 =
new wxStaticText(
this, wxID_ANY, _T(
""));
591 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
592 t4->Connect(wxEVT_LEFT_DOWN,
593 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
596 t6 =
new wxStaticText(
this, wxID_ANY, ioDir);
598 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
599 t6->Connect(wxEVT_LEFT_DOWN,
600 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
603 wxString proto = _T(
"");
605 t12 =
new wxStaticText(
this, wxID_ANY, proto);
606 t12->SetFont(*bFont);
607 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
608 t12->Connect(wxEVT_LEFT_DOWN,
609 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
613 t14 =
new wxStaticText(
this, wxID_ANY, address);
614 t14->SetFont(*bFont);
615 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
616 t14->Connect(wxEVT_LEFT_DOWN,
617 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
621 t16 =
new wxStaticText(
this, wxID_ANY, port);
622 t16->SetFont(*bFont);
623 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
624 t16->Connect(wxEVT_LEFT_DOWN,
625 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
629 priority.Printf(_T(
"%d"), m_pConnectionParams->Priority);
630 t18 =
new wxStaticText(
this, wxID_ANY, priority);
631 t18->SetFont(*bFont);
632 netGrid->Add(t18, 0, wxALIGN_CENTER_HORIZONTAL);
633 t18->Connect(wxEVT_LEFT_DOWN,
634 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
637 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
638 wxDefaultSize, wxLI_HORIZONTAL);
639 parmSizer->Add(line, 0, wxEXPAND);
640 line->Connect(wxEVT_LEFT_DOWN,
641 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
644 t21 =
new wxStaticText(
this, wxID_ANY,
645 _(
"Comment: ") + m_pConnectionParams->UserComment);
646 parmSizer->Add(t21, 0);
647 t21->Connect(wxEVT_LEFT_DOWN,
648 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
650 }
else if (m_pConnectionParams->Type == SOCKETCAN) {
651 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 7, 0, metric / 2);
652 netGrid->SetFlexibleDirection(wxHORIZONTAL);
653 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
655 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
656 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
657 t1->Connect(wxEVT_LEFT_DOWN,
658 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
661 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
662 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
663 t3->Connect(wxEVT_LEFT_DOWN,
664 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
667 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Driver"));
668 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
669 t5->Connect(wxEVT_LEFT_DOWN,
670 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
673 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _T(
""));
674 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
675 t11->Connect(wxEVT_LEFT_DOWN,
676 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
679 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _T(
""));
680 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
681 t13->Connect(wxEVT_LEFT_DOWN,
682 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
685 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _T(
""));
686 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
687 t15->Connect(wxEVT_LEFT_DOWN,
688 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
691 wxStaticText *t17 =
new wxStaticText(
this, wxID_ANY,
"");
692 netGrid->Add(t17, 0, wxALIGN_CENTER_HORIZONTAL);
693 t17->Connect(wxEVT_LEFT_DOWN,
694 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
698 t2 =
new wxStaticText(
this, wxID_ANY,
"socketCan");
700 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
701 t2->Connect(wxEVT_LEFT_DOWN,
702 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
705 t4 =
new wxStaticText(
this, wxID_ANY, _T(
""));
706 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
707 t4->Connect(wxEVT_LEFT_DOWN,
708 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
711 t6 =
new wxStaticText(
this, wxID_ANY, m_pConnectionParams->socketCAN_port);
713 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
714 t6->Connect(wxEVT_LEFT_DOWN,
715 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
718 wxString proto = _T(
"");
720 t12 =
new wxStaticText(
this, wxID_ANY, proto);
721 t12->SetFont(*bFont);
722 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
723 t12->Connect(wxEVT_LEFT_DOWN,
724 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
728 t14 =
new wxStaticText(
this, wxID_ANY, address);
729 t14->SetFont(*bFont);
730 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
731 t14->Connect(wxEVT_LEFT_DOWN,
732 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
736 t16 =
new wxStaticText(
this, wxID_ANY, port);
737 t16->SetFont(*bFont);
738 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
739 t16->Connect(wxEVT_LEFT_DOWN,
740 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
744 t18 =
new wxStaticText(
this, wxID_ANY,
"");
745 t18->SetFont(*bFont);
746 netGrid->Add(t18, 0, wxALIGN_CENTER_HORIZONTAL);
747 t18->Connect(wxEVT_LEFT_DOWN,
748 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
751 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
752 wxDefaultSize, wxLI_HORIZONTAL);
753 parmSizer->Add(line, 0, wxEXPAND);
754 line->Connect(wxEVT_LEFT_DOWN,
755 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
758 t21 =
new wxStaticText(
this, wxID_ANY,
759 _(
"Comment: ") + m_pConnectionParams->UserComment);
760 parmSizer->Add(t21, 0);
761 t21->Connect(wxEVT_LEFT_DOWN,
762 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
770 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
772 priority.Printf(_T(
"%d"), m_pConnectionParams->Priority);
774 if (m_pConnectionParams->Type == SERIAL) {
776 baudRate.Printf(_T(
"%d"), m_pConnectionParams->Baudrate);
779 switch (m_pConnectionParams->Protocol) {
781 proto = _T(
"NMEA 0183");
784 proto = _T(
"NMEA 2000");
787 proto = _(
"Undefined");
791 t2->SetLabel(_(
"Serial"));
793 t12->SetLabel(proto);
794 t14->SetLabel(m_pConnectionParams->Port);
795 t16->SetLabel(baudRate);
796 t18->SetLabel(priority);
798 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
799 }
else if (m_pConnectionParams->Type == NETWORK) {
801 switch (m_pConnectionParams->NetProtocol) {
812 proto = _T(
"Signal K");
815 proto = _(
"Undefined");
819 port.Printf(_T(
"%d"), m_pConnectionParams->NetworkPort);
821 t2->SetLabel(_(
"Network"));
823 t12->SetLabel(proto);
824 t14->SetLabel(m_pConnectionParams->NetworkAddress);
826 t18->SetLabel(priority);
828 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
829 }
else if (m_pConnectionParams->Type == INTERNAL_GPS) {
830 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
833 else if (m_pConnectionParams->Type == INTERNAL_BT) {
834 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
837 else if (m_pConnectionParams->Type == SOCKETCAN) {
838 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
839 t6->SetLabel(m_pConnectionParams->socketCAN_port);
842 GetSizer()->Layout();
845void ConnectionParamsPanel::OnEraseBackground(wxEraseEvent &event) {}
847void ConnectionParamsPanel::OnPaint(wxPaintEvent &event) {
849 GetSize(&width, &height);
852 dc.SetPen(*wxTRANSPARENT_PEN);
853 dc.SetBrush(wxBrush(GetBackgroundColour()));
854 dc.DrawRectangle(GetVirtualSize());
858 wxString nameString = m_pConnectionParams->Serialize();
860 wxFont *dFont = GetOCPNScaledFont_PlugIn(_(
"Dialog"));
863 dc.SetBrush(wxBrush(m_boxColour));
865 GetGlobalColor(_T (
"UITX1" ), &c);
866 dc.SetPen(wxPen(wxColor(0xCE, 0xD5, 0xD6), 3));
868 dc.DrawRoundedRectangle(0, 0, width - 1, height - 1, height / 10);
872 dc.SetTextForeground(wxColour(0, 0, 0));
874 dc.SetBrush(wxBrush(m_boxColour));
876 GetGlobalColor(_T (
"UITX1" ), &c);
877 dc.SetPen(wxPen(c, 1));
879 int offset = height / 10;
880 dc.DrawRectangle(offset, offset, width - (2 * offset),
881 height - (2 * offset));
883 dc.SetTextForeground(wxColour(128, 128, 128));
A wxStaticText bold label with correct width, see #2538.