X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6964cbbac953c53157236e81c251f0228ac6b051..b3d006af0fca9ba3679f092016cf149c9f6fd06c:/src/gtk/textctrl.cpp diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 40329ca9fa..b9671b2850 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -17,17 +17,16 @@ #include "wx/log.h" #include "wx/utils.h" #include "wx/panel.h" + #include "wx/settings.h" + #include "wx/math.h" #endif -#include "wx/math.h" -#include "wx/settings.h" #include "wx/strconv.h" #include "wx/fontutil.h" // for wxNativeFontInfo (GetNativeFontInfo()) #include #include #include -#include "wx/math.h" #include "wx/gtk/private.h" #include @@ -105,7 +104,7 @@ static void wxGtkTextApplyTagsFromAttr(GtkTextBuffer *text_buffer, if (attr.HasTextColour()) { - GdkColor *colFg = attr.GetTextColour().GetColor(); + const GdkColor *colFg = attr.GetTextColour().GetColor(); g_snprintf(buf, sizeof(buf), "WXFORECOLOR %d %d %d", colFg->red, colFg->green, colFg->blue); tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ), @@ -118,7 +117,7 @@ static void wxGtkTextApplyTagsFromAttr(GtkTextBuffer *text_buffer, if (attr.HasBackgroundColour()) { - GdkColor *colBg = attr.GetBackgroundColour().GetColor(); + const GdkColor *colBg = attr.GetBackgroundColour().GetColor(); g_snprintf(buf, sizeof(buf), "WXBACKCOLOR %d %d %d", colBg->red, colBg->green, colBg->blue); tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ), @@ -470,7 +469,7 @@ gtk_text_changed_callback( GtkWidget *widget, wxTextCtrl *win ) // common part of the event handlers below static void handle_text_clipboard_callback( GtkWidget *widget, wxTextCtrl *win, - wxEventType eventType, const gchar * signal_name) + wxEventType eventType, const gchar * signal_name) { wxClipboardTextEvent event( eventType, win->GetId() ); event.SetEventObject( win ); @@ -478,7 +477,7 @@ handle_text_clipboard_callback( GtkWidget *widget, wxTextCtrl *win, { // don't let the default processing to take place if we did something // ourselves in the event handler - g_signal_stop_emission_by_name (widget, signal_name); + g_signal_stop_emission_by_name (widget, signal_name); } } @@ -486,22 +485,22 @@ extern "C" { static void gtk_copy_clipboard_callback( GtkWidget *widget, wxTextCtrl *win ) { - handle_text_clipboard_callback( - widget, win, wxEVT_COMMAND_TEXT_COPY, "copy-clipboard" ); + handle_text_clipboard_callback( + widget, win, wxEVT_COMMAND_TEXT_COPY, "copy-clipboard" ); } static void gtk_cut_clipboard_callback( GtkWidget *widget, wxTextCtrl *win ) { - handle_text_clipboard_callback( - widget, win, wxEVT_COMMAND_TEXT_CUT, "cut-clipboard" ); + handle_text_clipboard_callback( + widget, win, wxEVT_COMMAND_TEXT_CUT, "cut-clipboard" ); } static void gtk_paste_clipboard_callback( GtkWidget *widget, wxTextCtrl *win ) { - handle_text_clipboard_callback( - widget, win, wxEVT_COMMAND_TEXT_PASTE, "paste-clipboard" ); + handle_text_clipboard_callback( + widget, win, wxEVT_COMMAND_TEXT_PASTE, "paste-clipboard" ); } } @@ -522,9 +521,9 @@ gtk_text_exposed_callback( GtkWidget *widget, GdkEventExpose *event, wxTextCtrl // wxTextCtrl //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl,wxControl) +IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase) -BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) +BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase) EVT_CHAR(wxTextCtrl::OnChar) EVT_MENU(wxID_CUT, wxTextCtrl::OnCut) @@ -618,6 +617,8 @@ bool wxTextCtrl::Create( wxWindow *parent, m_widget = gtk_scrolled_window_new( NULL, NULL ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( m_widget ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); + // for ScrollLines/Pages + m_scrollBar[1] = (GtkRange*)((GtkScrolledWindow*)m_widget)->vscrollbar; // Insert view into scrolled window gtk_container_add( GTK_CONTAINER(m_widget), m_text ); @@ -670,7 +671,6 @@ bool wxTextCtrl::Create( wxWindow *parent, if (multi_line) { gtk_widget_show(m_text); - SetVScrollAdjustment(gtk_scrolled_window_get_vadjustment((GtkScrolledWindow*)m_widget)); } if (!value.empty()) @@ -943,19 +943,25 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const if ( m_windowStyle & wxTE_MULTILINE ) { GtkTextIter iter; - gtk_text_buffer_get_iter_at_offset(m_buffer, &iter, pos); - if (gtk_text_iter_is_end(&iter)) + + if (pos > GetLastPosition()) return false; - *y = gtk_text_iter_get_line(&iter); - *x = gtk_text_iter_get_line_offset(&iter); + gtk_text_buffer_get_iter_at_offset(m_buffer, &iter, pos); + + if ( y ) + *y = gtk_text_iter_get_line(&iter); + if ( x ) + *x = gtk_text_iter_get_line_offset(&iter); } else // single line control { if ( pos <= GTK_ENTRY(m_text)->text_length ) { - *y = 0; - *x = pos; + if ( y ) + *y = 0; + if ( x ) + *x = pos; } else {