4#include <wx/listctrl.h>
13#include "model/cutil.h"
15#include "model/wx28compat.h"
16#include "OCPNPlatform.h"
17#include "RolloverWin.h"
20#include "ocpn_frame.h"
22extern ColorScheme global_color_scheme;
25extern wxString g_locale;
32enum { ID_TCWIN_NX, ID_TCWIN_PR };
34enum { TIDE_PLOT, CURRENT_PLOT };
36#include <wx/listimpl.cpp>
37WX_DEFINE_LIST(SplineList);
39BEGIN_EVENT_TABLE(
TCWin, wxWindow)
40EVT_PAINT(TCWin::OnPaint)
41EVT_SIZE(TCWin::OnSize)
42EVT_MOTION(TCWin::MouseEvent)
43EVT_BUTTON(wxID_OK, TCWin::OKEvent)
44EVT_BUTTON(ID_TCWIN_NX, TCWin::NXEvent)
45EVT_BUTTON(ID_TCWIN_PR, TCWin::PREvent)
46EVT_CLOSE(TCWin::OnCloseWindow)
47EVT_TIMER(TCWININF_TIMER, TCWin::OnTCWinPopupTimerEvent)
51extern wxDateTime gTimeSource;
57 m_pTCRolloverWin = NULL;
59 long wstyle = wxCLIP_CHILDREN | wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER |
60 wxFRAME_FLOAT_ON_PARENT;
70 pConfig->SetPath(_T (
"/Settings/Others" ));
71 pConfig->Read(_T (
"TCWindowTimeZone" ), &m_tzoneDisplay, 0);
74 wxFrame::Create(parent, wxID_ANY, wxString(_T (
"" )), m_position, m_tc_size,
84 if (strchr(
"Tt", pIDX->IDX_type)) {
85 m_plot_type = TIDE_PLOT;
86 SetTitle(wxString(_(
"Tide")));
89 m_plot_type = CURRENT_PLOT;
90 SetTitle(wxString(_(
"Current")));
94 GetClientSize(&sx, &sy);
100 wxString *TClist = NULL;
101 m_tList =
new wxListCtrl(
this, -1, wxPoint(sx * 65 / 100, 11),
102 wxSize((sx * 32 / 100), (sy * 20 / 100)),
103 wxLC_REPORT | wxLC_NO_HEADER);
108 col0.SetText(_T(
""));
109 col0.SetAlign(wxLIST_FORMAT_LEFT);
110 col0.SetWidth(sx * 30 / 100);
111 m_tList->InsertColumn(0, col0);
114 wxButton *test_button =
115 new wxButton(
this, wxID_OK, _(
"OK"), wxPoint(-1, -1), wxDefaultSize);
116 test_button->GetSize(&m_tsx, &m_tsy);
122 if ((m_tsy * 15) > sx) m_tList->Hide();
124 OK_button =
new wxButton(
this, wxID_OK, _(
"OK"),
125 wxPoint(sx - (2 * m_tsy + 10), sy - (m_tsy + 10)),
128 PR_button =
new wxButton(
this, ID_TCWIN_PR, _(
"Prev"),
129 wxPoint(10, sy - (m_tsy + 10)), wxSize(-1, -1));
131 wxSize texc_size = wxSize((sx * 60 / 100), (sy * 29 / 100));
132 if (!m_tList->IsShown()) {
133 texc_size = wxSize((sx * 90 / 100), (sy * 29 / 100));
137 new wxTextCtrl(
this, -1, _T(
""), wxPoint(sx * 3 / 100, 6), texc_size,
138 wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
139 int bsx, bsy, bpx, bpy;
140 PR_button->GetSize(&bsx, &bsy);
141 PR_button->GetPosition(&bpx, &bpy);
144 new wxButton(
this, ID_TCWIN_NX, _(
"Next"),
145 wxPoint(bpx + bsx + 5, sy - (m_tsy + 10)), wxSize(-1, -1));
147 wxString m_choiceTimezoneChoices[] = {_(
"LMT@Station"), _(
"UTC")};
148 int m_choiceTimezoneNChoices =
149 sizeof(m_choiceTimezoneChoices) /
sizeof(wxString);
150 m_choiceTimezone =
new wxChoice(
151 this, wxID_ANY, wxPoint((sx - (bsx * 2)) / 2, sy - (m_tsy * 12 / 10)),
152 wxSize(2 * bsx, bsy), m_choiceTimezoneNChoices, m_choiceTimezoneChoices,
154 m_choiceTimezone->SetToolTip(
155 _(
"Select whether tide times are shown in UTC or "
156 "Local Mean Time (LMT) at the station"));
157 m_choiceSize_x = bsx * 2;
159 m_choiceTimezone->SetSelection(m_tzoneDisplay);
160 m_choiceTimezone->Connect(wxEVT_COMMAND_CHOICE_SELECTED,
161 wxCommandEventHandler(TCWin::TimezoneOnChoice),
164 m_TCWinPopupTimer.SetOwner(
this, TCWININF_TIMER);
169 dc.GetTextExtent(_T(
"W"), NULL, &text_height);
170 m_refTextHeight = text_height;
171 m_button_height = m_tsy;
175 wxFont *dlg_font = FontMgr::Get().
GetFont(_(
"Dialog"));
176 int dlg_font_size = dlg_font->GetPointSize();
177#if defined(__WXOSX__) || defined(__WXGTK3__)
179 dlg_font_size /= GetContentScaleFactor();
183 dlg_font_size - 2, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL,
184 wxFONTWEIGHT_NORMAL, FALSE, wxString(_T (
"Arial" )));
186 dlg_font_size - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL,
187 wxFONTWEIGHT_NORMAL, FALSE, wxString(_T (
"Arial" )));
189 dlg_font_size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD,
190 FALSE, wxString(_T (
"Arial" )));
192 dlg_font_size + 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL,
193 wxFONTWEIGHT_BOLD, FALSE, wxString(_T (
"Arial" )));
196 pblack_1 = wxThePenList->FindOrCreatePen(
197 this->GetForegroundColour(), wxMax(1, (
int)(m_tcwin_scaler + 0.5)),
200 pblack_2 = wxThePenList->FindOrCreatePen(
201 this->GetForegroundColour(), wxMax(2, (
int)(2 * m_tcwin_scaler + 0.5)),
204 pblack_3 = wxThePenList->FindOrCreatePen(
205 wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW),
206 wxMax(1, (
int)(m_tcwin_scaler + 0.5)), wxPENSTYLE_SOLID);
208 pred_2 = wxThePenList->FindOrCreatePen(
209 wxColor(230, 54, 54), wxMax(4, (
int)(4 * m_tcwin_scaler + 0.5)),
212 pltgray = wxTheBrushList->FindOrCreateBrush(this->GetBackgroundColour(),
215 pltgray2 = wxTheBrushList->FindOrCreateBrush(this->GetBackgroundColour(),
217 pgraph = wxThePenList->FindOrCreatePen(
218 wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT),
219 wxMax(1, (
int)(m_tcwin_scaler + 0.5)), wxPENSTYLE_SOLID);
226 m_ptextctrl->Clear();
228 wxString locn(pIDX->IDX_station_name, wxConvUTF8);
229 wxString locna, locnb;
230 if (locn.Contains(wxString(_T (
"," )))) {
231 locna = locn.BeforeFirst(
',');
232 locnb = locn.AfterFirst(
',');
240 style.SetFont(*pLFont);
241 m_ptextctrl->SetDefaultStyle(style);
243 m_ptextctrl->AppendText(locna);
244 m_ptextctrl->AppendText(_T(
"\n"));
246 style.SetFont(*pSMFont);
247 m_ptextctrl->SetDefaultStyle(style);
249 if (!locnb.IsEmpty()) m_ptextctrl->AppendText(locnb);
250 m_ptextctrl->AppendText(_T(
"\n"));
253 if ((
't' == pIDX->IDX_type) || (
'c' == pIDX->IDX_type)) {
254 wxString mref(pIDX->IDX_reference_name, wxConvUTF8);
255 mref.Prepend(_T(
" "));
257 m_ptextctrl->AppendText(_(
"Reference Station :"));
258 m_ptextctrl->AppendText(_T(
"\n"));
260 m_ptextctrl->AppendText(mref);
261 m_ptextctrl->AppendText(_T(
"\n"));
264 m_ptextctrl->AppendText(_T(
"\n"));
268 wxString dsource(pIDX->source_ident, wxConvUTF8);
269 dsource.Prepend(_T(
" "));
271 m_ptextctrl->AppendText(_(
"Data Source :"));
272 m_ptextctrl->AppendText(_T(
"\n"));
274 m_ptextctrl->AppendText(dsource);
276 m_ptextctrl->ShowPosition(0);
279TCWin::~TCWin() { pParent->Refresh(
false); }
281void TCWin::SetTimeFactors() {
283 wxDateTime this_now = gTimeSource;
284 bool cur_time = !gTimeSource.IsValid();
287 this_now = wxDateTime::Now();
289 wxDateTime this_gmt = this_now.ToGMT();
291#if wxCHECK_VERSION(2, 6, 2)
292 wxTimeSpan diff = this_now.Subtract(this_gmt);
294 wxTimeSpan diff = this_gmt.Subtract(this_now);
297 m_diff_mins = diff.GetMinutes();
302#if wxCHECK_VERSION(3, 0, 2)
303 if (m_diff_mins == 0 && this_now.IsDST()) m_diff_mins += 60;
306 int station_offset = ptcmgr->GetStationTimeOffset(pIDX);
308 m_stationOffset_mins = station_offset;
309 if (this_now.IsDST()) {
310 m_stationOffset_mins += 60;
316#if wxCHECK_VERSION(3, 0, 2)
323 m_graphday = this_gmt;
325 int day_gmt = this_gmt.GetDayOfYear();
327 time_t ttNow = this_now.GetTicks();
328 time_t tt_at_station =
329 ttNow - (m_diff_mins * 60) + (m_stationOffset_mins * 60);
330 wxDateTime atStation(tt_at_station);
331 int day_at_station = atStation.GetDayOfYear();
333 if (day_gmt > day_at_station) {
334 wxTimeSpan dt(24, 0, 0, 0);
335 m_graphday.Subtract(dt);
336 }
else if (day_gmt < day_at_station) {
337 wxTimeSpan dt(24, 0, 0, 0);
341 wxDateTime graphday_00 = m_graphday;
342 graphday_00.ResetTime();
343 time_t t_graphday_00 = graphday_00.GetTicks();
349 m_t_graphday_GMT = t_graphday_00;
354void TCWin::TimezoneOnChoice(wxCommandEvent &event) {
355 m_tzoneDisplay = m_choiceTimezone->GetSelection();
361void TCWin::RecalculateSize() {
362 wxSize parent_size(2000, 2000);
363 if (pParent) parent_size = pParent->GetClientSize();
365 int unscaledheight = 600;
366 int unscaledwidth = 650;
372 g_tcwin_scale = wxMax(g_tcwin_scale, 10);
373 m_tcwin_scaler = g_Platform->GetDisplayDPmm() * 0.254 * g_tcwin_scale / 100.0;
375 m_tc_size.x = (int)(unscaledwidth * m_tcwin_scaler + 0.5);
376 m_tc_size.y = (int)(unscaledheight * m_tcwin_scaler + 0.5);
378 m_tc_size.x = wxMin(m_tc_size.x, parent_size.x);
379 m_tc_size.y = wxMin(m_tc_size.y, parent_size.y);
386 if ((m_x + 8 + m_tc_size.x) > parent_size.x) xc = xc - m_tc_size.x - 16;
387 if ((m_y + m_tc_size.y) > parent_size.y) yc = yc - m_tc_size.y;
393 if (pParent) pParent->ClientToScreen(&xc, &yc);
394 m_position = wxPoint(xc, yc);
402void TCWin::OKEvent(wxCommandEvent &event) {
404 pParent->pCwin = NULL;
406 delete m_pTCRolloverWin;
408 pParent->Refresh(
false);
412 pConfig->SetPath(_T (
"/Settings/Others" ));
413 pConfig->Write(_T (
"TCWindowTimeZone" ), m_tzoneDisplay);
419void TCWin::OnCloseWindow(wxCloseEvent &event) {
421 pParent->pCwin = NULL;
423 delete m_pTCRolloverWin;
428 pConfig->SetPath(_T (
"/Settings/Others" ));
429 pConfig->Write(_T (
"TCWindowTimeZone" ), m_tzoneDisplay);
435void TCWin::NXEvent(wxCommandEvent &event) {
436 wxTimeSpan dt(24, 0, 0, 0);
438 wxDateTime dm = m_graphday;
440 wxDateTime graphday_00 = dm.ResetTime();
441 time_t t_graphday_00 = graphday_00.GetTicks();
443 if (!graphday_00.IsDST() && m_graphday.IsDST()) t_graphday_00 -= 3600;
444 if (graphday_00.IsDST() && !m_graphday.IsDST()) t_graphday_00 += 3600;
446 m_t_graphday_GMT = t_graphday_00;
452void TCWin::PREvent(wxCommandEvent &event) {
453 wxTimeSpan dt(-24, 0, 0, 0);
455 wxDateTime dm = m_graphday;
457 wxDateTime graphday_00 = dm.ResetTime();
458 time_t t_graphday_00 = graphday_00.GetTicks();
460 if (!graphday_00.IsDST() && m_graphday.IsDST()) t_graphday_00 -= 3600;
461 if (graphday_00.IsDST() && !m_graphday.IsDST()) t_graphday_00 += 3600;
463 m_t_graphday_GMT = t_graphday_00;
469void TCWin::RePosition(
void) {
476 pParent->ClientToScreen(&r.x, &r.y);
480void TCWin::OnPaint(wxPaintEvent &event) {
490 if (m_graph_rect.x == 0)
return;
492 GetClientSize(&x, &y);
497 int x_graph = x * 1 / 10;
498 int y_graph = y * 32 / 100;
499 int x_graph_w = x * 8 / 10;
500 int y_graph_h = (y * .7) - (3 * m_button_height);
501 m_graph_rect = wxRect(x_graph, y_graph, x_graph_w, y_graph_h);
503 wxSize texc_size = wxSize( ( x * 60 / 100 ), ( y *29 / 100 ) );
504 if( !m_tList->IsShown()){
505 texc_size = wxSize( ( x * 90 / 100 ), ( y *29 / 100 ) );
508 m_ptextctrl->SetSize(texc_size);
518 pblack_1->SetColour(this->GetForegroundColour());
519 pblack_2->SetColour(this->GetForegroundColour());
520 pltgray->SetColour(this->GetBackgroundColour());
521 pltgray2->SetColour(this->GetBackgroundColour());
522 pred_2->SetColour(GetDimedColor(wxColor(230, 54, 54)));
526 int x_textbox = x * 5 / 100;
529 int x_textbox_w = x * 51 / 100;
530 int y_textbox_h = y * 25 / 100;
533 dc.SetPen(*pblack_3);
534 dc.SetBrush(*pltgray2);
535 dc.DrawRoundedRectangle(x_textbox, y_textbox, x_textbox_w, y_textbox_h,
538 if (m_tList->IsShown()) {
539 wxRect tab_rect = m_tList->GetRect();
540 dc.DrawRoundedRectangle(tab_rect.x - 4, y_textbox, tab_rect.width + 8,
545 dc.SetPen(*pblack_1);
546 dc.SetBrush(*pltgray);
547 dc.DrawRectangle(m_graph_rect.x, m_graph_rect.y, m_graph_rect.width,
548 m_graph_rect.height);
553 const int hour_delta = 4;
555 const int hour_delta = 1;
565 for (i = 0; i < 25; i++) {
566 int xd = m_graph_rect.x + ((i)*m_graph_rect.width / 25);
567 if (hour_delta != 1) {
568 if (i % hour_delta == 0) {
569 dc.SetPen(*pblack_2);
570 dc.DrawLine(xd, m_graph_rect.y, xd,
571 m_graph_rect.y + m_graph_rect.height + 5);
573 int hour_show = hour_start + i;
574 if (hour_show >= 24) hour_show -= 24;
575 sprintf(sbuf,
"%02d", hour_show);
577 dc.DrawText(wxString(sbuf, wxConvUTF8),
578 xd + x_shim + (m_graph_rect.width / 25) / 2,
579 m_graph_rect.y + m_graph_rect.height + 8);
581 dc.SetPen(*pblack_1);
582 dc.DrawLine(xd, m_graph_rect.y, xd,
583 m_graph_rect.y + m_graph_rect.height + 5);
586 dc.SetPen(*pblack_1);
587 dc.DrawLine(xd, m_graph_rect.y, xd,
588 m_graph_rect.y + m_graph_rect.height + 5);
590 sst.Printf(_T(
"%02d"), i);
591 dc.DrawRotatedText(sst, xd + (m_graph_rect.width / 25) / 2,
592 m_graph_rect.y + m_graph_rect.height + 8, 270.);
597 wxDateTime this_now = gTimeSource;
598 bool cur_time = !gTimeSource.IsValid();
599 if (cur_time) this_now = wxDateTime::Now();
601 time_t t_now = this_now.GetTicks();
602 t_now -= m_diff_mins * 60;
603 if (m_tzoneDisplay == 0)
604 t_now += m_stationOffset_mins * 60;
607 m_graph_rect.width * (t_now - m_t_graphday_GMT) / (25 * 3600.0f);
611 int xnow = (t_ratio < 0 || t_ratio > m_graph_rect.width)
613 : m_graph_rect.x + (int)t_ratio;
615 dc.DrawLine(xnow, m_graph_rect.y, xnow,
616 m_graph_rect.y + m_graph_rect.height);
617 dc.SetPen(*pblack_1);
626 m_tList->DeleteAllItems();
634 int tt_localtz = m_t_graphday_GMT + (m_diff_mins * 60);
637 ptcmgr->GetTideFlowSens(tt_localtz, BACKWARD_TEN_MINUTES_STEP,
640 if (m_tzoneDisplay == 0)
641 tt_localtz -= m_stationOffset_mins * 60;
643 for (i = 0; i < 26; i++) {
644 int tt = tt_localtz + (i * FORWARD_ONE_HOUR_STEP);
646 ptcmgr->GetTideOrCurrent(tt, pIDX->
IDX_rec_num, tcv[i], dir);
648 if (tcv[i] > tcmax) tcmax = tcv[i];
650 if (tcv[i] < tcmin) tcmin = tcv[i];
651 if (TIDE_PLOT == m_plot_type) {
652 if (!((tcv[i] > val) == wt) && (i > 0))
656 ptcmgr->GetHightOrLowTide(tt, BACKWARD_TEN_MINUTES_STEP,
657 BACKWARD_ONE_MINUTES_STEP, tcv[i], wt,
659 if (tctime > tt_localtz) {
663 tcd.Set(tctime - (m_diff_mins * 60));
664 if (m_tzoneDisplay == 0)
665 tcd.Set(tctime + (m_stationOffset_mins - m_diff_mins) * 60);
667 s.Printf(tcd.Format(_T(
"%H:%M ")));
668 s1.Printf(_T(
"%05.2f "), tcvalue);
671 if (pmsd) s.Append(wxString(pmsd->units_abbrv, wxConvUTF8));
673 (wt) ? s.Append(_(
"HW")) : s.Append(_(
"LW"));
676 li.SetId(list_index);
677 li.SetAlign(wxLIST_FORMAT_LEFT);
680 m_tList->InsertItem(li);
687 if (CURRENT_PLOT == m_plot_type) {
691 thx.Set((time_t)tt - (m_diff_mins * 60));
692 if (m_tzoneDisplay == 0)
693 thx.Set((time_t)tt + (m_stationOffset_mins - m_diff_mins) * 60);
695 s.Printf(thx.Format(_T(
"%H:%M ")));
696 s1.Printf(_T(
"%05.2f "), fabs(tcv[i]));
699 if (pmsd) s.Append(wxString(pmsd->units_abbrv, wxConvUTF8));
700 s1.Printf(_T(
" %03.0f"), dir);
704 li.SetId(list_index);
705 li.SetAlign(wxLIST_FORMAT_LEFT);
708 m_tList->InsertItem(li);
716 if (CURRENT_PLOT == m_plot_type) {
717 it = std::max(abs((
int)tcmin - 1), abs((
int)tcmax + 1));
721 m_plot_y_offset = m_graph_rect.height / 2;
725 if (tcmin < 0) ib -= 1;
729 m_plot_y_offset = (m_graph_rect.height * (it - ib)) / im;
736 dc.GetTextExtent(_T(
"1"), NULL, &height_stext);
737 float available_lines = (float)m_graph_rect.height / height_stext;
738 i_skip = (int)ceil(im / available_lines);
740 if (CURRENT_PLOT == m_plot_type && i_skip != 1) {
749 m_sList.DeleteContents(
true);
752 for (i = 0; i < 26; i++) {
753 wxPoint *pp =
new wxPoint;
754 pp->x = m_graph_rect.x + ((i)*m_graph_rect.width / 25);
755 pp->y = m_graph_rect.y + (m_plot_y_offset) -
756 (
int)((tcv[i] - val_off) * m_graph_rect.height / im);
765 dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
771 int yd = m_graph_rect.y + (m_plot_y_offset) -
772 ((i - val_off) * m_graph_rect.height / im);
774 if ((m_plot_y_offset + m_graph_rect.y) == yd)
775 dc.SetPen(*pblack_2);
777 dc.SetPen(*pblack_1);
779 dc.DrawLine(m_graph_rect.x, yd, m_graph_rect.x + m_graph_rect.width, yd);
780 snprintf(sbuf, 99,
"%d", i);
781 dc.DrawText(wxString(sbuf, wxConvUTF8), m_graph_rect.x - 20, yd - 5);
786#if wxCHECK_VERSION(2, 9, 0)
787 wxPointList *list = (wxPointList *)&m_sList;
789 wxList *list = (wxList *)&m_sList;
800 if (m_tzoneDisplay == 0) {
801 int station_offset = ptcmgr->GetStationTimeOffset(pIDX);
802 int h = station_offset / 60;
803 int m = station_offset - (h * 60);
804 if (m_graphday.IsDST()) h += 1;
805 m_stz.Printf(_T(
"UTC %+03d:%02d"), h, m);
809 double lat = ptcmgr->GetStationLat(pIDX);
813 switch (ptcmgr->GetStationTimeOffset(pIDX)) {
826 if (m_graphday.IsDST()) mtz[1] =
'D';
837 dc.GetTextExtent(m_stz, &w, &h);
838 dc.DrawText(m_stz, x / 2 - w / 2,
839 y - (m_button_height * 15 / 10) - (m_refTextHeight * 2));
842 if (g_locale == _T(
"en_US"))
843 sdate = m_graphday.Format(_T (
"%A %b %d, %Y" ));
845 sdate = m_graphday.Format(_T (
"%A %d %b %Y" ));
848 dc.GetTextExtent(sdate, &w, &h);
849 dc.DrawText(sdate, x / 2 - w / 2,
850 y - (m_button_height * 15 / 10) - (m_refTextHeight * 1));
854 dc.GetTextExtent(wxString(pmsd->units_conv, wxConvUTF8), &w, &h);
855 dc.DrawRotatedText(wxString(pmsd->units_conv, wxConvUTF8), 5,
856 m_graph_rect.y + m_graph_rect.height / 2 + w / 2, 90.);
865 dc.DrawText(fdir, m_graph_rect.x + m_graph_rect.width + 4,
866 m_graph_rect.y + m_graph_rect.height * 1 / 4);
870 dc.DrawText(edir, m_graph_rect.x + m_graph_rect.width + 4,
871 m_graph_rect.y + m_graph_rect.height * 3 / 4);
875 if ((m_button_height * 15) < x && cur_time) {
878 int day = m_graphday.GetDayOfYear();
879 if (m_graphday.GetYear() == this_now.GetYear()) {
880 if (day == this_now.GetDayOfYear())
881 sday.Append(_(
"Today"));
882 else if (day == this_now.GetDayOfYear() + 1)
883 sday.Append(_(
"Tomorrow"));
885 sday.Append(m_graphday.GetWeekDayName(m_graphday.GetWeekDay()));
886 }
else if (m_graphday.GetYear() == this_now.GetYear() + 1 &&
887 day == this_now.Add(wxTimeSpan::Day()).GetDayOfYear())
888 sday.Append(_(
"Tomorrow"));
891 dc.GetTextExtent(sday, &w, &h);
892 dc.DrawText(sday, 55 - w / 2,
893 y - (m_button_height * 15 / 10) - (m_refTextHeight * 1));
897 double spotDim = 4 * g_Platform->GetDisplayDPmm();
899 dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(
900 GetGlobalColor(_T (
"YELO1" )), wxBRUSHSTYLE_SOLID));
901 dc.SetPen(wxPen(GetGlobalColor(_T (
"URED" )),
902 wxMax(2, 0.5 * g_Platform->GetDisplayDPmm())));
903 dc.DrawRoundedRectangle(xSpot - spotDim / 2, ySpot - spotDim / 2, spotDim,
904 spotDim, spotDim / 2);
906 dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(
907 GetGlobalColor(_T (
"UBLCK" )), wxBRUSHSTYLE_SOLID));
908 dc.SetPen(wxPen(GetGlobalColor(_T (
"UBLCK" )), 1));
910 double ispotDim = spotDim / 5.;
911 dc.DrawRoundedRectangle(xSpot - ispotDim / 2, ySpot - ispotDim / 2,
912 ispotDim, ispotDim, ispotDim / 2);
916void TCWin::OnSize(wxSizeEvent &event) {
917 if (!m_created)
return;
920 GetClientSize(&x, &y);
923 int x_graph = x * 1 / 10;
924 int y_graph = y * 32 / 100;
925 int x_graph_w = x * 8 / 10;
927 (y * 65 / 100) - (m_button_height * 15 / 10) - (m_refTextHeight * 2);
931 m_graph_rect = wxRect(x_graph, y_graph, x_graph_w, y_graph_h);
936 if ((m_tsy * 15) > x)
939 m_tList->Move(wxPoint(x * 65 / 100, 11));
943 wxSize texc_size = wxSize((x * 60 / 100), (y * 29 / 100));
944 if (!m_tList->IsShown()) {
945 texc_size = wxSize((x * 90 / 100), (y * 29 / 100));
947 m_ptextctrl->SetSize(texc_size);
951 wxPoint(x - (4 * m_button_height + 10), y - (m_button_height * 12 / 10)));
954 wxPoint(x - (3 * m_button_height + 10), y - (m_button_height * 12 / 10)));
956 PR_button->Move(wxPoint(10, y - (m_button_height + 10)));
958 m_choiceTimezone->Move(
959 wxPoint(x / 2 - m_choiceSize_x / 2, y - (m_button_height * 12 / 10)));
961 int bsx, bsy, bpx, bpy;
962 PR_button->GetSize(&bsx, &bsy);
963 PR_button->GetPosition(&bpx, &bpy);
965 NX_button->Move(wxPoint(bpx + bsx + 5, y - (m_button_height + 10)));
973void TCWin::MouseEvent(wxMouseEvent &event) {
974 event.GetPosition(&curs_x, &curs_y);
976 if (!m_TCWinPopupTimer.IsRunning())
977 m_TCWinPopupTimer.Start(20, wxTIMER_ONE_SHOT);
980void TCWin::OnTCWinPopupTimerEvent(wxTimerEvent &event) {
984 GetClientSize(&x, &y);
985 wxRegion cursorarea(m_graph_rect);
986 if (cursorarea.Contains(curs_x, curs_y)) {
988 SetCursor(*pParent->pCursorCross);
989 if (NULL == m_pTCRolloverWin) {
990 m_pTCRolloverWin =
new RolloverWin(
this, -1,
false);
994 m_pTCRolloverWin->SetMousePropogation(1);
995 m_pTCRolloverWin->Hide();
1000 t = (25 / ((float)x * 8 / 10)) * ((
float)curs_x - ((float)x * 1 / 10));
1002 int tt = m_t_graphday_GMT + (int)(t * 3600);
1007 p.Printf(thd.Format(_T(
"%Hh %Mmn")));
1012 int tt_localtz = m_t_graphday_GMT + (m_diff_mins * 60);
1014 int ttv = tt_localtz + (int)(t * 3600);
1015 if (m_tzoneDisplay == 0) {
1016 ttv -= m_stationOffset_mins * 60;
1022 ptcmgr->GetTideOrCurrent(tts, pIDX->
IDX_rec_num, t, d);
1023 s.Printf(_T(
"%3.2f "), (t < 0 && CURRENT_PLOT == m_plot_type)
1030 if (pmsd) p.Append(wxString(pmsd->units_abbrv, wxConvUTF8));
1033 if (CURRENT_PLOT == m_plot_type) {
1034 s.Printf(
"%3.0f%c", d, 0x00B0);
1041 win_size.Set(x * 90 / 100, y * 80 / 100);
1043 m_pTCRolloverWin->SetString(p);
1044 m_pTCRolloverWin->SetBestPosition(curs_x, curs_y, 1, 1, TC_ROLLOVER,
1046 m_pTCRolloverWin->SetBitmap(TC_ROLLOVER);
1047 m_pTCRolloverWin->Refresh();
1048 m_pTCRolloverWin->Show();
1056 for (
int i = 0; i < 26; i++) {
1057 float ppx = m_graph_rect.x + ((i)*m_graph_rect.width / 25.f);
1064 wxPointList *list = (wxPointList *)&m_sList;
1065 wxPoint *a = list->Item(idx - 1)->GetData();
1066 wxPoint *b = list->Item(idx)->GetData();
1068 float pct = (curs_x - a->x) / (
float)((b->x - a->x));
1069 float dy = pct * (b->y - a->y);
1077 SetCursor(*pParent->pCursorArrow);
1078 ShowRollover =
false;
1081 if (m_pTCRolloverWin && m_pTCRolloverWin->IsShown() && !ShowRollover) {
1082 m_pTCRolloverWin->Hide();
ChartCanvas - Main chart display and interaction component.
bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) rounded to nearest integer.
wxFont * FindOrCreateFont(int point_size, wxFontFamily family, wxFontStyle style, wxFontWeight weight, bool underline=false, const wxString &facename=wxEmptyString, wxFontEncoding encoding=wxFONTENCODING_DEFAULT)
Creates or finds a matching font in the font cache.
wxFont * GetFont(const wxString &TextElement, int requested_font_size=0)
Gets a font object for a UI element.
Represents an index entry for tidal and current data.
char IDX_type
Entry type identifier "TCtcIUu".
int IDX_flood_dir
Flood current direction (in degrees)
char IDX_station_name[MAXNAMELEN]
Name of the tidal or current station.
int IDX_ebb_dir
Ebb current direction (in degrees)
double IDX_lat
Latitude of the station (in degrees, +North)
double IDX_lon
Longitude of the station (in degrees, +East)
Station_Data * pref_sta_data
Pointer to the reference station data.
int IDX_rec_num
Record number for multiple entries with same name.
wxFont * GetOCPNScaledFont(wxString item, int default_size)
Retrieves a font from FontMgr, optionally scaled for physical readability.
General purpose GUI support.