1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/textdlgg.cpp
3 // Purpose: wxTextEntryDialog
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
29 #include "wx/generic/textdlgg.h"
33 #include "wx/dialog.h"
34 #include "wx/button.h"
35 #include "wx/stattext.h"
36 #include "wx/textctrl.h"
42 #include "wx/statline.h"
45 const wxChar wxGetTextFromUserPromptStr
[] = wxT("Input Text");
46 const wxChar wxGetPasswordFromUserPromptStr
[] = wxT("Enter Password");
48 // ----------------------------------------------------------------------------
50 // ----------------------------------------------------------------------------
52 static const int wxID_TEXT
= 3000;
54 // ============================================================================
56 // ============================================================================
58 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
62 BEGIN_EVENT_TABLE(wxTextEntryDialog
, wxDialog
)
63 EVT_BUTTON(wxID_OK
, wxTextEntryDialog::OnOK
)
66 IMPLEMENT_CLASS(wxTextEntryDialog
, wxDialog
)
68 wxTextEntryDialog::wxTextEntryDialog(wxWindow
*parent
,
69 const wxString
& message
,
70 const wxString
& caption
,
71 const wxString
& value
,
74 : wxDialog(parent
, wxID_ANY
, caption
, pos
, wxDefaultSize
,
75 wxDEFAULT_DIALOG_STYLE
),
78 m_dialogStyle
= style
;
83 wxBoxSizer
*topsizer
= new wxBoxSizer( wxVERTICAL
);
85 wxSizerFlags flagsBorder2
;
86 flagsBorder2
.DoubleBorder();
90 topsizer
->Add(CreateTextSizer(message
), flagsBorder2
);
94 m_textctrl
= new wxTextCtrl(this, wxID_TEXT
, value
,
95 wxDefaultPosition
, wxSize(300, wxDefaultCoord
),
96 style
& ~wxTextEntryDialogStyle
);
98 topsizer
->Add(m_textctrl
,
99 wxSizerFlags(style
& wxTE_MULTILINE
? 1 : 0).
101 TripleBorder(wxLEFT
| wxRIGHT
));
104 wxTextValidator
validator( wxFILTER_NONE
, &m_value
);
105 m_textctrl
->SetValidator( validator
);
106 #endif // wxUSE_VALIDATORS
109 wxSizer
*buttonSizer
= CreateSeparatedButtonSizer(style
& ButtonSizerFlags
);
112 topsizer
->Add(buttonSizer
, wxSizerFlags(flagsBorder2
).Expand());
115 SetAutoLayout( true );
116 SetSizer( topsizer
);
118 topsizer
->SetSizeHints( this );
119 topsizer
->Fit( this );
121 if ( style
& wxCENTRE
)
124 m_textctrl
->SetSelection(-1, -1);
125 m_textctrl
->SetFocus();
130 void wxTextEntryDialog::OnOK(wxCommandEvent
& WXUNUSED(event
) )
133 if( Validate() && TransferDataFromWindow() )
138 m_value
= m_textctrl
->GetValue();
145 void wxTextEntryDialog::SetValue(const wxString
& val
)
149 m_textctrl
->SetValue(val
);
153 void wxTextEntryDialog::SetTextValidator( long style
)
155 wxTextValidator
validator( style
, &m_value
);
156 m_textctrl
->SetValidator( validator
);
159 void wxTextEntryDialog::SetTextValidator( const wxTextValidator
& validator
)
161 m_textctrl
->SetValidator( validator
);
167 // ----------------------------------------------------------------------------
168 // wxPasswordEntryDialog
169 // ----------------------------------------------------------------------------
171 IMPLEMENT_CLASS(wxPasswordEntryDialog
, wxTextEntryDialog
)
173 wxPasswordEntryDialog::wxPasswordEntryDialog(wxWindow
*parent
,
174 const wxString
& message
,
175 const wxString
& caption
,
176 const wxString
& value
,
179 : wxTextEntryDialog(parent
, message
, caption
, value
,
180 style
| wxTE_PASSWORD
, pos
)
182 // Only change from wxTextEntryDialog is the password style
185 #endif // wxUSE_TEXTDLG