95 const fs::path m_svg_dir;
99 double GetSize(
const wxWindow* parent) {
100 double size = parent->GetCharHeight() * (IsWindows() ? 1.3 : 1.0);
101#if wxCHECK_VERSION(3, 1, 2)
104 size *=
static_cast<double>(parent->ToDIP(100)) / 100.;
108 double pixel_per_mm =
110 size = std::max(size, 7.0 * pixel_per_mm);
115 wxBitmap LoadIcon(
const std::string& filename)
const {
116 fs::path path = m_svg_dir / filename;
117 return LoadSVG(path.string(), m_size, m_size);
120 wxBitmap IconApplyColorScheme(
const wxBitmap proto)
const {
121 if (!proto.IsOk())
return wxNullBitmap;
122 if ((m_cs != GLOBAL_COLOR_SCHEME_DAY) &&
123 (m_cs != GLOBAL_COLOR_SCHEME_RGB)) {
125 wxImage image = proto.ConvertToImage();
126 unsigned char* data = image.GetData();
127 unsigned char* p_idata = data;
128 for (
int i = 0; i < image.GetSize().y; i++) {
129 for (
int j = 0; j < image.GetSize().x; j++) {
130 unsigned char v = *p_idata;
141 return wxBitmap(image);
148 : m_size(GetSize(parent)),
149 m_svg_dir(fs::path(g_Platform->GetSharedDataDir().ToStdString()) /
150 "uidata" /
"MUI_flat"),
151 m_cs(GLOBAL_COLOR_SCHEME_RGB),
152 trashbin_proto(LoadIcon(
"trash_bin.svg")),
153 settings_proto(LoadIcon(
"setting_gear.svg")),
154 filled_circle_proto(LoadIcon(
"circle-on.svg")),
155 open_circle_proto(LoadIcon(
"circle-off.svg")),
156 exclaim_mark_proto(LoadIcon(
"exclaim_mark.svg")),
157 x_mult_proto(LoadIcon(
"X_mult.svg")),
158 check_mark_proto(LoadIcon(
"check_mark.svg")) {
159 trashbin = trashbin_proto;
160 settings = settings_proto;
161 filled_circle = filled_circle_proto;
162 open_circle = open_circle_proto;
163 exclaim_mark = exclaim_mark_proto;
164 x_mult = x_mult_proto;
165 check_mark = check_mark_proto;
168 void SetColorScheme(ColorScheme cs) {
171 trashbin = IconApplyColorScheme(trashbin_proto);
172 settings = IconApplyColorScheme(settings_proto);
173 filled_circle = IconApplyColorScheme(filled_circle_proto);
174 open_circle = IconApplyColorScheme(open_circle_proto);
175 exclaim_mark = IconApplyColorScheme(exclaim_mark_proto);
176 x_mult = IconApplyColorScheme(x_mult_proto);
177 check_mark = IconApplyColorScheme(check_mark_proto);
181 const wxBitmap trashbin_proto;
182 const wxBitmap settings_proto;
183 const wxBitmap filled_circle_proto;
184 const wxBitmap open_circle_proto;
185 const wxBitmap exclaim_mark_proto;
186 const wxBitmap x_mult_proto;
187 const wxBitmap check_mark_proto;
191 wxBitmap filled_circle;
192 wxBitmap open_circle;
193 wxBitmap exclaim_mark;
300 wxWindow* parent,
const std::vector<ConnectionParams*>& connections,
303 : wxGrid(parent, wxID_ANY),
304 m_connections(connections),
305 m_on_conn_delete(on_conn_update),
306 m_last_tooltip_cell(100),
308 m_on_edit_conn(on_edit_conn) {
309 ShowScrollbars(wxSHOW_SB_NEVER, wxSHOW_SB_NEVER);
310 SetTable(
new wxGridStringTable(),
false);
311 GetTable()->AppendCols(8);
314 SetDefaultRowSize(wxWindow::GetCharHeight() * 2);
315 SetColLabelSize(wxWindow::GetCharHeight() * 2);
317 static const std::array<wxString, 7> headers = {
318 "", _(
"Protocol") +
" ", _(
"In/Out"), _(
"Data port"), _(
"Status"),
"",
321 for (
auto hdr = headers.begin(); hdr != headers.end(); hdr++, ic++) {
322 SetColLabelValue(
static_cast<int>(hdr - headers.begin()), *hdr);
323 int col_width = (*hdr).Length() * GetCharWidth();
324 col_width = wxMax(col_width, 6 * GetCharWidth());
325 header_column_widths[ic] = col_width;
326 SetColSize(ic, col_width);
330 SetLabelBackgroundColour(GetGlobalColor(
"DILG1"));
331 SetLabelTextColour(GetGlobalColor(
"DILG3"));
334 SetColAttributes(parent);
337 DisableDragColSize();
338 DisableDragRowSize();
339 wxWindow::Show(GetNumberRows() > 0);
341 GetGridWindow()->Bind(wxEVT_MOTION, [&](wxMouseEvent& ev) {
345 GetGridWindow()->Bind(wxEVT_MOUSEWHEEL,
346 [&](
const wxMouseEvent& ev) {
OnWheel(ev); });
348 Bind(wxEVT_GRID_LABEL_LEFT_CLICK,
349 [&](wxGridEvent& ev) { HandleSort(ev.GetCol()); });
350 Bind(wxEVT_GRID_CELL_LEFT_CLICK,
351 [&](wxGridEvent& ev) { OnClickCell(ev.GetRow(), ev.GetCol()); });
352 Bind(wxEVT_PAINT, [&](wxPaintEvent& ev) {
353 SetColAttributes(
static_cast<wxWindow*
>(ev.GetEventObject()));
356 conn_change_lstnr.
Init(
358 [&](
ObservedEvt&) { OnConnectionChange(m_connections); });
360 void SetColorScheme(ColorScheme cs) {
362 m_icons.SetColorScheme(cs);
366 wxSize GetEstimatedSize() {
368 for (
auto s : header_column_widths) rs += s;
369 return wxSize(rs, -1);
374 auto w =
static_cast<wxScrolledWindow*
>(
375 wxWindow::FindWindowByName(TopScrollWindowName));
376 assert(w &&
"No TopScroll window found");
379 w->GetViewStart(&xpos, &ypos);
382 w->GetScrollPixelsPerUnit(&x, &y);
384 int dir = ev.GetWheelRotation();
385 w->Scroll(-1, ypos - dir / y / 4);
389 void ReloadGrid(
const std::vector<ConnectionParams*>& connections) {
391 m_renderer_status_vector.clear();
393 for (
auto it = connections.begin(); it != connections.end(); it++) {
394 auto row =
static_cast<int>(it - connections.begin());
396 SetCellValue(row, 0, (*it)->bEnabled ?
"1" :
"");
398 m_tooltips[row][0] = _(
"Enabled, click to disable");
400 m_tooltips[row][0] = _(
"Disabled, click to enable");
401 std::string protocol = NavAddr::BusToString((*it)->GetCommProtocol());
402 SetCellValue(row, 1, protocol);
403 SetCellValue(row, 2, (*it)->GetIOTypeValueStr());
404 SetCellValue(row, 3, (*it)->GetStrippedDSPort());
405 m_tooltips[row][3] = (*it)->UserComment;
407 m_tooltips[row][5] = _(
"Edit connection");
409 m_tooltips[row][6] = _(
"Delete connection");
410 SetCellValue(row, 7, (*it)->GetKey());
413 stat_renderer->status = ConnState::Disabled;
414 m_renderer_status_vector.push_back(stat_renderer);
415 SetCellRenderer(row, 4, stat_renderer);
417 wxString sp(protocol);
418 int ssize = sp.Length() * wxWindow::GetCharWidth();
419 header_column_widths[1] = wxMax(header_column_widths[1], ssize);
420 ssize = (*it)->GetIOTypeValueStr().Length() * wxWindow::GetCharWidth();
421 header_column_widths[2] = wxMax(header_column_widths[2], ssize);
422 sp = wxString((*it)->GetStrippedDSPort());
423 ssize = sp.Length() * wxWindow::GetCharWidth();
424 header_column_widths[3] = wxMax(header_column_widths[3], ssize);
427 OnConnectionChange(m_connections);
431 for (
auto val : header_column_widths) {
446 if (row1 == -1 && row2 == -1)
return false;
447 if (row1 == -1)
return false;
448 if (row2 == -1)
return true;
449 int v1 =
static_cast<int>(m_conns->GetCellValue(row1, 4)[0]);
450 int v2 =
static_cast<int>(m_conns->GetCellValue(row2, 4)[0]);
463 auto found = find_if(
464 m_connections.begin(), m_connections.end(),
466 if (found == m_connections.end())
return -1;
467 return static_cast<int>(found - m_connections.begin());
476 auto found = find_if(m_connections.begin(), m_connections.end(),
478 return GetCellValue(row, 7) == p->GetKey();
480 return found != m_connections.end() ? *found :
nullptr;
487 void EnsureRows(
size_t rows) {
488 while (m_tooltips.size() <= rows)
489 m_tooltips.push_back(std::vector<std::string>(7));
490 while (GetNumberRows() <=
static_cast<int>(rows)) AppendRows(1,
false);
494 void SetColAttributes(
const wxWindow* parent) {
497 SetDefaultCellBackgroundColour(GetGlobalColor(
"DILG1"));
499 auto enable_attr =
new wxGridCellAttr();
500 enable_attr->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
501 enable_attr->SetRenderer(
new wxGridCellBoolRenderer());
502 enable_attr->SetEditor(
new wxGridCellBoolEditor());
503 if (IsWindows()) enable_attr->SetBackgroundColour(GetGlobalColor(
"DILG1"));
504 SetColAttr(0, enable_attr);
506 auto protocol_attr =
new wxGridCellAttr();
507 protocol_attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
508 protocol_attr->SetReadOnly(
true);
510 protocol_attr->SetBackgroundColour(GetGlobalColor(
"DILG1"));
511 SetColAttr(1, protocol_attr);
513 auto in_out_attr =
new wxGridCellAttr();
514 in_out_attr->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
515 in_out_attr->SetReadOnly(
true);
516 if (IsWindows()) in_out_attr->SetBackgroundColour(GetGlobalColor(
"DILG1"));
517 SetColAttr(2, in_out_attr);
519 auto port_attr =
new wxGridCellAttr();
520 port_attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
521 port_attr->SetReadOnly(
true);
522 if (IsWindows()) port_attr->SetBackgroundColour(GetGlobalColor(
"DILG1"));
523 SetColAttr(3, port_attr);
525 auto status_attr =
new wxGridCellAttr();
526 status_attr->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
527 status_attr->SetReadOnly(
true);
528 status_attr->SetFont(parent->GetFont().Scale(1.3));
529 if (IsWindows()) status_attr->SetBackgroundColour(GetGlobalColor(
"DILG1"));
530 SetColAttr(4, status_attr);
532 auto edit_attr =
new wxGridCellAttr();
533 edit_attr->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
534 edit_attr->SetFont(parent->GetFont().Scale(1.3));
535 edit_attr->SetReadOnly(
true);
536 if (IsWindows()) edit_attr->SetBackgroundColour(GetGlobalColor(
"DILG1"));
537 SetColAttr(5, edit_attr);
539 auto delete_attr =
new wxGridCellAttr();
540 delete_attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
541 delete_attr->SetFont(parent->GetFont().Scale(1.3));
542 delete_attr->SetTextColour(*wxRED);
543 delete_attr->SetReadOnly(
true);
544 if (IsWindows()) delete_attr->SetBackgroundColour(GetGlobalColor(
"DILG1"));
545 SetColAttr(6, delete_attr);
549 void OnClickCell(
int row,
int col) {
554 }
else if (col == 6) {
560 void OnMouseMove(
const wxMouseEvent& ev) {
561 wxPoint pt = ev.GetPosition();
562 int row = YToRow(pt.y);
563 int col = XToCol(pt.x);
564 if (col < 0 || col >= 7 || row < 0 || row >= GetNumberRows())
return;
565 if (row * 7 + col == m_last_tooltip_cell)
return;
566 m_last_tooltip_cell = row * 7 + col;
567 GetGridWindow()->SetToolTip(m_tooltips[row][col]);
571 void OnConnectionChange(
const std::vector<ConnectionParams*>& connections) {
572 bool refresh_needed =
false;
573 for (
auto it = connections.begin(); it != connections.end(); it++) {
574 ConnState state = m_conn_states.GetDriverState(
575 (*it)->GetCommProtocol(), (*it)->GetStrippedDSPort());
576 if (!(*it)->bEnabled) state = ConnState::Disabled;
577 auto row =
static_cast<int>(it - connections.begin());
579 if (m_renderer_status_vector.size() <
static_cast<size_t>(row + 1))
582 case ConnState::Disabled:
583 if (m_renderer_status_vector[row]->status != ConnState::Disabled) {
584 m_renderer_status_vector[row]->SetBitmap(m_icons.filled_circle);
585 m_renderer_status_vector[row]->status = ConnState::Disabled;
586 refresh_needed =
true;
588 m_tooltips[row][4] = _(
"Disabled");
590 case ConnState::NoStats:
591 if (m_renderer_status_vector[row]->status != ConnState::NoStats) {
592 m_renderer_status_vector[row]->SetBitmap(m_icons.open_circle);
593 m_renderer_status_vector[row]->status = ConnState::NoStats;
594 refresh_needed =
true;
596 m_tooltips[row][4] = _(
"No driver statistics available");
598 case ConnState::NoData:
599 if (m_renderer_status_vector[row]->status != ConnState::NoData) {
600 m_renderer_status_vector[row]->SetBitmap(m_icons.exclaim_mark);
601 m_renderer_status_vector[row]->status = ConnState::NoData;
602 refresh_needed =
true;
604 m_tooltips[row][4] = _(
"No data flowing through connection");
606 case ConnState::Unavailable:
607 if (m_renderer_status_vector[row]->status != ConnState::Unavailable) {
608 m_renderer_status_vector[row]->SetBitmap(m_icons.x_mult);
609 m_renderer_status_vector[row]->status = ConnState::Unavailable;
610 refresh_needed =
true;
612 m_tooltips[row][4] = _(
"The device is unavailable");
615 if (m_renderer_status_vector[row]->status != ConnState::Ok) {
616 m_renderer_status_vector[row]->SetBitmap(m_icons.check_mark);
617 m_renderer_status_vector[row]->status = ConnState::Ok;
618 refresh_needed =
true;
620 m_tooltips[row][4] = _(
"Data is flowing");
624 if (refresh_needed) ForceRefresh();
628 void SetSortingColumn(
int col) {
629 if (GetSortingColumn() != wxNOT_FOUND) {
630 int old_col = GetSortingColumn();
631 auto label = GetColLabelValue(old_col);
632 if (label[0] == kUtfArrowDown[0])
633 SetColLabelValue(old_col, label.substr(2));
635 auto label = GetColLabelValue(col);
636 if (label[0] != kUtfArrowDown[0])
637 SetColLabelValue(col, kUtfArrowDown +
" " + label);
638 wxGrid::SetSortingColumn(col);
643 void HandleSort(
int col) {
645 auto& params = TheConnectionParams();
647 std::sort(params.begin(), params.end(),
ConnCompare(col));
649 std::sort(params.begin(), params.end(), ConnStateCompare(
this));
651 SetSortingColumn(col);
655 void HandleEnable(
int row) {
658 cp->bEnabled = !cp->bEnabled;
659 cp->b_IsSetup = FALSE;
660 SetCellValue(row, 0, cp->bEnabled ?
"1" :
"");
662 m_tooltips[row][0] = _(
"Enabled, click to disable");
664 m_tooltips[row][0] = _(
"Disabled, click to enable");
666 stats.driver_iface = cp->GetStrippedDSPort();
667 stats.driver_bus = cp->GetCommProtocol();
668 m_conn_states.HandleDriverStats(stats);
669 StopAndRemoveCommDriver(cp->GetStrippedDSPort(), cp->GetCommProtocol());
670 if (cp->bEnabled) MakeCommDriver(cp);
671 cp->b_IsSetup =
true;
673 SetCellValue(row, 4, kUtfFilledCircle);
679 void HandleEdit(
int row) {
681 Show(GetNumberRows() > 0);
682 m_on_edit_conn(cp,
true);
687 void HandleDelete(
int row) {
689 auto found = std::find(m_connections.begin(), m_connections.end(), cp);
690 if (found != m_connections.end()) {
691 std::stringstream ss;
692 ss << _(
"Ok to delete connection on ") << (*found)->GetStrippedDSPort();
693 int rcode = OCPNMessageBox(
this, ss.str(), _(
"Delete connection?"),
695 if (rcode != wxID_OK && rcode != wxID_YES)
return;
696 delete (*found)->m_optionsPanel;
697 StopAndRemoveCommDriver((*found)->GetStrippedDSPort(),
698 (*found)->GetCommProtocol());
699 TheConnectionParams().erase(found);
700 if (GetNumberRows() >
static_cast<int>(m_connections.size()))
701 DeleteRows(GetNumberRows() - 1);
702 m_on_conn_delete.
Notify();
707 std::vector<std::vector<std::string>> m_tooltips;
709 const std::vector<ConnectionParams*>& m_connections;
711 int m_last_tooltip_cell;
713 std::vector<BitmapCellRenderer*> m_renderer_status_vector;
714 std::array<int, 7> header_column_widths;
826 : wxPanel(parent, wxID_ANY) {
827 auto sizer =
new wxStaticBoxSizer(wxVERTICAL,
this,
"");
828 sizer->Add(
new BearingsCheckbox(
this), wxSizerFlags().Expand());
829 sizer->Add(
new NmeaFilterRow(
this), wxSizerFlags().Expand());
830 sizer->Add(
new TalkerIdRow(
this), wxSizerFlags().Expand());
831 sizer->Add(
new NetmaskRow(
this), wxSizerFlags().Expand());
833 wxWindow::SetMaxSize(max_size);
838 class BearingsCheckbox :
public wxCheckBox,
public ApplyCancel {
840 BearingsCheckbox(wxWindow* parent)
841 : wxCheckBox(parent, wxID_ANY,
842 _(
"Use magnetic bearing in output sentence APB")) {
843 wxCheckBox::SetValue(g_bMagneticAPB);
846 void Apply()
override { g_bMagneticAPB = GetValue(); }
847 void Cancel()
override { SetValue(g_bMagneticAPB); }
851 class NmeaFilterRow :
public wxPanel,
public ApplyCancel {
852 wxCheckBox* checkbox;
853 wxTextCtrl* filter_period;
856 NmeaFilterRow(wxWindow* parent) : wxPanel(parent) {
857 auto hbox =
new wxBoxSizer(wxHORIZONTAL);
858 checkbox =
new wxCheckBox(
860 _(
"Filter NMEA course and speed data. Filter period: "));
861 checkbox->SetValue(g_bfilter_cogsog);
862 hbox->Add(checkbox, wxSizerFlags().Align(wxALIGN_CENTRE));
864 new wxTextCtrl(
this, wxID_ANY,
"", wxDefaultPosition,
865 wxSize(50, 3 * wxWindow::GetCharWidth()), 0);
866 filter_period->SetValue(std::to_string(g_COGFilterSec));
867 hbox->Add(filter_period, wxSizerFlags().Border());
869 NmeaFilterRow::Cancel();
872 void Apply()
override {
873 std::stringstream ss;
874 ss << filter_period->GetValue();
875 ss >> g_COGFilterSec;
876 g_bfilter_cogsog = checkbox->GetValue();
879 void Cancel()
override {
880 std::stringstream ss;
881 ss << g_COGFilterSec;
882 filter_period->SetValue(ss.str());
883 checkbox->SetValue(g_bfilter_cogsog);
888 class TalkerIdRow :
public wxPanel,
public ApplyCancel {
889 wxTextCtrl* text_ctrl;
892 TalkerIdRow(wxWindow* parent) : wxPanel(parent) {
893 auto hbox =
new wxBoxSizer(wxHORIZONTAL);
894 hbox->Add(
new wxStaticText(
this, wxID_ANY, _(
"NMEA 0183 Talker Id: ")),
895 wxSizerFlags().Align(wxALIGN_CENTRE_VERTICAL).Border());
896 text_ctrl =
new wxTextCtrl(
this, wxID_ANY,
"", wxDefaultPosition,
897 wxSize(50, 3 * wxWindow::GetCharWidth()));
898 text_ctrl->SetToolTip(
899 _(
"Enter a two-letter talker ID to override the default ID in NMEA "
900 "sentences generated by OpenCPN (e.g., GP, HC, EC). This affects "
901 "only sentences created by OpenCPN, not those forwarded from other "
903 text_ctrl->SetValue(g_TalkerIdText);
904 hbox->Add(text_ctrl, wxSizerFlags().Border());
906 TalkerIdRow::Cancel();
909 void Apply()
override { g_TalkerIdText = text_ctrl->GetValue(); }
910 void Cancel()
override { text_ctrl->SetValue(g_TalkerIdText); }
914 class NetmaskRow :
public wxPanel,
public ApplyCancel {
916 NetmaskRow(wxWindow* parent)
918 m_spin_ctrl(
new wxSpinCtrl(
this, wxID_ANY)),
919 m_text(
new wxStaticText(
this, wxID_ANY,
"")) {
920 m_spin_ctrl->SetRange(8, 32);
921 auto hbox =
new wxBoxSizer(wxHORIZONTAL);
922 auto flags = wxSizerFlags().Align(wxALIGN_CENTRE_VERTICAL).Border();
923 hbox->Add(
new wxStaticText(
this, wxID_ANY, _(
"Netmask: ")), flags);
924 hbox->Add(m_text, flags);
925 hbox->Add(
new wxStaticText(
this, wxID_ANY, _(
"length (bits): ")), flags);
926 hbox->Add(m_spin_ctrl, flags);
928 NetmaskRow::Cancel();
930 Bind(wxEVT_SPINCTRL, [&](wxSpinEvent& ev) {
931 m_text->SetLabel(BitsToDottedMask(m_spin_ctrl->GetValue()));
936 void Apply()
override { g_netmask_bits = m_spin_ctrl->GetValue(); }
938 void Cancel()
override {
939 m_spin_ctrl->SetValue(g_netmask_bits);
940 m_text->SetLabel(BitsToDottedMask(m_spin_ctrl->GetValue()));
945 wxSpinCtrl* m_spin_ctrl;
946 wxStaticText* m_text;
953 TopPanel(wxWindow* parent,
const std::vector<ConnectionParams*>& connections,
956 : wxPanel(parent, wxID_ANY),
957 m_evt_add_connection(evt_add_connection),
958 m_connections(connections) {
959 auto vbox =
new wxBoxSizer(wxVERTICAL);
960 auto conn_grid =
new Connections(
this, m_connections, m_evt_add_connection,
962 wxSize panel_max_size(conn_grid->GetEstimatedSize());
963 vbox->AddSpacer(wxWindow::GetCharHeight());
964 auto conn_flags = wxSizerFlags().Border();
965 if (IsAndroid()) conn_flags = wxSizerFlags().Border().Expand();
966 vbox->Add(conn_grid, conn_flags);
968 wxSizerFlags().Border());
969 vbox->Add(0, wxWindow::GetCharHeight());
971 wxSizerFlags().Border(wxLEFT | wxDOWN | wxRIGHT).Expand();
972 m_general_panel =
new GeneralPanel(
this, panel_max_size);
973 vbox->Add(m_general_panel, panel_flags);
975 auto advanced_panel =
new AdvancedPanel(
this, panel_max_size);
976 m_advanced_panel = advanced_panel;
977 auto on_toggle = [&, advanced_panel, vbox](
bool show) {
978 advanced_panel->Show(show);
979 vbox->SetSizeHints(
this);
982 vbox->Add(
new ShowAdvanced(
this, on_toggle), panel_flags);
983 vbox->Add(advanced_panel, panel_flags.ReserveSpaceEvenIfHidden());
986 vbox->SetSizeHints(
this);
991 auto on_evt_update_connections = [&, conn_grid](
ObservedEvt&) {
992 conn_grid->ReloadGrid(TheConnectionParams());
993 conn_grid->Show(conn_grid->GetNumberRows() > 0);
996 m_add_connection_lstnr.
Init(m_evt_add_connection,
997 on_evt_update_connections);
998 m_conn_grid = conn_grid;
1001 void SetColorScheme(ColorScheme cs) {
1002 m_conn_grid->SetColorScheme(cs);
1003 m_general_panel->SetColorScheme(cs);
1005 Connections* GetConnectionsGrid() {
return m_conn_grid; }
1010 const std::vector<ConnectionParams*>& m_connections;
1020 TopScroll(wxWindow* parent,
const std::vector<ConnectionParams*>& connections,
1022 : wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
1023 wxVSCROLL | wxHSCROLL, TopScrollWindowName) {
1024 ShowScrollbars(wxSHOW_SB_NEVER, wxSHOW_SB_ALWAYS);
1025 auto vbox =
new wxBoxSizer(wxVERTICAL);
1036 new TopPanel(
this, connections, evt_add_connection, on_edit_connection);
1037 vbox->Add(top_panel, wxSizerFlags(1).Expand());
1041 HandleEditFinish(p, new_mode, ok_cancel);
1045 m_edit_panel->SetPropsLabel(_(
"Edit Selected Connection"));
1046 wxWindow*
options = wxWindow::FindWindowByName(
"Options");
1047 assert(
options &&
"Null Options window!");
1052 m_edit_panel->SetSize(
1053 wxSize(
options->GetSize().x,
options->GetSize().y * fraction / 10));
1054 vbox->Add(m_edit_panel, wxSizerFlags(0).Expand());
1055 m_edit_panel->Hide();
1057 SetScrollRate(0, 10);
1058 if (IsAndroid()) SetScrollRate(1, 1);
1060 SetScrollRate(0, 10);
1061 if (IsAndroid()) SetScrollRate(1, 1);
1064 void SetColorScheme(ColorScheme cs) {
1065 if (top_panel) top_panel->SetColorScheme(cs);
1069 m_edit_panel->SetPropsLabel(_(
"Edit Selected Connection"));
1070 m_edit_panel->SetNewMode(
false);
1071 m_edit_panel->PreloadControls(p);
1072 m_edit_panel->AddOKCancelButtons();
1077 m_edit_panel->SetPropsLabel(_(
"Configure new connection"));
1078 m_edit_panel->SetDefaultConnectionParams();
1079 m_edit_panel->SetNewMode(
true);
1080 m_edit_panel->AddOKCancelButtons();
1084 void SwitchToEditor() {
1087 DimeControl(m_edit_panel);
1088 m_edit_panel->Show();
1089 g_options->ShowOKButtons(
false);
1094 void SwitchToGrid() {
1095 g_options->ShowOKButtons(
true);
1096 m_edit_panel->Hide();
1098 top_panel->GetConnectionsGrid()->
ReloadGrid(TheConnectionParams());
1112 delete cp_orig->m_optionsPanel;
1113 StopAndRemoveCommDriver(cp_orig->GetStrippedDSPort(),
1114 cp_orig->GetCommProtocol());
1116 assert(index != -1 &&
"Cannot look up connection index");
1117 TheConnectionParams()[index] = cp_edited;
1118 cp_edited->b_IsSetup =
false;
1123 if (cp->GetValidPort()) {
1124 cp->b_IsSetup =
false;
1125 TheConnectionParams().push_back(cp);
1128 _(
"Unable to create a connection as configured. "
1129 "Connected port or address was missing.");
1130 auto& noteman = NotificationManager::GetInstance();
1131 noteman.AddNotification(NotificationSeverity::kWarning,
1132 msg.ToStdString(), 60);
1135 UpdateDatastreams();
1136 top_panel->m_evt_add_connection.
Notify();
1140 UpdateDatastreams();