X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b3d006af0fca9ba3679f092016cf149c9f6fd06c..12bb29f5432174ecbd65549bda832d70d34a98ae:/src/gtk1/window.cpp diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 98c21e02b3..9dc790f7ff 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -32,10 +32,9 @@ #include "wx/layout.h" #include "wx/statusbr.h" #include "wx/math.h" + #include "wx/module.h" #endif -#include "wx/module.h" - #if wxUSE_DRAG_AND_DROP #include "wx/dnd.h" #endif @@ -50,7 +49,7 @@ #include "wx/fontutil.h" -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL #include "wx/thread.h" #endif @@ -208,43 +207,45 @@ static GdkGC *g_eraseGC = NULL; // mouse capture state: the window which has it and if the mouse is currently // inside it -static wxWindowGTK *g_captureWindow = (wxWindowGTK*) NULL; +static wxWindowGTK *g_captureWindow = NULL; static bool g_captureWindowHasMouse = false; -wxWindowGTK *g_focusWindow = (wxWindowGTK*) NULL; +wxWindowGTK *g_focusWindow = NULL; // the last window which had the focus - this is normally never NULL (except // if we never had focus at all) as even when g_focusWindow is NULL it still // keeps its previous value -wxWindowGTK *g_focusWindowLast = (wxWindowGTK*) NULL; +wxWindowGTK *g_focusWindowLast = NULL; // If a window get the focus set but has not been realized // yet, defer setting the focus to idle time. -wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL; +wxWindowGTK *g_delayedFocus = NULL; // hack: we need something to pass to gtk_menu_popup, so we store the time of // the last click here (extern: used from gtk/menu.cpp) guint32 wxGtkTimeLastClick = 0; +// global variables because GTK+ DnD want to have the +// mouse event that caused it +GdkEvent *g_lastMouseEvent = NULL; +int g_lastButtonNumber = 0; + extern bool g_mainThreadLocked; //----------------------------------------------------------------------------- // debug //----------------------------------------------------------------------------- -#ifdef __WXDEBUG__ - #if wxUSE_THREADS -# define DEBUG_MAIN_THREAD if (wxThread::IsMain() && g_mainThreadLocked) printf("gui reentrance"); +# define DEBUG_MAIN_THREAD \ + wxASSERT_MSG( !g_mainThreadLocked || !wxThread::IsMain(), \ + "GUI reentrancy detected" ); #else # define DEBUG_MAIN_THREAD #endif -#else -#define DEBUG_MAIN_THREAD -#endif // Debug // the trace mask used for the focus debugging messages -#define TRACE_FOCUS _T("focus") +#define TRACE_FOCUS wxT("focus") //----------------------------------------------------------------------------- // missing gdk functions @@ -290,7 +291,7 @@ wxWindow *wxFindFocusedChild(wxWindowGTK *win) { wxWindow *winFocus = wxWindowGTK::FindFocus(); if ( !winFocus ) - return (wxWindow *)NULL; + return NULL; if ( winFocus == win ) return (wxWindow *)win; @@ -304,7 +305,7 @@ wxWindow *wxFindFocusedChild(wxWindowGTK *win) return child; } - return (wxWindow *)NULL; + return NULL; } static void draw_frame( GtkWidget *widget, wxWindowGTK *win ) @@ -367,7 +368,7 @@ static void draw_frame( GtkWidget *widget, wxWindowGTK *win ) return; } - if (win->HasFlag(wxSUNKEN_BORDER)) + if (win->HasFlag(wxSUNKEN_BORDER) || win->HasFlag(wxBORDER_THEME)) { gtk_draw_shadow( widget->style, widget->window, @@ -424,7 +425,7 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU // make it extern because wxStaticText needs to disconnect this one extern "C" { -void wxgtk_window_size_request_callback(GtkWidget *widget, +void wxgtk_window_size_request_callback(GtkWidget *WXUNUSED(widget), GtkRequisition *requisition, wxWindow *win) { @@ -442,7 +443,7 @@ void wxgtk_window_size_request_callback(GtkWidget *widget, extern "C" { static -void wxgtk_combo_size_request_callback(GtkWidget *widget, +void wxgtk_combo_size_request_callback(GtkWidget *WXUNUSED(widget), GtkRequisition *requisition, wxComboBox *win) { @@ -474,7 +475,7 @@ void wxgtk_combo_size_request_callback(GtkWidget *widget, //----------------------------------------------------------------------------- extern "C" { -static int gtk_window_expose_callback( GtkWidget *widget, +static int gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win ) { @@ -607,7 +608,7 @@ static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle child_area; if (gtk_widget_intersect (child->widget, rect, &child_area)) { - gtk_widget_draw (child->widget, &child_area /* (GdkRectangle*) NULL*/ ); + gtk_widget_draw (child->widget, &child_area /* NULL*/ ); } } #endif @@ -619,7 +620,7 @@ static void gtk_window_draw_callback( GtkWidget *widget, //----------------------------------------------------------------------------- // set WXTRACE to this to see the key event codes on the console -#define TRACE_KEYS _T("keyevent") +#define TRACE_KEYS wxT("keyevent") // translates an X key symbol to WXK_XXX value // @@ -919,11 +920,13 @@ static void wxFillOtherKeyEventFields(wxKeyEvent& event, event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK) != 0; event.m_altDown = (gdk_event->state & GDK_MOD1_MASK) != 0; event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK) != 0; - event.m_scanCode = gdk_event->keyval; event.m_rawCode = (wxUint32) gdk_event->keyval; event.m_rawFlags = 0; #if wxUSE_UNICODE - event.m_uniChar = gdk_keyval_to_unicode(gdk_event->keyval); +#if 0 + // this is not gtk1.x + event.m_uniChar = gdk_keyval_to_unicode(gdk_event->keyval); +#endif #endif wxGetMousePosition( &x, &y ); win->ScreenToClient( &x, &y ); @@ -951,9 +954,9 @@ wxTranslateGTKKeyEventToWx(wxKeyEvent& event, KeySym keysym = gdk_event->keyval; - wxLogTrace(TRACE_KEYS, _T("Key %s event: keysym = %ld"), - event.GetEventType() == wxEVT_KEY_UP ? _T("release") - : _T("press"), + wxLogTrace(TRACE_KEYS, wxT("Key %s event: keysym = %ld"), + event.GetEventType() == wxEVT_KEY_UP ? wxT("release") + : wxT("press"), keysym); long key_code = wxTranslateKeySymToWXKey(keysym, false /* !isChar */); @@ -982,7 +985,7 @@ wxTranslateGTKKeyEventToWx(wxKeyEvent& event, Display *dpy = (Display *)wxGetDisplay(); KeyCode keycode = XKeysymToKeycode(dpy, keysym); - wxLogTrace(TRACE_KEYS, _T("\t-> keycode %d"), keycode); + wxLogTrace(TRACE_KEYS, wxT("\t-> keycode %d"), keycode); KeySym keysymNormalized = XKeycodeToKeysym(dpy, keycode, 0); @@ -1021,7 +1024,7 @@ wxTranslateGTKKeyEventToWx(wxKeyEvent& event, } } - wxLogTrace(TRACE_KEYS, _T("\t-> wxKeyCode %ld"), key_code); + wxLogTrace(TRACE_KEYS, wxT("\t-> wxKeyCode %ld"), key_code); // sending unknown key events doesn't really make sense if ( !key_code ) @@ -1056,10 +1059,10 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, bool ret = false; bool return_after_IM = false; - if( wxTranslateGTKKeyEventToWx(event, win, gdk_event) == false ) + if ( wxTranslateGTKKeyEventToWx(event, win, gdk_event) ) { // Emit KEY_DOWN event - ret = win->GetEventHandler()->ProcessEvent( event ); + ret = win->HandleWindowEvent( event ); } else { @@ -1115,12 +1118,12 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, if (parent) { event.SetEventType( wxEVT_CHAR_HOOK ); - ret = parent->GetEventHandler()->ProcessEvent( event ); + ret = parent->HandleWindowEvent( event ); } if (!ret) { event.SetEventType(wxEVT_CHAR); - win->GetEventHandler()->ProcessEvent( event ); + win->HandleWindowEvent( event ); } } return true; @@ -1138,8 +1141,8 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, int command = ancestor->GetAcceleratorTable()->GetCommand( event ); if (command != -1) { - wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command ); - ret = ancestor->GetEventHandler()->ProcessEvent( command_event ); + wxCommandEvent command_event( wxEVT_MENU, command ); + ret = ancestor->HandleWindowEvent( command_event ); break; } if (ancestor->IsTopLevel()) @@ -1173,7 +1176,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, if ( key_code ) { - wxLogTrace(TRACE_KEYS, _T("Char event: %ld"), key_code); + wxLogTrace(TRACE_KEYS, wxT("Char event: %ld"), key_code); event.m_keyCode = key_code; @@ -1184,13 +1187,13 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, if (parent) { event.SetEventType( wxEVT_CHAR_HOOK ); - ret = parent->GetEventHandler()->ProcessEvent( event ); + ret = parent->HandleWindowEvent( event ); } if (!ret) { event.SetEventType(wxEVT_CHAR); - ret = win->GetEventHandler()->ProcessEvent( event ); + ret = win->HandleWindowEvent( event ); } } } @@ -1220,7 +1223,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, // CTRL-TAB changes the (parent) window, i.e. switch notebook page new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) ); new_event.SetCurrentFocus( win ); - ret = win->GetParent()->GetEventHandler()->ProcessEvent( new_event ); + ret = win->GetParent()->HandleWindowEvent( new_event ); } // generate wxID_CANCEL if has been pressed (typically in dialogs) @@ -1254,9 +1257,9 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, if ( btnCancel ) { - wxCommandEvent eventClick(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + wxCommandEvent eventClick(wxEVT_BUTTON, wxID_CANCEL); eventClick.SetEventObject(btnCancel); - ret = btnCancel->GetEventHandler()->ProcessEvent(eventClick); + ret = btnCancel->HandleWindowEvent(eventClick); } } @@ -1297,7 +1300,7 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, return FALSE; } - if ( !win->GetEventHandler()->ProcessEvent( event ) ) + if ( !win->HandleWindowEvent( event ) ) return FALSE; gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_release_event" ); @@ -1329,6 +1332,7 @@ template void InitMouseEvent(wxWindowGTK *win, if (event.GetEventType() == wxEVT_MOUSEWHEEL) { event.m_linesPerAction = 3; + event.m_columnsPerAction = 3; event.m_wheelDelta = 120; if (((GdkEventButton*)gdk_event)->button == 4) event.m_wheelRotation = 120; @@ -1426,7 +1430,7 @@ wxWindowGTK *FindWindowForMouseEvent(wxWindowGTK *win, wxCoord& x, wxCoord& y) } else { - if ((child->m_wxwindow == (GtkWidget*) NULL) && + if ((child->m_wxwindow == NULL) && (child->m_x <= xx) && (child->m_y <= yy) && (child->m_x+child->m_width >= xx) && @@ -1469,7 +1473,9 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; - if (win->m_wxwindow && (g_focusWindow != win) && win->AcceptsFocus()) + g_lastButtonNumber = gdk_event->button; + + if (win->m_wxwindow && (g_focusWindow != win) && win->IsFocusable()) { gtk_widget_grab_focus( win->m_wxwindow ); /* @@ -1576,6 +1582,8 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, return FALSE; } + g_lastMouseEvent = (GdkEvent*) gdk_event; + wxMouseEvent event( event_type ); InitMouseEvent( win, event, gdk_event ); @@ -1605,11 +1613,13 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, } } - if (win->GetEventHandler()->ProcessEvent( event )) + if (win->HandleWindowEvent( event )) { gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" ); + g_lastMouseEvent = NULL; return TRUE; } + g_lastMouseEvent = NULL; if (event_type == wxEVT_RIGHT_DOWN) { @@ -1625,7 +1635,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, win->GetId(), win->ClientToScreen(event.GetPosition())); evtCtx.SetEventObject(win); - return win->GetEventHandler()->ProcessEvent(evtCtx); + return win->HandleWindowEvent(evtCtx); } return FALSE; @@ -1652,6 +1662,8 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; + g_lastButtonNumber = 0; + wxEventType event_type = wxEVT_NULL; switch (gdk_event->button) @@ -1669,10 +1681,12 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, break; default: - // unknwon button, don't process + // unknown button, don't process return FALSE; } + g_lastMouseEvent = (GdkEvent*) gdk_event; + wxMouseEvent event( event_type ); InitMouseEvent( win, event, gdk_event ); @@ -1684,7 +1698,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, if ( !g_captureWindow ) win = FindWindowForMouseEvent(win, event.m_x, event.m_y); - if (win->GetEventHandler()->ProcessEvent( event )) + if (win->HandleWindowEvent( event )) { gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_release_event" ); return TRUE; @@ -1724,6 +1738,8 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, gdk_event->y = y; } + g_lastMouseEvent = (GdkEvent*) gdk_event; + /* printf( "OnMotion from " ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) @@ -1752,7 +1768,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, : wxEVT_LEAVE_WINDOW); InitMouseEvent(win, eventM, gdk_event); eventM.SetEventObject(win); - win->GetEventHandler()->ProcessEvent(eventM); + win->HandleWindowEvent(eventM); } } else // no capture @@ -1760,13 +1776,15 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, win = FindWindowForMouseEvent(win, event.m_x, event.m_y); } - if (win->GetEventHandler()->ProcessEvent( event )) + bool ret = win->HandleWindowEvent( event ); + g_lastMouseEvent = NULL; + + if ( ret ) { gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "motion_notify_event" ); - return TRUE; } - return FALSE; + return ret ? TRUE : FALSE; } } @@ -1781,12 +1799,12 @@ static bool DoSendFocusEvents(wxWindow *win) // Notify the parent keeping track of focus for the kbd navigation // purposes that we got it. wxChildFocusEvent eventChildFocus(win); - (void)win->GetEventHandler()->ProcessEvent(eventChildFocus); + (void)win->HandleWindowEvent(eventChildFocus); wxFocusEvent eventFocus(wxEVT_SET_FOCUS, win->GetId()); eventFocus.SetEventObject(win); - return win->GetEventHandler()->ProcessEvent(eventFocus); + return win->HandleWindowEvent(eventFocus); } extern "C" { @@ -1803,7 +1821,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, g_focusWindow = win; wxLogTrace(TRACE_FOCUS, - _T("%s: focus in"), win->GetName().c_str()); + wxT("%s: focus in"), win->GetName().c_str()); #ifdef HAVE_XIM if (win->m_ic) @@ -1841,7 +1859,9 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, //----------------------------------------------------------------------------- extern "C" { -static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEventFocus *gdk_event, wxWindowGTK *win ) +static gint gtk_window_focus_out_callback( GtkWidget *WXUNUSED(widget), + GdkEventFocus *WXUNUSED(gdk_event), + wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1849,14 +1869,14 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEventFocus *gdk wxapp_install_idle_handler(); wxLogTrace( TRACE_FOCUS, - _T("%s: focus out"), win->GetName().c_str() ); + wxT("%s: focus out"), win->GetName().c_str() ); wxWindowGTK *winFocus = wxFindFocusedChild(win); if ( winFocus ) win = winFocus; - g_focusWindow = (wxWindowGTK *)NULL; + g_focusWindow = NULL; #ifdef HAVE_XIM if (win->m_ic) @@ -1885,7 +1905,7 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEventFocus *gdk // process it too as otherwise bad things happen, especially in GTK2 // where the text control simply aborts the program if it doesn't get // the matching focus out event - (void)win->GetEventHandler()->ProcessEvent( event ); + (void)win->HandleWindowEvent( event ); } return FALSE; @@ -1927,7 +1947,7 @@ gint gtk_window_enter_callback( GtkWidget *widget, event.m_x = x + pt.x; event.m_y = y + pt.y; - if (win->GetEventHandler()->ProcessEvent( event )) + if (win->HandleWindowEvent( event )) { gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" ); return TRUE; @@ -1979,7 +1999,7 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ event.m_x = x + pt.x; event.m_y = y + pt.y; - if (win->GetEventHandler()->ProcessEvent( event )) + if (win->HandleWindowEvent( event )) { gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" ); return TRUE; @@ -2019,7 +2039,7 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxScrollWinEvent event( command, value, wxVERTICAL ); event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); + win->HandleWindowEvent( event ); } } @@ -2052,7 +2072,7 @@ static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxScrollWinEvent event( command, value, wxHORIZONTAL ); event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); + win->HandleWindowEvent( event ); } } @@ -2118,7 +2138,7 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget, wxScrollWinEvent event( command, value, dir ); event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); + win->HandleWindowEvent( event ); } win->m_isScrolling = false; @@ -2147,7 +2167,7 @@ wxWindow *wxWindowBase::DoFindFocus() extern "C" { static gint -gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win ) +gtk_window_realized_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) { DEBUG_MAIN_THREAD @@ -2156,7 +2176,7 @@ gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win ) wxWindowCreateEvent event( win ); event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); + win->HandleWindowEvent( event ); return FALSE; } @@ -2190,7 +2210,7 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), { wxSizeEvent event( win->GetSize(), win->GetId() ); event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); + win->HandleWindowEvent( event ); } } } @@ -2207,7 +2227,7 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), extern "C" { static void gtk_wxwindow_size_callback( GtkWidget* WXUNUSED_UNLESS_XIM(widget), - GtkAllocation* WXUNUSED_UNLESS_XIM(alloc), + GtkAllocation* WXUNUSED(alloc), wxWindowGTK* WXUNUSED_UNLESS_XIM(win) ) { if (g_isIdle) @@ -2394,16 +2414,14 @@ wxMouseState wxGetMouseState() // method #ifdef __WXUNIVERSAL__ IMPLEMENT_ABSTRACT_CLASS(wxWindowGTK, wxWindowBase) -#else // __WXGTK__ - IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) -#endif // __WXUNIVERSAL__/__WXGTK__ +#endif // __WXUNIVERSAL__ void wxWindowGTK::Init() { // GTK specific - m_widget = (GtkWidget *) NULL; - m_wxwindow = (GtkWidget *) NULL; - m_focusWidget = (GtkWidget *) NULL; + m_widget = NULL; + m_wxwindow = NULL; + m_focusWidget = NULL; // position/size m_x = 0; @@ -2414,7 +2432,6 @@ void wxWindowGTK::Init() m_sizeSet = false; m_hasVMT = false; m_needParent = true; - m_isBeingDeleted = false; m_noExpose = false; m_nativeSizeEvent = false; @@ -2422,8 +2439,8 @@ void wxWindowGTK::Init() m_hasScrolling = false; m_isScrolling = false; - m_hAdjust = (GtkAdjustment*) NULL; - m_vAdjust = (GtkAdjustment*) NULL; + m_hAdjust = NULL; + m_vAdjust = NULL; m_oldHorizontalPos = m_oldVerticalPos = 0.0; m_oldClientWidth = @@ -2443,8 +2460,8 @@ void wxWindowGTK::Init() m_cursor = *wxSTANDARD_CURSOR; #ifdef HAVE_XIM - m_ic = (GdkIC*) NULL; - m_icattr = (GdkICAttr*) NULL; + m_ic = NULL; + m_icattr = NULL; #endif } @@ -2472,6 +2489,11 @@ bool wxWindowGTK::Create( wxWindow *parent, long style, const wxString &name ) { + // Get default border + wxBorder border = GetBorder(style); + style &= ~wxBORDER_MASK; + style |= border; + if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { @@ -2481,7 +2503,7 @@ bool wxWindowGTK::Create( wxWindow *parent, m_insertCallback = wxInsertChildInWindow; - m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); + m_widget = gtk_scrolled_window_new( NULL, NULL ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget); @@ -2503,7 +2525,7 @@ bool wxWindowGTK::Create( wxWindow *parent, { gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_OUT ); } - else if (HasFlag(wxSUNKEN_BORDER)) + else if (HasFlag(wxSUNKEN_BORDER) || HasFlag(wxBORDER_THEME)) { gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_IN ); } @@ -2585,7 +2607,6 @@ wxWindowGTK::~wxWindowGTK() if ( g_delayedFocus == this ) g_delayedFocus = NULL; - m_isBeingDeleted = true; m_hasVMT = false; // destroy children before destroying this window itself @@ -2614,13 +2635,13 @@ wxWindowGTK::~wxWindowGTK() if (m_wxwindow) { gtk_widget_destroy( m_wxwindow ); - m_wxwindow = (GtkWidget*) NULL; + m_wxwindow = NULL; } if (m_widget) { gtk_widget_destroy( m_widget ); - m_widget = (GtkWidget*) NULL; + m_widget = NULL; } } @@ -2889,7 +2910,7 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags { wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); + HandleWindowEvent( event ); } m_resizing = false; @@ -2909,9 +2930,9 @@ void wxWindowGTK::OnInternalIdle() GtkUpdate(); wxCursor cursor = m_cursor; - if (g_globalCursor.Ok()) cursor = g_globalCursor; + if (g_globalCursor.IsOk()) cursor = g_globalCursor; - if (cursor.Ok()) + if (cursor.IsOk()) { /* I now set the cursor anew in every OnInternalIdle call as setting the cursor in a parent window also effects the @@ -2924,7 +2945,7 @@ void wxWindowGTK::OnInternalIdle() if (window) gdk_window_set_cursor( window, cursor.GetCursor() ); - if (!g_globalCursor.Ok()) + if (!g_globalCursor.IsOk()) cursor = *wxSTANDARD_CURSOR; window = m_widget->window; @@ -2940,8 +2961,7 @@ void wxWindowGTK::OnInternalIdle() } } - if (wxUpdateUIEvent::CanUpdate(this)) - UpdateWindowUI(wxUPDATE_UI_FROMIDLE); + wxWindowBase::OnInternalIdle(); } void wxWindowGTK::DoGetSize( int *width, int *height ) const @@ -2966,7 +2986,7 @@ void wxWindowGTK::DoSetClientSize( int width, int height ) int dh = 0; #ifndef __WXUNIVERSAL__ - if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) + if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER) || HasFlag(wxBORDER_THEME)) { /* when using GTK 1.2 we set the shadow border size to 2 */ dw += 2 * 2; @@ -3030,7 +3050,7 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const int dh = 0; #ifndef __WXUNIVERSAL__ - if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) + if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER) || HasFlag(wxBORDER_THEME)) { /* when using GTK 1.2 we set the shadow border size to 2 */ dw += 2 * 2; @@ -3110,7 +3130,7 @@ void wxWindowGTK::DoClientToScreen( int *x, int *y ) const if (!m_widget->window) return; - GdkWindow *source = (GdkWindow *) NULL; + GdkWindow *source = NULL; if (m_wxwindow) source = GTK_PIZZA(m_wxwindow)->bin_window; else @@ -3139,7 +3159,7 @@ void wxWindowGTK::DoScreenToClient( int *x, int *y ) const if (!m_widget->window) return; - GdkWindow *source = (GdkWindow *) NULL; + GdkWindow *source = NULL; if (m_wxwindow) source = GTK_PIZZA(m_wxwindow)->bin_window; else @@ -3180,45 +3200,18 @@ bool wxWindowGTK::Show( bool show ) wxShowEvent eventShow(GetId(), show); eventShow.SetEventObject(this); - GetEventHandler()->ProcessEvent(eventShow); + HandleWindowEvent(eventShow); return true; } -static void wxWindowNotifyEnable(wxWindowGTK* win, bool enable) +void wxWindowGTK::DoEnable( bool enable ) { - win->OnParentEnable(enable); - - // Recurse, so that children have the opportunity to Do The Right Thing - // and reset colours that have been messed up by a parent's (really ancestor's) - // Enable call - for ( wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst(); - node; - node = node->GetNext() ) - { - wxWindow *child = node->GetData(); - if (!child->IsKindOf(CLASSINFO(wxDialog)) && !child->IsKindOf(CLASSINFO(wxFrame))) - wxWindowNotifyEnable(child, enable); - } -} - -bool wxWindowGTK::Enable( bool enable ) -{ - wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") ); - - if (!wxWindowBase::Enable(enable)) - { - // nothing to do - return false; - } + wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); gtk_widget_set_sensitive( m_widget, enable ); if ( m_wxwindow ) gtk_widget_set_sensitive( m_wxwindow, enable ); - - wxWindowNotifyEnable(this, enable); - - return true; } int wxWindowGTK::GetCharHeight() const @@ -3226,7 +3219,7 @@ int wxWindowGTK::GetCharHeight() const wxCHECK_MSG( (m_widget != NULL), 12, wxT("invalid window") ); wxFont font = GetFont(); - wxCHECK_MSG( font.Ok(), 12, wxT("invalid font") ); + wxCHECK_MSG( font.IsOk(), 12, wxT("invalid font") ); GdkFont *gfont = font.GetInternalFont( 1.0 ); @@ -3238,23 +3231,23 @@ int wxWindowGTK::GetCharWidth() const wxCHECK_MSG( (m_widget != NULL), 8, wxT("invalid window") ); wxFont font = GetFont(); - wxCHECK_MSG( font.Ok(), 8, wxT("invalid font") ); + wxCHECK_MSG( font.IsOk(), 8, wxT("invalid font") ); GdkFont *gfont = font.GetInternalFont( 1.0 ); return gdk_string_width( gfont, "g" ); } -void wxWindowGTK::GetTextExtent( const wxString& string, - int *x, - int *y, - int *descent, - int *externalLeading, - const wxFont *theFont ) const +void wxWindowGTK::DoGetTextExtent(const wxString& string, + int *x, + int *y, + int *descent, + int *externalLeading, + const wxFont *theFont) const { wxFont fontToUse = theFont ? *theFont : GetFont(); - wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") ); + wxCHECK_RET( fontToUse.IsOk(), wxT("invalid font") ); if (string.empty()) { @@ -3297,7 +3290,7 @@ void wxWindowGTK::SetFocus() // it should be focused and will do it later, during the idle // time, as soon as we can wxLogTrace(TRACE_FOCUS, - _T("Delaying setting focus to %s(%s)"), + wxT("Delaying setting focus to %s(%s)"), GetClassInfo()->GetClassName(), GetLabel().c_str()); g_delayedFocus = this; @@ -3305,7 +3298,7 @@ void wxWindowGTK::SetFocus() else { wxLogTrace(TRACE_FOCUS, - _T("Setting focus to %s(%s)"), + wxT("Setting focus to %s(%s)"), GetClassInfo()->GetClassName(), GetLabel().c_str()); gtk_widget_grab_focus (m_widget); @@ -3319,7 +3312,7 @@ void wxWindowGTK::SetFocus() else { wxLogTrace(TRACE_FOCUS, - _T("Can't set focus to %s(%s)"), + wxT("Can't set focus to %s(%s)"), GetClassInfo()->GetClassName(), GetLabel().c_str()); } } @@ -3413,16 +3406,14 @@ bool wxWindowGTK::SetCursor( const wxCursor &cursor ) { wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") ); - if (cursor == m_cursor) + if ( cursor.IsSameAs(m_cursor) ) return false; if (g_isIdle) wxapp_install_idle_handler(); - if (cursor == wxNullCursor) - return wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ); - else - return wxWindowBase::SetCursor( cursor ); + return wxWindowBase::SetCursor( cursor.IsOk() ? cursor + : *wxSTANDARD_CURSOR ); } void wxWindowGTK::WarpPointer( int x, int y ) @@ -3432,7 +3423,7 @@ void wxWindowGTK::WarpPointer( int x, int y ) // We provide this function ourselves as it is // missing in GDK (top of this file). - GdkWindow *window = (GdkWindow*) NULL; + GdkWindow *window = NULL; if (m_wxwindow) window = GTK_PIZZA(m_wxwindow)->bin_window; else @@ -3506,7 +3497,7 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect ) } else { - gtk_widget_draw( m_widget, (GdkRectangle*) NULL ); + gtk_widget_draw( m_widget, NULL ); } } } @@ -3584,20 +3575,16 @@ void wxWindowGTK::GtkSendPaintEvents() } } } - else - - // if (!m_clearRegion.IsEmpty()) // Always send an erase event under GTK 1.2 + else // Always send an erase event under GTK 1.2 { wxWindowDC dc( (wxWindow*)this ); - if (m_clearRegion.IsEmpty()) - dc.SetClippingRegion( m_updateRegion ); - else - dc.SetClippingRegion( m_clearRegion ); + dc.SetDeviceClippingRegion( m_clearRegion.IsEmpty() ? m_updateRegion + : m_clearRegion ); wxEraseEvent erase_event( GetId(), &dc ); erase_event.SetEventObject( this ); - if (!GetEventHandler()->ProcessEvent(erase_event) && GetBackgroundStyle() != wxBG_STYLE_CUSTOM) + if (!HandleWindowEvent(erase_event) && GetBackgroundStyle() != wxBG_STYLE_CUSTOM) { if (!g_eraseGC) { @@ -3619,11 +3606,11 @@ void wxWindowGTK::GtkSendPaintEvents() wxNcPaintEvent nc_paint_event( GetId() ); nc_paint_event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( nc_paint_event ); + HandleWindowEvent( nc_paint_event ); wxPaintEvent paint_event( GetId() ); paint_event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( paint_event ); + HandleWindowEvent( paint_event ); m_clipPaintRegion = false; @@ -3700,7 +3687,7 @@ void wxWindowGTK::DoSetToolTip( wxToolTip *tip ) void wxWindowGTK::ApplyToolTip( GtkTooltips *tips, const wxChar *tip ) { wxString tmp( tip ); - gtk_tooltips_set_tip( tips, GetConnectWidget(), wxGTK_CONV(tmp), (gchar*) NULL ); + gtk_tooltips_set_tip( tips, GetConnectWidget(), wxGTK_CONV(tmp), NULL ); } #endif // wxUSE_TOOLTIPS @@ -3711,7 +3698,7 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) if (!wxWindowBase::SetBackgroundColour(colour)) return false; - if (colour.Ok()) + if (colour.IsOk()) { // We need the pixel value e.g. for background clearing. m_backgroundColour.CalcPixel(gtk_widget_get_colormap(m_widget)); @@ -3734,7 +3721,7 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) return false; } - if (colour.Ok()) + if (colour.IsOk()) { // We need the pixel value e.g. for background clearing. m_foregroundColour.CalcPixel(gtk_widget_get_colormap(m_widget)); @@ -3751,21 +3738,21 @@ GtkRcStyle *wxWindowGTK::CreateWidgetStyle(bool forceStyle) { // do we need to apply any changes at all? if ( !forceStyle && - !m_font.Ok() && - !m_foregroundColour.Ok() && !m_backgroundColour.Ok() ) + !m_font.IsOk() && + !m_foregroundColour.IsOk() && !m_backgroundColour.IsOk() ) { return NULL; } GtkRcStyle *style = gtk_rc_style_new(); - if ( m_font.Ok() ) + if ( m_font.IsOk() ) { wxString xfontname = m_font.GetNativeFontInfo()->GetXFontName(); style->fontset_name = g_strdup(xfontname.c_str()); } - if ( m_foregroundColour.Ok() ) + if ( m_foregroundColour.IsOk() ) { GdkColor *fg = m_foregroundColour.GetColor(); @@ -3779,7 +3766,7 @@ GtkRcStyle *wxWindowGTK::CreateWidgetStyle(bool forceStyle) style->color_flags[GTK_STATE_ACTIVE] = GTK_RC_FG; } - if ( m_backgroundColour.Ok() ) + if ( m_backgroundColour.IsOk() ) { GdkColor *bg = m_backgroundColour.GetColor(); @@ -3834,7 +3821,7 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style) if (style == wxBG_STYLE_CUSTOM) { - GdkWindow *window = (GdkWindow*) NULL; + GdkWindow *window = NULL; if (m_wxwindow) window = GTK_PIZZA(m_wxwindow)->bin_window; else @@ -3918,16 +3905,16 @@ void wxWindowGTK::DoCaptureMouse() { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - GdkWindow *window = (GdkWindow*) NULL; + GdkWindow *window = NULL; if (m_wxwindow) window = GTK_PIZZA(m_wxwindow)->bin_window; else window = GetConnectWidget()->window; - wxCHECK_RET( window, _T("CaptureMouse() failed") ); + wxCHECK_RET( window, wxT("CaptureMouse() failed") ); const wxCursor* cursor = &m_cursor; - if (!cursor->Ok()) + if (!cursor->IsOk()) cursor = wxSTANDARD_CURSOR; gdk_pointer_grab( window, FALSE, @@ -3936,7 +3923,7 @@ void wxWindowGTK::DoCaptureMouse() GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_POINTER_MOTION_MASK), - (GdkWindow *) NULL, + NULL, cursor->GetCursor(), (guint32)GDK_CURRENT_TIME ); g_captureWindow = this; @@ -3949,9 +3936,9 @@ void wxWindowGTK::DoReleaseMouse() wxCHECK_RET( g_captureWindow, wxT("can't release mouse - not captured") ); - g_captureWindow = (wxWindowGTK*) NULL; + g_captureWindow = NULL; - GdkWindow *window = (GdkWindow*) NULL; + GdkWindow *window = NULL; if (m_wxwindow) window = GTK_PIZZA(m_wxwindow)->bin_window; else @@ -4230,3 +4217,11 @@ void wxWinModule::OnExit() if (g_eraseGC) gdk_gc_unref( g_eraseGC ); } + +GdkWindow* wxWindowGTK::GTKGetDrawingWindow() const +{ + GdkWindow* window = NULL; + if (m_wxwindow) + window = GTK_PIZZA(m_wxwindow)->bin_window; + return window; +}