Added resize support to wxMiniFrame.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40788 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2006-08-24 11:08:42 +00:00
parent c67e060d09
commit 85a0a12a9c
2 changed files with 88 additions and 15 deletions

View File

@@ -81,15 +81,22 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g
int style = win->GetWindowStyle(); 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() && if (!win->GetTitle().empty() &&
((style & wxCAPTION) || ((style & wxCAPTION) ||
(style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_HORIZ) ||
(style & wxTINY_CAPTION_VERT))) (style & wxTINY_CAPTION_VERT)))
{ {
wxClientDC dc(win);
// Hack alert
dc.m_window = pizza->bin_window;
dc.SetFont( *wxSMALL_FONT ); dc.SetFont( *wxSMALL_FONT );
int height = dc.GetCharHeight(); int height = dc.GetCharHeight();
@@ -125,10 +132,32 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
GtkPizza *pizza = GTK_PIZZA(widget); GtkPizza *pizza = GTK_PIZZA(widget);
if (gdk_event->window != pizza->bin_window) return TRUE; if (gdk_event->window != pizza->bin_window) return TRUE;
int style = win->GetWindowStyle();
int y = (int)gdk_event->y; int y = (int)gdk_event->y;
int x = (int)gdk_event->x; int x = (int)gdk_event->x;
int style = win->GetWindowStyle(); 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;
}
if ((style & wxCLOSE_BOX) && if ((style & wxCLOSE_BOX) &&
((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))) ((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 // "motion_notify_event" of m_mainWidget
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" { 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 (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE; if (g_blockEventsOnScroll) return TRUE;
if (!win->m_isDragging) return TRUE;
if (gdk_event->is_hint) if (gdk_event->is_hint)
{ {
int x = 0; int x = 0;
@@ -231,12 +280,26 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
gdk_event->state = state; gdk_event->state = state;
} }
win->m_oldX = (int)gdk_event->x - win->m_diffX; int style = win->GetWindowStyle();
win->m_oldY = (int)gdk_event->y - win->m_diffY;
int x = (int)gdk_event->x; int x = (int)gdk_event->x;
int y = (int)gdk_event->y; 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_x = 0;
int org_y = 0; int org_y = 0;
gdk_window_get_origin( widget->window, &org_x, &org_y ); 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; m_miniTitle = 16;
if (style & wxRESIZE_BORDER) if (style & wxRESIZE_BORDER)
m_miniEdge = 5; m_miniEdge = 4;
else else
m_miniEdge = 3; m_miniEdge = 3;
m_isDragging = false; 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_CALLBACK (gtk_window_button_release_callback), this);
g_signal_connect (m_mainWidget, "motion_notify_event", g_signal_connect (m_mainWidget, "motion_notify_event",
G_CALLBACK (gtk_window_motion_notify_callback), this); 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; return true;
} }

View File

@@ -625,12 +625,21 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
G_CALLBACK (gtk_frame_focus_out_callback), this); G_CALLBACK (gtk_frame_focus_out_callback), this);
// decorations // decorations
if ((m_miniEdge > 0) || (style & wxSIMPLE_BORDER) || (style & wxNO_BORDER)) if ((style & wxSIMPLE_BORDER) || (style & wxNO_BORDER))
{ {
m_gdkDecor = 0; m_gdkDecor = 0;
m_gdkFunc = 0; m_gdkFunc = 0;
} }
else 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_gdkDecor = (long) GDK_DECOR_BORDER;
m_gdkFunc = (long) GDK_FUNC_MOVE; m_gdkFunc = (long) GDK_FUNC_MOVE;