From ed58dbeab64d18a0f869ea8e1610a0a88ad7b22c Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 20 Aug 1999 22:52:21 +0000 Subject: [PATCH] Changed a few #include to #include "xxx.h" Added endl operator to wxTextStream Corrrected a few misbehaviours in wxFileDialog, Corrected tab traversal a bit Corrected wxImage::SetData() to not copy, but take the data and care for ref couting as well git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3436 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/datstrm.h | 2 +- include/wx/dynlib.h | 8 ++--- include/wx/filefn.h | 2 +- include/wx/fs_inet.h | 7 ++--- include/wx/fs_zip.h | 8 ++--- include/wx/gtk/notebook.h | 3 ++ include/wx/gtk1/notebook.h | 3 ++ include/wx/mstream.h | 2 +- include/wx/serbase.h | 4 +-- include/wx/socket.h | 8 ++--- include/wx/thread.h | 2 +- include/wx/txtstrm.h | 4 ++- include/wx/wfstream.h | 8 ++--- include/wx/zstream.h | 2 +- samples/controls/controls.cpp | 2 +- samples/dialogs/dialogs.cpp | 2 +- src/common/image.cpp | 15 +++++++++- src/common/intl.cpp | 9 ++++-- src/common/txtstrm.cpp | 5 ++++ src/generic/filedlgg.cpp | 37 +++++++++++++++++++---- src/generic/notebook.cpp | 12 ++++---- src/generic/panelg.cpp | 10 ++++--- src/gtk/notebook.cpp | 55 +++++++++-------------------------- src/gtk/stattext.cpp | 2 +- src/gtk/window.cpp | 1 - src/gtk1/notebook.cpp | 55 +++++++++-------------------------- src/gtk1/stattext.cpp | 2 +- src/gtk1/window.cpp | 1 - 28 files changed, 135 insertions(+), 136 deletions(-) diff --git a/include/wx/datstrm.h b/include/wx/datstrm.h index 7b0fa1a613..6ba074de71 100644 --- a/include/wx/datstrm.h +++ b/include/wx/datstrm.h @@ -16,7 +16,7 @@ #pragma interface "datstrm.h" #endif -#include +#include "wx/stream.h" #if wxUSE_STREAMS diff --git a/include/wx/dynlib.h b/include/wx/dynlib.h index 0802665377..e6b0bc8c14 100644 --- a/include/wx/dynlib.h +++ b/include/wx/dynlib.h @@ -16,13 +16,13 @@ # pragma interface #endif -#include +#include "wx/setup.h" #if wxUSE_DYNLIB_CLASS -#include -#include -#include +#include "wx/string.h" +#include "wx/list.h" +#include "wx/hash.h" // this is normally done by configure, but I leave it here for now... #if defined(__UNIX__) && !(defined(HAVE_DLOPEN) || defined(HAVE_SHL_LOAD)) diff --git a/include/wx/filefn.h b/include/wx/filefn.h index b7455424ad..152bfaea4b 100644 --- a/include/wx/filefn.h +++ b/include/wx/filefn.h @@ -16,7 +16,7 @@ #pragma interface "filefn.h" #endif -#include +#include "wx/list.h" // ---------------------------------------------------------------------------- // constants diff --git a/include/wx/fs_inet.h b/include/wx/fs_inet.h index ccf2a71915..7179f40742 100644 --- a/include/wx/fs_inet.h +++ b/include/wx/fs_inet.h @@ -23,7 +23,7 @@ limitation) #pragma implementation #endif -#include +#include "wx/wxprec.h" #ifdef __BORDLANDC__ #pragma hdrstop @@ -32,11 +32,10 @@ limitation) #if wxUSE_FS_INET && wxUSE_STREAMS && wxUSE_SOCKETS #ifndef WXPRECOMP -#include +#include "wx/wx.h" #endif -#include - +#include "wx/filesys.h" //-------------------------------------------------------------------------------- diff --git a/include/wx/fs_zip.h b/include/wx/fs_zip.h index f891349cbf..e3461634b8 100644 --- a/include/wx/fs_zip.h +++ b/include/wx/fs_zip.h @@ -11,7 +11,7 @@ #pragma implementation #endif -#include +#include "wx/wxprec.h" #ifdef __BORDLANDC__ #pragma hdrstop @@ -21,12 +21,10 @@ #ifndef WXPRECOMP -#include +#include "wx/wx.h" #endif -#include - - +#include "wx/filesys.h" //-------------------------------------------------------------------------------- // wxZipFSHandler diff --git a/include/wx/gtk/notebook.h b/include/wx/gtk/notebook.h index 3481d3016c..d8c772d7a0 100644 --- a/include/wx/gtk/notebook.h +++ b/include/wx/gtk/notebook.h @@ -130,6 +130,9 @@ public: void OnNavigationKey(wxNavigationKeyEvent& event); + // overridden from wxWindow to make tabbing work + void SetFocus(); + // implementation void SetConstraintSizes(bool recurse); diff --git a/include/wx/gtk1/notebook.h b/include/wx/gtk1/notebook.h index 3481d3016c..d8c772d7a0 100644 --- a/include/wx/gtk1/notebook.h +++ b/include/wx/gtk1/notebook.h @@ -130,6 +130,9 @@ public: void OnNavigationKey(wxNavigationKeyEvent& event); + // overridden from wxWindow to make tabbing work + void SetFocus(); + // implementation void SetConstraintSizes(bool recurse); diff --git a/include/wx/mstream.h b/include/wx/mstream.h index 61a9df7eff..7a71e8059a 100644 --- a/include/wx/mstream.h +++ b/include/wx/mstream.h @@ -11,7 +11,7 @@ #ifndef _WX_WXMMSTREAM_H__ #define _WX_WXMMSTREAM_H__ -#include +#include "wx/stream.h" #if wxUSE_STREAMS diff --git a/include/wx/serbase.h b/include/wx/serbase.h index 2b22998a44..1ec7b6a52d 100644 --- a/include/wx/serbase.h +++ b/include/wx/serbase.h @@ -11,8 +11,8 @@ #ifndef _WX_WX_SERBASEH_H__ #define _WX_WX_SERBASEH_H__ -#include -#include +#include "wx/setup.h" +#include "wx/dynlib.h" #define WXSERIAL(classname) classname##_Serialize diff --git a/include/wx/socket.h b/include/wx/socket.h index 762e01c863..496f5a47de 100644 --- a/include/wx/socket.h +++ b/include/wx/socket.h @@ -24,13 +24,13 @@ // wxSocket headers (generic) // --------------------------------------------------------------------------- #ifdef WXPREC -# include +# include "wx/wxprec.h" #else -# include -# include +# include "wx/event.h" +# include "wx/string.h" #endif -#include +#include "wx/sckaddr.h" #include "wx/gsocket.h" class WXDLLEXPORT wxTimer; diff --git a/include/wx/thread.h b/include/wx/thread.h index 7e0dc5997f..fc734e6878 100644 --- a/include/wx/thread.h +++ b/include/wx/thread.h @@ -352,7 +352,7 @@ void WXDLLEXPORT wxMutexGuiLeave(); #else // !wxUSE_THREADS -#include // for WXDLLEXPORT +#include "wx/defs.h" // for WXDLLEXPORT // no thread support inline void WXDLLEXPORT wxMutexGuiEnter() { } diff --git a/include/wx/txtstrm.h b/include/wx/txtstrm.h index 5586707252..aa2378fb52 100644 --- a/include/wx/txtstrm.h +++ b/include/wx/txtstrm.h @@ -16,7 +16,7 @@ #pragma interface "txtstrm.h" #endif -#include +#include "wx/stream.h" #if wxUSE_STREAMS @@ -73,6 +73,8 @@ class WXDLLEXPORT wxTextOutputStream { wxOutputStream *m_output; }; +wxTextOutputStream &endl( wxTextOutputStream &stream ); + #endif // wxUSE_STREAMS diff --git a/include/wx/wfstream.h b/include/wx/wfstream.h index 1ab45426e1..33217d75b5 100644 --- a/include/wx/wfstream.h +++ b/include/wx/wfstream.h @@ -20,10 +20,10 @@ #if wxUSE_STREAMS && wxUSE_FILE -#include -#include -#include -#include +#include "wx/object.h" +#include "wx/string.h" +#include "wx/stream.h" +#include "wx/file.h" class wxFileInputStream: public wxInputStream { public: diff --git a/include/wx/zstream.h b/include/wx/zstream.h index b1cb0f4760..fa65ee7f4e 100644 --- a/include/wx/zstream.h +++ b/include/wx/zstream.h @@ -19,7 +19,7 @@ #if wxUSE_ZLIB && wxUSE_STREAMS -#include +#include "wx/stream.h" class WXDLLEXPORT wxZlibInputStream: public wxFilterInputStream { public: diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index ed3755f463..85d378f766 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -384,7 +384,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) button->SetToolTip( "Press here to set italic font" ); #endif // wxUSE_TOOLTIPS - m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "&Disable", wxPoint(20,130), wxSize(-1, -1), wxALIGN_RIGHT ); + m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "&Disable", wxPoint(20,130) ); m_checkbox->SetValue(FALSE); #if wxUSE_TOOLTIPS m_checkbox->SetToolTip( "Click here to disable the listbox" ); diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index fe0d694bbc..bf92673cbe 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -271,7 +271,7 @@ void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) ) void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) ) { - wxFileDialog dialog(this, "Testing save file dialog", "", "", + wxFileDialog dialog(this, "Testing save file dialog", "", "myletter.txt", "Text files (*.txt)|*.txt|Document files (*.doc)|*.doc", wxSAVE|wxOVERWRITE_PROMPT); diff --git a/src/common/image.cpp b/src/common/image.cpp index 7478392fe2..ac9acecf15 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -300,7 +300,20 @@ void wxImage::SetData( char unsigned *data ) { wxCHECK_RET( Ok(), _T("invalid image") ); - memcpy(M_IMGDATA->m_data, data, M_IMGDATA->m_width * M_IMGDATA->m_height * 3); + wxImageRefData *newRefData = new wxImageRefData(); + + newRefData->m_width = M_IMGDATA->m_width; + newRefData->m_height = M_IMGDATA->m_height; + newRefData->m_data = data; + newRefData->m_ok = TRUE; + newRefData->m_maskRed = M_IMGDATA->m_maskRed; + newRefData->m_maskGreen = M_IMGDATA->m_maskGreen; + newRefData->m_maskBlue = M_IMGDATA->m_maskBlue; + newRefData->m_hasMask = M_IMGDATA->m_hasMask; + + UnRef(); + + m_refData = newRefData; } void wxImage::SetMaskColour( unsigned char r, unsigned char g, unsigned char b ) diff --git a/src/common/intl.cpp b/src/common/intl.cpp index ec2362d7e8..3dd7a175ad 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -40,6 +40,7 @@ #include "wx/intl.h" #include "wx/file.h" #include "wx/log.h" +#include "wx/debug.h" #include "wx/utils.h" #include @@ -337,20 +338,22 @@ bool wxMsgCatalog::Load(const wxChar *szDirPrefix, const wxChar *szName0) // not yet be loaded (and it's normal) // // (we're using an object because we have several return paths) + NoTransErr noTransErr; +// Then why do you translate at all? Just use _T() and not _(). RR. wxLogVerbose(_("looking for catalog '%s' in path '%s'."), - szName, searchPath.c_str()); + szName.c_str, searchPath.c_str()); wxString strFullName; if ( !wxFindFileInPath(&strFullName, searchPath, strFile) ) { - wxLogWarning(_("catalog file for domain '%s' not found."), szName); + wxLogWarning(_("catalog file for domain '%s' not found."), szName.c_str()); return FALSE; } // open file wxLogVerbose(_("using catalog '%s' from '%s'."), - szName, strFullName.c_str()); + szName.c_str(), strFullName.c_str()); wxFile fileMsg(strFullName); if ( !fileMsg.IsOpened() ) diff --git a/src/common/txtstrm.cpp b/src/common/txtstrm.cpp index 70ca315e43..3a236e7f23 100644 --- a/src/common/txtstrm.cpp +++ b/src/common/txtstrm.cpp @@ -477,5 +477,10 @@ wxTextOutputStream& wxTextOutputStream::operator<<(float f) return *this; } +wxTextOutputStream &endl( wxTextOutputStream &stream ) +{ + return stream << _T('\n'); +} + #endif // wxUSE_STREAMS diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index 39642ac8dd..b4c5e885fe 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -670,8 +670,11 @@ wxFileDialog::wxFileDialog(wxWindow *parent, mainsizer->SetSizeHints( this ); Centre( wxBOTH ); - - m_list->SetFocus(); + + if (m_fileName.IsEmpty()) + m_list->SetFocus(); + else + m_text->SetFocus(); wxEndBusyCursor(); } @@ -723,6 +726,24 @@ void wxFileDialog::OnListOk( wxCommandEvent &event ) return; } + if (filename == _T("~")) + { + m_list->GoToHomeDir(); + m_list->SetFocus(); + m_list->GetDir( dir ); + m_static->SetLabel( dir ); + return; + } + + if (filename[0] == _T('~')) + { + filename.Remove( 0, 1 ); + wxString tmp( wxGetUserHome() ); + tmp += _T('/'); + tmp += filename; + filename = tmp; + } + if ((filename.Find(_T('*')) != wxNOT_FOUND) || (filename.Find(_T('?')) != wxNOT_FOUND)) { @@ -736,13 +757,19 @@ void wxFileDialog::OnListOk( wxCommandEvent &event ) } if (dir != _T("/")) dir += _T("/"); - dir += filename; - filename = dir; + if (filename[0] != _T('/')) + { + dir += filename; + filename = dir; + } if (wxDirExists(filename)) { m_list->GoToDir( filename ); - m_text->SetValue( _T("..") ); + if (filename == _T("/")) + m_text->SetValue( _T("") ); + else + m_text->SetValue( _T("..") ); m_list->GetDir( dir ); m_static->SetLabel( dir ); return; diff --git a/src/generic/notebook.cpp b/src/generic/notebook.cpp index 3b18a3ce2a..a398e2a546 100644 --- a/src/generic/notebook.cpp +++ b/src/generic/notebook.cpp @@ -27,12 +27,12 @@ #pragma hdrstop #endif -#include -#include -#include -#include -#include -#include +#include "wx/string.h" +#include "wx/log.h" +#include "wx/settings.h" +#include "wx/generic/imaglist.h" +#include "wx/notebook.h" +#include "wx/dcclient.h" // ---------------------------------------------------------------------------- // macros diff --git a/src/generic/panelg.cpp b/src/generic/panelg.cpp index a37cabb6ed..2ed8f5148c 100644 --- a/src/generic/panelg.cpp +++ b/src/generic/panelg.cpp @@ -101,7 +101,7 @@ void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event ) wxWindow *winFocus = event.GetCurrentFocus(); if (!winFocus) winFocus = wxWindow::FindFocus(); - + if (!winFocus) { event.Skip(); @@ -126,14 +126,16 @@ void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event ) // so give them the chance to process it instead of looping inside // this panel (normally, the focus will go to the next/previous // item after this panel in the parent panel) + wxWindow *focussed_child_of_p = this; for ( wxWindow *p = GetParent(); p; p = p->GetParent() ) { if ( wxDynamicCast(p, wxPanel) ) { - event.Skip(); - - return; + event.SetCurrentFocus( focussed_child_of_p ); + if (p->GetEventHandler()->ProcessEvent( event )) + return; } + focussed_child_of_p = p; } // no, we are not inside another panel so process this ourself diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 6cac1f9135..aa910af6ed 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -127,43 +127,6 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* if (win->GetAutoLayout()) win->Layout(); } -//----------------------------------------------------------------------------- -// "key_press_event" -//----------------------------------------------------------------------------- - -static gint -gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *notebook ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (g_blockEventsOnDrag) return FALSE; - - if (!notebook->m_hasVMT) return FALSE; - - /* this code makes jumping down from the handles of the notebooks - to the actual items in the visible notebook page possible with - the down-arrow key */ - - if (gdk_event->keyval != GDK_Down) return FALSE; - - if (notebook != notebook->FindFocus()) return FALSE; - - if (notebook->m_pages.GetCount() == 0) return FALSE; - - wxNode *node = notebook->m_pages.Nth( notebook->GetSelection() ); - - if (!node) return FALSE; - - wxNotebookPage *page = (wxNotebookPage*) node->Data(); - - // don't let others the key event - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); - - page->m_client->SetFocus(); - - return TRUE; -} - //----------------------------------------------------------------------------- // InsertChild callback for wxNotebook //----------------------------------------------------------------------------- @@ -241,9 +204,6 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id, m_parent->DoAddChild( this ); - gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event", - GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this ); - PostCreation(); Show( TRUE ); @@ -251,6 +211,19 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id, return TRUE; } +void wxNotebook::SetFocus() +{ + if (m_pages.GetCount() == 0) return; + + wxNode *node = m_pages.Nth( GetSelection() ); + + if (!node) return; + + wxNotebookPage *page = (wxNotebookPage*) node->Data(); + + page->m_client->SetFocus(); +} + int wxNotebook::GetSelection() const { wxCHECK_MSG( m_widget != NULL, -1, _T("invalid notebook") ); @@ -284,7 +257,7 @@ wxString wxNotebook::GetPageText( int page ) const if (nb_page) return nb_page->m_text; else - return ""; + return _T(""); } int wxNotebook::GetPageImage( int page ) const diff --git a/src/gtk/stattext.cpp b/src/gtk/stattext.cpp index af8c6a1063..42938260a3 100644 --- a/src/gtk/stattext.cpp +++ b/src/gtk/stattext.cpp @@ -98,7 +98,7 @@ bool wxStaticText::Create(wxWindow *parent, return TRUE; } -wxString wxStaticText::GetLabel(void) const +wxString wxStaticText::GetLabel() const { char *str = (char *) NULL; gtk_label_get( GTK_LABEL(m_widget), &str ); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index fa872fc36f..93a1debab4 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -812,7 +812,6 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e ret = (ret || win->GetEventHandler()->ProcessEvent( event2 )); } - /* win is a control: tab can be propagated up */ if ( (!ret) && ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) && diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index 6cac1f9135..aa910af6ed 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -127,43 +127,6 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* if (win->GetAutoLayout()) win->Layout(); } -//----------------------------------------------------------------------------- -// "key_press_event" -//----------------------------------------------------------------------------- - -static gint -gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *notebook ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (g_blockEventsOnDrag) return FALSE; - - if (!notebook->m_hasVMT) return FALSE; - - /* this code makes jumping down from the handles of the notebooks - to the actual items in the visible notebook page possible with - the down-arrow key */ - - if (gdk_event->keyval != GDK_Down) return FALSE; - - if (notebook != notebook->FindFocus()) return FALSE; - - if (notebook->m_pages.GetCount() == 0) return FALSE; - - wxNode *node = notebook->m_pages.Nth( notebook->GetSelection() ); - - if (!node) return FALSE; - - wxNotebookPage *page = (wxNotebookPage*) node->Data(); - - // don't let others the key event - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); - - page->m_client->SetFocus(); - - return TRUE; -} - //----------------------------------------------------------------------------- // InsertChild callback for wxNotebook //----------------------------------------------------------------------------- @@ -241,9 +204,6 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id, m_parent->DoAddChild( this ); - gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event", - GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this ); - PostCreation(); Show( TRUE ); @@ -251,6 +211,19 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id, return TRUE; } +void wxNotebook::SetFocus() +{ + if (m_pages.GetCount() == 0) return; + + wxNode *node = m_pages.Nth( GetSelection() ); + + if (!node) return; + + wxNotebookPage *page = (wxNotebookPage*) node->Data(); + + page->m_client->SetFocus(); +} + int wxNotebook::GetSelection() const { wxCHECK_MSG( m_widget != NULL, -1, _T("invalid notebook") ); @@ -284,7 +257,7 @@ wxString wxNotebook::GetPageText( int page ) const if (nb_page) return nb_page->m_text; else - return ""; + return _T(""); } int wxNotebook::GetPageImage( int page ) const diff --git a/src/gtk1/stattext.cpp b/src/gtk1/stattext.cpp index af8c6a1063..42938260a3 100644 --- a/src/gtk1/stattext.cpp +++ b/src/gtk1/stattext.cpp @@ -98,7 +98,7 @@ bool wxStaticText::Create(wxWindow *parent, return TRUE; } -wxString wxStaticText::GetLabel(void) const +wxString wxStaticText::GetLabel() const { char *str = (char *) NULL; gtk_label_get( GTK_LABEL(m_widget), &str ); diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index fa872fc36f..93a1debab4 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -812,7 +812,6 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e ret = (ret || win->GetEventHandler()->ProcessEvent( event2 )); } - /* win is a control: tab can be propagated up */ if ( (!ret) && ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) && -- 2.47.2