#ifndef _WX_GTK_PRIVATE_H_
#define _WX_GTK_PRIVATE_H_
-#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/event.h"
(GSignalMatchType)(G_SIGNAL_MATCH_FUNC | \
G_SIGNAL_MATCH_DATA), 0)
-// child is not a member of GTK_BUTTON() any more in GTK+ 2.0
-#define BUTTON_CHILD(w) GTK_BIN((w))->child
-
-// event_window has disappeared from GtkToggleButton in GTK+ 2.0
-#define TOGGLE_BUTTON_EVENT_WIN(w) GTK_BUTTON((w))->event_window
-
-// gtk_editable_{copy|cut|paste}_clipboard() had an extra argument under
-// previous GTK+ versions but no more
-#if defined(__WXGTK20__) || (GTK_MINOR_VERSION > 0)
- #define DUMMY_CLIPBOARD_ARG
-#else
- #define DUMMY_CLIPBOARD_ARG ,0
-#endif
-
-// _GtkEditable is now private
-#define GET_EDITABLE_POS(w) gtk_editable_get_position(GTK_EDITABLE(w))
-#define SET_EDITABLE_POS(w, pos) \
- gtk_editable_set_position(GTK_EDITABLE(w), (pos))
-
-// this GtkNotebook struct field has been renamed
-#define NOTEBOOK_PANEL(nb) GTK_NOTEBOOK(nb)->event_window
-
-#define SCROLLBAR_CBACK_ARG
-#define GET_SCROLL_TYPE(w) GTK_SCROLL_JUMP
-
// translate a GTK+ scroll type to a wxEventType
inline wxEventType GtkScrollTypeToWx(guint scrollType)
{
void wxBitmapButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
- if ( !BUTTON_CHILD(m_widget) )
+ if (!GTK_BIN(m_widget)->child)
return;
wxButton::DoApplyWidgetStyle(style);
GdkBitmap *mask = (GdkBitmap *) NULL;
if (the_one.GetMask()) mask = the_one.GetMask()->GetBitmap();
- GtkWidget *child = BUTTON_CHILD(m_widget);
+ GtkWidget *child = GTK_BIN(m_widget)->child;
if (child == NULL)
{
// initial bitmap
else
#endif
{
- if (GTK_IS_MISC(BUTTON_CHILD(m_widget)))
- gtk_misc_set_alignment (GTK_MISC (BUTTON_CHILD (m_widget)),
+ if (GTK_IS_MISC(GTK_BIN(m_widget)->child))
+ gtk_misc_set_alignment(GTK_MISC(GTK_BIN(m_widget)->child),
x_alignment, y_alignment);
}
if ( !wxControl::Enable( enable ) )
return FALSE;
- gtk_widget_set_sensitive( BUTTON_CHILD(m_widget), enable );
+ gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
return TRUE;
}
void wxButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
- gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
+ gtk_widget_modify_style(GTK_BIN(m_widget)->child, style);
}
wxSize wxButton::DoGetBestSize() const
else
{
m_widgetCheckbox = gtk_check_button_new_with_label("");
- m_widgetLabel = BUTTON_CHILD( m_widgetCheckbox );
+ m_widgetLabel = GTK_BIN(m_widgetCheckbox)->child;
m_widget = m_widgetCheckbox;
}
SetLabel( label );
bool wxCheckBox::IsOwnGtkWindow( GdkWindow *window )
{
- return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
+ return window == GTK_BUTTON(m_widget)->event_window;
}
void wxCheckBox::OnInternalIdle()
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
- GdkWindow *event_window = TOGGLE_BUTTON_EVENT_WIN(m_widgetCheckbox);
+ GdkWindow *event_window = GTK_BUTTON(m_widgetCheckbox)->event_window;
if ( event_window && cursor.Ok() )
{
/* I now set the cursor the anew in every OnInternalIdle call
if (bin->child)
label = GTK_LABEL(bin->child);
if (!label)
- label = GTK_LABEL( BUTTON_CHILD(m_widget) );
+ label = GTK_LABEL(GTK_BIN(m_widget)->child);
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
if (bin->child)
label = GTK_LABEL(bin->child);
if (!label)
- label = GTK_LABEL( BUTTON_CHILD(m_widget) );
+ label = GTK_LABEL(GTK_BIN(m_widget)->child);
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
if (bin->child)
label = GTK_LABEL(bin->child);
if (!label)
- label = GTK_LABEL( BUTTON_CHILD(m_widget) );
+ label = GTK_LABEL(GTK_BIN(m_widget)->child);
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
if (bin->child)
label = bin->child;
if (!label)
- label = BUTTON_CHILD(m_widget);
+ label = GTK_BIN(m_widget)->child;
gtk_widget_modify_style( label, style );
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
- gtk_editable_copy_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG );
+ gtk_editable_copy_clipboard(GTK_EDITABLE(entry));
}
void wxComboBox::Cut()
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
- gtk_editable_cut_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG );
+ gtk_editable_cut_clipboard(GTK_EDITABLE(entry));
}
void wxComboBox::Paste()
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
- gtk_editable_paste_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG);
+ gtk_editable_paste_clipboard(GTK_EDITABLE(entry));
}
void wxComboBox::Undo()
long wxComboBox::GetInsertionPoint() const
{
- return (long) GET_EDITABLE_POS( GTK_COMBO(m_widget)->entry );
+ return (long) gtk_editable_get_position(GTK_EDITABLE(GTK_COMBO(m_widget)->entry));
}
wxTextPos wxComboBox::GetLastPosition() const
bool wxNotebook::IsOwnGtkWindow( GdkWindow *window )
{
return ((m_widget->window == window) ||
- (NOTEBOOK_PANEL(m_widget) == window));
+ GTK_NOTEBOOK(m_widget)->event_window == window);
}
// static
wxCHECK_MSG( node, wxEmptyString, wxT("radiobox wrong index") );
- GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->GetData()) );
+ GtkLabel *label = GTK_LABEL(GTK_BIN(node->GetData())->child);
wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
wxCHECK_RET( node, wxT("radiobox wrong index") );
- GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(node->GetData()) );
+ GtkLabel *g_label = GTK_LABEL(GTK_BIN(node->GetData())->child);
gtk_label_set( g_label, wxGTK_CONV( label ) );
}
while (node)
{
GtkButton *button = GTK_BUTTON( node->GetData() );
- GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
+ GtkLabel *label = GTK_LABEL(GTK_BIN(button)->child);
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() );
- GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
+ GtkLabel *label = GTK_LABEL(GTK_BIN(button)->child);
gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
GtkWidget *widget = GTK_WIDGET( node->GetData() );
gtk_widget_modify_style( widget, style );
- gtk_widget_modify_style( BUTTON_CHILD(node->GetData()), style );
+ gtk_widget_modify_style(GTK_BIN(widget)->child, style);
node = node->GetNext();
}
{
wxCHECK_RET( m_widget != NULL, wxT("invalid radiobutton") );
- GTKSetLabelForLabel(GTK_LABEL(BUTTON_CHILD(m_widget)), label);
+ GTKSetLabelForLabel(GTK_LABEL(GTK_BIN(m_widget)->child), label);
}
void wxRadioButton::SetValue( bool val )
if ( !wxControl::Enable( enable ) )
return FALSE;
- gtk_widget_set_sensitive( BUTTON_CHILD(m_widget), enable );
+ gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
return TRUE;
}
void wxRadioButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
- gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
+ gtk_widget_modify_style(GTK_BIN(m_widget)->child, style);
}
bool wxRadioButton::IsOwnGtkWindow( GdkWindow *window )
{
- return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
+ return window == GTK_BUTTON(m_widget)->event_window;
}
void wxRadioButton::OnInternalIdle()
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
- GdkWindow *win = TOGGLE_BUTTON_EVENT_WIN(m_widget);
+ GdkWindow *win = GTK_BUTTON(m_widget)->event_window;
if ( win && cursor.Ok())
{
/* I now set the cursor the anew in every OnInternalIdle call
extern "C" {
static void gtk_scrollbar_callback( GtkAdjustment *adjust,
- SCROLLBAR_CBACK_ARG
wxScrollBar *win )
{
if (g_isIdle) wxapp_install_idle_handler();
win->m_oldPos = adjust->value;
- wxEventType command = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget));
+ wxEventType command = GtkScrollTypeToWx(GTK_SCROLL_JUMP);
double dvalue = adjust->value;
int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5);
extern "C" {
static void gtk_slider_callback( GtkAdjustment *adjust,
- SCROLLBAR_CBACK_ARG
wxSlider *win )
{
if (g_isIdle) wxapp_install_idle_handler();
gtk_editable_delete_selection( GTK_EDITABLE(m_text) );
// This moves the cursor pos to behind the inserted text.
- gint len = GET_EDITABLE_POS(m_text);
+ gint len = gtk_editable_get_position(GTK_EDITABLE(m_text));
#if wxUSE_UNICODE
wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) );
gtk_entry_set_position( GTK_ENTRY(m_text), (int)pos );
// Bring editable's cursor uptodate. Bug in GTK.
- SET_EDITABLE_POS(m_text, (guint32)pos);
+ gtk_editable_set_position(GTK_EDITABLE(m_text), int(pos));
}
}
}
else
{
- return (long) GET_EDITABLE_POS(m_text);
+ return (long) gtk_editable_get_position(GTK_EDITABLE(m_text));
}
}
if (m_windowStyle & wxTE_MULTILINE)
g_signal_emit_by_name (m_text, "cut-clipboard");
else
- gtk_editable_cut_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG);
+ gtk_editable_cut_clipboard(GTK_EDITABLE(m_text));
}
void wxTextCtrl::Copy()
if (m_windowStyle & wxTE_MULTILINE)
g_signal_emit_by_name (m_text, "copy-clipboard");
else
- gtk_editable_copy_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG);
+ gtk_editable_copy_clipboard(GTK_EDITABLE(m_text));
}
void wxTextCtrl::Paste()
if (m_windowStyle & wxTE_MULTILINE)
g_signal_emit_by_name (m_text, "paste-clipboard");
else
- gtk_editable_paste_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG);
+ gtk_editable_paste_clipboard(GTK_EDITABLE(m_text));
}
// Undo/redo
GdkBitmap *mask = (GdkBitmap *) NULL;
if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
- GtkWidget *child = BUTTON_CHILD(m_widget);
+ GtkWidget *child = GTK_BIN(m_widget)->child;
if (child == NULL)
{
// initial bitmap
if (!wxControl::Enable(enable))
return false;
- gtk_widget_set_sensitive(BUTTON_CHILD(m_widget), enable);
+ gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
return true;
}
void wxToggleBitmapButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
- gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
+ gtk_widget_modify_style(GTK_BIN(m_widget)->child, style);
}
bool wxToggleBitmapButton::IsOwnGtkWindow(GdkWindow *window)
{
- return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
+ return window == GTK_BUTTON(m_widget)->event_window;
}
void wxToggleBitmapButton::OnInternalIdle()
if (g_globalCursor.Ok())
cursor = g_globalCursor;
- GdkWindow *win = TOGGLE_BUTTON_EVENT_WIN(m_widget);
+ GdkWindow *win = GTK_BUTTON(m_widget)->event_window;
if ( win && cursor.Ok() )
{
/* I now set the cursor the anew in every OnInternalIdle call
wxControl::SetLabel(label);
- gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), wxGTK_CONV( GetLabel() ) );
+ gtk_label_set(GTK_LABEL(GTK_BIN(m_widget)->child), wxGTK_CONV(GetLabel()));
}
bool wxToggleButton::Enable(bool enable /*=true*/)
if (!wxControl::Enable(enable))
return false;
- gtk_widget_set_sensitive(BUTTON_CHILD(m_widget), enable);
+ gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
return true;
}
void wxToggleButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
- gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
+ gtk_widget_modify_style(GTK_BIN(m_widget)->child, style);
}
bool wxToggleButton::IsOwnGtkWindow(GdkWindow *window)
{
- return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
+ return window == GTK_BUTTON(m_widget)->event_window;
}
void wxToggleButton::OnInternalIdle()
if (g_globalCursor.Ok())
cursor = g_globalCursor;
- GdkWindow *win = TOGGLE_BUTTON_EVENT_WIN(m_widget);
+ GdkWindow *win = GTK_BUTTON(m_widget)->event_window;
if ( win && cursor.Ok() )
{
/* I now set the cursor the anew in every OnInternalIdle call
extern "C" {
static void gtk_window_vscroll_callback( GtkAdjustment *adjust,
- SCROLLBAR_CBACK_ARG
wxWindowGTK *win )
{
DEBUG_MAIN_THREAD
win->m_oldVerticalPos = adjust->value;
- wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(sw->vscrollbar));
+ wxEventType command = GtkScrollWinTypeToWx(GTK_SCROLL_JUMP);
int value = (int)(adjust->value+0.5);
extern "C" {
static void gtk_window_hscroll_callback( GtkAdjustment *adjust,
- SCROLLBAR_CBACK_ARG
wxWindowGTK *win )
{
DEBUG_MAIN_THREAD
float diff = adjust->value - win->m_oldHorizontalPos;
if (fabs(diff) < 0.2) return;
- wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(sw->hscrollbar));
+ wxEventType command = GtkScrollWinTypeToWx(GTK_SCROLL_JUMP);
win->m_oldHorizontalPos = adjust->value;