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)
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);
69extern "C" bool GetGlobalColor(wxString colorName, wxColour *pcolour);
72EVT_PAINT(ConnectionParamsPanel::OnPaint)
73EVT_ERASE_BACKGROUND(ConnectionParamsPanel::OnEraseBackground)
77 wxWindow *parent, wxWindowID
id, const wxPoint &pos, const wxSize &size,
79 : wxPanel(parent,
id, pos, size, wxBORDER_NONE) {
80 m_pContainer = pContainer;
81 m_pConnectionParams = p_itemConnectionParams;
84 wxFont *dFont = GetOCPNScaledFont_PlugIn(_(
"Dialog"));
87 int refHeight = GetCharHeight();
92 Connect(wxEVT_LEFT_DOWN,
93 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
this);
97ConnectionParamsPanel::~ConnectionParamsPanel() {
98 if (m_pConnectionParams) m_pConnectionParams->m_optionsPanel =
nullptr;
101void ConnectionParamsPanel::OnSelected(wxMouseEvent &event) {}
103void ConnectionParamsPanel::SetSelected(
bool selected) {
104 m_bSelected = selected;
106 int refHeight = GetCharHeight();
109 m_boxColour = GetDialogColor(DLG_HIGHLIGHT);
111 m_boxColour = GetDialogColor(DLG_BACKGROUND);
114 wxWindowList kids = GetChildren();
115 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
116 wxWindowListNode *node = kids.Item(i);
117 wxWindow *win = node->GetData();
118 win->SetBackgroundColour(m_boxColour);
121 GetSizer()->Layout();
125void ConnectionParamsPanel::OnEnableCBClick(wxCommandEvent &event) {}
127void ConnectionParamsPanel::CreateControls(
void) {
128 int metric = GetCharHeight();
130 wxFont *dFont = GetOCPNScaledFont_PlugIn(_(
"Dialog"));
131 double font_size = dFont->GetPointSize() * 17 / 16;
132 wxFont *bFont = wxTheFontList->FindOrCreateFont(
133 font_size, dFont->GetFamily(), dFont->GetStyle(), wxFONTWEIGHT_BOLD);
135 wxBoxSizer *mainSizer =
new wxBoxSizer(wxVERTICAL);
138 mainSizer->AddSpacer(metric);
140 wxBoxSizer *panelSizer =
new wxBoxSizer(wxHORIZONTAL);
141 mainSizer->Add(panelSizer, 0, wxLEFT, 5);
143 mainSizer->AddSpacer(metric);
146 wxBoxSizer *enableSizer =
new wxBoxSizer(wxVERTICAL);
147 panelSizer->Add(enableSizer, 1);
149 m_cbEnable =
new wxCheckBox(
this, wxID_ANY, _(
"Enable"));
151 wxEVT_COMMAND_CHECKBOX_CLICKED,
152 wxCommandEventHandler(ConnectionParamsPanel::OnEnableCBClick), NULL,
154 m_cbEnable->SetValue(m_pConnectionParams->bEnabled);
156 enableSizer->Add(m_cbEnable, 1, wxLEFT | wxEXPAND, metric);
159 wxBoxSizer *parmSizer =
new wxBoxSizer(wxVERTICAL);
160 panelSizer->Add(parmSizer, 5);
162 if (m_pConnectionParams->Type == SERIAL) {
163 wxFlexGridSizer *serialGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
164 serialGrid->SetFlexibleDirection(wxHORIZONTAL);
165 parmSizer->Add(serialGrid, 0, wxALIGN_LEFT);
167 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
169 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
170 serialGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
171 t1->Connect(wxEVT_LEFT_DOWN,
172 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
175 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
176 serialGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
177 t3->Connect(wxEVT_LEFT_DOWN,
178 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
181 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
182 serialGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
183 t5->Connect(wxEVT_LEFT_DOWN,
184 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
187 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _(
"Protocol"));
188 serialGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
189 t11->Connect(wxEVT_LEFT_DOWN,
190 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
193 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _(
"Serial Port"));
194 serialGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
195 t13->Connect(wxEVT_LEFT_DOWN,
196 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
199 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _(
"Baudrate"));
200 serialGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
201 t15->Connect(wxEVT_LEFT_DOWN,
202 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
207 serialGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
210 serialGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
213 serialGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
216 switch (m_pConnectionParams->Protocol) {
224 proto = _(
"Undefined");
229 serialGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
232 serialGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
234 auto baudRate = wxString::Format(
"%d", m_pConnectionParams->Baudrate);
236 serialGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
238 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
239 wxDefaultSize, wxLI_HORIZONTAL);
240 parmSizer->Add(line, 0, wxEXPAND);
241 line->Connect(wxEVT_LEFT_DOWN,
242 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
245 t21 =
new wxStaticText(
this, wxID_ANY,
246 _(
"Comment: ") + m_pConnectionParams->UserComment);
247 parmSizer->Add(t21, 0);
248 t21->Connect(wxEVT_LEFT_DOWN,
249 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
254 else if (m_pConnectionParams->Type == NETWORK) {
255 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
257 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
258 netGrid->SetFlexibleDirection(wxHORIZONTAL);
259 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
261 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
262 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
263 t1->Connect(wxEVT_LEFT_DOWN,
264 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
267 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
268 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
269 t3->Connect(wxEVT_LEFT_DOWN,
270 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
273 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
274 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
275 t5->Connect(wxEVT_LEFT_DOWN,
276 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
279 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _(
"Protocol"));
280 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
281 t11->Connect(wxEVT_LEFT_DOWN,
282 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
285 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _(
"Network Address"));
286 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
287 t13->Connect(wxEVT_LEFT_DOWN,
288 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
291 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _(
"Network Port"));
292 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
293 t15->Connect(wxEVT_LEFT_DOWN,
294 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
298 t2 =
new wxStaticText(
this, wxID_ANY, _(
"Network"));
300 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
301 t2->Connect(wxEVT_LEFT_DOWN,
302 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
305 t4 =
new wxStaticText(
this, wxID_ANY, _T(
""));
306 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
307 t4->Connect(wxEVT_LEFT_DOWN,
308 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
311 t6 =
new wxStaticText(
this, wxID_ANY, ioDir);
313 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
314 t6->Connect(wxEVT_LEFT_DOWN,
315 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
319 switch (m_pConnectionParams->NetProtocol) {
322 if (m_pConnectionParams->Protocol == PROTO_NMEA0183)
324 else if (m_pConnectionParams->Protocol == PROTO_NMEA2000)
329 if (m_pConnectionParams->Protocol == PROTO_NMEA0183)
331 else if (m_pConnectionParams->Protocol == PROTO_NMEA2000)
338 proto = _T(
"Signal K");
341 proto = _(
"Undefined");
345 t12 =
new wxStaticText(
this, wxID_ANY, proto);
346 t12->SetFont(*bFont);
347 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
348 t12->Connect(wxEVT_LEFT_DOWN,
349 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
352 wxString address = m_pConnectionParams->NetworkAddress;
353 t14 =
new wxStaticText(
this, wxID_ANY, address);
354 t14->SetFont(*bFont);
355 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
356 t14->Connect(wxEVT_LEFT_DOWN,
357 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
361 port.Printf(_T(
"%d"), m_pConnectionParams->NetworkPort);
362 t16 =
new wxStaticText(
this, wxID_ANY, port);
363 t16->SetFont(*bFont);
364 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
365 t16->Connect(wxEVT_LEFT_DOWN,
366 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
369 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
370 wxDefaultSize, wxLI_HORIZONTAL);
371 parmSizer->Add(line, 0, wxEXPAND);
372 line->Connect(wxEVT_LEFT_DOWN,
373 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
376 t21 =
new wxStaticText(
this, wxID_ANY,
377 _(
"Comment: ") + m_pConnectionParams->UserComment);
378 parmSizer->Add(t21, 0);
379 t21->Connect(wxEVT_LEFT_DOWN,
380 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
384 else if (m_pConnectionParams->Type == INTERNAL_GPS) {
385 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
387 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
388 netGrid->SetFlexibleDirection(wxHORIZONTAL);
389 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
391 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
392 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
393 t1->Connect(wxEVT_LEFT_DOWN,
394 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
397 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
398 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
399 t3->Connect(wxEVT_LEFT_DOWN,
400 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
403 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
404 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
405 t5->Connect(wxEVT_LEFT_DOWN,
406 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
409 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _T(
""));
410 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
411 t11->Connect(wxEVT_LEFT_DOWN,
412 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
415 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _T(
""));
416 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
417 t13->Connect(wxEVT_LEFT_DOWN,
418 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
421 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _T(
""));
422 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
423 t15->Connect(wxEVT_LEFT_DOWN,
424 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
428 t2 =
new wxStaticText(
this, wxID_ANY, _(
"Built-in GPS"));
430 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
431 t2->Connect(wxEVT_LEFT_DOWN,
432 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
435 t4 =
new wxStaticText(
this, wxID_ANY, _T(
""));
436 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
437 t4->Connect(wxEVT_LEFT_DOWN,
438 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
441 t6 =
new wxStaticText(
this, wxID_ANY, ioDir);
443 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
444 t6->Connect(wxEVT_LEFT_DOWN,
445 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
448 wxString proto = _T(
"");
450 t12 =
new wxStaticText(
this, wxID_ANY, proto);
451 t12->SetFont(*bFont);
452 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
453 t12->Connect(wxEVT_LEFT_DOWN,
454 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
458 t14 =
new wxStaticText(
this, wxID_ANY, address);
459 t14->SetFont(*bFont);
460 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
461 t14->Connect(wxEVT_LEFT_DOWN,
462 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
466 t16 =
new wxStaticText(
this, wxID_ANY, port);
467 t16->SetFont(*bFont);
468 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
469 t16->Connect(wxEVT_LEFT_DOWN,
470 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
473 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
474 wxDefaultSize, wxLI_HORIZONTAL);
475 parmSizer->Add(line, 0, wxEXPAND);
476 line->Connect(wxEVT_LEFT_DOWN,
477 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
480 t21 =
new wxStaticText(
this, wxID_ANY,
481 _(
"Comment: ") + m_pConnectionParams->UserComment);
482 parmSizer->Add(t21, 0);
483 t21->Connect(wxEVT_LEFT_DOWN,
484 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
487 }
else if (m_pConnectionParams->Type == INTERNAL_BT) {
488 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
490 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
491 netGrid->SetFlexibleDirection(wxHORIZONTAL);
492 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
494 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
495 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
496 t1->Connect(wxEVT_LEFT_DOWN,
497 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
500 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
501 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
502 t3->Connect(wxEVT_LEFT_DOWN,
503 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
506 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Direction"));
507 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
508 t5->Connect(wxEVT_LEFT_DOWN,
509 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
512 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _T(
""));
513 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
514 t11->Connect(wxEVT_LEFT_DOWN,
515 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
518 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _T(
""));
519 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
520 t13->Connect(wxEVT_LEFT_DOWN,
521 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
524 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _T(
""));
525 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
526 t15->Connect(wxEVT_LEFT_DOWN,
527 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
531 t2 =
new wxStaticText(
this, wxID_ANY, _(
"Built-in Bluetooth"));
533 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
534 t2->Connect(wxEVT_LEFT_DOWN,
535 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
538 t4 =
new wxStaticText(
this, wxID_ANY, _T(
""));
539 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
540 t4->Connect(wxEVT_LEFT_DOWN,
541 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
544 t6 =
new wxStaticText(
this, wxID_ANY, ioDir);
546 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
547 t6->Connect(wxEVT_LEFT_DOWN,
548 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
551 wxString proto = _T(
"");
553 t12 =
new wxStaticText(
this, wxID_ANY, proto);
554 t12->SetFont(*bFont);
555 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
556 t12->Connect(wxEVT_LEFT_DOWN,
557 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
561 t14 =
new wxStaticText(
this, wxID_ANY, address);
562 t14->SetFont(*bFont);
563 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
564 t14->Connect(wxEVT_LEFT_DOWN,
565 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
569 t16 =
new wxStaticText(
this, wxID_ANY, port);
570 t16->SetFont(*bFont);
571 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
572 t16->Connect(wxEVT_LEFT_DOWN,
573 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
576 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
577 wxDefaultSize, wxLI_HORIZONTAL);
578 parmSizer->Add(line, 0, wxEXPAND);
579 line->Connect(wxEVT_LEFT_DOWN,
580 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
583 t21 =
new wxStaticText(
this, wxID_ANY,
584 _(
"Comment: ") + m_pConnectionParams->UserComment);
585 parmSizer->Add(t21, 0);
586 t21->Connect(wxEVT_LEFT_DOWN,
587 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
589 }
else if (m_pConnectionParams->Type == SOCKETCAN) {
590 wxFlexGridSizer *netGrid =
new wxFlexGridSizer(2, 6, 0, metric / 2);
591 netGrid->SetFlexibleDirection(wxHORIZONTAL);
592 parmSizer->Add(netGrid, 0, wxALIGN_LEFT);
594 wxStaticText *t1 =
new wxStaticText(
this, wxID_ANY, _(
"Type"));
595 netGrid->Add(t1, 0, wxALIGN_CENTER_HORIZONTAL);
596 t1->Connect(wxEVT_LEFT_DOWN,
597 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
600 wxStaticText *t3 =
new wxStaticText(
this, wxID_ANY, _T(
""));
601 netGrid->Add(t3, 0, wxALIGN_CENTER_HORIZONTAL);
602 t3->Connect(wxEVT_LEFT_DOWN,
603 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
606 wxStaticText *t5 =
new wxStaticText(
this, wxID_ANY, _(
"Driver"));
607 netGrid->Add(t5, 0, wxALIGN_CENTER_HORIZONTAL);
608 t5->Connect(wxEVT_LEFT_DOWN,
609 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
612 wxStaticText *t11 =
new wxStaticText(
this, wxID_ANY, _T(
""));
613 netGrid->Add(t11, 0, wxALIGN_CENTER_HORIZONTAL);
614 t11->Connect(wxEVT_LEFT_DOWN,
615 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
618 wxStaticText *t13 =
new wxStaticText(
this, wxID_ANY, _T(
""));
619 netGrid->Add(t13, 0, wxALIGN_CENTER_HORIZONTAL);
620 t13->Connect(wxEVT_LEFT_DOWN,
621 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
624 wxStaticText *t15 =
new wxStaticText(
this, wxID_ANY, _T(
""));
625 netGrid->Add(t15, 0, wxALIGN_CENTER_HORIZONTAL);
626 t15->Connect(wxEVT_LEFT_DOWN,
627 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
631 t2 =
new wxStaticText(
this, wxID_ANY,
"socketCan");
633 netGrid->Add(t2, 0, wxALIGN_CENTER_HORIZONTAL);
634 t2->Connect(wxEVT_LEFT_DOWN,
635 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
638 t4 =
new wxStaticText(
this, wxID_ANY, _T(
""));
639 netGrid->Add(t4, 0, wxALIGN_CENTER_HORIZONTAL);
640 t4->Connect(wxEVT_LEFT_DOWN,
641 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
644 t6 =
new wxStaticText(
this, wxID_ANY, m_pConnectionParams->socketCAN_port);
646 netGrid->Add(t6, 0, wxALIGN_CENTER_HORIZONTAL);
647 t6->Connect(wxEVT_LEFT_DOWN,
648 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
651 wxString proto = _T(
"");
653 t12 =
new wxStaticText(
this, wxID_ANY, proto);
654 t12->SetFont(*bFont);
655 netGrid->Add(t12, 0, wxALIGN_CENTER_HORIZONTAL);
656 t12->Connect(wxEVT_LEFT_DOWN,
657 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
661 t14 =
new wxStaticText(
this, wxID_ANY, address);
662 t14->SetFont(*bFont);
663 netGrid->Add(t14, 0, wxALIGN_CENTER_HORIZONTAL);
664 t14->Connect(wxEVT_LEFT_DOWN,
665 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
669 t16 =
new wxStaticText(
this, wxID_ANY, port);
670 t16->SetFont(*bFont);
671 netGrid->Add(t16, 0, wxALIGN_CENTER_HORIZONTAL);
672 t16->Connect(wxEVT_LEFT_DOWN,
673 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
676 wxStaticLine *line =
new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
677 wxDefaultSize, wxLI_HORIZONTAL);
678 parmSizer->Add(line, 0, wxEXPAND);
679 line->Connect(wxEVT_LEFT_DOWN,
680 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
683 t21 =
new wxStaticText(
this, wxID_ANY,
684 _(
"Comment: ") + m_pConnectionParams->UserComment);
685 parmSizer->Add(t21, 0);
686 t21->Connect(wxEVT_LEFT_DOWN,
687 wxMouseEventHandler(ConnectionParamsPanel::OnSelected), NULL,
695 wxString ioDir = m_pConnectionParams->GetIOTypeValueStr();
697 if (m_pConnectionParams->Type == SERIAL) {
699 baudRate.Printf(_T(
"%d"), m_pConnectionParams->Baudrate);
702 switch (m_pConnectionParams->Protocol) {
704 proto = _T(
"NMEA 0183");
707 proto = _T(
"NMEA 2000");
710 proto = _(
"Undefined");
714 t2->SetLabel(_(
"Serial"));
716 t12->SetLabel(proto);
717 t14->SetLabel(m_pConnectionParams->Port);
718 t16->SetLabel(baudRate);
720 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
721 }
else if (m_pConnectionParams->Type == NETWORK) {
723 switch (m_pConnectionParams->NetProtocol) {
726 if (m_pConnectionParams->Protocol == PROTO_NMEA0183)
728 else if (m_pConnectionParams->Protocol == PROTO_NMEA2000)
733 if (m_pConnectionParams->Protocol == PROTO_NMEA0183)
735 else if (m_pConnectionParams->Protocol == PROTO_NMEA2000)
742 proto = _T(
"Signal K");
745 proto = _(
"Undefined");
749 port.Printf(_T(
"%d"), m_pConnectionParams->NetworkPort);
751 t2->SetLabel(_(
"Network"));
753 t12->SetLabel(proto);
754 t14->SetLabel(m_pConnectionParams->NetworkAddress);
757 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
758 }
else if (m_pConnectionParams->Type == INTERNAL_GPS) {
759 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
762 else if (m_pConnectionParams->Type == INTERNAL_BT) {
763 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
766 else if (m_pConnectionParams->Type == SOCKETCAN) {
767 t21->SetLabel(_(
"Comment: ") + m_pConnectionParams->UserComment);
768 t6->SetLabel(m_pConnectionParams->socketCAN_port);
771 GetSizer()->Layout();
774void ConnectionParamsPanel::OnEraseBackground(wxEraseEvent &event) {}
776void ConnectionParamsPanel::OnPaint(wxPaintEvent &event) {
778 GetSize(&width, &height);
781 dc.SetPen(*wxTRANSPARENT_PEN);
782 dc.SetBrush(wxBrush(GetBackgroundColour()));
783 dc.DrawRectangle(GetVirtualSize());
787 wxString nameString = m_pConnectionParams->Serialize();
789 wxFont *dFont = GetOCPNScaledFont_PlugIn(_(
"Dialog"));
792 dc.SetBrush(wxBrush(m_boxColour));
794 GetGlobalColor(_T (
"UITX1" ), &c);
795 dc.SetPen(wxPen(wxColor(0xCE, 0xD5, 0xD6), 3));
797 dc.DrawRoundedRectangle(0, 0, width - 1, height - 1, height / 10);
801 dc.SetTextForeground(wxColour(0, 0, 0));
803 dc.SetBrush(wxBrush(m_boxColour));
805 GetGlobalColor(_T (
"UITX1" ), &c);
806 dc.SetPen(wxPen(c, 1));
808 int offset = height / 10;
809 dc.DrawRectangle(offset, offset, width - (2 * offset),
810 height - (2 * offset));
812 dc.SetTextForeground(wxColour(128, 128, 128));
A wxStaticText bold label with correct width, see #2538.
Panel for displaying and editing connection parameters.
PlugIn Object Definition/API.