1
/////////////////////////////////////////////////////////////////////////////
2
// Name: wxMaskedTextCtrl.h
3
// Purpose: wxMaskedTextCtrl: masked edit control class
4
// Author: Thomas H�rtel
7
// RCS-ID: $Id: wxMaskedTextCtrl.h,v 1.0 2002/12/12 16:10:32 GD Exp $
8
// Copyright: (c) Thomas H�rtel
9
// Licence: wxWindows licence
10
/////////////////////////////////////////////////////////////////////////////
13
#include <wx/datetime.h>
14
#include <wx/textctrl.h>
16
const wxChar chNULL = wxT('\0') ;
17
const wxChar chDECIMALNULL = wxT('0') ;
18
const wxChar chCR = wxT('\r') ;
19
const wxChar chLF = wxT('\n') ;
20
const wxChar chSPACE = wxT('_') ;
21
const wxChar chPERIOD = wxT('.') ;
22
const wxChar chCOMMA = wxT(',') ;
23
const wxChar chCOLON = wxT(':') ;
24
const wxChar chSLASH = wxT('/') ;
26
/////////////////////////////////////////////////////////////////////////////
29
const wxChar chMaskPlaceholderDECIMALSEPARATOR = wxT('.');
30
const wxChar chMaskPlaceholderTHOUSANDSSEPARATOR = wxT(',');
31
const wxChar chMaskPlaceholderTIMESEPARATOR = wxT(':');
32
const wxChar chMaskPlaceholderDATESEPARATOR = wxT('/');
33
const wxChar chMaskPlaceholderDIGIT = wxT('#');
34
const wxChar chMaskPlaceholderALPHANUMERIC = wxT('A');
35
const wxChar chMaskPlaceholderALPHABETIC = wxT('?');
36
const wxChar chMaskPlaceholderALPHABETICUPPER = wxT('>');
37
const wxChar chMaskPlaceholderALPHABETICLOWER = wxT('<');
38
const wxChar chMaskPlaceholderCHARACTER = wxT('&');
39
const wxChar chMaskPlaceholderLITERALESCAPE = wxT('\\');
40
const wxChar chMaskPlaceholderDATEDAY = wxT('d');
41
const wxChar chMaskPlaceholderDATEMONTH = wxT('m');
42
const wxChar chMaskPlaceholderDATEYEAR = wxT('y');
43
const wxChar chMaskPlaceholderTIMEHOUR = wxT('h');
44
const wxChar chMaskPlaceholderTIMEMINUTE = wxT('n');
45
const wxChar chMaskPlaceholderTIMESECOND = wxT('s');
49
MaskDataTypeDECIMALSEPARATOR=0, // Decimal separator.
50
MaskDataTypeTHOUSANDSSEPARATOR, // Thousands separator.
51
MaskDataTypeTIMESEPARATOR , // Time separator.
52
MaskDataTypeDATESEPARATOR , // Date separator.
53
MaskDataTypeDIGIT , // # digit placeholder (0-9).
54
MaskDataTypeALPHANUMERIC , // A alphanumeric character placeholder (0-9 and a-Z).
55
MaskDataTypeALPHABETIC , // ? Alphabetic placeholder (a-Z).
56
MaskDataTypeALPHAETICUPPER , // > Alphabetic placeholder, but forced to Uppercase characters (A-Z).
57
MaskDataTypeALPHAETICLOWER , // < Alphabetic placeholder, but forced to Lowercase characters (a-z).
58
MaskDataTypeCHARACTER , // # character placeholder (ANSI characters 32-126 and 128-255).
59
MaskDataTypeLITERALESCAPE , // All other symbols are displayed as themselves.
60
MaskDataTypeLITERAL , // All other symbols are displayed as themselves.
64
enum enumMaskDataSubType
66
MaskDataSubTypeNONE = 0,
67
MaskDataSubTypeDATEDAY,
68
MaskDataSubTypeDATEMONTH,
69
MaskDataSubTypeDATEYEAR,
70
MaskDataSubTypeTIMEHOUR,
71
MaskDataSubTypeTIMEMINUTE,
72
MaskDataSubTypeTIMESECOND,
76
class EXTAPI wxMaskData : public wxObject
78
DECLARE_DYNAMIC_CLASS(wxMaskData)
82
virtual ~wxMaskData();
86
enumMaskDataType m_eType;
87
enumMaskDataSubType m_eSubType;
92
void operator=(const wxMaskData& src);
94
bool IsValidInput(wxChar chNewChar);
95
wxChar PreProcessChar(wxChar chNewChar);
98
class EXTAPI wxMaskedTextCtrl : public wxTextCtrl
100
DECLARE_DYNAMIC_CLASS(wxMaskedTextCtrl)
102
// Member functions ---------------------------------------------------------
105
wxMaskedTextCtrl(wxWindow *parent, wxWindowID id, const wxString& mask, const wxString &value, const wxPoint &pos, const wxSize &size, int style);
106
virtual ~wxMaskedTextCtrl();
109
void SetMask(wxString& mask);
110
wxChar GetPromptSymbol();
111
void SetPromptSymbol(wxChar chNewPromptSymbol);
112
wxChar GetDecimalSeperator();
113
void SetDecimalSeperator(wxChar chNewDecimalSeperator);
114
wxChar GetThousandsSeperator();
115
void SetThousandsSeperator(wxChar chNewThousandsSeperator);
116
wxChar GetTimeSeperator();
117
void SetTimeSeperator(wxChar chNewTimeSeperator);
118
wxChar GetDateSeperator();
119
void SetDateSeperator(wxChar chNewDateSeperator);
120
bool GetInsertMode();
121
void SetInsertMode(bool bInsertMode);
123
void SetAutoTab(bool bAutoTab);
124
bool GetBackwardLocationRight();
125
void SetBackwardLocationRight(bool bRight=TRUE);
126
wxDateTime GetMinDateTime(void);
127
void SetMinDateTime(wxDateTime& minDateTime);
128
wxDateTime GetMaxDateTime(void);
129
void SetMaxDateTime(wxDateTime& maxDateTime);
130
void SetDateTimeRange(wxDateTime& minDateTime, wxDateTime& maxDateTime);
133
void SetValue(const wxString& value);
134
wxDateTime GetDateTimeValue();
135
void SetDateTimeValue(wxDateTime& value);
137
// Internal Member functions ------------------------------------------------
140
void OnKeyDown(wxKeyEvent& event);
141
void OnChar(wxKeyEvent& event);
142
void OnSetFocus(wxFocusEvent& event);
143
void OnKillFocus(wxFocusEvent& event);
144
void OnLeftButtonDown(wxMouseEvent& event);
145
void OnCut(wxUpdateUIEvent& event);
146
void OnCopy(wxUpdateUIEvent& event);
147
void OnPaste(wxUpdateUIEvent& event);
148
DECLARE_EVENT_TABLE();
151
wxString GetInputData();
152
wxString GetInputData(wxString& value);
153
bool SetInputData(const wxString& value, int nBeginPos=0, bool bAllowPrompt=TRUE);
154
void EmptyData(bool bOnlyInput=FALSE);
155
bool IsInputEmpty() const;
156
bool IsEmpty() const;
157
virtual void ValidationError();
160
int RPtoLP(int nRealPos);
161
int LPtoRP(int nLogicalPos);
163
void DeleteContents();
164
bool IsInputData(int nPosition);
165
int DeleteRange(int nSelectionStart, int nSelectionEnd);
166
int InsertAt(int nSelectionStart, wxChar chNewChar);
167
int SetAt(int nSelectionStart, wxChar chNewChar);
168
int GetNextInputLocation(int nSelectionStart);
169
int GetPreviousInputLocation(int nSelectionStart);
170
int GetEmptyInputLocation(int nSelectionStart);
172
void UpdateControl(int nSelectionStart=0); // UpdateInsertionPoint is automatic.
173
void UpdateInsertionPointForward(int nSelectionStart);
174
void UpdateInsertionPointBackward(int nSelectionStart);
176
// Data members -------------------------------------------------------------
180
wxChar m_chPromptSymbol;
181
wxChar m_chIntlDecimal;
182
wxChar m_chIntlThousands;
186
bool m_bBackwardLocationRight;
187
bool m_bNeedValidation;
190
wxDateTime m_dtDateTime;
191
wxDateTime m_dtMinDateTime;
192
wxDateTime m_dtMaxDateTime;