// Purpose:
// Author: Robert Roebling
// Id: $Id$
-// Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin
+// Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin, 2005 Mart Raudsepp
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
if (!name || strncmp(name, prefix, strlen(prefix)))
// anonymous tag or not starting with prefix - don't remove
- g_signal_stop_emission_by_name(buffer, "remove_tag");
+ g_signal_stop_emission_by_name (buffer, "remove_tag");
g_free(name);
}
static gchar buf[1024];
GtkTextTag *tag;
- gulong remove_handler_id = g_signal_connect( text_buffer, "remove_tag",
- G_CALLBACK(wxGtkOnRemoveTag), gpointer("WX"));
+ gulong remove_handler_id = g_signal_connect (text_buffer, "remove_tag",
+ G_CALLBACK (wxGtkOnRemoveTag), gpointer("WX"));
gtk_text_buffer_remove_all_tags(text_buffer, start, end);
- g_signal_handler_disconnect( text_buffer, remove_handler_id );
+ g_signal_handler_disconnect (text_buffer, remove_handler_id);
if (attr.HasFont())
{
gtk_text_iter_get_line(start) );
gtk_text_iter_forward_line(¶_end);
- remove_handler_id = g_signal_connect( text_buffer, "remove_tag",
+ remove_handler_id = g_signal_connect (text_buffer, "remove_tag",
G_CALLBACK(wxGtkOnRemoveTag),
gpointer("WXALIGNMENT"));
gtk_text_buffer_remove_all_tags( text_buffer, ¶_start, ¶_end );
- g_signal_handler_disconnect( text_buffer, remove_handler_id );
+ g_signal_handler_disconnect (text_buffer, remove_handler_id);
GtkJustification align;
switch (attr.GetAlignment())
if ( entry->text_length == entry->text_max_length )
{
// we don't need to run the base class version at all
- gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text");
+ g_signal_stop_emission_by_name (editable, "insert_text");
// remember that the next changed signal is to be ignored to avoid
// generating a dummy wxEVT_COMMAND_TEXT_UPDATED event
gpointer textctrl)
{
if(tag == gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buffer), "wxUrl"))
- g_signal_stop_emission_by_name(buffer, "apply_tag");
+ g_signal_stop_emission_by_name (buffer, "apply_tag");
}
}
if(n < WXSIZEOF(URIPrefixes))
{
- gulong signal_id = g_signal_handler_find(buffer,
- (GSignalMatchType) (G_SIGNAL_MATCH_FUNC),
- 0, 0, NULL,
- (gpointer)au_apply_tag_callback, NULL);
+ gulong signal_id = g_signal_handler_find (buffer,
+ (GSignalMatchType) (G_SIGNAL_MATCH_FUNC),
+ 0, 0, NULL,
+ (gpointer)au_apply_tag_callback, NULL);
- g_signal_handler_block(buffer, signal_id);
+ g_signal_handler_block (buffer, signal_id);
gtk_text_buffer_apply_tag(buffer, tag, &start, &end);
- g_signal_handler_unblock(buffer, signal_id);
+ g_signal_handler_unblock (buffer, signal_id);
}
}
}
PostCreation(size);
if (multi_line)
+ {
gtk_widget_show(m_text);
+ SetVScrollAdjustment(gtk_scrolled_window_get_vadjustment((GtkScrolledWindow*)m_widget));
+ }
if (!value.empty())
{
if (style & wxTE_READONLY)
{
if (!multi_line)
- gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE );
+ gtk_editable_set_editable( GTK_EDITABLE(m_text), FALSE );
else
gtk_text_view_set_editable( GTK_TEXT_VIEW( m_text), FALSE);
}
// We want to be notified about text changes.
if (multi_line)
{
- g_signal_connect( G_OBJECT(m_buffer), "changed",
- GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+ g_signal_connect (m_buffer, "changed",
+ G_CALLBACK (gtk_text_changed_callback), this);
// .. and handle URLs on multi-line controls with wxTE_AUTO_URL style
if (style & wxTE_AUTO_URL)
NULL);
// Check for URLs after each text change
- g_signal_connect_after( G_OBJECT(m_buffer), "insert_text",
- GTK_SIGNAL_FUNC(au_insert_text_callback), (gpointer)this);
- g_signal_connect_after( G_OBJECT(m_buffer), "delete_range",
- GTK_SIGNAL_FUNC(au_delete_range_callback), (gpointer)this);
+ g_signal_connect_after (m_buffer, "insert_text",
+ G_CALLBACK (au_insert_text_callback), this);
+ g_signal_connect_after (m_buffer, "delete_range",
+ G_CALLBACK (au_delete_range_callback), this);
// Block all wxUrl tag applying unless we do it ourselves, in which case we
// block this callback temporarily. This takes care of gtk+ internal
// which is undesired because only a part of the URL might be copied.
// The insert-text signal emitted inside it will take care of newly formed
// or wholly copied URLs.
- g_signal_connect( G_OBJECT(m_buffer), "apply_tag",
- GTK_SIGNAL_FUNC(au_apply_tag_callback), NULL);
+ g_signal_connect (m_buffer, "apply_tag",
+ G_CALLBACK (au_apply_tag_callback), NULL);
// Check for URLs in the initial string passed to Create
gtk_text_buffer_get_start_iter(m_buffer, &start);
}
else
{
- gtk_signal_connect( GTK_OBJECT(m_text), "changed",
- GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+ g_signal_connect (m_text, "changed",
+ G_CALLBACK (gtk_text_changed_callback), this);
}
m_cursor = wxCursor( wxCURSOR_IBEAM );
gtk_editable_delete_selection( GTK_EDITABLE(m_text) );
// This moves the cursor pos to behind the inserted text.
- gint len = GET_EDITABLE_POS(m_text);
+ gint len = gtk_editable_get_position(GTK_EDITABLE(m_text));
#if wxUSE_UNICODE
wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) );
gtk_editable_insert_text( GTK_EDITABLE(m_text), buffer, strlen(buffer), &len );
// Bring entry's cursor uptodate.
- gtk_entry_set_position( GTK_ENTRY(m_text), len );
+ gtk_editable_set_position( GTK_EDITABLE(m_text), len );
}
m_modified = oldModified;
}
else
{
- gtk_entry_set_position( GTK_ENTRY(m_text), (int)pos );
-
- // Bring editable's cursor uptodate. Bug in GTK.
- SET_EDITABLE_POS(m_text, (guint32)pos);
+ // FIXME: Is the editable's cursor really uptodate without double set_position in GTK2?
+ gtk_editable_set_position(GTK_EDITABLE(m_text), int(pos));
}
}
}
else
{
- gtk_entry_set_position( GTK_ENTRY(m_text), -1 );
+ gtk_editable_set_position( GTK_EDITABLE(m_text), -1 );
}
}
}
else
{
- gtk_entry_set_editable( GTK_ENTRY(m_text), editable );
+ gtk_editable_set_editable( GTK_EDITABLE(m_text), editable );
}
}
// we shouldn't check anything any more
if ( len )
{
- gtk_signal_connect( GTK_OBJECT(m_text),
- "insert_text",
- GTK_SIGNAL_FUNC(gtk_insert_text_callback),
- (gpointer)this);
+ g_signal_connect (m_text, "insert_text",
+ G_CALLBACK (gtk_insert_text_callback), this);
}
else // no checking
{
- gtk_signal_disconnect_by_func
- (
- GTK_OBJECT(m_text),
- GTK_SIGNAL_FUNC(gtk_insert_text_callback),
- (gpointer)this
- );
+ g_signal_handlers_disconnect_by_func (m_text,
+ (gpointer) gtk_insert_text_callback, this);
}
}
}
}
else
{
- return (long) GET_EDITABLE_POS(m_text);
+ return (long) gtk_editable_get_position(GTK_EDITABLE(m_text));
}
}
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
if (m_windowStyle & wxTE_MULTILINE)
- g_signal_emit_by_name(m_text, "cut-clipboard");
+ g_signal_emit_by_name (m_text, "cut-clipboard");
else
- gtk_editable_cut_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG);
+ gtk_editable_cut_clipboard(GTK_EDITABLE(m_text));
}
void wxTextCtrl::Copy()
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
if (m_windowStyle & wxTE_MULTILINE)
- g_signal_emit_by_name(m_text, "copy-clipboard");
+ g_signal_emit_by_name (m_text, "copy-clipboard");
else
- gtk_editable_copy_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG);
+ gtk_editable_copy_clipboard(GTK_EDITABLE(m_text));
}
void wxTextCtrl::Paste()
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
if (m_windowStyle & wxTE_MULTILINE)
- g_signal_emit_by_name(m_text, "paste-clipboard");
+ g_signal_emit_by_name (m_text, "paste-clipboard");
else
- gtk_editable_paste_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG);
+ gtk_editable_paste_clipboard(GTK_EDITABLE(m_text));
}
// Undo/redo
if ( !m_frozenness++ )
{
// freeze textview updates and remove buffer
- g_signal_connect( G_OBJECT(m_text), "expose_event",
- GTK_SIGNAL_FUNC(gtk_text_exposed_callback), (gpointer)this);
- g_signal_connect( G_OBJECT(m_widget), "expose_event",
- GTK_SIGNAL_FUNC(gtk_text_exposed_callback), (gpointer)this);
+ g_signal_connect (m_text, "expose_event",
+ G_CALLBACK (gtk_text_exposed_callback), this);
+ g_signal_connect (m_widget, "expose_event",
+ G_CALLBACK (gtk_text_exposed_callback), this);
gtk_widget_set_sensitive(m_widget, false);
g_object_ref(m_buffer);
gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), gtk_text_buffer_new(NULL));
gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), m_buffer);
g_object_unref(m_buffer);
gtk_widget_set_sensitive(m_widget, true);
- g_signal_handlers_disconnect_by_func(m_widget, (gpointer)gtk_text_exposed_callback, this);
- g_signal_handlers_disconnect_by_func(m_text, (gpointer)gtk_text_exposed_callback, this);
+ g_signal_handlers_disconnect_by_func (m_widget,
+ (gpointer) gtk_text_exposed_callback, this);
+ g_signal_handlers_disconnect_by_func (m_text,
+ (gpointer) gtk_text_exposed_callback, this);
}
}
}
GetEventHandler()->ProcessEvent(url_event);
}
-// ----------------------------------------------------------------------------
-// scrolling
-// ----------------------------------------------------------------------------
-
-GtkAdjustment *wxTextCtrl::GetVAdj() const
-{
- if ( !IsMultiLine() )
- return NULL;
-
- return gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(m_widget));
-}
-
-bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff)
-{
- float value = adj->value + diff;
-
- if ( value < 0 )
- value = 0;
-
- float upper = adj->upper - adj->page_size;
- if ( value > upper )
- value = upper;
-
- // did we noticeably change the scroll position?
- if ( fabs(adj->value - value) < 0.2 )
- {
- // well, this is what Robert does in wxScrollBar, so it must be good...
- return false;
- }
-
- adj->value = value;
-
- gtk_adjustment_value_changed(GTK_ADJUSTMENT(adj));
-
- return true;
-}
-
-bool wxTextCtrl::ScrollLines(int lines)
-{
- GtkAdjustment *adj = GetVAdj();
- if ( !adj )
- return false;
-
- int diff = (int)ceil(lines*adj->step_increment);
-
- return DoScroll(adj, diff);
-}
-
-bool wxTextCtrl::ScrollPages(int pages)
-{
- GtkAdjustment *adj = GetVAdj();
- if ( !adj )
- return false;
-
- return DoScroll(adj, (int)ceil(pages*adj->page_increment));
-}
-
-
// static
wxVisualAttributes
wxTextCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))