From: Paul Cornett Date: Mon, 17 Sep 2007 17:24:44 +0000 (+0000) Subject: various small cleanups X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/260020e39271329f71d1ef7912e3dc8216a2e924 various small cleanups git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48755 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/filectrl.h b/include/wx/filectrl.h index b12a666d05..0b7a40c903 100644 --- a/include/wx/filectrl.h +++ b/include/wx/filectrl.h @@ -66,7 +66,7 @@ public: virtual int GetFilterIndex() const = 0; virtual bool HasMultipleFileSelection() const = 0; - virtual void ShowHidden(const bool show) = 0; + virtual void ShowHidden(bool show) = 0; }; void GenerateFolderChangedEvent( wxFileCtrlBase *fileCtrl, wxWindow *wnd ); @@ -104,17 +104,17 @@ public: // no need for the copy constructor as the default one will be fine. virtual wxEvent *Clone() const { return new wxFileCtrlEvent( *this ); } - void SetFiles( const wxArrayString &files ) { this->files = files; } - void SetDirectory( const wxString &directory ) { this->directory = directory; } + void SetFiles( const wxArrayString &files ) { m_files = files; } + void SetDirectory( const wxString &directory ) { m_directory = directory; } - wxArrayString GetFiles() const { return files; } - wxString GetDirectory() const { return directory; } + wxArrayString GetFiles() const { return m_files; } + wxString GetDirectory() const { return m_directory; } wxString GetFile() const; protected: - wxString directory; - wxArrayString files; + wxString m_directory; + wxArrayString m_files; DECLARE_DYNAMIC_CLASS_NO_ASSIGN( wxFileCtrlEvent ) }; diff --git a/include/wx/generic/filectrlg.h b/include/wx/generic/filectrlg.h index bf26b1f632..f4508e5e02 100644 --- a/include/wx/generic/filectrlg.h +++ b/include/wx/generic/filectrlg.h @@ -161,8 +161,8 @@ public: void OnListEndLabelEdit( wxListEvent &event ); void OnListColClick( wxListEvent &event ); - virtual void SortItems(wxFileData::fileListFieldType field, bool foward); - bool GetSortDirection() const { return m_sort_foward; } + virtual void SortItems(wxFileData::fileListFieldType field, bool forward); + bool GetSortDirection() const { return m_sort_forward; } wxFileData::fileListFieldType GetSortField() const { return m_sort_field; } protected: @@ -173,7 +173,7 @@ protected: bool m_showHidden; wxString m_wild; - bool m_sort_foward; + bool m_sort_forward; wxFileData::fileListFieldType m_sort_field; private: @@ -237,7 +237,7 @@ public: virtual int GetFilterIndex() const { return m_filterIndex; } virtual bool HasMultipleFileSelection() const { return m_style & wxFC_MULTIPLE; } - virtual void ShowHidden(const bool show) { m_list->ShowHidden( show ); } + virtual void ShowHidden(bool show) { m_list->ShowHidden( show ); } void GoToParentDir(); void GoToHomeDir(); diff --git a/include/wx/gtk/filectrl.h b/include/wx/gtk/filectrl.h index 516fe62e12..77b5fa193f 100644 --- a/include/wx/gtk/filectrl.h +++ b/include/wx/gtk/filectrl.h @@ -100,7 +100,7 @@ public: virtual int GetFilterIndex() const { return m_fc.GetFilterIndex(); } virtual bool HasMultipleFileSelection() const { return HasFlag( wxFC_MULTIPLE ); } - virtual void ShowHidden(const bool show); + virtual void ShowHidden(bool show); bool m_checkNextSelEvent; bool m_ignoreNextFolderChangeEvent; diff --git a/src/common/filectrlcmn.cpp b/src/common/filectrlcmn.cpp index d6b4adb044..17665f27c1 100644 --- a/src/common/filectrlcmn.cpp +++ b/src/common/filectrlcmn.cpp @@ -84,10 +84,10 @@ wxString wxFileCtrlEvent::GetFile() const wxASSERT_MSG( !wxDynamicCast( GetEventObject(), wxFileCtrl )->HasMultipleFileSelection(), wxT( "Please use GetFiles() to get all files instead of this function" ) ); - if ( files.Count() == 0 ) - return wxEmptyString; - else - return files[0]; + wxString string; + if (m_files.Count() != 0) + string = m_files[0]; + return string; } #endif // wxUSE_FILECTRL diff --git a/src/generic/filectrlg.cpp b/src/generic/filectrlg.cpp index cfecb2217d..44486c1bf9 100644 --- a/src/generic/filectrlg.cpp +++ b/src/generic/filectrlg.cpp @@ -224,7 +224,7 @@ void wxFileData::ReadData() #if defined(__UNIX__) && (!defined( __OS2__ ) && !defined(__VMS)) lstat( m_filePath.fn_str(), &buff ); - m_type |= S_ISLNK( buff.st_mode ) != 0 ? is_link : 0; + m_type |= S_ISLNK(buff.st_mode) ? is_link : 0; #else // no lstat() // only translate to file charset if we don't go by our // wxStat implementation @@ -393,6 +393,7 @@ void wxFileData::MakeItem( wxListItem &item ) // wxFileListCtrl //----------------------------------------------------------------------------- +// FIXME: what is this for? It's never read static bool ignoreChanges = false; IMPLEMENT_DYNAMIC_CLASS(wxFileListCtrl,wxListCtrl) @@ -408,7 +409,7 @@ END_EVENT_TABLE() wxFileListCtrl::wxFileListCtrl() { m_showHidden = false; - m_sort_foward = 1; + m_sort_forward = true; m_sort_field = wxFileData::FileList_Name; } @@ -430,7 +431,7 @@ wxFileListCtrl::wxFileListCtrl(wxWindow *win, m_showHidden = showHidden; - m_sort_foward = 1; + m_sort_forward = true; m_sort_field = wxFileData::FileList_Name; m_dirName = wxT("*"); @@ -626,7 +627,7 @@ void wxFileListCtrl::UpdateFiles() } } - SortItems(m_sort_field, m_sort_foward); + SortItems(m_sort_field, m_sort_forward); } void wxFileListCtrl::SetWild( const wxString &wild ) @@ -677,7 +678,7 @@ void wxFileListCtrl::MakeDir() if (id != -1) { - SortItems(m_sort_field, m_sort_foward); + SortItems(m_sort_field, m_sort_forward); id = FindItem( 0, wxPtrToUInt(fd) ); EnsureVisible( id ); EditLabel( id ); @@ -834,17 +835,17 @@ void wxFileListCtrl::OnListColClick( wxListEvent &event ) } if ((wxFileData::fileListFieldType)col == m_sort_field) - m_sort_foward = !m_sort_foward; + m_sort_forward = !m_sort_forward; else m_sort_field = (wxFileData::fileListFieldType)col; - SortItems(m_sort_field, m_sort_foward); + SortItems(m_sort_field, m_sort_forward); } void wxFileListCtrl::SortItems(wxFileData::fileListFieldType field, bool forward) { m_sort_field = field; - m_sort_foward = forward; + m_sort_forward = forward; const long sort_dir = forward ? 1 : -1; switch (m_sort_field) diff --git a/src/gtk/filectrl.cpp b/src/gtk/filectrl.cpp index 03437535ea..6b2a0001df 100644 --- a/src/gtk/filectrl.cpp +++ b/src/gtk/filectrl.cpp @@ -45,10 +45,10 @@ wxString wxGtkFileChooser::GetPath() const { wxGtkString str( gtk_file_chooser_get_filename( m_widget ) ); - if ( str.c_str() == NULL ) - return wxEmptyString; - - return wxConvFileName->cMB2WX( str ); + wxString string; + if (str.c_str() != NULL) + string = wxConvFileName->cMB2WX(str); + return string; } void wxGtkFileChooser::GetFilenames( wxArrayString& files ) const @@ -95,7 +95,7 @@ bool wxGtkFileChooser::SetDirectory( const wxString& dir ) const gboolean b = gtk_file_chooser_set_current_folder( m_widget, wxConvFileName->cWX2MB( dir.c_str() ) ); - return b == TRUE; + return b != 0; } wxString wxGtkFileChooser::GetDirectory() const @@ -282,19 +282,13 @@ bool wxGtkFileCtrl::Create( wxWindow *parent, return false; } - GtkFileChooserAction gtkAction; + GtkFileChooserAction gtkAction = GTK_FILE_CHOOSER_ACTION_OPEN; if ( style & wxFC_SAVE ) - { gtkAction = GTK_FILE_CHOOSER_ACTION_SAVE; - } - else if ( style & wxFC_OPEN ) - { - gtkAction = GTK_FILE_CHOOSER_ACTION_OPEN; - } m_widget = gtk_alignment_new ( 0, 0, 1, 1 ); - m_fcWidget = GTK_FILE_CHOOSER( gtk_file_chooser_widget_new( GTK_FILE_CHOOSER_ACTION_OPEN ) ); + m_fcWidget = GTK_FILE_CHOOSER( gtk_file_chooser_widget_new(gtkAction) ); gtk_widget_show ( GTK_WIDGET( m_fcWidget ) ); gtk_container_add ( GTK_CONTAINER ( m_widget ), GTK_WIDGET( m_fcWidget ) ); @@ -426,9 +420,9 @@ void wxGtkFileCtrl::GetFilenames( wxArrayString& files ) const m_fc.GetFilenames( files ); } -void wxGtkFileCtrl::ShowHidden(const bool show) +void wxGtkFileCtrl::ShowHidden(bool show) { - gtk_file_chooser_set_show_hidden( m_fcWidget, ( show == true ) ? TRUE : FALSE ); + gtk_file_chooser_set_show_hidden(m_fcWidget, show); } #endif