]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/button.cpp
fix for infinite loop in wxFileConfig when reading from input stream fails (patch...
[wxWidgets.git] / src / gtk / button.cpp
index fc88afb78903bb00dda6c05982e5b913b8cf5670..51caf3b9dcbc625fa09e0ebc215b8186ffcd973b 100644 (file)
@@ -7,10 +7,13 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
 #pragma implementation "button.h"
 #endif
 
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
 #include "wx/defs.h"
 
 #if wxUSE_BUTTON
@@ -107,6 +110,21 @@ bool wxButton::Create(  wxWindow *parent, wxWindowID id, const wxString &label,
 
     m_widget = gtk_button_new_with_label("");
 
+    float x_alignment = 0.5;
+    if (HasFlag(wxBU_LEFT))
+        x_alignment = 0.0;
+    else if (HasFlag(wxBU_RIGHT))
+        x_alignment = 1.0;
+
+    float y_alignment = 0.5;
+    if (HasFlag(wxBU_TOP))
+        y_alignment = 0.0;
+    else if (HasFlag(wxBU_BOTTOM))
+        y_alignment = 1.0;
+
+    gtk_misc_set_alignment (GTK_MISC (BUTTON_CHILD (m_widget)),
+                            x_alignment, y_alignment);
+
     SetLabel( label );
 
     if (style & wxNO_BORDER)
@@ -160,7 +178,12 @@ void wxButton::SetLabel( const wxString &label )
 
     wxControl::SetLabel( label );
 
+#ifdef __WXGTK20__
+    wxString label2 = PrepareLabelMnemonics( label );
+    gtk_label_set_text_with_mnemonic( GTK_LABEL( BUTTON_CHILD(m_widget) ), wxGTK_CONV( label2 ) );
+#else
     gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), wxGTK_CONV( GetLabel() ) );
+#endif
 }
 
 bool wxButton::Enable( bool enable )
@@ -173,6 +196,15 @@ bool wxButton::Enable( bool enable )
     return TRUE;
 }
 
+bool wxButton::IsOwnGtkWindow( GdkWindow *window )
+{
+#ifdef __WXGTK20__
+    return GTK_BUTTON(m_widget)->event_window;
+#else
+    return (window == m_widget->window);
+#endif
+}
+
 void wxButton::ApplyWidgetStyle()
 {
     SetWidgetStyle();