~ubuntu-branches/ubuntu/wily/ginkgocadx/wily-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/wx/maskedtextctrl/maskedtextctrl.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Tille
  • Date: 2011-05-02 08:09:26 UTC
  • Revision ID: james.westby@ubuntu.com-20110502080926-bql5wep49c7hg91t
Tags: upstream-2.4.1.1
Import upstream version 2.4.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////////////////////
 
2
// Name:        wxMaskedTextCtrl.h
 
3
// Purpose:     wxMaskedTextCtrl: masked edit control class
 
4
// Author:      Thomas H�rtel
 
5
// Modified by:
 
6
// Created:     2002-11-14
 
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
/////////////////////////////////////////////////////////////////////////////
 
11
#include <api/api.h>
 
12
#include <wx/list.h>
 
13
#include <wx/datetime.h>
 
14
#include <wx/textctrl.h>
 
15
 
 
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('/') ;
 
25
 
 
26
/////////////////////////////////////////////////////////////////////////////
 
27
// wxMaskData object
 
28
 
 
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');
 
46
 
 
47
enum enumMaskDataType
 
48
{
 
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. 
 
61
        MASKDATATYPECOUNT
 
62
};
 
63
 
 
64
enum enumMaskDataSubType
 
65
{
 
66
        MaskDataSubTypeNONE = 0,
 
67
        MaskDataSubTypeDATEDAY,
 
68
        MaskDataSubTypeDATEMONTH,
 
69
        MaskDataSubTypeDATEYEAR,
 
70
        MaskDataSubTypeTIMEHOUR,
 
71
        MaskDataSubTypeTIMEMINUTE,
 
72
        MaskDataSubTypeTIMESECOND,
 
73
        MASKDATASUBTYPECOUNT
 
74
};
 
75
 
 
76
class EXTAPI wxMaskData : public wxObject
 
77
{
 
78
        DECLARE_DYNAMIC_CLASS(wxMaskData)
 
79
        
 
80
public:
 
81
        wxMaskData();
 
82
        virtual ~wxMaskData();
 
83
 
 
84
// Attributes
 
85
public:
 
86
        enumMaskDataType m_eType;
 
87
        enumMaskDataSubType m_eSubType;
 
88
        wxChar m_chValue;
 
89
        
 
90
// Operations
 
91
public:
 
92
        void operator=(const wxMaskData& src);
 
93
        bool IsInputData();
 
94
        bool IsValidInput(wxChar chNewChar);
 
95
        wxChar PreProcessChar(wxChar chNewChar);
 
96
};
 
97
 
 
98
class EXTAPI wxMaskedTextCtrl : public wxTextCtrl
 
99
{
 
100
DECLARE_DYNAMIC_CLASS(wxMaskedTextCtrl)
 
101
 
 
102
// Member functions ---------------------------------------------------------
 
103
public:
 
104
        wxMaskedTextCtrl();
 
105
        wxMaskedTextCtrl(wxWindow *parent, wxWindowID id, const wxString& mask, const wxString &value, const wxPoint &pos, const wxSize &size, int style);
 
106
        virtual ~wxMaskedTextCtrl();
 
107
 
 
108
        wxString GetMask();
 
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);
 
122
        bool GetAutoTab();
 
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);
 
131
 
 
132
        void Clear();
 
133
        void SetValue(const wxString& value);
 
134
        wxDateTime GetDateTimeValue();
 
135
        void SetDateTimeValue(wxDateTime& value);
 
136
        
 
137
// Internal Member functions ------------------------------------------------
 
138
protected:
 
139
        // Event Handler
 
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();
 
149
        
 
150
        wxString ShowMask();
 
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();
 
158
        bool Validate();
 
159
        bool IsValid(void);
 
160
        int RPtoLP(int nRealPos);
 
161
        int LPtoRP(int nLogicalPos);
 
162
 
 
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);
 
171
 
 
172
        void UpdateControl(int nSelectionStart=0);  // UpdateInsertionPoint is automatic. 
 
173
        void UpdateInsertionPointForward(int nSelectionStart);
 
174
        void UpdateInsertionPointBackward(int nSelectionStart);
 
175
 
 
176
// Data members -------------------------------------------------------------
 
177
        wxList m_listData;
 
178
 
 
179
        bool m_bInsertMode;
 
180
        wxChar m_chPromptSymbol;
 
181
        wxChar m_chIntlDecimal;
 
182
        wxChar m_chIntlThousands;
 
183
        wxChar m_chIntlTime;
 
184
        wxChar m_chIntlDate;
 
185
        bool m_bAutoTab;        
 
186
        bool m_bBackwardLocationRight;
 
187
        bool m_bNeedValidation;
 
188
        bool m_bValidation;
 
189
 
 
190
        wxDateTime m_dtDateTime;
 
191
        wxDateTime m_dtMinDateTime;
 
192
        wxDateTime m_dtMaxDateTime;
 
193
};