]> git.saurik.com Git - wxWidgets.git/blob - src/generic/textdlgg.cpp
fixed client area handling for wxFrame/Univ
[wxWidgets.git] / src / generic / textdlgg.cpp
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
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "textdlgg.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #if wxUSE_TEXTDLG
32
33 #ifndef WX_PRECOMP
34 #include <stdio.h>
35
36 #include "wx/utils.h"
37 #include "wx/dialog.h"
38 #include "wx/button.h"
39 #include "wx/stattext.h"
40 #include "wx/textctrl.h"
41 #include "wx/intl.h"
42 #include "wx/sizer.h"
43 #endif
44
45 #if wxUSE_STATLINE
46 #include "wx/statline.h"
47 #endif
48
49 #include "wx/generic/textdlgg.h"
50
51 // ----------------------------------------------------------------------------
52 // constants
53 // ----------------------------------------------------------------------------
54
55 static const int wxID_TEXT = 3000;
56
57 // ============================================================================
58 // implementation
59 // ============================================================================
60
61 // ----------------------------------------------------------------------------
62 // wxTextEntryDialog
63 // ----------------------------------------------------------------------------
64
65 BEGIN_EVENT_TABLE(wxTextEntryDialog, wxDialog)
66 EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK)
67 END_EVENT_TABLE()
68
69 IMPLEMENT_CLASS(wxTextEntryDialog, wxDialog)
70
71 wxTextEntryDialog::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)
80 {
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,
93 wxDefaultPosition, wxSize(300, -1),
94 style & ~wxTextEntryDialogStyle);
95 topsizer->Add( m_textctrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
96
97 #if wxUSE_STATLINE
98 // 3) static line
99 topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
100 #endif
101
102 // 4) buttons
103 topsizer->Add( CreateButtonSizer( style ), 0, wxCENTRE | wxALL, 10 );
104
105 SetAutoLayout( TRUE );
106 SetSizer( topsizer );
107
108 topsizer->SetSizeHints( this );
109 topsizer->Fit( this );
110
111 Centre( wxBOTH );
112
113 m_textctrl->SetFocus();
114
115 wxEndBusyCursor();
116 }
117
118 void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
119 {
120 m_value = m_textctrl->GetValue();
121
122 EndModal(wxID_OK);
123 }
124
125 #endif // wxUSE_TEXTDLG