]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/textdlgg.h
Use CFSocket instead of CFFileDescriptor in wxCFEventLoopSource.
[wxWidgets.git] / include / wx / generic / textdlgg.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/textdlgg.h
3 // Purpose: wxTextEntryDialog class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TEXTDLGG_H_
13 #define _WX_TEXTDLGG_H_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_TEXTDLG
18
19 #include "wx/dialog.h"
20
21 #if wxUSE_VALIDATORS
22 #include "wx/valtext.h"
23 #include "wx/textctrl.h"
24 #endif
25
26 class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
27
28 extern WXDLLIMPEXP_DATA_CORE(const char) wxGetTextFromUserPromptStr[];
29 extern WXDLLIMPEXP_DATA_CORE(const char) wxGetPasswordFromUserPromptStr[];
30
31 #define wxTextEntryDialogStyle (wxOK | wxCANCEL | wxCENTRE | wxWS_EX_VALIDATE_RECURSIVELY)
32
33 // ----------------------------------------------------------------------------
34 // wxTextEntryDialog: a dialog with text control, [ok] and [cancel] buttons
35 // ----------------------------------------------------------------------------
36
37 class WXDLLIMPEXP_CORE wxTextEntryDialog : public wxDialog
38 {
39 public:
40 wxTextEntryDialog()
41 {
42 m_textctrl = NULL;
43 }
44
45 wxTextEntryDialog(wxWindow *parent,
46 const wxString& message,
47 const wxString& caption = wxGetTextFromUserPromptStr,
48 const wxString& value = wxEmptyString,
49 long style = wxTextEntryDialogStyle,
50 const wxPoint& pos = wxDefaultPosition)
51 {
52 Create(parent, message, caption, value, style, pos);
53 }
54
55 bool Create(wxWindow *parent,
56 const wxString& message,
57 const wxString& caption = wxGetTextFromUserPromptStr,
58 const wxString& value = wxEmptyString,
59 long style = wxTextEntryDialogStyle,
60 const wxPoint& pos = wxDefaultPosition);
61
62 void SetValue(const wxString& val);
63 wxString GetValue() const { return m_value; }
64
65 void SetMaxLength(unsigned long len);
66
67 #if wxUSE_VALIDATORS
68 void SetTextValidator( const wxTextValidator& validator );
69 #if WXWIN_COMPATIBILITY_2_8
70 wxDEPRECATED( void SetTextValidator( long style ) );
71 #endif
72 void SetTextValidator( wxTextValidatorStyle style = wxFILTER_NONE );
73 wxTextValidator* GetTextValidator() { return (wxTextValidator*)m_textctrl->GetValidator(); }
74 #endif // wxUSE_VALIDATORS
75
76 virtual bool TransferDataToWindow();
77 virtual bool TransferDataFromWindow();
78
79 // implementation only
80 void OnOK(wxCommandEvent& event);
81
82 protected:
83 wxTextCtrl *m_textctrl;
84 wxString m_value;
85 long m_dialogStyle;
86
87 private:
88 DECLARE_EVENT_TABLE()
89 DECLARE_DYNAMIC_CLASS(wxTextEntryDialog)
90 wxDECLARE_NO_COPY_CLASS(wxTextEntryDialog);
91 };
92
93 // ----------------------------------------------------------------------------
94 // wxPasswordEntryDialog: dialog with password control, [ok] and [cancel]
95 // ----------------------------------------------------------------------------
96
97 class WXDLLIMPEXP_CORE wxPasswordEntryDialog : public wxTextEntryDialog
98 {
99 public:
100 wxPasswordEntryDialog(wxWindow *parent,
101 const wxString& message,
102 const wxString& caption = wxGetPasswordFromUserPromptStr,
103 const wxString& value = wxEmptyString,
104 long style = wxTextEntryDialogStyle,
105 const wxPoint& pos = wxDefaultPosition);
106 private:
107 DECLARE_DYNAMIC_CLASS(wxPasswordEntryDialog)
108 wxDECLARE_NO_COPY_CLASS(wxPasswordEntryDialog);
109 };
110
111 // ----------------------------------------------------------------------------
112 // function to get a string from user
113 // ----------------------------------------------------------------------------
114
115 WXDLLIMPEXP_CORE wxString
116 wxGetTextFromUser(const wxString& message,
117 const wxString& caption = wxGetTextFromUserPromptStr,
118 const wxString& default_value = wxEmptyString,
119 wxWindow *parent = NULL,
120 wxCoord x = wxDefaultCoord,
121 wxCoord y = wxDefaultCoord,
122 bool centre = true);
123
124 WXDLLIMPEXP_CORE wxString
125 wxGetPasswordFromUser(const wxString& message,
126 const wxString& caption = wxGetPasswordFromUserPromptStr,
127 const wxString& default_value = wxEmptyString,
128 wxWindow *parent = NULL,
129 wxCoord x = wxDefaultCoord,
130 wxCoord y = wxDefaultCoord,
131 bool centre = true);
132
133 #endif
134 // wxUSE_TEXTDLG
135 #endif // _WX_TEXTDLGG_H_