]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/textdlgg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTextEntryDialog
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "textdlgg.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
35 #include "wx/dialog.h"
36 #include "wx/button.h"
37 #include "wx/stattext.h"
38 #include "wx/textctrl.h"
44 #include "wx/statline.h"
47 #include "wx/generic/textdlgg.h"
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
53 static const int wxID_TEXT
= 3000;
55 // ============================================================================
57 // ============================================================================
59 // ----------------------------------------------------------------------------
61 // ----------------------------------------------------------------------------
63 BEGIN_EVENT_TABLE(wxTextEntryDialog
, wxDialog
)
64 EVT_BUTTON(wxID_OK
, wxTextEntryDialog::OnOK
)
67 IMPLEMENT_CLASS(wxTextEntryDialog
, wxDialog
)
69 wxTextEntryDialog::wxTextEntryDialog(wxWindow
*parent
,
70 const wxString
& message
,
71 const wxString
& caption
,
72 const wxString
& value
,
75 : wxDialog(parent
, wxID_ANY
, caption
, pos
, wxDefaultSize
,
76 wxDEFAULT_DIALOG_STYLE
| wxDIALOG_MODAL
),
79 m_dialogStyle
= style
;
84 wxBoxSizer
*topsizer
= new wxBoxSizer( wxVERTICAL
);
87 topsizer
->Add( CreateTextSizer( message
), 0, wxALL
, 10 );
90 m_textctrl
= new wxTextCtrl(this, wxID_TEXT
, value
,
91 wxDefaultPosition
, wxSize(300, wxDefaultCoord
),
92 style
& ~wxTextEntryDialogStyle
);
93 topsizer
->Add( m_textctrl
, 1, wxEXPAND
| wxLEFT
|wxRIGHT
, 15 );
96 wxTextValidator
validator( wxFILTER_NONE
, &m_value
);
97 m_textctrl
->SetValidator( validator
);
103 topsizer
->Add( new wxStaticLine( this, wxID_ANY
), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
107 topsizer
->Add( CreateButtonSizer( style
), 0, wxCENTRE
| wxALL
, 10 );
109 SetAutoLayout( true );
110 SetSizer( topsizer
);
112 topsizer
->SetSizeHints( this );
113 topsizer
->Fit( this );
115 if ( ( style
& wxCENTRE
) == wxCENTRE
)
118 m_textctrl
->SetSelection(-1, -1);
119 m_textctrl
->SetFocus();
124 void wxTextEntryDialog::OnOK(wxCommandEvent
& WXUNUSED(event
) )
127 if( Validate() && TransferDataFromWindow() )
132 m_value
= m_textctrl
->GetValue();
139 void wxTextEntryDialog::SetValue(const wxString
& val
)
143 m_textctrl
->SetValue(val
);
147 void wxTextEntryDialog::SetTextValidator( long style
)
149 wxTextValidator
validator( style
, &m_value
);
150 m_textctrl
->SetValidator( validator
);
153 void wxTextEntryDialog::SetTextValidator( wxTextValidator
& validator
)
155 m_textctrl
->SetValidator( validator
);
161 #endif // wxUSE_TEXTDLG