extern "C" {
static void wxGtkOnRemoveTag(GtkTextBuffer *buffer,
GtkTextTag *tag,
- GtkTextIter *start,
- GtkTextIter *end,
+ GtkTextIter * WXUNUSED(start),
+ GtkTextIter * WXUNUSED(end),
char *prefix)
{
gchar *name;
wxGtkTextRemoveTagsWithPrefix(text_buffer, "WXINDENT", start, end);
// Convert indent from 1/10th of a mm into pixels
- float factor;
-#if GTK_CHECK_VERSION(2,2,0)
- if (!gtk_check_version(2,2,0))
- factor = (float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
+ float factor =
+ (float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
gdk_screen_get_width_mm(gtk_widget_get_screen(text)) / 10;
- else
-#endif
- factor = (float)gdk_screen_width() / gdk_screen_width_mm() / 10;
const int indent = (int)(factor * attr.GetLeftIndent());
const int subIndent = (int)(factor * attr.GetLeftSubIndent());
if (!tag)
{
// Factor to convert from 1/10th of a mm into pixels
- float factor;
-#if GTK_CHECK_VERSION(2,2,0)
- if (!gtk_check_version(2,2,0))
- factor = (float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
+ float factor =
+ (float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
gdk_screen_get_width_mm(gtk_widget_get_screen(text)) / 10;
- else
-#endif
- factor = (float)gdk_screen_width() / gdk_screen_width_mm() / 10;
PangoTabArray* tabArray = pango_tab_array_new(tabs.GetCount(), TRUE);
for (size_t i = 0; i < tabs.GetCount(); i++)
static void
au_apply_tag_callback(GtkTextBuffer *buffer,
GtkTextTag *tag,
- GtkTextIter *start,
- GtkTextIter *end,
- gpointer textctrl)
+ GtkTextIter * WXUNUSED(start),
+ GtkTextIter * WXUNUSED(end),
+ gpointer WXUNUSED(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");
extern "C" {
static gboolean
-pred_whitespace (gunichar ch, gpointer user_data)
+pred_whitespace(gunichar ch, gpointer WXUNUSED(user_data))
{
return g_unichar_isspace(ch);
}
extern "C" {
static gboolean
-pred_non_whitespace (gunichar ch, gpointer user_data)
+pred_non_whitespace (gunichar ch, gpointer WXUNUSED(user_data))
{
return !g_unichar_isspace(ch);
}
extern "C" {
static gboolean
-pred_nonpunct (gunichar ch, gpointer user_data)
+pred_nonpunct (gunichar ch, gpointer WXUNUSED(user_data))
{
return !g_unichar_ispunct(ch);
}
extern "C" {
static gboolean
-pred_nonpunct_or_slash (gunichar ch, gpointer user_data)
+pred_nonpunct_or_slash (gunichar ch, gpointer WXUNUSED(user_data))
{
return !g_unichar_ispunct(ch) || ch == '/';
}
extern "C" {
static void
-au_insert_text_callback(GtkTextBuffer *buffer,
+au_insert_text_callback(GtkTextBuffer * WXUNUSED(buffer),
GtkTextIter *end,
gchar *text,
gint len,
extern "C" {
static void
-au_delete_range_callback(GtkTextBuffer *buffer,
+au_delete_range_callback(GtkTextBuffer * WXUNUSED(buffer),
GtkTextIter *start,
GtkTextIter *end,
wxTextCtrl *win)
extern "C" {
static void
-gtk_text_changed_callback( GtkWidget *widget, wxTextCtrl *win )
+gtk_text_changed_callback( GtkWidget * WXUNUSED(widget), wxTextCtrl *win )
{
if ( win->IgnoreTextUpdate() )
return;
extern "C" {
static gboolean
-gtk_text_exposed_callback( GtkWidget *widget, GdkEventExpose *event, wxTextCtrl *win )
+gtk_text_exposed_callback( GtkWidget * WXUNUSED(widget),
+ GdkEventExpose * WXUNUSED(event),
+ wxTextCtrl * WXUNUSED(win) )
{
return TRUE;
}
if (style & wxTE_READONLY)
GTKSetEditable();
+ if (style & wxTE_PROCESS_ENTER)
+ GTKSetActivatesDefault();
+
// left justification (alignment) is the default anyhow
if ( style & (wxTE_RIGHT | wxTE_CENTRE) )
GTKSetJustification();
void wxTextCtrl::GTKSetVisibility()
{
- // VZ: shouldn't we assert if wxTE_PASSWORD is set for multiline control?
- if ( IsSingleLine() )
- gtk_entry_set_visibility(GTK_ENTRY(m_text), !HasFlag(wxTE_PASSWORD));
+ wxCHECK_RET( IsSingleLine(),
+ "wxTE_PASSWORD is for single line text controls only" );
+
+ gtk_entry_set_visibility(GTK_ENTRY(m_text), !HasFlag(wxTE_PASSWORD));
+}
+
+void wxTextCtrl::GTKSetActivatesDefault()
+{
+ wxCHECK_RET( IsSingleLine(),
+ "wxTE_PROCESS_ENTER is for single line text controls only" );
+
+ gtk_entry_set_activates_default(GTK_ENTRY(m_text),
+ !HasFlag(wxTE_PROCESS_ENTER));
}
void wxTextCtrl::GTKSetWrapMode()
else if ( HasFlag( wxTE_WORDWRAP ) )
wrap = GTK_WRAP_WORD;
else // HasFlag(wxTE_BESTWRAP) always true as wxTE_BESTWRAP == 0
- {
- // GTK_WRAP_WORD_CHAR seems to be new in GTK+ 2.4
-#ifdef __WXGTK24__
- if ( !gtk_check_version(2,4,0) )
- {
- wrap = GTK_WRAP_WORD_CHAR;
- }
- else
-#endif // __WXGTK24__
- wrap = GTK_WRAP_WORD;
- }
+ wrap = GTK_WRAP_WORD_CHAR;
gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), wrap );
}
}
else // single line
{
-#ifdef __WXGTK24__
- // gtk_entry_set_alignment was introduced in gtk+-2.3.5
- if (!gtk_check_version(2,4,0))
- {
- gfloat align;
- if ( HasFlag(wxTE_RIGHT) )
- align = 1.0;
- else if ( HasFlag(wxTE_CENTRE) )
- align = 0.5;
- else // single line
- align = 0.0;
-
- gtk_entry_set_alignment(GTK_ENTRY(m_text), align);
- }
-#endif // __WXGTK24__
- }
+ gfloat align;
+ if ( HasFlag(wxTE_RIGHT) )
+ align = 1.0;
+ else if ( HasFlag(wxTE_CENTRE) )
+ align = 0.5;
+ else // single line
+ align = 0.0;
+ gtk_entry_set_alignment(GTK_ENTRY(m_text), align);
+ }
}
void wxTextCtrl::SetWindowStyleFlag(long style)
if ( (style & wxTE_PASSWORD) != (styleOld & wxTE_PASSWORD) )
GTKSetVisibility();
+ if ( (style & wxTE_PROCESS_ENTER) != (styleOld & wxTE_PROCESS_ENTER) )
+ GTKSetActivatesDefault();
+
static const long flagsWrap = wxTE_WORDWRAP | wxTE_CHARWRAP | wxTE_DONTWRAP;
if ( (style & flagsWrap) != (styleOld & flagsWrap) )
GTKSetWrapMode();
// wxGTK-specific: called recursively by Enable,
// to give widgets an opportunity to correct their colours after they
// have been changed by Enable
-void wxTextCtrl::OnEnabled( bool enable )
+void wxTextCtrl::OnEnabled(bool WXUNUSED(enable))
{
// If we have a custom background colour, we use this colour in both
// disabled and enabled mode, or we end up with a different colour under the
if ( GetEventHandler()->ProcessEvent(event) )
return;
}
-
- // FIXME: this is not the right place to do it, wxDialog::OnCharHook()
- // probably is
- if ( IsSingleLine() )
- {
- // This will invoke the dialog default action, such
- // as the clicking the default button.
-
- wxWindow *top_frame = m_parent;
- while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
- top_frame = top_frame->GetParent();
-
- if (top_frame && GTK_IS_WINDOW(top_frame->m_widget))
- {
- GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
-
- if (window->default_widget)
- {
- gtk_widget_activate (window->default_widget);
- return;
- }
- }
- }
}
key_event.Skip();