31#include <wx/tokenzr.h>
33#include <wx/statline.h>
39#if !wxUSE_XLOCALE && wxCHECK_VERSION(3, 0, 0)
40#define wxAtoi(arg) atoi(arg)
47 : wxStaticText(parent, wxID_ANY,
"") {
48 font = parent->GetFont();
52 Connect(wxEVT_LEFT_DOWN,
53 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
57 void SetLabel(
const wxString &label) {
58 wxStaticText::SetLabel(label);
60 auto size = dc.GetTextExtent(label).Scale(1.1, 1.1);
70EVT_PAINT(ConnectionParamsPanel::OnPaint)
71EVT_ERASE_BACKGROUND(ConnectionParamsPanel::OnEraseBackground)
75 wxWindow *parent, wxWindowID
id, const wxPoint &pos, const wxSize &size,
77 : wxPanel(parent,
id, pos, size, wxBORDER_NONE) {
78 m_pContainer = pContainer;
79 m_pConnectionParams = p_itemConnectionParams;
82 wxFont *dFont = GetOCPNScaledFont_PlugIn(_(
"Dialog"));
85 int refHeight = GetCharHeight();
90 Connect(wxEVT_LEFT_DOWN,
91 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
this);
95ConnectionParamsPanel::~ConnectionParamsPanel() {
96 if (m_pConnectionParams) m_pConnectionParams->m_optionsPanel =
nullptr;
99void ConnectionParamsPanel::OnSelected(wxMouseEvent &event) {}
101void ConnectionParamsPanel::SetSelected(
bool selected) {
102 m_bSelected = selected;
104 int refHeight = GetCharHeight();
112 wxWindowList kids = GetChildren();
113 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
114 wxWindowListNode *node = kids.Item(i);
115 wxWindow *win = node->GetData();
116 win->SetBackgroundColour(m_boxColour);
119 GetSizer()->Layout();
123void ConnectionParamsPanel::OnEnableCBClick(wxCommandEvent &event) {}
125void ConnectionParamsPanel::CreateControls(
void) {
126 int metric = GetCharHeight();
128 wxFont *dFont = GetOCPNScaledFont_PlugIn(_(
"Dialog"));
129 double font_size = dFont->GetPointSize() * 17 / 16;
130 wxFont *bFont = wxTheFontList->FindOrCreateFont(
131 font_size, dFont->GetFamily(), dFont->GetStyle(), wxFONTWEIGHT_BOLD);
133 wxBoxSizer *mainSizer =
new wxBoxSizer(wxVERTICAL);
136 mainSizer->AddSpacer(metric);
138 wxBoxSizer *panelSizer =
new wxBoxSizer(wxHORIZONTAL);
139 mainSizer->Add(panelSizer, 0, wxLEFT, 5);
141 mainSizer->AddSpacer(metric);
144 wxBoxSizer *enableSizer =
new wxBoxSizer(wxVERTICAL);
145 panelSizer->Add(enableSizer, 1);
147 m_cbEnable =
new wxCheckBox(
this, wxID_ANY, _(
"Enable"));
149 wxEVT_COMMAND_CHECKBOX_CLICKED,
150 wxCommandEventHandler(ConnectionParamsPanel::OnEnableCBClick), NULL,
152 m_cbEnable->SetValue(m_pConnectionParams->bEnabled);
154 enableSizer->Add(m_cbEnable, 1, wxLEFT | wxEXPAND, metric);
157 wxBoxSizer *parmSizer =
new wxBoxSizer(wxVERTICAL);
158 panelSizer->Add(parmSizer, 5);
160 if (m_pConnectionParams->Type == SERIAL) {
161 wxFlexGridSizer *serialGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
162 serialGrid->SetFlexibleDirection(wxHORIZONTAL);
163 parmSizer->Add(serialGrid, 0, wxALIGN_LEFT);
165 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
167 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
168 serialGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
169 t1->Connect(wxEVT_LEFT_DOWN,
170 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
173 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY,
"");
174 serialGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
175 t3->Connect(wxEVT_LEFT_DOWN,
176 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
179 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
180 serialGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
181 t5->Connect(wxEVT_LEFT_DOWN,
182 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
185 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _(
"Protocol"));
186 serialGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
187 t11->Connect(wxEVT_LEFT_DOWN,
188 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
191 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _(
"Serial Port"));
192 serialGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
193 t13->Connect(wxEVT_LEFT_DOWN,
194 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
197 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _(
"Baudrate"));
198 serialGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
199 t15->Connect(wxEVT_LEFT_DOWN,
200 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
205 serialGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
208 serialGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
211 serialGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
214 switch (m_pConnectionParams->Protocol) {
222 proto = _(
"Undefined");
227 serialGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
230 serialGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
232 auto baudRate = wxString::Format(
"%d", m_pConnectionParams->Baudrate);
234 serialGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
236 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
237 wxDefaultSize, wxLI_HORIZONTAL);
238 parmSizer->Add(line, 0, wxEXPAND);
239 line->Connect(wxEVT_LEFT_DOWN,
240 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
243 t21 =
new wxStaticText(
this, wxID_ANY,
244 _(
"Comment: ") + m_pConnectionParams->UserComment);
245 parmSizer->Add(t21, 0);
246 t21->Connect(wxEVT_LEFT_DOWN,
247 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
252 else if (m_pConnectionParams->Type == NETWORK) {
253 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
255 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
256 netGrid->SetFlexibleDirection(wxHORIZONTAL);
257 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
259 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
260 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
261 t1->Connect(wxEVT_LEFT_DOWN,
262 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
265 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY,
"");
266 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
267 t3->Connect(wxEVT_LEFT_DOWN,
268 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
271 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
272 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
273 t5->Connect(wxEVT_LEFT_DOWN,
274 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
277 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _(
"Protocol"));
278 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
279 t11->Connect(wxEVT_LEFT_DOWN,
280 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
283 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _(
"Network Address"));
284 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
285 t13->Connect(wxEVT_LEFT_DOWN,
286 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
289 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _(
"Network Port"));
290 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
291 t15->Connect(wxEVT_LEFT_DOWN,
292 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
296 t2 =
new wxStaticText(
this, wxID_ANY, _(
"Network"));
298 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
299 t2->Connect(wxEVT_LEFT_DOWN,
300 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
303 t4 =
new wxStaticText(
this, wxID_ANY,
"");
304 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
305 t4->Connect(wxEVT_LEFT_DOWN,
306 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
309 t6 =
new wxStaticText(
this, wxID_ANY, ioDir);
311 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
312 t6->Connect(wxEVT_LEFT_DOWN,
313 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
317 switch (m_pConnectionParams->NetProtocol) {
320 if (m_pConnectionParams->Protocol == PROTO_NMEA0183)
322 else if (m_pConnectionParams->Protocol == PROTO_NMEA2000)
327 if (m_pConnectionParams->Protocol == PROTO_NMEA0183)
329 else if (m_pConnectionParams->Protocol == PROTO_NMEA2000)
339 proto = _(
"Undefined");
343 t12 =
new wxStaticText(
this, wxID_ANY, proto);
344 t12->SetFont(*bFont);
345 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
346 t12->Connect(wxEVT_LEFT_DOWN,
347 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
350 wxString address = m_pConnectionParams->NetworkAddress;
351 t14 =
new wxStaticText(
this, wxID_ANY, address);
352 t14->SetFont(*bFont);
353 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
354 t14->Connect(wxEVT_LEFT_DOWN,
355 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
359 port.Printf(
"%d", m_pConnectionParams->NetworkPort);
360 t16 =
new wxStaticText(
this, wxID_ANY, port);
361 t16->SetFont(*bFont);
362 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
363 t16->Connect(wxEVT_LEFT_DOWN,
364 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
367 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
368 wxDefaultSize, wxLI_HORIZONTAL);
369 parmSizer->Add(line, 0, wxEXPAND);
370 line->Connect(wxEVT_LEFT_DOWN,
371 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
374 t21 =
new wxStaticText(
this, wxID_ANY,
375 _(
"Comment: ") + m_pConnectionParams->UserComment);
376 parmSizer->Add(t21, 0);
377 t21->Connect(wxEVT_LEFT_DOWN,
378 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
382 else if (m_pConnectionParams->Type == INTERNAL_GPS) {
383 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
385 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
386 netGrid->SetFlexibleDirection(wxHORIZONTAL);
387 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
389 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
390 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
391 t1->Connect(wxEVT_LEFT_DOWN,
392 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
395 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY,
"");
396 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
397 t3->Connect(wxEVT_LEFT_DOWN,
398 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
401 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
402 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
403 t5->Connect(wxEVT_LEFT_DOWN,
404 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
407 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY,
"");
408 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
409 t11->Connect(wxEVT_LEFT_DOWN,
410 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
413 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY,
"");
414 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
415 t13->Connect(wxEVT_LEFT_DOWN,
416 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
419 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY,
"");
420 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
421 t15->Connect(wxEVT_LEFT_DOWN,
422 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
426 t2 =
new wxStaticText(
this, wxID_ANY, _(
"Built-in GPS"));
428 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
429 t2->Connect(wxEVT_LEFT_DOWN,
430 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
433 t4 =
new wxStaticText(
this, wxID_ANY,
"");
434 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
435 t4->Connect(wxEVT_LEFT_DOWN,
436 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
439 t6 =
new wxStaticText(
this, wxID_ANY, ioDir);
441 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
442 t6->Connect(wxEVT_LEFT_DOWN,
443 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
448 t12 =
new wxStaticText(
this, wxID_ANY, proto);
449 t12->SetFont(*bFont);
450 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
451 t12->Connect(wxEVT_LEFT_DOWN,
452 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
456 t14 =
new wxStaticText(
this, wxID_ANY, address);
457 t14->SetFont(*bFont);
458 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
459 t14->Connect(wxEVT_LEFT_DOWN,
460 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
464 t16 =
new wxStaticText(
this, wxID_ANY, port);
465 t16->SetFont(*bFont);
466 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
467 t16->Connect(wxEVT_LEFT_DOWN,
468 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
471 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
472 wxDefaultSize, wxLI_HORIZONTAL);
473 parmSizer->Add(line, 0, wxEXPAND);
474 line->Connect(wxEVT_LEFT_DOWN,
475 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
478 t21 =
new wxStaticText(
this, wxID_ANY,
479 _(
"Comment: ") + m_pConnectionParams->UserComment);
480 parmSizer->Add(t21, 0);
481 t21->Connect(wxEVT_LEFT_DOWN,
482 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
485 }
else if (m_pConnectionParams->Type == INTERNAL_BT) {
486 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
488 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
489 netGrid->SetFlexibleDirection(wxHORIZONTAL);
490 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
492 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
493 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
494 t1->Connect(wxEVT_LEFT_DOWN,
495 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
498 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY,
"");
499 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
500 t3->Connect(wxEVT_LEFT_DOWN,
501 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
504 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
505 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
506 t5->Connect(wxEVT_LEFT_DOWN,
507 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
510 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY,
"");
511 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
512 t11->Connect(wxEVT_LEFT_DOWN,
513 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
516 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY,
"");
517 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
518 t13->Connect(wxEVT_LEFT_DOWN,
519 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
522 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY,
"");
523 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
524 t15->Connect(wxEVT_LEFT_DOWN,
525 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
529 t2 =
new wxStaticText(
this, wxID_ANY, _(
"Built-in Bluetooth"));
531 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
532 t2->Connect(wxEVT_LEFT_DOWN,
533 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
536 t4 =
new wxStaticText(
this, wxID_ANY,
"");
537 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
538 t4->Connect(wxEVT_LEFT_DOWN,
539 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
542 t6 =
new wxStaticText(
this, wxID_ANY, ioDir);
544 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
545 t6->Connect(wxEVT_LEFT_DOWN,
546 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
551 t12 =
new wxStaticText(
this, wxID_ANY, proto);
552 t12->SetFont(*bFont);
553 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
554 t12->Connect(wxEVT_LEFT_DOWN,
555 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
559 t14 =
new wxStaticText(
this, wxID_ANY, address);
560 t14->SetFont(*bFont);
561 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
562 t14->Connect(wxEVT_LEFT_DOWN,
563 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
567 t16 =
new wxStaticText(
this, wxID_ANY, port);
568 t16->SetFont(*bFont);
569 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
570 t16->Connect(wxEVT_LEFT_DOWN,
571 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
574 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
575 wxDefaultSize, wxLI_HORIZONTAL);
576 parmSizer->Add(line, 0, wxEXPAND);
577 line->Connect(wxEVT_LEFT_DOWN,
578 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
581 t21 =
new wxStaticText(
this, wxID_ANY,
582 _(
"Comment: ") + m_pConnectionParams->UserComment);
583 parmSizer->Add(t21, 0);
584 t21->Connect(wxEVT_LEFT_DOWN,
585 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
587 }
else if (m_pConnectionParams->Type == SOCKETCAN) {
588 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
589 netGrid->SetFlexibleDirection(wxHORIZONTAL);
590 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
592 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
593 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
594 t1->Connect(wxEVT_LEFT_DOWN,
595 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
598 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY,
"");
599 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
600 t3->Connect(wxEVT_LEFT_DOWN,
601 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
604 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Driver"));
605 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
606 t5->Connect(wxEVT_LEFT_DOWN,
607 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
610 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY,
"");
611 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
612 t11->Connect(wxEVT_LEFT_DOWN,
613 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
616 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY,
"");
617 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
618 t13->Connect(wxEVT_LEFT_DOWN,
619 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
622 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY,
"");
623 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
624 t15->Connect(wxEVT_LEFT_DOWN,
625 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
629 t2 =
new wxStaticText(
this, wxID_ANY,
"socketCan");
631 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
632 t2->Connect(wxEVT_LEFT_DOWN,
633 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
636 t4 =
new wxStaticText(
this, wxID_ANY,
"");
637 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
638 t4->Connect(wxEVT_LEFT_DOWN,
639 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
642 t6 =
new wxStaticText(
this, wxID_ANY, m_pConnectionParams->socketCAN_port);
644 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
645 t6->Connect(wxEVT_LEFT_DOWN,
646 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
651 t12 =
new wxStaticText(
this, wxID_ANY, proto);
652 t12->SetFont(*bFont);
653 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
654 t12->Connect(wxEVT_LEFT_DOWN,
655 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
659 t14 =
new wxStaticText(
this, wxID_ANY, address);
660 t14->SetFont(*bFont);
661 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
662 t14->Connect(wxEVT_LEFT_DOWN,
663 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
667 t16 =
new wxStaticText(
this, wxID_ANY, port);
668 t16->SetFont(*bFont);
669 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
670 t16->Connect(wxEVT_LEFT_DOWN,
671 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
674 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
675 wxDefaultSize, wxLI_HORIZONTAL);
676 parmSizer->Add(line, 0, wxEXPAND);
677 line->Connect(wxEVT_LEFT_DOWN,
678 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
681 t21 =
new wxStaticText(
this, wxID_ANY,
682 _(
"Comment: ") + m_pConnectionParams->UserComment);
683 parmSizer->Add(t21, 0);
684 t21->Connect(wxEVT_LEFT_DOWN,
685 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
693 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
695 if (m_pConnectionParams->Type == SERIAL) {
697 baudRate.Printf(
"%d", m_pConnectionParams->Baudrate);
700 switch (m_pConnectionParams->Protocol) {
708 proto = _(
"Undefined");
712 t2->SetLabel(_(
"Serial"));
714 t12->SetLabel(proto);
715 t14->SetLabel(m_pConnectionParams->Port);
716 t16->SetLabel(baudRate);
718 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
719 }
else if (m_pConnectionParams->Type == NETWORK) {
721 switch (m_pConnectionParams->NetProtocol) {
724 if (m_pConnectionParams->Protocol == PROTO_NMEA0183)
726 else if (m_pConnectionParams->Protocol == PROTO_NMEA2000)
731 if (m_pConnectionParams->Protocol == PROTO_NMEA0183)
733 else if (m_pConnectionParams->Protocol == PROTO_NMEA2000)
743 proto = _(
"Undefined");
747 port.Printf(
"%d", m_pConnectionParams->NetworkPort);
749 t2->SetLabel(_(
"Network"));
751 t12->SetLabel(proto);
752 t14->SetLabel(m_pConnectionParams->NetworkAddress);
755 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
756 }
else if (m_pConnectionParams->Type == INTERNAL_GPS) {
757 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
760 else if (m_pConnectionParams->Type == INTERNAL_BT) {
761 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
764 else if (m_pConnectionParams->Type == SOCKETCAN) {
765 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
766 t6->SetLabel(m_pConnectionParams->socketCAN_port);
769 GetSizer()->Layout();
772void ConnectionParamsPanel::OnEraseBackground(wxEraseEvent &event) {}
774void ConnectionParamsPanel::OnPaint(wxPaintEvent &event) {
776 GetSize(&width, &height);
779 dc.SetPen(*wxTRANSPARENT_PEN);
780 dc.SetBrush(wxBrush(GetBackgroundColour()));
781 dc.DrawRectangle(GetVirtualSize());
785 wxString nameString = m_pConnectionParams->Serialize();
787 wxFont *dFont = GetOCPNScaledFont_PlugIn(_(
"Dialog"));
790 dc.SetBrush(wxBrush(m_boxColour));
792 GetGlobalColor(_T (
"UITX1" ), &c);
793 dc.SetPen(wxPen(wxColor(0xCE, 0xD5, 0xD6), 3));
795 dc.DrawRoundedRectangle(0, 0, width - 1, height - 1, height / 10);
799 dc.SetTextForeground(wxColour(0, 0, 0));
801 dc.SetBrush(wxBrush(m_boxColour));
803 GetGlobalColor(_T (
"UITX1" ), &c);
804 dc.SetPen(wxPen(c, 1));
806 int offset = height / 10;
807 dc.DrawRectangle(offset, offset, width - (2 * offset),
808 height - (2 * offset));
810 dc.SetTextForeground(wxColour(128, 128, 128));
A wxStaticText bold label with correct width, see #2538.
Panel for displaying and editing connection parameters.
wxColour GetDialogColor(DialogColor color)
Retrieves a dialog color based on its role in the application's dialogs.
Global color handling by name.
@ DLG_BACKGROUND
Background color of the dialog.
@ DLG_HIGHLIGHT
Highlight color.
Panel for editing a connection.
PlugIn Object Definition/API.