]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/textdlgg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTextEntryDialog
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
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"
43 #include "wx/statline.h"
46 #include "wx/generic/textdlgg.h"
48 // ----------------------------------------------------------------------------
50 // ----------------------------------------------------------------------------
52 static const int wxID_TEXT
= 3000;
54 // ============================================================================
56 // ============================================================================
58 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
62 #if !USE_SHARED_LIBRARY
63 BEGIN_EVENT_TABLE(wxTextEntryDialog
, wxDialog
)
64 EVT_BUTTON(wxID_OK
, wxTextEntryDialog::OnOK
)
67 IMPLEMENT_CLASS(wxTextEntryDialog
, wxDialog
)
70 wxTextEntryDialog::wxTextEntryDialog(wxWindow
*parent
,
71 const wxString
& message
,
72 const wxString
& caption
,
73 const wxString
& value
,
76 : wxDialog(parent
, -1, caption
, pos
, wxDefaultSize
,
77 wxDEFAULT_DIALOG_STYLE
| wxDIALOG_MODAL
),
80 // calculate the sizes
81 // -------------------
84 wxSize sizeText
= SplitTextMessage(message
, &lines
);
86 wxSize sizeBtn
= GetStandardButtonSize();
88 long wText
= wxMax(4*sizeBtn
.GetWidth(), sizeText
.GetWidth());
89 long hText
= GetStandardTextHeight();
91 long wDialog
= 4*LAYOUT_X_MARGIN
+ wText
;
92 long hDialog
= 2*LAYOUT_Y_MARGIN
+
93 sizeText
.GetHeight() * lines
.GetCount() +
100 // create the controls
101 // -------------------
104 long x
= 2*LAYOUT_X_MARGIN
;
105 long y
= CreateTextMessage(lines
,
106 wxPoint(x
, 2*LAYOUT_Y_MARGIN
),
109 y
+= 2*LAYOUT_X_MARGIN
;
112 m_textctrl
= new wxTextCtrl(this, wxID_TEXT
, m_value
,
114 wxSize(wText
, hText
));
115 y
+= hText
+ 2*LAYOUT_X_MARGIN
;
118 CreateStandardButtons(wDialog
, y
, sizeBtn
.GetWidth(), sizeBtn
.GetHeight());
120 // set the dialog size and position
121 SetClientSize(wDialog
, hDialog
);
122 if ( pos
== wxDefaultPosition
)
124 // centre the dialog if no explicit position given
125 Centre(wxBOTH
| wxCENTER_FRAME
);
128 m_textctrl
->SetFocus();
131 void wxTextEntryDialog::OnOK(wxCommandEvent
& WXUNUSED(event
) )
133 m_value
= m_textctrl
->GetValue();