]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/generic/textdlgg.cpp
added copy arrow cursor macos specific
[wxWidgets.git] / src / generic / textdlgg.cpp
... / ...
CommitLineData
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 "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"
40 #include "wx/sizer.h"
41#endif
42
43#if wxUSE_STATLINE
44 #include "wx/statline.h"
45#endif
46
47#include "wx/generic/textdlgg.h"
48
49// ----------------------------------------------------------------------------
50// constants
51// ----------------------------------------------------------------------------
52
53static const int wxID_TEXT = 3000;
54
55// ============================================================================
56// implementation
57// ============================================================================
58
59// ----------------------------------------------------------------------------
60// wxTextEntryDialog
61// ----------------------------------------------------------------------------
62
63BEGIN_EVENT_TABLE(wxTextEntryDialog, wxDialog)
64 EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK)
65END_EVENT_TABLE()
66
67IMPLEMENT_CLASS(wxTextEntryDialog, wxDialog)
68
69wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent,
70 const wxString& message,
71 const wxString& caption,
72 const wxString& value,
73 long style,
74 const wxPoint& pos)
75 : wxDialog(parent, -1, caption, pos, wxDefaultSize,
76 wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL),
77 m_value(value)
78{
79 m_dialogStyle = style;
80 m_value = value;
81
82 wxBeginBusyCursor();
83
84 wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
85
86 // 1) text message
87 topsizer->Add( CreateTextSizer( message ), 0, wxALL, 10 );
88
89 // 2) text ctrl
90 m_textctrl = new wxTextCtrl(this, wxID_TEXT, value,
91 wxDefaultPosition, wxSize(300, -1),
92 style & ~wxTextEntryDialogStyle);
93 topsizer->Add( m_textctrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
94
95#if wxUSE_VALIDATORS
96 wxTextValidator validator( wxFILTER_NONE, &m_value );
97 m_textctrl->SetValidator( validator );
98#endif
99 // wxUSE_VALIDATORS
100
101#if wxUSE_STATLINE
102 // 3) static line
103 topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
104#endif
105
106 // 4) buttons
107 topsizer->Add( CreateButtonSizer( style ), 0, wxCENTRE | wxALL, 10 );
108
109 SetAutoLayout( TRUE );
110 SetSizer( topsizer );
111
112 topsizer->SetSizeHints( this );
113 topsizer->Fit( this );
114
115 Centre( wxBOTH );
116
117 m_textctrl->SetFocus();
118
119 wxEndBusyCursor();
120}
121
122void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
123{
124#if wxUSE_VALIDATORS
125 if( Validate() && TransferDataFromWindow() )
126 {
127 EndModal( wxID_OK );
128 }
129#else
130 m_value = m_textctrl->GetValue();
131
132 EndModal(wxID_OK);
133#endif
134 // wxUSE_VALIDATORS
135}
136
137void wxTextEntryDialog::SetValue(const wxString& val)
138{
139 m_value = val;
140
141 m_textctrl->SetValue(val);
142}
143
144#if wxUSE_VALIDATORS
145void wxTextEntryDialog::SetTextValidator( long style )
146{
147 wxTextValidator validator( style, &m_value );
148 m_textctrl->SetValidator( validator );
149}
150
151void wxTextEntryDialog::SetTextValidator( wxTextValidator& validator )
152{
153 m_textctrl->SetValidator( validator );
154}
155
156#endif
157 // wxUSE_VALIDATORS
158
159#endif // wxUSE_TEXTDLG