4 #include <wx/listctrl.h>
10 #include "tide_time.h"
13 #include "model/cutil.h"
15 #include "model/wx28compat.h"
16 #include "OCPNPlatform.h"
17 #include "RolloverWin.h"
20 #include "ocpn_frame.h"
22 extern ColorScheme global_color_scheme;
25 extern wxString g_locale;
32 enum { ID_TCWIN_NX, ID_TCWIN_PR };
34 enum { TIDE_PLOT, CURRENT_PLOT };
36 #include <wx/listimpl.cpp>
37 WX_DEFINE_LIST(SplineList);
39 BEGIN_EVENT_TABLE(
TCWin, wxWindow)
40 EVT_PAINT(TCWin::OnPaint)
41 EVT_SIZE(TCWin::OnSize)
42 EVT_MOTION(TCWin::MouseEvent)
43 EVT_BUTTON(wxID_OK, TCWin::OKEvent)
44 EVT_BUTTON(ID_TCWIN_NX, TCWin::NXEvent)
45 EVT_BUTTON(ID_TCWIN_PR, TCWin::PREvent)
46 EVT_CLOSE(TCWin::OnCloseWindow)
47 EVT_TIMER(TCWININF_TIMER, TCWin::OnTCWinPopupTimerEvent)
51 extern 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,
78 wxFont *qFont = GetOCPNScaledFont(_(
"Dialog"));
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_choiceSize_x = bsx * 2;
156 m_choiceTimezone->SetSelection(m_tzoneDisplay);
157 m_choiceTimezone->Connect(wxEVT_COMMAND_CHOICE_SELECTED,
158 wxCommandEventHandler(TCWin::TimezoneOnChoice),
161 m_TCWinPopupTimer.SetOwner(
this, TCWININF_TIMER);
166 dc.GetTextExtent(_T(
"W"), NULL, &text_height);
167 m_refTextHeight = text_height;
168 m_button_height = m_tsy;
172 wxFont *dlg_font = FontMgr::Get().GetFont(_(
"Dialog"));
173 int dlg_font_size = dlg_font->GetPointSize();
174 #if defined(__WXOSX__) || defined(__WXGTK3__)
176 dlg_font_size /= GetContentScaleFactor();
179 pSFont = FontMgr::Get().FindOrCreateFont(
180 dlg_font_size - 2, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL,
181 wxFONTWEIGHT_NORMAL, FALSE, wxString(_T (
"Arial" )));
182 pSMFont = FontMgr::Get().FindOrCreateFont(
183 dlg_font_size - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL,
184 wxFONTWEIGHT_NORMAL, FALSE, wxString(_T (
"Arial" )));
185 pMFont = FontMgr::Get().FindOrCreateFont(
186 dlg_font_size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD,
187 FALSE, wxString(_T (
"Arial" )));
188 pLFont = FontMgr::Get().FindOrCreateFont(
189 dlg_font_size + 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL,
190 wxFONTWEIGHT_BOLD, FALSE, wxString(_T (
"Arial" )));
193 pblack_1 = wxThePenList->FindOrCreatePen(
194 this->GetForegroundColour(), wxMax(1, (
int)(m_tcwin_scaler + 0.5)),
197 pblack_2 = wxThePenList->FindOrCreatePen(
198 this->GetForegroundColour(), wxMax(2, (
int)(2 * m_tcwin_scaler + 0.5)),
201 pblack_3 = wxThePenList->FindOrCreatePen(
202 wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW),
203 wxMax(1, (
int)(m_tcwin_scaler + 0.5)), wxPENSTYLE_SOLID);
205 pred_2 = wxThePenList->FindOrCreatePen(
206 wxColor(230, 54, 54), wxMax(4, (
int)(4 * m_tcwin_scaler + 0.5)),
209 pltgray = wxTheBrushList->FindOrCreateBrush(this->GetBackgroundColour(),
212 pltgray2 = wxTheBrushList->FindOrCreateBrush(this->GetBackgroundColour(),
214 pgraph = wxThePenList->FindOrCreatePen(
215 wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT),
216 wxMax(1, (
int)(m_tcwin_scaler + 0.5)), wxPENSTYLE_SOLID);
223 m_ptextctrl->Clear();
225 wxString locn(pIDX->IDX_station_name, wxConvUTF8);
226 wxString locna, locnb;
227 if (locn.Contains(wxString(_T (
"," )))) {
228 locna = locn.BeforeFirst(
',');
229 locnb = locn.AfterFirst(
',');
237 style.SetFont(*pLFont);
238 m_ptextctrl->SetDefaultStyle(style);
240 m_ptextctrl->AppendText(locna);
241 m_ptextctrl->AppendText(_T(
"\n"));
243 style.SetFont(*pSMFont);
244 m_ptextctrl->SetDefaultStyle(style);
246 if (!locnb.IsEmpty()) m_ptextctrl->AppendText(locnb);
247 m_ptextctrl->AppendText(_T(
"\n"));
250 if ((
't' == pIDX->IDX_type) || (
'c' == pIDX->IDX_type)) {
251 wxString mref(pIDX->IDX_reference_name, wxConvUTF8);
252 mref.Prepend(_T(
" "));
254 m_ptextctrl->AppendText(_(
"Reference Station :"));
255 m_ptextctrl->AppendText(_T(
"\n"));
257 m_ptextctrl->AppendText(mref);
258 m_ptextctrl->AppendText(_T(
"\n"));
261 m_ptextctrl->AppendText(_T(
"\n"));
265 wxString dsource(pIDX->source_ident, wxConvUTF8);
266 dsource.Prepend(_T(
" "));
268 m_ptextctrl->AppendText(_(
"Data Source :"));
269 m_ptextctrl->AppendText(_T(
"\n"));
271 m_ptextctrl->AppendText(dsource);
273 m_ptextctrl->ShowPosition(0);
276 TCWin::~TCWin() { pParent->Refresh(
false); }
278 void TCWin::SetTimeFactors() {
280 wxDateTime this_now = gTimeSource;
281 bool cur_time = !gTimeSource.IsValid();
284 this_now = wxDateTime::Now();
286 wxDateTime this_gmt = this_now.ToGMT();
288 #if wxCHECK_VERSION(2, 6, 2)
289 wxTimeSpan diff = this_now.Subtract(this_gmt);
291 wxTimeSpan diff = this_gmt.Subtract(this_now);
294 m_diff_mins = diff.GetMinutes();
299 #if wxCHECK_VERSION(3, 0, 2)
300 if (m_diff_mins == 0 && this_now.IsDST()) m_diff_mins += 60;
303 int station_offset = ptcmgr->GetStationTimeOffset(pIDX);
305 m_stationOffset_mins = station_offset;
306 if (this_now.IsDST()) m_stationOffset_mins += 60;
311 #if wxCHECK_VERSION(3, 0, 2)
318 m_graphday = this_gmt;
320 int day_gmt = this_gmt.GetDayOfYear();
322 time_t ttNow = this_now.GetTicks();
323 time_t tt_at_station =
324 ttNow - (m_diff_mins * 60) + (m_stationOffset_mins * 60);
325 wxDateTime atStation(tt_at_station);
326 int day_at_station = atStation.GetDayOfYear();
328 if (day_gmt > day_at_station) {
329 wxTimeSpan dt(24, 0, 0, 0);
330 m_graphday.Subtract(dt);
331 }
else if (day_gmt < day_at_station) {
332 wxTimeSpan dt(24, 0, 0, 0);
336 wxDateTime graphday_00 = m_graphday;
337 graphday_00.ResetTime();
338 time_t t_graphday_00 = graphday_00.GetTicks();
344 m_t_graphday_GMT = t_graphday_00;
349 void TCWin::TimezoneOnChoice(wxCommandEvent &event) {
350 m_tzoneDisplay = m_choiceTimezone->GetSelection();
356 void TCWin::RecalculateSize() {
357 wxSize parent_size(2000, 2000);
358 if (pParent) parent_size = pParent->GetClientSize();
360 int unscaledheight = 600;
361 int unscaledwidth = 650;
367 g_tcwin_scale = wxMax(g_tcwin_scale, 10);
368 m_tcwin_scaler = g_Platform->GetDisplayDPmm() * 0.254 * g_tcwin_scale / 100.0;
370 m_tc_size.x = (int)(unscaledwidth * m_tcwin_scaler + 0.5);
371 m_tc_size.y = (int)(unscaledheight * m_tcwin_scaler + 0.5);
373 m_tc_size.x = wxMin(m_tc_size.x, parent_size.x);
374 m_tc_size.y = wxMin(m_tc_size.y, parent_size.y);
381 if ((m_x + 8 + m_tc_size.x) > parent_size.x) xc = xc - m_tc_size.x - 16;
382 if ((m_y + m_tc_size.y) > parent_size.y) yc = yc - m_tc_size.y;
388 if (pParent) pParent->ClientToScreen(&xc, &yc);
389 m_position = wxPoint(xc, yc);
397 void TCWin::OKEvent(wxCommandEvent &event) {
399 pParent->pCwin = NULL;
401 delete m_pTCRolloverWin;
403 pParent->Refresh(
false);
407 pConfig->SetPath(_T (
"/Settings/Others" ));
408 pConfig->Write(_T (
"TCWindowTimeZone" ), m_tzoneDisplay);
414 void TCWin::OnCloseWindow(wxCloseEvent &event) {
416 pParent->pCwin = NULL;
418 delete m_pTCRolloverWin;
423 pConfig->SetPath(_T (
"/Settings/Others" ));
424 pConfig->Write(_T (
"TCWindowTimeZone" ), m_tzoneDisplay);
430 void TCWin::NXEvent(wxCommandEvent &event) {
431 wxTimeSpan dt(24, 0, 0, 0);
433 wxDateTime dm = m_graphday;
435 wxDateTime graphday_00 = dm.ResetTime();
436 time_t t_graphday_00 = graphday_00.GetTicks();
438 if (!graphday_00.IsDST() && m_graphday.IsDST()) t_graphday_00 -= 3600;
439 if (graphday_00.IsDST() && !m_graphday.IsDST()) t_graphday_00 += 3600;
441 m_t_graphday_GMT = t_graphday_00;
447 void TCWin::PREvent(wxCommandEvent &event) {
448 wxTimeSpan dt(-24, 0, 0, 0);
450 wxDateTime dm = m_graphday;
452 wxDateTime graphday_00 = dm.ResetTime();
453 time_t t_graphday_00 = graphday_00.GetTicks();
455 if (!graphday_00.IsDST() && m_graphday.IsDST()) t_graphday_00 -= 3600;
456 if (graphday_00.IsDST() && !m_graphday.IsDST()) t_graphday_00 += 3600;
458 m_t_graphday_GMT = t_graphday_00;
464 void TCWin::RePosition(
void) {
466 double lon = pIDX->IDX_lon;
467 double lat = pIDX->IDX_lat;
470 pParent->GetCanvasPointPix(lat, lon, &r);
471 pParent->ClientToScreen(&r.x, &r.y);
475 void TCWin::OnPaint(wxPaintEvent &event) {
485 if (m_graph_rect.x == 0)
return;
487 GetClientSize(&x, &y);
492 int x_graph = x * 1 / 10;
493 int y_graph = y * 32 / 100;
494 int x_graph_w = x * 8 / 10;
495 int y_graph_h = (y * .7) - (3 * m_button_height);
496 m_graph_rect = wxRect(x_graph, y_graph, x_graph_w, y_graph_h);
498 wxSize texc_size = wxSize( ( x * 60 / 100 ), ( y *29 / 100 ) );
499 if( !m_tList->IsShown()){
500 texc_size = wxSize( ( x * 90 / 100 ), ( y *29 / 100 ) );
503 m_ptextctrl->SetSize(texc_size);
508 wxString tlocn(pIDX->IDX_station_name, wxConvUTF8);
513 pblack_1->SetColour(this->GetForegroundColour());
514 pblack_2->SetColour(this->GetForegroundColour());
515 pltgray->SetColour(this->GetBackgroundColour());
516 pltgray2->SetColour(this->GetBackgroundColour());
517 pred_2->SetColour(GetDimedColor(wxColor(230, 54, 54)));
521 int x_textbox = x * 5 / 100;
524 int x_textbox_w = x * 51 / 100;
525 int y_textbox_h = y * 25 / 100;
528 dc.SetPen(*pblack_3);
529 dc.SetBrush(*pltgray2);
530 dc.DrawRoundedRectangle(x_textbox, y_textbox, x_textbox_w, y_textbox_h,
533 if (m_tList->IsShown()) {
534 wxRect tab_rect = m_tList->GetRect();
535 dc.DrawRoundedRectangle(tab_rect.x - 4, y_textbox, tab_rect.width + 8,
540 dc.SetPen(*pblack_1);
541 dc.SetBrush(*pltgray);
542 dc.DrawRectangle(m_graph_rect.x, m_graph_rect.y, m_graph_rect.width,
543 m_graph_rect.height);
548 const int hour_delta = 4;
550 const int hour_delta = 1;
560 for (i = 0; i < 25; i++) {
561 int xd = m_graph_rect.x + ((i)*m_graph_rect.width / 25);
562 if (hour_delta != 1) {
563 if (i % hour_delta == 0) {
564 dc.SetPen(*pblack_2);
565 dc.DrawLine(xd, m_graph_rect.y, xd,
566 m_graph_rect.y + m_graph_rect.height + 5);
568 int hour_show = hour_start + i;
569 if (hour_show >= 24) hour_show -= 24;
570 sprintf(sbuf,
"%02d", hour_show);
572 dc.DrawText(wxString(sbuf, wxConvUTF8),
573 xd + x_shim + (m_graph_rect.width / 25) / 2,
574 m_graph_rect.y + m_graph_rect.height + 8);
576 dc.SetPen(*pblack_1);
577 dc.DrawLine(xd, m_graph_rect.y, xd,
578 m_graph_rect.y + m_graph_rect.height + 5);
581 dc.SetPen(*pblack_1);
582 dc.DrawLine(xd, m_graph_rect.y, xd,
583 m_graph_rect.y + m_graph_rect.height + 5);
585 sst.Printf(_T(
"%02d"), i);
586 dc.DrawRotatedText(sst, xd + (m_graph_rect.width / 25) / 2,
587 m_graph_rect.y + m_graph_rect.height + 8, 270.);
592 wxDateTime this_now = gTimeSource;
593 bool cur_time = !gTimeSource.IsValid();
594 if (cur_time) this_now = wxDateTime::Now();
596 time_t t_now = this_now.GetTicks();
597 t_now -= m_diff_mins * 60;
598 if (m_tzoneDisplay == 0)
599 t_now += m_stationOffset_mins * 60;
602 m_graph_rect.width * (t_now - m_t_graphday_GMT) / (25 * 3600.0f);
606 int xnow = (t_ratio < 0 || t_ratio > m_graph_rect.width)
608 : m_graph_rect.x + (
int)t_ratio;
610 dc.DrawLine(xnow, m_graph_rect.y, xnow,
611 m_graph_rect.y + m_graph_rect.height);
612 dc.SetPen(*pblack_1);
621 m_tList->DeleteAllItems();
629 int tt_localtz = m_t_graphday_GMT + (m_diff_mins * 60);
632 ptcmgr->GetTideFlowSens(tt_localtz, BACKWARD_TEN_MINUTES_STEP,
633 pIDX->IDX_rec_num, tcv[0], val, wt);
635 if (m_tzoneDisplay == 0)
636 tt_localtz -= m_stationOffset_mins * 60;
638 for (i = 0; i < 26; i++) {
639 int tt = tt_localtz + (i * FORWARD_ONE_HOUR_STEP);
641 ptcmgr->GetTideOrCurrent(tt, pIDX->IDX_rec_num, tcv[i], dir);
643 if (tcv[i] > tcmax) tcmax = tcv[i];
645 if (tcv[i] < tcmin) tcmin = tcv[i];
646 if (TIDE_PLOT == m_plot_type) {
647 if (!((tcv[i] > val) == wt) && (i > 0))
651 ptcmgr->GetHightOrLowTide(tt, BACKWARD_TEN_MINUTES_STEP,
652 BACKWARD_ONE_MINUTES_STEP, tcv[i], wt,
653 pIDX->IDX_rec_num, tcvalue, tctime);
654 if (tctime > tt_localtz) {
658 tcd.Set(tctime - (m_diff_mins * 60));
659 if (m_tzoneDisplay == 0)
660 tcd.Set(tctime + (m_stationOffset_mins - m_diff_mins) * 60);
662 s.Printf(tcd.Format(_T(
"%H:%M ")));
663 s1.Printf(_T(
"%05.2f "), tcvalue);
666 if (pmsd) s.Append(wxString(pmsd->units_abbrv, wxConvUTF8));
668 (wt) ? s.Append(_(
"HW")) : s.Append(_(
"LW"));
671 li.SetId(list_index);
672 li.SetAlign(wxLIST_FORMAT_LEFT);
675 m_tList->InsertItem(li);
682 if (CURRENT_PLOT == m_plot_type) {
686 thx.Set((time_t)tt - (m_diff_mins * 60));
687 if (m_tzoneDisplay == 0)
688 thx.Set((time_t)tt + (m_stationOffset_mins - m_diff_mins) * 60);
690 s.Printf(thx.Format(_T(
"%H:%M ")));
691 s1.Printf(_T(
"%05.2f "), fabs(tcv[i]));
694 if (pmsd) s.Append(wxString(pmsd->units_abbrv, wxConvUTF8));
695 s1.Printf(_T(
" %03.0f"), dir);
699 li.SetId(list_index);
700 li.SetAlign(wxLIST_FORMAT_LEFT);
703 m_tList->InsertItem(li);
711 if (CURRENT_PLOT == m_plot_type) {
712 it = std::max(abs((
int)tcmin - 1), abs((
int)tcmax + 1));
716 m_plot_y_offset = m_graph_rect.height / 2;
720 if (tcmin < 0) ib -= 1;
724 m_plot_y_offset = (m_graph_rect.height * (it - ib)) / im;
731 dc.GetTextExtent(_T(
"1"), NULL, &height_stext);
732 float available_lines = (float)m_graph_rect.height / height_stext;
733 i_skip = (
int)ceil(im / available_lines);
735 if (CURRENT_PLOT == m_plot_type && i_skip != 1) {
744 m_sList.DeleteContents(
true);
747 for (i = 0; i < 26; i++) {
748 wxPoint *pp =
new wxPoint;
749 pp->x = m_graph_rect.x + ((i)*m_graph_rect.width / 25);
750 pp->y = m_graph_rect.y + (m_plot_y_offset) -
751 (
int)((tcv[i] - val_off) * m_graph_rect.height / im);
760 dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
766 int yd = m_graph_rect.y + (m_plot_y_offset) -
767 ((i - val_off) * m_graph_rect.height / im);
769 if ((m_plot_y_offset + m_graph_rect.y) == yd)
770 dc.SetPen(*pblack_2);
772 dc.SetPen(*pblack_1);
774 dc.DrawLine(m_graph_rect.x, yd, m_graph_rect.x + m_graph_rect.width, yd);
775 snprintf(sbuf, 99,
"%d", i);
776 dc.DrawText(wxString(sbuf, wxConvUTF8), m_graph_rect.x - 20, yd - 5);
781 #if wxCHECK_VERSION(2, 9, 0)
782 wxPointList *list = (wxPointList *)&m_sList;
784 wxList *list = (wxList *)&m_sList;
795 if (m_tzoneDisplay == 0) {
796 int station_offset = ptcmgr->GetStationTimeOffset(pIDX);
797 int h = station_offset / 60;
798 int m = station_offset - (h * 60);
799 if (m_graphday.IsDST()) h += 1;
800 m_stz.Printf(_T(
"UTC %+03d:%02d"), h, m);
804 double lat = ptcmgr->GetStationLat(pIDX);
808 switch (ptcmgr->GetStationTimeOffset(pIDX)) {
821 if (m_graphday.IsDST()) mtz[1] =
'D';
832 dc.GetTextExtent(m_stz, &w, &h);
833 dc.DrawText(m_stz, x / 2 - w / 2,
834 y - (m_button_height * 15 / 10) - (m_refTextHeight * 2));
837 if (g_locale == _T(
"en_US"))
838 sdate = m_graphday.Format(_T (
"%A %b %d, %Y" ));
840 sdate = m_graphday.Format(_T (
"%A %d %b %Y" ));
843 dc.GetTextExtent(sdate, &w, &h);
844 dc.DrawText(sdate, x / 2 - w / 2,
845 y - (m_button_height * 15 / 10) - (m_refTextHeight * 1));
849 dc.GetTextExtent(wxString(pmsd->units_conv, wxConvUTF8), &w, &h);
850 dc.DrawRotatedText(wxString(pmsd->units_conv, wxConvUTF8), 5,
851 m_graph_rect.y + m_graph_rect.height / 2 + w / 2, 90.);
855 if ((strchr(
"c", pIDX->IDX_type)) || (strchr(
"C", pIDX->IDX_type))) {
859 fdir.Printf(_T(
"%03d"), pIDX->IDX_flood_dir);
860 dc.DrawText(fdir, m_graph_rect.x + m_graph_rect.width + 4,
861 m_graph_rect.y + m_graph_rect.height * 1 / 4);
864 edir.Printf(_T(
"%03d"), pIDX->IDX_ebb_dir);
865 dc.DrawText(edir, m_graph_rect.x + m_graph_rect.width + 4,
866 m_graph_rect.y + m_graph_rect.height * 3 / 4);
870 if ((m_button_height * 15) < x && cur_time) {
873 int day = m_graphday.GetDayOfYear();
874 if (m_graphday.GetYear() == this_now.GetYear()) {
875 if (day == this_now.GetDayOfYear())
876 sday.Append(_(
"Today"));
877 else if (day == this_now.GetDayOfYear() + 1)
878 sday.Append(_(
"Tomorrow"));
880 sday.Append(m_graphday.GetWeekDayName(m_graphday.GetWeekDay()));
881 }
else if (m_graphday.GetYear() == this_now.GetYear() + 1 &&
882 day == this_now.Add(wxTimeSpan::Day()).GetDayOfYear())
883 sday.Append(_(
"Tomorrow"));
886 dc.GetTextExtent(sday, &w, &h);
887 dc.DrawText(sday, 55 - w / 2,
888 y - (m_button_height * 15 / 10) - (m_refTextHeight * 1));
892 double spotDim = 4 * g_Platform->GetDisplayDPmm();
894 dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(
895 GetGlobalColor(_T (
"YELO1" )), wxBRUSHSTYLE_SOLID));
896 dc.SetPen(wxPen(GetGlobalColor(_T (
"URED" )),
897 wxMax(2, 0.5 * g_Platform->GetDisplayDPmm())));
898 dc.DrawRoundedRectangle(xSpot - spotDim / 2, ySpot - spotDim / 2, spotDim,
899 spotDim, spotDim / 2);
901 dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(
902 GetGlobalColor(_T (
"UBLCK" )), wxBRUSHSTYLE_SOLID));
903 dc.SetPen(wxPen(GetGlobalColor(_T (
"UBLCK" )), 1));
905 double ispotDim = spotDim / 5.;
906 dc.DrawRoundedRectangle(xSpot - ispotDim / 2, ySpot - ispotDim / 2,
907 ispotDim, ispotDim, ispotDim / 2);
911 void TCWin::OnSize(wxSizeEvent &event) {
912 if (!m_created)
return;
915 GetClientSize(&x, &y);
918 int x_graph = x * 1 / 10;
919 int y_graph = y * 32 / 100;
920 int x_graph_w = x * 8 / 10;
922 (y * 65 / 100) - (m_button_height * 15 / 10) - (m_refTextHeight * 2);
926 m_graph_rect = wxRect(x_graph, y_graph, x_graph_w, y_graph_h);
931 if ((m_tsy * 15) > x)
934 m_tList->Move(wxPoint(x * 65 / 100, 11));
938 wxSize texc_size = wxSize((x * 60 / 100), (y * 29 / 100));
939 if (!m_tList->IsShown()) {
940 texc_size = wxSize((x * 90 / 100), (y * 29 / 100));
942 m_ptextctrl->SetSize(texc_size);
946 wxPoint(x - (4 * m_button_height + 10), y - (m_button_height * 12 / 10)));
949 wxPoint(x - (3 * m_button_height + 10), y - (m_button_height * 12 / 10)));
951 PR_button->Move(wxPoint(10, y - (m_button_height + 10)));
953 m_choiceTimezone->Move(
954 wxPoint(x / 2 - m_choiceSize_x / 2, y - (m_button_height * 12 / 10)));
956 int bsx, bsy, bpx, bpy;
957 PR_button->GetSize(&bsx, &bsy);
958 PR_button->GetPosition(&bpx, &bpy);
960 NX_button->Move(wxPoint(bpx + bsx + 5, y - (m_button_height + 10)));
968 void TCWin::MouseEvent(wxMouseEvent &event) {
969 event.GetPosition(&curs_x, &curs_y);
971 if (!m_TCWinPopupTimer.IsRunning())
972 m_TCWinPopupTimer.Start(20, wxTIMER_ONE_SHOT);
975 void TCWin::OnTCWinPopupTimerEvent(wxTimerEvent &event) {
979 GetClientSize(&x, &y);
980 wxRegion cursorarea(m_graph_rect);
981 if (cursorarea.Contains(curs_x, curs_y)) {
983 SetCursor(*pParent->pCursorCross);
984 if (NULL == m_pTCRolloverWin) {
985 m_pTCRolloverWin =
new RolloverWin(
this, -1,
false);
989 m_pTCRolloverWin->SetMousePropogation(1);
990 m_pTCRolloverWin->Hide();
995 t = (25 / ((float)x * 8 / 10)) * ((
float)curs_x - ((float)x * 1 / 10));
997 int tt = m_t_graphday_GMT + (int)(t * 3600);
1002 p.Printf(thd.Format(_T(
"%Hh %Mmn")));
1007 int tt_localtz = m_t_graphday_GMT + (m_diff_mins * 60);
1009 int ttv = tt_localtz + (int)(t * 3600);
1010 if (m_tzoneDisplay == 0) {
1011 ttv -= m_stationOffset_mins * 60;
1017 ptcmgr->GetTideOrCurrent(tts, pIDX->IDX_rec_num, t, d);
1018 s.Printf(_T(
"%3.2f "), (t < 0 && CURRENT_PLOT == m_plot_type)
1025 if (pmsd) p.Append(wxString(pmsd->units_abbrv, wxConvUTF8));
1028 if (CURRENT_PLOT == m_plot_type) {
1029 s.Printf(
"%3.0f%c", d, 0x00B0);
1036 win_size.Set(x * 90 / 100, y * 80 / 100);
1038 m_pTCRolloverWin->SetString(p);
1039 m_pTCRolloverWin->SetBestPosition(curs_x, curs_y, 1, 1, TC_ROLLOVER,
1041 m_pTCRolloverWin->SetBitmap(TC_ROLLOVER);
1042 m_pTCRolloverWin->Refresh();
1043 m_pTCRolloverWin->Show();
1051 for (
int i = 0; i < 26; i++) {
1052 float ppx = m_graph_rect.x + ((i)*m_graph_rect.width / 25.f);
1059 wxPointList *list = (wxPointList *)&m_sList;
1060 wxPoint *a = list->Item(idx - 1)->GetData();
1061 wxPoint *b = list->Item(idx)->GetData();
1063 float pct = (curs_x - a->x) / (
float)((b->x - a->x));
1064 float dy = pct * (b->y - a->y);
1072 SetCursor(*pParent->pCursorArrow);
1073 ShowRollover =
false;
1076 if (m_pTCRolloverWin && m_pTCRolloverWin->IsShown() && !ShowRollover) {
1077 m_pTCRolloverWin->Hide();
General purpose GUI support.