void OnMenuHighlight( wxMenuEvent& event );
wxMenuBar *m_menuBar;
- GtkNotebookPage *m_page;
bool m_justInserted;
private:
}
#define g_object_ref_sink wx_g_object_ref_sink
+// ----------------------------------------------------------------------------
+// the following were introduced in GTK+ 2.12
+
+static inline void wx_gtk_about_dialog_set_program_name(GtkAboutDialog* about, const gchar* name)
+{
+ gtk_about_dialog_set_name(about, name);
+}
+#define gtk_about_dialog_set_program_name wx_gtk_about_dialog_set_program_name
+
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.14
}
#define gtk_adjustment_get_upper wx_gtk_adjustment_get_upper
+static inline void wx_gtk_adjustment_set_page_size(GtkAdjustment* adjustment, gdouble page_size)
+{
+ adjustment->page_size = page_size;
+}
+#define gtk_adjustment_set_page_size wx_gtk_adjustment_set_page_size
+
static inline GtkWidget* wx_gtk_color_selection_dialog_get_color_selection(GtkColorSelectionDialog* csd)
{
return csd->colorsel;
}
#define gtk_dialog_get_action_area wx_gtk_dialog_get_action_area
+static inline guint16 wx_gtk_entry_get_text_length(GtkEntry* entry)
+{
+ return entry->text_length;
+}
+#define gtk_entry_get_text_length wx_gtk_entry_get_text_length
+
static inline GtkWidget* wx_gtk_font_selection_dialog_get_cancel_button(GtkFontSelectionDialog* fsd)
{
return fsd->cancel_button;
}
#define gtk_font_selection_dialog_get_ok_button wx_gtk_font_selection_dialog_get_ok_button
+static inline const guchar* wx_gtk_selection_data_get_data(GtkSelectionData* selection_data)
+{
+ return selection_data->data;
+}
+#define gtk_selection_data_get_data wx_gtk_selection_data_get_data
+
static inline GdkAtom wx_gtk_selection_data_get_data_type(GtkSelectionData* selection_data)
{
return selection_data->type;
}
#define gtk_widget_get_window wx_gtk_widget_get_window
+static inline GtkWidget* wx_gtk_window_get_default_widget(GtkWindow* window)
+{
+ return window->default_widget;
+}
+#define gtk_window_get_default_widget wx_gtk_window_get_default_widget
+
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.16
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.18
+static inline void wx_gtk_cell_renderer_get_alignment(GtkCellRenderer* cell, gfloat* xalign, gfloat* yalign)
+{
+ *xalign = cell->xalign;
+ *yalign = cell->yalign;
+}
+#define gtk_cell_renderer_get_alignment wx_gtk_cell_renderer_get_alignment
+
+static inline void wx_gtk_cell_renderer_get_padding(GtkCellRenderer* cell, gint* xpad, gint* ypad)
+{
+ *xpad = cell->xpad;
+ *ypad = cell->ypad;
+}
+#define gtk_cell_renderer_get_padding wx_gtk_cell_renderer_get_padding
+
static inline void wx_gtk_widget_get_allocation(GtkWidget* widget, GtkAllocation* allocation)
{
*allocation = widget->allocation;
}
#define gtk_widget_get_mapped wx_gtk_widget_get_mapped
+static inline void wx_gtk_widget_get_requisition(GtkWidget* widget, GtkRequisition* requisition)
+{
+ *requisition = widget->requisition;
+}
+#define gtk_widget_get_requisition wx_gtk_widget_get_requisition
+
static inline GdkWindow* wx_gtk_entry_get_text_window(GtkEntry* entry)
{
return entry->text_area;
#ifndef _WX_GTK_SCROLLBAR_H_
#define _WX_GTK_SCROLLBAR_H_
-#include "wx/defs.h"
-
-//-----------------------------------------------------------------------------
-// classes
-//-----------------------------------------------------------------------------
-
-class WXDLLIMPEXP_FWD_CORE wxScrollBar;
-
//-----------------------------------------------------------------------------
// wxScrollBar
//-----------------------------------------------------------------------------
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
-protected:
- virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
-
-private:
DECLARE_DYNAMIC_CLASS(wxScrollBar)
};
GtkTextBuffer *m_buffer;
GtkTextMark* m_showPositionOnThaw;
+ GSList* m_anonymousMarkList;
// For wxTE_AUTO_URL
void OnUrlMouseEvent(wxMouseEvent&);
#include "wx/dlimpexp.h"
#define GTK_TYPE_TREE_ENTRY (gtk_tree_entry_get_type())
-#define GTK_TREE_ENTRY(obj) (GTK_CHECK_CAST (obj, gtk_tree_entry_get_type (), GtkTreeEntry))
-#define GTK_TREE_ENTRY_CLASS(klass) (GTK_CHECK_CLASS_CAST (klass, gtk_tree_entry_get_type (), GtkTreeEntryClass))
-#define GTK_IS_TREE_ENTRY(obj) (GTK_CHECK_TYPE (obj, gtk_tree_entry_get_type ()))
+#define GTK_TREE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_tree_entry_get_type (), GtkTreeEntry))
+#define GTK_TREE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, gtk_tree_entry_get_type (), GtkTreeEntryClass))
+#define GTK_IS_TREE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, gtk_tree_entry_get_type ()))
typedef struct _GtkTreeEntry GtkTreeEntry;
typedef struct _GtkTreeEntryClass GtkTreeEntryClass;
GtkTreeEntry* gtk_tree_entry_new (void);
WXDLLIMPEXP_CORE
-GtkType gtk_tree_entry_get_type (void);
+GType gtk_tree_entry_get_type (void);
WXDLLIMPEXP_CORE
gchar* gtk_tree_entry_get_collate_key (GtkTreeEntry* entry);
gtk_paint_handle
(
- window->m_wxwindow->style,
+ gtk_widget_get_style(window->m_wxwindow),
window->GTKGetDrawingWindow(),
// flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
GTK_STATE_NORMAL,
// __WXGTK20__
#include <gtk/gtk.h>
+#include "wx/gtk/private/gtk2-compat.h"
static void
gtk_pseudo_window_realized_callback( GtkWidget *m_widget, void *WXUNUSED(win) )
if ((j*16+8)<amount)
region.Union(0, y, disp.x, 1);
}
- gdk_window_shape_combine_region(m_widget->window, region.GetRegion(), 0, 0);
+ gdk_window_shape_combine_region(gtk_widget_get_window(m_widget), region.GetRegion(), 0, 0);
}
#ifdef __WXGTK__
#include <gtk/gtk.h>
+ #include "wx/gtk/private/gtk2-compat.h"
#elif defined(__WXMSW__)
#include "wx/msw/private.h"
#elif defined(__WXX11__)
{
gtk_grab_add( m_widget );
- gdk_pointer_grab( m_widget->window, TRUE,
+ gdk_pointer_grab( gtk_widget_get_window(m_widget), true,
(GdkEventMask)
(GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GdkWindowEdge edge =
GetLayoutDirection() == wxLayout_RightToLeft ? GDK_WINDOW_EDGE_SOUTH_WEST :
GDK_WINDOW_EDGE_SOUTH_EAST;
- gtk_paint_resize_grip( m_widget->style,
+ gtk_paint_resize_grip(gtk_widget_get_style(m_widget),
GTKGetDrawingWindow(),
gtk_widget_get_state(m_widget),
NULL,
gs_aboutDialog = GTK_ABOUT_DIALOG(gtk_about_dialog_new());
GtkAboutDialog * const dlg = gs_aboutDialog;
- gtk_about_dialog_set_name(dlg, wxGTK_CONV_SYS(info.GetName()));
+ gtk_about_dialog_set_program_name(dlg, wxGTK_CONV_SYS(info.GetName()));
if ( info.HasVersion() )
gtk_about_dialog_set_version(dlg, wxGTK_CONV_SYS(info.GetVersion()));
else
// with "stock-id" representation (in addition to pixmap and pixbuf
// ones) and would convert it to pixbuf when rendered.
- GtkStyle* style = wxGTKPrivate::GetButtonWidget()->style;
+ GtkStyle* style = gtk_widget_get_style(wxGTKPrivate::GetButtonWidget());
GtkIconSet* iconset = gtk_style_lookup_icon_set(style, stockid);
if (!iconset)
const wxString stockid = wxArtIDToStock(id);
// try to load the bundle as stock icon first
- GtkStyle* style = wxGTKPrivate::GetButtonWidget()->style;
+ GtkStyle* style = gtk_widget_get_style(wxGTKPrivate::GetButtonWidget());
GtkIconSet* iconset = gtk_style_lookup_icon_set(style, stockid.utf8_str());
if ( iconset )
{
else
{
m_widget = gtk_combo_box_entry_new_with_model( GTK_TREE_MODEL(store), m_stringCellIndex );
- m_entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
- gtk_entry_set_editable( m_entry, TRUE );
+ m_entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(m_widget)));
+ gtk_editable_set_editable(GTK_EDITABLE(m_entry), true);
}
g_object_ref(m_widget);
if (!base_type::Enable(enable))
return false;
- gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
+ gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(m_widget)), enable);
if (enable)
GTKFixSensitivity();
GtkLabel *wxButton::GTKGetLabel() const
{
- GtkWidget *child = GTK_BIN(m_widget)->child;
+ GtkWidget* child = gtk_bin_get_child(GTK_BIN(m_widget));
if ( GTK_IS_ALIGNMENT(child) )
{
- GtkWidget *box = GTK_BIN(child)->child;
- for (GList* item = GTK_BOX(box)->children; item; item = item->next)
+ GtkWidget* box = gtk_bin_get_child(GTK_BIN(child));
+ GtkLabel* label = NULL;
+ GList* list = gtk_container_get_children(GTK_CONTAINER(box));
+ for (GList* item = list; item; item = item->next)
{
GtkBoxChild* boxChild = static_cast<GtkBoxChild*>(item->data);
if ( GTK_IS_LABEL(boxChild->widget) )
- return GTK_LABEL(boxChild->widget);
+ label = GTK_LABEL(boxChild->widget);
}
+ g_list_free(list);
- return NULL;
+ return label;
}
return GTK_LABEL(child);
void wxButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
- GtkWidget *child = GTK_BIN(m_widget)->child;
+ GtkWidget* child = gtk_bin_get_child(GTK_BIN(m_widget));
gtk_widget_modify_style(child, style);
// for buttons with images, the path to the label is (at least in 2.12)
// GtkButton -> GtkAlignment -> GtkHBox -> GtkLabel
if ( GTK_IS_ALIGNMENT(child) )
{
- GtkWidget *box = GTK_BIN(child)->child;
+ GtkWidget* box = gtk_bin_get_child(GTK_BIN(child));
if ( GTK_IS_BOX(box) )
{
- for (GList* item = GTK_BOX(box)->children; item; item = item->next)
+ GList* list = gtk_container_get_children(GTK_CONTAINER(box));
+ for (GList* item = list; item; item = item->next)
{
GtkBoxChild* boxChild = static_cast<GtkBoxChild*>(item->data);
gtk_widget_modify_style(boxChild->widget, style);
}
+ g_list_free(list);
}
}
}
GtkWidget *image;
if ( DontShowLabel() )
{
- image = GTK_BIN(m_widget)->child;
+ image = gtk_bin_get_child(GTK_BIN(m_widget));
}
else // have both label and bitmap
{
else
{
m_widgetCheckbox = gtk_check_button_new_with_label("");
- m_widgetLabel = GTK_BIN(m_widgetCheckbox)->child;
+ m_widgetLabel = gtk_bin_get_child(GTK_BIN(m_widgetCheckbox));
m_widget = m_widgetCheckbox;
}
g_object_ref(m_widget);
GdkWindow *wxChoice::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{
- return m_widget->window;
+ return gtk_widget_get_window(m_widget);
}
// Notice that this method shouldn't be necessary, because GTK calculates
void wxChoice::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
- gtk_widget_modify_style(GTK_BIN(m_widget)->child, style);
+ gtk_widget_modify_style(gtk_bin_get_child(GTK_BIN(m_widget)), style);
}
wxON_BLOCK_EXIT1(wxClipboardSync::OnDone, clipboard);
- if ( !selection_data || selection_data->length <= 0 )
+ if (!selection_data)
+ return;
+
+ const int selection_data_length = gtk_selection_data_get_length(selection_data);
+ if (selection_data_length <= 0)
return;
// make sure we got the data in the correct form
- GdkAtom type = selection_data->type;
+ GdkAtom type = gtk_selection_data_get_data_type(selection_data);
if ( type != GDK_SELECTION_TYPE_ATOM )
{
if ( strcmp(wxGtkString(gdk_atom_name(type)), "TARGETS") != 0 )
// it's not really a format, of course, but we can reuse its GetId() method
// to format this atom as string
- wxDataFormat clip(selection_data->selection);
+ wxDataFormat clip(gtk_selection_data_get_selection(selection_data));
wxLogTrace( TRACE_CLIPBOARD,
wxT("Received available formats for clipboard %s"),
clip.GetId().c_str() );
// the atoms we received, holding a list of targets (= formats)
- const GdkAtom * const atoms = (GdkAtom *)selection_data->data;
- for ( size_t i = 0; i < selection_data->length/sizeof(GdkAtom); i++ )
+ const GdkAtom* const atoms = (GdkAtom*)gtk_selection_data_get_data(selection_data);
+ for (size_t i = 0; i < selection_data_length / sizeof(GdkAtom); i++)
{
const wxDataFormat format(atoms[i]);
wxON_BLOCK_EXIT1(wxClipboardSync::OnDone, clipboard);
- if ( !selection_data || selection_data->length <= 0 )
+ if (!selection_data || gtk_selection_data_get_length(selection_data) <= 0)
return;
clipboard->GTKOnSelectionReceived(*selection_data);
if ( !clipboard )
return;
- wxDataObject * const data = clipboard->GTKGetDataObject(selection_data->selection);
+ wxDataObject * const data = clipboard->GTKGetDataObject(
+ gtk_selection_data_get_selection(selection_data));
if ( !data )
return;
// In particular, it satisfies Klipper, which polls
// TIMESTAMP to see if the clipboards content has changed.
// It shall return the time which was used to set the data.
- if (selection_data->target == g_timestampAtom)
+ if (gtk_selection_data_get_target(selection_data) == g_timestampAtom)
{
guint timestamp = GPOINTER_TO_UINT (signal_data);
gtk_selection_data_set(selection_data,
return;
}
- wxDataFormat format( selection_data->target );
+ wxDataFormat format(gtk_selection_data_get_target(selection_data));
wxLogTrace(TRACE_CLIPBOARD,
wxT("clipboard data in format %s, GtkSelectionData is target=%s type=%s selection=%s timestamp=%u"),
format.GetId().c_str(),
- wxString::FromAscii(wxGtkString(gdk_atom_name(selection_data->target))).c_str(),
- wxString::FromAscii(wxGtkString(gdk_atom_name(selection_data->type))).c_str(),
- wxString::FromAscii(wxGtkString(gdk_atom_name(selection_data->selection))).c_str(),
+ wxString::FromAscii(wxGtkString(gdk_atom_name(gtk_selection_data_get_target(selection_data)))).c_str(),
+ wxString::FromAscii(wxGtkString(gdk_atom_name(gtk_selection_data_get_data_type(selection_data)))).c_str(),
+ wxString::FromAscii(wxGtkString(gdk_atom_name(gtk_selection_data_get_selection(selection_data)))).c_str(),
GPOINTER_TO_UINT( signal_data )
);
{
wxCHECK_RET( m_receivedData, wxT("should be inside GetData()") );
- const wxDataFormat format(sel.target);
+ const wxDataFormat format(gtk_selection_data_get_target(const_cast<GtkSelectionData*>(&sel)));
wxLogTrace(TRACE_CLIPBOARD, wxT("Received selection %s"),
format.GetId().c_str());
if ( !m_receivedData->IsSupportedFormat(format) )
return;
- m_receivedData->SetData(format, sel.length, sel.data);
+ m_receivedData->SetData(format,
+ gtk_selection_data_get_length(const_cast<GtkSelectionData*>(&sel)),
+ gtk_selection_data_get_data(const_cast<GtkSelectionData*>(&sel)));
m_formatSupported = true;
}
wxClipboardEvent *event = new wxClipboardEvent(wxEVT_CLIPBOARD_CHANGED);
event->SetEventObject( clipboard );
- if ( !selection_data || selection_data->length <= 0 )
+ int selection_data_length = 0;
+ if (selection_data)
+ selection_data_length = gtk_selection_data_get_length(selection_data);
+
+ if (selection_data_length <= 0)
{
clipboard->m_sink->QueueEvent( event );
clipboard->m_sink.Release();
}
// make sure we got the data in the correct form
- GdkAtom type = selection_data->type;
+ GdkAtom type = gtk_selection_data_get_data_type(selection_data);
if ( type != GDK_SELECTION_TYPE_ATOM )
{
if ( strcmp(wxGtkString(gdk_atom_name(type)), "TARGETS") != 0 )
// it's not really a format, of course, but we can reuse its GetId() method
// to format this atom as string
- wxDataFormat clip(selection_data->selection);
+ wxDataFormat clip(gtk_selection_data_get_selection(selection_data));
wxLogTrace( TRACE_CLIPBOARD,
wxT("Received available formats for clipboard %s"),
clip.GetId().c_str() );
// the atoms we received, holding a list of targets (= formats)
- const GdkAtom * const atoms = (GdkAtom *)selection_data->data;
- for ( size_t i = 0; i < selection_data->length/sizeof(GdkAtom); i++ )
+ const GdkAtom* const atoms = (GdkAtom*)gtk_selection_data_get_data(selection_data);
+ for (size_t i = 0; i < selection_data_length / sizeof(GdkAtom); i++)
{
const wxDataFormat format(atoms[i]);
gtk_selection_clear_targets( m_clipboardWidget, GTKGetClipboardAtom() );
if ( gdk_selection_owner_get(GTKGetClipboardAtom()) ==
- m_clipboardWidget->window )
+ gtk_widget_get_window(m_clipboardWidget) )
{
wxClipboardSync sync(*this);
GdkWindow *wxCollapsiblePane::GTKGetWindow(wxArrayGdkWindows& windows) const
{
GtkWidget *label = gtk_expander_get_label_widget( GTK_EXPANDER(m_widget) );
- windows.Add( label->window );
- windows.Add( m_widget->window );
+ windows.Add(gtk_widget_get_window(label));
+ windows.Add(gtk_widget_get_window(m_widget));
return NULL;
}
}
#if !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
- GtkColorSelection *sel =
- GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
+ GtkColorSelection* sel = GTK_COLOR_SELECTION(
+ gtk_color_selection_dialog_get_color_selection(
+ GTK_COLOR_SELECTION_DIALOG(m_widget)));
gtk_color_selection_set_has_palette(sel, true);
#endif // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
hildon_color_chooser_dialog_set_color((HildonColorChooserDialog *)m_widget, &clr);
#else // !wxUSE_LIBHILDON2/!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
- GtkColorSelection *sel =
- GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
+ GtkColorSelection* sel = GTK_COLOR_SELECTION(
+ gtk_color_selection_dialog_get_color_selection(
+ GTK_COLOR_SELECTION_DIALOG(m_widget)));
if ( col )
gtk_color_selection_set_current_color(sel, col);
m_data.SetColour(new_color);
#else // !wxUSE_LIBHILDON2
- GtkColorSelection *sel =
- GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
+ GtkColorSelection* sel = GTK_COLOR_SELECTION(
+ gtk_color_selection_dialog_get_color_selection(
+ GTK_COLOR_SELECTION_DIALOG(m_widget)));
GdkColor clr;
gtk_color_selection_get_current_color(sel, &clr);
gtk_entry_set_activates_default( entry,
!HasFlag(wxTE_PROCESS_ENTER) );
- gtk_entry_set_editable( entry, TRUE );
+ gtk_editable_set_editable(GTK_EDITABLE(entry), true);
}
Append(n, choices);
// wxMSW and also because it doesn't make sense to have a string
// which is not a possible choice in a read-only combobox)
SetStringSelection(value);
- gtk_entry_set_editable( entry, FALSE );
+ gtk_editable_set_editable(GTK_EDITABLE(entry), false);
}
else // editable combobox
{
m_widget = gtk_combo_box_entry_new_text();
g_object_ref(m_widget);
- m_entry = GTK_ENTRY(GTK_BIN(m_widget)->child);
+ m_entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(m_widget)));
}
GtkEditable *wxComboBox::GetEditable() const
{
- return GTK_EDITABLE( GTK_BIN(m_widget)->child );
+ return GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(m_widget)));
}
void wxComboBox::OnChar( wxKeyEvent &event )
if ( enable )
{
- g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child,
+ g_signal_handlers_unblock_by_func(gtk_bin_get_child(GTK_BIN(m_widget)),
(gpointer)gtkcombobox_text_changed_callback, this);
}
else // disable
{
- g_signal_handlers_block_by_func(GTK_BIN(m_widget)->child,
+ g_signal_handlers_block_by_func(gtk_bin_get_child(GTK_BIN(m_widget)),
(gpointer)gtkcombobox_text_changed_callback, this);
}
}
GdkWindow* wxComboBox::GTKGetWindow(wxArrayGdkWindows& /* windows */) const
{
- return GetEntry()->text_area;
+ return gtk_entry_get_text_window(GetEntry());
}
// static
#include <gtk/gtk.h>
#include "wx/gtk/private/object.h"
+#include "wx/gtk/private/gtk2-compat.h"
//-----------------------------------------------------------------------------
// wxCursorRefData
if (hotSpotY < 0 || hotSpotY >= height)
hotSpotY = 0;
- GdkBitmap *data = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) bits, width, height );
- GdkBitmap *mask = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) maskBits, width, height);
+ GdkBitmap* data = gdk_bitmap_create_from_data(
+ gtk_widget_get_window(wxGetRootWindow()), const_cast<char*>(bits), width, height);
+ GdkBitmap* mask = gdk_bitmap_create_from_data(
+ gtk_widget_get_window(wxGetRootWindow()), const_cast<char*>(maskBits), width, height);
m_refData = new wxCursorRefData;
M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap(
m_refData = new wxCursorRefData;
wxImage image_copy(image);
- GdkDisplay* display = gdk_drawable_get_display(wxGetRootWindow()->window);
+ GdkDisplay* display = gdk_drawable_get_display(gtk_widget_get_window(wxGetRootWindow()));
if (gdk_display_supports_cursor_color(display))
{
if (!image.HasAlpha())
char* bits = new char[size];
memset(bits, 0xff, size);
maskRaw = gdk_bitmap_create_from_data(
- wxGetRootWindow()->window, bits, w, h);
+ gtk_widget_get_window(wxGetRootWindow()), bits, w, h);
delete[] bits;
}
for (size_t n = list.size(); n--; ++i)
{
wxWindow* win = *i;
- if (display == NULL && win->m_widget && win->m_widget->window)
- display = gdk_drawable_get_display(win->m_widget->window);
+ if (display == NULL && win->m_widget)
+ {
+ GdkWindow* w = gtk_widget_get_window(win->m_widget);
+ if (w)
+ display = gdk_drawable_get_display(w);
+ }
win->GTKUpdateCursor(true, false);
UpdateCursors(win->GetChildren(), display);
}
gint sort_column_id,
GtkTreeIterCompareFunc func,
gpointer data,
- GtkDestroyNotify destroy);
+ GDestroyNotify destroy);
static void wxgtk_tree_model_set_default_sort_func (GtkTreeSortable *sortable,
GtkTreeIterCompareFunc func,
gpointer data,
- GtkDestroyNotify destroy);
+ GDestroyNotify destroy);
static gboolean wxgtk_tree_model_has_default_sort_func (GtkTreeSortable *sortable);
/* drag'n'drop */
gint WXUNUSED(sort_column_id),
GtkTreeIterCompareFunc func,
gpointer WXUNUSED(data),
- GtkDestroyNotify WXUNUSED(destroy))
+ GDestroyNotify WXUNUSED(destroy))
{
g_return_if_fail (GTK_IS_WX_TREE_MODEL (sortable) );
g_return_if_fail (func != NULL);
wxgtk_tree_model_set_default_sort_func (GtkTreeSortable *sortable,
GtkTreeIterCompareFunc func,
gpointer WXUNUSED(data),
- GtkDestroyNotify WXUNUSED(destroy))
+ GDestroyNotify WXUNUSED(destroy))
{
g_return_if_fail (GTK_IS_WX_TREE_MODEL (sortable) );
g_return_if_fail (func != NULL);
wxSize size = cell->GetSize();
- gint calc_width = (gint) renderer->xpad * 2 + size.x;
- gint calc_height = (gint) renderer->ypad * 2 + size.y;
+ int xpad, ypad;
+ gtk_cell_renderer_get_padding(renderer, &xpad, &ypad);
+ int calc_width = xpad * 2 + size.x;
+ int calc_height = ypad * 2 + size.y;
if (x_offset)
*x_offset = 0;
if (cell_area && size.x > 0 && size.y > 0)
{
+ float xalign, yalign;
+ gtk_cell_renderer_get_alignment(renderer, &xalign, &yalign);
if (x_offset)
{
- *x_offset = (gint)((renderer->xalign *
- (cell_area->width - calc_width - 2 * renderer->xpad)));
- *x_offset = MAX (*x_offset, 0) + renderer->xpad;
+ *x_offset = int(xalign * (cell_area->width - calc_width - 2 * xpad));
+ *x_offset = MAX(*x_offset, 0) + xpad;
}
if (y_offset)
{
- *y_offset = (gint)((renderer->yalign *
- (cell_area->height - calc_height - 2 * renderer->ypad)));
- *y_offset = MAX (*y_offset, 0) + renderer->ypad;
+ *y_offset = int(yalign * (cell_area->height - calc_height - 2 * ypad));
+ *y_offset = MAX(*y_offset, 0) + ypad;
}
}
background_area, expose_area, flags);
wxRect rect(wxRectFromGDKRect(cell_area));
- rect = rect.Deflate(renderer->xpad, renderer->ypad);
+ int xpad, ypad;
+ gtk_cell_renderer_get_padding(renderer, &xpad, &ypad);
+ rect = rect.Deflate(xpad, ypad);
wxWindowDC* dc = (wxWindowDC*) cell->GetDC();
wxWindowDCImpl *impl = (wxWindowDCImpl *) dc->GetImpl();
rect.x += cell_area->x;
rect.y += cell_area->y;
- rect.width -= renderer->xpad * 2;
- rect.height -= renderer->ypad * 2;
+ int xpad, ypad;
+ gtk_cell_renderer_get_padding(renderer, &xpad, &ypad);
+ rect.width -= xpad * 2;
+ rect.height -= ypad * 2;
wxRect renderrect(wxRectFromGDKRect(&rect));
m_context = window->GTKGetPangoDefaultContext();
m_layout = pango_layout_new( m_context );
- m_fontdesc = pango_font_description_copy( widget->style->font_desc );
+ m_fontdesc = pango_font_description_copy(gtk_widget_get_style(widget)->font_desc);
m_cmap = gtk_widget_get_colormap( widget ? widget : window->m_widget );
// we create it on demand so need to do it even from a const function
const_cast<wxDataViewCustomRenderer *>(this)->
m_text_renderer = GTK_CELL_RENDERER_TEXT(gtk_cell_renderer_text_new());
+ g_object_ref_sink(m_text_renderer);
}
return m_text_renderer;
delete m_dc;
if (m_text_renderer)
- gtk_object_sink( GTK_OBJECT(m_text_renderer) );
+ g_object_unref(m_text_renderer);
}
wxDC *wxDataViewCustomRenderer::GetDC()
if ( !item )
return FALSE;
- if (!m_dragDataObject->IsSupported( selection_data->target ))
+ GdkAtom target = gtk_selection_data_get_target(selection_data);
+ if (!m_dragDataObject->IsSupported(target))
return FALSE;
- size_t size = m_dragDataObject->GetDataSize( selection_data->target );
+ size_t size = m_dragDataObject->GetDataSize(target);
if (size == 0)
return FALSE;
void *buf = malloc( size );
gboolean res = FALSE;
- if (m_dragDataObject->GetDataHere( selection_data->target, buf ))
+ if (m_dragDataObject->GetDataHere(target, buf))
{
res = TRUE;
- gtk_selection_data_set( selection_data, selection_data->target,
+ gtk_selection_data_set(selection_data, target,
8, (const guchar*) buf, size );
}
event.SetEventObject( m_owner );
event.SetItem( item );
event.SetModel( m_wx_model );
- event.SetDataFormat( selection_data->target );
- event.SetDataSize( selection_data->length );
- event.SetDataBuffer( selection_data->data );
+ event.SetDataFormat(gtk_selection_data_get_target(selection_data));
+ event.SetDataSize(gtk_selection_data_get_length(selection_data));
+ event.SetDataBuffer(const_cast<guchar*>(gtk_selection_data_get_data(selection_data)));
if (!m_owner->HandleWindowEvent( event ))
return FALSE;
event.SetEventObject( m_owner );
event.SetItem( item );
event.SetModel( m_wx_model );
- event.SetDataFormat( selection_data->target );
+ event.SetDataFormat(gtk_selection_data_get_target(selection_data));
if (!m_owner->HandleWindowEvent( event ))
return FALSE;
#include "wx/scopeguard.h"
#include <gtk/gtk.h>
+#include "wx/gtk/private/gtk2-compat.h"
//----------------------------------------------------------------------------
// global data
/* Owen Taylor: "call gtk_drag_finish() with
success == TRUE" */
- if ((data->length <= 0) || (data->format != 8))
+ if (gtk_selection_data_get_length(data) <= 0 || gtk_selection_data_get_format(data) != 8)
{
/* negative data length and non 8-bit data format
qualifies for junk */
if (!m_dataObject)
return false;
- wxDataFormat dragFormat( m_dragData->target );
+ wxDataFormat dragFormat(gtk_selection_data_get_target(m_dragData));
if (!m_dataObject->IsSupportedFormat( dragFormat ))
return false;
- m_dataObject->SetData( dragFormat, (size_t)m_dragData->length, (const void*)m_dragData->data );
+ m_dataObject->SetData(dragFormat,
+ (size_t)gtk_selection_data_get_length(m_dragData),
+ (const void*)gtk_selection_data_get_data(m_dragData));
return true;
}
guint WXUNUSED(time),
wxDropSource *drop_source )
{
- wxDataFormat format( selection_data->target );
+ wxDataFormat format(gtk_selection_data_get_target(selection_data));
wxLogTrace(TRACE_DND, wxT("Drop source: format requested: %s"),
format.GetId().c_str());
drop_source->m_retValue = ConvertFromGTK( context->action );
gtk_selection_data_set( selection_data,
- selection_data->target,
+ gtk_selection_data_get_target(selection_data),
8, // 8-bit
d,
size );
g_signal_connect (m_iconWindow, "configure_event",
G_CALLBACK (gtk_dnd_window_configure_callback), this);
- gdk_window_set_back_pixmap (m_iconWindow->window, pixmap, FALSE);
+ gdk_window_set_back_pixmap(gtk_widget_get_window(m_iconWindow), pixmap, false);
if (mask)
gtk_widget_shape_combine_mask (m_iconWindow, mask, 0, 0);
GtkFontSelectionDialog *sel = GTK_FONT_SELECTION_DIALOG(m_widget);
- g_signal_connect (sel->ok_button, "clicked",
+ g_signal_connect (gtk_font_selection_dialog_get_ok_button(sel), "clicked",
G_CALLBACK (gtk_fontdialog_ok_callback), this);
- g_signal_connect (sel->cancel_button, "clicked",
+ g_signal_connect (gtk_font_selection_dialog_get_cancel_button(sel), "clicked",
G_CALLBACK (gtk_fontdialog_cancel_callback), this);
g_signal_connect (m_widget, "delete_event",
{
// Vertical toolbar and m_wxwindow go into an hbox, inside the
// vbox (m_mainWidget). hbox is created on demand.
- GtkWidget* hbox = m_wxwindow->parent;
+ GtkWidget* hbox = gtk_widget_get_parent(m_wxwindow);
if (!GTK_IS_HBOX(hbox))
{
hbox = gtk_hbox_new(false, 0);
wxWindow::Update();
if (m_treeview)
- gdk_window_process_updates(GTK_WIDGET(m_treeview)->window, TRUE);
+ gdk_window_process_updates(gtk_widget_get_window(GTK_WIDGET(m_treeview)), true);
}
// ----------------------------------------------------------------------------
extern "C" {
static void
-gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget),
- GtkNotebookPage *page,
- gint WXUNUSED(page_num),
- wxMDIParentFrame *parent )
+switch_page(GtkNotebook* widget, GtkNotebookPage*, guint page_num, wxMDIParentFrame* parent)
{
// send deactivate event to old child
return;
child = NULL;
+ GtkWidget* page = gtk_notebook_get_nth_page(widget, page_num);
wxWindowList::compatibility_iterator node = client_window->GetChildren().GetFirst();
while ( node )
// child_frame can be NULL when this is called from dtor, probably
// because g_signal_connect (m_widget, "switch_page", (see below)
// isn't deleted early enough
- if ( child_frame && child_frame->m_page == page )
+ if (child_frame && child_frame->m_widget == page)
{
child = child_frame;
break;
if (m_justInserted)
{
GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget);
- gtk_notebook_set_current_page( notebook, g_list_length( notebook->children ) - 1 );
+ gtk_notebook_set_current_page(notebook, -1);
/* need to set the menubar of the child */
wxMDIChildFrame *active_child_frame = GetActiveChild();
gint i = gtk_notebook_get_current_page( notebook );
if (i < 0) return NULL;
- GtkNotebookPage* page = (GtkNotebookPage*) (g_list_nth(notebook->children,i)->data);
+ GtkWidget* page = gtk_notebook_get_nth_page(notebook, i);
if (!page) return NULL;
wxWindowList::compatibility_iterator node = m_clientWindow->GetChildren().GetFirst();
if (!child_frame)
return NULL;
- if (child_frame->m_page == page)
+ if (child_frame->m_widget == page)
return child_frame;
node = node->GetNext();
void wxMDIChildFrame::Init()
{
m_menuBar = NULL;
- m_page = NULL;
}
bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
// a call to gtk_mdi_page_change_callback with an invalid parent
// (because gtk_mdi_page_change_callback expects a wxMDIClientWindow but
// at that point of the dtor chain we are a simple wxWindow!)
- g_signal_handlers_disconnect_by_func(m_widget,
- (gpointer)gtk_mdi_page_change_callback,
- GetParent());
+ g_signal_handlers_disconnect_by_func(m_widget, (void*)switch_page, GetParent());
}
bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
m_widget = gtk_notebook_new();
g_object_ref(m_widget);
- g_signal_connect (m_widget, "switch_page",
- G_CALLBACK (gtk_mdi_page_change_callback), parent);
+ g_signal_connect(m_widget, "switch_page", G_CALLBACK(switch_page), parent);
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
gtk_notebook_append_page( notebook, child->m_widget, label_widget );
- child_frame->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
-
wxMDIParentFrame* parent_frame = static_cast<wxMDIParentFrame*>(GetParent());
parent_frame->m_justInserted = true;
}
menu->SetTitle( str );
if (menu->m_owner)
- gtk_label_set_text_with_mnemonic( GTK_LABEL( GTK_BIN(menu->m_owner)->child), wxGTK_CONV(str) );
+ gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menu->m_owner))), wxGTK_CONV(str));
}
//-----------------------------------------------------------------------------
void wxMenuItem::SetGtkLabel()
{
const wxString text = wxConvertMnemonicsToGTK(m_text.BeforeFirst('\t'));
- GtkLabel* label = GTK_LABEL(GTK_BIN(m_menuItem)->child);
+ GtkLabel* label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(m_menuItem)));
gtk_label_set_text_with_mnemonic(label, wxGTK_CONV_SYS(text));
#if wxUSE_ACCEL
guint accel_key;
wxCHECK_MSG( IsCheckable(), false,
wxT("can't get state of uncheckable item!") );
- return ((GtkCheckMenuItem*)m_menuItem)->active != 0;
+ return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(m_menuItem)) != 0;
}
//-----------------------------------------------------------------------------
m_menu = gtk_menu_new();
// NB: keep reference to the menu so that it is not destroyed behind
// our back by GTK+ e.g. when it is removed from menubar:
- g_object_ref(m_menu);
- gtk_object_sink(GTK_OBJECT(m_menu));
+ g_object_ref_sink(m_menu);
m_owner = NULL;
#include "wx/gtk/dcclient.h"
#include <gtk/gtk.h>
+#include "wx/gtk/private/gtk2-compat.h"
//-----------------------------------------------------------------------------
// data
static gboolean gtk_window_own_expose_callback(GtkWidget* widget, GdkEventExpose* gdk_event, wxMiniFrame* win)
{
if (!win->m_hasVMT || gdk_event->count > 0 ||
- gdk_event->window != widget->window)
+ gdk_event->window != gtk_widget_get_window(widget))
{
return false;
}
- gtk_paint_shadow (widget->style,
- widget->window,
+ gtk_paint_shadow (gtk_widget_get_style(widget),
+ gtk_widget_get_window(widget),
GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
NULL, NULL, NULL, // FIXME: No clipping?
wxDCImpl *impl = dc.GetImpl();
wxClientDCImpl *gtk_impl = wxDynamicCast( impl, wxClientDCImpl );
- gtk_impl->m_gdkwindow = widget->window; // Hack alert
+ gtk_impl->m_gdkwindow = gtk_widget_get_window(widget); // Hack alert
if (style & wxRESIZE_BORDER)
{
static gboolean
gtk_window_button_press_callback(GtkWidget* widget, GdkEventButton* gdk_event, wxMiniFrame* win)
{
- if (!win->m_hasVMT || gdk_event->window != widget->window)
+ if (!win->m_hasVMT || gdk_event->window != gtk_widget_get_window(widget))
return false;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
{
GtkWidget *ancestor = gtk_widget_get_toplevel( widget );
- GdkWindow *source = widget->window;
+ GdkWindow *source = gtk_widget_get_window(widget);
int org_x = 0;
int org_y = 0;
if (y >= win->m_miniEdge + win->m_miniTitle)
return true;
- gdk_window_raise( win->m_widget->window );
+ gdk_window_raise(gtk_widget_get_window(win->m_widget));
- gdk_pointer_grab( widget->window, FALSE,
+ gdk_pointer_grab( gtk_widget_get_window(widget), false,
(GdkEventMask)
(GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
static gboolean
gtk_window_button_release_callback(GtkWidget* widget, GdkEventButton* gdk_event, wxMiniFrame* win)
{
- if (!win->m_hasVMT || gdk_event->window != widget->window)
+ if (!win->m_hasVMT || gdk_event->window != gtk_widget_get_window(widget))
return false;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME );
int org_x = 0;
int org_y = 0;
- gdk_window_get_origin( widget->window, &org_x, &org_y );
+ gdk_window_get_origin(gtk_widget_get_window(widget), &org_x, &org_y);
x += org_x - win->m_diffX;
y += org_y - win->m_diffY;
win->m_x = x;
{
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
- if (gdk_event->window != widget->window)
+ if (gdk_event->window != gtk_widget_get_window(widget))
return false;
- gdk_window_set_cursor( widget->window, NULL );
+ gdk_window_set_cursor(gtk_widget_get_window(widget), NULL);
return FALSE;
}
static gboolean
gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win )
{
- if (!win->m_hasVMT || gdk_event->window != widget->window)
+ if (!win->m_hasVMT || gdk_event->window != gtk_widget_get_window(widget))
return false;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
if (style & wxRESIZE_BORDER)
{
if ((x > win->m_width-14) && (y > win->m_height-14))
- gdk_window_set_cursor( widget->window, gdk_cursor_new( GDK_BOTTOM_RIGHT_CORNER ) );
+ gdk_window_set_cursor(gtk_widget_get_window(widget), gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER));
else
- gdk_window_set_cursor( widget->window, NULL );
+ gdk_window_set_cursor(gtk_widget_get_window(widget), NULL);
win->GTKUpdateCursor(false);
}
return TRUE;
int org_x = 0;
int org_y = 0;
- gdk_window_get_origin( widget->window, &org_x, &org_y );
+ gdk_window_get_origin(gtk_widget_get_window(widget), &org_x, &org_y);
x += org_x - win->m_diffX;
y += org_y - win->m_diffY;
win->m_x = x;
{
wxFrame::SetTitle( title );
- GtkWidget* widget = GTK_BIN(m_widget)->child;
- if (widget->window)
- gdk_window_invalidate_rect(widget->window, NULL, false);
+ GdkWindow* window = gtk_widget_get_window(gtk_bin_get_child(GTK_BIN(m_widget)));
+ if (window)
+ gdk_window_invalidate_rect(window, NULL, false);
}
#endif // wxUSE_MINIFRAME
#include "wx/nativewin.h"
#include <gtk/gtk.h>
+#include "wx/gtk/private/gtk2-compat.h"
#ifdef GDK_WINDOWING_X11
#include <X11/Xlib.h>
// we need to realize the window first before reparenting it
gtk_widget_realize(m_widget);
- gdk_window_reparent(m_widget->window, win, 0, 0);
+ gdk_window_reparent(gtk_widget_get_window(m_widget), win, 0, 0);
#ifdef GDK_WINDOWING_X11
// if the native window is destroyed, our own window will be destroyed too
// destroyed" GdkWindow, so intercept to DestroyNotify ourselves to fix
// this and also destroy the associated C++ object when its window is
// destroyed
- gdk_window_add_filter(m_widget->window, wxNativeContainerWindowFilter, this);
+ gdk_window_add_filter(gtk_widget_get_window(m_widget), wxNativeContainerWindowFilter, this);
#endif // GDK_WINDOWING_X11
// we should be initially visible as we suppose that the native window we
if ( style )
{
gtk_widget_modify_style(pageData->m_label, style);
- gtk_rc_style_unref(style);
+ g_object_unref(style);
}
if (select && GetPageCount() > 1)
IsPointInsideWidget(const wxPoint& pt, GtkWidget *w,
gint x, gint y, gint border = 0)
{
+ GtkAllocation a;
+ gtk_widget_get_allocation(w, &a);
return
- (pt.x >= w->allocation.x - x - border) &&
- (pt.x <= w->allocation.x - x + border + w->allocation.width) &&
- (pt.y >= w->allocation.y - y - border) &&
- (pt.y <= w->allocation.y - y + border + w->allocation.height);
+ (pt.x >= a.x - x - border) &&
+ (pt.x <= a.x - x + border + a.width) &&
+ (pt.y >= a.y - y - border) &&
+ (pt.y <= a.y - y + border + a.height);
}
int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
{
- const gint x = m_widget->allocation.x;
- const gint y = m_widget->allocation.y;
+ GtkAllocation a;
+ gtk_widget_get_allocation(m_widget, &a);
+ const int x = a.x;
+ const int y = a.y;
const size_t count = GetPageCount();
size_t i = 0;
+#if !GTK_CHECK_VERSION(3,0,0) && !defined(GSEAL_ENABLE)
GtkNotebook * notebook = GTK_NOTEBOOK(m_widget);
if (gtk_notebook_get_scrollable(notebook))
i = g_list_position( notebook->children, notebook->first_tab );
+#endif
for ( ; i < count; i++ )
{
GdkWindow *wxNotebook::GTKGetWindow(wxArrayGdkWindows& windows) const
{
- windows.push_back(m_widget->window);
+ windows.push_back(gtk_widget_get_window(m_widget));
windows.push_back(GTK_NOTEBOOK(m_widget)->event_window);
return NULL;
{
if (child == widget)
return FALSE;
- child = child->parent;
+ child = gtk_widget_get_parent(child);
}
}
if (!rb->m_hasVMT) return;
if (g_blockEventsOnDrag) return;
- if (!button->active) return;
+ if (!gtk_toggle_button_get_active(button)) return;
wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, rb->GetId() );
event.SetInt( rb->GetSelection() );
while (node)
{
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData()->button );
- if (button->active) return count;
+ if (gtk_toggle_button_get_active(button)) return count;
count++;
node = node->GetNext();
}
wxCHECK_MSG( node, wxEmptyString, wxT("radiobox wrong index") );
- GtkLabel *label = GTK_LABEL(GTK_BIN(node->GetData()->button)->child);
+ GtkLabel* label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(node->GetData()->button)));
wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
wxCHECK_RET( node, wxT("radiobox wrong index") );
- GtkLabel *g_label = GTK_LABEL(GTK_BIN(node->GetData()->button)->child);
+ GtkLabel* g_label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(node->GetData()->button)));
gtk_label_set_text( g_label, wxGTK_CONV( label ) );
}
while (node)
{
GtkButton *button = GTK_BUTTON( node->GetData()->button );
- GtkLabel *label = GTK_LABEL(GTK_BIN(button)->child);
+ GtkLabel *label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(button)));
gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
GtkButton *button = GTK_BUTTON( node->GetData()->button );
- GtkLabel *label = GTK_LABEL(GTK_BIN(button)->child);
+ GtkLabel *label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(button)));
gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
GtkWidget *widget = GTK_WIDGET( node->GetData()->button );
gtk_widget_modify_style( widget, style );
- gtk_widget_modify_style(GTK_BIN(widget)->child, style);
+ gtk_widget_modify_style(gtk_bin_get_child(GTK_BIN(widget)), style);
node = node->GetNext();
}
GdkWindow *wxRadioBox::GTKGetWindow(wxArrayGdkWindows& windows) const
{
- windows.push_back(m_widget->window);
+ windows.push_back(gtk_widget_get_window(m_widget));
wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
while (node)
GtkWidget *button = GTK_WIDGET( node->GetData()->button );
// don't put NULL pointers in the 'windows' array!
- if (button->window)
- windows.push_back(button->window);
+ if (gtk_widget_get_window(button))
+ windows.push_back(gtk_widget_get_window(button));
node = node->GetNext();
}
if (g_blockEventsOnDrag) return;
- if (!button->active) return;
+ if (!gtk_toggle_button_get_active(button)) return;
wxCommandEvent event( wxEVT_COMMAND_RADIOBUTTON_SELECTED, rb->GetId());
event.SetInt( rb->GetValue() );
// save the original label
wxControlBase::SetLabel(label);
- GTKSetLabelForLabel(GTK_LABEL(GTK_BIN(m_widget)->child), label);
+ GTKSetLabelForLabel(GTK_LABEL(gtk_bin_get_child(GTK_BIN(m_widget))), label);
}
void wxRadioButton::SetValue( bool val )
{
wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobutton") );
- return GTK_TOGGLE_BUTTON(m_widget)->active;
+ return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_widget)) != 0;
}
bool wxRadioButton::Enable( bool enable )
if (!base_type::Enable(enable))
return false;
- gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
+ gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(m_widget)), enable);
if (enable)
GTKFixSensitivity();
void wxRadioButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
- gtk_widget_modify_style(GTK_BIN(m_widget)->child, style);
+ gtk_widget_modify_style(gtk_bin_get_child(GTK_BIN(m_widget)), style);
}
GdkWindow *
gtk_paint_box
(
- button->style,
+ gtk_widget_get_style(button),
gdk_window,
state,
GTK_SHADOW_OUT,
// in the given rectangle, +2/3 below is just what looks good here...
gtk_paint_expander
(
- tree->style,
+ gtk_widget_get_style(tree),
gdk_window,
state,
NULL,
wxOrientation orient,
int flags)
{
- if ( !win->m_wxwindow->window )
+ if (gtk_widget_get_window(win->m_wxwindow) == NULL)
{
// window not realized yet
return;
gtk_paint_handle
(
- win->m_wxwindow->style,
+ gtk_widget_get_style(win->m_wxwindow),
gdk_window,
flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
GTK_SHADOW_NONE,
// draw arrow on button
gtk_paint_arrow
(
- button->style,
+ gtk_widget_get_style(button),
gdk_window,
state,
flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
gtk_paint_check
(
- button->style,
+ gtk_widget_get_style(button),
gdk_window,
state,
shadow_type,
gtk_paint_box
(
- button->style,
+ gtk_widget_get_style(button),
gdk_window,
state,
flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
// the wxCONTROL_FOCUSED state is deduced
// directly from the m_wxwindow by GTK+
- gtk_paint_flat_box(wxGTKPrivate::GetTreeWidget()->style,
+ gtk_paint_flat_box(gtk_widget_get_style(wxGTKPrivate::GetTreeWidget()),
gdk_window,
GTK_STATE_SELECTED,
GTK_SHADOW_NONE,
else
state = GTK_STATE_NORMAL;
- gtk_paint_focus( win->m_widget->style,
+ gtk_paint_focus( gtk_widget_get_style(win->m_widget),
gdk_window,
state,
NULL,
if ( flags & wxCONTROL_DISABLED )
state = GTK_STATE_INSENSITIVE;
- if (flags & wxCONTROL_CURRENT )
- GTK_WIDGET_SET_FLAGS( entry, GTK_HAS_FOCUS );
- else
- GTK_WIDGET_UNSET_FLAGS( entry, GTK_HAS_FOCUS );
+ gtk_widget_set_can_focus(entry, (flags & wxCONTROL_CURRENT) != 0);
gtk_paint_shadow
(
- entry->style,
+ gtk_widget_get_style(entry),
gdk_window,
state,
GTK_SHADOW_OUT,
if ( flags & wxCONTROL_DISABLED )
state = GTK_STATE_INSENSITIVE;
- if (flags & wxCONTROL_CURRENT )
- GTK_WIDGET_SET_FLAGS( combo, GTK_HAS_FOCUS );
- else
- GTK_WIDGET_UNSET_FLAGS( combo, GTK_HAS_FOCUS );
+ gtk_widget_set_can_focus(combo, (flags & wxCONTROL_CURRENT) != 0);
gtk_paint_shadow
(
- combo->style,
+ gtk_widget_get_style(combo),
gdk_window,
state,
GTK_SHADOW_OUT,
gtk_paint_arrow
(
- combo->style,
+ gtk_widget_get_style(combo),
gdk_window,
state,
GTK_SHADOW_OUT,
gtk_paint_box
(
- combo->style,
+ gtk_widget_get_style(combo),
gdk_window,
state,
GTK_SHADOW_ETCHED_OUT,
gtk_paint_option
(
- button->style,
+ gtk_widget_get_style(button),
gdk_window,
state,
shadow_type,
int wxScrollBar::GetThumbPosition() const
{
- GtkAdjustment* adj = ((GtkRange*)m_widget)->adjustment;
- return int(adj->value + 0.5);
+ return wxRound(gtk_range_get_value(GTK_RANGE(m_widget)));
}
int wxScrollBar::GetThumbSize() const
{
- GtkAdjustment* adj = ((GtkRange*)m_widget)->adjustment;
- return int(adj->page_size);
+ GtkAdjustment* adj = gtk_range_get_adjustment(GTK_RANGE(m_widget));
+ return int(gtk_adjustment_get_page_size(adj));
}
int wxScrollBar::GetPageSize() const
{
- GtkAdjustment* adj = ((GtkRange*)m_widget)->adjustment;
- return int(adj->page_increment);
+ GtkAdjustment* adj = gtk_range_get_adjustment(GTK_RANGE(m_widget));
+ return int(gtk_adjustment_get_page_increment(adj));
}
int wxScrollBar::GetRange() const
{
- GtkAdjustment* adj = ((GtkRange*)m_widget)->adjustment;
- return int(adj->upper);
+ GtkAdjustment* adj = gtk_range_get_adjustment(GTK_RANGE(m_widget));
+ return int(gtk_adjustment_get_upper(adj));
}
void wxScrollBar::SetThumbPosition( int viewStart )
range =
thumbSize = 1;
}
- GtkAdjustment* adj = ((GtkRange*)m_widget)->adjustment;
- adj->step_increment = 1;
- adj->page_increment = pageSize;
- adj->page_size = thumbSize;
- adj->value = position;
g_signal_handlers_block_by_func(m_widget, (void*)gtk_value_changed, this);
- gtk_range_set_range((GtkRange*)m_widget, 0, range);
- m_scrollPos[0] = adj->value;
+ GtkRange* widget = GTK_RANGE(m_widget);
+ gtk_adjustment_set_page_size(gtk_range_get_adjustment(widget), thumbSize);
+ gtk_range_set_increments(widget, 1, pageSize);
+ gtk_range_set_range(widget, 0, range);
+ gtk_range_set_value(widget, position);
+ m_scrollPos[0] = gtk_range_get_value(widget);
g_signal_handlers_unblock_by_func(m_widget, (void*)gtk_value_changed, this);
}
SetScrollbar(GetThumbPosition(), GetThumbSize(), range, GetPageSize());
}
-GdkWindow *wxScrollBar::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
-{
- return m_widget->window;
-}
-
// static
wxVisualAttributes
wxScrollBar::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
#include "wx/scrolwin.h"
#include <gtk/gtk.h>
+#include "wx/gtk/private/gtk2-compat.h"
// ----------------------------------------------------------------------------
// wxScrollHelper implementation
int xPos, int yPos,
bool noRefresh)
{
- m_win->m_scrollPos[wxWindow::ScrollDir_Horz] =
- m_win->m_scrollBar[wxWindow::ScrollDir_Horz]->adjustment->value = xPos;
- m_win->m_scrollPos[wxWindow::ScrollDir_Vert] =
- m_win->m_scrollBar[wxWindow::ScrollDir_Vert]->adjustment->value = yPos;
base_type::SetScrollbars(
pixelsPerUnitX, pixelsPerUnitY, noUnitsX, noUnitsY, xPos, yPos, noRefresh);
+
+ gtk_range_set_value(m_win->m_scrollBar[wxWindow::ScrollDir_Horz], m_xScrollPosition);
+ gtk_range_set_value(m_win->m_scrollBar[wxWindow::ScrollDir_Vert], m_yScrollPosition);
+ m_win->m_scrollPos[wxWindow::ScrollDir_Horz] =
+ gtk_range_get_value(m_win->m_scrollBar[wxWindow::ScrollDir_Horz]);
+ m_win->m_scrollPos[wxWindow::ScrollDir_Vert] =
+ gtk_range_get_value(m_win->m_scrollBar[wxWindow::ScrollDir_Vert]);
}
void wxScrollHelper::DoAdjustScrollbar(GtkRange* range,
*linesPerPage = 0;
}
- GtkAdjustment* adj = range->adjustment;
- adj->step_increment = 1;
- adj->page_increment =
- adj->page_size = page_size;
+ gtk_range_set_increments(range, 1, page_size);
+ gtk_adjustment_set_page_size(gtk_range_get_adjustment(range), page_size);
gtk_range_set_range(range, 0, upper);
// ensure that the scroll position is always in valid range
#include <gtk/gtk.h>
#include "wx/gtk/private/win_gtk.h"
+#include "wx/gtk/private/gtk2-compat.h"
bool wxGetFrameExtents(GdkWindow* window, int* left, int* right, int* top, int* bottom);
gtk_widget_ensure_style(s_widget);
g_signal_connect(s_widget, "style_set", G_CALLBACK(style_set), NULL);
}
- return s_widget->style;
+ return gtk_widget_get_style(s_widget);
}
static const GtkStyle* ListStyle()
gtk_container_add(ContainerWidget(), s_widget);
gtk_widget_ensure_style(s_widget);
}
- return s_widget->style;
+ return gtk_widget_get_style(s_widget);
}
static const GtkStyle* TextCtrlStyle()
gtk_container_add(ContainerWidget(), s_widget);
gtk_widget_ensure_style(s_widget);
}
- return s_widget->style;
+ return gtk_widget_get_style(s_widget);
}
static const GtkStyle* MenuItemStyle()
gtk_container_add(ContainerWidget(), s_widget);
gtk_widget_ensure_style(s_widget);
}
- return s_widget->style;
+ return gtk_widget_get_style(s_widget);
}
static const GtkStyle* MenuBarStyle()
gtk_container_add(ContainerWidget(), s_widget);
gtk_widget_ensure_style(s_widget);
}
- return s_widget->style;
+ return gtk_widget_get_style(s_widget);
}
static const GtkStyle* ToolTipStyle()
gtk_widget_set_name(s_widget, name);
gtk_widget_ensure_style(s_widget);
}
- return s_widget->style;
+ return gtk_widget_get_style(s_widget);
}
wxColour wxSystemSettingsNative::GetColour( wxSystemColour index )
int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win )
{
GdkWindow *window = NULL;
- if(win && gtk_widget_get_realized(win->GetHandle()))
- window = win->GetHandle()->window;
+ if (win)
+ window = gtk_widget_get_window(win->GetHandle());
switch (index)
{
#endif
#include <gtk/gtk.h>
+#include "wx/gtk/private/gtk2-compat.h"
//-----------------------------------------------------------------------------
// data
static void
gtk_value_changed(GtkRange* range, wxSlider* win)
{
- GtkAdjustment* adj = gtk_range_get_adjustment (range);
- const int pos = wxRound(adj->value);
+ const double value = gtk_range_get_value(range);
const double oldPos = win->m_pos;
- win->m_pos = adj->value;
+ win->m_pos = value;
if (!win->m_hasVMT || g_blockEventsOnDrag)
return;
else if (win->m_mouseButtonDown)
{
// Difference from last change event
- const double diff = adj->value - oldPos;
+ const double diff = value - oldPos;
const bool isDown = diff > 0;
- if (IsScrollIncrement(adj->page_increment, diff))
+ GtkAdjustment* adj = gtk_range_get_adjustment(range);
+ if (IsScrollIncrement(gtk_adjustment_get_page_increment(adj), diff))
{
eventType = isDown ? wxEVT_SCROLL_PAGEDOWN : wxEVT_SCROLL_PAGEUP;
}
- else if (wxIsSameDouble(adj->value, 0))
+ else if (wxIsSameDouble(value, 0))
{
eventType = wxEVT_SCROLL_PAGEUP;
}
- else if (wxIsSameDouble(adj->value, adj->upper))
+ else if (wxIsSameDouble(value, gtk_adjustment_get_upper(adj)))
{
eventType = wxEVT_SCROLL_PAGEDOWN;
}
win->m_scrollEventType = GTK_SCROLL_NONE;
// If integral position has changed
- if (wxRound(oldPos) != pos)
+ if (wxRound(oldPos) != wxRound(value))
{
ProcessScrollEvent(win, eventType);
win->m_needThumbRelease = eventType == wxEVT_SCROLL_THUMBTRACK;
int wxSlider::GetMin() const
{
- return int(gtk_range_get_adjustment (GTK_RANGE (m_scale))->lower);
+ GtkAdjustment* adj = gtk_range_get_adjustment(GTK_RANGE(m_scale));
+ return int(gtk_adjustment_get_lower(adj));
}
int wxSlider::GetMax() const
{
- return int(gtk_range_get_adjustment (GTK_RANGE (m_scale))->upper);
+ GtkAdjustment* adj = gtk_range_get_adjustment(GTK_RANGE(m_scale));
+ return int(gtk_adjustment_get_upper(adj));
}
void wxSlider::SetPageSize( int pageSize )
int wxSlider::GetPageSize() const
{
- return int(gtk_range_get_adjustment (GTK_RANGE (m_scale))->page_increment);
+ GtkAdjustment* adj = gtk_range_get_adjustment(GTK_RANGE(m_scale));
+ return int(gtk_adjustment_get_page_increment(adj));
}
// GTK does not support changing the size of the slider
int wxSlider::GetLineSize() const
{
- return int(gtk_range_get_adjustment (GTK_RANGE (m_scale))->step_increment);
+ GtkAdjustment* adj = gtk_range_get_adjustment(GTK_RANGE(m_scale));
+ return int(gtk_adjustment_get_step_increment(adj));
}
GdkWindow *wxSlider::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
#include "wx/apptrait.h"
#include "wx/private/fdiomanager.h"
-#include <gdk/gdk.h>
+#include <glib.h>
extern "C" {
-static
-void wxSocket_GDK_Input(gpointer data,
- gint WXUNUSED(source),
- GdkInputCondition condition)
+static gboolean wxSocket_Input(GIOChannel*, GIOCondition condition, gpointer data)
{
wxFDIOHandler * const handler = static_cast<wxFDIOHandler *>(data);
- if ( condition & GDK_INPUT_READ )
+ if (condition & G_IO_IN)
{
handler->OnReadWaiting();
// shouldn't call OnWriteWaiting() as the socket is now closed and it
// would assert
if ( !handler->IsOk() )
- return;
+ return true;
}
- if ( condition & GDK_INPUT_WRITE )
+ if (condition & G_IO_OUT)
handler->OnWriteWaiting();
+
+ return true;
}
}
public:
virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d)
{
- return gdk_input_add
- (
- fd,
- d == OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ,
- wxSocket_GDK_Input,
- handler
- );
+ return g_io_add_watch(
+ g_io_channel_unix_new(fd),
+ d == OUTPUT ? G_IO_OUT : G_IO_IN,
+ wxSocket_Input,
+ handler);
}
virtual void
RemoveInput(wxFDIOHandler* WXUNUSED(handler), int fd, Direction WXUNUSED(d))
{
- gdk_input_remove(fd);
+ g_source_remove(fd);
}
};
g_signal_emit(m_widget, sig_id, 0, &value, &handled);
if (!handled)
value = g_strtod(gtk_entry_get_text(GTK_ENTRY(m_widget)), NULL);
- const GtkAdjustment* adj =
+ GtkAdjustment* adj =
gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(m_widget));
- if (value < adj->lower)
- value = adj->lower;
- else if (value > adj->upper)
- value = adj->upper;
+ const double lower = gtk_adjustment_get_lower(adj);
+ const double upper = gtk_adjustment_get_upper(adj);
+ if (value < lower)
+ value = lower;
+ else if (value > upper)
+ value = upper;
return value;
}
GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
if ( window )
{
- GtkWidget *widgetDef = window->default_widget;
+ GtkWidget* widgetDef = gtk_window_get_default_widget(window);
if ( widgetDef )
{
#include "wx/gtk/private/win_gtk.h" // for wxPizza
#include <gtk/gtk.h>
+#include "wx/gtk/private/gtk2-compat.h"
// constants taken from GTK sources
#define LABEL_PAD 1
// clip label as GTK >= 2.12 does
GtkWidget* label_widget = gtk_frame_get_label_widget(GTK_FRAME(widget));
int w = alloc->width -
- 2 * widget->style->xthickness - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD;
+ 2 * gtk_widget_get_style(widget)->xthickness - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD;
if (w < 0)
w = 0;
- if (label_widget->allocation.width > w)
+ GtkAllocation a;
+ gtk_widget_get_allocation(label_widget, &a);
+ if (a.width > w)
{
- GtkAllocation alloc2 = label_widget->allocation;
- alloc2.width = w;
- gtk_widget_size_allocate(label_widget, &alloc2);
+ a.width = w;
+ gtk_widget_size_allocate(label_widget, &a);
}
}
}
m_size = 0;
if (m_eggTrayIcon)
{
- GtkWidget* image = GTK_BIN(m_eggTrayIcon)->child;
+ GtkWidget* image = gtk_bin_get_child(GTK_BIN(m_eggTrayIcon));
gtk_image_set_from_pixbuf(GTK_IMAGE(image), m_bitmap.GetPixbuf());
}
else
#if GTK_CHECK_VERSION(2,10,0)
if (m_statusIcon)
- gtk_status_icon_set_tooltip(m_statusIcon, tip_text);
- else
+ {
+#if GTK_CHECK_VERSION(2,16,0)
+ if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,16,0) == NULL)
+ gtk_status_icon_set_tooltip_text(m_statusIcon, tip_text);
+ else
+#endif
+ {
+#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
+ gtk_status_icon_set_tooltip(m_statusIcon, tip_text);
#endif
+ }
+ }
+ else
+#endif // GTK_CHECK_VERSION(2,10,0)
{
+#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
if (tip_text && m_tooltips == NULL)
{
m_tooltips = gtk_tooltips_new();
}
if (m_tooltips)
gtk_tooltips_set_tip(m_tooltips, m_eggTrayIcon, tip_text, "");
+#endif
}
#endif // wxUSE_TOOLTIPS
}
if (h > size) h = size;
GdkPixbuf* pixbuf =
gdk_pixbuf_scale_simple(m_bitmap.GetPixbuf(), w, h, GDK_INTERP_BILINEAR);
- GtkImage* image = GTK_IMAGE(GTK_BIN(m_eggTrayIcon)->child);
+ GtkImage* image = GTK_IMAGE(gtk_bin_get_child(GTK_BIN(m_eggTrayIcon)));
gtk_image_set_from_pixbuf(image, pixbuf);
g_object_unref(pixbuf);
}
}
}
+//-----------------------------------------------------------------------------
+// "mark_set"
+//-----------------------------------------------------------------------------
+
+extern "C" {
+static void mark_set(GtkTextBuffer*, GtkTextIter*, GtkTextMark* mark, GSList** markList)
+{
+ if (gtk_text_mark_get_name(mark) == NULL)
+ *markList = g_slist_prepend(*markList, mark);
+}
+}
+
//-----------------------------------------------------------------------------
// wxTextCtrl
//-----------------------------------------------------------------------------
m_text = NULL;
m_showPositionOnThaw = NULL;
+ m_anonymousMarkList = NULL;
}
wxTextCtrl::~wxTextCtrl()
{
+ if (m_anonymousMarkList)
+ g_slist_free(m_anonymousMarkList);
}
wxTextCtrl::wxTextCtrl( wxWindow *parent,
if (multi_line)
{
+ m_buffer = gtk_text_buffer_new(NULL);
+ gulong sig_id = g_signal_connect(m_buffer, "mark_set", G_CALLBACK(mark_set), &m_anonymousMarkList);
// Create view
- m_text = gtk_text_view_new();
-
- m_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+ m_text = gtk_text_view_new_with_buffer(m_buffer);
+ // gtk_text_view_set_buffer adds its own reference
+ g_object_unref(m_buffer);
+ g_signal_handler_disconnect(m_buffer, sig_id);
// create "ShowPosition" marker
GtkTextIter iter;
? GTK_POLICY_NEVER
: GTK_POLICY_AUTOMATIC );
// for ScrollLines/Pages
- m_scrollBar[1] = (GtkRange*)((GtkScrolledWindow*)m_widget)->vscrollbar;
+ m_scrollBar[1] = GTK_RANGE(gtk_scrolled_window_get_vscrollbar(GTK_SCROLLED_WINDOW(m_widget)));
// Insert view into scrolled window
gtk_container_add( GTK_CONTAINER(m_widget), m_text );
// Insert the text
wxGtkTextInsert( m_text, m_buffer, m_defaultStyle, buffer );
- GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(m_widget) );
// Scroll to cursor, but only if scrollbar thumb is at the very bottom
// won't work when frozen, text view is not using m_buffer then
- if (!IsFrozen() && wxIsSameDouble(adj->value, adj->upper - adj->page_size))
+ if (!IsFrozen())
{
- gtk_text_view_scroll_to_mark( GTK_TEXT_VIEW(m_text),
- gtk_text_buffer_get_insert( m_buffer ), 0.0, FALSE, 0.0, 1.0 );
+ GtkAdjustment* adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(m_widget));
+ const double value = gtk_adjustment_get_value(adj);
+ const double upper = gtk_adjustment_get_upper(adj);
+ const double page_size = gtk_adjustment_get_page_size(adj);
+ if (wxIsSameDouble(value, upper - page_size))
+ {
+ gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(m_text),
+ gtk_text_buffer_get_insert(m_buffer), 0, false, 0, 1);
+ }
}
}
}
else // single line control
{
- if ( pos <= GTK_ENTRY(m_text)->text_length )
+ if (pos <= gtk_entry_get_text_length(GTK_ENTRY(m_text)))
{
if ( y )
*y = 0;
}
else
{
- return GTK_ENTRY(m_text)->text_area;
+ return gtk_entry_get_text_window(GTK_ENTRY(m_text));
}
}
// removing buffer dramatically speeds up insertion:
g_object_ref(m_buffer);
GtkTextBuffer* buf_new = gtk_text_buffer_new(NULL);
- GtkTextMark* mark = GTK_TEXT_VIEW(m_text)->first_para_mark;
gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), buf_new);
// gtk_text_view_set_buffer adds its own reference
g_object_unref(buf_new);
- // This mark should be deleted when the buffer is changed,
- // but it's not (in GTK+ up to at least 2.10.6).
+ // These marks should be deleted when the buffer is changed,
+ // but they are not (in GTK+ up to at least 3.0.1).
// Otherwise these anonymous marks start to build up in the buffer,
// and Freeze takes longer and longer each time it is called.
- if (GTK_IS_TEXT_MARK(mark) && !gtk_text_mark_get_deleted(mark))
- gtk_text_buffer_delete_mark(m_buffer, mark);
+ if (m_anonymousMarkList)
+ {
+ for (GSList* item = m_anonymousMarkList; item; item = item->next)
+ {
+ GtkTextMark* mark = static_cast<GtkTextMark*>(item->data);
+ if (GTK_IS_TEXT_MARK(mark) && !gtk_text_mark_get_deleted(mark))
+ gtk_text_buffer_delete_mark(m_buffer, mark);
+ }
+ g_slist_free(m_anonymousMarkList);
+ m_anonymousMarkList = NULL;
+ }
}
}
if ( HasFlag(wxTE_MULTILINE) )
{
// reattach buffer:
+ gulong sig_id = g_signal_connect(m_buffer, "mark_set", G_CALLBACK(mark_set), &m_anonymousMarkList);
gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), m_buffer);
g_object_unref(m_buffer);
+ g_signal_handler_disconnect(m_buffer, sig_id);
if (m_showPositionOnThaw != NULL)
{
// we should only be called if we have a max len limit at all
GtkEntry *entry = GTK_ENTRY (editable);
- wxCHECK_RET( entry->text_max_length, wxT("shouldn't be called") );
+ const int text_length = gtk_entry_get_text_length(entry);
+#if GTK_CHECK_VERSION(3,0,0) || defined(GSEAL_ENABLE)
+ const int text_max_length = gtk_entry_buffer_get_max_length(gtk_entry_get_buffer(entry));
+#else
+ const int text_max_length = entry->text_max_length;
+#endif
+ wxCHECK_RET(text_max_length, "shouldn't be called");
// check that we don't overflow the max length limit
//
// FIXME: this doesn't work when we paste a string which is going to be
// truncated
- if ( entry->text_length == entry->text_max_length )
+ if (text_length == text_max_length)
{
// we don't need to run the base class version at all
g_signal_stop_emission_by_name (editable, "insert_text");
// GtkEntries
GtkEntry * const entry = GTK_ENTRY(GetEditable());
- return entry ? entry->text_length : - 1;
+ return entry ? gtk_entry_get_text_length(entry) : -1;
}
// ----------------------------------------------------------------------------
{
if (!m_bitmap.Ok()) return;
- GtkWidget* image = ((GtkBin*)m_widget)->child;
+ GtkWidget* image = gtk_bin_get_child(GTK_BIN(m_widget));
if (image == NULL)
{
image = gtk_image_new();
if (!wxControl::Enable(enable))
return false;
- gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
+ gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(m_widget)), enable);
if (!isEnabled && enable)
{
void wxBitmapToggleButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
- gtk_widget_modify_style(GTK_BIN(m_widget)->child, style);
+ gtk_widget_modify_style(gtk_bin_get_child(GTK_BIN(m_widget)), style);
}
GdkWindow *
{
wxCHECK_MSG(m_widget != NULL, false, wxT("invalid toggle button"));
- return GTK_TOGGLE_BUTTON(m_widget)->active;
+ return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_widget)) != 0;
}
void wxToggleButton::SetLabel(const wxString& label)
if (!base_type::Enable(enable))
return false;
- gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
+ gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(m_widget)), enable);
if (enable)
GTKFixSensitivity();
void wxToggleButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
- gtk_widget_modify_style(GTK_BIN(m_widget)->child, style);
+ gtk_widget_modify_style(gtk_bin_get_child(GTK_BIN(m_widget)), style);
}
GdkWindow *
return false;
// draw disabled bitmap ourselves, GtkImage has no way to specify it
- const GtkAllocation& alloc = widget->allocation;
+ GtkAllocation alloc;
+ gtk_widget_get_allocation(widget, &alloc);
+ GtkRequisition req;
+ gtk_widget_get_requisition(widget, &req);
gdk_draw_pixbuf(
- widget->window, widget->style->black_gc, bitmap.GetPixbuf(),
+ gtk_widget_get_window(widget), gtk_widget_get_style(widget)->black_gc, bitmap.GetPixbuf(),
0, 0,
- alloc.x + (alloc.width - widget->requisition.width) / 2,
- alloc.y + (alloc.height - widget->requisition.height) / 2,
+ alloc.x + (alloc.width - req.width) / 2,
+ alloc.y + (alloc.height - req.height) / 2,
-1, -1, GDK_RGB_DITHER_NORMAL, 0, 0);
return true;
}
GtkToolItem* item = gtk_tool_item_new();
gtk_container_add(GTK_CONTAINER(item), align);
// position will be corrected in DoInsertTool if necessary
- gtk_toolbar_insert(GTK_TOOLBAR(GTK_BIN(m_widget)->child), item, -1);
+ gtk_toolbar_insert(GTK_TOOLBAR(gtk_bin_get_child(GTK_BIN(m_widget))), item, -1);
}
// ----------------------------------------------------------------------------
box = gtk_hbox_new(false, 0);
arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE);
}
- GtkWidget* tool_button = GTK_BIN(m_item)->child;
+ GtkWidget* tool_button = gtk_bin_get_child(GTK_BIN(m_item));
gtk_widget_reparent(tool_button, box);
GtkWidget* arrow_button = gtk_toggle_button_new();
gtk_button_set_relief(GTK_BUTTON(arrow_button),
wxMenu* menu = GetDropdownMenu();
if (menu)
{
- const GtkAllocation& alloc = GTK_WIDGET(button)->allocation;
+ GtkAllocation alloc;
+ gtk_widget_set_allocation(GTK_WIDGET(button), &alloc);
int x = alloc.x;
int y = alloc.y;
if (toolbar->HasFlag(wxTB_LEFT | wxTB_RIGHT))
FixupStyle();
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
+#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
if (gtk_check_version(2, 12, 0))
{
m_tooltips = gtk_tooltips_new();
g_object_ref(m_tooltips);
gtk_object_sink(GTK_OBJECT(m_tooltips));
}
+#endif
GtkSetStyle();
if (style & wxTB_DOCKABLE)
GdkWindow *wxToolBar::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{
- return GTK_WIDGET(m_toolbar)->window;
+ return gtk_widget_get_window(GTK_WIDGET(m_toolbar));
}
void wxToolBar::GtkSetStyle()
style = GTK_TOOLBAR_BOTH_HORIZ;
}
+#if GTK_CHECK_VERSION(3,0,0) || defined(GTK_DISABLE_DEPRECATED)
+ gtk_orientable_set_orientation(GTK_ORIENTABLE(m_toolbar), orient);
+#else
gtk_toolbar_set_orientation(m_toolbar, orient);
+#endif
gtk_toolbar_set_style(m_toolbar, style);
}
if (!HasFlag(wxTB_NO_TOOLTIPS) && !tool->GetShortHelp().empty())
{
#if GTK_CHECK_VERSION(2, 12, 0)
- if (!gtk_check_version(2, 12, 0))
+ if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
{
gtk_tool_item_set_tooltip_text(tool->m_item,
wxGTK_CONV(tool->GetShortHelp()));
else
#endif
{
+#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
gtk_tool_item_set_tooltip(tool->m_item,
m_tooltips, wxGTK_CONV(tool->GetShortHelp()), "");
+#endif
}
}
bin_child = gtk_bin_get_child(GTK_BIN(tool->m_item));
case wxTOOL_STYLE_CONTROL:
wxWindow* control = tool->GetControl();
- if (control->m_widget->parent == NULL)
+ if (gtk_widget_get_parent(control->m_widget) == NULL)
AddChildGTK(control);
- tool->m_item = GTK_TOOL_ITEM(control->m_widget->parent->parent);
+ tool->m_item = GTK_TOOL_ITEM(gtk_widget_get_parent(gtk_widget_get_parent(control->m_widget)));
if (gtk_toolbar_get_item_index(m_toolbar, tool->m_item) != int(pos))
{
g_object_ref(tool->m_item);
// while if we're called from DeleteTool() the control will
// be destroyed when wxToolBarToolBase itself is deleted
GtkWidget* widget = tool->GetControl()->m_widget;
- gtk_container_remove(GTK_CONTAINER(widget->parent), widget);
+ gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(widget)), widget);
}
gtk_object_destroy(GTK_OBJECT(tool->m_item));
tool->m_item = NULL;
if (tool->m_item)
{
#if GTK_CHECK_VERSION(2, 12, 0)
- if (!gtk_check_version(2, 12, 0))
+ if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
{
gtk_tool_item_set_tooltip_text(tool->m_item,
wxGTK_CONV(helpString));
else
#endif
{
+#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
gtk_tool_item_set_tooltip(tool->m_item,
m_tooltips, wxGTK_CONV(helpString), "");
+#endif
}
}
}
// global data
//-----------------------------------------------------------------------------
+#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
static GtkTooltips *gs_tooltips = NULL;
+#endif
//-----------------------------------------------------------------------------
// wxToolTip
void wxToolTip::GTKApply(GtkWidget* widget, const char* tip)
{
#if GTK_CHECK_VERSION(2, 12, 0)
- if (!gtk_check_version(2, 12, 0))
+ if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
gtk_widget_set_tooltip_text(widget, tip);
else
#endif
{
+#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
if ( !gs_tooltips )
gs_tooltips = gtk_tooltips_new();
gtk_tooltips_set_tip(gs_tooltips, widget, tip, NULL);
+#endif
}
}
void wxToolTip::Enable( bool flag )
{
#if GTK_CHECK_VERSION(2, 12, 0)
- if (!gtk_check_version(2, 12, 0))
+ if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
{
GtkSettings* settings = gtk_settings_get_default();
if (settings)
else
#endif
{
+#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
if (!gs_tooltips)
gs_tooltips = gtk_tooltips_new();
gtk_tooltips_enable( gs_tooltips );
else
gtk_tooltips_disable( gs_tooltips );
+#endif
}
}
void wxToolTip::SetDelay( long msecs )
{
#if GTK_CHECK_VERSION(2, 12, 0)
- if (!gtk_check_version(2, 12, 0))
+ if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
{
GtkSettings* settings = gtk_settings_get_default();
if (settings)
else
#endif
{
+#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
if (!gs_tooltips)
gs_tooltips = gtk_tooltips_new();
gtk_tooltips_set_delay( gs_tooltips, (int)msecs );
+#endif
}
}
static void wxgtk_window_set_urgency_hint (GtkWindow *win,
gboolean setting)
{
- wxASSERT_MSG( gtk_widget_get_realized(GTK_WIDGET(win)),
- wxT("wxgtk_window_set_urgency_hint: GdkWindow not realized") );
- GdkWindow *window = GTK_WIDGET(win)->window;
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(win));
+ wxASSERT_MSG(window, "wxgtk_window_set_urgency_hint: GdkWindow not realized");
XWMHints *wm_hints;
wm_hints = XGetWMHints(GDK_WINDOW_XDISPLAY(window), GDK_WINDOW_XWINDOW(window));
win->m_oldClientWidth = alloc->width;
win->m_oldClientHeight = alloc->height;
- wxSize size(win->m_widget->allocation.width,
- win->m_widget->allocation.height);
+ GtkAllocation a;
+ gtk_widget_get_allocation(win->m_widget, &a);
+ wxSize size(a.width, a.height);
size += win->m_decorSize;
win->m_width = size.x;
win->m_height = size.y;
gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget),
wxTopLevelWindowGTK *win )
{
- gdk_window_set_decorations(win->m_widget->window,
+ gdk_window_set_decorations(gtk_widget_get_window(win->m_widget),
(GdkWMDecoration)win->m_gdkDecor);
- gdk_window_set_functions(win->m_widget->window,
+ gdk_window_set_functions(gtk_widget_get_window(win->m_widget),
(GdkWMFunction)win->m_gdkFunc);
// GTK's shrinking/growing policy
if ( !(win->m_gdkFunc & GDK_FUNC_RESIZE) )
gtk_window_set_resizable(GTK_WINDOW(win->m_widget), FALSE);
+#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
else
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+#endif
const wxIconBundle& icons = win->GetIcons();
if (icons.GetIconCount())
#endif
gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) );
- GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
+ gtk_widget_set_can_focus(m_widget, false);
g_signal_connect (m_widget, "delete_event",
G_CALLBACK (gtk_frame_delete_callback), this);
// m_mainWidget is a GtkVBox, holding the bars and client area (m_wxwindow)
m_mainWidget = gtk_vbox_new(false, 0);
gtk_widget_show( m_mainWidget );
- GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
+ gtk_widget_set_can_focus(m_mainWidget, false);
gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
// m_wxwindow is the client area
// we donm't allow the frame to get the focus as otherwise
// the frame will grab it at arbitrary focus changes
- GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
+ gtk_widget_set_can_focus(m_wxwindow, false);
if (m_parent) m_parent->AddChild( this );
G_CALLBACK (wxgtk_tlw_size_request_callback), this);
PostCreation();
+#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
if ((m_x != -1) || (m_y != -1))
gtk_widget_set_uposition( m_widget, m_x, m_y );
+#endif
// we cannot set MWM hints and icons before the widget has
// been realized, so we do this directly after realization
else
m_gdkFunc &= ~GDK_FUNC_CLOSE;
- if (gtk_widget_get_realized(m_widget) && (m_widget->window))
- gdk_window_set_functions( m_widget->window, (GdkWMFunction)m_gdkFunc );
+ GdkWindow* window = gtk_widget_get_window(m_widget);
+ if (window)
+ gdk_window_set_functions(window, (GdkWMFunction)m_gdkFunc);
return true;
}
}
else
{
- GdkWindow *window = m_widget->window;
+ GdkWindow* window = gtk_widget_get_window(m_widget);
if (show)
{
gdk_window_set_decorations(window, (GdkWMDecoration)0);
gdk_window_set_functions(window, (GdkWMFunction)0);
- gdk_window_get_origin (m_widget->window, &root_x, &root_y);
- gdk_window_get_geometry (m_widget->window, &client_x, &client_y,
- &width, &height, NULL);
+ gdk_window_get_origin(window, &root_x, &root_y);
+ gdk_window_get_geometry(window, &client_x, &client_y, &width, &height, NULL);
- gdk_window_move_resize (m_widget->window, -client_x, -client_y,
- screen_width + 1, screen_height + 1);
+ gdk_window_move_resize(
+ window, -client_x, -client_y, screen_width + 1, screen_height + 1);
wxSetFullScreenStateX11((WXDisplay*)GDK_DISPLAY(),
(WXWindow)GDK_ROOT_WINDOW(),
gtk_widget_queue_draw( m_widget );
- if (m_wxwindow && m_wxwindow->window)
- gdk_window_invalidate_rect( m_wxwindow->window, NULL, TRUE );
+ GdkWindow* window = NULL;
+ if (m_wxwindow)
+ window = gtk_widget_get_window(m_wxwindow);
+ if (window)
+ gdk_window_invalidate_rect(window, NULL, true);
}
bool wxTopLevelWindowGTK::Show( bool show )
// causes the widget tree to be size_allocated, which generates size
// events in the wrong order. However, the size_allocates will not be
// done if the allocation is not the default (1,1).
- const int alloc_width = m_widget->allocation.width;
+ GtkAllocation alloc;
+ gtk_widget_get_allocation(m_widget, &alloc);
+ const int alloc_width = alloc.width;
if (alloc_width == 1)
- m_widget->allocation.width = 2;
+ {
+ alloc.width = 2;
+ gtk_widget_set_allocation(m_widget, &alloc);
+ }
gtk_widget_realize(m_widget);
if (alloc_width == 1)
- m_widget->allocation.width = 1;
+ {
+ alloc.width = 1;
+ gtk_widget_set_allocation(m_widget, &alloc);
+ }
// send _NET_REQUEST_FRAME_EXTENTS
XClientMessageEvent xevent;
memset(&xevent, 0, sizeof(xevent));
xevent.type = ClientMessage;
- xevent.window = gdk_x11_drawable_get_xid(m_widget->window);
+ GdkWindow* window = gtk_widget_get_window(m_widget);
+ xevent.window = gdk_x11_drawable_get_xid(window);
xevent.message_type = gdk_x11_atom_to_xatom_for_display(
- gdk_drawable_get_display(m_widget->window),
+ gdk_drawable_get_display(window),
gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false));
xevent.format = 32;
- Display* display = gdk_x11_drawable_get_xdisplay(m_widget->window);
+ Display* display = gdk_x11_drawable_get_xdisplay(window);
XSendEvent(display, DefaultRootWindow(display), false,
SubstructureNotifyMask | SubstructureRedirectMask,
(XEvent*)&xevent);
bool wxTopLevelWindowGTK::IsMaximized() const
{
- return m_widget->window &&
- (gdk_window_get_state(m_widget->window) & GDK_WINDOW_STATE_MAXIMIZED);
+ GdkWindow* window = gtk_widget_get_window(m_widget);
+ return window && (gdk_window_get_state(window) & GDK_WINDOW_STATE_MAXIMIZED);
}
void wxTopLevelWindowGTK::Restore()
if ( gtk_widget_get_realized(m_widget) )
{
if ( m_wxwindow )
- do_shape_combine_region(m_wxwindow->window, region);
+ do_shape_combine_region(gtk_widget_get_window(m_wxwindow), region);
- return do_shape_combine_region(m_widget->window, region);
+ return do_shape_combine_region(gtk_widget_get_window(m_widget), region);
}
else // not realized yet
{
bool wxTopLevelWindowGTK::SetTransparent(wxByte alpha)
{
- if (!m_widget || !m_widget->window)
+ GdkWindow* window = NULL;
+ if (m_widget)
+ window = gtk_widget_get_window(m_widget);
+ if (window == NULL)
return false;
- Display* dpy = GDK_WINDOW_XDISPLAY (m_widget->window);
+ Display* dpy = GDK_WINDOW_XDISPLAY(window);
// We need to get the X Window that has the root window as the immediate parent
// and m_widget->window as a child. This should be the X Window that the WM manages and
// from which the opacity property is checked from.
- Window win = wxGetTopmostWindowX11(dpy, GDK_WINDOW_XID (m_widget->window));
+ Window win = wxGetTopmostWindowX11(dpy, GDK_WINDOW_XID(window));
// Using pure Xlib to not have a GTK version check mess due to gtk2.0 not having GdkDisplay
#ifdef __VMS
#include <types.h>
-typedef pid_t GPid;
-#define G_GNUC_INTERNAL
-#define GSEAL(x) x
#endif
#include "wx/gtk/treeentry_gtk.h"
return GTK_TREE_ENTRY(g_object_new(GTK_TYPE_TREE_ENTRY, NULL));
}
-GtkType
+GType
gtk_tree_entry_get_type ()
{
- static GtkType tree_entry_type = 0;
+ static GType tree_entry_type = 0;
if (!tree_entry_type)
{
int wxDisplayDepth()
{
- return gdk_drawable_get_visual( wxGetRootWindow()->window )->depth;
+ return gtk_widget_get_visual(wxGetRootWindow())->depth;
}
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
// ----------------------------------------------------------------------------
extern "C" {
-static
-void GTK_EndProcessDetector(gpointer data, gint source,
- GdkInputCondition WXUNUSED(condition))
+static gboolean EndProcessDetector(GIOChannel* source, GIOCondition, void* data)
{
wxEndProcessData * const
proc_data = static_cast<wxEndProcessData *>(data);
// child exited, end waiting
- close(source);
-
- // don't call us again!
- gdk_input_remove(proc_data->tag);
+ close(g_io_channel_unix_get_fd(source));
wxHandleProcessTermination(proc_data);
+
+ // don't call us again!
+ return false;
}
}
int wxGUIAppTraits::AddProcessCallback(wxEndProcessData *proc_data, int fd)
{
- int tag = gdk_input_add(fd,
- GDK_INPUT_READ,
- GTK_EndProcessDetector,
- (gpointer)proc_data);
-
- return tag;
+ return g_io_add_watch(
+ g_io_channel_unix_new(fd), G_IO_IN, EndProcessDetector, proc_data);
}