⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 solartimer.h

📁 Powerful and Portable GPS application -- support Linux, Windows, Windows CE GPS navigation and Map m
💻 H
字号:
/* *  Roadnav *  SolarTimer.h * *  Copyright (c) 2005 Rick Brice <rick_brice@users.sourceforge.net> * *  This program is free software; you can redistribute it and/or *  modify it under the terms of version 2 of the GNU General Public License *  as published by the Free Software Foundation. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA *////////////////////////////////////////////////////////////////////////////////// \file////// Contains the SolarTimer class - a class that fires events at sunrise /// and sunset./////////////////////////////////////////////////////////////////////////////////#ifndef SOLARTIMER_H#define SOLARTIMER_H#include <wx/event.h>#include <wx/timer.h>#include <wx/datetime.h>//////////////////////////////////////////////////////////////////////////////////// Defines the SolarEvent object/////////////////////////////////////////////////////////////////////////////////BEGIN_DECLARE_EVENT_TYPES()    DECLARE_EVENT_TYPE(wxEVT_SOLAR, wxEVT_USER_FIRST)    DECLARE_EVENT_TYPE(wxEVT_TIMECHANGE, wxEVT_USER_FIRST+1)END_DECLARE_EVENT_TYPES()class SolarEvent : public wxEvent{public:    SolarEvent(bool bIsSunrise=true) : wxEvent()    {        m_eventType = wxEVT_SOLAR;        m_bIsSunrise = bIsSunrise;    }    SolarEvent(const SolarEvent& event) :    wxEvent(event)    {       m_eventType = event.m_eventType;       m_bIsSunrise = event.m_bIsSunrise;    }    // Returns true if this is a sunrise event,    // otherwise it is a sunset event    bool IsSunrise() const { return m_bIsSunrise; }    // implement the base class pure virtual    virtual wxEvent *Clone() const { return new SolarEvent(*this); }private:    bool m_bIsSunrise;    DECLARE_DYNAMIC_CLASS(SolarEvent)};typedef void (wxEvtHandler::*SolarEventFunction)(SolarEvent&);#define EVT_SOLAR(func) DECLARE_EVENT_TABLE_ENTRY(wxEVT_SOLAR, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (SolarEventFunction) & func, NULL),class wxTimeChangeEvent : public wxEvent{public:   wxTimeChangeEvent() : wxEvent()   { m_eventType = wxEVT_TIMECHANGE; }   wxTimeChangeEvent(const wxTimeChangeEvent& event) : wxEvent(event)   {      m_eventType = event.m_eventType;   }   virtual wxEvent* Clone() const { return new wxTimeChangeEvent(*this); }private:      DECLARE_DYNAMIC_CLASS(wxTimeChangeEvent)};typedef void (wxEvtHandler::*wxTimeChangeEventFunction)(wxTimeChangeEvent&);#define EVT_TIMECHANGE(func) DECLARE_EVENT_TABLE_ENTRY(wxEVT_TIMECHANGE, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxTimeChangeEventFunction) & func, NULL),//////////////////////////////////////////////////////////////////////////////////// \brief SolarTimer/////////////////////////////////////////////////////////////////////////////////class SolarTimer: public wxEvtHandler{public:   // Type of Sunrise/Sunset event   enum EventType { Official, Civil, Nautical, Astronomical };	SolarTimer();	SolarTimer(wxEvtHandler* owner,double fLong,double fLat,EventType type);	void SetOwner(wxEvtHandler* owner,double fLong,double fLat,EventType type);	void SetPosition(double fLong,double fLat);   	void Start();  	void Stop();   	bool IsDaytime();	bool Valid();	void GetPosition(double& fLong,double& fLat) const;	EventType GetEventType() const;	wxDateTime GetSunrise() const;	wxDateTime GetSunset() const;	virtual void Notify();private:	void Init();	void OnTimer(wxTimerEvent& event);	void OnTimeChange(wxTimeChangeEvent& event);	void ComputeSunriset();	bool IsNewDay();	void NotifyIfNeeded();	wxEvtHandler* m_pOwner;	wxTimer m_Timer;	double m_fLong;	double m_fLat;	EventType m_EventType;	wxDateTime m_Today;	wxDateTime m_Sunrise;	wxDateTime m_Sunset;	bool m_bIsDaytime;	DECLARE_EVENT_TABLE()};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -