changes to make wxGTK compile with GTK+ 2.0: now it does but the minimal

sample crashes on startup


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14567 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-03-12 19:24:30 +00:00
parent 7fccee998d
commit 9e691f46b2
65 changed files with 1902 additions and 1700 deletions

View File

@@ -21,13 +21,23 @@
#include "wx/dcmemory.h"
#include "wx/app.h"
#ifdef __WXGTK20__
// need this to get gdk_image_new_bitmap()
#define GDK_ENABLE_BROKEN
#endif
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#if (GTK_MINOR_VERSION > 0)
#include <gdk/gdkrgb.h>
#endif
#ifdef __WXGTK20__
#include <gdk/gdkimage.h>
#else // GTK+ 1.2
// VZ: is this still needed? seems to compile fine without it...
#if (GTK_MINOR_VERSION > 0)
#include <gdk/gdkrgb.h>
#endif
#endif // GTK+ 2.0/1.2
extern void gdk_wx_draw_bitmap (GdkDrawable *drawable,
GdkGC *gc,

View File

@@ -17,8 +17,7 @@
#include "wx/bmpbuttn.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// classes
@@ -199,7 +198,8 @@ wxString wxBitmapButton::GetLabel() const
void wxBitmapButton::ApplyWidgetStyle()
{
if (GTK_BUTTON(m_widget)->child == NULL) return;
if ( !BUTTON_CHILD(m_widget) )
return;
wxButton::ApplyWidgetStyle();
}
@@ -236,8 +236,8 @@ void wxBitmapButton::OnSetBitmap()
GdkBitmap *mask = (GdkBitmap *) NULL;
if (the_one.GetMask()) mask = the_one.GetMask()->GetBitmap();
GtkButton *bin = GTK_BUTTON(m_widget);
if (bin->child == NULL)
GtkWidget *child = BUTTON_CHILD(m_widget);
if (child == NULL)
{
// initial bitmap
GtkWidget *pixmap = gtk_pixmap_new(the_one.GetPixmap(), mask);
@@ -246,7 +246,7 @@ void wxBitmapButton::OnSetBitmap()
}
else
{ // subsequent bitmaps
GtkPixmap *g_pixmap = GTK_PIXMAP(bin->child);
GtkPixmap *g_pixmap = GTK_PIXMAP(child);
gtk_pixmap_set(g_pixmap, the_one.GetPixmap(), mask);
}
}

View File

@@ -17,8 +17,7 @@
#include "wx/button.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// classes
@@ -45,12 +44,12 @@ extern bool g_blockEventsOnDrag;
static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button )
{
if (g_isIdle)
if (g_isIdle)
wxapp_install_idle_handler();
if (!button->m_hasVMT) return;
if (g_blockEventsOnDrag) return;
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId());
event.SetEventObject(button);
button->GetEventHandler()->ProcessEvent(event);
@@ -91,26 +90,26 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
if (label2.GetChar(i) == wxT('&'))
label2.SetChar(i,wxT('_'));
}
GtkWidget *accel_label = gtk_accel_label_new( label2.mb_str() );
gtk_widget_show( accel_label );
m_widget = gtk_button_new();
gtk_container_add( GTK_CONTAINER(m_widget), accel_label );
gtk_accel_label_set_accel_widget( GTK_ACCEL_LABEL(accel_label), m_widget );
guint accel_key = gtk_label_parse_uline (GTK_LABEL(accel_label), label2.mb_str() );
gtk_accel_label_refetch( GTK_ACCEL_LABEL(accel_label) );
wxControl::SetLabel( label );
*/
m_widget = gtk_button_new_with_label("");
SetLabel( label );
#if (GTK_MINOR_VERSION > 0)
#if (GTK_MINOR_VERSION > 0)
if (style & wxNO_BORDER)
gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE );
#endif
@@ -119,9 +118,9 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
m_parent->DoAddChild( this );
PostCreation();
SetFont( parent->GetFont() );
wxSize best_size( DoGetBestSize() );
@@ -147,7 +146,7 @@ void wxButton::SetDefault()
{
GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT );
gtk_widget_grab_default( m_widget );
SetSize( m_x, m_y, m_width, m_height );
}
@@ -160,18 +159,18 @@ wxSize wxButton::GetDefaultSize()
void wxButton::SetLabel( const wxString &label )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid button") );
wxControl::SetLabel( label );
gtk_label_set( GTK_LABEL( GTK_BUTTON(m_widget)->child ), GetLabel().mbc_str() );
gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), GetLabel().mbc_str() );
}
bool wxButton::Enable( bool enable )
{
if ( !wxControl::Enable( enable ) )
return FALSE;
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
gtk_widget_set_sensitive( BUTTON_CHILD(m_widget), enable );
return TRUE;
}
@@ -180,18 +179,18 @@ void wxButton::ApplyWidgetStyle()
{
SetWidgetStyle();
gtk_widget_set_style( m_widget, m_widgetStyle );
gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle );
gtk_widget_set_style( BUTTON_CHILD(m_widget), m_widgetStyle );
}
wxSize wxButton::DoGetBestSize() const
{
wxSize ret( wxControl::DoGetBestSize() );
if (!HasFlag(wxBU_EXACTFIT))
{
if (ret.x < 80) ret.x = 80;
}
return ret;
}

View File

@@ -18,8 +18,7 @@
#include "wx/checkbox.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -107,7 +106,7 @@ bool wxCheckBox::Create(wxWindow *parent,
else
{
m_widgetCheckbox = gtk_check_button_new_with_label( m_label.mbc_str() );
m_widgetLabel = GTK_BUTTON( m_widgetCheckbox )->child;
m_widgetLabel = BUTTON_CHILD( m_widgetCheckbox );
m_widget = m_widgetCheckbox;
}
@@ -188,7 +187,7 @@ void wxCheckBox::ApplyWidgetStyle()
bool wxCheckBox::IsOwnGtkWindow( GdkWindow *window )
{
return (window == GTK_TOGGLE_BUTTON(m_widget)->event_window);
return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
}
void wxCheckBox::OnInternalIdle()
@@ -196,14 +195,15 @@ void wxCheckBox::OnInternalIdle()
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
if (GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window && cursor.Ok())
GdkWindow *event_window = TOGGLE_BUTTON_EVENT_WIN(m_widgetCheckbox);
if ( event_window && cursor.Ok() )
{
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window, cursor.GetCursor() );
gdk_window_set_cursor( event_window, cursor.GetCursor() );
}
UpdateWindowUI();

View File

@@ -18,8 +18,7 @@
#include "wx/choice.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -229,16 +228,18 @@ int wxChoice::FindString( const wxString &string ) const
{
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = (GtkLabel *) NULL;
if (bin->child) label = GTK_LABEL(bin->child);
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
if (bin->child)
label = GTK_LABEL(bin->child);
if (!label)
label = GTK_LABEL( BUTTON_CHILD(m_widget) );
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
if (string == wxString(label->label,*wxConvCurrent))
return count;
if (string == wxString(label->label,*wxConvCurrent))
return count;
child = child->next;
count++;
child = child->next;
count++;
}
return -1;
@@ -282,8 +283,10 @@ wxString wxChoice::GetString( int n ) const
if (count == n)
{
GtkLabel *label = (GtkLabel *) NULL;
if (bin->child) label = GTK_LABEL(bin->child);
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
if (bin->child)
label = GTK_LABEL(bin->child);
if (!label)
label = GTK_LABEL( BUTTON_CHILD(m_widget) );
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
@@ -337,8 +340,10 @@ void wxChoice::ApplyWidgetStyle()
GtkBin *bin = GTK_BIN( child->data );
GtkWidget *label = (GtkWidget *) NULL;
if (bin->child) label = bin->child;
if (!label) label = GTK_BUTTON(m_widget)->child;
if (bin->child)
label = bin->child;
if (!label)
label = BUTTON_CHILD(m_widget);
gtk_widget_set_style( label, m_widgetStyle );
@@ -434,7 +439,8 @@ wxSize wxChoice::DoGetBestSize() const
if ( ret.x < 80 )
ret.x = 80;
ret.y = 16 + gdk_char_height( m_widget->style->font, 'H' );
ret.y = 16 + gdk_char_height(GET_STYLE_FONT( m_widget->style ), 'H');
return ret;
}

View File

@@ -20,8 +20,7 @@
#include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -492,11 +491,7 @@ void wxComboBox::Copy()
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if defined(__WXGTK13__) || (GTK_MINOR_VERSION > 0)
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
#else
gtk_editable_copy_clipboard( GTK_EDITABLE(entry), 0 );
#endif
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG );
}
void wxComboBox::Cut()
@@ -504,11 +499,7 @@ void wxComboBox::Cut()
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if defined(__WXGTK13__) || (GTK_MINOR_VERSION > 0)
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
#else
gtk_editable_cut_clipboard( GTK_EDITABLE(entry), 0 );
#endif
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG );
}
void wxComboBox::Paste()
@@ -516,11 +507,7 @@ void wxComboBox::Paste()
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if defined(__WXGTK13__) || (GTK_MINOR_VERSION > 0)
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
#else
gtk_editable_paste_clipboard( GTK_EDITABLE(entry), 0 );
#endif
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG);
}
void wxComboBox::SetInsertionPoint( long pos )
@@ -540,8 +527,7 @@ void wxComboBox::SetInsertionPointEnd()
long wxComboBox::GetInsertionPoint() const
{
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
return (long) GTK_EDITABLE(entry)->current_pos;
return (long) GET_EDITABLE_POS( GTK_COMBO(m_widget)->entry );
}
long wxComboBox::GetLastPosition() const

View File

@@ -1358,11 +1358,11 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
y = YLOG2DEV(y);
#if defined(__WXGTK20__) && wxUSE_WCHAR_T
/* FIXME: the layout engine should probably be abstracted at a higher level in wxDC... */
// TODO: the layout engine should be abstracted at a higher level!
PangoLayout *layout = pango_layout_new(m_context);
pango_layout_set_font_description(layout, m_fontdesc);
{
wxWX2MBbuf data = text.mb_str(wxConvUTF8);
const wxWX2MBbuf data = text.mb_str(wxConvUTF8);
pango_layout_set_text(layout, data, strlen(data));
}
PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
@@ -1371,7 +1371,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
wxCoord width = rect.width;
wxCoord height = rect.height;
gdk_draw_layout( m_window, m_textGC, x, y, layout );
#else
#else // GTK+ 1.x
wxCoord width = gdk_string_width( font, text.mbc_str() );
wxCoord height = font->ascent + font->descent;
@@ -1382,7 +1382,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() );
}
gdk_draw_string( m_window, font, m_textGC, x, y + font->ascent, text.mbc_str() );
#endif
#endif // GTK+ 2.0/1.x
/* CMB 17/7/98: simple underline: ignores scaling and underlying
X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS

View File

@@ -21,8 +21,8 @@
#include "wx/intl.h"
#include "wx/utils.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkprivate.h>
#include <gtk/gtkdnd.h>

View File

@@ -30,9 +30,8 @@
#include <strings.h>
#include <gdk/gdk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkprivate.h>
#include <gtk/gtk.h>
// ----------------------------------------------------------------------------
// constants
@@ -656,13 +655,13 @@ extern GdkFont *GtkGetDefaultGuiFont()
GtkStyle *def = gtk_rc_get_style( widget );
if (def)
{
g_systemDefaultGuiFont = gdk_font_ref( def->font );
g_systemDefaultGuiFont = gdk_font_ref( GET_STYLE_FONT(def) );
}
else
{
def = gtk_widget_get_default_style();
if (def)
g_systemDefaultGuiFont = gdk_font_ref( def->font );
g_systemDefaultGuiFont = gdk_font_ref( GET_STYLE_FONT(def) );
}
gtk_widget_destroy( widget );
}

View File

@@ -22,7 +22,7 @@
#include "wx/debug.h"
#include "wx/msgdlg.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -133,13 +133,13 @@ wxFontDialog::wxFontDialog( wxWindow *parent, wxFontData *fontdata )
GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback), (gpointer*)this );
// strange way to internationalize
gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->ok_button)->child ), wxConvCurrent->cWX2MB(_("OK")) );
gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), wxConvCurrent->cWX2MB(_("OK")) );
gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked",
GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback), (gpointer*)this );
// strange way to internationalize
gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->cancel_button)->child ), wxConvCurrent->cWX2MB(_("Cancel")) );
gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), wxConvCurrent->cWX2MB(_("Cancel")) );
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback), (gpointer)this );

View File

@@ -34,8 +34,8 @@
#include "wx/dcclient.h"
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>

View File

@@ -363,12 +363,12 @@ wxMenuBar *wxMDIChildFrame::GetMenuBar() const
void wxMDIChildFrame::Activate()
{
#if (GTK_MINOR_VERSION > 0)
#if defined(__WXGTK20__) || (GTK_MINOR_VERSION > 0)
wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent();
GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget);
gint pageno = gtk_notebook_page_num( notebook, m_page->child );
gint pageno = gtk_notebook_page_num( notebook, m_widget );
gtk_notebook_set_page( notebook, pageno );
#else
#else // GTK+ 1.0
// the only way I can see to do this under gtk+ 1.0.X would
// be to keep track of page numbers, start at first and
// do "next" enough times to get to this page number - messy
@@ -402,7 +402,7 @@ void wxMDIChildFrame::SetTitle( const wxString &title )
wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent();
GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget);
gtk_notebook_set_tab_label_text(notebook, m_page->child, title.mbc_str());
gtk_notebook_set_tab_label_text(notebook, m_widget, title.mbc_str());
}
//-----------------------------------------------------------------------------

View File

@@ -22,9 +22,26 @@
#include "wx/accel.h"
#endif // wxUSE_ACCEL
#include <gdk/gdk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
// FIXME: is this right? somehow I don't think so (VZ)
#ifdef __WXGTK20__
#include <glib-object.h>
#define gtk_accel_group_attach(g, o) _gtk_accel_group_attach((g), (o))
#define gtk_accel_group_detach(g, o) _gtk_accel_group_detach((g), (o))
#define gtk_menu_ensure_uline_accel_group(m) gtk_menu_get_accel_group(m)
#define ACCEL_OBJECT GObject
#define ACCEL_OBJECTS(a) (a)->acceleratables
#define ACCEL_OBJ_CAST(obj) G_OBJECT(obj)
#else // GTK+ 1.x
#define ACCEL_OBJECT GtkObject
#define ACCEL_OBJECTS(a) (a)->attach_objects
#define ACCEL_OBJ_CAST(obj) GTK_OBJECT(obj)
#endif
//-----------------------------------------------------------------------------
// idle system
@@ -33,14 +50,21 @@
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
#if (GTK_MINOR_VERSION > 0) && wxUSE_ACCEL
static wxString GetHotKey( const wxMenuItem& item );
#if GTK_CHECK_VERSION(1, 2, 0) && wxUSE_ACCEL
static wxString GetHotKey( const wxMenuItem& item );
#endif
//-----------------------------------------------------------------------------
// substitute for missing GtkPixmapMenuItem
//-----------------------------------------------------------------------------
// FIXME: I can't make this compile with GTK+ 2.0, disabling for now (VZ)
#ifndef __WXGTK20__
#define USE_MENU_BITMAPS
#endif
#ifdef USE_MENU_BITMAPS
#define GTK_TYPE_PIXMAP_MENU_ITEM (gtk_pixmap_menu_item_get_type ())
#define GTK_PIXMAP_MENU_ITEM(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_PIXMAP_MENU_ITEM, GtkPixmapMenuItem))
#define GTK_PIXMAP_MENU_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_PIXMAP_MENU_ITEM, GtkPixmapMenuItemClass))
@@ -77,6 +101,8 @@ GtkWidget* gtk_pixmap_menu_item_new (void);
void gtk_pixmap_menu_item_set_pixmap (GtkPixmapMenuItem *menu_item,
GtkWidget *pixmap);
#endif // USE_MENU_BITMAPS
//-----------------------------------------------------------------------------
// idle system
//-----------------------------------------------------------------------------
@@ -91,7 +117,7 @@ static wxString wxReplaceUnderscore( const wxString& title )
{
if (*pc == wxT('&'))
{
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
str << wxT('_');
}
else if (*pc == wxT('/'))
@@ -139,7 +165,7 @@ wxMenuBar::wxMenuBar( long style )
m_menus.DeleteContents( TRUE );
/* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
m_accel = gtk_accel_group_new();
m_factory = gtk_item_factory_new( GTK_TYPE_MENU_BAR, "<main>", m_accel );
m_menubar = gtk_item_factory_get_widget( m_factory, "<main>" );
@@ -180,7 +206,7 @@ wxMenuBar::wxMenuBar()
m_menus.DeleteContents( TRUE );
/* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
m_accel = gtk_accel_group_new();
m_factory = gtk_item_factory_new( GTK_TYPE_MENU_BAR, "<main>", m_accel );
m_menubar = gtk_item_factory_get_widget( m_factory, "<main>" );
@@ -204,13 +230,13 @@ static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( (wxWindow*) NULL );
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native hot keys */
gtk_accel_group_detach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) );
gtk_accel_group_detach( menu->m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) );
#endif
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
@@ -227,16 +253,16 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( win );
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native hot keys */
GtkObject *obj = GTK_OBJECT(top_frame->m_widget);
if ( !g_slist_find( menu->m_accel->attach_objects, obj ) )
ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget);
if ( !g_slist_find( ACCEL_OBJECTS(menu->m_accel), obj ) )
gtk_accel_group_attach( menu->m_accel, obj );
#endif
#endif // GTK+ 1.2.1+
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
while (node)
@@ -251,16 +277,16 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win )
void wxMenuBar::SetInvokingWindow( wxWindow *win )
{
m_invokingWindow = win;
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native key accelerators indicated by underscroes */
GtkObject *obj = GTK_OBJECT(top_frame->m_widget);
if ( !g_slist_find( m_accel->attach_objects, obj ) )
ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget);
if ( !g_slist_find( ACCEL_OBJECTS(m_accel), obj ) )
gtk_accel_group_attach( m_accel, obj );
#endif
#endif // GTK+ 1.2.1+
wxMenuList::Node *node = m_menus.GetFirst();
while (node)
@@ -274,14 +300,14 @@ void wxMenuBar::SetInvokingWindow( wxWindow *win )
void wxMenuBar::UnsetInvokingWindow( wxWindow *win )
{
m_invokingWindow = (wxWindow*) NULL;
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native key accelerators indicated by underscroes */
gtk_accel_group_detach( m_accel, GTK_OBJECT(top_frame->m_widget) );
#endif
gtk_accel_group_detach( m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) );
#endif // GTK+ 1.2.1+
wxMenuList::Node *node = m_menus.GetFirst();
while (node)
@@ -308,7 +334,7 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title)
menu->SetTitle( str );
/* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
/* local buffer in multibyte form */
wxString buf;
@@ -527,7 +553,7 @@ wxString wxMenuBar::GetLabelTop( size_t pos ) const
wxString label;
wxString text( menu->GetTitle() );
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
for ( const wxChar *pc = text.c_str(); *pc; pc++ )
{
if ( *pc == wxT('_') || *pc == wxT('&') )
@@ -764,7 +790,7 @@ void wxMenuItem::DoSetText( const wxString& str )
{
if (*pc == wxT('&'))
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
m_text << wxT('_');
}
else if ( *pc == wxT('_') ) // escape underscores
@@ -774,7 +800,7 @@ void wxMenuItem::DoSetText( const wxString& str )
else if (*pc == wxT('/')) /* we have to filter out slashes ... */
{
m_text << wxT('\\'); /* ... and replace them with back slashes */
#endif
#endif // GTK+ 1.2.0+
}
else
m_text << *pc;
@@ -782,13 +808,14 @@ void wxMenuItem::DoSetText( const wxString& str )
/* only GTK 1.2 knows about hot keys */
m_hotKey = wxT("");
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
if(*pc == wxT('\t'))
{
pc++;
m_hotKey = pc;
}
#endif
#endif // GTK+ 1.2.0+
}
#if wxUSE_ACCEL
@@ -869,7 +896,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler)
void wxMenu::Init()
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
m_accel = gtk_accel_group_new();
m_factory = gtk_item_factory_new( GTK_TYPE_MENU, "<main>", m_accel );
m_menu = gtk_item_factory_get_widget( m_factory, "<main>" );
@@ -879,7 +906,7 @@ void wxMenu::Init()
m_owner = (GtkWidget*) NULL;
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
/* Tearoffs are entries, just like separators. So if we want this
menu to be a tear-off one, we just append a tearoff entry
immediately. */
@@ -894,7 +921,7 @@ void wxMenu::Init()
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
//GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, "<main>/tearoff" );
}
#endif
#endif // GTK+ 1.2.0+
// append the title as the very first entry if we have it
if ( !!m_title )
@@ -917,11 +944,13 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
{
GtkWidget *menuItem;
#if defined(USE_MENU_BITMAPS) || !GTK_CHECK_VERSION(1, 2, 0)
bool appended = FALSE;
#endif
if ( mitem->IsSeparator() )
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
GtkItemFactoryEntry entry;
entry.path = (char *)"/sep";
entry.callback = (GtkItemFactoryCallback) NULL;
@@ -939,7 +968,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
}
else if ( mitem->IsSubMenu() )
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
/* text has "_" instead of "&" after mitem->SetText() */
wxString text( mitem->GetText() );
@@ -971,6 +1000,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
if ( m_invokingWindow )
wxMenubarSetInvokingWindow(mitem->GetSubMenu(), m_invokingWindow);
}
#ifdef USE_MENU_BITMAPS
else if (mitem->GetBitmap().Ok()) // An item with bitmap
{
wxString text( mitem->GetText() );
@@ -1006,9 +1036,10 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
appended = TRUE; // We've done this, don't do it again
}
#endif // USE_MENU_BITMAPS
else // a normal item
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
/* text has "_" instead of "&" after mitem->SetText() */
wxString text( mitem->GetText() );
@@ -1064,7 +1095,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
(gpointer)this );
}
#if GTK_MINOR_VERSION == 0
#if !GTK_CHECK_VERSION(1, 2, 0)
if (!appended)
{
gtk_menu_append( GTK_MENU(m_menu), menuItem );
@@ -1144,7 +1175,7 @@ int wxMenu::FindMenuIdByMenuItem( GtkWidget *menuItem ) const
// helpers
// ----------------------------------------------------------------------------
#if (GTK_MINOR_VERSION > 0) && wxUSE_ACCEL
#if GTK_CHECK_VERSION(1, 2, 0) && wxUSE_ACCEL
static wxString GetHotKey( const wxMenuItem& item )
{
@@ -1225,6 +1256,8 @@ static wxString GetHotKey( const wxMenuItem& item )
// substitute for missing GtkPixmapMenuItem
//-----------------------------------------------------------------------------
#ifdef USE_MENU_BITMAPS
/*
* Copyright (C) 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
@@ -1595,4 +1628,5 @@ changed_have_pixmap_status (GtkPixmapMenuItem *menu_item)
gtk_widget_queue_resize(GTK_WIDGET(menu_item));
}
#endif // USE_MENU_BITMAPS

View File

@@ -21,9 +21,9 @@
#include "wx/intl.h"
#include "wx/log.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h"
#include <gdk/gdkkeysyms.h>
// ----------------------------------------------------------------------------
@@ -686,7 +686,7 @@ void wxNotebook::ApplyWidgetStyle()
bool wxNotebook::IsOwnGtkWindow( GdkWindow *window )
{
return ((m_widget->window == window) ||
(GTK_NOTEBOOK(m_widget)->panel == window));
(NOTEBOOK_PANEL(m_widget) == window));
}
//-----------------------------------------------------------------------------

View File

@@ -21,8 +21,7 @@
#include "wx/frame.h"
#include "wx/log.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
#include "wx/gtk/win_gtk.h"
@@ -427,10 +426,10 @@ int wxRadioBox::FindString( const wxString &s ) const
wxNode *node = m_boxes.First();
while (node)
{
GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
if (s == label->label)
return count;
GtkLabel *label = GTK_LABEL( button->child );
if (s == label->label) return count;
count++;
node = node->Next();
@@ -504,8 +503,7 @@ wxString wxRadioBox::GetString( int n ) const
wxCHECK_MSG( node, wxT(""), wxT("radiobox wrong index") );
GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *label = GTK_LABEL( button->child );
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
return wxString( label->label );
}
@@ -527,8 +525,7 @@ void wxRadioBox::SetString( int item, const wxString& label )
wxCHECK_RET( node, wxT("radiobox wrong index") );
GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *g_label = GTK_LABEL( button->child );
GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
gtk_label_set( g_label, label.mbc_str() );
}
@@ -542,9 +539,10 @@ bool wxRadioBox::Enable( bool enable )
while (node)
{
GtkButton *button = GTK_BUTTON( node->Data() );
GtkWidget *label = button->child;
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( label, enable );
gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
node = node->Next();
}
@@ -560,9 +558,10 @@ void wxRadioBox::Enable( int item, bool enable )
wxCHECK_RET( node, wxT("radiobox wrong index") );
GtkButton *button = GTK_BUTTON( node->Data() );
GtkWidget *label = button->child;
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( label, enable );
gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
}
void wxRadioBox::Show( int item, bool show )
@@ -591,7 +590,8 @@ wxString wxRadioBox::GetStringSelection() const
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
if (button->active)
{
GtkLabel *label = GTK_LABEL( GTK_BUTTON(button)->child );
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
return label->label;
}
node = node->Next();
@@ -663,8 +663,7 @@ void wxRadioBox::ApplyWidgetStyle()
GtkWidget *widget = GTK_WIDGET( node->Data() );
gtk_widget_set_style( widget, m_widgetStyle );
GtkButton *button = GTK_BUTTON( node->Data() );
gtk_widget_set_style( button->child, m_widgetStyle );
gtk_widget_set_style( BUTTON_CHILD(node->Data()), m_widgetStyle );
node = node->Next();
}

View File

@@ -18,8 +18,7 @@
#include "wx/radiobut.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -148,8 +147,7 @@ void wxRadioButton::SetLabel( const wxString& label )
wxCHECK_RET( m_widget != NULL, wxT("invalid radiobutton") );
wxControl::SetLabel( label );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkLabel *g_label = GTK_LABEL( bin->child );
GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(m_widget) );
gtk_label_set( g_label, GetLabel().mbc_str() );
}
@@ -188,7 +186,7 @@ bool wxRadioButton::Enable( bool enable )
if ( !wxControl::Enable( enable ) )
return FALSE;
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
gtk_widget_set_sensitive( BUTTON_CHILD(m_widget), enable );
return TRUE;
}
@@ -197,12 +195,12 @@ void wxRadioButton::ApplyWidgetStyle()
{
SetWidgetStyle();
gtk_widget_set_style( m_widget, m_widgetStyle );
gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle );
gtk_widget_set_style( BUTTON_CHILD(m_widget), m_widgetStyle );
}
bool wxRadioButton::IsOwnGtkWindow( GdkWindow *window )
{
return (window == GTK_TOGGLE_BUTTON(m_widget)->event_window);
return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
}
void wxRadioButton::OnInternalIdle()
@@ -210,14 +208,15 @@ void wxRadioButton::OnInternalIdle()
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
if (GTK_TOGGLE_BUTTON(m_widget)->event_window && cursor.Ok())
GdkWindow *win = TOGGLE_BUTTON_EVENT_WIN(m_widget);
if ( win && cursor.Ok())
{
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widget)->event_window, cursor.GetCursor() );
gdk_window_set_cursor( win, cursor.GetCursor() );
}
UpdateWindowUI();

View File

@@ -20,12 +20,11 @@
// headers
// ----------------------------------------------------------------------------
#include "wx/log.h"
#include "wx/region.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/log.h"
#include "wx/gtk/private.h"
// ----------------------------------------------------------------------------
// wxRegionRefData: private class containing the information about the region
@@ -87,7 +86,7 @@ void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
m_refData = new wxRegionRefData();
#ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_rectangle( rect );
M_REGIONDATA->m_region = gdk_region_rectangle( &rect );
#else
GdkRegion *reg = gdk_region_new();
M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect );
@@ -170,7 +169,7 @@ bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
m_refData = new wxRegionRefData();
#ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_rectangle( rect );
M_REGIONDATA->m_region = gdk_region_rectangle( &rect );
#else
GdkRegion *reg = gdk_region_new();
M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect );
@@ -498,9 +497,9 @@ void wxRIRefData::CreateRects( const wxRegion& region )
if (!gdkregion) return;
#ifdef __WXGTK20__
GdkRectangles *gdkrects = NULL;
GdkRectangle *gdkrects = NULL;
gint numRects = 0;
gdk_region_get_rectangles( gdkregion, &gdkrect, &numRects );
gdk_region_get_rectangles( gdkregion, &gdkrects, &numRects );
m_numRects = numRects;
if (numRects)
@@ -516,8 +515,8 @@ void wxRIRefData::CreateRects( const wxRegion& region )
wr.height = gr.height;
}
}
g_delete( gdkrects ); // delete []
#else
g_free( gdkrects );
#else // GTK+ 1.x
Region r = ((GdkRegionPrivate *)gdkregion)->xregion;
if (r)
{
@@ -536,7 +535,7 @@ void wxRIRefData::CreateRects( const wxRegion& region )
}
}
}
#endif
#endif // GTK+ 2.0/1.x
}
wxRegionIterator::wxRegionIterator()

View File

@@ -22,8 +22,7 @@
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -45,7 +44,11 @@ static const float sensitivity = 0.02;
// "value_changed"
//-----------------------------------------------------------------------------
static void gtk_scrollbar_callback( GtkAdjustment *adjust, wxScrollBar *win )
// FIXME: is GtkScrollType really passed to us as 2nd argument?
static void gtk_scrollbar_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxScrollBar *win )
{
if (g_isIdle) wxapp_install_idle_handler();
@@ -57,14 +60,8 @@ static void gtk_scrollbar_callback( GtkAdjustment *adjust, wxScrollBar *win )
win->m_oldPos = adjust->value;
GtkRange *range = GTK_RANGE( win->m_widget );
wxEventType command = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget));
wxEventType command = wxEVT_SCROLL_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLL_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLL_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLL_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLL_PAGEDOWN;
double dvalue = adjust->value;
int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5);
@@ -93,7 +90,10 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget,
// g_blockEventsOnScroll = TRUE; doesn't work in DialogEd
// FIXME: there is no slider field any more, what was meant here?
#ifndef __WXGTK20__
win->m_isScrolling = (gdk_event->window == widget->slider);
#endif
return FALSE;
}
@@ -316,11 +316,14 @@ void wxScrollBar::SetViewLength( int viewLength )
bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window )
{
GtkRange *range = GTK_RANGE(m_widget);
return ( (window == GTK_WIDGET(range)->window) ||
(window == range->trough) ||
(window == range->slider) ||
(window == range->step_forw) ||
(window == range->step_back) );
return ( (window == GTK_WIDGET(range)->window)
#ifndef __WXGTK20__
|| (window == range->trough)
|| (window == range->slider)
|| (window == range->step_forw)
|| (window == range->step_back)
#endif // GTK+ 1.x
);
}
void wxScrollBar::ApplyWidgetStyle()

View File

@@ -31,10 +31,10 @@
#include "wx/utils.h"
#include "wx/dcclient.h"
#include "wx/gtk/scrolwin.h"
#include "wx/scrolwin.h"
#include "wx/panel.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h"
// ----------------------------------------------------------------------------
@@ -72,7 +72,9 @@ extern bool g_isIdle;
// "value_changed" from m_vAdjust
//-----------------------------------------------------------------------------
static void gtk_scrolled_window_vscroll_callback( GtkAdjustment *adjust, wxScrolledWindow *win )
static void gtk_scrolled_window_vscroll_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxScrolledWindow *win )
{
if (g_isIdle)
wxapp_install_idle_handler();
@@ -81,14 +83,17 @@ static void gtk_scrolled_window_vscroll_callback( GtkAdjustment *adjust, wxScrol
if (!win->m_hasVMT) return;
win->GtkVScroll( adjust->value );
win->GtkVScroll( adjust->value,
GET_SCROLL_TYPE(GTK_SCROLLED_WINDOW(win->m_widget)->vscrollbar) );
}
//-----------------------------------------------------------------------------
// "value_changed" from m_hAdjust
//-----------------------------------------------------------------------------
static void gtk_scrolled_window_hscroll_callback( GtkAdjustment *adjust, wxScrolledWindow *win )
static void gtk_scrolled_window_hscroll_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxScrolledWindow *win )
{
if (g_isIdle)
wxapp_install_idle_handler();
@@ -96,7 +101,8 @@ static void gtk_scrolled_window_hscroll_callback( GtkAdjustment *adjust, wxScrol
if (g_blockEventsOnDrag) return;
if (!win->m_hasVMT) return;
win->GtkHScroll( adjust->value );
win->GtkHScroll( adjust->value,
GET_SCROLL_TYPE(GTK_SCROLLED_WINDOW(win->m_widget)->hscrollbar) );
}
//-----------------------------------------------------------------------------
@@ -111,7 +117,11 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget,
wxapp_install_idle_handler();
g_blockEventsOnScroll = TRUE;
// FIXME: there is no slider field any more, what was meant here?
#ifndef __WXGTK20__
win->m_isScrolling = (gdk_event->window == widget->slider);
#endif
return FALSE;
}
@@ -512,7 +522,9 @@ void wxScrolledWindow::Scroll( int x_pos, int y_pos )
}
}
void wxScrolledWindow::GtkVScroll( float value )
// TODO: [VH]Scroll functions should be combined
void wxScrolledWindow::GtkVScroll( float value, unsigned int scroll_type )
{
if (!m_targetWindow)
return;
@@ -525,21 +537,14 @@ void wxScrolledWindow::GtkVScroll( float value )
if (y_pos == m_yScrollPosition)
return;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
GtkRange *range = GTK_RANGE(scrolledWindow->vscrollbar);
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
wxEventType command = GtkScrollWinTypeToWx(scroll_type);
wxScrollWinEvent event( command, y_pos, wxVERTICAL );
event.SetEventObject( this );
GetEventHandler()->ProcessEvent( event );
}
void wxScrolledWindow::GtkHScroll( float value )
void wxScrolledWindow::GtkHScroll( float value, unsigned int scroll_type )
{
if (!m_targetWindow)
return;
@@ -552,14 +557,7 @@ void wxScrolledWindow::GtkHScroll( float value )
if (x_pos == m_xScrollPosition)
return;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
GtkRange *range = GTK_RANGE(scrolledWindow->hscrollbar);
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
wxEventType command = GtkScrollWinTypeToWx(scroll_type);
wxScrollWinEvent event( command, x_pos, wxHORIZONTAL );
event.SetEventObject( this );

View File

@@ -19,8 +19,7 @@
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -41,7 +40,9 @@ static const float sensitivity = 0.02;
// "value_changed"
//-----------------------------------------------------------------------------
static void gtk_slider_callback( GtkAdjustment *adjust, wxSlider *win )
static void gtk_slider_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxSlider *win )
{
if (g_isIdle) wxapp_install_idle_handler();
@@ -53,13 +54,7 @@ static void gtk_slider_callback( GtkAdjustment *adjust, wxSlider *win )
win->m_oldPos = adjust->value;
GtkRange *range = GTK_RANGE( win->m_widget );
wxEventType command = wxEVT_SCROLL_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLL_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLL_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLL_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLL_PAGEDOWN;
wxEventType command = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget));
double dvalue = adjust->value;
int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5);
@@ -247,11 +242,14 @@ int wxSlider::GetLineSize() const
bool wxSlider::IsOwnGtkWindow( GdkWindow *window )
{
GtkRange *range = GTK_RANGE(m_widget);
return ( (window == GTK_WIDGET(range)->window) ||
(window == range->trough) ||
(window == range->slider) ||
(window == range->step_forw) ||
(window == range->step_back) );
return ( (window == GTK_WIDGET(range)->window)
#ifndef __WXGTK20__
|| (window == range->trough)
|| (window == range->slider)
|| (window == range->step_forw)
|| (window == range->step_back)
#endif // GTK+ 1.x
);
}
void wxSlider::ApplyWidgetStyle()

View File

@@ -21,8 +21,7 @@
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system

View File

@@ -26,9 +26,8 @@
#include "wx/frame.h"
#include "glib.h"
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include <glib.h>
#include "wx/gtk/private.h"
extern GdkFont *GtkGetDefaultGuiFont();
@@ -222,7 +221,14 @@ bool wxToolBar::Create( wxWindow *parent,
GtkOrientation orient = style & wxTB_VERTICAL ? GTK_ORIENTATION_VERTICAL
: GTK_ORIENTATION_HORIZONTAL;
#ifdef __WXGTK20__
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
gtk_toolbar_set_orientation(m_toolbar, orient);
gtk_toolbar_set_style(m_toolbar, GTK_TOOLBAR_ICONS);
#else
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new( orient, GTK_TOOLBAR_ICONS ) );
#endif
SetToolSeparation(7);
@@ -242,8 +248,11 @@ bool wxToolBar::Create( wxWindow *parent,
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
// FIXME: there is no such function for toolbars in 2.0
#ifndef __WXGTK20__
if (style & wxTB_FLAT)
gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE );
#endif
m_fg = new GdkColor;
@@ -270,8 +279,9 @@ bool wxToolBar::Create( wxWindow *parent,
GTK_TOOLBAR(m_toolbar)->tooltips->tip_window ) );
g_style->bg[GTK_STATE_NORMAL] = *m_bg;
gdk_font_unref( g_style->font );
g_style->font = gdk_font_ref( GtkGetDefaultGuiFont() );
SET_STYLE_FONT(g_style, GtkGetDefaultGuiFont());
gtk_widget_set_style( GTK_TOOLBAR(m_toolbar)->tooltips->tip_window, g_style );
m_parent->DoAddChild( this );
@@ -478,7 +488,11 @@ void wxToolBar::SetMargins( int x, int y )
void wxToolBar::SetToolSeparation( int separation )
{
// FIXME: this function disappeared
#ifndef __WXGTK20__
gtk_toolbar_set_space_size( m_toolbar, separation );
#endif
m_toolSeparation = separation;
}

View File

@@ -23,9 +23,13 @@
#include <ctype.h>
#include <math.h> // for fabs
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include "gdk/gdkkeysyms.h"
// TODO: reimplement wxTextCtrl using GtkTextView
#ifdef __WXGTK20__
#define GTK_ENABLE_BROKEN // need this to get GtkText at all
#endif // __WXGTK20__
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
//-----------------------------------------------------------------------------
// idle system
@@ -212,7 +216,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
bool multi_line = (style & wxTE_MULTILINE) != 0;
if (multi_line)
{
#if (GTK_MINOR_VERSION > 2)
#ifdef __WXGTK13__
/* a multi-line edit control: create a vertical scrollbar by default and
horizontal if requested */
bool bHasHScrollbar = (style & wxHSCROLL) != 0;
@@ -234,7 +238,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
/* always wrap words */
gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE );
#if (GTK_MINOR_VERSION > 2)
#ifdef __WXGTK13__
/* put the horizontal scrollbar in the lower left hand corner */
if (bHasHScrollbar)
{
@@ -296,7 +300,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
{
gint tmp = 0;
#if GTK_MINOR_VERSION == 0
#if !GTK_CHECK_VERSION(1, 2, 0)
// if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in
// gtk_editable_insert_text()
gtk_widget_realize(m_text);
@@ -312,8 +316,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
if (multi_line)
{
/* bring editable's cursor uptodate. bug in GTK. */
GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
}
}
@@ -446,7 +449,7 @@ void wxTextCtrl::WriteText( const wxString &text )
if ( m_windowStyle & wxTE_MULTILINE )
{
// After cursor movements, gtk_text_get_point() is wrong by one.
gtk_text_set_point( GTK_TEXT(m_text), GTK_EDITABLE(m_text)->current_pos );
gtk_text_set_point( GTK_TEXT(m_text), GET_EDITABLE_POS(m_text) );
// if we have any special style, use it
if ( !m_defaultStyle.IsDefault() )
@@ -457,24 +460,24 @@ void wxTextCtrl::WriteText( const wxString &text )
}
else // no style
{
gint len = GTK_EDITABLE(m_text)->current_pos;
gint len = GET_EDITABLE_POS(m_text);
gtk_editable_insert_text( GTK_EDITABLE(m_text), txt, txtlen, &len );
}
// Bring editable's cursor back uptodate.
GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
}
else // single line
{
// This moves the cursor pos to behind the inserted text.
gint len = GTK_EDITABLE(m_text)->current_pos;
gint len = GET_EDITABLE_POS(m_text);
gtk_editable_insert_text( GTK_EDITABLE(m_text), txt, txtlen, &len );
// Bring editable's cursor uptodate.
GTK_EDITABLE(m_text)->current_pos += text.Len();
len += text.Len();
// Bring entry's cursor uptodate.
gtk_entry_set_position( GTK_ENTRY(m_text), GTK_EDITABLE(m_text)->current_pos );
gtk_entry_set_position( GTK_ENTRY(m_text), len );
}
m_modified = TRUE;
@@ -643,7 +646,7 @@ void wxTextCtrl::SetInsertionPoint( long pos )
/* bring editable's cursor uptodate. another bug in GTK. */
GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
}
else
{
@@ -651,7 +654,7 @@ void wxTextCtrl::SetInsertionPoint( long pos )
/* bring editable's cursor uptodate. bug in GTK. */
GTK_EDITABLE(m_text)->current_pos = (guint32)pos;
SET_EDITABLE_POS(m_text, (guint32)pos);
}
}
@@ -810,7 +813,7 @@ long wxTextCtrl::GetInsertionPoint() const
{
wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
return (long) GTK_EDITABLE(m_text)->current_pos;
return (long) GET_EDITABLE_POS(m_text);
}
long wxTextCtrl::GetLastPosition() const
@@ -855,33 +858,21 @@ void wxTextCtrl::Cut()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
#if (GTK_MINOR_VERSION > 0)
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) );
#else
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text), 0 );
#endif
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
}
void wxTextCtrl::Copy()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
#if (GTK_MINOR_VERSION > 0)
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) );
#else
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text), 0 );
#endif
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
}
void wxTextCtrl::Paste()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
#if (GTK_MINOR_VERSION > 0)
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) );
#else
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text), 0 );
#endif
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
}
// Undo/redo
@@ -917,21 +908,27 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
long from, to;
gint from, to;
#ifdef __WXGTK20__
if ( !gtk_editable_get_selection_bounds(GTK_EDITABLE(m_text), &from, &to) )
#else
if ( !(GTK_EDITABLE(m_text)->has_selection) )
#endif
{
from =
to = GetInsertionPoint();
}
else // got selection
{
#ifndef __WXGTK20__
from = (long) GTK_EDITABLE(m_text)->selection_start_pos;
to = (long) GTK_EDITABLE(m_text)->selection_end_pos;
#endif
if ( from > to )
{
// exchange them to be compatible with wxMSW
long tmp = from;
gint tmp = from;
from = to;
to = tmp;
}
@@ -947,7 +944,11 @@ bool wxTextCtrl::IsEditable() const
{
wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") );
#ifdef __WXGTK20__
return gtk_editable_get_editable(GTK_EDITABLE(m_text));
#else
return GTK_EDITABLE(m_text)->editable;
#endif
}
bool wxTextCtrl::IsModified() const

View File

@@ -15,8 +15,7 @@
#if wxUSE_TOGGLEBTN
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
@@ -125,8 +124,7 @@ void wxToggleButton::SetLabel(const wxString& label)
wxControl::SetLabel(label);
gtk_label_set(GTK_LABEL(GTK_BUTTON(m_widget)->child),
GetLabel().mbc_str());
gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), GetLabel().mbc_str());
}
bool wxToggleButton::Enable(bool enable /*=TRUE*/)
@@ -134,7 +132,7 @@ bool wxToggleButton::Enable(bool enable /*=TRUE*/)
if (!wxControl::Enable(enable))
return FALSE;
gtk_widget_set_sensitive(GTK_BUTTON(m_widget)->child, enable);
gtk_widget_set_sensitive(BUTTON_CHILD(m_widget), enable);
return TRUE;
}
@@ -143,12 +141,12 @@ void wxToggleButton::ApplyWidgetStyle()
{
SetWidgetStyle();
gtk_widget_set_style(m_widget, m_widgetStyle);
gtk_widget_set_style(GTK_BUTTON(m_widget)->child, m_widgetStyle);
gtk_widget_set_style(BUTTON_CHILD(m_widget), m_widgetStyle);
}
bool wxToggleButton::IsOwnGtkWindow(GdkWindow *window)
{
return (window == GTK_TOGGLE_BUTTON(m_widget)->event_window);
return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
}
void wxToggleButton::OnInternalIdle()
@@ -158,14 +156,15 @@ void wxToggleButton::OnInternalIdle()
if (g_globalCursor.Ok())
cursor = g_globalCursor;
if (GTK_TOGGLE_BUTTON(m_widget)->event_window && cursor.Ok()) {
GdkWindow *win = TOGGLE_BUTTON_EVENT_WIN(m_widget);
if ( win && cursor.Ok() )
{
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor(GTK_TOGGLE_BUTTON(m_widget)->event_window,
cursor.GetCursor());
gdk_window_set_cursor(win, cursor.GetCursor());
}
UpdateWindowUI();

View File

@@ -18,8 +18,7 @@
#include "wx/window.h"
#include "wx/tooltip.h"
#include "gtk/gtk.h"
#include "gdk/gdk.h"
#include "wx/gtk/private.h"
extern GdkFont *GtkGetDefaultGuiFont();
@@ -67,7 +66,7 @@ void wxToolTip::Apply( wxWindow *win )
ss_bg.blue = 50000;
gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_bg );
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
gtk_tooltips_force_window( ss_tooltips );
GtkStyle *g_style =
@@ -76,11 +75,11 @@ void wxToolTip::Apply( wxWindow *win )
g_style->fg[GTK_STATE_NORMAL] = ss_fg;
g_style->bg[GTK_STATE_NORMAL] = ss_bg;
gdk_font_unref( g_style->font );
g_style->font = gdk_font_ref( GtkGetDefaultGuiFont() );
SET_STYLE_FONT( g_style, GtkGetDefaultGuiFont() );
gtk_widget_set_style( ss_tooltips->tip_window, g_style );
#else
#else // GTK+ 1.0
gtk_tooltips_set_colors( ss_tooltips, &ss_bg, &ss_fg );
#endif
}

View File

@@ -376,7 +376,14 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
win_type = GTK_WINDOW_POPUP;
if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)
{
// there is no more GTK_WINDOW_DIALOG in 2.0
#ifdef __WXGTK20__
win_type = GTK_WINDOW_TOPLEVEL;
#else
win_type = GTK_WINDOW_DIALOG;
#endif
}
m_widget = gtk_window_new( win_type );

View File

@@ -50,8 +50,10 @@ static void gtk_pizza_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_pizza_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
#ifndef __WXGTK20__
static void gtk_pizza_draw (GtkWidget *widget,
GdkRectangle *area);
#endif /* __WXGTK20__ */
static gint gtk_pizza_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_pizza_add (GtkContainer *container,
@@ -146,7 +148,9 @@ gtk_pizza_class_init (GtkPizzaClass *klass)
widget_class->unrealize = gtk_pizza_unrealize;
widget_class->size_request = gtk_pizza_size_request;
widget_class->size_allocate = gtk_pizza_size_allocate;
#ifndef __WXGTK20__
widget_class->draw = gtk_pizza_draw;
#endif
widget_class->expose_event = gtk_pizza_expose;
container_class->add = gtk_pizza_add;
@@ -160,7 +164,6 @@ gtk_pizza_class_init (GtkPizzaClass *klass)
widget_class->set_scroll_adjustments_signal =
gtk_signal_new ("set_scroll_adjustments",
GTK_RUN_LAST,
#ifdef __WXGTK20__
GTK_CLASS_TYPE(object_class),
#else
@@ -708,6 +711,8 @@ gtk_pizza_size_allocate (GtkWidget *widget,
}
}
#ifndef __WXGTK20__
static void
gtk_pizza_draw (GtkWidget *widget,
GdkRectangle *area)
@@ -744,6 +749,8 @@ gtk_pizza_draw (GtkWidget *widget,
}
}
#endif /* __WXGTK20__ */
static gint
gtk_pizza_expose (GtkWidget *widget,
GdkEventExpose *event)
@@ -1048,6 +1055,7 @@ gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
{
GtkWidget *widget;
XEvent xevent;
XID win;
gint x,y,w,h,border;
@@ -1142,10 +1150,12 @@ gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
gtk_pizza_position_children (pizza);
gdk_flush();
win = GDK_WINDOW_XWINDOW (pizza->bin_window);
while (XCheckIfEvent(GDK_WINDOW_XDISPLAY (pizza->bin_window),
&xevent,
gtk_pizza_expose_predicate,
(XPointer)&GDK_WINDOW_XWINDOW (pizza->bin_window)))
(XPointer)&win))
{
GdkEvent event;
GtkWidget *event_widget;

View File

@@ -54,8 +54,7 @@
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkprivate.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
@@ -65,6 +64,12 @@
#include "wx/gtk/win_gtk.h"
#ifdef __WXGTK20__
#define SET_CONTAINER_FOCUS(w, d) gtk_widget_child_focus((w), (d))
#else
#define SET_CONTAINER_FOCUS(w, d) gtk_container_focus(GTK_CONTAINER(w), (d))
#endif
//-----------------------------------------------------------------------------
// documentation on internals
//-----------------------------------------------------------------------------
@@ -1857,7 +1862,9 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_
// "value_changed" from m_vAdjust
//-----------------------------------------------------------------------------
static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win )
static void gtk_window_vscroll_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxWindowGTK *win )
{
DEBUG_MAIN_THREAD
@@ -1873,14 +1880,7 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win
win->m_oldVerticalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->vscrollbar );
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(win->m_widget));
int value = (int)(adjust->value+0.5);
@@ -1893,7 +1893,9 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win
// "value_changed" from m_hAdjust
//-----------------------------------------------------------------------------
static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win )
static void gtk_window_hscroll_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxWindowGTK *win )
{
DEBUG_MAIN_THREAD
@@ -1906,17 +1908,10 @@ static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win
float diff = adjust->value - win->m_oldHorizontalPos;
if (fabs(diff) < 0.2) return;
wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(win->m_widget));
win->m_oldHorizontalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->hscrollbar );
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
int value = (int)(adjust->value+0.5);
wxScrollWinEvent event( command, value, wxHORIZONTAL );
@@ -1939,7 +1934,11 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget,
g_blockEventsOnScroll = TRUE;
// FIXME: there is no 'slider' field in GTK+ 2.0 any more
#ifndef __WXGTK20__
win->m_isScrolling = (gdk_event->window == widget->slider);
#endif
return FALSE;
}
@@ -2341,7 +2340,8 @@ bool wxWindowGTK::Create( wxWindow *parent,
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
#ifndef __WXUNIVERSAL__
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
if (HasFlag(wxRAISED_BORDER))
@@ -2360,7 +2360,7 @@ bool wxWindowGTK::Create( wxWindow *parent,
{
gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_NONE );
}
#else // GTK_MINOR_VERSION == 0
#else // GTK+ 1.0
GtkViewport *viewport = GTK_VIEWPORT(scrolledWindow->viewport);
if (HasFlag(wxRAISED_BORDER))
@@ -2375,17 +2375,18 @@ bool wxWindowGTK::Create( wxWindow *parent,
{
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
}
#endif // GTK_MINOR_VERSION
#endif // GTK+ > 1.0/<= 1.0
#endif // __WXUNIVERSAL__
GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
m_acceptsFocus = TRUE;
#if (GTK_MINOR_VERSION == 0)
#if !GTK_CHECK_VERSION(1, 2, 0)
// shut the viewport up
gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
gtk_viewport_set_vadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
#endif // GTK_MINOR_VERSION == 0
#endif // GTK+ 1.0
// I _really_ don't want scrollbars in the beginning
m_vAdjust->lower = 0.0;
@@ -3167,7 +3168,7 @@ void wxWindowGTK::SetFocus()
}
else if (GTK_IS_CONTAINER(m_widget))
{
gtk_container_focus( GTK_CONTAINER(m_widget), GTK_DIR_TAB_FORWARD );
SET_CONTAINER_FOCUS( m_widget, GTK_DIR_TAB_FORWARD );
}
else
{
@@ -3541,10 +3542,9 @@ GtkStyle *wxWindowGTK::GetWidgetStyle()
if (m_widgetStyle)
{
GtkStyle *remake = gtk_style_copy( m_widgetStyle );
#ifdef __WXGTK20__
/* FIXME: is this necessary? */
_G_TYPE_IGC(remake, GtkObjectClass) = _G_TYPE_IGC(m_widgetStyle, GtkObjectClass);
#else
// FIXME: no more klass in 2.0
#ifndef __WXGTK20__
remake->klass = m_widgetStyle->klass;
#endif
@@ -3559,10 +3559,9 @@ GtkStyle *wxWindowGTK::GetWidgetStyle()
def = gtk_widget_get_default_style();
m_widgetStyle = gtk_style_copy( def );
#ifdef __WXGTK20__
/* FIXME: is this necessary? */
_G_TYPE_IGC(m_widgetStyle, GtkObjectClass) = _G_TYPE_IGC(def, GtkObjectClass);
#else
// FIXME: no more klass in 2.0
#ifndef __WXGTK20__
m_widgetStyle->klass = def->klass;
#endif
}
@@ -3590,8 +3589,7 @@ void wxWindowGTK::SetWidgetStyle()
if (m_font != wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ))
{
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
SET_STYLE_FONT(style, m_font.GetInternalFont( 1.0 ));
}
if (m_foregroundColour.Ok())
@@ -3701,6 +3699,9 @@ static gint gs_pop_y = 0;
extern "C" void wxPopupMenuPositionCallback( GtkMenu *menu,
gint *x, gint *y,
#ifdef __WXGTK20__
gboolean * WXUNUSED(whatever),
#endif
gpointer WXUNUSED(user_data) )
{
// ensure that the menu appears entirely on screen