}
}
+#if wxUSE_COMBOBOX
+
extern "C" {
static
void wxgtk_combo_size_request_callback(GtkWidget *widget,
}
}
+#endif // wxUSE_COMBOBOX
+
//-----------------------------------------------------------------------------
// "expose_event" of m_wxwindow
//-----------------------------------------------------------------------------
event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK);
event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK);
event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK);
- if (event.GetEventType() == wxEVT_MOUSEWHEEL)
- {
- event.m_linesPerAction = 3;
- event.m_wheelDelta = 120;
- if (((GdkEventButton*)gdk_event)->button == 4)
- event.m_wheelRotation = 120;
- else if (((GdkEventButton*)gdk_event)->button == 5)
- event.m_wheelRotation = -120;
- }
wxPoint pt = win->GetClientAreaOrigin();
event.m_x = (wxCoord)gdk_event->x - pt.x;
g_lastButtonNumber = gdk_event->button;
- if (win->m_wxwindow && (g_focusWindow != win) && win->CanAcceptFocus())
+ if (win->m_wxwindow && (g_focusWindow != win) && win->IsFocusable())
{
gtk_widget_grab_focus( win->m_wxwindow );
}
;
}
}
- else if (gdk_event->button == 4 || gdk_event->button == 5)
- {
- if (gdk_event->type == GDK_BUTTON_PRESS )
- {
- event_type = wxEVT_MOUSEWHEEL;
- }
- }
if ( event_type == wxEVT_NULL )
{
return TRUE;
if ((event_type == wxEVT_LEFT_DOWN) && !win->IsOfStandardClass() &&
- (g_focusWindow != win) && win->CanAcceptFocus())
+ (g_focusWindow != win) && win->IsFocusable())
{
gtk_widget_grab_focus( win->m_wxwindow );
}
}
//-----------------------------------------------------------------------------
-// "scroll_event", (mouse wheel event)
+// "scroll_event" (mouse wheel event)
//-----------------------------------------------------------------------------
static gboolean
wxScrollWinEvent event(eventType, win->GetScrollPos(orient), orient);
event.SetEventObject(win);
- win->m_blockValueChanged[dir] = true;
win->GTKProcessEvent(event);
- win->m_blockValueChanged[dir] = false;
}
}
{
m_scrollBar[dir] = NULL;
m_scrollPos[dir] = 0;
- m_blockValueChanged[dir] = false;
}
m_oldClientWidth =
g_signal_handler_block(m_scrollBar[dir], handler_id);
// these handlers get notified when scrollbar slider moves
- g_signal_connect(m_scrollBar[dir], "value_changed",
+ g_signal_connect_after(m_scrollBar[dir], "value_changed",
G_CALLBACK(gtk_scrollbar_value_changed), this);
}
G_CALLBACK (gtk_window_size_callback), this);
}
+#if wxUSE_COMBOBOX
if (GTK_IS_COMBO(m_widget))
{
GtkCombo *gcombo = GTK_COMBO(m_widget);
g_signal_connect (gcombo->entry, "size_request",
G_CALLBACK (wxgtk_combo_size_request_callback),
this);
- }
+ } else
+#endif // wxUSE_COMBOBOX
#ifdef GTK_IS_FILE_CHOOSER_BUTTON
- else if (!gtk_check_version(2,6,0) && GTK_IS_FILE_CHOOSER_BUTTON(m_widget))
+ if (!gtk_check_version(2,6,0) && GTK_IS_FILE_CHOOSER_BUTTON(m_widget))
{
// If we connect to the "size_request" signal of a GtkFileChooserButton
// then that control won't be sized properly when placed inside sizers
// (this can be tested removing this elseif and running XRC or WIDGETS samples)
// FIXME: what should be done here ?
- }
+ } else
#endif
- else if ( !IsTopLevel() ) // top level windows use their own callback
+ if ( !IsTopLevel() ) // top level windows use their own callback
{
// This is needed if we want to add our windows into native
// GTK controls, such as the toolbar. With this callback, the
{
if (GTK_IS_CONTAINER(m_widget))
{
+#if wxUSE_RADIOBTN
if (IsKindOf(CLASSINFO(wxRadioButton)))
{
gtk_widget_grab_focus (m_widget);
return;
}
+#endif // wxUSE_RADIOBTN
gtk_widget_child_focus( m_widget, GTK_DIR_TAB_FORWARD );
}
}
else // navigate inside the container
{
- wxWindow *parent = wxGetTopLevelParent(this);
+ wxWindow *parent = wxGetTopLevelParent((wxWindow *)this);
wxCHECK_MSG( parent, false, _T("every window must have a TLW parent") );
GtkDirectionType dir;
if (style == wxBG_STYLE_CUSTOM)
{
- GdkWindow *window = (GdkWindow*) NULL;
- if (m_wxwindow)
+ GdkWindow *window;
+ if ( m_wxwindow )
+ {
window = GTK_PIZZA(m_wxwindow)->bin_window;
+ }
else
- window = GetConnectWidget()->window;
+ {
+ GtkWidget * const w = GetConnectWidget();
+ window = w ? w->window : NULL;
+ }
if (window)
{
#endif
m_needsStyleChange = false;
}
- else
+ else // window not realized yet
+ {
// Do in OnIdle, because the window is not yet available
m_needsStyleChange = true;
+ }
// Don't apply widget style, or we get a grey background
}
int range,
bool WXUNUSED(update))
{
- wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
- wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
- wxCHECK_RET( m_wxwindow != m_widget, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") );
+ GtkRange * const sb = m_scrollBar[ScrollDirFromOrient(orient)];
+ wxCHECK_RET( sb, _T("this window is not scrollable") );
if (range > 0)
{
pos = range - thumbVisible;
if (pos < 0)
pos = 0;
- GtkAdjustment* adj = m_scrollBar[ScrollDirFromOrient(orient)]->adjustment;
+ GtkAdjustment * const adj = sb->adjustment;
adj->step_increment = 1;
adj->page_increment =
adj->page_size = thumbVisible;
void wxWindowGTK::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
{
- wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
- wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
- wxCHECK_RET( m_wxwindow != m_widget, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") );
+ const int dir = ScrollDirFromOrient(orient);
+ GtkRange * const sb = m_scrollBar[dir];
+ wxCHECK_RET( sb, _T("this window is not scrollable") );
// This check is more than an optimization. Without it, the slider
// will not move smoothly while tracking when using wxScrollHelper.
if (GetScrollPos(orient) != pos)
{
- const int dir = ScrollDirFromOrient(orient);
- GtkAdjustment* adj = m_scrollBar[dir]->adjustment;
+ GtkAdjustment* adj = sb->adjustment;
const int max = int(adj->upper - adj->page_size);
if (pos > max)
pos = max;
pos = 0;
m_scrollPos[dir] = adj->value = pos;
- // If a "value_changed" signal emission is not already in progress
- if (!m_blockValueChanged[dir])
- {
- gtk_adjustment_value_changed(adj);
- }
+ g_signal_handlers_block_by_func(m_scrollBar[dir],
+ (gpointer)gtk_scrollbar_value_changed, this);
+
+ gtk_adjustment_value_changed(adj);
+
+ g_signal_handlers_unblock_by_func(m_scrollBar[dir],
+ (gpointer)gtk_scrollbar_value_changed, this);
}
}
int wxWindowGTK::GetScrollThumb(int orient) const
{
- wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") );
- wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") );
- wxCHECK_MSG( m_wxwindow != m_widget, 0, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") );
+ GtkRange * const sb = m_scrollBar[ScrollDirFromOrient(orient)];
+ wxCHECK_MSG( sb, 0, _T("this window is not scrollable") );
- return int(m_scrollBar[ScrollDirFromOrient(orient)]->adjustment->page_size);
+ return int(sb->adjustment->page_size);
}
int wxWindowGTK::GetScrollPos( int orient ) const
{
- wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") );
- wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") );
- wxCHECK_MSG( m_wxwindow != m_widget, 0, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") );
+ GtkRange * const sb = m_scrollBar[ScrollDirFromOrient(orient)];
+ wxCHECK_MSG( sb, 0, _T("this window is not scrollable") );
- return int(m_scrollBar[ScrollDirFromOrient(orient)]->adjustment->value + 0.5);
+ return int(sb->adjustment->value + 0.5);
}
int wxWindowGTK::GetScrollRange( int orient ) const
{
- wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") );
- wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") );
- wxCHECK_MSG( m_wxwindow != m_widget, 0, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") );
+ GtkRange * const sb = m_scrollBar[ScrollDirFromOrient(orient)];
+ wxCHECK_MSG( sb, 0, _T("this window is not scrollable") );
- return int(m_scrollBar[ScrollDirFromOrient(orient)]->adjustment->upper);
+ return int(sb->adjustment->upper);
}
// Determine if increment is the same as +/-x, allowing for some small
// No scrolling requested.
if ((dx == 0) && (dy == 0)) return;
-
+
m_clipPaintRegion = true;
if (GetLayoutDirection() == wxLayout_RightToLeft)