// mouse capture state: the window which has it and if the mouse is currently
// inside it
static wxWindowGTK *g_captureWindow = (wxWindowGTK*) NULL;
-static bool g_captureWindowHasMouse = FALSE;
+static bool g_captureWindowHasMouse = false;
wxWindowGTK *g_focusWindow = (wxWindowGTK*) NULL;
// hack: we need something to pass to gtk_menu_popup, so we store the time of
// the last click here
-static guint32 gs_timeLastClick = 0;
+static guint32 gs_timeLastClick = 0;
extern bool g_mainThreadLocked;
{
// This callback is actually hooked into the text entry
// of the combo box, not the GtkHBox.
-
+
int w, h;
win->GetSize( &w, &h );
if (w < 2)
h = 2;
GtkCombo *gcombo = GTK_COMBO(win->m_widget);
-
+
GtkRequisition entry_req;
entry_req.width = 2;
entry_req.height = 2;
(* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(gcombo->button) )->size_request )
(gcombo->button, &entry_req );
-
+
requisition->width = w - entry_req.width;
requisition->height = entry_req.height;
}
(int)gdk_event->area.width,
(int)gdk_event->area.height );
}
-
+
gtk_paint_box
(
win->m_wxwindow->style,
: _T("press"),
keysym);
- long key_code = wxTranslateKeySymToWXKey(keysym, FALSE /* !isChar */);
+ long key_code = wxTranslateKeySymToWXKey(keysym, false /* !isChar */);
if ( !key_code )
{
// sending unknown key events doesn't really make sense
if ( !key_code )
- return FALSE;
+ return false;
// now fill all the other fields
wxFillOtherKeyEventFields(event, win, gdk_event);
-
+
event.m_keyCode = key_code;
- return TRUE;
+ return true;
}
// Emit KEY_DOWN event
ret = win->GetEventHandler()->ProcessEvent( event );
}
- else
+ else
{
// Return after IM processing as we cannot do
// anything with it anyhow.
// 2005.01.26 modified by Hong Jen Yee (hzysoft@sina.com.tw):
// When we get a key_press event here, it could be originate
// from the current widget or its child widgets. However, only the widget
- // with the INPUT FOCUS can generate the INITIAL key_press event. That is,
+ // with the INPUT FOCUS can generate the INITIAL key_press event. That is,
// if the CURRENT widget doesn't have the FOCUS at all, this event definitely
// originated from its child widgets and shouldn't be passed to IM context.
// In fact, what a GTK+ IM should do is filtering keyEvents and convert them
// into text input ONLY WHEN THE WIDGET HAS INPUT FOCUS. Besides, when current
- // widgets has both IM context and input focus, the event should be filtered
+ // widgets has both IM context and input focus, the event should be filtered
// by gtk_im_context_filter_keypress().
// Then, we should, according to GTK+ 2.0 API doc, return whatever it returns.
if ((!ret) && (win->m_imData != NULL) && ( wxWindow::FindFocus() == win ))
{
// We should let GTK+ IM filter key event first. According to GTK+ 2.0 API
// docs, if IM filter returns true, no further processing should be done.
- // we should send the key_down event anyway.
+ // we should send the key_down event anyway.
bool intercepted_by_IM = gtk_im_context_filter_keypress(win->m_imData->context, gdk_event);
win->m_imData->lastKeyEvent = NULL;
if (intercepted_by_IM)
if (return_after_IM)
return false;
-#ifndef __WXGTK20__
+#ifndef __WXGTK20__
// This is for GTK+ 1.2 only. The char event generatation for GTK+ 2.0 is done
// in the "commit" handler.
-
+
// 2005.02.02 modified by Hong Jen Yee (hzysoft@sina.com.tw).
- // In GTK+ 1.2, strings sent by IMs are also regarded as key_press events whose
- // keyCodes cannot be recognized by wxWidgets. These MBCS strings, however, are
- // composed of more than one character, which means gdk_event->length will always
+ // In GTK+ 1.2, strings sent by IMs are also regarded as key_press events whose
+ // keyCodes cannot be recognized by wxWidgets. These MBCS strings, however, are
+ // composed of more than one character, which means gdk_event->length will always
// greater than one. When gtk_event->length == 1, this may be an ASCII character
- // and can be translated by wx. However, when MBCS characters are sent by IM,
+ // and can be translated by wx. However, when MBCS characters are sent by IM,
// gdk_event->length will >= 2. So neither should we pass it to accelerator table,
// nor should we pass it to controls. The following explanation was excerpted
// from GDK documentation.
}
return true;
}
-
+
#endif // #ifndef __WXGTK20__
#if wxUSE_ACCEL
long key_code;
KeySym keysym = gdk_event->keyval;
// Find key code for EVT_CHAR and EVT_CHAR_HOOK events
- key_code = wxTranslateKeySymToWXKey(keysym, TRUE /* isChar */);
+ key_code = wxTranslateKeySymToWXKey(keysym, true /* isChar */);
if ( !key_code )
{
if ( wxIsAsciiKeysym(keysym) )
event_type = wxEVT_MOUSEWHEEL;
else
return FALSE;
-
+
wxMouseEvent event( event_type );
// Can't use InitMouse macro because scroll events don't have button
event.SetTimestamp( gdk_event->time );
event.SetEventObject( win );
event.SetId( win->GetId() );
event.SetTimestamp( gdk_event->time );
-
+
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "scroll_event" );
wxWindow *win )
{
DEBUG_MAIN_THREAD
-
+
if (g_isIdle)
wxapp_install_idle_handler();
if ( !win->m_hasFocus )
{
// not yet, notify it
- win->m_hasFocus = TRUE;
-
+ win->m_hasFocus = true;
+
if ( DoSendFocusEvents(win) )
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus_in_event" );
// have focus already
if ( win->m_hasFocus )
{
- win->m_hasFocus = FALSE;
+ win->m_hasFocus = false;
wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() );
event.SetEventObject( win );
wxapp_install_idle_handler();
- g_blockEventsOnScroll = TRUE;
+ g_blockEventsOnScroll = true;
// FIXME: there is no 'slider' field in GTK+ 2.0 any more
#ifndef __WXGTK20__
//
// if (gdk_event->window != widget->slider) return FALSE;
- g_blockEventsOnScroll = FALSE;
+ g_blockEventsOnScroll = false;
if (win->m_isScrolling)
{
win->GetEventHandler()->ProcessEvent( event );
}
- win->m_isScrolling = FALSE;
+ win->m_isScrolling = false;
return FALSE;
}
if (g_isIdle)
wxapp_install_idle_handler();
-
+
#ifdef __WXGTK20__
if (win->m_imData)
{
m_width = 0;
m_height = 0;
- m_sizeSet = FALSE;
- m_hasVMT = FALSE;
- m_needParent = TRUE;
- m_isBeingDeleted = FALSE;
+ m_sizeSet = false;
+ m_hasVMT = false;
+ m_needParent = true;
+ m_isBeingDeleted = false;
- m_noExpose = FALSE;
- m_nativeSizeEvent = FALSE;
+ m_noExpose = false;
+ m_nativeSizeEvent = false;
- m_hasScrolling = FALSE;
- m_isScrolling = FALSE;
+ m_hasScrolling = false;
+ m_isScrolling = false;
m_hAdjust = (GtkAdjustment*) NULL;
m_vAdjust = (GtkAdjustment*) NULL;
m_oldClientWidth =
m_oldClientHeight = 0;
- m_resizing = FALSE;
+ m_resizing = false;
m_insertCallback = (wxInsertChildFunction) NULL;
- m_acceptsFocus = FALSE;
- m_hasFocus = FALSE;
+ m_acceptsFocus = false;
+ m_hasFocus = false;
- m_clipPaintRegion = FALSE;
+ m_clipPaintRegion = false;
m_needsStyleChange = false;
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
{
wxFAIL_MSG( wxT("wxWindowGTK creation failed") );
- return FALSE;
+ return false;
}
m_insertCallback = wxInsertChildInWindow;
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
- m_acceptsFocus = TRUE;
+ m_acceptsFocus = true;
// I _really_ don't want scrollbars in the beginning
m_vAdjust->lower = 0.0;
PostCreation();
- return TRUE;
+ return true;
}
wxWindowGTK::~wxWindowGTK()
if ( g_delayedFocus == this )
g_delayedFocus = NULL;
- m_isBeingDeleted = TRUE;
- m_hasVMT = FALSE;
+ m_isBeingDeleted = true;
+ m_hasVMT = false;
if (m_widget)
- Show( FALSE );
+ Show( false );
DestroyChildren();
bool wxWindowGTK::PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size )
{
- wxCHECK_MSG( !m_needParent || parent, FALSE, wxT("Need complete parent.") );
+ wxCHECK_MSG( !m_needParent || parent, false, wxT("Need complete parent.") );
// Use either the given size, or the default if -1 is given.
// See wxWindowBase for these functions.
m_x = (int)pos.x;
m_y = (int)pos.y;
- return TRUE;
+ return true;
}
void wxWindowGTK::PostCreation()
{
if (m_focusWidget == NULL)
m_focusWidget = m_widget;
-
+
gtk_signal_connect( GTK_OBJECT(m_focusWidget), "focus_in_event",
GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this );
if (GTK_IS_COMBO(m_widget))
{
GtkCombo *gcombo = GTK_COMBO(m_widget);
-
+
gtk_signal_connect( GTK_OBJECT(gcombo->entry), "size_request",
GTK_SIGNAL_FUNC(wxgtk_combo_size_request_callback),
(gpointer) this );
InheritAttributes();
- m_hasVMT = TRUE;
+ m_hasVMT = true;
// unless the window was created initially hidden (i.e. Hide() had been
// called before Create()), we should show it at GTK+ level as well
{
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
- m_hasVMT = FALSE;
+ m_hasVMT = false;
return wxWindowBase::Destroy();
}
*/
if (m_resizing) return; /* I don't like recursions */
- m_resizing = TRUE;
+ m_resizing = true;
int currentX, currentY;
GetPosition(¤tX, ¤tY);
GetEventHandler()->ProcessEvent( event );
}
- m_resizing = FALSE;
+ m_resizing = false;
}
void wxWindowGTK::OnInternalIdle()
bool wxWindowGTK::Show( bool show )
{
- wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") );
+ wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") );
if (!wxWindowBase::Show(show))
{
// nothing to do
- return FALSE;
+ return false;
}
if (show)
GetEventHandler()->ProcessEvent(eventShow);
- return TRUE;
+ return true;
}
static void wxWindowNotifyEnable(wxWindowGTK* win, bool enable)
bool wxWindowGTK::Enable( bool enable )
{
- wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") );
+ wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") );
if (!wxWindowBase::Enable(enable))
{
// nothing to do
- return FALSE;
+ return false;
}
gtk_widget_set_sensitive( m_widget, enable );
wxWindowNotifyEnable(this, enable);
- return TRUE;
+ return true;
}
int wxWindowGTK::GetCharHeight() const
}
void wxWindowGTK::GetTextExtent( const wxString& string,
- int *x,
- int *y,
- int *descent,
- int *externalLeading,
- const wxFont *theFont ) const
+ int *x,
+ int *y,
+ int *descent,
+ int *externalLeading,
+ const wxFont *theFont ) const
{
wxFont fontToUse = theFont ? *theFont : GetFont();
wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") );
- if (string.IsEmpty())
+ if (string.empty())
{
if (x) (*x) = 0;
if (y) (*y) = 0;
#endif
if (GTK_WIDGET_CAN_FOCUS(m_widget) && !GTK_WIDGET_HAS_FOCUS (m_widget) )
{
-
+
if (!GTK_WIDGET_REALIZED(m_widget))
{
// we can't set the focus to the widget now so we remember that
gtk_widget_grab_focus (m_widget);
}
}
- else
+ else
#ifndef __WXGTK20__
if (GTK_IS_CONTAINER(m_widget))
{
bool wxWindowGTK::Reparent( wxWindowBase *newParentBase )
{
- wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") );
+ wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") );
wxWindowGTK *oldParent = m_parent,
*newParent = (wxWindowGTK *)newParentBase;
wxASSERT( GTK_IS_WIDGET(m_widget) );
if ( !wxWindowBase::Reparent(newParent) )
- return FALSE;
+ return false;
wxASSERT( GTK_IS_WIDGET(m_widget) );
/* reverse: prevent GTK from deleting the widget arbitrarily */
gtk_widget_unref( m_widget );
- return TRUE;
+ return true;
}
void wxWindowGTK::DoAddChild(wxWindowGTK *child)
if (g_isIdle)
wxapp_install_idle_handler();
}
-
+
void wxWindowGTK::DoMoveInTabOrder(wxWindow *win, MoveKind move)
{
wxWindowBase::DoMoveInTabOrder(win, move);
if (m_children.size() > 0)
{
GList *chain = NULL;
-
+
for (wxWindowList::const_iterator i = m_children.begin();
i != m_children.end(); ++i)
{
chain = g_list_prepend(chain, (*i)->m_widget);
}
-
+
chain = g_list_reverse(chain);
-
+
gtk_container_set_focus_chain(GTK_CONTAINER(m_wxwindow), chain);
g_list_free(chain);
}
gtk_container_unset_focus_chain(GTK_CONTAINER(m_wxwindow));
}
}
-
+
m_dirtyTabOrder = false;
}
{
gdk_window_raise( m_wxwindow->window );
}
- else if (m_widget->window)
+ else if (m_widget->window)
{
gdk_window_raise( m_widget->window );
}
{
gdk_window_lower( m_wxwindow->window );
}
- else if (m_widget->window)
+ else if (m_widget->window)
{
gdk_window_lower( m_widget->window );
}
bool wxWindowGTK::SetCursor( const wxCursor &cursor )
{
- wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") );
+ wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") );
if (cursor == m_cursor)
- return FALSE;
+ return false;
if (g_isIdle)
wxapp_install_idle_handler();
}
// Clip to paint region in wxClientDC
- m_clipPaintRegion = TRUE;
+ m_clipPaintRegion = true;
// widget to draw on
GtkPizza *pizza = GTK_PIZZA (m_wxwindow);
paint_event.SetEventObject( this );
GetEventHandler()->ProcessEvent( paint_event );
- m_clipPaintRegion = FALSE;
+ m_clipPaintRegion = false;
-#ifndef __WXUNIVERSAL__
-#ifndef __WXGTK20__
+#if !defined(__WXUNIVERSAL__) && !defined(__WXGTK20__)
// The following code will result in all window-less widgets
// being redrawn because the wxWidgets class is allowed to
// paint over the window-less widgets.
gdk_event.type = GDK_EXPOSE;
gdk_event.window = pizza->bin_window;
gdk_event.count = 0;
+ gdk_event.send_event = TRUE;
wxRegionIterator upd( m_updateRegion );
while (upd)
}
}
}
-#endif
-#endif
+#endif // native GTK 1
m_updateRegion.Clear();
}
bool wxWindowGTK::SetBackgroundColour( const wxColour &colour )
{
- wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") );
+ wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") );
if (!wxWindowBase::SetBackgroundColour(colour))
return false;
bool wxWindowGTK::SetForegroundColour( const wxColour &colour )
{
- wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") );
+ wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") );
if (!wxWindowBase::SetForegroundColour(colour))
{
return false;
}
-
+
if (colour.Ok())
{
// We need the pixel value e.g. for background clearing.
return gtk_widget_get_pango_context( m_widget );
}
+// MR: Returns the same as GtkGetPangoDefaultContext until the symbol can be removed in 2.7.x
PangoContext *wxWindowGTK::GtkGetPangoX11Context()
{
- if (!m_x11Context)
- m_x11Context = pango_x_get_context( gdk_display );
-
- return m_x11Context;
+ return gtk_widget_get_pango_context( m_widget );
}
#endif
-
+
GtkRcStyle *wxWindowGTK::CreateWidgetStyle(bool forceStyle)
{
// do we need to apply any changes at all?
if ( m_font.Ok() )
{
#ifdef __WXGTK20__
- style->font_desc =
+ style->font_desc =
pango_font_description_copy( m_font.GetNativeFontInfo()->description );
#else
wxString xfontname = m_font.GetNativeFontInfo()->GetXFontName();
if ( m_foregroundColour.Ok() )
{
GdkColor *fg = m_foregroundColour.GetColor();
-
+
style->fg[GTK_STATE_NORMAL] = *fg;
style->color_flags[GTK_STATE_NORMAL] = GTK_RC_FG;
-
+
style->fg[GTK_STATE_PRELIGHT] = *fg;
style->color_flags[GTK_STATE_PRELIGHT] = GTK_RC_FG;
-
+
style->fg[GTK_STATE_ACTIVE] = *fg;
style->color_flags[GTK_STATE_ACTIVE] = GTK_RC_FG;
}
style->base[GTK_STATE_NORMAL] = *bg;
style->color_flags[GTK_STATE_NORMAL] = (GtkRcFlags)
(style->color_flags[GTK_STATE_NORMAL] | GTK_RC_BG | GTK_RC_BASE);
-
+
style->bg[GTK_STATE_PRELIGHT] = *bg;
style->base[GTK_STATE_PRELIGHT] = *bg;
style->color_flags[GTK_STATE_PRELIGHT] = (GtkRcFlags)
(style->color_flags[GTK_STATE_PRELIGHT] | GTK_RC_BG | GTK_RC_BASE);
-
+
style->bg[GTK_STATE_ACTIVE] = *bg;
style->base[GTK_STATE_ACTIVE] = *bg;
style->color_flags[GTK_STATE_ACTIVE] = (GtkRcFlags)
(style->color_flags[GTK_STATE_ACTIVE] | GTK_RC_BG | GTK_RC_BASE);
-
+
style->bg[GTK_STATE_INSENSITIVE] = *bg;
style->base[GTK_STATE_INSENSITIVE] = *bg;
style->color_flags[GTK_STATE_INSENSITIVE] = (GtkRcFlags)
(style->color_flags[GTK_STATE_INSENSITIVE] | GTK_RC_BG | GTK_RC_BASE);
}
-
+
return style;
}
bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style)
{
wxWindowBase::SetBackgroundStyle(style);
-
+
if (style == wxBG_STYLE_CUSTOM)
{
GdkWindow *window = (GdkWindow*) NULL;
else
// Do in OnIdle, because the window is not yet available
m_needsStyleChange = true;
-
+
// Don't apply widget style, or we get a grey background
}
else
#if wxUSE_MENUS_NATIVE
-extern "C"
+extern "C" WXDLLIMPEXP_CORE
void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting )
{
*is_waiting = FALSE;
}
-void SetInvokingWindow( wxMenu *menu, wxWindow* win )
+WXDLLIMPEXP_CORE void SetInvokingWindow( wxMenu *menu, wxWindow* win )
{
menu->SetInvokingWindow( win );
-
+
wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst();
while (node)
{
}
}
-extern "C" void wxPopupMenuPositionCallback( GtkMenu *menu,
- gint *x, gint *y,
+extern "C" WXDLLIMPEXP_CORE
+void wxPopupMenuPositionCallback( GtkMenu *menu,
+ gint *x, gint *y,
#ifdef __WXGTK20__
- gboolean * WXUNUSED(whatever),
+ gboolean * WXUNUSED(whatever),
#endif
- gpointer user_data )
+ gpointer user_data )
{
// ensure that the menu appears entirely on screen
GtkRequisition req;
bool wxWindowGTK::SetFont( const wxFont &font )
{
- wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") );
+ wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") );
if (!wxWindowBase::SetFont(font))
return false;
// apply style change (forceStyle=true so that new style is applied
// even if the font changed from valid to wxNullFont):
- ApplyWidgetStyle(true);
+ ApplyWidgetStyle(true);
return true;
}
cursor->GetCursor(),
(guint32)GDK_CURRENT_TIME );
g_captureWindow = this;
- g_captureWindowHasMouse = TRUE;
+ g_captureWindowHasMouse = true;
}
void wxWindowGTK::DoReleaseMouse()
bool wxWindowGTK::IsRetained() const
{
- return FALSE;
+ return false;
}
void wxWindowGTK::SetScrollbar( int orient, int pos, int thumbVisible,
wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
- m_hasScrolling = TRUE;
+ m_hasScrolling = true;
if (orient == wxHORIZONTAL)
{
}
#endif
- m_clipPaintRegion = TRUE;
+ m_clipPaintRegion = true;
gtk_pizza_scroll( GTK_PIZZA(m_wxwindow), -dx, -dy );
- m_clipPaintRegion = FALSE;
+ m_clipPaintRegion = false;
}
// g_eraseGC = gdk_gc_new( GDK_ROOT_PARENT() );
// gdk_gc_set_fill( g_eraseGC, GDK_SOLID );
- return TRUE;
+ return true;
}
void wxWinModule::OnExit()