]> git.saurik.com Git - wxWidgets.git/blame - src/generic/textdlgg.cpp
Applied patch for multiple file selection, documented.
[wxWidgets.git] / src / generic / textdlgg.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: textdlgg.cpp
3// Purpose: wxTextEntryDialog
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
c50f1fb9 9// Licence: wxWindows license
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
c50f1fb9
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
c801d85f 20#ifdef __GNUG__
c50f1fb9 21 #pragma implementation "textdlgg.h"
c801d85f
KB
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
c50f1fb9 28 #pragma hdrstop
c801d85f
KB
29#endif
30
31#ifndef WX_PRECOMP
c50f1fb9
VZ
32 #include <stdio.h>
33
34 #include "wx/utils.h"
35 #include "wx/dialog.h"
36 #include "wx/button.h"
37 #include "wx/stattext.h"
38 #include "wx/textctrl.h"
39 #include "wx/intl.h"
92afa2b1 40 #include "wx/sizer.h"
dcf924a3
RR
41#endif
42
43#if wxUSE_STATLINE
c50f1fb9 44 #include "wx/statline.h"
c801d85f
KB
45#endif
46
47#include "wx/generic/textdlgg.h"
48
c50f1fb9
VZ
49// ----------------------------------------------------------------------------
50// constants
51// ----------------------------------------------------------------------------
52
c49245f8 53static const int wxID_TEXT = 3000;
dcf924a3 54
c50f1fb9
VZ
55// ============================================================================
56// implementation
57// ============================================================================
58
59// ----------------------------------------------------------------------------
c801d85f 60// wxTextEntryDialog
c50f1fb9 61// ----------------------------------------------------------------------------
c801d85f
KB
62
63#if !USE_SHARED_LIBRARY
64BEGIN_EVENT_TABLE(wxTextEntryDialog, wxDialog)
c50f1fb9 65 EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK)
c801d85f
KB
66END_EVENT_TABLE()
67
68IMPLEMENT_CLASS(wxTextEntryDialog, wxDialog)
69#endif
70
c50f1fb9
VZ
71wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent,
72 const wxString& message,
73 const wxString& caption,
74 const wxString& value,
75 long style,
76 const wxPoint& pos)
77 : wxDialog(parent, -1, caption, pos, wxDefaultSize,
78 wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL),
79 m_value(value)
c801d85f 80{
92afa2b1
RR
81 m_dialogStyle = style;
82 m_value = value;
83
84 wxBeginBusyCursor();
85
86 wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
87
88 // 1) text message
89 topsizer->Add( CreateTextSizer( message ), 0, wxALL, 10 );
90
91 // 2) text ctrl
92 m_textctrl = new wxTextCtrl(this, wxID_TEXT, value, wxDefaultPosition, wxSize(300, -1));
93 topsizer->Add( m_textctrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
94
95#if wxUSE_STATLINE
96 // 3) static line
97 topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
98#endif
99
100 // 4) buttons
101 topsizer->Add( CreateButtonSizer( style ), 0, wxCENTRE | wxALL, 10 );
102
8b17ba72
RR
103 SetAutoLayout( TRUE );
104 SetSizer( topsizer );
105
92afa2b1
RR
106 topsizer->SetSizeHints( this );
107 topsizer->Fit( this );
92afa2b1
RR
108
109 Centre( wxBOTH );
c801d85f 110
c50f1fb9 111 m_textctrl->SetFocus();
92afa2b1
RR
112
113 wxEndBusyCursor();
c801d85f
KB
114}
115
116void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
117{
c50f1fb9 118 m_value = m_textctrl->GetValue();
c801d85f 119
c50f1fb9 120 EndModal(wxID_OK);
c801d85f 121}