]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/textdlg.cpp
c4cbd59af03085d5a853a86703cb184794451791
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTextEntryDialog
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "textdlgg.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
26 #include "wx/dialog.h"
27 #include "wx/button.h"
28 #include "wx/stattext.h"
29 #include "wx/textctrl.h"
35 #include "wx/statline.h"
38 #include "wx/gtk/textdlg.h"
40 static void wxSplitMessage2( const wxString
&message
, wxWindow
*parent
, wxSizer
* sizer
)
43 for (size_t pos
= 0; pos
< message
.Len(); pos
++)
45 if (message
[pos
] == _T('\n'))
49 wxStaticText
*s1
= new wxStaticText( parent
, -1, line
);
60 // remaining text behind last '\n'
63 wxStaticText
*s2
= new wxStaticText( parent
, -1, line
);
70 #if !USE_SHARED_LIBRARY
71 BEGIN_EVENT_TABLE(wxTextEntryDialog
, wxDialog
)
72 EVT_BUTTON(wxID_OK
, wxTextEntryDialog::OnOK
)
75 IMPLEMENT_CLASS(wxTextEntryDialog
, wxDialog
)
78 wxTextEntryDialog::wxTextEntryDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
79 const wxString
& value
, long style
, const wxPoint
& pos
):
80 wxDialog(parent
, -1, caption
, pos
, wxDefaultSize
, wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
|wxTAB_TRAVERSAL
)
82 m_dialogStyle
= style
;
87 wxBox
*topsizer
= new wxBox( wxVERTICAL
);
90 wxBox
*textsizer
= new wxBox( wxVERTICAL
);
91 wxSplitMessage2( message
, this, textsizer
);
92 topsizer
->Add( textsizer
, 0, wxALL
, 10 );
95 wxTextCtrl
*textCtrl
= new wxTextCtrl(this, wxID_TEXT
, value
, wxDefaultPosition
, wxSize(300, -1));
96 topsizer
->Add( textCtrl
, 1, wxEXPAND
| wxLEFT
|wxRIGHT
, 15 );
100 topsizer
->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
105 wxBox
*buttonsizer
= new wxBox( wxHORIZONTAL
);
107 wxButton
*ok
= (wxButton
*) NULL
;
110 ok
= new wxButton( this, wxID_OK
, _("OK") );
111 buttonsizer
->Add( ok
, 0, wxLEFT
|wxRIGHT
, 10 );
114 wxButton
*cancel
= (wxButton
*) NULL
;
115 if (style
& wxCANCEL
)
117 cancel
= new wxButton( this, wxID_CANCEL
, _("Cancel") );
118 buttonsizer
->Add( cancel
, 0, wxLEFT
|wxRIGHT
, 10 );
121 topsizer
->Add( buttonsizer
, 0, wxCENTRE
| wxALL
, 10 );
123 topsizer
->SetSizeHints( this );
124 topsizer
->Fit( this );
125 SetSizer( topsizer
);
126 SetAutoLayout( TRUE
);
133 textCtrl
->SetFocus();
138 void wxTextEntryDialog::OnOK(wxCommandEvent
& WXUNUSED(event
) )
140 wxTextCtrl
*textCtrl
= (wxTextCtrl
*)FindWindow(wxID_TEXT
);
142 m_value
= textCtrl
->GetValue();