]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/textctrl.cpp
added translation of mac system into language, adaption of search paths
[wxWidgets.git] / src / gtk / textctrl.cpp
index 23abc60f42397fae0b1a382dd5f662542c3e0f3a..f16643b0c74218275e3ac7100832e24fa35324e6 100644 (file)
@@ -21,6 +21,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <ctype.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <ctype.h>
+#include <math.h>               // for fabs
 
 #include "gdk/gdk.h"
 #include "gtk/gtk.h"
 
 #include "gdk/gdk.h"
 #include "gtk/gtk.h"
@@ -96,11 +97,9 @@ static gint gtk_text_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(ev
 
     g_focusWindow = win;
 
 
     g_focusWindow = win;
 
-    wxPanel *panel = wxDynamicCast(win->GetParent(), wxPanel);
-    if (panel)
-    {
-        panel->SetLastFocus(win);
-    }
+    // notify the parent that we got the focus
+    wxChildFocusEvent eventFocus(win);
+    (void)win->GetEventHandler()->ProcessEvent(eventFocus);
 
 #ifdef HAVE_XIM
     if (win->m_ic)
 
 #ifdef HAVE_XIM
     if (win->m_ic)
@@ -123,7 +122,6 @@ static gint gtk_text_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(ev
 
     if (win->GetEventHandler()->ProcessEvent( event ))
     {
 
     if (win->GetEventHandler()->ProcessEvent( event ))
     {
-        gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus_in_event" );
         return TRUE;
     }
 
         return TRUE;
     }
 
@@ -178,7 +176,6 @@ static gint gtk_text_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(e
 
     if (win->GetEventHandler()->ProcessEvent( event ))
     {
 
     if (win->GetEventHandler()->ProcessEvent( event ))
     {
-        gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus_out_event" );
         return TRUE;
     }
 
         return TRUE;
     }
 
@@ -1078,10 +1075,10 @@ void wxTextCtrl::ChangeFontGlobally()
     wxString value = GetValue();
     if ( !value.IsEmpty() )
     {
     wxString value = GetValue();
     if ( !value.IsEmpty() )
     {
+        m_updateFont = FALSE;
+
         Clear();
         AppendText(value);
         Clear();
         AppendText(value);
-
-        m_updateFont = FALSE;
     }
 }
 
     }
 }
 
@@ -1296,6 +1293,10 @@ wxSize wxTextCtrl::DoGetBestSize() const
     return wxSize(80, ret.y);
 }
 
     return wxSize(80, ret.y);
 }
 
+// ----------------------------------------------------------------------------
+// freeze/thaw
+// ----------------------------------------------------------------------------
+
 void wxTextCtrl::Freeze()
 {
     if ( HasFlag(wxTE_MULTILINE) )
 void wxTextCtrl::Freeze()
 {
     if ( HasFlag(wxTE_MULTILINE) )
@@ -1308,6 +1309,64 @@ void wxTextCtrl::Thaw()
 {
     if ( HasFlag(wxTE_MULTILINE) )
     {
 {
     if ( HasFlag(wxTE_MULTILINE) )
     {
+        GTK_TEXT(m_text)->vadj->value = 0.0;
+
         gtk_text_thaw(GTK_TEXT(m_text));
     }
 }
         gtk_text_thaw(GTK_TEXT(m_text));
     }
 }
+
+// ----------------------------------------------------------------------------
+// scrolling
+// ----------------------------------------------------------------------------
+
+GtkAdjustment *wxTextCtrl::GetVAdj() const
+{
+    return HasFlag(wxTE_MULTILINE) ? GTK_TEXT(m_text)->vadj : NULL;
+}
+
+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_signal_emit_by_name(GTK_OBJECT(adj), "value_changed");
+
+    return TRUE;
+}
+
+bool wxTextCtrl::ScrollLines(int lines)
+{
+    GtkAdjustment *adj = GetVAdj();
+    if ( !adj )
+        return FALSE;
+
+    // this is hardcoded to 10 in GTK+ 1.2 (great idea)
+    static const int KEY_SCROLL_PIXELS = 10;
+
+    return DoScroll(adj, lines*KEY_SCROLL_PIXELS);
+}
+
+bool wxTextCtrl::ScrollPages(int pages)
+{
+    GtkAdjustment *adj = GetVAdj();
+    if ( !adj )
+        return FALSE;
+
+    return DoScroll(adj, (int)ceil(pages*adj->page_increment));
+}
+