}
}
+#if wxUSE_COMBOBOX
+
extern "C" {
static
void wxgtk_combo_size_request_callback(GtkWidget *widget,
}
}
+#endif // wxUSE_COMBOBOX
+
//-----------------------------------------------------------------------------
// "expose_event" of m_wxwindow
//-----------------------------------------------------------------------------
event.SetEventObject( window );
}
- const wxWxCharBuffer data(wxGTK_CONV_BACK_SYS(str));
- if( !data )
+ const wxString data(wxGTK_CONV_BACK_SYS(str));
+ if( data.empty() )
return;
bool ret = false;
while (parent && !parent->IsTopLevel())
parent = parent->GetParent();
- for( const wxChar* pstr = data; *pstr; pstr++ )
+ for( wxString::const_iterator pstr = data.begin(); pstr != data.end(); ++pstr )
{
#if wxUSE_UNICODE
event.m_uniChar = *pstr;
event.m_keyCode = *pstr < 256 ? event.m_uniChar : 0;
wxLogTrace(TRACE_KEYS, _T("IM sent character '%c'"), event.m_uniChar);
#else
- event.m_keyCode = *pstr;
+ event.m_keyCode = (char)*pstr;
#endif // wxUSE_UNICODE
// To conform to the docs we need to translate Ctrl-alpha
T *gdk_event)
{
event.SetTimestamp( gdk_event->time );
- event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
- event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
- event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
- event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
- 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;
- }
+ event.m_shiftDown = gdk_event->state & GDK_SHIFT_MASK;
+ event.m_controlDown = gdk_event->state & GDK_CONTROL_MASK;
+ event.m_altDown = gdk_event->state & GDK_MOD1_MASK;
+ event.m_metaDown = gdk_event->state & GDK_MOD2_MASK;
+ 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;
+ event.m_aux1Down = gdk_event->state & GDK_BUTTON4_MASK;
+ event.m_aux2Down = gdk_event->state & GDK_BUTTON5_MASK;
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
}
wxMouseEvent event(wxEVT_MOUSEWHEEL);
- // Can't use InitMouse macro because scroll events don't have button
- event.SetTimestamp( gdk_event->time );
- event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
- event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
- event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
- event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
- 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);
+ InitMouseEvent(win, event, gdk_event);
event.m_linesPerAction = 3;
event.m_wheelDelta = 120;
if (gdk_event->direction == GDK_SCROLL_UP)
else
event.m_wheelRotation = -120;
- wxPoint pt = win->GetClientAreaOrigin();
- event.m_x = (wxCoord)gdk_event->x - pt.x;
- event.m_y = (wxCoord)gdk_event->y - pt.y;
-
- event.SetEventObject( win );
- event.SetId( win->GetId() );
- event.SetTimestamp( gdk_event->time );
-
return win->GTKProcessEvent(event);
}
if (gdk_event->mode != GDK_CROSSING_NORMAL) return FALSE;
wxMouseEvent event( wxEVT_LEAVE_WINDOW );
- event.SetTimestamp( gdk_event->time );
- event.SetEventObject( win );
int x = 0;
int y = 0;
gdk_window_get_pointer( widget->window, &x, &y, &state );
- event.m_shiftDown = (state & GDK_SHIFT_MASK) != 0;
- event.m_controlDown = (state & GDK_CONTROL_MASK) != 0;
- event.m_altDown = (state & GDK_MOD1_MASK) != 0;
- event.m_metaDown = (state & GDK_MOD2_MASK) != 0;
- event.m_leftDown = (state & GDK_BUTTON1_MASK) != 0;
- event.m_middleDown = (state & GDK_BUTTON2_MASK) != 0;
- event.m_rightDown = (state & GDK_BUTTON3_MASK) != 0;
-
- wxPoint pt = win->GetClientAreaOrigin();
- event.m_x = x + pt.x;
- event.m_y = y + pt.y;
+ InitMouseEvent(win, event, gdk_event);
return win->GTKProcessEvent(event);
}
wxScrollWinEvent event(eventType, win->GetScrollPos(orient), orient);
event.SetEventObject(win);
- win->m_blockValueChanged[dir] = true;
win->GTKProcessEvent(event);
- win->m_blockValueChanged[dir] = false;
}
}
ms.SetLeftDown(mask & GDK_BUTTON1_MASK);
ms.SetMiddleDown(mask & GDK_BUTTON2_MASK);
ms.SetRightDown(mask & GDK_BUTTON3_MASK);
+ ms.SetAux1Down(mask & GDK_BUTTON4_MASK);
+ ms.SetAux2Down(mask & GDK_BUTTON5_MASK);
ms.SetControlDown(mask & GDK_CONTROL_MASK);
ms.SetShiftDown(mask & GDK_SHIFT_MASK);
{
m_scrollBar[dir] = NULL;
m_scrollPos[dir] = 0;
- m_blockValueChanged[dir] = false;
}
m_oldClientWidth =
m_resizing = false;
- m_insertCallback = (wxInsertChildFunction) NULL;
+ m_insertCallback = wxInsertChildInWindow;
m_hasFocus = false;
return false;
}
- m_insertCallback = wxInsertChildInWindow;
-
-
if (!HasFlag(wxHSCROLL) && !HasFlag(wxVSCROLL))
{
m_wxwindow = gtk_pizza_new_no_scroll();
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
right_border += default_border->right;
top_border += default_border->top;
bottom_border += default_border->bottom;
- g_free( default_border );
+ gtk_border_free( default_border );
}
}
- DoMoveWindow( m_x-top_border,
- m_y-left_border,
+ DoMoveWindow( m_x - left_border,
+ m_y - top_border,
m_width+left_border+right_border,
m_height+top_border+bottom_border );
}
{
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 );
}
void wxWindowGTK::DoAddChild(wxWindowGTK *child)
{
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
-
wxASSERT_MSG( (child != NULL), wxT("invalid child window") );
- wxASSERT_MSG( (m_insertCallback != NULL), wxT("invalid child insertion function") );
-
/* add to list */
AddChild( child );
}
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;
m_tooltip->Apply( (wxWindow *)this );
}
-void wxWindowGTK::ApplyToolTip( GtkTooltips *tips, const wxChar *tip )
+void wxWindowGTK::ApplyToolTip( GtkTooltips *tips, const gchar *tip )
{
- if (tip)
- {
- wxString tmp( tip );
- gtk_tooltips_set_tip( tips, GetConnectWidget(), wxGTK_CONV(tmp), (gchar*) NULL );
- }
- else
- {
- gtk_tooltips_set_tip( tips, GetConnectWidget(), NULL, NULL);
- }
+ gtk_tooltips_set_tip(tips, GetConnectWidget(), tip, NULL);
}
#endif // wxUSE_TOOLTIPS
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)