#include "wx/fontutil.h"
-#ifdef __WXDEBUG__
+#if wxDEBUG_LEVEL
#include "wx/thread.h"
#endif
// 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)
// global variables because GTK+ DnD want to have the
// mouse event that caused it
-GdkEvent *g_lastMouseEvent = (GdkEvent*) NULL;
+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
{
wxWindow *winFocus = wxWindowGTK::FindFocus();
if ( !winFocus )
- return (wxWindow *)NULL;
+ return NULL;
if ( winFocus == win )
return (wxWindow *)win;
return child;
}
- return (wxWindow *)NULL;
+ return NULL;
}
static void draw_frame( GtkWidget *widget, wxWindowGTK *win )
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
//-----------------------------------------------------------------------------
// 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
//
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
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 */);
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);
}
}
- 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 )
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
if (command != -1)
{
- wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
+ wxCommandEvent command_event( wxEVT_MENU, command );
ret = ancestor->HandleWindowEvent( command_event );
break;
}
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;
if ( btnCancel )
{
- wxCommandEvent eventClick(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
+ wxCommandEvent eventClick(wxEVT_BUTTON, wxID_CANCEL);
eventClick.SetEventObject(btnCancel);
ret = btnCancel->HandleWindowEvent(eventClick);
}
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;
}
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) &&
break;
default:
- // unknwon button, don't process
+ // unknown button, don't process
return FALSE;
}
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)
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)
// 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;
m_sizeSet = false;
m_hasVMT = false;
m_needParent = true;
- m_isBeingDeleted = false;
m_noExpose = false;
m_nativeSizeEvent = false;
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 =
m_cursor = *wxSTANDARD_CURSOR;
#ifdef HAVE_XIM
- m_ic = (GdkIC*) NULL;
- m_icattr = (GdkICAttr*) NULL;
+ m_ic = NULL;
+ m_icattr = NULL;
#endif
}
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);
if ( g_delayedFocus == this )
g_delayedFocus = NULL;
- m_isBeingDeleted = true;
m_hasVMT = false;
// destroy children before destroying this window itself
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;
}
}
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
if (window)
gdk_window_set_cursor( window, cursor.GetCursor() );
- if (!g_globalCursor.Ok())
+ if (!g_globalCursor.IsOk())
cursor = *wxSTANDARD_CURSOR;
window = m_widget->window;
}
}
- if (wxUpdateUIEvent::CanUpdate(this) && IsShownOnScreen())
- UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
+ wxWindowBase::OnInternalIdle();
}
void wxWindowGTK::DoGetSize( int *width, int *height ) const
if (!m_widget->window) return;
- GdkWindow *source = (GdkWindow *) NULL;
+ GdkWindow *source = NULL;
if (m_wxwindow)
source = GTK_PIZZA(m_wxwindow)->bin_window;
else
if (!m_widget->window) return;
- GdkWindow *source = (GdkWindow *) NULL;
+ GdkWindow *source = NULL;
if (m_wxwindow)
source = GTK_PIZZA(m_wxwindow)->bin_window;
else
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 );
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())
{
// 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;
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);
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());
}
}
// 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
}
else
{
- gtk_widget_draw( m_widget, (GdkRectangle*) NULL );
+ gtk_widget_draw( m_widget, NULL );
}
}
}
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
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));
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));
{
// 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();
style->color_flags[GTK_STATE_ACTIVE] = GTK_RC_FG;
}
- if ( m_backgroundColour.Ok() )
+ if ( m_backgroundColour.IsOk() )
{
GdkColor *bg = m_backgroundColour.GetColor();
if (style == wxBG_STYLE_CUSTOM)
{
- GdkWindow *window = (GdkWindow*) NULL;
+ GdkWindow *window = NULL;
if (m_wxwindow)
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
{
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,
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;
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