home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Computer Buyer 1998 October
/
dpcb1098.iso
/
Business
/
Maxim
/
MAX5
/
data.z
/
CalendarCtrl.h
< prev
next >
Wrap
C/C++ Source or Header
|
1998-05-15
|
5KB
|
261 lines
//////////////////////////////////////////////////////////////////////////////
// NAME.......: CalendarCtrl.H
// PURPOSE....: Group of day, month and year controls
// WRITTEN....: 96/09/27 by Darko Juvan
// DESCRIPTION:
//
// This code and information is provided "as is" without warranty of any
// kind, either expressed or implied, including but not limited to the
// implied warranties of merchantability and/or fitness for a particular
// purpose..
//
// Copyright (c) 1998 Multiactive Software Inc. All Rights Reserved.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __CALENDARCTRL_H
#define __CALENDARCTRL_H
#define UM_DATE_CHANGED WM_USER + 5
class CCalendarCtrl;
enum eDayType {eCurrentMonth, eCurrentDay, eOtherMonth};
class CDayButton : public CButton
{
// Constructors
public:
CDayButton();
protected:
// Attributes
public:
CCalendarCtrl* m_pCalendarGroup; // date control group
int m_iYear; // current selected year [m_iLowYear..m_iHighYear]
int m_iMonth; // current selected month [1..12]
int m_iDay; // current selected day [1..31]
int m_iDaysInMonth; // number of days in current month
int m_iFirstWeekDay; // weekday for the 1st of this month [0..6]
int m_iButtonWidth; // control width
int m_iButtonHeight; // control height
int m_iBoxWidth; // width of a single day space on screen
int m_iBoxHeight; // height of a single day space on screen
int m_iCurrentIndex; // index in array [1..42] of day spaces on screen
BOOL m_bInitialized; // set when control is drawn the first time
int m_iLowYear; // lower limit for year
int m_iHighYear; // upper limit for year
CComboBox* m_pMonthControl; // month control connected to this control
CSpinButtonCtrl* m_pYearControl; // year control connected to this control
protected:
// Operations
public:
void DrawItem(LPDRAWITEMSTRUCT lpDIS);
void DrawBorder(CRect rcItem);
void DrawAll(CDC* pDC);
void WeekBack();
void WeekForward();
void DayBack();
void DayForward();
void FirstDay();
void LastDay();
BOOL MonthBack();
BOOL MonthForward();
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDayButton)
//}}AFX_VIRTUAL
protected:
private:
// Implementation
public:
virtual ~CDayButton();
protected:
void DrawDays(CDC* pDC);
void DrawDayNames(CDC* pDC);
void DrawDayName(CDC* pDC, int iIndex, int iHorOr, int iVerOr);
void DrawChanged(CDC* pDC, int iOld, int iNew);
void DrawDay(CDC* pDC, int iIndex, const CString& szDay, eDayType eDay);
void RecalculateData();
int GetDaysInMonth(int iYear, int iMonth);
int GetFirstWeekDay(int iYear, int iMonth, int iDay);
int ProcessMouseClick(int& iOld, int& iNew);
//{{AFX_MSG(CDayButton)
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
//}}AFX_MSG
private:
DECLARE_MESSAGE_MAP()
DECLARE_DYNAMIC(CDayButton)
};
class CMonthComboBox : public CComboBox
{
// Constructors
public:
CMonthComboBox();
protected:
private:
// Attributes
public:
CCalendarCtrl* m_pCalendarGroup; // date control group
protected:
private:
// Operations
public:
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMonthComboBox)
//}}AFX_VIRTUAL
protected:
private:
// Implementation
public:
virtual ~CMonthComboBox();
protected:
//{{AFX_MSG(CMonthComboBox)
afx_msg void OnSelchange();
//}}AFX_MSG
private:
DECLARE_MESSAGE_MAP()
};
class CYearSpin : public CSpinButtonCtrl
{
// Constructors
public:
CYearSpin();
protected:
private:
// Attributes
public:
CCalendarCtrl* m_pCalendarGroup; // date control group
protected:
private:
// Operations
public:
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CYearSpin)
//}}AFX_VIRTUAL
protected:
private:
// Implementation
public:
virtual ~CYearSpin();
protected:
//{{AFX_MSG(CYearSpin)
afx_msg void OnDeltapos(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
private:
DECLARE_MESSAGE_MAP()
};
class CCalendarCtrl : public CObject
{
// Constructors
public:
CCalendarCtrl();
void Create(CWnd* parent,
UINT iDayControl,
UINT iMonthControl,
UINT iYearControl,
CString date);
void Create(CWnd* parent,
UINT iDayControl,
UINT iMonthControl,
UINT iYearControl,
int iYear=0, int iMonth=0, int iDay=0);
void SetDate(int iYear=0, int iMonth=0, int iDay=0);
void SetDate(LPCTSTR date);
int GetMonth(LPCTSTR sMonth);
protected:
private:
// Attributes
public:
CDayButton m_DayControl; // day control
CMonthComboBox m_MonthControl; // month control
CYearSpin m_YearControl; // year control
CWnd* m_pParent;
BOOL m_bClose;
int m_iYear; // year
int m_iMonth; // month
int m_iDay; // day
protected:
private:
// Operations
public:
void ForwardMsg(MSG* pMsg);
void RefreshDate();
void UpdateMonth();
void UpdateYear(NMHDR* pNMHDR);
void DateChanged();
protected:
private:
// Implementation
public:
protected:
private:
DECLARE_DYNAMIC(CCalendarCtrl)
};
#endif //__CALENDARCTRL_H