📄 calendar_btn.h
字号:
// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - -
// - File: calendar_btn.h. -
// - -
// - Contents: Interface of class CCalBtn. -
// - -
// - Purpose: Ownerdrawn button specially made for calendar usage. -
// - -
// - Remarks: - -
// - -
// - Originator: Michael Mogensen, MM-IT Consult 2003. -
// - -
// - Compiler: MS Visual C++ ver6.0. -
// - -
// - Period: 29.04.03 - 00.00.00. -
// - -
// - Version: 1.00. -
// - -
// ------------------------------------------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - Miscellaneous. -
// ------------------------------------------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - Header(s). -
// ------------------------------------------------------------------------------------------------------------------------------------------------------
#pragma once
#include "calendar.rh"
#include "geometryex.hpp"
#include "keyboard.hpp"
#include "shadow_dc.h"
#include "windowex.hpp"
// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - Miscellaneous. -
// ------------------------------------------------------------------------------------------------------------------------------------------------------
#define ID_TIMER_HOVER 1
#define ID_TIMER_AUTOREPEAT 2
#define I_TIMEOUT_HOVER 100
#define I_TIMEOUT_AUTOREPEAT 50
#define I_COUNTDOWN_AUTOREPEAT 800 // Wait until 0.8 sec. before autorepeat.
// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - CCalBtn. -
// ------------------------------------------------------------------------------------------------------------------------------------------------------
class CCalBtn : public CButton
{
public:
// 0. Data. (alphabetical).
static const UINT WM_BTN;
static const UINT WM_BTN_RADIO;
static const UINT WM_BTN_ONHOVER;
enum EArrowDirection
{ eAE_Unknown, eAE_North, eAE_East, eAE_South, eAE_West };
enum EBehaviour
{ eBE_Static, eBE_Push, eBE_Radio };
enum EState
{ eST_Up, eST_Normal, eST_Down, eST_Disabled };
enum EStyle
{ eS_OldFashioned, eS_Flat };
enum EGraph
{
eT_Box,
eT_Text,
eT_1Arrow_North,
eT_1Arrow_East,
eT_1Arrow_South,
eT_1Arrow_West,
eT_2Arrow_North, // No impl.
eT_2Arrow_East,
eT_2Arrow_South, // No impl.
eT_2Arrow_West,
};
// 1. Object. (alphabetical).
CCalBtn(const enum EGraph iTypeEx = eT_Text,
const enum EStyle iStyleEx = eS_OldFashioned,
const enum EBehaviour iBehaviour = eBE_Push);
virtual ~CCalBtn();
// 4. Slaves. (alphabetical).
const EBehaviour GetBehaviour();
const CString GetCaption();
const void GetRepresentation(CShadowDC&);
const int GetCheck();
const void GetColors( // For a better understanding see SetColors(...).
HBRUSH *phbrBtn_Externals_BackgroundEx = NULL,
COLORREF *pcrBtn_Externals_Raised_LeftTopEx = NULL,
COLORREF *pcrBtn_Externals_Raised_RightBottomEx = NULL,
COLORREF *pcrBtn_Externals_Pressed_LeftTopEx = NULL,
COLORREF *pcrBtn_Externals_Pressed_RightBottomEx = NULL,
COLORREF *pcrBtn_Externals_Sleeping_LeftTopEx = NULL,
COLORREF *pcrBtn_Externals_Sleeping_RightBottomEx = NULL,
COLORREF *pcrBtn_Externals_DisabledEx = NULL,
COLORREF *pcrBtn_Internals_HoveredEx = NULL,
COLORREF *pcrBtn_Internals_PressedEx = NULL,
COLORREF *pcrBtn_Internals_SleepingEx = NULL,
COLORREF *pcrBtn_Internals_DisabledEx = NULL,
COLORREF *pcrBtn_Internals_CheckmarkEx = NULL);
const EState GetState();
const EStyle GetStyle();
const int GetPos_Left();
const int GetPos_Top();
const int GetPos_Right();
const int GetPos_Bottom();
const EGraph GetType();
const bool HasCaption();
const void Pos_Set(const int, const int);
const void SetAutorepeat(const bool);
const void SetBehaviour(const enum EBehaviour, const bool bDoInvalidateEx = true);
const void SetCaption(const int);
const void SetCaption(const CString &cstrCaptionEx = CString(""));
const void SetCheck(const int, const bool bDoInvalidateEx = true);
const void SetColors(
const HBRUSH hbrBtn_Externals_BackgroundEx = 0L, // Meaning "use default".
const COLORREF crBtn_Externals_Raised_LeftTopEx = 0L, // ditto.
const COLORREF crBtn_Externals_Raised_RightBottomEx = 0L, // ditto.
const COLORREF crBtn_Externals_Pressed_LeftTopEx = 0L, // ditto.
const COLORREF crBtn_Externals_Pressed_RightBottomEx = 0L, // ditto.
const COLORREF crBtn_Externals_Sleeping_LeftTopEx = 0L, // ditto.
const COLORREF crBtn_Externals_Sleeping_RightBottomEx = 0L, // ditto.
const COLORREF crBtn_Externals_DisabledEx = 0L, // ditto.
const COLORREF crBtn_Internals_HoveredEx = 0L, // ditto.
const COLORREF crBtn_Internals_PressedEx = 0L, // ditto.
const COLORREF crBtn_Internals_SleepingEx = 0L, // ditto.
const COLORREF crBtn_Internals_Disabled = 0L, // ditto.
const COLORREF crBtn_Internals_CheckmarkEx = 0L); // ditto.
const void SetHint(const CString&);
const void SetState(const enum EState, const bool bDoInvalidateEx = true);
const void SetStyle(const enum EStyle, const bool bDoInvalidateEx = true);
const void SetTextAlign(CONST UINT);
protected:
// 0. Data. (alphabetical).
bool m_bIsPressed;
enum EBehaviour m_iBehaviour;
enum EState m_iState;
enum EStyle m_iStyle;
enum EGraph m_iType;
// 2. Event's. (alphabetical).
virtual void DrawItem(LPDRAWITEMSTRUCT);
virtual afx_msg void OnClicked();
virtual afx_msg int OnCreate(LPCREATESTRUCT);
virtual afx_msg void OnDestroy();
virtual afx_msg void OnKeyDown(UINT, UINT, UINT);
virtual afx_msg BOOL OnMouseWheel(UINT, short, CPoint);
virtual afx_msg UINT OnNcHitTest(CPoint);
virtual afx_msg void OnTimer(UINT);
// 4. Slaves. (alphabetical).
const void CreateFont(int iPointSizeEx = 0, LPCTSTR lpszFaceNameEx = NULL);
const void Draw_ArrowHead(CShadowDC&, const CRectEx&, const enum EArrowDirection);
const void Draw_Box(CShadowDC&, const CRectEx&);
const void Draw_Button(CShadowDC&, const CRectEx&);
const void Draw_Button_Externals(CShadowDC&, const CRectEx&);
const void Draw_Button_Internals(CShadowDC&, const CRectEx&);
const void Draw_Button_Text(CShadowDC&, const CRectEx&);
const void Draw_Checkmark(CShadowDC&, const CRectEx&);
const void Init();
const bool IsHovered();
const void Timer_Create(CONST UINT, CONST UINT);
const void Timer_Destroy(CONST UINT);
const void UnInit();
private:
// 0. Data. (alphabetical).
bool m_bIsHovered;
CFont *m_pFont;
COLORREF
m_crBtn_Externals_Raised_LeftTop, // Color of edge raised.
m_crBtn_Externals_Raised_RightBottom, // Color of edge raised.
m_crBtn_Externals_Pressed_LeftTop, // Color of edge pressed.
m_crBtn_Externals_Pressed_RightBottom, // Color of edge pressed.
m_crBtn_Externals_Sleeping_LeftTop, // Color of edge sleeping.
m_crBtn_Externals_Sleeping_RightBottom, // Color of edge sleeping.
m_crBtn_Externals_Disabled, // Color of (left, top, right, bottom)-edge disabled.
m_crBtn_Internals_Raised, // Color of deco. raised.
m_crBtn_Internals_Pressed, // Color of deco. pressed.
m_crBtn_Internals_Sleeping, // Color of deco. sleeping.
m_crBtn_Internals_Disabled, // Color of deco. disabled.
m_crBtn_Internals_Checkmark; // Color of checkmark.
CPointEx m_ipTopLeft;
CString m_cstrHint;
HBRUSH m_hbrBtn_Externals_Background; // Color of background.
int m_iCheckState,
m_iAutoRepeat;
UINT m_uTextAlign;
// 4. Slaves. (alphabetical).
const void ResourcesCreate();
const void ResourcesDestroy();
// 5. Other. (alphabetical).
DECLARE_DYNCREATE(CCalBtn)
DECLARE_MESSAGE_MAP()
};
// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - CCalBtn_Radio. -
// ------------------------------------------------------------------------------------------------------------------------------------------------------
class CCalBtn_Radio : public CCalBtn
{
public:
// 1. Object. (alphabetical).
CCalBtn_Radio(const enum CCalBtn::EGraph iTypeEx = CCalBtn::eT_Text,
const enum CCalBtn::EStyle iStyleEx = CCalBtn::eS_OldFashioned,
const enum CCalBtn::EBehaviour iBehaviour = CCalBtn::eBE_Push);
virtual ~CCalBtn_Radio();
// 4. Slaves. (alphabetical).
inline const void SetRadioGroupMember_Last(CCalBtn_Radio *const pWnd)
{ m_pWnd_RadioGroupMember_Last = pWnd; }
inline const void SetRadioGroupMember_Previous(CCalBtn_Radio *const pWnd)
{ m_pWnd_RadioGroupMember_Previous = pWnd; }
protected:
// 2. Event's. (alphabetical).
virtual afx_msg void OnClickedRadio();
virtual afx_msg void OnLButtonDown(UINT, CPoint);
// 4. Slaves. (alphabetical).
virtual const void Draw_ReleaseRadioGroup();
private:
// 0. Data. (alphabetical).
CCalBtn_Radio *m_pWnd_RadioGroupMember_Previous,
*m_pWnd_RadioGroupMember_Last;
// 5. Other. (alphabetical).
DECLARE_DYNCREATE(CCalBtn_Radio)
DECLARE_MESSAGE_MAP()
};
// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - -
// ------------------------------------------------------------------------------------------------------------------------------------------------------
// 0. Data. (alphabetical).
// 1. Object. (alphabetical).
// 2. Event's. (alphabetical).
// 3.0. Menu choice. (menu order).
// 3.1. Menu choice, enablers. (menu order).
// 4. Slaves. (alphabetical).
// 5. Other. (alphabetical).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -