From 5549fa6559b3e4fdb975df6b4abd253279ed5351 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 4 May 1999 11:15:37 +0000 Subject: [PATCH] Added window resize patch to wxFrame Added patch to wxNotebook for keeping m_id in synch after deletion of pages Added patch for idle handling within DnD git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2337 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/dnd.cpp | 23 +++++++++++++++++++++++ src/gtk/frame.cpp | 8 +++----- src/gtk/notebook.cpp | 12 ++++++++++++ src/gtk1/dnd.cpp | 23 +++++++++++++++++++++++ src/gtk1/frame.cpp | 8 +++----- src/gtk1/notebook.cpp | 12 ++++++++++++ 6 files changed, 76 insertions(+), 10 deletions(-) diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index 7bef3e8f1c..9378aba506 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -28,6 +28,13 @@ #include "gtk/gtkdnd.h" #include "gtk/gtkselection.h" +//----------------------------------------------------------------------------- +// idle system +//----------------------------------------------------------------------------- + +extern void wxapp_install_idle_handler(); +extern bool g_isIdle; + //---------------------------------------------------------------------------- // global data //---------------------------------------------------------------------------- @@ -134,6 +141,8 @@ static void target_drag_leave( GtkWidget *WXUNUSED(widget), guint WXUNUSED(time), wxDropTarget *drop_target ) { + if (g_isIdle) wxapp_install_idle_handler(); + /* inform the wxDropTarget about the current GdkDragContext. this is only valid for the duration of this call */ drop_target->SetDragContext( context ); @@ -160,6 +169,8 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget), guint time, wxDropTarget *drop_target ) { + if (g_isIdle) wxapp_install_idle_handler(); + /* Owen Taylor: "if the coordinates not in a drop zone, return FALSE, otherwise call gtk_drag_status() and return TRUE" */ @@ -203,6 +214,8 @@ static gboolean target_drag_drop( GtkWidget *widget, guint time, wxDropTarget *drop_target ) { + if (g_isIdle) wxapp_install_idle_handler(); + /* Owen Taylor: "if the drop is not in a drop zone, return FALSE, otherwise, if you aren't accepting the drop, call gtk_drag_finish() with success == FALSE @@ -262,6 +275,8 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget), guint time, wxDropTarget *drop_target ) { + if (g_isIdle) wxapp_install_idle_handler(); + /* Owen Taylor: "call gtk_drag_finish() with success == TRUE" */ @@ -589,6 +604,8 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget), guint WXUNUSED(time), wxDropSource *drop_source ) { + if (g_isIdle) wxapp_install_idle_handler(); + // printf( "Provide data!\n" ); // char *name = gdk_atom_name( selection_data->target ); @@ -640,6 +657,8 @@ static void source_drag_data_delete( GtkWidget *WXUNUSED(widget), GdkDragContext *WXUNUSED(context), wxDropSource *drop_source ) { + if (g_isIdle) wxapp_install_idle_handler(); + // printf( "Delete the data!\n" ); drop_source->m_retValue = wxDragMove; @@ -653,6 +672,8 @@ static void source_drag_begin( GtkWidget *WXUNUSED(widget), GdkDragContext *WXUNUSED(context), wxDropSource *WXUNUSED(drop_source) ) { + if (g_isIdle) wxapp_install_idle_handler(); + // printf( "drag_begin.\n" ); } @@ -664,6 +685,8 @@ static void source_drag_end( GtkWidget *WXUNUSED(widget), GdkDragContext *WXUNUSED(context), wxDropSource *drop_source ) { + if (g_isIdle) wxapp_install_idle_handler(); + // printf( "drag_end.\n" ); drop_source->m_waiting = FALSE; diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 04a8523505..62cfe002c0 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -696,8 +696,6 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_frameToolBar->m_widget, xx, yy ); -// m_frameToolBar->m_widget->requisition.width = ww; -// m_frameToolBar->m_widget->requisition.height = hh; gtk_widget_set_usize( m_frameToolBar->m_widget, ww, hh ); client_area_y_offset += hh; @@ -709,10 +707,10 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height int client_w = m_width - 2*m_miniEdge; int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle; -// m_wxwindow->requisition.width = client_w; -// m_wxwindow->requisition.height = client_h; gtk_widget_set_usize( m_wxwindow, client_w, client_h ); - + GtkAllocation alloc; + alloc.x = client_x; alloc.y = client_y; alloc.width = client_w; alloc.height = client_h; + gtk_widget_size_allocate( m_wxwindow, &alloc ); } else { diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 56ef149e82..2eb7a24f51 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -572,6 +572,18 @@ bool wxNotebook::DeletePage( int page ) m_pages.DeleteObject( nb_page ); + /* adjust the notebook page numbers so that + m_id reflects the current position, Daniel Paull */ + int count = 0; + wxNode *node = m_pages.First(); + wxNotebookPage *pagePtr = (wxNotebookPage *) NULL; + while (node) + { + pagePtr = (wxNotebookPage*)node->Data(); + pagePtr->m_id = count++; + node = node->Next(); + } + return TRUE; } diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index 7bef3e8f1c..9378aba506 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -28,6 +28,13 @@ #include "gtk/gtkdnd.h" #include "gtk/gtkselection.h" +//----------------------------------------------------------------------------- +// idle system +//----------------------------------------------------------------------------- + +extern void wxapp_install_idle_handler(); +extern bool g_isIdle; + //---------------------------------------------------------------------------- // global data //---------------------------------------------------------------------------- @@ -134,6 +141,8 @@ static void target_drag_leave( GtkWidget *WXUNUSED(widget), guint WXUNUSED(time), wxDropTarget *drop_target ) { + if (g_isIdle) wxapp_install_idle_handler(); + /* inform the wxDropTarget about the current GdkDragContext. this is only valid for the duration of this call */ drop_target->SetDragContext( context ); @@ -160,6 +169,8 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget), guint time, wxDropTarget *drop_target ) { + if (g_isIdle) wxapp_install_idle_handler(); + /* Owen Taylor: "if the coordinates not in a drop zone, return FALSE, otherwise call gtk_drag_status() and return TRUE" */ @@ -203,6 +214,8 @@ static gboolean target_drag_drop( GtkWidget *widget, guint time, wxDropTarget *drop_target ) { + if (g_isIdle) wxapp_install_idle_handler(); + /* Owen Taylor: "if the drop is not in a drop zone, return FALSE, otherwise, if you aren't accepting the drop, call gtk_drag_finish() with success == FALSE @@ -262,6 +275,8 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget), guint time, wxDropTarget *drop_target ) { + if (g_isIdle) wxapp_install_idle_handler(); + /* Owen Taylor: "call gtk_drag_finish() with success == TRUE" */ @@ -589,6 +604,8 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget), guint WXUNUSED(time), wxDropSource *drop_source ) { + if (g_isIdle) wxapp_install_idle_handler(); + // printf( "Provide data!\n" ); // char *name = gdk_atom_name( selection_data->target ); @@ -640,6 +657,8 @@ static void source_drag_data_delete( GtkWidget *WXUNUSED(widget), GdkDragContext *WXUNUSED(context), wxDropSource *drop_source ) { + if (g_isIdle) wxapp_install_idle_handler(); + // printf( "Delete the data!\n" ); drop_source->m_retValue = wxDragMove; @@ -653,6 +672,8 @@ static void source_drag_begin( GtkWidget *WXUNUSED(widget), GdkDragContext *WXUNUSED(context), wxDropSource *WXUNUSED(drop_source) ) { + if (g_isIdle) wxapp_install_idle_handler(); + // printf( "drag_begin.\n" ); } @@ -664,6 +685,8 @@ static void source_drag_end( GtkWidget *WXUNUSED(widget), GdkDragContext *WXUNUSED(context), wxDropSource *drop_source ) { + if (g_isIdle) wxapp_install_idle_handler(); + // printf( "drag_end.\n" ); drop_source->m_waiting = FALSE; diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 04a8523505..62cfe002c0 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -696,8 +696,6 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_frameToolBar->m_widget, xx, yy ); -// m_frameToolBar->m_widget->requisition.width = ww; -// m_frameToolBar->m_widget->requisition.height = hh; gtk_widget_set_usize( m_frameToolBar->m_widget, ww, hh ); client_area_y_offset += hh; @@ -709,10 +707,10 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height int client_w = m_width - 2*m_miniEdge; int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle; -// m_wxwindow->requisition.width = client_w; -// m_wxwindow->requisition.height = client_h; gtk_widget_set_usize( m_wxwindow, client_w, client_h ); - + GtkAllocation alloc; + alloc.x = client_x; alloc.y = client_y; alloc.width = client_w; alloc.height = client_h; + gtk_widget_size_allocate( m_wxwindow, &alloc ); } else { diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index 56ef149e82..2eb7a24f51 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -572,6 +572,18 @@ bool wxNotebook::DeletePage( int page ) m_pages.DeleteObject( nb_page ); + /* adjust the notebook page numbers so that + m_id reflects the current position, Daniel Paull */ + int count = 0; + wxNode *node = m_pages.First(); + wxNotebookPage *pagePtr = (wxNotebookPage *) NULL; + while (node) + { + pagePtr = (wxNotebookPage*)node->Data(); + pagePtr->m_id = count++; + node = node->Next(); + } + return TRUE; } -- 2.45.2