4#include <wx/listctrl.h>
15#include "wx28compat.h"
16#include "OCPNPlatform.h"
17#include "RolloverWin.h"
20#include "ocpn_frame.h"
22extern ColorScheme global_color_scheme;
26extern 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) EVT_SIZE(TCWin::OnSize) EVT_MOTION(TCWin::MouseEvent)
41 EVT_BUTTON(wxID_OK, TCWin::OKEvent) EVT_BUTTON(ID_TCWIN_NX, TCWin::NXEvent)
42 EVT_BUTTON(ID_TCWIN_PR, TCWin::PREvent) EVT_CLOSE(TCWin::OnCloseWindow)
43 EVT_TIMER(TCWININF_TIMER, TCWin::OnTCWinPopupTimerEvent)
47 extern wxDateTime gTimeSource;
59 m_pTCRolloverWin = NULL;
61 long wstyle = wxCLIP_CHILDREN | wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER |
62 wxFRAME_FLOAT_ON_PARENT;
63 if ((global_color_scheme != GLOBAL_COLOR_SCHEME_DAY) &&
64 (global_color_scheme != GLOBAL_COLOR_SCHEME_RGB))
65 wstyle |= (wxNO_BORDER);
75 pConfig->SetPath(_T (
"/Settings/Others" ));
76 pConfig->Read(_T (
"TCWindowTimeZone" ), &m_tzoneDisplay, 0);
79 wxFrame::Create(parent, wxID_ANY, wxString(_T (
"" )), m_position, m_tc_size,
83 wxFont *qFont = GetOCPNScaledFont(_(
"Dialog"));
90 if (strchr(
"Tt", pIDX->IDX_type)) {
91 m_plot_type = TIDE_PLOT;
92 SetTitle(wxString(_(
"Tide")));
96 m_plot_type = CURRENT_PLOT;
97 SetTitle(wxString(_(
"Current")));
101 GetClientSize(&sx, &sy);
107 wxString *TClist = NULL;
108 m_tList =
new wxListCtrl(
this, -1, wxPoint(sx * 65 / 100, 11),
109 wxSize((sx * 32 / 100), (sy * 20 / 100)),
110 wxLC_REPORT | wxLC_NO_HEADER);
115 col0.SetText(_T(
""));
116 col0.SetAlign(wxLIST_FORMAT_LEFT);
117 col0.SetWidth(sx * 30 / 100);
118 m_tList->InsertColumn(0, col0);
121 wxButton *test_button =
122 new wxButton(
this, wxID_OK, _(
"OK"), wxPoint(-1, -1), wxDefaultSize);
123 test_button->GetSize(&m_tsx, &m_tsy);
129 if ((m_tsy * 15) > sx) m_tList->Hide();
131 OK_button =
new wxButton(
this, wxID_OK, _(
"OK"),
132 wxPoint(sx - (2 * m_tsy + 10), sy - (m_tsy + 10)),
135 PR_button =
new wxButton(
this, ID_TCWIN_PR, _(
"Prev"),
136 wxPoint(10, sy - (m_tsy + 10)), wxSize(-1, -1));
138 wxSize texc_size = wxSize((sx * 60 / 100), (sy * 29 / 100));
139 if (!m_tList->IsShown()) {
140 texc_size = wxSize((sx * 90 / 100), (sy * 29 / 100));
144 new wxTextCtrl(
this, -1, _T(
""), wxPoint(sx * 3 / 100, 6), texc_size,
145 wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
146 int bsx, bsy, bpx, bpy;
147 PR_button->GetSize(&bsx, &bsy);
148 PR_button->GetPosition(&bpx, &bpy);
151 new wxButton(
this, ID_TCWIN_NX, _(
"Next"),
152 wxPoint(bpx + bsx + 5, sy - (m_tsy + 10)), wxSize(-1, -1));
154 wxString m_choiceTimezoneChoices[] = {_(
"LMT@Station"), _(
"UTC")};
155 int m_choiceTimezoneNChoices =
156 sizeof(m_choiceTimezoneChoices) /
sizeof(wxString);
157 m_choiceTimezone =
new wxChoice(
158 this, wxID_ANY, wxPoint((sx - (bsx * 2)) / 2, sy - (m_tsy + 10)),
159 wxSize(2 * bsx, bsy), m_choiceTimezoneNChoices, m_choiceTimezoneChoices,
162 m_choiceTimezone->SetSelection(m_tzoneDisplay);
163 m_choiceTimezone->Connect(wxEVT_COMMAND_CHOICE_SELECTED,
164 wxCommandEventHandler(TCWin::TimezoneOnChoice),
167 m_TCWinPopupTimer.SetOwner(
this, TCWININF_TIMER);
171 dc.GetTextExtent(_T(
"W"), NULL, &text_height);
172 m_button_height = m_tsy;
176 wxFont *dlg_font = FontMgr::Get().GetFont(_(
"Dialog"));
177 int dlg_font_size = dlg_font->GetPointSize();
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" )));
192 pblack_1 = wxThePenList->FindOrCreatePen(
193 GetGlobalColor(_T (
"UINFD" )), wxMax(1, (
int)(m_tcwin_scaler + 0.5)),
195 pblack_2 = wxThePenList->FindOrCreatePen(
196 GetGlobalColor(_T (
"UINFD" )), wxMax(2, (
int)(2 * m_tcwin_scaler + 0.5)),
198 pblack_3 = wxThePenList->FindOrCreatePen(
199 GetGlobalColor(_T (
"UWHIT" )), wxMax(1, (
int)(m_tcwin_scaler + 0.5)),
201 pred_2 = wxThePenList->FindOrCreatePen(
202 GetGlobalColor(_T (
"UINFR" )), wxMax(4, (
int)(4 * m_tcwin_scaler + 0.5)),
204 pltgray = wxTheBrushList->FindOrCreateBrush(GetGlobalColor(_T (
"UIBCK" )),
206 pltgray2 = wxTheBrushList->FindOrCreateBrush(GetGlobalColor(_T (
"DILG1" )),
214 m_ptextctrl->Clear();
216 wxString locn(pIDX->IDX_station_name, wxConvUTF8);
217 wxString locna, locnb;
218 if (locn.Contains(wxString(_T (
"," )))) {
219 locna = locn.BeforeFirst(
',');
220 locnb = locn.AfterFirst(
',');
228 style.SetFont(*pLFont);
229 m_ptextctrl->SetDefaultStyle(style);
231 m_ptextctrl->AppendText(locna);
232 m_ptextctrl->AppendText(_T(
"\n"));
234 style.SetFont(*pSMFont);
235 m_ptextctrl->SetDefaultStyle(style);
237 if (!locnb.IsEmpty()) m_ptextctrl->AppendText(locnb);
238 m_ptextctrl->AppendText(_T(
"\n"));
241 if ((
't' == pIDX->IDX_type) || (
'c' == pIDX->IDX_type)) {
242 wxString mref(pIDX->IDX_reference_name, wxConvUTF8);
243 mref.Prepend(_T(
" "));
245 m_ptextctrl->AppendText(_(
"Reference Station :"));
246 m_ptextctrl->AppendText(_T(
"\n"));
248 m_ptextctrl->AppendText(mref);
249 m_ptextctrl->AppendText(_T(
"\n"));
252 m_ptextctrl->AppendText(_T(
"\n"));
256 wxString dsource(pIDX->source_ident, wxConvUTF8);
257 dsource.Prepend(_T(
" "));
259 m_ptextctrl->AppendText(_(
"Data Source :"));
260 m_ptextctrl->AppendText(_T(
"\n"));
262 m_ptextctrl->AppendText(dsource);
264 m_ptextctrl->ShowPosition(0);
267TCWin::~TCWin() { pParent->Refresh(
false); }
269void TCWin::SetTimeFactors() {
271 wxDateTime this_now = gTimeSource;
272 bool cur_time = !gTimeSource.IsValid();
275 this_now = wxDateTime::Now();
277 wxDateTime this_gmt = this_now.ToGMT();
279#if wxCHECK_VERSION(2, 6, 2)
280 wxTimeSpan diff = this_now.Subtract(this_gmt);
282 wxTimeSpan diff = this_gmt.Subtract(this_now);
285 m_diff_mins = diff.GetMinutes();
290#if wxCHECK_VERSION(3, 0, 2)
291 if (m_diff_mins == 0 && this_now.IsDST()) m_diff_mins += 60;
294 int station_offset = ptcmgr->GetStationTimeOffset(pIDX);
296 m_stationOffset_mins = station_offset;
297 if (this_now.IsDST()) m_stationOffset_mins += 60;
302#if wxCHECK_VERSION(3, 0, 2)
309 m_graphday = this_gmt;
311 int day_gmt = this_gmt.GetDayOfYear();
313 time_t ttNow = this_now.GetTicks();
314 time_t tt_at_station =
315 ttNow - (m_diff_mins * 60) + (m_stationOffset_mins * 60);
316 wxDateTime atStation(tt_at_station);
317 int day_at_station = atStation.GetDayOfYear();
319 if (day_gmt > day_at_station) {
320 wxTimeSpan dt(24, 0, 0, 0);
321 m_graphday.Subtract(dt);
322 }
else if (day_gmt < day_at_station) {
323 wxTimeSpan dt(24, 0, 0, 0);
327 wxDateTime graphday_00 = m_graphday;
328 graphday_00.ResetTime();
329 time_t t_graphday_00 = graphday_00.GetTicks();
335 m_t_graphday_GMT = t_graphday_00;
340void TCWin::TimezoneOnChoice(wxCommandEvent &event) {
341 m_tzoneDisplay = m_choiceTimezone->GetSelection();
347void TCWin::RecalculateSize() {
348 wxSize parent_size(2000, 2000);
349 if (pParent) parent_size = pParent->GetClientSize();
351 int unscaledheight = 600;
352 int unscaledwidth = 650;
358 g_tcwin_scale = wxMax(g_tcwin_scale, 10);
359 m_tcwin_scaler = g_Platform->GetDisplayDPmm() * 0.254 * g_tcwin_scale / 100.0;
361 m_tc_size.x = (int)(unscaledwidth * m_tcwin_scaler + 0.5);
362 m_tc_size.y = (int)(unscaledheight * m_tcwin_scaler + 0.5);
364 m_tc_size.x = wxMin(m_tc_size.x, parent_size.x);
365 m_tc_size.y = wxMin(m_tc_size.y, parent_size.y);
372 if ((m_x + 8 + m_tc_size.x) > parent_size.x) xc = xc - m_tc_size.x - 16;
373 if ((m_y + m_tc_size.y) > parent_size.y) yc = yc - m_tc_size.y;
379 if (pParent) pParent->ClientToScreen(&xc, &yc);
380 m_position = wxPoint(xc, yc);
388void TCWin::OKEvent(wxCommandEvent &event) {
390 pParent->pCwin = NULL;
391 if (--gpIDXn == 0) gpIDX = NULL;
392 delete m_pTCRolloverWin;
394 pParent->Refresh(
false);
398 pConfig->SetPath(_T (
"/Settings/Others" ));
399 pConfig->Write(_T (
"TCWindowTimeZone" ), m_tzoneDisplay);
405void TCWin::OnCloseWindow(wxCloseEvent &event) {
407 pParent->pCwin = NULL;
408 if (--gpIDXn == 0) gpIDX = NULL;
409 delete m_pTCRolloverWin;
414 pConfig->SetPath(_T (
"/Settings/Others" ));
415 pConfig->Write(_T (
"TCWindowTimeZone" ), m_tzoneDisplay);
421void TCWin::NXEvent(wxCommandEvent &event) {
422 wxTimeSpan dt(24, 0, 0, 0);
424 wxDateTime dm = m_graphday;
426 wxDateTime graphday_00 = dm.ResetTime();
427 time_t t_graphday_00 = graphday_00.GetTicks();
429 if (!graphday_00.IsDST() && m_graphday.IsDST()) t_graphday_00 -= 3600;
430 if (graphday_00.IsDST() && !m_graphday.IsDST()) t_graphday_00 += 3600;
432 m_t_graphday_GMT = t_graphday_00;
438void TCWin::PREvent(wxCommandEvent &event) {
439 wxTimeSpan dt(-24, 0, 0, 0);
441 wxDateTime dm = m_graphday;
443 wxDateTime graphday_00 = dm.ResetTime();
444 time_t t_graphday_00 = graphday_00.GetTicks();
446 if (!graphday_00.IsDST() && m_graphday.IsDST()) t_graphday_00 -= 3600;
447 if (graphday_00.IsDST() && !m_graphday.IsDST()) t_graphday_00 += 3600;
449 m_t_graphday_GMT = t_graphday_00;
455void TCWin::RePosition(
void) {
457 double lon = pIDX->IDX_lon;
458 double lat = pIDX->IDX_lat;
461 pParent->GetCanvasPointPix(lat, lon, &r);
462 pParent->ClientToScreen(&r.x, &r.y);
466void TCWin::OnPaint(wxPaintEvent &event) {
476 if (m_graph_rect.x == 0)
return;
478 GetClientSize(&x, &y);
483 int x_graph = x * 1 / 10;
484 int y_graph = y * 32 / 100;
485 int x_graph_w = x * 8 / 10;
486 int y_graph_h = (y * .7) - (3 * m_button_height);
487 m_graph_rect = wxRect(x_graph, y_graph, x_graph_w, y_graph_h);
489 wxSize texc_size = wxSize( ( x * 60 / 100 ), ( y *29 / 100 ) );
490 if( !m_tList->IsShown()){
491 texc_size = wxSize( ( x * 90 / 100 ), ( y *29 / 100 ) );
494 m_ptextctrl->SetSize(texc_size);
499 wxString tlocn(pIDX->IDX_station_name, wxConvUTF8);
503 int x_textbox = x * 5 / 100;
506 int x_textbox_w = x * 51 / 100;
507 int y_textbox_h = y * 25 / 100;
510 dc.SetPen(*pblack_3);
511 dc.SetBrush(*pltgray2);
512 dc.DrawRoundedRectangle(x_textbox, y_textbox, x_textbox_w, y_textbox_h,
515 if (m_tList->IsShown()) {
516 wxRect tab_rect = m_tList->GetRect();
517 dc.DrawRoundedRectangle(tab_rect.x - 4, y_textbox, tab_rect.width + 8,
522 dc.SetPen(*pblack_1);
523 dc.SetBrush(*pltgray);
524 dc.DrawRectangle(m_graph_rect.x, m_graph_rect.y, m_graph_rect.width,
525 m_graph_rect.height);
530 const int hour_delta = 4;
532 const int hour_delta = 1;
542 for (i = 0; i < 25; i++) {
543 int xd = m_graph_rect.x + ((i)*m_graph_rect.width / 25);
544 if (hour_delta != 1) {
545 if (i % hour_delta == 0) {
546 dc.SetPen(*pblack_2);
547 dc.DrawLine(xd, m_graph_rect.y, xd,
548 m_graph_rect.y + m_graph_rect.height + 5);
550 int hour_show = hour_start + i;
551 if (hour_show >= 24) hour_show -= 24;
552 sprintf(sbuf,
"%02d", hour_show);
554 dc.DrawText(wxString(sbuf, wxConvUTF8),
555 xd + x_shim + (m_graph_rect.width / 25) / 2,
556 m_graph_rect.y + m_graph_rect.height + 8);
558 dc.SetPen(*pblack_1);
559 dc.DrawLine(xd, m_graph_rect.y, xd,
560 m_graph_rect.y + m_graph_rect.height + 5);
563 dc.SetPen(*pblack_1);
564 dc.DrawLine(xd, m_graph_rect.y, xd,
565 m_graph_rect.y + m_graph_rect.height + 5);
567 sst.Printf(_T(
"%02d"), i);
568 dc.DrawRotatedText(sst, xd + (m_graph_rect.width / 25) / 2,
569 m_graph_rect.y + m_graph_rect.height + 8, 270.);
574 wxDateTime this_now = gTimeSource;
575 bool cur_time = !gTimeSource.IsValid();
576 if (cur_time) this_now = wxDateTime::Now();
578 time_t t_now = this_now.GetTicks();
579 t_now -= m_diff_mins * 60;
580 if (m_tzoneDisplay == 0)
581 t_now += m_stationOffset_mins * 60;
584 m_graph_rect.width * (t_now - m_t_graphday_GMT) / (25 * 3600.0f);
588 int xnow = (t_ratio < 0 || t_ratio > m_graph_rect.width)
590 : m_graph_rect.x + (
int)t_ratio;
592 dc.DrawLine(xnow, m_graph_rect.y, xnow,
593 m_graph_rect.y + m_graph_rect.height);
594 dc.SetPen(*pblack_1);
603 m_tList->DeleteAllItems();
611 int tt_localtz = m_t_graphday_GMT + (m_diff_mins * 60);
614 ptcmgr->GetTideFlowSens(tt_localtz, BACKWARD_TEN_MINUTES_STEP,
615 pIDX->IDX_rec_num, tcv[0], val, wt);
617 if (m_tzoneDisplay == 0)
618 tt_localtz -= m_stationOffset_mins * 60;
620 for (i = 0; i < 26; i++) {
621 int tt = tt_localtz + (i * FORWARD_ONE_HOUR_STEP);
623 ptcmgr->GetTideOrCurrent(tt, pIDX->IDX_rec_num, tcv[i], dir);
625 if (tcv[i] > tcmax) tcmax = tcv[i];
627 if (tcv[i] < tcmin) tcmin = tcv[i];
628 if (TIDE_PLOT == m_plot_type) {
629 if (!((tcv[i] > val) == wt) && (i > 0))
633 ptcmgr->GetHightOrLowTide(tt, BACKWARD_TEN_MINUTES_STEP,
634 BACKWARD_ONE_MINUTES_STEP, tcv[i], wt,
635 pIDX->IDX_rec_num, tcvalue, tctime);
636 if (tctime > tt_localtz) {
640 tcd.Set(tctime - (m_diff_mins * 60));
641 if (m_tzoneDisplay == 0)
642 tcd.Set(tctime + (m_stationOffset_mins - m_diff_mins) * 60);
644 s.Printf(tcd.Format(_T(
"%H:%M ")));
645 s1.Printf(_T(
"%05.2f "), tcvalue);
648 if (pmsd) s.Append(wxString(pmsd->units_abbrv, wxConvUTF8));
650 (wt) ? s.Append(_(
"HW")) : s.Append(_(
"LW"));
653 li.SetId(list_index);
654 li.SetAlign(wxLIST_FORMAT_LEFT);
657 m_tList->InsertItem(li);
664 if (CURRENT_PLOT == m_plot_type) {
668 thx.Set((time_t)tt - (m_diff_mins * 60));
669 if (m_tzoneDisplay == 0)
670 thx.Set((time_t)tt + (m_stationOffset_mins - m_diff_mins) * 60);
672 s.Printf(thx.Format(_T(
"%H:%M ")));
673 s1.Printf(_T(
"%05.2f "), fabs(tcv[i]));
676 if (pmsd) s.Append(wxString(pmsd->units_abbrv, wxConvUTF8));
677 s1.Printf(_T(
" %03.0f"), dir);
681 li.SetId(list_index);
682 li.SetAlign(wxLIST_FORMAT_LEFT);
685 m_tList->InsertItem(li);
693 if (CURRENT_PLOT == m_plot_type) {
694 it = std::max(abs((
int)tcmin - 1), abs((
int)tcmax + 1));
698 m_plot_y_offset = m_graph_rect.height / 2;
702 if (tcmin < 0) ib -= 1;
706 m_plot_y_offset = (m_graph_rect.height * (it - ib)) / im;
713 dc.GetTextExtent(_T(
"1"), NULL, &height_stext);
714 float available_lines = (float)m_graph_rect.height / height_stext;
715 i_skip = (
int)ceil(im / available_lines);
717 if (CURRENT_PLOT == m_plot_type && i_skip != 1) {
726 m_sList.DeleteContents(
true);
729 for (i = 0; i < 26; i++) {
730 wxPoint *pp =
new wxPoint;
731 pp->x = m_graph_rect.x + ((i)*m_graph_rect.width / 25);
732 pp->y = m_graph_rect.y + (m_plot_y_offset) -
733 (
int)((tcv[i] - val_off) * m_graph_rect.height / im);
741 dc.SetTextForeground(GetGlobalColor(_T (
"DILG3" )));
747 int yd = m_graph_rect.y + (m_plot_y_offset) -
748 ((i - val_off) * m_graph_rect.height / im);
750 if ((m_plot_y_offset + m_graph_rect.y) == yd)
751 dc.SetPen(*pblack_2);
753 dc.SetPen(*pblack_1);
755 dc.DrawLine(m_graph_rect.x, yd, m_graph_rect.x + m_graph_rect.width, yd);
756 snprintf(sbuf, 99,
"%d", i);
757 dc.DrawText(wxString(sbuf, wxConvUTF8), m_graph_rect.x - 20, yd - 5);
762#if wxCHECK_VERSION(2, 9, 0)
763 wxPointList *list = (wxPointList *)&m_sList;
765 wxList *list = (wxList *)&m_sList;
768 dc.SetPen(*pblack_2);
776 if (m_tzoneDisplay == 0) {
777 int station_offset = ptcmgr->GetStationTimeOffset(pIDX);
778 int h = station_offset / 60;
779 int m = station_offset - (h * 60);
780 if (m_graphday.IsDST()) h += 1;
781 m_stz.Printf(_T(
"UTC %+03d:%02d"), h, m);
785 double lat = ptcmgr->GetStationLat(pIDX);
789 switch (ptcmgr->GetStationTimeOffset(pIDX)) {
802 if (m_graphday.IsDST()) mtz[1] =
'D';
813 dc.GetTextExtent(m_stz, &w, &h);
814 dc.DrawText(m_stz, x / 2 - w / 2, y - 2.5 * m_button_height);
817 if (g_locale == _T(
"en_US"))
818 sdate = m_graphday.Format(_T (
"%A %b %d, %Y" ));
820 sdate = m_graphday.Format(_T (
"%A %d %b %Y" ));
823 dc.GetTextExtent(sdate, &w, &h);
824 dc.DrawText(sdate, x / 2 - w / 2, y - 2.0 * m_button_height);
828 dc.GetTextExtent(wxString(pmsd->units_conv, wxConvUTF8), &w, &h);
829 dc.DrawRotatedText(wxString(pmsd->units_conv, wxConvUTF8), 5,
830 m_graph_rect.y + m_graph_rect.height / 2 + w / 2, 90.);
834 if ((strchr(
"c", pIDX->IDX_type)) || (strchr(
"C", pIDX->IDX_type))) {
838 fdir.Printf(_T(
"%03d"), pIDX->IDX_flood_dir);
839 dc.DrawText(fdir, m_graph_rect.x + m_graph_rect.width + 4,
840 m_graph_rect.y + m_graph_rect.height * 1 / 4);
843 edir.Printf(_T(
"%03d"), pIDX->IDX_ebb_dir);
844 dc.DrawText(edir, m_graph_rect.x + m_graph_rect.width + 4,
845 m_graph_rect.y + m_graph_rect.height * 3 / 4);
849 if ((m_button_height * 15) < x && cur_time) {
852 int day = m_graphday.GetDayOfYear();
853 if (m_graphday.GetYear() == this_now.GetYear()) {
854 if (day == this_now.GetDayOfYear())
855 sday.Append(_(
"Today"));
856 else if (day == this_now.GetDayOfYear() + 1)
857 sday.Append(_(
"Tomorrow"));
859 sday.Append(m_graphday.GetWeekDayName(m_graphday.GetWeekDay()));
860 }
else if (m_graphday.GetYear() == this_now.GetYear() + 1 &&
861 day == this_now.Add(wxTimeSpan::Day()).GetDayOfYear())
862 sday.Append(_(
"Tomorrow"));
865 dc.GetTextExtent(sday, &w, &h);
866 dc.DrawText(sday, 55 - w / 2, y - 2 * m_button_height);
870 double spotDim = 4 * g_Platform->GetDisplayDPmm();
872 dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(
873 GetGlobalColor(_T (
"YELO1" )), wxBRUSHSTYLE_SOLID));
874 dc.SetPen(wxPen(GetGlobalColor(_T (
"URED" )),
875 wxMax(2, 0.5 * g_Platform->GetDisplayDPmm())));
876 dc.DrawRoundedRectangle(xSpot - spotDim / 2, ySpot - spotDim / 2, spotDim,
877 spotDim, spotDim / 2);
879 dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(
880 GetGlobalColor(_T (
"UBLCK" )), wxBRUSHSTYLE_SOLID));
881 dc.SetPen(wxPen(GetGlobalColor(_T (
"UBLCK" )), 1));
883 double ispotDim = spotDim / 5.;
884 dc.DrawRoundedRectangle(xSpot - ispotDim / 2, ySpot - ispotDim / 2,
885 ispotDim, ispotDim, ispotDim / 2);
889void TCWin::OnSize(wxSizeEvent &event) {
890 if (!m_created)
return;
893 GetClientSize(&x, &y);
896 int x_graph = x * 1 / 10;
897 int y_graph = y * 32 / 100;
898 int x_graph_w = x * 8 / 10;
899 int y_graph_h = (y * .7) - (7 * m_button_height / 2);
903 m_graph_rect = wxRect(x_graph, y_graph, x_graph_w, y_graph_h);
908 if ((m_tsy * 15) > x)
911 m_tList->Move(wxPoint(x * 65 / 100, 11));
915 wxSize texc_size = wxSize((x * 60 / 100), (y * 29 / 100));
916 if (!m_tList->IsShown()) {
917 texc_size = wxSize((x * 90 / 100), (y * 29 / 100));
919 m_ptextctrl->SetSize(texc_size);
922 OK_button->Move(wxPoint(x - (4 * m_tsy + 10), y - (m_tsy + 10)));
924 OK_button->Move(wxPoint(x - (3 * m_tsy + 10), y - (m_tsy + 10)));
926 PR_button->Move(wxPoint(10, y - (m_tsy + 10)));
928 int bsx, bsy, bpx, bpy;
929 PR_button->GetSize(&bsx, &bsy);
930 PR_button->GetPosition(&bpx, &bpy);
932 NX_button->Move(wxPoint(bpx + bsx + 5, y - (m_tsy + 10)));
940void TCWin::MouseEvent(wxMouseEvent &event) {
941 event.GetPosition(&curs_x, &curs_y);
943 if (!m_TCWinPopupTimer.IsRunning())
944 m_TCWinPopupTimer.Start(20, wxTIMER_ONE_SHOT);
947void TCWin::OnTCWinPopupTimerEvent(wxTimerEvent &event) {
951 GetClientSize(&x, &y);
952 wxRegion cursorarea(m_graph_rect);
953 if (cursorarea.Contains(curs_x, curs_y)) {
955 SetCursor(*pParent->pCursorCross);
956 if (NULL == m_pTCRolloverWin) {
957 m_pTCRolloverWin =
new RolloverWin(
this, -1,
false);
961 m_pTCRolloverWin->SetMousePropogation(1);
962 m_pTCRolloverWin->Hide();
967 t = (25 / ((float)x * 8 / 10)) * ((
float)curs_x - ((float)x * 1 / 10));
969 int tt = m_t_graphday_GMT + (int)(t * 3600);
974 p.Printf(thd.Format(_T(
"%Hh %Mmn")));
979 int tt_localtz = m_t_graphday_GMT + (m_diff_mins * 60);
981 int ttv = tt_localtz + (int)(t * 3600);
982 if (m_tzoneDisplay == 0) {
983 ttv -= m_stationOffset_mins * 60;
989 ptcmgr->GetTideOrCurrent(tts, pIDX->IDX_rec_num, t, d);
990 s.Printf(_T(
"%3.2f "), (t < 0 && CURRENT_PLOT == m_plot_type)
997 if (pmsd) p.Append(wxString(pmsd->units_abbrv, wxConvUTF8));
1000 if (CURRENT_PLOT == m_plot_type) {
1001 s.Printf(
"%3.0f%c", d, 0x00B0);
1008 win_size.Set(x * 90 / 100, y * 80 / 100);
1010 m_pTCRolloverWin->SetString(p);
1011 m_pTCRolloverWin->SetBestPosition(curs_x, curs_y, 1, 1, TC_ROLLOVER,
1013 m_pTCRolloverWin->SetBitmap(TC_ROLLOVER);
1014 m_pTCRolloverWin->Refresh();
1015 m_pTCRolloverWin->Show();
1023 for (
int i = 0; i < 26; i++) {
1024 float ppx = m_graph_rect.x + ((i)*m_graph_rect.width / 25.f);
1031 wxPointList *list = (wxPointList *)&m_sList;
1032 wxPoint *a = list->Item(idx - 1)->GetData();
1033 wxPoint *b = list->Item(idx)->GetData();
1035 float pct = (curs_x - a->x) / (
float)((b->x - a->x));
1036 float dy = pct * (b->y - a->y);
1044 SetCursor(*pParent->pCursorArrow);
1045 ShowRollover =
false;
1048 if (m_pTCRolloverWin && m_pTCRolloverWin->IsShown() && !ShowRollover) {
1049 m_pTCRolloverWin->Hide();