]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/textctrl.cpp
Applied patch #418555: wxTextCtrl uses wrong background colour
[wxWidgets.git] / src / gtk1 / textctrl.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: textctrl.cpp
3// Purpose:
4// Author: Robert Roebling
f96aa4d9 5// Id: $Id$
a81258be 6// Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin
13289f04 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "textctrl.h"
12#endif
13
14#include "wx/textctrl.h"
15#include "wx/utils.h"
ae0bdb01 16#include "wx/intl.h"
a1f79c1e 17#include "wx/log.h"
ae0bdb01 18#include "wx/settings.h"
fc71ef6e 19#include "wx/panel.h"
c801d85f 20
a81258be
RR
21#include <sys/types.h>
22#include <sys/stat.h>
23#include <ctype.h>
24
83624f79
RR
25#include "gdk/gdk.h"
26#include "gtk/gtk.h"
b292e2f5
RR
27#include "gdk/gdkkeysyms.h"
28
acfd422a
RR
29//-----------------------------------------------------------------------------
30// idle system
31//-----------------------------------------------------------------------------
32
33extern void wxapp_install_idle_handler();
34extern bool g_isIdle;
35
b292e2f5
RR
36//-----------------------------------------------------------------------------
37// data
38//-----------------------------------------------------------------------------
39
65045edd
RR
40extern bool g_blockEventsOnDrag;
41extern wxCursor g_globalCursor;
b292e2f5 42
c801d85f 43//-----------------------------------------------------------------------------
2f2aa628 44// "changed"
c801d85f
KB
45//-----------------------------------------------------------------------------
46
805dd538 47static void
2830bf19 48gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
484e45bf 49{
a2053b27 50 if (!win->m_hasVMT) return;
805dd538 51
bb69661b 52 if (g_isIdle)
3c679789
RR
53 wxapp_install_idle_handler();
54
034be888 55 win->SetModified();
01041145 56 win->UpdateFontIfNeeded();
8bbe427f 57
f03fc89f 58 wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
8a85884a 59 event.SetString( win->GetValue() );
2830bf19
RR
60 event.SetEventObject( win );
61 win->GetEventHandler()->ProcessEvent( event );
6de97a3b 62}
112892b9 63
2830bf19 64//-----------------------------------------------------------------------------
034be888 65// "changed" from vertical scrollbar
2830bf19
RR
66//-----------------------------------------------------------------------------
67
805dd538 68static void
034be888 69gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
2830bf19 70{
3c679789 71 if (!win->m_hasVMT) return;
bb69661b
VZ
72
73 if (g_isIdle)
3c679789 74 wxapp_install_idle_handler();
acfd422a 75
2830bf19
RR
76 win->CalculateScrollbar();
77}
78
fc71ef6e
JS
79//-----------------------------------------------------------------------------
80// "focus_in_event"
81//-----------------------------------------------------------------------------
82
83wxWindow *FindFocusedChild(wxWindow *win);
84extern wxWindow *g_focusWindow;
85extern bool g_blockEventsOnDrag;
86// extern bool g_isIdle;
87
88static gint gtk_text_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
89{
90 // Necessary?
91#if 0
92 if (g_isIdle)
93 wxapp_install_idle_handler();
94#endif
95 if (!win->m_hasVMT) return FALSE;
96 if (g_blockEventsOnDrag) return FALSE;
97
98 g_focusWindow = win;
99
100 wxPanel *panel = wxDynamicCast(win->GetParent(), wxPanel);
101 if (panel)
102 {
103 panel->SetLastFocus(win);
104 }
105
106#ifdef HAVE_XIM
107 if (win->m_ic)
108 gdk_im_begin(win->m_ic, win->m_wxwindow->window);
109#endif
110
111#if 0
112#ifdef wxUSE_CARET
113 // caret needs to be informed about focus change
114 wxCaret *caret = win->GetCaret();
115 if ( caret )
116 {
117 caret->OnSetFocus();
118 }
119#endif // wxUSE_CARET
120#endif
121
122 wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
123 event.SetEventObject( win );
124
125 if (win->GetEventHandler()->ProcessEvent( event ))
126 {
127 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus_in_event" );
128 return TRUE;
129 }
130
131 return FALSE;
132}
133
134//-----------------------------------------------------------------------------
135// "focus_out_event"
136//-----------------------------------------------------------------------------
137
138static gint gtk_text_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
139{
140#if 0
141 if (g_isIdle)
142 wxapp_install_idle_handler();
143#endif
144
145 if (!win->m_hasVMT) return FALSE;
146 if (g_blockEventsOnDrag) return FALSE;
147
148#if 0
149 // if the focus goes out of our app alltogether, OnIdle() will send
150 // wxActivateEvent, otherwise gtk_window_focus_in_callback() will reset
151 // g_sendActivateEvent to -1
152 g_sendActivateEvent = 0;
153#endif
154
155 wxWindow *winFocus = FindFocusedChild(win);
156 if ( winFocus )
157 win = winFocus;
158
159 g_focusWindow = (wxWindow *)NULL;
160
161#ifdef HAVE_XIM
162 if (win->m_ic)
163 gdk_im_end();
164#endif
165
166#if 0
167#ifdef wxUSE_CARET
168 // caret needs to be informed about focus change
169 wxCaret *caret = win->GetCaret();
170 if ( caret )
171 {
172 caret->OnKillFocus();
173 }
174#endif // wxUSE_CARET
175#endif
176
177 wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() );
178 event.SetEventObject( win );
179
180 if (win->GetEventHandler()->ProcessEvent( event ))
181 {
182 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus_out_event" );
183 return TRUE;
184 }
185
186 return FALSE;
187}
188
2f2aa628
RR
189//-----------------------------------------------------------------------------
190// wxTextCtrl
191//-----------------------------------------------------------------------------
192
193IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl,wxControl)
194
c801d85f 195BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
2830bf19 196 EVT_CHAR(wxTextCtrl::OnChar)
e702ff0f
JS
197
198 EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
199 EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
200 EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
201 EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
202 EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
203
204 EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
205 EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
206 EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
207 EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
208 EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
c801d85f
KB
209END_EVENT_TABLE()
210
01041145 211void wxTextCtrl::Init()
f5abe911
RR
212{
213 m_modified = FALSE;
01041145 214 m_updateFont = FALSE;
3ca6a5f0
BP
215 m_text =
216 m_vScrollbar = (GtkWidget *)NULL;
f5abe911 217}
13289f04 218
13111b2a
VZ
219wxTextCtrl::wxTextCtrl( wxWindow *parent,
220 wxWindowID id,
221 const wxString &value,
222 const wxPoint &pos,
223 const wxSize &size,
224 long style,
225 const wxValidator& validator,
226 const wxString &name )
f5abe911 227{
01041145
VZ
228 Init();
229
f5abe911
RR
230 Create( parent, id, value, pos, size, style, validator, name );
231}
c801d85f 232
13111b2a
VZ
233bool wxTextCtrl::Create( wxWindow *parent,
234 wxWindowID id,
235 const wxString &value,
236 const wxPoint &pos,
237 const wxSize &size,
238 long style,
239 const wxValidator& validator,
240 const wxString &name )
c801d85f 241{
2830bf19 242 m_needParent = TRUE;
b292e2f5 243 m_acceptsFocus = TRUE;
484e45bf 244
4dcaf11a
RR
245 if (!PreCreation( parent, pos, size ) ||
246 !CreateBase( parent, id, pos, size, style, validator, name ))
247 {
223d09f6 248 wxFAIL_MSG( wxT("wxTextCtrl creation failed") );
13111b2a 249 return FALSE;
4dcaf11a 250 }
6de97a3b 251
805dd538 252
034be888 253 m_vScrollbarVisible = FALSE;
13289f04 254
2830bf19 255 bool multi_line = (style & wxTE_MULTILINE) != 0;
ab46dc18 256 if (multi_line)
2830bf19 257 {
7d6d2cd4 258#if (GTK_MINOR_VERSION > 2)
034be888
RR
259 /* a multi-line edit control: create a vertical scrollbar by default and
260 horizontal if requested */
2830bf19 261 bool bHasHScrollbar = (style & wxHSCROLL) != 0;
7d6d2cd4
RR
262#else
263 bool bHasHScrollbar = FALSE;
264#endif
805dd538 265
034be888 266 /* create our control ... */
2830bf19
RR
267 m_text = gtk_text_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
268
034be888 269 /* ... and put into the upper left hand corner of the table */
2830bf19 270 m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE);
5664fc32 271 GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
2830bf19 272 gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1,
41dee9d0 273 (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
f5368809
RR
274 (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
275 0, 0);
bb69661b 276
5c387335
RR
277 /* always wrap words */
278 gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE );
bb69661b 279
7d6d2cd4 280#if (GTK_MINOR_VERSION > 2)
034be888 281 /* put the horizontal scrollbar in the lower left hand corner */
2830bf19
RR
282 if (bHasHScrollbar)
283 {
284 GtkWidget *hscrollbar = gtk_hscrollbar_new(GTK_TEXT(m_text)->hadj);
5664fc32 285 GTK_WIDGET_UNSET_FLAGS( hscrollbar, GTK_CAN_FOCUS );
2830bf19 286 gtk_table_attach(GTK_TABLE(m_widget), hscrollbar, 0, 1, 1, 2,
8ce63e9d 287 (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK),
13289f04
VZ
288 GTK_FILL,
289 0, 0);
2830bf19 290 gtk_widget_show(hscrollbar);
13289f04 291
3358d36e
VZ
292 /* don't wrap lines, otherwise we wouldn't need the scrollbar */
293 gtk_text_set_line_wrap( GTK_TEXT(m_text), FALSE );
5c387335 294 }
7d6d2cd4 295#endif
bb69661b 296
ab46dc18
RR
297 /* finally, put the vertical scrollbar in the upper right corner */
298 m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj );
299 GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS );
ab46dc18
RR
300 gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1,
301 GTK_FILL,
302 (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK),
303 0, 0);
2830bf19
RR
304 }
305 else
306 {
034be888 307 /* a single-line text control: no need for scrollbars */
2830bf19
RR
308 m_widget =
309 m_text = gtk_entry_new();
310 }
484e45bf 311
db434467
RR
312 m_parent->DoAddChild( this );
313
314 PostCreation();
315
316 SetFont( parent->GetFont() );
317
318 wxSize size_best( DoGetBestSize() );
319 wxSize new_size( size );
0279e844 320 if (new_size.x == -1)
db434467 321 new_size.x = size_best.x;
0279e844 322 if (new_size.y == -1)
db434467 323 new_size.y = size_best.y;
0279e844
RR
324 if ((new_size.x != size.x) || (new_size.y != size.y))
325 SetSize( new_size.x, new_size.y );
484e45bf 326
2830bf19 327 if (multi_line)
2830bf19 328 gtk_widget_show(m_text);
13289f04 329
ab46dc18
RR
330 if (multi_line)
331 {
332 gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed",
333 (GtkSignalFunc) gtk_scrollbar_changed_callback, (gpointer) this );
fc71ef6e
JS
334
335 gtk_signal_connect( GTK_OBJECT(GTK_TEXT(m_text)), "focus_in_event",
336 GTK_SIGNAL_FUNC(gtk_text_focus_in_callback), (gpointer)this );
337
338 gtk_signal_connect( GTK_OBJECT(GTK_TEXT(m_text)), "focus_out_event",
339 GTK_SIGNAL_FUNC(gtk_text_focus_out_callback), (gpointer)this );
340 }
341 else
342 {
343 gtk_signal_connect( GTK_OBJECT(m_text), "focus_in_event",
344 GTK_SIGNAL_FUNC(gtk_text_focus_in_callback), (gpointer)this );
345
346 gtk_signal_connect( GTK_OBJECT(m_text), "focus_out_event",
347 GTK_SIGNAL_FUNC(gtk_text_focus_out_callback), (gpointer)this );
ab46dc18 348 }
3358d36e 349
291a8f20 350 if (!value.IsEmpty())
2830bf19
RR
351 {
352 gint tmp = 0;
3358d36e
VZ
353
354#if GTK_MINOR_VERSION == 0
355 // if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in
356 // gtk_editable_insert_text()
357 gtk_widget_realize(m_text);
358#endif // GTK 1.0
359
05939a81 360#if wxUSE_UNICODE
3358d36e 361 wxWX2MBbuf val = value.mbc_str();
05939a81 362 gtk_editable_insert_text( GTK_EDITABLE(m_text), val, strlen(val), &tmp );
3358d36e 363#else // !Unicode
2830bf19 364 gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &tmp );
3358d36e
VZ
365#endif // Unicode/!Unicode
366
291a8f20
RR
367 if (multi_line)
368 {
3358d36e
VZ
369 /* bring editable's cursor uptodate. bug in GTK. */
370
371 GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
372 }
2830bf19 373 }
484e45bf 374
2830bf19
RR
375 if (style & wxTE_PASSWORD)
376 {
377 if (!multi_line)
378 gtk_entry_set_visibility( GTK_ENTRY(m_text), FALSE );
379 }
8bbe427f 380
2830bf19
RR
381 if (style & wxTE_READONLY)
382 {
383 if (!multi_line)
384 gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE );
385 }
386 else
387 {
388 if (multi_line)
389 gtk_text_set_editable( GTK_TEXT(m_text), 1 );
390 }
3358d36e 391
ce16e5d7
RR
392 /* we want to be notified about text changes */
393 gtk_signal_connect( GTK_OBJECT(m_text), "changed",
394 GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
395
a88acabd
JS
396 /* we don't set a valid background colour, because the window
397 manager should use a default one */
398 m_backgroundColour = wxColour();
034be888 399 SetForegroundColour( parent->GetForegroundColour() );
805dd538 400
65045edd 401 m_cursor = wxCursor( wxCURSOR_IBEAM );
13111b2a 402
2830bf19 403 Show( TRUE );
805dd538 404
2830bf19
RR
405 return TRUE;
406}
484e45bf 407
2830bf19
RR
408void wxTextCtrl::CalculateScrollbar()
409{
410 if ((m_windowStyle & wxTE_MULTILINE) == 0) return;
f96aa4d9 411
2830bf19 412 GtkAdjustment *adj = GTK_TEXT(m_text)->vadj;
805dd538 413
2830bf19
RR
414 if (adj->upper - adj->page_size < 0.8)
415 {
416 if (m_vScrollbarVisible)
417 {
034be888 418 gtk_widget_hide( m_vScrollbar );
034be888 419 m_vScrollbarVisible = FALSE;
2830bf19
RR
420 }
421 }
422 else
423 {
424 if (!m_vScrollbarVisible)
425 {
034be888 426 gtk_widget_show( m_vScrollbar );
034be888 427 m_vScrollbarVisible = TRUE;
2830bf19
RR
428 }
429 }
6de97a3b 430}
c801d85f 431
03f38c58 432wxString wxTextCtrl::GetValue() const
c801d85f 433{
223d09f6 434 wxCHECK_MSG( m_text != NULL, wxT(""), wxT("invalid text ctrl") );
8bbe427f 435
2830bf19
RR
436 wxString tmp;
437 if (m_windowStyle & wxTE_MULTILINE)
438 {
439 gint len = gtk_text_get_length( GTK_TEXT(m_text) );
440 char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
dcf924a3 441 tmp = wxString(text,*wxConvCurrent);
2830bf19
RR
442 g_free( text );
443 }
444 else
445 {
dcf924a3 446 tmp = wxString(gtk_entry_get_text( GTK_ENTRY(m_text) ),*wxConvCurrent);
2830bf19
RR
447 }
448 return tmp;
6de97a3b 449}
c801d85f
KB
450
451void wxTextCtrl::SetValue( const wxString &value )
452{
223d09f6 453 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
8bbe427f 454
2830bf19
RR
455 if (m_windowStyle & wxTE_MULTILINE)
456 {
457 gint len = gtk_text_get_length( GTK_TEXT(m_text) );
458 gtk_editable_delete_text( GTK_EDITABLE(m_text), 0, len );
459 len = 0;
05939a81 460#if wxUSE_UNICODE
01041145 461 wxWX2MBbuf tmpbuf = value.mbc_str();
05939a81
OK
462 gtk_editable_insert_text( GTK_EDITABLE(m_text), tmpbuf, strlen(tmpbuf), &len );
463#else
01041145 464 gtk_editable_insert_text( GTK_EDITABLE(m_text), value.mbc_str(), value.Length(), &len );
05939a81 465#endif
2830bf19
RR
466 }
467 else
468 {
01041145 469 gtk_entry_set_text( GTK_ENTRY(m_text), value.mbc_str() );
2830bf19 470 }
f6bcfd97
BP
471
472 // GRG, Jun/2000: Changed this after a lot of discussion in
473 // the lists. wxWindows 2.2 will have a set of flags to
474 // customize this behaviour.
475 SetInsertionPoint(0);
476
477 m_modified = FALSE;
6de97a3b 478}
c801d85f
KB
479
480void wxTextCtrl::WriteText( const wxString &text )
481{
223d09f6 482 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
8bbe427f 483
2df7be7f 484 if (text.IsEmpty()) return;
484e45bf 485
2830bf19
RR
486 if (m_windowStyle & wxTE_MULTILINE)
487 {
291a8f20 488 /* this moves the cursor pos to behind the inserted text */
3358d36e 489 gint len = GTK_EDITABLE(m_text)->current_pos;
13111b2a 490
05939a81 491#if wxUSE_UNICODE
3358d36e 492 wxWX2MBbuf buf = text.mbc_str();
05939a81
OK
493 gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &len );
494#else
2830bf19 495 gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
05939a81 496#endif
3358d36e
VZ
497
498 /* bring editable's cursor uptodate. bug in GTK. */
499 GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
2830bf19
RR
500 }
501 else
502 {
c46554be 503 /* this moves the cursor pos to behind the inserted text */
3358d36e 504 gint len = GTK_EDITABLE(m_text)->current_pos;
05939a81 505#if wxUSE_UNICODE
3358d36e 506 wxWX2MBbuf buf = text.mbc_str();
05939a81
OK
507 gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &len );
508#else
c46554be 509 gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
05939a81 510#endif
3358d36e
VZ
511
512 /* bring editable's cursor uptodate. bug in GTK. */
513 GTK_EDITABLE(m_text)->current_pos += text.Len();
514
515 /* bring entry's cursor uptodate. bug in GTK. */
516 gtk_entry_set_position( GTK_ENTRY(m_text), GTK_EDITABLE(m_text)->current_pos );
2830bf19 517 }
6de97a3b 518}
c801d85f 519
a6e21573
HH
520void wxTextCtrl::AppendText( const wxString &text )
521{
223d09f6 522 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
a6e21573 523
2df7be7f
RR
524 if (text.IsEmpty()) return;
525
a6e21573
HH
526 if (m_windowStyle & wxTE_MULTILINE)
527 {
bb69661b 528 bool hasSpecialAttributes = m_font.Ok() ||
a88acabd 529 m_foregroundColour.Ok();
bb69661b
VZ
530 if ( hasSpecialAttributes )
531 {
532 gtk_text_insert( GTK_TEXT(m_text),
533 m_font.GetInternalFont(),
534 m_foregroundColour.GetColor(),
a88acabd
JS
535 m_backgroundColour.Ok() ?
536 m_backgroundColour.GetColor(): NULL,
c980c992 537 text.mbc_str(), text.length());
bb69661b
VZ
538
539 }
540 else
541 {
542 /* we'll insert at the last position */
543 gint len = gtk_text_get_length( GTK_TEXT(m_text) );
05939a81 544#if wxUSE_UNICODE
bb69661b
VZ
545 wxWX2MBbuf buf = text.mbc_str();
546 gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &len );
05939a81 547#else
bb69661b 548 gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
05939a81 549#endif
bb69661b 550 }
3358d36e
VZ
551
552 /* bring editable's cursor uptodate. bug in GTK. */
553 GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
a6e21573
HH
554 }
555 else
556 {
05939a81 557 gtk_entry_append_text( GTK_ENTRY(m_text), text.mbc_str() );
a6e21573
HH
558 }
559}
560
debe6624 561wxString wxTextCtrl::GetLineText( long lineNo ) const
c801d85f 562{
a81258be
RR
563 if (m_windowStyle & wxTE_MULTILINE)
564 {
565 gint len = gtk_text_get_length( GTK_TEXT(m_text) );
566 char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
567
568 if (text)
569 {
223d09f6 570 wxString buf(wxT(""));
a81258be
RR
571 long i;
572 int currentLine = 0;
573 for (i = 0; currentLine != lineNo && text[i]; i++ )
574 if (text[i] == '\n')
575 currentLine++;
576 // Now get the text
577 int j;
578 for (j = 0; text[i] && text[i] != '\n'; i++, j++ )
579 buf += text[i];
8bbe427f 580
a81258be
RR
581 g_free( text );
582 return buf;
583 }
584 else
585 return wxEmptyString;
586 }
587 else
588 {
589 if (lineNo == 0) return GetValue();
590 return wxEmptyString;
591 }
6de97a3b 592}
c801d85f 593
a81258be
RR
594void wxTextCtrl::OnDropFiles( wxDropFilesEvent &WXUNUSED(event) )
595{
ac0d36b5
HH
596 /* If you implement this, don't forget to update the documentation!
597 * (file docs/latex/wx/text.tex) */
223d09f6 598 wxFAIL_MSG( wxT("wxTextCtrl::OnDropFiles not implemented") );
a81258be 599}
112892b9 600
0efe5ba7 601bool wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const
c801d85f 602{
96385642 603 if ( m_windowStyle & wxTE_MULTILINE )
805dd538 604 {
96385642
VZ
605 wxString text = GetValue();
606
6085b116 607 // cast to prevent warning. But pos really should've been unsigned.
2829d9e3 608 if( (unsigned long)pos > text.Len() )
96385642
VZ
609 return FALSE;
610
ac0d36b5
HH
611 *x=0; // First Col
612 *y=0; // First Line
2829d9e3 613
05939a81
OK
614 const wxChar* stop = text.c_str() + pos;
615 for ( const wxChar *p = text.c_str(); p < stop; p++ )
96385642 616 {
223d09f6 617 if (*p == wxT('\n'))
96385642
VZ
618 {
619 (*y)++;
ac0d36b5 620 *x=0;
96385642
VZ
621 }
622 else
623 (*x)++;
624 }
805dd538 625 }
96385642
VZ
626 else // single line control
627 {
2829d9e3 628 if ( pos <= GTK_ENTRY(m_text)->text_length )
96385642 629 {
ac0d36b5 630 *y = 0;
96385642
VZ
631 *x = pos;
632 }
633 else
634 {
635 // index out of bounds
636 return FALSE;
637 }
8bbe427f 638 }
96385642
VZ
639
640 return TRUE;
6de97a3b 641}
c801d85f 642
e3ca08dd 643long wxTextCtrl::XYToPosition(long x, long y ) const
c801d85f 644{
2830bf19 645 if (!(m_windowStyle & wxTE_MULTILINE)) return 0;
805dd538 646
2830bf19 647 long pos=0;
ac0d36b5 648 for( int i=0; i<y; i++ ) pos += GetLineLength(i) + 1; // one for '\n'
8bbe427f 649
3358d36e 650 pos += x;
2830bf19 651 return pos;
6de97a3b 652}
c801d85f 653
a81258be 654int wxTextCtrl::GetLineLength(long lineNo) const
c801d85f 655{
a81258be
RR
656 wxString str = GetLineText (lineNo);
657 return (int) str.Length();
6de97a3b 658}
c801d85f 659
a81258be 660int wxTextCtrl::GetNumberOfLines() const
c801d85f 661{
2830bf19 662 if (m_windowStyle & wxTE_MULTILINE)
a81258be 663 {
2830bf19
RR
664 gint len = gtk_text_get_length( GTK_TEXT(m_text) );
665 char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
666
667 if (text)
668 {
669 int currentLine = 0;
670 for (int i = 0; i < len; i++ )
96385642 671 {
2830bf19 672 if (text[i] == '\n')
96385642
VZ
673 currentLine++;
674 }
2830bf19 675 g_free( text );
2829d9e3
VZ
676
677 // currentLine is 0 based, add 1 to get number of lines
678 return currentLine + 1;
2830bf19
RR
679 }
680 else
96385642 681 {
2830bf19 682 return 0;
96385642 683 }
a81258be
RR
684 }
685 else
2830bf19 686 {
96385642 687 return 1;
2830bf19 688 }
6de97a3b 689}
c801d85f 690
debe6624 691void wxTextCtrl::SetInsertionPoint( long pos )
c801d85f 692{
223d09f6 693 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
3358d36e
VZ
694
695 if (m_windowStyle & wxTE_MULTILINE)
291a8f20
RR
696 {
697 /* seems to be broken in GTK 1.0.X:
3358d36e
VZ
698 gtk_text_set_point( GTK_TEXT(m_text), (int)pos ); */
699
291a8f20
RR
700 gtk_signal_disconnect_by_func( GTK_OBJECT(m_text),
701 GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
3358d36e 702
291a8f20 703 /* we fake a set_point by inserting and deleting. as the user
3358d36e
VZ
704 isn't supposed to get to know about thos non-sense, we
705 disconnect so that no events are sent to the user program. */
706
291a8f20
RR
707 gint tmp = (gint)pos;
708 gtk_editable_insert_text( GTK_EDITABLE(m_text), " ", 1, &tmp );
3358d36e
VZ
709 gtk_editable_delete_text( GTK_EDITABLE(m_text), tmp-1, tmp );
710
291a8f20
RR
711 gtk_signal_connect( GTK_OBJECT(m_text), "changed",
712 GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
3358d36e
VZ
713
714 /* bring editable's cursor uptodate. another bug in GTK. */
715
716 GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
ac0d36b5 717 }
2830bf19 718 else
291a8f20 719 {
d59051dd 720 gtk_entry_set_position( GTK_ENTRY(m_text), (int)pos );
3358d36e
VZ
721
722 /* bring editable's cursor uptodate. bug in GTK. */
723
b02da6b1 724 GTK_EDITABLE(m_text)->current_pos = (guint32)pos;
291a8f20 725 }
6de97a3b 726}
c801d85f 727
03f38c58 728void wxTextCtrl::SetInsertionPointEnd()
c801d85f 729{
223d09f6 730 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
8bbe427f 731
d59051dd
VZ
732 if (m_windowStyle & wxTE_MULTILINE)
733 SetInsertionPoint(gtk_text_get_length(GTK_TEXT(m_text)));
734 else
735 gtk_entry_set_position( GTK_ENTRY(m_text), -1 );
6de97a3b 736}
c801d85f 737
debe6624 738void wxTextCtrl::SetEditable( bool editable )
c801d85f 739{
223d09f6 740 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
8bbe427f 741
2830bf19
RR
742 if (m_windowStyle & wxTE_MULTILINE)
743 gtk_text_set_editable( GTK_TEXT(m_text), editable );
744 else
745 gtk_entry_set_editable( GTK_ENTRY(m_text), editable );
6de97a3b 746}
c801d85f 747
68df5777
RR
748bool wxTextCtrl::Enable( bool enable )
749{
750 if (!wxWindowBase::Enable(enable))
751 {
752 // nothing to do
753 return FALSE;
754 }
f6bcfd97 755
68df5777
RR
756 if (m_windowStyle & wxTE_MULTILINE)
757 {
758 gtk_text_set_editable( GTK_TEXT(m_text), enable );
759 }
760 else
761 {
762 gtk_widget_set_sensitive( m_text, enable );
763 }
764
765 return TRUE;
766}
767
0efe5ba7
VZ
768void wxTextCtrl::DiscardEdits()
769{
770 m_modified = FALSE;
771}
772
debe6624 773void wxTextCtrl::SetSelection( long from, long to )
c801d85f 774{
223d09f6 775 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
8bbe427f 776
a1f79c1e
VZ
777 if ( (m_windowStyle & wxTE_MULTILINE) &&
778 !GTK_TEXT(m_text)->line_start_cache )
779 {
780 // tell the programmer that it didn't work
781 wxLogDebug(_T("Can't call SetSelection() before realizing the control"));
782 return;
783 }
784
2830bf19 785 gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
6de97a3b 786}
c801d85f 787
910f1f8c 788void wxTextCtrl::ShowPosition( long WXUNUSED(pos) )
c801d85f 789{
910f1f8c 790// SetInsertionPoint( pos );
6de97a3b 791}
c801d85f 792
03f38c58 793long wxTextCtrl::GetInsertionPoint() const
c801d85f 794{
223d09f6 795 wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
8bbe427f 796
2830bf19 797 return (long) GTK_EDITABLE(m_text)->current_pos;
6de97a3b 798}
c801d85f 799
03f38c58 800long wxTextCtrl::GetLastPosition() const
c801d85f 801{
223d09f6 802 wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
8bbe427f 803
2830bf19
RR
804 int pos = 0;
805 if (m_windowStyle & wxTE_MULTILINE)
806 pos = gtk_text_get_length( GTK_TEXT(m_text) );
807 else
808 pos = GTK_ENTRY(m_text)->text_length;
805dd538 809
ac0d36b5 810 return (long)pos;
6de97a3b 811}
c801d85f 812
debe6624 813void wxTextCtrl::Remove( long from, long to )
c801d85f 814{
223d09f6 815 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
8bbe427f 816
2830bf19 817 gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
6de97a3b 818}
c801d85f 819
debe6624 820void wxTextCtrl::Replace( long from, long to, const wxString &value )
c801d85f 821{
223d09f6 822 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
8bbe427f 823
2830bf19 824 gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
bb69661b 825
2df7be7f
RR
826 if (!value.IsEmpty())
827 {
828 gint pos = (gint)from;
05939a81 829#if wxUSE_UNICODE
2df7be7f
RR
830 wxWX2MBbuf buf = value.mbc_str();
831 gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &pos );
05939a81 832#else
2df7be7f 833 gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos );
05939a81 834#endif
2df7be7f 835 }
6de97a3b 836}
c801d85f 837
03f38c58 838void wxTextCtrl::Cut()
c801d85f 839{
223d09f6 840 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
8bbe427f 841
d345e841 842#if (GTK_MINOR_VERSION > 0)
2830bf19 843 gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) );
75ed1d15 844#else
2830bf19 845 gtk_editable_cut_clipboard( GTK_EDITABLE(m_text), 0 );
75ed1d15 846#endif
6de97a3b 847}
c801d85f 848
03f38c58 849void wxTextCtrl::Copy()
c801d85f 850{
223d09f6 851 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
8bbe427f 852
d345e841 853#if (GTK_MINOR_VERSION > 0)
2830bf19 854 gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) );
75ed1d15 855#else
2830bf19 856 gtk_editable_copy_clipboard( GTK_EDITABLE(m_text), 0 );
75ed1d15 857#endif
6de97a3b 858}
c801d85f 859
03f38c58 860void wxTextCtrl::Paste()
c801d85f 861{
223d09f6 862 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
8bbe427f 863
d345e841 864#if (GTK_MINOR_VERSION > 0)
2830bf19 865 gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) );
75ed1d15 866#else
2830bf19 867 gtk_editable_paste_clipboard( GTK_EDITABLE(m_text), 0 );
75ed1d15 868#endif
6de97a3b 869}
c801d85f 870
ca8b28f2
JS
871bool wxTextCtrl::CanCopy() const
872{
873 // Can copy if there's a selection
874 long from, to;
875 GetSelection(& from, & to);
876 return (from != to) ;
877}
878
879bool wxTextCtrl::CanCut() const
880{
881 // Can cut if there's a selection
882 long from, to;
883 GetSelection(& from, & to);
dbf28859 884 return (from != to) && (IsEditable());
ca8b28f2
JS
885}
886
887bool wxTextCtrl::CanPaste() const
888{
889 return IsEditable() ;
890}
891
892// Undo/redo
893void wxTextCtrl::Undo()
894{
895 // TODO
223d09f6 896 wxFAIL_MSG( wxT("wxTextCtrl::Undo not implemented") );
ca8b28f2
JS
897}
898
899void wxTextCtrl::Redo()
900{
901 // TODO
223d09f6 902 wxFAIL_MSG( wxT("wxTextCtrl::Redo not implemented") );
ca8b28f2
JS
903}
904
905bool wxTextCtrl::CanUndo() const
906{
907 // TODO
223d09f6 908 wxFAIL_MSG( wxT("wxTextCtrl::CanUndo not implemented") );
ca8b28f2
JS
909 return FALSE;
910}
911
912bool wxTextCtrl::CanRedo() const
913{
914 // TODO
223d09f6 915 wxFAIL_MSG( wxT("wxTextCtrl::CanRedo not implemented") );
ca8b28f2
JS
916 return FALSE;
917}
918
919// If the return values from and to are the same, there is no
920// selection.
2d4cc5b6 921void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const
ca8b28f2 922{
223d09f6 923 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
bb69661b 924
2d4cc5b6
VZ
925 long from, to;
926 if ( !(GTK_EDITABLE(m_text)->has_selection) )
05060eeb 927 {
2d4cc5b6
VZ
928 from =
929 to = GetInsertionPoint();
930 }
931 else // got selection
932 {
933 from = (long) GTK_EDITABLE(m_text)->selection_start_pos;
934 to = (long) GTK_EDITABLE(m_text)->selection_end_pos;
935
936 if ( from > to )
937 {
938 // exchange them to be compatible with wxMSW
939 long tmp = from;
940 from = to;
941 to = tmp;
942 }
05060eeb 943 }
bb69661b 944
2d4cc5b6
VZ
945 if ( fromOut )
946 *fromOut = from;
947 if ( toOut )
948 *toOut = to;
ca8b28f2
JS
949}
950
951bool wxTextCtrl::IsEditable() const
952{
223d09f6 953 wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") );
05060eeb
RR
954
955 return GTK_EDITABLE(m_text)->editable;
ca8b28f2
JS
956}
957
0efe5ba7
VZ
958bool wxTextCtrl::IsModified() const
959{
960 return m_modified;
961}
962
03f38c58 963void wxTextCtrl::Clear()
c801d85f 964{
223d09f6 965 SetValue( wxT("") );
6de97a3b 966}
c801d85f 967
903f689b 968void wxTextCtrl::OnChar( wxKeyEvent &key_event )
c801d85f 969{
223d09f6 970 wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
805dd538 971
2830bf19
RR
972 if ((key_event.KeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER))
973 {
974 wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
975 event.SetEventObject(this);
f6bcfd97 976 event.SetString(GetValue());
2830bf19
RR
977 if (GetEventHandler()->ProcessEvent(event)) return;
978 }
903f689b 979
da048e3d
RR
980 if ((key_event.KeyCode() == WXK_RETURN) && !(m_windowStyle & wxTE_MULTILINE))
981 {
982 wxWindow *top_frame = m_parent;
8487f887 983 while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
da048e3d 984 top_frame = top_frame->GetParent();
13111b2a
VZ
985 GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
986
987 if (window->default_widget)
da048e3d
RR
988 {
989 gtk_widget_activate (window->default_widget);
13111b2a
VZ
990 return;
991 }
da048e3d
RR
992 }
993
2830bf19 994 key_event.Skip();
6de97a3b 995}
c801d85f 996
03f38c58 997GtkWidget* wxTextCtrl::GetConnectWidget()
e3e65dac 998{
ae0bdb01 999 return GTK_WIDGET(m_text);
6de97a3b 1000}
e3e65dac 1001
903f689b
RR
1002bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window )
1003{
ae0bdb01
RR
1004 if (m_windowStyle & wxTE_MULTILINE)
1005 return (window == GTK_TEXT(m_text)->text_area);
1006 else
1007 return (window == GTK_ENTRY(m_text)->text_area);
903f689b 1008}
e3e65dac 1009
bb69661b
VZ
1010// the font will change for subsequent text insertiongs
1011bool wxTextCtrl::SetFont( const wxFont &font )
868a2826 1012{
223d09f6 1013 wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") );
8bbe427f 1014
bb69661b
VZ
1015 if ( !wxWindowBase::SetFont(font) )
1016 {
1017 // font didn't change, nothing to do
1018 return FALSE;
1019 }
1020
1021 if ( m_windowStyle & wxTE_MULTILINE )
1022 {
01041145 1023 m_updateFont = TRUE;
bb69661b 1024
01041145 1025 ChangeFontGlobally();
bb69661b
VZ
1026 }
1027
1028 return TRUE;
58614078
RR
1029}
1030
01041145
VZ
1031void wxTextCtrl::ChangeFontGlobally()
1032{
1033 // this method is very inefficient and hence should be called as rarely as
1034 // possible!
1035 wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE) && m_updateFont,
1036 _T("shouldn't be called for single line controls") );
1037
1038 wxString value = GetValue();
1039 if ( !value.IsEmpty() )
1040 {
1041 Clear();
1042 AppendText(value);
1043
1044 m_updateFont = FALSE;
1045 }
1046}
1047
1048void wxTextCtrl::UpdateFontIfNeeded()
1049{
1050 if ( m_updateFont )
1051 ChangeFontGlobally();
1052}
1053
f03fc89f 1054bool wxTextCtrl::SetForegroundColour( const wxColour &WXUNUSED(colour) )
58614078 1055{
223d09f6 1056 wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") );
8bbe427f 1057
ae0bdb01 1058 // doesn't work
f03fc89f 1059 return FALSE;
868a2826 1060}
e3e65dac 1061
f03fc89f 1062bool wxTextCtrl::SetBackgroundColour( const wxColour &colour )
68dda785 1063{
223d09f6 1064 wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") );
a81258be 1065
ae0bdb01 1066 wxControl::SetBackgroundColour( colour );
3358d36e 1067
f03fc89f
VZ
1068 if (!m_widget->window)
1069 return FALSE;
8bbe427f 1070
ae0bdb01 1071 wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
805dd538
VZ
1072 if (sysbg.Red() == colour.Red() &&
1073 sysbg.Green() == colour.Green() &&
ae0bdb01
RR
1074 sysbg.Blue() == colour.Blue())
1075 {
f03fc89f 1076 return FALSE; // FIXME or TRUE?
805dd538
VZ
1077 }
1078
f03fc89f
VZ
1079 if (!m_backgroundColour.Ok())
1080 return FALSE;
8bbe427f 1081
ae0bdb01
RR
1082 if (m_windowStyle & wxTE_MULTILINE)
1083 {
1084 GdkWindow *window = GTK_TEXT(m_text)->text_area;
f03fc89f
VZ
1085 if (!window)
1086 return FALSE;
ae0bdb01
RR
1087 m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
1088 gdk_window_set_background( window, m_backgroundColour.GetColor() );
1089 gdk_window_clear( window );
1090 }
f03fc89f
VZ
1091
1092 return TRUE;
58614078
RR
1093}
1094
1095void wxTextCtrl::ApplyWidgetStyle()
1096{
ae0bdb01
RR
1097 if (m_windowStyle & wxTE_MULTILINE)
1098 {
2830bf19 1099 // how ?
805dd538 1100 }
ae0bdb01
RR
1101 else
1102 {
1103 SetWidgetStyle();
1104 gtk_widget_set_style( m_text, m_widgetStyle );
1105 }
68dda785 1106}
f96aa4d9 1107
e702ff0f
JS
1108void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
1109{
1110 Cut();
1111}
1112
1113void wxTextCtrl::OnCopy(wxCommandEvent& WXUNUSED(event))
1114{
1115 Copy();
1116}
1117
1118void wxTextCtrl::OnPaste(wxCommandEvent& WXUNUSED(event))
1119{
1120 Paste();
1121}
1122
1123void wxTextCtrl::OnUndo(wxCommandEvent& WXUNUSED(event))
1124{
1125 Undo();
1126}
1127
1128void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event))
1129{
1130 Redo();
1131}
1132
1133void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
1134{
1135 event.Enable( CanCut() );
1136}
1137
1138void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
1139{
1140 event.Enable( CanCopy() );
1141}
1142
1143void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
1144{
1145 event.Enable( CanPaste() );
1146}
1147
1148void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
1149{
1150 event.Enable( CanUndo() );
1151}
1152
1153void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
1154{
1155 event.Enable( CanRedo() );
1156}
65045edd
RR
1157
1158void wxTextCtrl::OnInternalIdle()
1159{
1160 wxCursor cursor = m_cursor;
1161 if (g_globalCursor.Ok()) cursor = g_globalCursor;
1162
307f16e8 1163 if (cursor.Ok())
65045edd 1164 {
65045edd 1165 GdkWindow *window = (GdkWindow*) NULL;
13111b2a 1166 if (HasFlag(wxTE_MULTILINE))
65045edd
RR
1167 window = GTK_TEXT(m_text)->text_area;
1168 else
1169 window = GTK_ENTRY(m_text)->text_area;
13111b2a 1170
65045edd
RR
1171 if (window)
1172 gdk_window_set_cursor( window, cursor.GetCursor() );
1173
1174 if (!g_globalCursor.Ok())
1175 cursor = *wxSTANDARD_CURSOR;
1176
1177 window = m_widget->window;
247e5b16 1178 if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget)))
65045edd
RR
1179 gdk_window_set_cursor( window, cursor.GetCursor() );
1180 }
26bf1ce0
VZ
1181
1182 UpdateWindowUI();
65045edd 1183}
f68586e5
VZ
1184
1185wxSize wxTextCtrl::DoGetBestSize() const
1186{
1187 // FIXME should be different for multi-line controls...
0279e844
RR
1188 wxSize ret( wxControl::DoGetBestSize() );
1189 return wxSize(80, ret.y);
f68586e5 1190}