calctrl.tex

来自「Wxpython Implemented on Windows CE, Sou」· TEX 代码 · 共 512 行 · 第 1/2 页

TEX
512
字号
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name:        calctrl.tex
%% Purpose:     wxCalendarCtrl documentation
%% Author:      Vadim Zeitlin
%% Modified by:
%% Created:     03.01.00
%% RCS-ID:      $Id: calctrl.tex,v 1.17 2006/05/28 23:56:47 VZ Exp $
%% Copyright:   (c) Vadim Zeitlin
%% License:     wxWindows license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{\class{wxCalendarCtrl}}\label{wxcalendarctrl}

The calendar control allows the user to pick a date. For this,
it displays a window containing several parts: a control at the top to pick the month
and the year (either or both of them may be disabled), and a month
area below them which shows all the days in the month. The user can move the
current selection using the keyboard and select the date (generating 
{\tt EVT\_CALENDAR} event) by pressing {\tt <Return>} or double clicking it.

It has advanced possibilities for the customization of its display. All global
settings (such as colours and fonts used) can, of course, be changed. But
also, the display style for each day in the month can be set independently
using \helpref{wxCalendarDateAttr}{wxcalendardateattr} class.

An item without custom attributes is drawn with the default colours and
font and without border, but setting custom attributes with 
\helpref{SetAttr}{wxcalendarctrlsetattr} allows to modify its appearance. Just
create a custom attribute object and set it for the day you want to be
displayed specially (note that the control will take ownership of the pointer,
i.e. it will delete it itself). A day may be marked as being a holiday, even
if it is not recognized as one by \helpref{wxDateTime}{tdateholidays} using 
\helpref{SetHoliday}{wxcalendardateattrsetholiday} method.

As the attributes are specified for each day, they may change when the month
is changed, so you will often want to update them in 
{\tt EVT\_CALENDAR\_MONTH} event handler.

\wxheading{Derived from}

\helpref{wxControl}{wxcontrol}\\
\helpref{wxWindow}{wxwindow}\\
\helpref{wxEvtHandler}{wxevthandler}\\
\helpref{wxObject}{wxobject}

\wxheading{Include files}

<wx/calctrl.h>

\wxheading{Window styles}

\twocolwidtha{5cm}
\begin{twocollist}\itemsep=4pt
\twocolitem{\windowstyle{wxCAL\_SUNDAY\_FIRST}}{Show Sunday as the first day in the week}
\twocolitem{\windowstyle{wxCAL\_MONDAY\_FIRST}}{Show Monday as the first day in the week}
\twocolitem{\windowstyle{wxCAL\_SHOW\_HOLIDAYS}}{Highlight holidays in the calendar}
\twocolitem{\windowstyle{wxCAL\_NO\_YEAR\_CHANGE}}{Disable the year changing}
\twocolitem{\windowstyle{wxCAL\_NO\_MONTH\_CHANGE}}{Disable the month (and, implicitly, the year) changing}
\twocolitem{\windowstyle{wxCAL\_SHOW\_SURROUNDING\_WEEKS}}{Show the neighbouring weeks in the previous and next months}
\twocolitem{\windowstyle{wxCAL\_SEQUENTIAL\_MONTH\_SELECTION}}{Use alternative, more compact, style for the month and year selection controls.}
\end{twocollist}

The default calendar style is {\tt wxCAL\_SHOW\_HOLIDAYS}.

\wxheading{Event table macros}

To process input from a calendar control, use these event handler macros to
direct input to member functions that take a 
\helpref{wxCalendarEvent}{wxcalendarevent} argument.

\twocolwidtha{7cm}
\begin{twocollist}\itemsep=7pt
\twocolitem{{\bf EVT\_CALENDAR(id, func)}}{A day was double clicked in the calendar.}
\twocolitem{{\bf EVT\_CALENDAR\_SEL\_CHANGED(id, func)}}{The selected date changed.}
\twocolitem{{\bf EVT\_CALENDAR\_DAY(id, func)}}{The selected day changed.}
\twocolitem{{\bf EVT\_CALENDAR\_MONTH(id, func)}}{The selected month changed.}
\twocolitem{{\bf EVT\_CALENDAR\_YEAR(id, func)}}{The selected year changed.}
\twocolitem{{\bf EVT\_CALENDAR\_WEEKDAY\_CLICKED(id, func)}}{User clicked on the week day header}
\end{twocollist}%

Note that changing the selected date will result in either of 
{\tt EVT\_CALENDAR\_DAY}, {\tt MONTH} or {\tt YEAR} events and 
{\tt EVT\_CALENDAR\_SEL\_CHANGED} one.

\wxheading{Constants}

The following are the possible return values for 
\helpref{HitTest}{wxcalendarctrlhittest} method:

{\small
\begin{verbatim}
enum wxCalendarHitTestResult
{
    wxCAL_HITTEST_NOWHERE,      // outside of anything
    wxCAL_HITTEST_HEADER,       // on the header (weekdays)
    wxCAL_HITTEST_DAY           // on a day in the calendar
}
\end{verbatim}
}

\wxheading{See also}

\helpref{Calendar sample}{samplecalendar}\\
\helpref{wxCalendarDateAttr}{wxcalendardateattr}\\
\helpref{wxCalendarEvent}{wxcalendarevent}

\latexignore{\rtfignore{\wxheading{Members}}}


\membersection{wxCalendarCtrl::wxCalendarCtrl}\label{wxcalendarctrlwxcalendarctrldef}

\func{}{wxCalendarCtrl}{\void}

Default constructor, use \helpref{Create}{wxcalendarctrlcreate} after it.

\func{}{wxCalendarCtrl}{\param{wxWindow* }{parent}, \param{wxWindowID }{id}, \param{const wxDateTime\& }{date = wxDefaultDateTime}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = wxCAL\_SHOW\_HOLIDAYS}, \param{const wxString\& }{name = wxCalendarNameStr}}

Does the same as \helpref{Create}{wxcalendarctrlcreate} method.


\membersection{wxCalendarCtrl::Create}\label{wxcalendarctrlcreate}

\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID }{id}, \param{const wxDateTime\& }{date = wxDefaultDateTime}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = wxCAL\_SHOW\_HOLIDAYS}, \param{const wxString\& }{name = wxCalendarNameStr}}

Creates the control. See \helpref{wxWindow}{wxwindowctor} for the meaning of
the parameters and the control overview for the possible styles.


\membersection{wxCalendarCtrl::\destruct{wxCalendarCtrl}}\label{wxcalendarctrldtor}

\func{}{\destruct{wxCalendarCtrl}}{\void}

Destroys the control.


\membersection{wxCalendarCtrl::SetDate}\label{wxcalendarctrlsetdate}

\func{void}{SetDate}{\param{const wxDateTime\& }{date}}

Sets the current date.


\membersection{wxCalendarCtrl::GetDate}\label{wxcalendarctrlgetdate}

\constfunc{const wxDateTime\&}{GetDate}{\void}

Gets the currently selected date.


\membersection{wxCalendarCtrl::EnableYearChange}\label{wxcalendarctrlenableyearchange}

\func{void}{EnableYearChange}{\param{bool }{enable = true}}

This function should be used instead of changing {\tt wxCAL\_NO\_YEAR\_CHANGE}
style bit directly. It allows or disallows the user to change the year
interactively.


\membersection{wxCalendarCtrl::EnableMonthChange}\label{wxcalendarctrlenablemonthchange}

\func{void}{EnableMonthChange}{\param{bool }{enable = true}}

This function should be used instead of changing 
{\tt wxCAL\_NO\_MONTH\_CHANGE} style bit. It allows or disallows the user to
change the month interactively. Note that if the month can not be changed, the
year can not be changed neither.


\membersection{wxCalendarCtrl::EnableHolidayDisplay}\label{wxcalendarctrlenableholidaydisplay}

\func{void}{EnableHolidayDisplay}{\param{bool }{display = true}}

This function should be used instead of changing {\tt wxCAL\_SHOW\_HOLIDAYS}
style bit directly. It enables or disables the special highlighting of the
holidays.


\membersection{wxCalendarCtrl::SetHeaderColours}\label{wxcalendarctrlsetheadercolours}

\func{void}{SetHeaderColours}{\param{const wxColour\& }{colFg}, \param{const wxColour\& }{colBg}}

Set the colours used for painting the weekdays at the top of the control.


\membersection{wxCalendarCtrl::GetHeaderColourFg}\label{wxcalendarctrlgetheadercolourfg}

\constfunc{const wxColour\&}{GetHeaderColourFg}{\void}

Gets the foreground colour of the header part of the calendar window.

\wxheading{See also}

\helpref{SetHeaderColours}{wxcalendarctrlsetheadercolours}


\membersection{wxCalendarCtrl::GetHeaderColourBg}\label{wxcalendarctrlgetheadercolourbg}

\constfunc{const wxColour\&}{GetHeaderColourBg}{\void}

Gets the background colour of the header part of the calendar window.

\wxheading{See also}

\helpref{SetHeaderColours}{wxcalendarctrlsetheadercolours}


\membersection{wxCalendarCtrl::SetHighlightColours}\label{wxcalendarctrlsethighlightcolours}

\func{void}{SetHighlightColours}{\param{const wxColour\& }{colFg}, \param{const wxColour\& }{colBg}}

Set the colours to be used for highlighting the currently selected date.


\membersection{wxCalendarCtrl::GetHighlightColourFg}\label{wxcalendarctrlgethighlightcolourfg}

\constfunc{const wxColour\&}{GetHighlightColourFg}{\void}

Gets the foreground highlight colour.

\wxheading{See also}

\helpref{SetHighlightColours}{wxcalendarctrlsethighlightcolours}


\membersection{wxCalendarCtrl::GetHighlightColourBg}\label{wxcalendarctrlgethighlightcolourbg}

\constfunc{const wxColour\&}{GetHighlightColourBg}{\void}

Gets the background highlight colour.

\wxheading{See also}

\helpref{SetHighlightColours}{wxcalendarctrlsethighlightcolours}


\membersection{wxCalendarCtrl::SetHolidayColours}\label{wxcalendarctrlsetholidaycolours}

\func{void}{SetHolidayColours}{\param{const wxColour\& }{colFg}, \param{const wxColour\& }{colBg}}

Sets the colours to be used for the holidays highlighting (only used if the
window style includes {\tt wxCAL\_SHOW\_HOLIDAYS} flag).


\membersection{wxCalendarCtrl::GetHolidayColourFg}\label{wxcalendarctrlgetholidaycolourfg}

\constfunc{const wxColour\&}{GetHolidayColourFg}{\void}

Return the foreground colour currently used for holiday highlighting.

\wxheading{See also}

\helpref{SetHolidayColours}{wxcalendarctrlsetholidaycolours}


\membersection{wxCalendarCtrl::GetHolidayColourBg}\label{wxcalendarctrlgetholidaycolourbg}

⌨️ 快捷键说明

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