fix warnings about conversion to bool, closes #14381

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71685 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett 2012-06-07 05:18:30 +00:00
parent ecdfd09516
commit d5027818a4
17 changed files with 34 additions and 37 deletions

View File

@ -368,7 +368,7 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_)
init_result = true; // is there a _check() version of this?
gpe_application_init( &argcGTK, &argvGTK );
#else
init_result = gtk_init_check( &argcGTK, &argvGTK );
init_result = gtk_init_check( &argcGTK, &argvGTK ) != 0;
#endif
wxUpdateLocaleIsUtf8();

View File

@ -295,7 +295,7 @@ wxSize wxButton::DoGetBestSize() const
// extra border around it, but we don't want to take it into account in
// our size calculations (otherwise the result is visually ugly), so
// always return the size of non default button from here
const bool isDefault = gtk_widget_has_default(m_widget);
const bool isDefault = gtk_widget_has_default(m_widget) != 0;
if ( isDefault )
{
// temporarily unset default flag

View File

@ -44,8 +44,8 @@ static void gtk_checkbox_toggled_callback(GtkWidget *widget, wxCheckBox *cb)
{
// The 3 states cycle like this when clicked:
// checked -> undetermined -> unchecked -> checked -> ...
bool active = gtk_toggle_button_get_active(toggle);
bool inconsistent = gtk_toggle_button_get_inconsistent(toggle);
bool active = gtk_toggle_button_get_active(toggle) != 0;
bool inconsistent = gtk_toggle_button_get_inconsistent(toggle) != 0;
cb->GTKDisableEvents();
@ -177,7 +177,7 @@ bool wxCheckBox::GetValue() const
{
wxCHECK_MSG( m_widgetCheckbox != NULL, false, wxT("invalid checkbox") );
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_widgetCheckbox));
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_widgetCheckbox)) != 0;
}
void wxCheckBox::DoSet3StateValue(wxCheckBoxState state)

View File

@ -121,7 +121,7 @@ bool wxCheckListBox::IsChecked(unsigned int index) const
0, //column
&value);
return g_value_get_boolean(&value) == TRUE ? true : false;
return g_value_get_boolean(&value) != 0;
}
void wxCheckListBox::Check(unsigned int index, bool check)

View File

@ -507,7 +507,7 @@ bool wxClipboard::SetSelectionOwner(bool set)
set ? m_clipboardWidget : NULL,
GTKGetClipboardAtom(),
(guint32)GDK_CURRENT_TIME
);
) != 0;
if ( !rc )
{

View File

@ -2257,12 +2257,10 @@ static void wxGtkToggleRendererToggledCallback( GtkCellRendererToggle *renderer,
GValue gvalue = { 0, };
g_value_init( &gvalue, G_TYPE_BOOLEAN );
g_object_get_property( G_OBJECT(renderer), "active", &gvalue );
bool tmp = g_value_get_boolean( &gvalue );
g_value_unset( &gvalue );
// invert it
tmp = !tmp;
wxVariant value = !g_value_get_boolean( &gvalue );
g_value_unset( &gvalue );
wxVariant value = tmp;
if (!cell->Validate( value ))
return;
@ -2320,11 +2318,9 @@ bool wxDataViewToggleRenderer::GetValue( wxVariant &value ) const
GValue gvalue = { 0, };
g_value_init( &gvalue, G_TYPE_BOOLEAN );
g_object_get_property( G_OBJECT(m_renderer), "active", &gvalue );
bool tmp = g_value_get_boolean( &gvalue );
value = g_value_get_boolean( &gvalue ) != 0;
g_value_unset( &gvalue );
value = tmp;
return true;
}
@ -2625,7 +2621,7 @@ wxDataViewChoiceRenderer::wxDataViewChoiceRenderer( const wxArrayString &choices
"has-entry", FALSE,
NULL);
bool editable = (mode & wxDATAVIEW_CELL_EDITABLE);
bool editable = (mode & wxDATAVIEW_CELL_EDITABLE) != 0;
g_object_set (m_renderer, "editable", editable, NULL);
SetAlignment(alignment);
@ -3143,19 +3139,19 @@ void wxDataViewColumn::SetSortable( bool sortable )
bool wxDataViewColumn::IsSortable() const
{
GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column);
return gtk_tree_view_column_get_clickable( column );
return gtk_tree_view_column_get_clickable( column ) != 0;
}
bool wxDataViewColumn::IsSortKey() const
{
GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column);
return gtk_tree_view_column_get_sort_indicator( column );
return gtk_tree_view_column_get_sort_indicator( column ) != 0;
}
bool wxDataViewColumn::IsResizeable() const
{
GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column);
return gtk_tree_view_column_get_resizable( column );
return gtk_tree_view_column_get_resizable( column ) != 0;
}
bool wxDataViewColumn::IsHidden() const
@ -3225,7 +3221,7 @@ void wxDataViewColumn::SetReorderable( bool reorderable )
bool wxDataViewColumn::IsReorderable() const
{
return gtk_tree_view_column_get_reorderable( GTK_TREE_VIEW_COLUMN(m_column) );
return gtk_tree_view_column_get_reorderable( GTK_TREE_VIEW_COLUMN(m_column) ) != 0;
}
//-----------------------------------------------------------------------------
@ -4811,7 +4807,7 @@ bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const
GtkTreeIter iter;
iter.user_data = item.GetID();
wxGtkTreePath path(m_internal->get_path( &iter ));
return gtk_tree_view_row_expanded( GTK_TREE_VIEW(m_treeview), path );
return gtk_tree_view_row_expanded( GTK_TREE_VIEW(m_treeview), path ) != 0;
}
wxDataViewItem wxDataViewCtrl::DoGetCurrentItem() const
@ -4996,7 +4992,7 @@ bool wxDataViewCtrl::IsSelected( const wxDataViewItem & item ) const
iter.stamp = m_internal->GetGtkModel()->stamp;
iter.user_data = (gpointer) item.GetID();
return gtk_tree_selection_iter_is_selected( selection, &iter );
return gtk_tree_selection_iter_is_selected( selection, &iter ) != 0;
}
void wxDataViewCtrl::SelectAll()

View File

@ -88,7 +88,7 @@ bool wxGtkFileChooser::SetPath( const wxString& path )
if ( path.empty() )
return true;
return gtk_file_chooser_set_filename( m_widget, path.utf8_str() );
return gtk_file_chooser_set_filename( m_widget, path.utf8_str() ) != 0;
}
bool wxGtkFileChooser::SetDirectory( const wxString& dir )

View File

@ -729,7 +729,7 @@ bool wxListBox::IsSelected( int n ) const
GtkTreeIter iter;
wxCHECK_MSG( GTKGetIteratorFor(n, &iter), false, wxT("Invalid index") );
return gtk_tree_selection_iter_is_selected(selection, &iter);
return gtk_tree_selection_iter_is_selected(selection, &iter) != 0;
}
void wxListBox::DoSetSelection( int n, bool select )

View File

@ -434,7 +434,7 @@ bool wxMenuBar::IsEnabledTop(size_t pos) const
wxCHECK_MSG( node, false, wxS("invalid index in IsEnabledTop") );
wxMenu* const menu = node->GetData();
wxCHECK_MSG( menu->m_owner, true, wxS("no menu owner?") );
return gtk_widget_get_sensitive( menu->m_owner );
return gtk_widget_get_sensitive( menu->m_owner ) != 0;
}
wxString wxMenuBar::GetMenuLabel( size_t pos ) const

View File

@ -88,7 +88,7 @@ static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_
// GDK reports GDK_ISO_Left_Tab for SHIFT-TAB
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
// CTRL-TAB changes the (parent) window, i.e. switch notebook page
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) != 0 );
new_event.SetCurrentFocus( rb );
return rb->GetParent()->HandleWindowEvent(new_event);
}
@ -475,7 +475,7 @@ bool wxRadioBox::IsItemEnabled(unsigned int item) const
// don't use GTK_WIDGET_IS_SENSITIVE() here, we want to return true even if
// the parent radiobox is disabled
return gtk_widget_get_sensitive(GTK_WIDGET(button));
return gtk_widget_get_sensitive(GTK_WIDGET(button)) != 0;
}
bool wxRadioBox::Show(unsigned int item, bool show)
@ -506,7 +506,7 @@ bool wxRadioBox::IsItemShown(unsigned int item) const
GtkButton *button = GTK_BUTTON( node->GetData()->button );
return gtk_widget_get_visible(GTK_WIDGET(button));
return gtk_widget_get_visible(GTK_WIDGET(button)) != 0;
}
unsigned int wxRadioBox::GetCount() const

View File

@ -137,7 +137,7 @@ wxGDIRefData *wxRegion::CloneGDIRefData(const wxGDIRefData *data) const
bool wxRegion::DoIsEqual(const wxRegion& region) const
{
return gdk_region_equal(M_REGIONDATA->m_region,
M_REGIONDATA_OF(region)->m_region);
M_REGIONDATA_OF(region)->m_region) != 0;
}
// ----------------------------------------------------------------------------
@ -292,7 +292,7 @@ bool wxRegion::IsEmpty() const
if (!m_refData)
return true;
return gdk_region_empty( M_REGIONDATA->m_region );
return gdk_region_empty( M_REGIONDATA->m_region ) != 0;
}
wxRegionContain wxRegion::DoContainsPoint( wxCoord x, wxCoord y ) const

View File

@ -195,7 +195,7 @@ bool wxSpinCtrlGTKBase::GetSnapToTicks() const
{
wxCHECK_MSG(m_widget, false, "invalid spin button");
return gtk_spin_button_get_snap_to_ticks( GTK_SPIN_BUTTON(m_widget) );
return gtk_spin_button_get_snap_to_ticks( GTK_SPIN_BUTTON(m_widget) ) != 0;
}
void wxSpinCtrlGTKBase::SetValue( const wxString& value )

View File

@ -1599,7 +1599,7 @@ bool wxTextCtrl::IsEditable() const
if ( IsMultiLine() )
{
return gtk_text_view_get_editable(GTK_TEXT_VIEW(m_text));
return gtk_text_view_get_editable(GTK_TEXT_VIEW(m_text)) != 0;
}
else
{

View File

@ -279,7 +279,7 @@ bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString& choices)
bool wxTextEntry::IsEditable() const
{
return gtk_editable_get_editable(GetEditable());
return gtk_editable_get_editable(GetEditable()) != 0;
}
void wxTextEntry::SetEditable(bool editable)

View File

@ -1433,7 +1433,7 @@ bool wxTopLevelWindowGTK::CanSetTransparent()
#if GTK_CHECK_VERSION(2,10,0)
if (!gtk_check_version(2,10,0))
{
return (gtk_widget_is_composited (m_widget));
return gtk_widget_is_composited(m_widget) != 0;
}
else
#endif // In case of lower versions than gtk+-2.10.0 we could look for _NET_WM_CM_Sn ourselves

View File

@ -923,7 +923,8 @@ gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget),
// 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.
bool intercepted_by_IM = gtk_im_context_filter_keypress(win->m_imData->context, gdk_event);
bool intercepted_by_IM =
gtk_im_context_filter_keypress(win->m_imData->context, gdk_event) != 0;
win->m_imData->lastKeyEvent = NULL;
if (intercepted_by_IM)
{
@ -3417,7 +3418,7 @@ bool wxWindowGTK::DoNavigateIn(int flags)
gboolean rc;
g_signal_emit_by_name(parent->m_widget, "focus", dir, &rc);
return rc == TRUE;
return rc != 0;
}
}
@ -3883,7 +3884,7 @@ void wxWindowGTK::SetDoubleBuffered( bool on )
bool wxWindowGTK::IsDoubleBuffered() const
{
return gtk_widget_get_double_buffered( m_wxwindow );
return gtk_widget_get_double_buffered( m_wxwindow ) != 0;
}
void wxWindowGTK::ClearBackground()

View File

@ -86,7 +86,7 @@ bool Uuid::operator==(const Uuid& uuid) const
{
// IsEqualGUID() returns BOOL and not bool so use an explicit comparison to
// avoid MSVC warnings about int->bool conversion
return IsEqualGUID(m_uuid, uuid.m_uuid) == TRUE;
return IsEqualGUID(m_uuid, uuid.m_uuid) != 0;
}
// dtor