29 #include <wx/tokenzr.h>
32 #include <wx/statline.h>
33 #include "conn_params_panel.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);
71 extern "C" bool GetGlobalColor(wxString colorName, wxColour *pcolour);
74 EVT_PAINT(ConnectionParamsPanel::OnPaint)
75 EVT_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);
99 ConnectionParamsPanel::~ConnectionParamsPanel() {
100 if (m_pConnectionParams) m_pConnectionParams->m_optionsPanel =
nullptr;
103 void ConnectionParamsPanel::OnSelected(wxMouseEvent &event) {
106 m_pContainer->SetSelectedConnectionPanel(
this);
109 m_pContainer->SetSelectedConnectionPanel(NULL);
113 void 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();
135 void ConnectionParamsPanel::OnEnableCBClick(wxCommandEvent &event) {
137 m_pContainer->EnableConnection(m_pConnectionParams, event.IsChecked());
141 void 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, 6, 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,
221 serialGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
224 serialGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
227 serialGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
230 switch (m_pConnectionParams->Protocol) {
238 proto = _(
"Undefined");
243 serialGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
246 serialGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
248 auto baudRate = wxString::Format(
"%d", m_pConnectionParams->Baudrate);
250 serialGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
252 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
253 wxDefaultSize, wxLI_HORIZONTAL);
254 parmSizer->Add(line, 0, wxEXPAND);
255 line->Connect(wxEVT_LEFT_DOWN,
256 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
259 t21 =
new wxStaticText(
this, wxID_ANY,
260 _(
"Comment: ") + m_pConnectionParams->UserComment);
261 parmSizer->Add(t21, 0);
262 t21->Connect(wxEVT_LEFT_DOWN,
263 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
268 else if (m_pConnectionParams->Type == NETWORK) {
269 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
271 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
272 netGrid->SetFlexibleDirection(wxHORIZONTAL);
273 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
275 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
276 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
277 t1->Connect(wxEVT_LEFT_DOWN,
278 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
281 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
282 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
283 t3->Connect(wxEVT_LEFT_DOWN,
284 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
287 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
288 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
289 t5->Connect(wxEVT_LEFT_DOWN,
290 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
293 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _(
"Protocol"));
294 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
295 t11->Connect(wxEVT_LEFT_DOWN,
296 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
299 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _(
"Network Address"));
300 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
301 t13->Connect(wxEVT_LEFT_DOWN,
302 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
305 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _(
"Network Port"));
306 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
307 t15->Connect(wxEVT_LEFT_DOWN,
308 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
312 t2 =
new wxStaticText(
this, wxID_ANY, _(
"Network"));
314 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
315 t2->Connect(wxEVT_LEFT_DOWN,
316 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
319 t4 =
new wxStaticText(
this, wxID_ANY, _T(
""));
320 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
321 t4->Connect(wxEVT_LEFT_DOWN,
322 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
325 t6 =
new wxStaticText(
this, wxID_ANY, ioDir);
327 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
328 t6->Connect(wxEVT_LEFT_DOWN,
329 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
333 switch (m_pConnectionParams->NetProtocol) {
336 if (m_pConnectionParams->Protocol == PROTO_NMEA0183)
338 else if (m_pConnectionParams->Protocol == PROTO_NMEA2000)
343 if (m_pConnectionParams->Protocol == PROTO_NMEA0183)
345 else if (m_pConnectionParams->Protocol == PROTO_NMEA2000)
352 proto = _T(
"Signal K");
355 proto = _(
"Undefined");
359 t12 =
new wxStaticText(
this, wxID_ANY, proto);
360 t12->SetFont(*bFont);
361 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
362 t12->Connect(wxEVT_LEFT_DOWN,
363 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
366 wxString address = m_pConnectionParams->NetworkAddress;
367 t14 =
new wxStaticText(
this, wxID_ANY, address);
368 t14->SetFont(*bFont);
369 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
370 t14->Connect(wxEVT_LEFT_DOWN,
371 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
375 port.Printf(_T(
"%d"), m_pConnectionParams->NetworkPort);
376 t16 =
new wxStaticText(
this, wxID_ANY, port);
377 t16->SetFont(*bFont);
378 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
379 t16->Connect(wxEVT_LEFT_DOWN,
380 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
383 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
384 wxDefaultSize, wxLI_HORIZONTAL);
385 parmSizer->Add(line, 0, wxEXPAND);
386 line->Connect(wxEVT_LEFT_DOWN,
387 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
390 t21 =
new wxStaticText(
this, wxID_ANY,
391 _(
"Comment: ") + m_pConnectionParams->UserComment);
392 parmSizer->Add(t21, 0);
393 t21->Connect(wxEVT_LEFT_DOWN,
394 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
398 else if (m_pConnectionParams->Type == INTERNAL_GPS) {
399 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
401 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
402 netGrid->SetFlexibleDirection(wxHORIZONTAL);
403 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
405 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
406 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
407 t1->Connect(wxEVT_LEFT_DOWN,
408 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
411 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
412 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
413 t3->Connect(wxEVT_LEFT_DOWN,
414 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
417 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
418 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
419 t5->Connect(wxEVT_LEFT_DOWN,
420 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
423 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _T(
""));
424 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
425 t11->Connect(wxEVT_LEFT_DOWN,
426 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
429 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _T(
""));
430 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
431 t13->Connect(wxEVT_LEFT_DOWN,
432 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
435 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _T(
""));
436 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
437 t15->Connect(wxEVT_LEFT_DOWN,
438 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
442 t2 =
new wxStaticText(
this, wxID_ANY, _(
"Built-in GPS"));
444 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
445 t2->Connect(wxEVT_LEFT_DOWN,
446 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
449 t4 =
new wxStaticText(
this, wxID_ANY, _T(
""));
450 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
451 t4->Connect(wxEVT_LEFT_DOWN,
452 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
455 t6 =
new wxStaticText(
this, wxID_ANY, ioDir);
457 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
458 t6->Connect(wxEVT_LEFT_DOWN,
459 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
462 wxString proto = _T(
"");
464 t12 =
new wxStaticText(
this, wxID_ANY, proto);
465 t12->SetFont(*bFont);
466 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
467 t12->Connect(wxEVT_LEFT_DOWN,
468 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
472 t14 =
new wxStaticText(
this, wxID_ANY, address);
473 t14->SetFont(*bFont);
474 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
475 t14->Connect(wxEVT_LEFT_DOWN,
476 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
480 t16 =
new wxStaticText(
this, wxID_ANY, port);
481 t16->SetFont(*bFont);
482 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
483 t16->Connect(wxEVT_LEFT_DOWN,
484 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
487 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
488 wxDefaultSize, wxLI_HORIZONTAL);
489 parmSizer->Add(line, 0, wxEXPAND);
490 line->Connect(wxEVT_LEFT_DOWN,
491 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
494 t21 =
new wxStaticText(
this, wxID_ANY,
495 _(
"Comment: ") + m_pConnectionParams->UserComment);
496 parmSizer->Add(t21, 0);
497 t21->Connect(wxEVT_LEFT_DOWN,
498 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
501 }
else if (m_pConnectionParams->Type == INTERNAL_BT) {
502 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
504 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
505 netGrid->SetFlexibleDirection(wxHORIZONTAL);
506 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
508 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
509 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
510 t1->Connect(wxEVT_LEFT_DOWN,
511 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
514 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
515 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
516 t3->Connect(wxEVT_LEFT_DOWN,
517 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
520 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
521 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
522 t5->Connect(wxEVT_LEFT_DOWN,
523 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
526 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _T(
""));
527 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
528 t11->Connect(wxEVT_LEFT_DOWN,
529 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
532 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _T(
""));
533 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
534 t13->Connect(wxEVT_LEFT_DOWN,
535 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
538 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _T(
""));
539 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
540 t15->Connect(wxEVT_LEFT_DOWN,
541 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
545 t2 =
new wxStaticText(
this, wxID_ANY, _(
"Built-in Bluetooth"));
547 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
548 t2->Connect(wxEVT_LEFT_DOWN,
549 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
552 t4 =
new wxStaticText(
this, wxID_ANY, _T(
""));
553 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
554 t4->Connect(wxEVT_LEFT_DOWN,
555 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
558 t6 =
new wxStaticText(
this, wxID_ANY, ioDir);
560 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
561 t6->Connect(wxEVT_LEFT_DOWN,
562 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
565 wxString proto = _T(
"");
567 t12 =
new wxStaticText(
this, wxID_ANY, proto);
568 t12->SetFont(*bFont);
569 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
570 t12->Connect(wxEVT_LEFT_DOWN,
571 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
575 t14 =
new wxStaticText(
this, wxID_ANY, address);
576 t14->SetFont(*bFont);
577 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
578 t14->Connect(wxEVT_LEFT_DOWN,
579 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
583 t16 =
new wxStaticText(
this, wxID_ANY, port);
584 t16->SetFont(*bFont);
585 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
586 t16->Connect(wxEVT_LEFT_DOWN,
587 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
590 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
591 wxDefaultSize, wxLI_HORIZONTAL);
592 parmSizer->Add(line, 0, wxEXPAND);
593 line->Connect(wxEVT_LEFT_DOWN,
594 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
597 t21 =
new wxStaticText(
this, wxID_ANY,
598 _(
"Comment: ") + m_pConnectionParams->UserComment);
599 parmSizer->Add(t21, 0);
600 t21->Connect(wxEVT_LEFT_DOWN,
601 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
603 }
else if (m_pConnectionParams->Type == SOCKETCAN) {
604 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
605 netGrid->SetFlexibleDirection(wxHORIZONTAL);
606 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
608 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
609 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
610 t1->Connect(wxEVT_LEFT_DOWN,
611 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
614 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
615 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
616 t3->Connect(wxEVT_LEFT_DOWN,
617 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
620 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Driver"));
621 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
622 t5->Connect(wxEVT_LEFT_DOWN,
623 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
626 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _T(
""));
627 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
628 t11->Connect(wxEVT_LEFT_DOWN,
629 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
632 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _T(
""));
633 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
634 t13->Connect(wxEVT_LEFT_DOWN,
635 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
638 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _T(
""));
639 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
640 t15->Connect(wxEVT_LEFT_DOWN,
641 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
645 t2 =
new wxStaticText(
this, wxID_ANY,
"socketCan");
647 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
648 t2->Connect(wxEVT_LEFT_DOWN,
649 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
652 t4 =
new wxStaticText(
this, wxID_ANY, _T(
""));
653 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
654 t4->Connect(wxEVT_LEFT_DOWN,
655 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
658 t6 =
new wxStaticText(
this, wxID_ANY, m_pConnectionParams->socketCAN_port);
660 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
661 t6->Connect(wxEVT_LEFT_DOWN,
662 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
665 wxString proto = _T(
"");
667 t12 =
new wxStaticText(
this, wxID_ANY, proto);
668 t12->SetFont(*bFont);
669 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
670 t12->Connect(wxEVT_LEFT_DOWN,
671 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
675 t14 =
new wxStaticText(
this, wxID_ANY, address);
676 t14->SetFont(*bFont);
677 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
678 t14->Connect(wxEVT_LEFT_DOWN,
679 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
683 t16 =
new wxStaticText(
this, wxID_ANY, port);
684 t16->SetFont(*bFont);
685 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
686 t16->Connect(wxEVT_LEFT_DOWN,
687 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
690 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
691 wxDefaultSize, wxLI_HORIZONTAL);
692 parmSizer->Add(line, 0, wxEXPAND);
693 line->Connect(wxEVT_LEFT_DOWN,
694 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
697 t21 =
new wxStaticText(
this, wxID_ANY,
698 _(
"Comment: ") + m_pConnectionParams->UserComment);
699 parmSizer->Add(t21, 0);
700 t21->Connect(wxEVT_LEFT_DOWN,
701 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
709 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
711 if (m_pConnectionParams->Type == SERIAL) {
713 baudRate.Printf(_T(
"%d"), m_pConnectionParams->Baudrate);
716 switch (m_pConnectionParams->Protocol) {
718 proto = _T(
"NMEA 0183");
721 proto = _T(
"NMEA 2000");
724 proto = _(
"Undefined");
728 t2->SetLabel(_(
"Serial"));
730 t12->SetLabel(proto);
731 t14->SetLabel(m_pConnectionParams->Port);
732 t16->SetLabel(baudRate);
734 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
735 }
else if (m_pConnectionParams->Type == NETWORK) {
737 switch (m_pConnectionParams->NetProtocol) {
740 if (m_pConnectionParams->Protocol == PROTO_NMEA0183)
742 else if (m_pConnectionParams->Protocol == PROTO_NMEA2000)
747 if (m_pConnectionParams->Protocol == PROTO_NMEA0183)
749 else if (m_pConnectionParams->Protocol == PROTO_NMEA2000)
756 proto = _T(
"Signal K");
759 proto = _(
"Undefined");
763 port.Printf(_T(
"%d"), m_pConnectionParams->NetworkPort);
765 t2->SetLabel(_(
"Network"));
767 t12->SetLabel(proto);
768 t14->SetLabel(m_pConnectionParams->NetworkAddress);
771 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
772 }
else if (m_pConnectionParams->Type == INTERNAL_GPS) {
773 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
776 else if (m_pConnectionParams->Type == INTERNAL_BT) {
777 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
780 else if (m_pConnectionParams->Type == SOCKETCAN) {
781 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
782 t6->SetLabel(m_pConnectionParams->socketCAN_port);
785 GetSizer()->Layout();
788 void ConnectionParamsPanel::OnEraseBackground(wxEraseEvent &event) {}
790 void ConnectionParamsPanel::OnPaint(wxPaintEvent &event) {
792 GetSize(&width, &height);
795 dc.SetPen(*wxTRANSPARENT_PEN);
796 dc.SetBrush(wxBrush(GetBackgroundColour()));
797 dc.DrawRectangle(GetVirtualSize());
801 wxString nameString = m_pConnectionParams->Serialize();
803 wxFont *dFont = GetOCPNScaledFont_PlugIn(_(
"Dialog"));
806 dc.SetBrush(wxBrush(m_boxColour));
808 GetGlobalColor(_T (
"UITX1" ), &c);
809 dc.SetPen(wxPen(wxColor(0xCE, 0xD5, 0xD6), 3));
811 dc.DrawRoundedRectangle(0, 0, width - 1, height - 1, height / 10);
815 dc.SetTextForeground(wxColour(0, 0, 0));
817 dc.SetBrush(wxBrush(m_boxColour));
819 GetGlobalColor(_T (
"UITX1" ), &c);
820 dc.SetPen(wxPen(c, 1));
822 int offset = height / 10;
823 dc.DrawRectangle(offset, offset, width - (2 * offset),
824 height - (2 * offset));
826 dc.SetTextForeground(wxColour(128, 128, 128));
A wxStaticText bold label with correct width, see #2538.