From 85a0a12a9c6fe2885c0de8801e91a2f6d6e4119a Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Thu, 24 Aug 2006 11:08:42 +0000 Subject: [PATCH] Added resize support to wxMiniFrame. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40788 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/minifram.cpp | 92 +++++++++++++++++++++++++++++++++++++------- src/gtk/toplevel.cpp | 11 +++++- 2 files changed, 88 insertions(+), 15 deletions(-) diff --git a/src/gtk/minifram.cpp b/src/gtk/minifram.cpp index 931fc2b1bd..319159f69e 100644 --- a/src/gtk/minifram.cpp +++ b/src/gtk/minifram.cpp @@ -81,15 +81,22 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g int style = win->GetWindowStyle(); + wxClientDC dc(win); + // Hack alert + dc.m_window = pizza->bin_window; + + if (style & wxRESIZE_BORDER) + { + dc.SetBrush( *wxGREY_BRUSH ); + dc.SetPen( *wxTRANSPARENT_PEN ); + dc.DrawRectangle( win->m_width - 14, win->m_height-14, 14, 14 ); + } + if (!win->GetTitle().empty() && ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))) { - wxClientDC dc(win); - // Hack alert - dc.m_window = pizza->bin_window; - dc.SetFont( *wxSMALL_FONT ); int height = dc.GetCharHeight(); @@ -125,10 +132,32 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton GtkPizza *pizza = GTK_PIZZA(widget); if (gdk_event->window != pizza->bin_window) return TRUE; + int style = win->GetWindowStyle(); + int y = (int)gdk_event->y; int x = (int)gdk_event->x; + + if ((style & wxRESIZE_BORDER) && + (x > win->m_width-14) && (y > win->m_height-14)) + { + GtkWidget *ancestor = gtk_widget_get_toplevel( widget ); + + GdkWindow *source = GTK_PIZZA(widget)->bin_window; + + int org_x = 0; + int org_y = 0; + gdk_window_get_origin( source, &org_x, &org_y ); + + gtk_window_begin_resize_drag (GTK_WINDOW (ancestor), + GDK_WINDOW_EDGE_SOUTH_EAST, + 1, + org_x + x, + org_y + y, + 0); + + return TRUE; + } - int style = win->GetWindowStyle(); if ((style & wxCLOSE_BOX) && ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))) { @@ -205,21 +234,41 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto } } +//----------------------------------------------------------------------------- +// "leave_notify_event" of m_mainWidget +//----------------------------------------------------------------------------- + +extern "C" { +static gboolean +gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxMiniFrame *win ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) return FALSE; + if (g_blockEventsOnDrag) return FALSE; + + gdk_window_set_cursor( widget->window, NULL ); + + return FALSE; +} +} + //----------------------------------------------------------------------------- // "motion_notify_event" of m_mainWidget //----------------------------------------------------------------------------- extern "C" { -static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win ) +static gint +gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win ) { - if (g_isIdle) wxapp_install_idle_handler(); + if (g_isIdle) + wxapp_install_idle_handler(); if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; - if (!win->m_isDragging) return TRUE; - if (gdk_event->is_hint) { int x = 0; @@ -231,12 +280,26 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion gdk_event->state = state; } - win->m_oldX = (int)gdk_event->x - win->m_diffX; - win->m_oldY = (int)gdk_event->y - win->m_diffY; - + int style = win->GetWindowStyle(); + int x = (int)gdk_event->x; int y = (int)gdk_event->y; + if (!win->m_isDragging) + { + if (style & wxRESIZE_BORDER) + { + if ((x > win->m_width-14) && (y > win->m_height-14)) + gdk_window_set_cursor( widget->window, gdk_cursor_new( GDK_BOTTOM_RIGHT_CORNER ) ); + else + gdk_window_set_cursor( widget->window, NULL ); + } + return TRUE; + } + + win->m_oldX = x - win->m_diffX; + win->m_oldY = y - win->m_diffY; + int org_x = 0; int org_y = 0; gdk_window_get_origin( widget->window, &org_x, &org_y ); @@ -273,7 +336,7 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title m_miniTitle = 16; if (style & wxRESIZE_BORDER) - m_miniEdge = 5; + m_miniEdge = 4; else m_miniEdge = 3; m_isDragging = false; @@ -309,7 +372,8 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title G_CALLBACK (gtk_window_button_release_callback), this); g_signal_connect (m_mainWidget, "motion_notify_event", G_CALLBACK (gtk_window_motion_notify_callback), this); - + g_signal_connect (m_mainWidget, "leave_notify_event", + G_CALLBACK (gtk_window_leave_callback), this); return true; } diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index 0c8752c927..f599caeab3 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -625,12 +625,21 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, G_CALLBACK (gtk_frame_focus_out_callback), this); // decorations - if ((m_miniEdge > 0) || (style & wxSIMPLE_BORDER) || (style & wxNO_BORDER)) + if ((style & wxSIMPLE_BORDER) || (style & wxNO_BORDER)) { m_gdkDecor = 0; m_gdkFunc = 0; } else + if (m_miniEdge > 0) + { + m_gdkDecor = 0; + m_gdkFunc = 0; + + if ((style & wxRESIZE_BORDER) != 0) + m_gdkFunc |= GDK_FUNC_RESIZE; + } + else { m_gdkDecor = (long) GDK_DECOR_BORDER; m_gdkFunc = (long) GDK_FUNC_MOVE; -- 2.45.2