From 5e014a0c44e36efe429bea1303f4309af287eb77 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Thu, 30 Sep 1999 22:13:45 +0000 Subject: [PATCH] Corrected filelist.txt a little - one gsocket.c is enough, Corrected cursors - not yet perfect, Added some tests to scroll sample Made wxScrolledWindow::Scroll() call Refresh(), Change wxListCtrl to reflect the latter change (wxTreeCtrl will follow), Added activate event for wxMDIChildFrame Implemented wxSIMPLE_BORDER for wxWindow (no controls), Tried to correct positioning upon start-up - no way, Rewrote catching of scroll events - page-up, page-down, up and down work now. Don't know what TOP and BOTTOM are used for. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3763 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 14 ++- distrib/msw/tmake/filelist.txt | 1 - include/wx/gtk/listbox.h | 1 + include/wx/gtk/win_gtk.h | 12 ++- include/wx/gtk1/listbox.h | 1 + include/wx/gtk1/win_gtk.h | 12 ++- samples/scroll/scroll.cpp | 24 ++++- src/generic/listctrl.cpp | 8 +- src/generic/scrolwin.cpp | 5 +- src/gtk/dialog.cpp | 38 +++++++ src/gtk/frame.cpp | 2 + src/gtk/listbox.cpp | 33 +++++- src/gtk/mdi.cpp | 24 +++++ src/gtk/win_gtk.c | 28 +++-- src/gtk/window.cpp | 182 ++++++++++++++++----------------- src/gtk1/dialog.cpp | 38 +++++++ src/gtk1/frame.cpp | 2 + src/gtk1/listbox.cpp | 33 +++++- src/gtk1/mdi.cpp | 24 +++++ src/gtk1/win_gtk.c | 28 +++-- src/gtk1/window.cpp | 182 ++++++++++++++++----------------- 21 files changed, 474 insertions(+), 218 deletions(-) diff --git a/Makefile.in b/Makefile.in index b3705be048..3b83477621 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,5 @@ # -# This file was automatically generated by tmake at 17:51, 1999/09/20 +# This file was automatically generated by tmake at 15:11, 1999/09/30 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T! # @@ -656,6 +656,7 @@ GTK_COMMONOBJS = \ fileconf.o \ filefn.o \ filesys.o \ + fontcmn.o \ framecmn.o \ fs_inet.o \ fs_zip.o \ @@ -665,6 +666,7 @@ GTK_COMMONOBJS = \ hash.o \ helpbase.o \ http.o \ + imagall.o \ imagbmp.o \ image.o \ imaggif.o \ @@ -741,6 +743,7 @@ GTK_COMMONDEPS = \ fileconf.d \ filefn.d \ filesys.d \ + fontcmn.d \ framecmn.d \ fs_inet.d \ fs_zip.d \ @@ -750,6 +753,7 @@ GTK_COMMONDEPS = \ hash.d \ helpbase.d \ http.d \ + imagall.d \ imagbmp.d \ image.d \ imaggif.d \ @@ -1020,6 +1024,7 @@ MOTIF_COMMONOBJS = \ fileconf.o \ filefn.o \ filesys.o \ + fontcmn.o \ framecmn.o \ fs_inet.o \ fs_zip.o \ @@ -1029,6 +1034,7 @@ MOTIF_COMMONOBJS = \ hash.o \ helpbase.o \ http.o \ + imagall.o \ imagbmp.o \ image.o \ imaggif.o \ @@ -1108,6 +1114,7 @@ MOTIF_COMMONDEPS = \ fileconf.d \ filefn.d \ filesys.d \ + fontcmn.d \ framecmn.d \ fs_inet.d \ fs_zip.d \ @@ -1117,6 +1124,7 @@ MOTIF_COMMONDEPS = \ hash.d \ helpbase.d \ http.d \ + imagall.d \ imagbmp.d \ image.d \ imaggif.d \ @@ -1350,6 +1358,7 @@ MSW_COMMONOBJS = \ fileconf.o \ filefn.o \ filesys.o \ + fontcmn.o \ framecmn.o \ fs_inet.o \ fs_zip.o \ @@ -1359,6 +1368,7 @@ MSW_COMMONOBJS = \ hash.o \ helpbase.o \ http.o \ + imagall.o \ imagbmp.o \ image.o \ imaggif.o \ @@ -1437,6 +1447,7 @@ MSW_COMMONDEPS = \ fileconf.d \ filefn.d \ filesys.d \ + fontcmn.d \ framecmn.d \ fs_inet.d \ fs_zip.d \ @@ -1446,6 +1457,7 @@ MSW_COMMONDEPS = \ hash.d \ helpbase.d \ http.d \ + imagall.d \ imagbmp.d \ image.d \ imaggif.d \ diff --git a/distrib/msw/tmake/filelist.txt b/distrib/msw/tmake/filelist.txt index e1b0066cfa..6c63b8e34e 100644 --- a/distrib/msw/tmake/filelist.txt +++ b/distrib/msw/tmake/filelist.txt @@ -305,7 +305,6 @@ fontdlg.cpp R frame.cpp R gauge.cpp R gdiobj.cpp R -gsockgtk.c R icon.cpp R listbox.cpp R main.cpp R diff --git a/include/wx/gtk/listbox.h b/include/wx/gtk/listbox.h index ea6b058644..8b477fff3a 100644 --- a/include/wx/gtk/listbox.h +++ b/include/wx/gtk/listbox.h @@ -116,6 +116,7 @@ public: GtkWidget *GetConnectWidget(); bool IsOwnGtkWindow( GdkWindow *window ); void ApplyWidgetStyle(); + void OnInternalIdle(); #if wxUSE_TOOLTIPS void ApplyToolTip( GtkTooltips *tips, const wxChar *tip ); diff --git a/include/wx/gtk/win_gtk.h b/include/wx/gtk/win_gtk.h index d27296eb13..ac04b3c0ef 100644 --- a/include/wx/gtk/win_gtk.h +++ b/include/wx/gtk/win_gtk.h @@ -25,6 +25,14 @@ extern "C" { #define GTK_MYFIXED_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_myfixed_get_type (), GtkMyFixedClass) #define GTK_IS_MYFIXED(obj) GTK_CHECK_TYPE (obj, gtk_myfixed_get_type ()) +/* Shadow types */ +typedef enum +{ + GTK_MYSHADOW_NONE, + GTK_MYSHADOW_THIN, + GTK_MYSHADOW_IN, + GTK_MYSHADOW_OUT, +} GtkMyShadowType; typedef struct _GtkMyFixed GtkMyFixed; typedef struct _GtkMyFixedClass GtkMyFixedClass; @@ -35,7 +43,7 @@ struct _GtkMyFixed GtkContainer container; GList *children; #if (GTK_MINOR_VERSION > 0) - GtkShadowType shadow_type; + GtkMyShadowType shadow_type; #endif }; @@ -63,7 +71,7 @@ guint gtk_myfixed_get_type (void); GtkWidget* gtk_myfixed_new (void); #if (GTK_MINOR_VERSION > 0) void gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed, - GtkShadowType type); + GtkMyShadowType type); #endif void gtk_myfixed_put (GtkMyFixed *myfixed, GtkWidget *widget, diff --git a/include/wx/gtk1/listbox.h b/include/wx/gtk1/listbox.h index ea6b058644..8b477fff3a 100644 --- a/include/wx/gtk1/listbox.h +++ b/include/wx/gtk1/listbox.h @@ -116,6 +116,7 @@ public: GtkWidget *GetConnectWidget(); bool IsOwnGtkWindow( GdkWindow *window ); void ApplyWidgetStyle(); + void OnInternalIdle(); #if wxUSE_TOOLTIPS void ApplyToolTip( GtkTooltips *tips, const wxChar *tip ); diff --git a/include/wx/gtk1/win_gtk.h b/include/wx/gtk1/win_gtk.h index d27296eb13..ac04b3c0ef 100644 --- a/include/wx/gtk1/win_gtk.h +++ b/include/wx/gtk1/win_gtk.h @@ -25,6 +25,14 @@ extern "C" { #define GTK_MYFIXED_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_myfixed_get_type (), GtkMyFixedClass) #define GTK_IS_MYFIXED(obj) GTK_CHECK_TYPE (obj, gtk_myfixed_get_type ()) +/* Shadow types */ +typedef enum +{ + GTK_MYSHADOW_NONE, + GTK_MYSHADOW_THIN, + GTK_MYSHADOW_IN, + GTK_MYSHADOW_OUT, +} GtkMyShadowType; typedef struct _GtkMyFixed GtkMyFixed; typedef struct _GtkMyFixedClass GtkMyFixedClass; @@ -35,7 +43,7 @@ struct _GtkMyFixed GtkContainer container; GList *children; #if (GTK_MINOR_VERSION > 0) - GtkShadowType shadow_type; + GtkMyShadowType shadow_type; #endif }; @@ -63,7 +71,7 @@ guint gtk_myfixed_get_type (void); GtkWidget* gtk_myfixed_new (void); #if (GTK_MINOR_VERSION > 0) void gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed, - GtkShadowType type); + GtkMyShadowType type); #endif void gtk_myfixed_put (GtkMyFixed *myfixed, GtkWidget *widget, diff --git a/samples/scroll/scroll.cpp b/samples/scroll/scroll.cpp index 8107e5e22c..2fb4406579 100644 --- a/samples/scroll/scroll.cpp +++ b/samples/scroll/scroll.cpp @@ -73,12 +73,12 @@ IMPLEMENT_APP(MyApp) IMPLEMENT_DYNAMIC_CLASS(MyCanvas, wxScrolledWindow) BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) - EVT_PAINT(MyCanvas::OnPaint) +// EVT_PAINT(MyCanvas::OnPaint) END_EVENT_TABLE() MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size ) - : wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER | wxTAB_TRAVERSAL ) + : wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER | wxTAB_TRAVERSAL, "test canvas" ) { wxString choices[] = { @@ -103,7 +103,7 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id, wxListCtrl *m_listCtrl = new wxListCtrl( this, -1, wxPoint(200, 10), wxSize(180, 120), - wxLC_REPORT | wxSUNKEN_BORDER | wxLC_SINGLE_SEL ); + wxLC_REPORT | wxSIMPLE_BORDER | wxLC_SINGLE_SEL ); m_listCtrl->InsertColumn(0, "First", wxLIST_FORMAT_LEFT, 90); m_listCtrl->InsertColumn(1, "Last", wxLIST_FORMAT_LEFT, 90); @@ -117,8 +117,26 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id, m_listCtrl->SetItemState( 3, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); (void) new wxListBox( this, -1, wxPoint(200,180), wxSize(180,120), 5, choices, wxLB_ALWAYS_SB ); + + wxWindow *test = new wxWindow( this, -1, wxPoint(10, 400), wxSize(130,120), wxSIMPLE_BORDER | wxTAB_TRAVERSAL ); + test->SetBackgroundColour( "WHEAT" ); + wxButton *test2 = new wxButton( test, -1, "Hallo", wxPoint(10,10) ); + + test = new wxWindow( this, -1, wxPoint(160, 400), wxSize(130,120), wxSUNKEN_BORDER | wxTAB_TRAVERSAL ); + test->SetBackgroundColour( "WHEAT" ); + test->SetCursor( wxCursor( wxCURSOR_NO_ENTRY ) ); + test2 = new wxButton( test, -1, "Hallo", wxPoint(10,10) ); + test2->SetCursor( wxCursor( wxCURSOR_PENCIL ) ); + test = new wxWindow( this, -1, wxPoint(310, 400), wxSize(130,120), wxRAISED_BORDER | wxTAB_TRAVERSAL ); + test->SetBackgroundColour( "WHEAT" ); + test->SetCursor( wxCursor( wxCURSOR_PENCIL ) ); + test2 = new wxButton( test, -1, "Hallo", wxPoint(10,10) ); + test2->SetCursor( wxCursor( wxCURSOR_NO_ENTRY ) ); + SetBackgroundColour( "WHEAT" ); + + SetCursor( wxCursor( wxCURSOR_IBEAM ) ); } MyCanvas::~MyCanvas() diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 36d171b2cc..b5d3611d3c 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -1455,15 +1455,15 @@ void wxListMainWindow::MoveToFocus() { int y_s = m_yScroll*GetScrollPos( wxVERTICAL ); if ((y > y_s) && (y+h < y_s+h_p)) return; - if (y-y_s < 5) { Scroll( -1, (y-5-h_p/2)/m_yScroll ); Refresh(); } - if (y+h+5 > y_s+h_p) { Scroll( -1, (y+h-h_p/2+h+15)/m_yScroll); Refresh(); } + if (y-y_s < 5) { Scroll( -1, (y-5-h_p/2)/m_yScroll ); } + if (y+h+5 > y_s+h_p) { Scroll( -1, (y+h-h_p/2+h+15)/m_yScroll); } } else { int x_s = m_xScroll*GetScrollPos( wxHORIZONTAL ); if ((x > x_s) && (x+w < x_s+w_p)) return; - if (x-x_s < 5) { Scroll( (x-5)/m_xScroll, -1 ); Refresh(); } - if (x+w-5 > x_s+w_p) { Scroll( (x+w-w_p+15)/m_xScroll, -1 ); Refresh(); } + if (x-x_s < 5) { Scroll( (x-5)/m_xScroll, -1 ); } + if (x+w-5 > x_s+w_p) { Scroll( (x+w-w_p+15)/m_xScroll, -1 ); } } } diff --git a/src/generic/scrolwin.cpp b/src/generic/scrolwin.cpp index 8078c767b4..5dccb848c1 100644 --- a/src/generic/scrolwin.cpp +++ b/src/generic/scrolwin.cpp @@ -468,12 +468,11 @@ void wxScrolledWindow::Scroll( int x_pos, int y_pos ) SetScrollPos( wxVERTICAL, m_yScrollPosition, TRUE ); } - // BAD, BAD, can cause event loops if called from OnPaint(). KB. - // Refresh(); #ifdef __WXMSW__ - // Necessary? ::UpdateWindow ((HWND) GetHWND()); +#else + Refresh(); #endif } diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 9812ec9c7b..4869b9263f 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -20,6 +20,11 @@ #include "wx/gtk/win_gtk.h" #include "wx/cursor.h" +/* +#include "gdk/gdkprivate.h" +#include "gdk/gdkx.h" +*/ + //----------------------------------------------------------------------------- // idle system //----------------------------------------------------------------------------- @@ -33,6 +38,33 @@ extern bool g_isIdle; extern wxList wxPendingDelete; +/* +//----------------------------------------------------------------------------- +// instruct X to set the WM hint for positioning +//----------------------------------------------------------------------------- + +extern "C" { + +static void gdk_window_set_position_hint( GdkWindow *window, gint x, gint y ) +{ + GdkWindowPrivate *priv; + XSizeHints size_hints; + + g_return_if_fail (window != NULL); + + priv = (GdkWindowPrivate*) window; + if (priv->destroyed) return; + + size_hints.flags = PPosition; + size_hints.x = x; + size_hints.y = y; + + XSetWMNormalHints (priv->xdisplay, priv->xwindow, &size_hints); +} + +} +*/ + //----------------------------------------------------------------------------- // "delete_event" //----------------------------------------------------------------------------- @@ -118,6 +150,10 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win ) position in "realize" and "map" */ gtk_widget_set_uposition( widget, win->m_x, win->m_y ); +/* + gdk_window_set_position_hint( widget->window, win->m_x, win->m_y ); +*/ + /* reset the icon */ if (win->m_icon != wxNullIcon) { @@ -546,6 +582,8 @@ void wxDialog::OnInternalIdle() { if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow)) GtkOnSize( m_x, m_y, m_width, m_height ); + + wxWindow::OnInternalIdle(); } bool wxDialog::Show( bool show ) diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 78247575e7..3e87057d4a 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -800,6 +800,8 @@ void wxFrame::OnInternalIdle() #if wxUSE_STATUSBAR if (m_frameStatusBar) m_frameStatusBar->OnInternalIdle(); #endif + + wxWindow::OnInternalIdle(); } void wxFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) ) diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 267cf1faee..d981ae99dd 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -72,10 +72,11 @@ extern bool g_isIdle; // data //----------------------------------------------------------------------------- -extern bool g_blockEventsOnDrag; -extern bool g_blockEventsOnScroll; +extern bool g_blockEventsOnDrag; +extern bool g_blockEventsOnScroll; +extern wxCursor g_globalCursor; -static bool g_hasDoubleClicked = FALSE; +static bool g_hasDoubleClicked = FALSE; //----------------------------------------------------------------------------- // "button_release_event" @@ -1005,4 +1006,30 @@ void wxListBox::ApplyWidgetStyle() } } +void wxListBox::OnInternalIdle() +{ + wxCursor cursor = m_cursor; + if (g_globalCursor.Ok()) cursor = g_globalCursor; + + if (m_widget->window && cursor.Ok() && m_currentGdkCursor != cursor) + { + m_currentGdkCursor = cursor; + + gdk_window_set_cursor( GTK_WIDGET(m_list)->window, m_currentGdkCursor.GetCursor() ); + + GList *child = m_list->children; + while (child) + { + GtkBin *bin = GTK_BIN( child->data ); + GtkWidget *label = GTK_WIDGET( bin->child ); + + gdk_window_set_cursor( label->window, m_currentGdkCursor.GetCursor() ); + + child = child->next; + } + } + + UpdateWindowUI(); +} + #endif diff --git a/src/gtk/mdi.cpp b/src/gtk/mdi.cpp index 0b98599d59..ab91caff85 100644 --- a/src/gtk/mdi.cpp +++ b/src/gtk/mdi.cpp @@ -43,6 +43,27 @@ extern bool g_isIdle; extern wxList wxPendingDelete; +//----------------------------------------------------------------------------- +// "switch_page" +//----------------------------------------------------------------------------- + +static void gtk_mdi_page_change_callback(GtkNotebook *WXUNUSED(widget), + GtkNotebookPage *WXUNUSED(page), + gint page, + wxMDIParentFrame *parent ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + + wxMDIChildFrame *child = parent->GetActiveChild(); + + if (!child) return; + + wxActivateEvent event( wxEVT_ACTIVATE, TRUE, child->GetId() ); + event.SetEventObject( child); + child->GetEventHandler()->ProcessEvent( event ); +} + //----------------------------------------------------------------------------- // wxMDIParentFrame //----------------------------------------------------------------------------- @@ -418,6 +439,9 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style ) m_widget = gtk_notebook_new(); + gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page", + GTK_SIGNAL_FUNC(gtk_mdi_page_change_callback), (gpointer)parent ); + gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 ); m_parent->DoAddChild( this ); diff --git a/src/gtk/win_gtk.c b/src/gtk/win_gtk.c index a9552bd63b..5f683d50c7 100644 --- a/src/gtk/win_gtk.c +++ b/src/gtk/win_gtk.c @@ -156,7 +156,7 @@ gtk_myfixed_init (GtkMyFixed *myfixed) #endif #if (GTK_MINOR_VERSION > 0) - myfixed->shadow_type = GTK_SHADOW_NONE; + myfixed->shadow_type = GTK_MYSHADOW_NONE; #endif myfixed->children = NULL; @@ -182,13 +182,13 @@ gtk_myfixed_scroll_set_adjustments (GtkMyFixed *myfixed, } void -gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed, - GtkShadowType type) +gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed, + GtkMyShadowType type) { g_return_if_fail (myfixed != NULL); g_return_if_fail (GTK_IS_MYFIXED (myfixed)); - if ((GtkShadowType) myfixed->shadow_type != type) + if ((GtkMyShadowType) myfixed->shadow_type != type) { myfixed->shadow_type = type; @@ -415,8 +415,21 @@ gtk_myfixed_realize (GtkWidget *widget) attributes.width = widget->allocation.width; attributes.height = widget->allocation.height; - if (myfixed->shadow_type != GTK_SHADOW_NONE) + if (myfixed->shadow_type == GTK_MYSHADOW_NONE) { + /* no border, no changes to sizes */ + } else + if (myfixed->shadow_type == GTK_MYSHADOW_THIN) + { + /* GTK_MYSHADOW_THIN == wxSIMPLE_BORDER */ + attributes.x += 1; + attributes.y += 1; + attributes.width -= 2; + attributes.height -= 2; + } else + { + /* GTK_MYSHADOW_IN == wxSUNKEN_BORDER */ + /* GTK_MYSHADOW_OUT == wxRAISED_BORDER */ attributes.x += 2; attributes.y += 2; attributes.width -= 4; @@ -511,8 +524,11 @@ gtk_myfixed_size_allocate (GtkWidget *widget, widget->allocation = *allocation; #if (GTK_MINOR_VERSION > 0) - if (myfixed->shadow_type == GTK_SHADOW_NONE) + if (myfixed->shadow_type == GTK_MYSHADOW_NONE) border = 0; + else + if (myfixed->shadow_type == GTK_MYSHADOW_THIN) + border = 1; else border = 2; #else diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index b4e5416019..2b47193e48 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -632,6 +632,17 @@ static void draw_frame( GtkWidget *widget, wxWindow *win ) win->m_width-dw, win->m_height-dh ); return; } + + if (win->HasFlag(wxSIMPLE_BORDER)) + { + GdkGC *gc = gdk_gc_new( widget->window ); + gdk_gc_set_foreground( gc, &widget->style->black ); + gdk_draw_rectangle( widget->window, gc, FALSE, + dx, dy, + win->m_width-dw-1, win->m_height-dh-1 ); + gdk_gc_unref( gc ); + return; + } } //----------------------------------------------------------------------------- @@ -1227,7 +1238,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; if (g_blockEventsOnScroll) return FALSE; - + if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; if (gdk_event->is_hint) @@ -1509,7 +1520,7 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ // "value_changed" from m_vAdjust //----------------------------------------------------------------------------- -static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) +static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -1517,32 +1528,25 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * if (g_blockEventsOnDrag) return; if (!win->m_hasVMT) return; - - float diff = win->m_vAdjust->value - win->m_oldVerticalPos; + + float diff = adjust->value - win->m_oldVerticalPos; if (fabs(diff) < 0.2) return; - win->m_oldVerticalPos = win->m_vAdjust->value; - - wxEventType command = wxEVT_NULL; - - float line_step = win->m_vAdjust->step_increment; - float page_step = win->m_vAdjust->page_increment; + + win->m_oldVerticalPos = adjust->value; - if (win->IsScrolling()) - { - command = wxEVT_SCROLLWIN_THUMBTRACK; - } - else - { - if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM; - else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP; - else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEDOWN; - else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEUP; - else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEDOWN; - else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEUP; - else command = wxEVT_SCROLLWIN_THUMBTRACK; - } + 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; + +// if (fabs(adjust->value-adjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM; +// if (fabs(adjust->value-adjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP; - int value = (int)(win->m_vAdjust->value+0.5); + int value = (int)(adjust->value+0.5); wxScrollWinEvent event( command, value, wxVERTICAL ); event.SetEventObject( win ); @@ -1553,7 +1557,7 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * // "value_changed" from m_hAdjust //----------------------------------------------------------------------------- -static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) +static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -1561,31 +1565,24 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * if (g_blockEventsOnDrag) return; if (!win->m_hasVMT) return; - float diff = win->m_hAdjust->value - win->m_oldHorizontalPos; + float diff = adjust->value - win->m_oldHorizontalPos; if (fabs(diff) < 0.2) return; - win->m_oldHorizontalPos = win->m_hAdjust->value; - - wxEventType command = wxEVT_NULL; - - float line_step = win->m_hAdjust->step_increment; - float page_step = win->m_hAdjust->page_increment; + + win->m_oldHorizontalPos = adjust->value; - if (win->IsScrolling()) - { - command = wxEVT_SCROLLWIN_THUMBTRACK; - } - else - { - if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM; - else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP; - else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEDOWN; - else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEUP; - else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEDOWN; - else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEUP; - else command = wxEVT_SCROLLWIN_THUMBTRACK; - } + 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; + +// if (fabs(adjust->value-adjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM; +// if (fabs(adjust->value-adjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP; - int value = (int)(win->m_hAdjust->value+0.5); + int value = (int)(adjust->value+0.5); wxScrollWinEvent event( command, value, wxHORIZONTAL ); event.SetEventObject( win ); @@ -1644,7 +1641,7 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget), wxapp_install_idle_handler(); // don't test here as we can release the mouse while being over -// a different window then the slider +// a different window than the slider // // if (gdk_event->window != widget->slider) return FALSE; @@ -1663,16 +1660,16 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget, { // don't test here as we can release the mouse while being over -// a different window then the slider +// a different window than the slider // // if (gdk_event->window != widget->slider) return FALSE; - GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget); - - if (widget == GTK_RANGE(scrolledWindow->vscrollbar)) - gtk_signal_emit_by_name( GTK_OBJECT(win->m_hAdjust), "value_changed" ); - else - gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" ); +// GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget); +// +// if (widget == GTK_RANGE(scrolledWindow->vscrollbar)) +// gtk_signal_emit_by_name( GTK_OBJECT(win->m_hAdjust), "value_changed" ); +// else +// gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" ); win->SetScrolling( FALSE ); @@ -1693,7 +1690,7 @@ wxWindow *wxWindowBase::FindFocus() // "realize" from m_widget //----------------------------------------------------------------------------- -/* we cannot set colours, fonts and cursors before the widget has +/* we cannot set colours and fonts before the widget has been realized, so we do this directly after realization */ static gint @@ -1711,8 +1708,6 @@ gtk_window_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win ) if (win->m_delayedForegroundColour) win->SetForegroundColour( win->GetForegroundColour() ); - win->SetCursor( win->GetCursor() ); - wxWindowCreateEvent event( win ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); @@ -1800,6 +1795,8 @@ void wxWindow::Init() m_isStaticBox = FALSE; m_isRadioButton = FALSE; m_acceptsFocus = FALSE; + + m_cursor = *wxSTANDARD_CURSOR; } wxWindow::wxWindow() @@ -1864,15 +1861,19 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, if (HasFlag(wxRAISED_BORDER)) { - gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_OUT ); + gtk_myfixed_set_shadow_type( myfixed, GTK_MYSHADOW_OUT ); } else if (HasFlag(wxSUNKEN_BORDER)) { - gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_IN ); + gtk_myfixed_set_shadow_type( myfixed, GTK_MYSHADOW_IN ); + } + else if (HasFlag(wxSIMPLE_BORDER)) + { + gtk_myfixed_set_shadow_type( myfixed, GTK_MYSHADOW_THIN ); } else { - gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_NONE ); + gtk_myfixed_set_shadow_type( myfixed, GTK_MYSHADOW_NONE ); } #else // GTK_MINOR_VERSION == 0 GtkViewport *viewport = GTK_VIEWPORT(scrolledWindow->viewport); @@ -2052,7 +2053,7 @@ void wxWindow::PostCreation() GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); #if (GTK_MINOR_VERSION > 0) - /* these are called when the "sunken" or "raised" borders are drawn */ + /* these are called when the "sunken", "raised" or "simple" borders are drawn */ gtk_signal_connect( GTK_OBJECT(m_widget), "expose_event", GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this ); @@ -2227,14 +2228,17 @@ void wxWindow::OnInternalIdle() cursor = *wxSTANDARD_CURSOR; window = m_widget->window; - if (window) + if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget))) gdk_window_set_cursor( window, cursor.GetCursor() ); + } else { + GdkWindow *window = m_widget->window; - if (window) + if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget))) gdk_window_set_cursor( window, cursor.GetCursor() ); + } } @@ -2282,10 +2286,16 @@ void wxWindow::DoSetClientSize( int width, int height ) #else if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) { - /* when using GTK 1.2 we set the border size to 2 */ + /* when using GTK 1.2 we set the shadow border size to 2 */ dw += 2 * 2; dh += 2 * 2; } + if (HasFlag(wxSIMPLE_BORDER)) + { + /* when using GTK 1.2 we set the simple border size to 1 */ + dw += 1 * 2; + dh += 1 * 2; + } #endif if (HasScrolling()) @@ -2351,10 +2361,16 @@ void wxWindow::DoGetClientSize( int *width, int *height ) const #else if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) { - /* when using GTK 1.2 we set the border size to 2 */ + /* when using GTK 1.2 we set the shadow border size to 2 */ dw += 2 * 2; dh += 2 * 2; } + if (HasFlag(wxSIMPLE_BORDER)) + { + /* when using GTK 1.2 we set the simple border size to 1 */ + dw += 1 * 2; + dh += 1 * 2; + } #endif if (HasScrolling()) { @@ -2615,29 +2631,7 @@ bool wxWindow::SetCursor( const wxCursor &cursor ) { wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") ); - if (!wxWindowBase::SetCursor(cursor)) - { - // don't leave if the GTK widget has just - // been realized - if (!m_delayedCursor) return FALSE; - } - - GtkWidget *connect_widget = GetConnectWidget(); - if (!connect_widget->window) - { - // indicate that a new style has been set - // but it couldn't get applied as the - // widget hasn't been realized yet. - m_delayedCursor = TRUE; - - // pretend we have done something - return TRUE; - } - -// gdk_window_set_cursor( connect_widget->window, GetCursor().GetCursor() ); - - // cursor was set - return TRUE; + return wxWindowBase::SetCursor( cursor ); } void wxWindow::WarpPointer( int x, int y ) @@ -2956,7 +2950,7 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window ) bool wxWindow::SetFont( const wxFont &font ) { - wxCHECK_MSG( m_widget != NULL, FALSE, _T( "invalid window") ); + wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") ); if (!wxWindowBase::SetFont(font)) { @@ -3121,8 +3115,10 @@ void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) m_vAdjust->value = fpos; } - if (!m_isScrolling) /* prevent recursion */ +/* + if (!m_isScrolling) { +*/ if (m_wxwindow->window) { if (orient == wxHORIZONTAL) @@ -3130,7 +3126,9 @@ void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) else gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" ); } +/* } +*/ } int wxWindow::GetScrollThumb( int orient ) const diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index 9812ec9c7b..4869b9263f 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -20,6 +20,11 @@ #include "wx/gtk/win_gtk.h" #include "wx/cursor.h" +/* +#include "gdk/gdkprivate.h" +#include "gdk/gdkx.h" +*/ + //----------------------------------------------------------------------------- // idle system //----------------------------------------------------------------------------- @@ -33,6 +38,33 @@ extern bool g_isIdle; extern wxList wxPendingDelete; +/* +//----------------------------------------------------------------------------- +// instruct X to set the WM hint for positioning +//----------------------------------------------------------------------------- + +extern "C" { + +static void gdk_window_set_position_hint( GdkWindow *window, gint x, gint y ) +{ + GdkWindowPrivate *priv; + XSizeHints size_hints; + + g_return_if_fail (window != NULL); + + priv = (GdkWindowPrivate*) window; + if (priv->destroyed) return; + + size_hints.flags = PPosition; + size_hints.x = x; + size_hints.y = y; + + XSetWMNormalHints (priv->xdisplay, priv->xwindow, &size_hints); +} + +} +*/ + //----------------------------------------------------------------------------- // "delete_event" //----------------------------------------------------------------------------- @@ -118,6 +150,10 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win ) position in "realize" and "map" */ gtk_widget_set_uposition( widget, win->m_x, win->m_y ); +/* + gdk_window_set_position_hint( widget->window, win->m_x, win->m_y ); +*/ + /* reset the icon */ if (win->m_icon != wxNullIcon) { @@ -546,6 +582,8 @@ void wxDialog::OnInternalIdle() { if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow)) GtkOnSize( m_x, m_y, m_width, m_height ); + + wxWindow::OnInternalIdle(); } bool wxDialog::Show( bool show ) diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 78247575e7..3e87057d4a 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -800,6 +800,8 @@ void wxFrame::OnInternalIdle() #if wxUSE_STATUSBAR if (m_frameStatusBar) m_frameStatusBar->OnInternalIdle(); #endif + + wxWindow::OnInternalIdle(); } void wxFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) ) diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index 267cf1faee..d981ae99dd 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -72,10 +72,11 @@ extern bool g_isIdle; // data //----------------------------------------------------------------------------- -extern bool g_blockEventsOnDrag; -extern bool g_blockEventsOnScroll; +extern bool g_blockEventsOnDrag; +extern bool g_blockEventsOnScroll; +extern wxCursor g_globalCursor; -static bool g_hasDoubleClicked = FALSE; +static bool g_hasDoubleClicked = FALSE; //----------------------------------------------------------------------------- // "button_release_event" @@ -1005,4 +1006,30 @@ void wxListBox::ApplyWidgetStyle() } } +void wxListBox::OnInternalIdle() +{ + wxCursor cursor = m_cursor; + if (g_globalCursor.Ok()) cursor = g_globalCursor; + + if (m_widget->window && cursor.Ok() && m_currentGdkCursor != cursor) + { + m_currentGdkCursor = cursor; + + gdk_window_set_cursor( GTK_WIDGET(m_list)->window, m_currentGdkCursor.GetCursor() ); + + GList *child = m_list->children; + while (child) + { + GtkBin *bin = GTK_BIN( child->data ); + GtkWidget *label = GTK_WIDGET( bin->child ); + + gdk_window_set_cursor( label->window, m_currentGdkCursor.GetCursor() ); + + child = child->next; + } + } + + UpdateWindowUI(); +} + #endif diff --git a/src/gtk1/mdi.cpp b/src/gtk1/mdi.cpp index 0b98599d59..ab91caff85 100644 --- a/src/gtk1/mdi.cpp +++ b/src/gtk1/mdi.cpp @@ -43,6 +43,27 @@ extern bool g_isIdle; extern wxList wxPendingDelete; +//----------------------------------------------------------------------------- +// "switch_page" +//----------------------------------------------------------------------------- + +static void gtk_mdi_page_change_callback(GtkNotebook *WXUNUSED(widget), + GtkNotebookPage *WXUNUSED(page), + gint page, + wxMDIParentFrame *parent ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + + wxMDIChildFrame *child = parent->GetActiveChild(); + + if (!child) return; + + wxActivateEvent event( wxEVT_ACTIVATE, TRUE, child->GetId() ); + event.SetEventObject( child); + child->GetEventHandler()->ProcessEvent( event ); +} + //----------------------------------------------------------------------------- // wxMDIParentFrame //----------------------------------------------------------------------------- @@ -418,6 +439,9 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style ) m_widget = gtk_notebook_new(); + gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page", + GTK_SIGNAL_FUNC(gtk_mdi_page_change_callback), (gpointer)parent ); + gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 ); m_parent->DoAddChild( this ); diff --git a/src/gtk1/win_gtk.c b/src/gtk1/win_gtk.c index a9552bd63b..5f683d50c7 100644 --- a/src/gtk1/win_gtk.c +++ b/src/gtk1/win_gtk.c @@ -156,7 +156,7 @@ gtk_myfixed_init (GtkMyFixed *myfixed) #endif #if (GTK_MINOR_VERSION > 0) - myfixed->shadow_type = GTK_SHADOW_NONE; + myfixed->shadow_type = GTK_MYSHADOW_NONE; #endif myfixed->children = NULL; @@ -182,13 +182,13 @@ gtk_myfixed_scroll_set_adjustments (GtkMyFixed *myfixed, } void -gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed, - GtkShadowType type) +gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed, + GtkMyShadowType type) { g_return_if_fail (myfixed != NULL); g_return_if_fail (GTK_IS_MYFIXED (myfixed)); - if ((GtkShadowType) myfixed->shadow_type != type) + if ((GtkMyShadowType) myfixed->shadow_type != type) { myfixed->shadow_type = type; @@ -415,8 +415,21 @@ gtk_myfixed_realize (GtkWidget *widget) attributes.width = widget->allocation.width; attributes.height = widget->allocation.height; - if (myfixed->shadow_type != GTK_SHADOW_NONE) + if (myfixed->shadow_type == GTK_MYSHADOW_NONE) { + /* no border, no changes to sizes */ + } else + if (myfixed->shadow_type == GTK_MYSHADOW_THIN) + { + /* GTK_MYSHADOW_THIN == wxSIMPLE_BORDER */ + attributes.x += 1; + attributes.y += 1; + attributes.width -= 2; + attributes.height -= 2; + } else + { + /* GTK_MYSHADOW_IN == wxSUNKEN_BORDER */ + /* GTK_MYSHADOW_OUT == wxRAISED_BORDER */ attributes.x += 2; attributes.y += 2; attributes.width -= 4; @@ -511,8 +524,11 @@ gtk_myfixed_size_allocate (GtkWidget *widget, widget->allocation = *allocation; #if (GTK_MINOR_VERSION > 0) - if (myfixed->shadow_type == GTK_SHADOW_NONE) + if (myfixed->shadow_type == GTK_MYSHADOW_NONE) border = 0; + else + if (myfixed->shadow_type == GTK_MYSHADOW_THIN) + border = 1; else border = 2; #else diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index b4e5416019..2b47193e48 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -632,6 +632,17 @@ static void draw_frame( GtkWidget *widget, wxWindow *win ) win->m_width-dw, win->m_height-dh ); return; } + + if (win->HasFlag(wxSIMPLE_BORDER)) + { + GdkGC *gc = gdk_gc_new( widget->window ); + gdk_gc_set_foreground( gc, &widget->style->black ); + gdk_draw_rectangle( widget->window, gc, FALSE, + dx, dy, + win->m_width-dw-1, win->m_height-dh-1 ); + gdk_gc_unref( gc ); + return; + } } //----------------------------------------------------------------------------- @@ -1227,7 +1238,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; if (g_blockEventsOnScroll) return FALSE; - + if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; if (gdk_event->is_hint) @@ -1509,7 +1520,7 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ // "value_changed" from m_vAdjust //----------------------------------------------------------------------------- -static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) +static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -1517,32 +1528,25 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * if (g_blockEventsOnDrag) return; if (!win->m_hasVMT) return; - - float diff = win->m_vAdjust->value - win->m_oldVerticalPos; + + float diff = adjust->value - win->m_oldVerticalPos; if (fabs(diff) < 0.2) return; - win->m_oldVerticalPos = win->m_vAdjust->value; - - wxEventType command = wxEVT_NULL; - - float line_step = win->m_vAdjust->step_increment; - float page_step = win->m_vAdjust->page_increment; + + win->m_oldVerticalPos = adjust->value; - if (win->IsScrolling()) - { - command = wxEVT_SCROLLWIN_THUMBTRACK; - } - else - { - if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM; - else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP; - else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEDOWN; - else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEUP; - else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEDOWN; - else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEUP; - else command = wxEVT_SCROLLWIN_THUMBTRACK; - } + 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; + +// if (fabs(adjust->value-adjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM; +// if (fabs(adjust->value-adjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP; - int value = (int)(win->m_vAdjust->value+0.5); + int value = (int)(adjust->value+0.5); wxScrollWinEvent event( command, value, wxVERTICAL ); event.SetEventObject( win ); @@ -1553,7 +1557,7 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * // "value_changed" from m_hAdjust //----------------------------------------------------------------------------- -static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) +static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -1561,31 +1565,24 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow * if (g_blockEventsOnDrag) return; if (!win->m_hasVMT) return; - float diff = win->m_hAdjust->value - win->m_oldHorizontalPos; + float diff = adjust->value - win->m_oldHorizontalPos; if (fabs(diff) < 0.2) return; - win->m_oldHorizontalPos = win->m_hAdjust->value; - - wxEventType command = wxEVT_NULL; - - float line_step = win->m_hAdjust->step_increment; - float page_step = win->m_hAdjust->page_increment; + + win->m_oldHorizontalPos = adjust->value; - if (win->IsScrolling()) - { - command = wxEVT_SCROLLWIN_THUMBTRACK; - } - else - { - if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM; - else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP; - else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEDOWN; - else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLLWIN_LINEUP; - else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEDOWN; - else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLLWIN_PAGEUP; - else command = wxEVT_SCROLLWIN_THUMBTRACK; - } + 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; + +// if (fabs(adjust->value-adjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM; +// if (fabs(adjust->value-adjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP; - int value = (int)(win->m_hAdjust->value+0.5); + int value = (int)(adjust->value+0.5); wxScrollWinEvent event( command, value, wxHORIZONTAL ); event.SetEventObject( win ); @@ -1644,7 +1641,7 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget), wxapp_install_idle_handler(); // don't test here as we can release the mouse while being over -// a different window then the slider +// a different window than the slider // // if (gdk_event->window != widget->slider) return FALSE; @@ -1663,16 +1660,16 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget, { // don't test here as we can release the mouse while being over -// a different window then the slider +// a different window than the slider // // if (gdk_event->window != widget->slider) return FALSE; - GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget); - - if (widget == GTK_RANGE(scrolledWindow->vscrollbar)) - gtk_signal_emit_by_name( GTK_OBJECT(win->m_hAdjust), "value_changed" ); - else - gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" ); +// GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget); +// +// if (widget == GTK_RANGE(scrolledWindow->vscrollbar)) +// gtk_signal_emit_by_name( GTK_OBJECT(win->m_hAdjust), "value_changed" ); +// else +// gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" ); win->SetScrolling( FALSE ); @@ -1693,7 +1690,7 @@ wxWindow *wxWindowBase::FindFocus() // "realize" from m_widget //----------------------------------------------------------------------------- -/* we cannot set colours, fonts and cursors before the widget has +/* we cannot set colours and fonts before the widget has been realized, so we do this directly after realization */ static gint @@ -1711,8 +1708,6 @@ gtk_window_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win ) if (win->m_delayedForegroundColour) win->SetForegroundColour( win->GetForegroundColour() ); - win->SetCursor( win->GetCursor() ); - wxWindowCreateEvent event( win ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); @@ -1800,6 +1795,8 @@ void wxWindow::Init() m_isStaticBox = FALSE; m_isRadioButton = FALSE; m_acceptsFocus = FALSE; + + m_cursor = *wxSTANDARD_CURSOR; } wxWindow::wxWindow() @@ -1864,15 +1861,19 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, if (HasFlag(wxRAISED_BORDER)) { - gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_OUT ); + gtk_myfixed_set_shadow_type( myfixed, GTK_MYSHADOW_OUT ); } else if (HasFlag(wxSUNKEN_BORDER)) { - gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_IN ); + gtk_myfixed_set_shadow_type( myfixed, GTK_MYSHADOW_IN ); + } + else if (HasFlag(wxSIMPLE_BORDER)) + { + gtk_myfixed_set_shadow_type( myfixed, GTK_MYSHADOW_THIN ); } else { - gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_NONE ); + gtk_myfixed_set_shadow_type( myfixed, GTK_MYSHADOW_NONE ); } #else // GTK_MINOR_VERSION == 0 GtkViewport *viewport = GTK_VIEWPORT(scrolledWindow->viewport); @@ -2052,7 +2053,7 @@ void wxWindow::PostCreation() GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); #if (GTK_MINOR_VERSION > 0) - /* these are called when the "sunken" or "raised" borders are drawn */ + /* these are called when the "sunken", "raised" or "simple" borders are drawn */ gtk_signal_connect( GTK_OBJECT(m_widget), "expose_event", GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this ); @@ -2227,14 +2228,17 @@ void wxWindow::OnInternalIdle() cursor = *wxSTANDARD_CURSOR; window = m_widget->window; - if (window) + if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget))) gdk_window_set_cursor( window, cursor.GetCursor() ); + } else { + GdkWindow *window = m_widget->window; - if (window) + if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget))) gdk_window_set_cursor( window, cursor.GetCursor() ); + } } @@ -2282,10 +2286,16 @@ void wxWindow::DoSetClientSize( int width, int height ) #else if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) { - /* when using GTK 1.2 we set the border size to 2 */ + /* when using GTK 1.2 we set the shadow border size to 2 */ dw += 2 * 2; dh += 2 * 2; } + if (HasFlag(wxSIMPLE_BORDER)) + { + /* when using GTK 1.2 we set the simple border size to 1 */ + dw += 1 * 2; + dh += 1 * 2; + } #endif if (HasScrolling()) @@ -2351,10 +2361,16 @@ void wxWindow::DoGetClientSize( int *width, int *height ) const #else if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) { - /* when using GTK 1.2 we set the border size to 2 */ + /* when using GTK 1.2 we set the shadow border size to 2 */ dw += 2 * 2; dh += 2 * 2; } + if (HasFlag(wxSIMPLE_BORDER)) + { + /* when using GTK 1.2 we set the simple border size to 1 */ + dw += 1 * 2; + dh += 1 * 2; + } #endif if (HasScrolling()) { @@ -2615,29 +2631,7 @@ bool wxWindow::SetCursor( const wxCursor &cursor ) { wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") ); - if (!wxWindowBase::SetCursor(cursor)) - { - // don't leave if the GTK widget has just - // been realized - if (!m_delayedCursor) return FALSE; - } - - GtkWidget *connect_widget = GetConnectWidget(); - if (!connect_widget->window) - { - // indicate that a new style has been set - // but it couldn't get applied as the - // widget hasn't been realized yet. - m_delayedCursor = TRUE; - - // pretend we have done something - return TRUE; - } - -// gdk_window_set_cursor( connect_widget->window, GetCursor().GetCursor() ); - - // cursor was set - return TRUE; + return wxWindowBase::SetCursor( cursor ); } void wxWindow::WarpPointer( int x, int y ) @@ -2956,7 +2950,7 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window ) bool wxWindow::SetFont( const wxFont &font ) { - wxCHECK_MSG( m_widget != NULL, FALSE, _T( "invalid window") ); + wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") ); if (!wxWindowBase::SetFont(font)) { @@ -3121,8 +3115,10 @@ void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) m_vAdjust->value = fpos; } - if (!m_isScrolling) /* prevent recursion */ +/* + if (!m_isScrolling) { +*/ if (m_wxwindow->window) { if (orient == wxHORIZONTAL) @@ -3130,7 +3126,9 @@ void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) else gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" ); } +/* } +*/ } int wxWindow::GetScrollThumb( int orient ) const -- 2.45.2