From e3e65dac0c4e7ad19e3c270caa1e0eea138e5d8d Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 27 Jul 1998 20:50:48 +0000 Subject: [PATCH] warning msgs toolbar updates mdi fixes dnd works now Forty Thieves drawing optimization wxDF_Text constants ListCtrl bugs fixed memory leak work imrc now refers to home dir dcclient/memory leak fixed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@381 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/defs.h | 24 +-- include/wx/generic/listctrl.h | 7 +- include/wx/gtk/dnd.h | 204 +++++++++++++++++---- include/wx/gtk/frame.h | 7 +- include/wx/gtk/listbox.h | 2 + include/wx/gtk/mdi.h | 1 + include/wx/gtk/notebook.h | 1 - include/wx/gtk/tbargtk.h | 2 +- include/wx/gtk/textctrl.h | 2 + include/wx/gtk/window.h | 6 +- include/wx/gtk1/dnd.h | 204 +++++++++++++++++---- include/wx/gtk1/frame.h | 7 +- include/wx/gtk1/listbox.h | 2 + include/wx/gtk1/mdi.h | 1 + include/wx/gtk1/notebook.h | 1 - include/wx/gtk1/tbargtk.h | 2 +- include/wx/gtk1/textctrl.h | 2 + include/wx/gtk1/window.h | 6 +- include/wx/ipcbase.h | 10 +- include/wx/object.h | 2 +- misc/imlib/imrc | 2 +- samples/dnd/Makefile | 1 + samples/dnd/Makefile.in | 26 +++ samples/dnd/dnd.cpp | 17 +- samples/docview/docview.cpp | 2 +- samples/docview/view.cpp | 20 ++- samples/dynamic/minimal.cpp | 3 +- samples/forty/canvas.cpp | 1 + samples/forty/card.cpp | 12 +- samples/forty/pile.cpp | 22 ++- samples/mdi/mdi.cpp | 13 +- samples/memcheck/memcheck.cpp | 2 +- samples/minimal/minimal.cpp | 3 +- samples/png/pngdemo.cpp | 8 +- samples/printing/printing.cpp | 57 +++--- samples/splitter/test.cpp | 8 +- samples/tab/test.cpp | 10 +- samples/thread/test.cpp | 12 +- samples/toolbar/Makefile | 1 + samples/toolbar/Makefile.in | 26 +++ samples/treectrl/treetest.cpp | 28 +-- src/common/zstream.cpp | 2 +- src/generic/gridg.cpp | 2 +- src/generic/listctrl.cpp | 44 +++-- src/gtk/dcclient.cpp | 15 ++ src/gtk/dnd.cpp | 192 ++++++++++++++------ src/gtk/frame.cpp | 26 ++- src/gtk/gauge.cpp | 2 - src/gtk/listbox.cpp | 8 + src/gtk/mdi.cpp | 31 ++++ src/gtk/notebook.cpp | 13 +- src/gtk/tbargtk.cpp | 2 +- src/gtk/textctrl.cpp | 8 + src/gtk/utilsgtk.cpp | 2 +- src/gtk/window.cpp | 66 ++++--- src/gtk1/dcclient.cpp | 15 ++ src/gtk1/dnd.cpp | 192 ++++++++++++++------ src/gtk1/frame.cpp | 26 ++- src/gtk1/gauge.cpp | 2 - src/gtk1/listbox.cpp | 8 + src/gtk1/mdi.cpp | 31 ++++ src/gtk1/notebook.cpp | 13 +- src/gtk1/tbargtk.cpp | 2 +- src/gtk1/textctrl.cpp | 8 + src/gtk1/utilsgtk.cpp | 2 +- src/gtk1/window.cpp | 66 ++++--- src/iodbc/hdbc.c | 8 +- src/iodbc/hstmt.c | 2 +- user/wxFile/FMJobs.cpp | 326 ++++++++++++++++++++++++++++++++++ user/wxFile/FMJobs.h | 143 +++++++++++++++ user/wxFile/Makefile.in | 4 +- user/wxFile/dirctrl.cpp | 34 +--- user/wxFile/dirctrl.h | 1 - user/wxFile/filectrl.cpp | 15 +- user/wxFile/filectrl.h | 3 + user/wxFile/wxFile.cpp | 7 +- 76 files changed, 1634 insertions(+), 454 deletions(-) create mode 100644 samples/dnd/Makefile create mode 100644 samples/dnd/Makefile.in create mode 100644 samples/toolbar/Makefile create mode 100644 samples/toolbar/Makefile.in create mode 100644 user/wxFile/FMJobs.cpp create mode 100644 user/wxFile/FMJobs.h diff --git a/include/wx/defs.h b/include/wx/defs.h index 4dc564eae3..6734839262 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -680,15 +680,22 @@ typedef enum { // Don't do parent client adjustments (for implementation only) #define wxSIZE_NO_ADJUSTMENTS 0x0008 -// Clipboard formats -// Numbers as per winuser.h -# define wxCF_TEXT 1 /* CF_TEXT */ -# define wxCF_BITMAP 2 /* CF_BITMAP */ -# define wxCF_METAFILE 3 /* CF_METAFILEPICT */ -# define wxCF_DIB 8 /* CF_DIB */ -# define wxCF_OEMTEXT 7 /* CF_OEMTEXT */ + +// Data format for drag & drop and clipboard operations +// numbers as per winuser.h + +enum wxDataFormat +{ + wxDF_TEXT = 1, /* CF_TEXT */ + wxDF_BITMAP = 2, /* CF_BITMAP */ + wxDF_METAFILE = 3, /* CF_METAFILEPICT */ + wxDF_DIB = 8, /* CF_DIB */ + wxDF_OEMTEXT = 7, /* CF_OEMTEXT */ + wxDF_FILENAME = 15 /* CF_HDROP */ +}; // Virtual keycodes + enum _Virtual_keycodes { WXK_BACK = 8, WXK_TAB = 9, @@ -872,8 +879,5 @@ typedef int (*WXFARPROC)(); #endif -// for drag & drop and clipboard operations -typedef unsigned short wxDataFormat; - #endif // __WXDEFSH__ diff --git a/include/wx/generic/listctrl.h b/include/wx/generic/listctrl.h index 39f7c11319..e38c503ea8 100644 --- a/include/wx/generic/listctrl.h +++ b/include/wx/generic/listctrl.h @@ -475,7 +475,7 @@ class wxListMainWindow: public wxScrolledWindow bool m_renameAccept; wxString m_renameRes; bool m_isCreated; - bool m_isDragging; + int m_dragCount; public: wxListMainWindow(void); @@ -524,6 +524,7 @@ class wxListMainWindow: public wxScrolledWindow int GetItemState( long item, long stateMask ); int GetItemCount( void ); void GetItemRect( long index, wxRectangle &rect ); + bool GetItemPosition(long item, wxPoint& pos); int GetSelectedItemCount( void ); void SetMode( long mode ); long GetMode( void ) const; @@ -582,8 +583,8 @@ class wxListCtrl: public wxControl void SetItemText( long item, const wxString& str ); long GetItemData( long item ); bool SetItemData( long item, long data ); - bool GetItemRect( long item, wxRectangle& rect, int code = wxLIST_RECT_BOUNDS ); // not supported in wxGLC - bool GetItemPosition( long item, wxPoint& pos ) const; // not supported in wxGLC + bool GetItemRect( long item, wxRectangle& rect, int code = wxLIST_RECT_BOUNDS ); + bool GetItemPosition( long item, wxPoint& pos ); bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC int GetItemCount(void); void SetItemSpacing( int spacing, bool isSmall = FALSE ); diff --git a/include/wx/gtk/dnd.h b/include/wx/gtk/dnd.h index 1ce3e29040..2c2a0f5338 100644 --- a/include/wx/gtk/dnd.h +++ b/include/wx/gtk/dnd.h @@ -26,11 +26,119 @@ class wxWindow; +class wxDataObject; +class wxTextDataObject; +class wxFileDataObject; + class wxDropTarget; class wxTextDropTarget; -class wxDragSource; -class wxTextDragSource; +class wxFileDropTarget; + +class wxDropSource; + +//------------------------------------------------------------------------- +// wxDataObject +//------------------------------------------------------------------------- + +class wxDataObject: public wxObject +{ +public: + // all data formats (values are the same as in windows.h, do not change!) + enum StdFormat + { + Invalid, + Text, + Bitmap, + MetafilePict, + Sylk, + Dif, + Tiff, + OemText, + Dib, + Palette, + Pendata, + Riff, + Wave, + UnicodeText, + EnhMetafile, + Hdrop, + Locale, + Max + }; + + // function to return symbolic name of clipboard format (debug messages) + static const char *GetFormatName(wxDataFormat format); + + // ctor & dtor + wxDataObject() {}; + ~wxDataObject() {}; + + // pure virtuals to override + // get the best suited format for our data + virtual wxDataFormat GetPreferredFormat() const = 0; + // decide if we support this format (should be one of values of + // StdFormat enumerations or a user-defined format) + virtual bool IsSupportedFormat(wxDataFormat format) const = 0; + // get the (total) size of data + virtual uint GetDataSize() const = 0; + // copy raw data to provided pointer + virtual void GetDataHere(void *pBuf) const = 0; + +}; + +// ---------------------------------------------------------------------------- +// wxTextDataObject is a specialization of wxDataObject for text data +// ---------------------------------------------------------------------------- + +class wxTextDataObject : public wxDataObject +{ +public: + // ctors + wxTextDataObject() { } + wxTextDataObject(const wxString& strText) : m_strText(strText) { } + void Init(const wxString& strText) { m_strText = strText; } + + // implement base class pure virtuals + virtual wxDataFormat GetPreferredFormat() const + { return wxDF_TEXT; } + virtual bool IsSupportedFormat(wxDataFormat format) const + { return format == wxDF_TEXT; } + virtual uint GetDataSize() const + { return m_strText.Len() + 1; } // +1 for trailing '\0'of course + virtual void GetDataHere(void *pBuf) const + { memcpy(pBuf, m_strText.c_str(), GetDataSize()); } + +private: + wxString m_strText; + +}; +// ---------------------------------------------------------------------------- +// wxFileDataObject is a specialization of wxDataObject for file names +// ---------------------------------------------------------------------------- + +class wxFileDataObject : public wxDataObject +{ +public: + + wxFileDataObject(void) { } + void AddFile( const wxString &file ) + { m_files += file; m_files += ";"; } + + // implement base class pure virtuals + virtual wxDataFormat GetPreferredFormat() const + { return wxDF_FILENAME; } + virtual bool IsSupportedFormat(wxDataFormat format) const + { return format == wxDF_FILENAME; } + virtual uint GetDataSize() const + { return m_files.Len() + 1; } // +1 for trailing '\0'of course + virtual void GetDataHere(void *pBuf) const + { memcpy(pBuf, m_files.c_str(), GetDataSize()); } + +private: + wxString m_files; + +}; //------------------------------------------------------------------------- // wxDropTarget //------------------------------------------------------------------------- @@ -41,14 +149,22 @@ class wxDropTarget: public wxObject wxDropTarget(); ~wxDropTarget(); + virtual void OnEnter() { } virtual void OnLeave() { } virtual bool OnDrop( long x, long y, const void *pData ) = 0; - public: - +// protected: + + friend wxWindow; + + // Override these to indicate what kind of data you support: + + virtual size_t GetFormatCount() const = 0; + virtual wxDataFormat GetFormat(size_t n) const = 0; + void Drop( GdkEvent *event, int x, int y ); - virtual void RegisterWidget( GtkWidget *widget ) = 0; + void RegisterWidget( GtkWidget *widget ); void UnregisterWidget( GtkWidget *widget ); }; @@ -63,52 +179,72 @@ class wxTextDropTarget: public wxDropTarget wxTextDropTarget() {}; virtual bool OnDrop( long x, long y, const void *pData ); virtual bool OnDropText( long x, long y, const char *psz ); - virtual void RegisterWidget( GtkWidget *widget ); + + protected: + + virtual size_t GetFormatCount() const; + virtual wxDataFormat GetFormat(size_t n) const; }; -//------------------------------------------------------------------------- -// wxDragSource -//------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- +// A drop target which accepts files (dragged from File Manager or Explorer) +// ---------------------------------------------------------------------------- -class wxDragSource: public wxObject +class wxFileDropTarget: public wxDropTarget { public: + + wxFileDropTarget() {}; + + virtual bool OnDrop(long x, long y, const void *pData); + virtual bool OnDropFiles( long x, long y, + size_t nFiles, const char * const aszFiles[]); - wxDragSource( wxWindow *win ); - ~wxDragSource(void); - void SetData( char *data, long size ); - void Start( int x, int y ); - - public: - - void ConnectWindow(void); - void UnconnectWindow(void); - virtual void RegisterWindow(void) = 0; - void UnregisterWindow(void); + protected: - GtkWidget *m_widget; - wxWindow *m_window; - char *m_data; - long m_size; - wxCursor m_defaultCursor; - wxCursor m_goaheadCursor; + virtual size_t GetFormatCount() const; + virtual wxDataFormat GetFormat(size_t n) const; }; //------------------------------------------------------------------------- -// wxTextDragSource +// wxDropSource //------------------------------------------------------------------------- -class wxTextDragSource: public wxDragSource +class wxDropSource: public wxObject { public: - wxTextDragSource( wxWindow *win ) : wxDragSource(win) {}; - void SetTextData( const wxString &text ); - void RegisterWindow(void); + enum DragResult + { + Error, // error prevented the d&d operation from completing + None, // drag target didn't accept the data + Copy, // the data was successfully copied + Move, // the data was successfully moved + Cancel // the operation was cancelled by user (not an error) + }; + + wxDropSource( wxWindow *win ); + wxDropSource( wxDataObject &data, wxWindow *win ); + + ~wxDropSource(void); - private: + void SetData( wxDataObject &data ); + DragResult DoDragDrop( bool bAllowMove = FALSE ); + + virtual bool GiveFeedback( DragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; }; + + protected: - wxString m_tmp; + void RegisterWindow(void); + void UnregisterWindow(void); + + GtkWidget *m_widget; + wxWindow *m_window; + + wxDataObject *m_data; + + wxCursor m_defaultCursor; + wxCursor m_goaheadCursor; }; #endif diff --git a/include/wx/gtk/frame.h b/include/wx/gtk/frame.h index 47f7037e0c..f0fd76b885 100644 --- a/include/wx/gtk/frame.h +++ b/include/wx/gtk/frame.h @@ -64,13 +64,14 @@ public: // set minimal/maxmimal size for the frame virtual void SetSizeHints( int minW, int minH, int maxW, int maxH, int incW = -1 ); - virtual bool CreateStatusBar( int number = 1 ); + virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, + const wxString& name = "statusBar"); virtual wxStatusBar *GetStatusBar(); virtual void SetStatusText( const wxString &text, int number = 0 ); virtual void SetStatusWidths( int n, int *width ); - virtual wxToolBar *CreateToolBar( int style = 0, - int orientation = wxHORIZONTAL, int rowsOrColumns = 1 ); + virtual wxToolBar* CreateToolBar( long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, + const wxString& name = wxToolBarNameStr); virtual wxToolBar *GetToolBar(); virtual void SetMenuBar( wxMenuBar *menuBar ); diff --git a/include/wx/gtk/listbox.h b/include/wx/gtk/listbox.h index ee3332ba2e..fa14d3d609 100644 --- a/include/wx/gtk/listbox.h +++ b/include/wx/gtk/listbox.h @@ -73,6 +73,8 @@ class wxListBox: public wxControl void SetString( int n, const wxString &string ); void SetStringSelection( const wxString &string, bool select = TRUE ); + virtual GtkWidget *GetDropTargetWidget(void); + private: GtkList *m_list; diff --git a/include/wx/gtk/mdi.h b/include/wx/gtk/mdi.h index 4a4aadf0bc..b53e87c26f 100644 --- a/include/wx/gtk/mdi.h +++ b/include/wx/gtk/mdi.h @@ -129,6 +129,7 @@ class wxMDIChildFrame: public wxPanel bool Destroy(void); void OnCloseWindow( wxCloseEvent& event ); + void OnSize( wxSizeEvent &event ); public: diff --git a/include/wx/gtk/notebook.h b/include/wx/gtk/notebook.h index 1f8148d18c..a30a9d6ba0 100644 --- a/include/wx/gtk/notebook.h +++ b/include/wx/gtk/notebook.h @@ -156,7 +156,6 @@ private: uint m_idHandler; // the change page handler id DECLARE_DYNAMIC_CLASS(wxNotebook) - DECLARE_EVENT_TABLE() }; // ---------------------------------------------------------------------------- diff --git a/include/wx/gtk/tbargtk.h b/include/wx/gtk/tbargtk.h index 19b59ff9d2..0c33e408b9 100644 --- a/include/wx/gtk/tbargtk.h +++ b/include/wx/gtk/tbargtk.h @@ -113,7 +113,7 @@ class wxToolBar: public wxControl virtual void AddSeparator(void); virtual void ClearTools(void); - virtual void Layout(void); + virtual void Realize(void); virtual void EnableTool(int toolIndex, bool enable); virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on diff --git a/include/wx/gtk/textctrl.h b/include/wx/gtk/textctrl.h index 99f76a3305..797c61bc7f 100644 --- a/include/wx/gtk/textctrl.h +++ b/include/wx/gtk/textctrl.h @@ -99,6 +99,8 @@ public: wxTextCtrl& operator<<(double d); wxTextCtrl& operator<<(const char c); + virtual GtkWidget* GetDropTargetWidget(void); + private: bool m_modified; diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index aaa887c9d6..91a20f9496 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -167,7 +167,10 @@ public: virtual void SetDropTarget( wxDropTarget *dropTarget ); virtual wxDropTarget *GetDropTarget() const; - +private: + virtual GtkWidget* GetDropTargetWidget(void); + +public: virtual void SetScrollbar( int orient, int pos, int thumbVisible, int range, bool refresh = TRUE ); virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ); @@ -182,6 +185,7 @@ public: // update the UI state (called from OnIdle) void UpdateWindowUI(); + public: // cannot get private going yet void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos, diff --git a/include/wx/gtk1/dnd.h b/include/wx/gtk1/dnd.h index 1ce3e29040..2c2a0f5338 100644 --- a/include/wx/gtk1/dnd.h +++ b/include/wx/gtk1/dnd.h @@ -26,11 +26,119 @@ class wxWindow; +class wxDataObject; +class wxTextDataObject; +class wxFileDataObject; + class wxDropTarget; class wxTextDropTarget; -class wxDragSource; -class wxTextDragSource; +class wxFileDropTarget; + +class wxDropSource; + +//------------------------------------------------------------------------- +// wxDataObject +//------------------------------------------------------------------------- + +class wxDataObject: public wxObject +{ +public: + // all data formats (values are the same as in windows.h, do not change!) + enum StdFormat + { + Invalid, + Text, + Bitmap, + MetafilePict, + Sylk, + Dif, + Tiff, + OemText, + Dib, + Palette, + Pendata, + Riff, + Wave, + UnicodeText, + EnhMetafile, + Hdrop, + Locale, + Max + }; + + // function to return symbolic name of clipboard format (debug messages) + static const char *GetFormatName(wxDataFormat format); + + // ctor & dtor + wxDataObject() {}; + ~wxDataObject() {}; + + // pure virtuals to override + // get the best suited format for our data + virtual wxDataFormat GetPreferredFormat() const = 0; + // decide if we support this format (should be one of values of + // StdFormat enumerations or a user-defined format) + virtual bool IsSupportedFormat(wxDataFormat format) const = 0; + // get the (total) size of data + virtual uint GetDataSize() const = 0; + // copy raw data to provided pointer + virtual void GetDataHere(void *pBuf) const = 0; + +}; + +// ---------------------------------------------------------------------------- +// wxTextDataObject is a specialization of wxDataObject for text data +// ---------------------------------------------------------------------------- + +class wxTextDataObject : public wxDataObject +{ +public: + // ctors + wxTextDataObject() { } + wxTextDataObject(const wxString& strText) : m_strText(strText) { } + void Init(const wxString& strText) { m_strText = strText; } + + // implement base class pure virtuals + virtual wxDataFormat GetPreferredFormat() const + { return wxDF_TEXT; } + virtual bool IsSupportedFormat(wxDataFormat format) const + { return format == wxDF_TEXT; } + virtual uint GetDataSize() const + { return m_strText.Len() + 1; } // +1 for trailing '\0'of course + virtual void GetDataHere(void *pBuf) const + { memcpy(pBuf, m_strText.c_str(), GetDataSize()); } + +private: + wxString m_strText; + +}; +// ---------------------------------------------------------------------------- +// wxFileDataObject is a specialization of wxDataObject for file names +// ---------------------------------------------------------------------------- + +class wxFileDataObject : public wxDataObject +{ +public: + + wxFileDataObject(void) { } + void AddFile( const wxString &file ) + { m_files += file; m_files += ";"; } + + // implement base class pure virtuals + virtual wxDataFormat GetPreferredFormat() const + { return wxDF_FILENAME; } + virtual bool IsSupportedFormat(wxDataFormat format) const + { return format == wxDF_FILENAME; } + virtual uint GetDataSize() const + { return m_files.Len() + 1; } // +1 for trailing '\0'of course + virtual void GetDataHere(void *pBuf) const + { memcpy(pBuf, m_files.c_str(), GetDataSize()); } + +private: + wxString m_files; + +}; //------------------------------------------------------------------------- // wxDropTarget //------------------------------------------------------------------------- @@ -41,14 +149,22 @@ class wxDropTarget: public wxObject wxDropTarget(); ~wxDropTarget(); + virtual void OnEnter() { } virtual void OnLeave() { } virtual bool OnDrop( long x, long y, const void *pData ) = 0; - public: - +// protected: + + friend wxWindow; + + // Override these to indicate what kind of data you support: + + virtual size_t GetFormatCount() const = 0; + virtual wxDataFormat GetFormat(size_t n) const = 0; + void Drop( GdkEvent *event, int x, int y ); - virtual void RegisterWidget( GtkWidget *widget ) = 0; + void RegisterWidget( GtkWidget *widget ); void UnregisterWidget( GtkWidget *widget ); }; @@ -63,52 +179,72 @@ class wxTextDropTarget: public wxDropTarget wxTextDropTarget() {}; virtual bool OnDrop( long x, long y, const void *pData ); virtual bool OnDropText( long x, long y, const char *psz ); - virtual void RegisterWidget( GtkWidget *widget ); + + protected: + + virtual size_t GetFormatCount() const; + virtual wxDataFormat GetFormat(size_t n) const; }; -//------------------------------------------------------------------------- -// wxDragSource -//------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- +// A drop target which accepts files (dragged from File Manager or Explorer) +// ---------------------------------------------------------------------------- -class wxDragSource: public wxObject +class wxFileDropTarget: public wxDropTarget { public: + + wxFileDropTarget() {}; + + virtual bool OnDrop(long x, long y, const void *pData); + virtual bool OnDropFiles( long x, long y, + size_t nFiles, const char * const aszFiles[]); - wxDragSource( wxWindow *win ); - ~wxDragSource(void); - void SetData( char *data, long size ); - void Start( int x, int y ); - - public: - - void ConnectWindow(void); - void UnconnectWindow(void); - virtual void RegisterWindow(void) = 0; - void UnregisterWindow(void); + protected: - GtkWidget *m_widget; - wxWindow *m_window; - char *m_data; - long m_size; - wxCursor m_defaultCursor; - wxCursor m_goaheadCursor; + virtual size_t GetFormatCount() const; + virtual wxDataFormat GetFormat(size_t n) const; }; //------------------------------------------------------------------------- -// wxTextDragSource +// wxDropSource //------------------------------------------------------------------------- -class wxTextDragSource: public wxDragSource +class wxDropSource: public wxObject { public: - wxTextDragSource( wxWindow *win ) : wxDragSource(win) {}; - void SetTextData( const wxString &text ); - void RegisterWindow(void); + enum DragResult + { + Error, // error prevented the d&d operation from completing + None, // drag target didn't accept the data + Copy, // the data was successfully copied + Move, // the data was successfully moved + Cancel // the operation was cancelled by user (not an error) + }; + + wxDropSource( wxWindow *win ); + wxDropSource( wxDataObject &data, wxWindow *win ); + + ~wxDropSource(void); - private: + void SetData( wxDataObject &data ); + DragResult DoDragDrop( bool bAllowMove = FALSE ); + + virtual bool GiveFeedback( DragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; }; + + protected: - wxString m_tmp; + void RegisterWindow(void); + void UnregisterWindow(void); + + GtkWidget *m_widget; + wxWindow *m_window; + + wxDataObject *m_data; + + wxCursor m_defaultCursor; + wxCursor m_goaheadCursor; }; #endif diff --git a/include/wx/gtk1/frame.h b/include/wx/gtk1/frame.h index 47f7037e0c..f0fd76b885 100644 --- a/include/wx/gtk1/frame.h +++ b/include/wx/gtk1/frame.h @@ -64,13 +64,14 @@ public: // set minimal/maxmimal size for the frame virtual void SetSizeHints( int minW, int minH, int maxW, int maxH, int incW = -1 ); - virtual bool CreateStatusBar( int number = 1 ); + virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, + const wxString& name = "statusBar"); virtual wxStatusBar *GetStatusBar(); virtual void SetStatusText( const wxString &text, int number = 0 ); virtual void SetStatusWidths( int n, int *width ); - virtual wxToolBar *CreateToolBar( int style = 0, - int orientation = wxHORIZONTAL, int rowsOrColumns = 1 ); + virtual wxToolBar* CreateToolBar( long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, + const wxString& name = wxToolBarNameStr); virtual wxToolBar *GetToolBar(); virtual void SetMenuBar( wxMenuBar *menuBar ); diff --git a/include/wx/gtk1/listbox.h b/include/wx/gtk1/listbox.h index ee3332ba2e..fa14d3d609 100644 --- a/include/wx/gtk1/listbox.h +++ b/include/wx/gtk1/listbox.h @@ -73,6 +73,8 @@ class wxListBox: public wxControl void SetString( int n, const wxString &string ); void SetStringSelection( const wxString &string, bool select = TRUE ); + virtual GtkWidget *GetDropTargetWidget(void); + private: GtkList *m_list; diff --git a/include/wx/gtk1/mdi.h b/include/wx/gtk1/mdi.h index 4a4aadf0bc..b53e87c26f 100644 --- a/include/wx/gtk1/mdi.h +++ b/include/wx/gtk1/mdi.h @@ -129,6 +129,7 @@ class wxMDIChildFrame: public wxPanel bool Destroy(void); void OnCloseWindow( wxCloseEvent& event ); + void OnSize( wxSizeEvent &event ); public: diff --git a/include/wx/gtk1/notebook.h b/include/wx/gtk1/notebook.h index 1f8148d18c..a30a9d6ba0 100644 --- a/include/wx/gtk1/notebook.h +++ b/include/wx/gtk1/notebook.h @@ -156,7 +156,6 @@ private: uint m_idHandler; // the change page handler id DECLARE_DYNAMIC_CLASS(wxNotebook) - DECLARE_EVENT_TABLE() }; // ---------------------------------------------------------------------------- diff --git a/include/wx/gtk1/tbargtk.h b/include/wx/gtk1/tbargtk.h index 19b59ff9d2..0c33e408b9 100644 --- a/include/wx/gtk1/tbargtk.h +++ b/include/wx/gtk1/tbargtk.h @@ -113,7 +113,7 @@ class wxToolBar: public wxControl virtual void AddSeparator(void); virtual void ClearTools(void); - virtual void Layout(void); + virtual void Realize(void); virtual void EnableTool(int toolIndex, bool enable); virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on diff --git a/include/wx/gtk1/textctrl.h b/include/wx/gtk1/textctrl.h index 99f76a3305..797c61bc7f 100644 --- a/include/wx/gtk1/textctrl.h +++ b/include/wx/gtk1/textctrl.h @@ -99,6 +99,8 @@ public: wxTextCtrl& operator<<(double d); wxTextCtrl& operator<<(const char c); + virtual GtkWidget* GetDropTargetWidget(void); + private: bool m_modified; diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index aaa887c9d6..91a20f9496 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -167,7 +167,10 @@ public: virtual void SetDropTarget( wxDropTarget *dropTarget ); virtual wxDropTarget *GetDropTarget() const; - +private: + virtual GtkWidget* GetDropTargetWidget(void); + +public: virtual void SetScrollbar( int orient, int pos, int thumbVisible, int range, bool refresh = TRUE ); virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ); @@ -182,6 +185,7 @@ public: // update the UI state (called from OnIdle) void UpdateWindowUI(); + public: // cannot get private going yet void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos, diff --git a/include/wx/ipcbase.h b/include/wx/ipcbase.h index 235618fdfc..44c594b45d 100644 --- a/include/wx/ipcbase.h +++ b/include/wx/ipcbase.h @@ -31,15 +31,15 @@ class WXDLLEXPORT wxConnectionBase: public wxObject inline ~wxConnectionBase(void) {} // Calls that CLIENT can make - virtual bool Execute(char *data, int size = -1, int format = wxCF_TEXT) = 0; - virtual bool Execute(const wxString& str) { return Execute((char *)(const char *)str, -1, wxCF_TEXT); } - virtual char *Request(const wxString& item, int *size = NULL, int format = wxCF_TEXT) = 0; - virtual bool Poke(const wxString& item, char *data, int size = -1, int format = wxCF_TEXT) = 0; + virtual bool Execute(char *data, int size = -1, wxDataFormat format = wxDF_TEXT ) = 0; + virtual bool Execute(const wxString& str) { return Execute((char *)(const char *)str, -1, wxDF_TEXT); } + virtual char *Request(const wxString& item, int *size = NULL, wxDataFormat format = wxDF_TEXT) = 0; + virtual bool Poke(const wxString& item, char *data, int size = -1, wxDataFormat format = wxDF_TEXT) = 0; virtual bool StartAdvise(const wxString& item) = 0; virtual bool StopAdvise(const wxString& item) = 0; // Calls that SERVER can make - virtual bool Advise(const wxString& item, char *data, int size = -1, int format = wxCF_TEXT) = 0; + virtual bool Advise(const wxString& item, char *data, int size = -1, wxDataFormat format = wxDF_TEXT) = 0; // Calls that both can make virtual bool Disconnect(void) = 0; diff --git a/include/wx/object.h b/include/wx/object.h index 178af1fb35..50667186a6 100644 --- a/include/wx/object.h +++ b/include/wx/object.h @@ -135,7 +135,7 @@ wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \ #endif -#define IS_KIND_OF(obj, className) obj->IsKindOf(&className::class##name) +#define IS_KIND_OF(obj, className) obj->IsKindOf(&className::class##className) // Unfortunately Borland seems to need this include. #ifdef __BORLANDC__ diff --git a/misc/imlib/imrc b/misc/imlib/imrc index 5849d45bb7..d091e056a6 100644 --- a/misc/imlib/imrc +++ b/misc/imlib/imrc @@ -5,7 +5,7 @@ # The file that contains palette entries for a global palette for all Imlib # based programs. # options: full path to palette file -PaletteFile /etc/im_palette.pal +PaletteFile ~/im_palette.pal # This defines if when the display is greater than 8 bit, that it still remaps # the images to the palette defined, rather than using "perfect" rendering # options: yes/no diff --git a/samples/dnd/Makefile b/samples/dnd/Makefile new file mode 100644 index 0000000000..027d82ae19 --- /dev/null +++ b/samples/dnd/Makefile @@ -0,0 +1 @@ +include ../../src/gtk/setup/general/makeapp diff --git a/samples/dnd/Makefile.in b/samples/dnd/Makefile.in new file mode 100644 index 0000000000..d645ef43c1 --- /dev/null +++ b/samples/dnd/Makefile.in @@ -0,0 +1,26 @@ +# WXXT base directory +WXBASEDIR=@WXBASEDIR@ + +# set the OS type for compilation +OS=@OS@ +# compile a library only +RULE=bin + +# define library name +BIN_TARGET=dnd +# define library sources +BIN_SRC=\ +dnd.cpp + +#define library objects +BIN_OBJ=\ +dnd.o + +# additional things needed to link +BIN_LINK= + +# additional things needed to compile +ADD_COMPILE= + +# include the definitions now +include ../../../template.mak diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index f2d5292921..9c61559838 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -138,8 +138,12 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) m_strText("wxWindows drag & drop works :-)") { + +#ifdef __WXMSW__ // frame icon and status bar SetIcon(wxIcon("mondrian")); +#endif + const int widths[] = { -1 }; CreateStatusBar(); @@ -172,6 +176,7 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) m_ctrlFile = new wxListBox(this, -1, pos, size, 1, &strFile, wxLB_HSCROLL); m_ctrlText = new wxListBox(this, -1, pos, size, 1, &strText, wxLB_HSCROLL); + m_ctrlLog = new wxTextCtrl(this, -1, "", pos, size, wxTE_MULTILINE | wxTE_READONLY | wxSUNKEN_BORDER| wxHSCROLL); @@ -181,10 +186,10 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) m_pLogPrev = wxLog::SetActiveTarget(m_pLog); // associate drop targets with 2 text controls - m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile)); - m_ctrlText->SetDropTarget(new DnDText(m_ctrlText)); +// m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile)); + m_ctrlText->SetDropTarget(new DnDText(m_ctrlText)); - wxLayoutConstraints *c; + wxLayoutConstraints *c; // Top-left listbox c = new wxLayoutConstraints; @@ -274,7 +279,7 @@ void DnDFrame::OnHelp(wxCommandEvent& /* event */) dialog.ShowModal(); } -void DnDFrame::OnLogClear(wxCommandEvent& event) +void DnDFrame::OnLogClear(wxCommandEvent& /* event */ ) { m_ctrlLog->Clear(); } @@ -284,12 +289,12 @@ bool DnDFrame::OnClose() return TRUE; } -void DnDFrame::OnMouseBtnDown(wxMouseEvent& event) +void DnDFrame::OnMouseBtnDown(wxMouseEvent& /* event */ ) { if ( !m_strText.IsEmpty() ) { // start drag operation wxTextDataObject data(m_strText); - wxDropSource dragSource(data); + wxDropSource dragSource(data, this); const char *pc; switch ( dragSource.DoDragDrop(TRUE) ) { diff --git a/samples/docview/docview.cpp b/samples/docview/docview.cpp index 8943fb94c6..ee3e82d832 100644 --- a/samples/docview/docview.cpp +++ b/samples/docview/docview.cpp @@ -244,7 +244,7 @@ MyFrame::MyFrame(wxDocManager *manager, wxFrame *frame, const wxString& title, editMenu = NULL; } -void MyFrame::OnAbout(wxCommandEvent& event) +void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) ) { (void)wxMessageBox("DocView Demo\nAuthor: Julian Smart julian.smart@ukonline.co.uk\nUsage: docview.exe [-single]", "About DocView"); } diff --git a/samples/docview/view.cpp b/samples/docview/view.cpp index 15784e23f6..f09fad19fa 100644 --- a/samples/docview/view.cpp +++ b/samples/docview/view.cpp @@ -44,7 +44,7 @@ END_EVENT_TABLE() // What to do when a view is created. Creates actual // windows for displaying the view. -bool DrawingView::OnCreate(wxDocument *doc, long flags) +bool DrawingView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) { if (!singleWindowMode) { @@ -99,7 +99,7 @@ void DrawingView::OnDraw(wxDC *dc) } } -void DrawingView::OnUpdate(wxView *sender, wxObject *hint) +void DrawingView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint)) { if (canvas) canvas->Refresh(); @@ -147,7 +147,7 @@ bool DrawingView::OnClose(bool deleteWindow) return TRUE; } -void DrawingView::OnCut(wxCommandEvent& event) +void DrawingView::OnCut(wxCommandEvent& WXUNUSED(event) ) { DrawingDocument *doc = (DrawingDocument *)GetDocument(); doc->GetCommandProcessor()->Submit(new DrawingCommand("Cut Last Segment", DOODLE_CUT, doc, NULL)); @@ -155,7 +155,7 @@ void DrawingView::OnCut(wxCommandEvent& event) IMPLEMENT_DYNAMIC_CLASS(TextEditView, wxView) -bool TextEditView::OnCreate(wxDocument *doc, long flags) +bool TextEditView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) { frame = wxGetApp().CreateChildFrame(doc, this, FALSE); @@ -178,11 +178,11 @@ bool TextEditView::OnCreate(wxDocument *doc, long flags) } // Handled by wxTextWindow -void TextEditView::OnDraw(wxDC *dc) +void TextEditView::OnDraw(wxDC *WXUNUSED(dc) ) { } -void TextEditView::OnUpdate(wxView *sender, wxObject *hint) +void TextEditView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) { } @@ -264,11 +264,13 @@ void MyCanvas::OnMouseEvent(wxMouseEvent& event) currentSegment = new DoodleSegment; DoodleLine *newLine = new DoodleLine; - newLine->x1 = xpos; newLine->y1 = ypos; - newLine->x2 = pt.x; newLine->y2 = pt.y; + newLine->x1 = (long)xpos; + newLine->y1 = (long)ypos; + newLine->x2 = pt.x; + newLine->y2 = pt.y; currentSegment->lines.Append(newLine); - dc.DrawLine(xpos, ypos, pt.x, pt.y); + dc.DrawLine( (long)xpos, (long)ypos, pt.x, pt.y); } xpos = pt.x; ypos = pt.y; diff --git a/samples/dynamic/minimal.cpp b/samples/dynamic/minimal.cpp index e96dbd4578..50b45ca0bd 100644 --- a/samples/dynamic/minimal.cpp +++ b/samples/dynamic/minimal.cpp @@ -79,8 +79,7 @@ bool MyApp::OnInit(void) // Make a panel with a message wxPanel *panel = new wxPanel(frame, -1, wxPoint(0, 0), wxSize(400, 200), wxTAB_TRAVERSAL); - wxStaticText *msg = new wxStaticText(panel, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1), - 0); + (void)new wxStaticText(panel, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1), 0); // Show the frame frame->Show(TRUE); diff --git a/samples/forty/canvas.cpp b/samples/forty/canvas.cpp index 18dec216f2..a6d1137ee7 100644 --- a/samples/forty/canvas.cpp +++ b/samples/forty/canvas.cpp @@ -109,6 +109,7 @@ void FortyCanvas::OnDraw(wxDC& dc) m_game->DisplayScore(dc); delete m_playerDialog; m_playerDialog = 0; + Refresh(); } else { diff --git a/samples/forty/card.cpp b/samples/forty/card.cpp index 5dc266982e..b38056ead0 100644 --- a/samples/forty/card.cpp +++ b/samples/forty/card.cpp @@ -11,12 +11,12 @@ // Last modified: 22nd July 1998 - ported to wxWindows 2.0 ///////////////////////////////////////////////////////////////////////////// //+-------------------------------------------------------------+ -//| Description: | -//| A class for drawing playing cards. | -//| Currently assumes that the card symbols have been | -//| loaded into hbmap_symbols and the pictures for the | -//| Jack, Queen and King have been loaded into | -//| hbmap_pictures. | +//| Description +//| A class for drawing playing cards. +//| Currently assumes that the card symbols have been +//| loaded into hbmap_symbols and the pictures for the +//| Jack, Queen and King have been loaded into +//| hbmap_pictures. //+-------------------------------------------------------------+ #ifdef __GNUG__ diff --git a/samples/forty/pile.cpp b/samples/forty/pile.cpp index fd0f60d388..02d3a92205 100644 --- a/samples/forty/pile.cpp +++ b/samples/forty/pile.cpp @@ -41,6 +41,7 @@ #include "card.h" #include "pile.h" +#include "wx/app.h" //+-------------------------------------------------------------+ //| Pile::Pile() | @@ -72,13 +73,22 @@ Pile::Pile(int x, int y, int dx, int dy) //| at the origin of the pile, shifting each subsequent | //| card by the pile's x and y offsets. | //+-------------------------------------------------------------+ -void Pile::Redraw(wxDC& dc) +void Pile::Redraw(wxDC& dc ) { + wxWindow *frame = wxTheApp->GetTopWindow(); + wxWindow *canvas = NULL; + if (frame) + { + wxNode *node = frame->GetChildren()->First(); + if (node) canvas = (wxWindow*)node->Data(); + } + if (m_topCard >= 0) { if (m_dx == 0 && m_dy == 0) { - m_cards[m_topCard]->Draw(dc, m_x, m_y); + if ((canvas) && (canvas->IsExposed(m_x,m_y,60,200))) + m_cards[m_topCard]->Draw(dc, m_x, m_y); } else { @@ -86,14 +96,16 @@ void Pile::Redraw(wxDC& dc) int y = m_y; for (int i = 0; i <= m_topCard; i++) { - m_cards[i]->Draw(dc, x, y); - x += m_dx; - y += m_dy; + if ((canvas) && (canvas->IsExposed(x,y,60,200))) + m_cards[i]->Draw(dc, x, y); + x += m_dx; + y += m_dy; } } } else { + if ((canvas) && (canvas->IsExposed(m_x,m_y,60,200))) Card::DrawNullCard(dc, m_x, m_y); } } diff --git a/samples/mdi/mdi.cpp b/samples/mdi/mdi.cpp index 24d2650b56..f3f9a78db9 100644 --- a/samples/mdi/mdi.cpp +++ b/samples/mdi/mdi.cpp @@ -102,20 +102,20 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c InitToolBar(GetToolBar()); } -void MyFrame::OnQuit(wxCommandEvent& event) +void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) ) { Close(TRUE); } -void MyFrame::OnAbout(wxCommandEvent& event) +void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) ) { (void)wxMessageBox("wxWindows 2.0 MDI Demo\nAuthor: Julian Smart (c) 1997\nUsage: mdi.exe", "About MDI Demo"); } -void MyFrame::OnNewWindow(wxCommandEvent& event) +void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) ) { // Make another frame, containing a canvas - MyChild *subframe = new MyChild(frame, "Canvas Frame", wxPoint(10, 10), wxSize(300, 300), + MyChild *subframe = new MyChild(frame, "Canvas Frame", wxPoint(4, 4), wxSize(100, 100), wxDEFAULT_FRAME); char titleBuf[100]; @@ -241,12 +241,10 @@ bool MyFrame::OnClose(void) return TRUE; } -void MyFrame::OnSize(wxSizeEvent& event) +void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event) ) { int w, h; GetClientSize(&w, &h); - int tw = 0; - int th = 0; textWindow->SetSize(0, 0, 200, h); GetClientWindow()->SetSize(200, 0, w - 200, h); @@ -318,7 +316,6 @@ void MyFrame::InitToolBar(wxToolBar* toolBar) #else int width = 16; #endif - int offX = 5; int currentX = 5; toolBar->AddTool(0, *bitmaps[0], wxNullBitmap, FALSE, currentX, -1, NULL, "New file"); diff --git a/samples/memcheck/memcheck.cpp b/samples/memcheck/memcheck.cpp index 5ccb6165a8..805b315945 100644 --- a/samples/memcheck/memcheck.cpp +++ b/samples/memcheck/memcheck.cpp @@ -28,7 +28,7 @@ #include "wx/date.h" #if !WXDEBUG -#error You must set WXDEBUG to 1 on the 'make' command line or make.env. +#error You must set WXDEBUG to 1 on the 'make' command line (MSW) or with configure (GTK) #endif // #define new WXDEBUG_NEW diff --git a/samples/minimal/minimal.cpp b/samples/minimal/minimal.cpp index 4bbae39331..b6ce6c8d98 100644 --- a/samples/minimal/minimal.cpp +++ b/samples/minimal/minimal.cpp @@ -84,8 +84,7 @@ bool MyApp::OnInit(void) // Make a panel with a message wxPanel *panel = new wxPanel(frame, -1, wxPoint(0, 0), wxSize(400, 200), wxTAB_TRAVERSAL); - wxStaticText *msg = new wxStaticText(panel, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1), - 0); + (void)new wxStaticText(panel, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1), 0); // Show the frame frame->Show(TRUE); diff --git a/samples/png/pngdemo.cpp b/samples/png/pngdemo.cpp index 05fb32d7ef..a08f20aeca 100644 --- a/samples/png/pngdemo.cpp +++ b/samples/png/pngdemo.cpp @@ -89,18 +89,18 @@ MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, cons canvas = NULL; } -void MyFrame::OnQuit(wxCommandEvent& event) +void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { Close(TRUE); } -void MyFrame::OnAbout(wxCommandEvent& event) +void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { (void)wxMessageBox("PNG demo\nJulian Smart (c) 1998", "About PNG Demo", wxOK); } -void MyFrame::OnLoadFile(wxCommandEvent& event) +void MyFrame::OnLoadFile(wxCommandEvent& WXUNUSED(event)) { // Show file selector. char *f = wxFileSelector("Open Image", NULL, NULL,"png", @@ -136,7 +136,7 @@ MyCanvas::~MyCanvas(void) } // Define the repainting behaviour -void MyCanvas::OnPaint(wxPaintEvent& event) +void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); dc.SetPen(wxRED_PEN); diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp index 14e1fb48c5..bd0a78877b 100644 --- a/samples/printing/printing.cpp +++ b/samples/printing/printing.cpp @@ -159,12 +159,12 @@ MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, cons canvas = NULL; } -void MyFrame::OnExit(wxCommandEvent& event) +void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event)) { Close(TRUE); } -void MyFrame::OnPrint(wxCommandEvent& event) +void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event)) { #ifdef __WXMSW__ wxGetApp().SetPrintMode(wxPRINT_WINDOWS); @@ -177,7 +177,7 @@ void MyFrame::OnPrint(wxCommandEvent& event) wxMessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wxOK); } -void MyFrame::OnPrintPS(wxCommandEvent& event) +void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event)) { wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT); @@ -186,7 +186,7 @@ void MyFrame::OnPrintPS(wxCommandEvent& event) printer.Print(this, &printout, TRUE); } -void MyFrame::OnPrintPreview(wxCommandEvent& event) +void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event)) { #ifdef __WXMSW__ wxGetApp().SetPrintMode(wxPRINT_WINDOWS); @@ -211,7 +211,7 @@ void MyFrame::OnPrintPreview(wxCommandEvent& event) frame->Show(TRUE); } -void MyFrame::OnPrintPreviewPS(wxCommandEvent& event) +void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event)) { wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT); @@ -226,7 +226,7 @@ void MyFrame::OnPrintPreviewPS(wxCommandEvent& event) frame->Show(TRUE); } -void MyFrame::OnPrintSetup(wxCommandEvent& event) +void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event)) { #ifdef __WXMSW__ wxGetApp().SetPrintMode(wxPRINT_WINDOWS); @@ -247,7 +247,7 @@ void MyFrame::OnPrintSetup(wxCommandEvent& event) orientation = printerDialog.GetPrintData().GetOrientation(); } -void MyFrame::OnPageSetup(wxCommandEvent& event) +void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event)) { #ifdef __WXMSW__ wxGetApp().SetPrintMode(wxPRINT_WINDOWS); @@ -268,7 +268,7 @@ void MyFrame::OnPageSetup(wxCommandEvent& event) orientation = data.GetOrientation(); } -void MyFrame::OnPrintSetupPS(wxCommandEvent& event) +void MyFrame::OnPrintSetupPS(wxCommandEvent& WXUNUSED(event)) { wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT); @@ -282,7 +282,7 @@ void MyFrame::OnPrintSetupPS(wxCommandEvent& event) orientation = printerDialog.GetPrintData().GetOrientation(); } -void MyFrame::OnPageSetupPS(wxCommandEvent& event) +void MyFrame::OnPageSetupPS(wxCommandEvent& WXUNUSED(event)) { wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT); @@ -295,7 +295,7 @@ void MyFrame::OnPageSetupPS(wxCommandEvent& event) orientation = pageSetupDialog.GetPageSetupData().GetOrientation(); } -void MyFrame::OnPrintAbout(wxCommandEvent& event) +void MyFrame::OnPrintAbout(wxCommandEvent& WXUNUSED(event)) { (void)wxMessageBox("wxWindows printing demo\nAuthor: Julian Smart julian.smart@ukonline.co.uk", "About wxWindows printing demo", wxOK|wxCENTRE); @@ -309,19 +309,19 @@ void MyFrame::Draw(wxDC& dc) dc.SetBrush(wxCYAN_BRUSH); dc.SetPen(wxRED_PEN); - dc.DrawRectangle(0.0, 30.0, 200.0, 100.0); - dc.DrawText("Rectangle 200 by 100", 40.0, 40.0); + dc.DrawRectangle(0, 30, 200, 100); + dc.DrawText("Rectangle 200 by 100", 40, 40); - dc.DrawEllipse(50.0, 140.0, 100.0, 50.0); + dc.DrawEllipse(50, 140, 100, 50); - dc.DrawText("Test message: this is in 11 point text", 10.0, 180.0); + dc.DrawText("Test message: this is in 11 point text", 10, 180); dc.SetPen(wxBLACK_PEN); - dc.DrawLine(0.0, 0.0, 200.0, 200.0); - dc.DrawLine(200.0, 0.0, 0.0, 200.0); + dc.DrawLine(0, 0, 200, 200); + dc.DrawLine(200, 0, 0, 200); } -void MyFrame::OnSize(wxSizeEvent& event) +void MyFrame::OnSize(wxSizeEvent& event ) { wxFrame::OnSize(event); } @@ -346,7 +346,7 @@ void MyCanvas::OnDraw(wxDC& dc) frame->Draw(dc); } -void MyCanvas::OnEvent(wxMouseEvent& event) +void MyCanvas::OnEvent(wxMouseEvent& WXUNUSED(event)) { } @@ -373,7 +373,7 @@ bool MyPrintout::OnPrintPage(int page) char buf[200]; sprintf(buf, "PAGE %d", page); - dc->DrawText(buf, 10.0, 10.0); + dc->DrawText(buf, 10, 10); return TRUE; } @@ -438,7 +438,7 @@ void MyPrintout::DrawPageOne(wxDC *dc) // Set the scale and origin dc->SetUserScale(actualScale, actualScale); - dc->SetDeviceOrigin(posX, posY); + dc->SetDeviceOrigin( (long)posX, (long)posY ); frame->Draw(*dc); } @@ -486,13 +486,13 @@ void MyPrintout::DrawPageTwo(wxDC *dc) float logUnitsFactor = (float)(ppiPrinterX/(scale*25.1)); float logUnits = (float)(50*logUnitsFactor); dc->SetPen(wxBLACK_PEN); - dc->DrawLine(50.0, 50.0, (float)(50.0 + logUnits), 50.0); - dc->DrawLine(50.0, 50.0, 50.0, (float)(50.0 + logUnits)); + dc->DrawLine(50, 50, (long)(50.0 + logUnits), 50); + dc->DrawLine(50, 50, 50, (long)(50.0 + logUnits)); dc->SetFont(itemFont); dc->SetBackgroundMode(wxTRANSPARENT); - dc->DrawText("Some test text", 200.0, 200.0); + dc->DrawText("Some test text", 200, 200 ); // TESTING @@ -510,8 +510,10 @@ void MyPrintout::DrawPageTwo(wxDC *dc) float rightMarginLogical = (float)(logUnitsFactor*(pageWidthMM - rightMargin)); dc->SetPen(wxBLACK_PEN); - dc->DrawLine(leftMarginLogical, topMarginLogical, rightMarginLogical, topMarginLogical); - dc->DrawLine(leftMarginLogical, bottomMarginLogical, rightMarginLogical, bottomMarginLogical); + dc->DrawLine( (long)leftMarginLogical, (long)topMarginLogical, + (long)rightMarginLogical, (long)topMarginLogical); + dc->DrawLine( (long)leftMarginLogical, (long)bottomMarginLogical, + (long)rightMarginLogical, (long)bottomMarginLogical); WritePageHeader(this, dc, "A header", logUnitsFactor); } @@ -541,10 +543,11 @@ bool WritePageHeader(wxPrintout *printout, wxDC *dc, char *text, float mmToLogic long xExtent, yExtent; dc->GetTextExtent(text, &xExtent, &yExtent); float xPos = (float)(((((pageWidthMM - leftMargin - rightMargin)/2.0)+leftMargin)*mmToLogical) - (xExtent/2.0)); - dc->DrawText(text, (long)xPos, topMarginLogical); + dc->DrawText(text, (long)xPos, (long)topMarginLogical); dc->SetPen(wxBLACK_PEN); - dc->DrawLine(leftMarginLogical, topMarginLogical+yExtent, rightMarginLogical, topMarginLogical+yExtent); + dc->DrawLine( (long)leftMarginLogical, (long)(topMarginLogical+yExtent), + (long)rightMarginLogical, (long)topMarginLogical+yExtent ); return TRUE; } diff --git a/samples/splitter/test.cpp b/samples/splitter/test.cpp index 996b6d7b53..4d749c959b 100644 --- a/samples/splitter/test.cpp +++ b/samples/splitter/test.cpp @@ -163,12 +163,12 @@ bool MyFrame::OnClose() return TRUE; } -void MyFrame::Quit(wxCommandEvent& event) +void MyFrame::Quit(wxCommandEvent& WXUNUSED(event) ) { Close(TRUE); } -void MyFrame::SplitHorizontal(wxCommandEvent& event) +void MyFrame::SplitHorizontal(wxCommandEvent& WXUNUSED(event) ) { if ( splitter->IsSplit() ) splitter->Unsplit(); @@ -177,7 +177,7 @@ void MyFrame::SplitHorizontal(wxCommandEvent& event) splitter->SplitHorizontally( leftCanvas, rightCanvas ); } -void MyFrame::SplitVertical(wxCommandEvent& event) +void MyFrame::SplitVertical(wxCommandEvent& WXUNUSED(event) ) { if ( splitter->IsSplit() ) splitter->Unsplit(); @@ -186,7 +186,7 @@ void MyFrame::SplitVertical(wxCommandEvent& event) splitter->SplitVertically( leftCanvas, rightCanvas ); } -void MyFrame::Unsplit(wxCommandEvent& event) +void MyFrame::Unsplit(wxCommandEvent& WXUNUSED(event) ) { if ( splitter->IsSplit() ) splitter->Unsplit(); diff --git a/samples/tab/test.cpp b/samples/tab/test.cpp index 2b2064a29d..62aabc036f 100644 --- a/samples/tab/test.cpp +++ b/samples/tab/test.cpp @@ -52,12 +52,12 @@ MyDialog::MyDialog(wxWindow* parent, const wxWindowID id, const wxString& title, Init(); } -void MyDialog::OnOK(wxCommandEvent& event) +void MyDialog::OnOK(wxCommandEvent& WXUNUSED(event) ) { EndModal(wxID_OK); } -void MyDialog::OnCloseWindow(wxCloseEvent& event) +void MyDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event) ) { EndModal(wxID_CANCEL); } @@ -68,8 +68,8 @@ void MyDialog::Init(void) int dialogHeight = 390; wxButton *okButton = new wxButton(this, wxID_OK, "Close", wxPoint(100, 330), wxSize(80, 25)); - wxButton *cancelButton = new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(185, 330), wxSize(80, 25)); - wxButton *HelpButton = new wxButton(this, wxID_HELP, "Help", wxPoint(270, 330), wxSize(80, 25)); + (void)new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(185, 330), wxSize(80, 25)); + (void)new wxButton(this, wxID_HELP, "Help", wxPoint(270, 330), wxSize(80, 25)); okButton->SetDefault(); // Note, omit the wxTAB_STYLE_COLOUR_INTERIOR, so we will guarantee a match @@ -136,7 +136,7 @@ void MyDialog::Init(void) view->AddTabWindow(TEST_TAB_DOG, panel2); // Don't know why this is necessary under Motif... -#ifdef wx_motif +#ifndef __WXMSW__ this->SetSize(dialogWidth, dialogHeight-20); #endif diff --git a/samples/thread/test.cpp b/samples/thread/test.cpp index 21730f7da7..3d7e70edc7 100644 --- a/samples/thread/test.cpp +++ b/samples/thread/test.cpp @@ -157,7 +157,7 @@ MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h): wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)) {} -void MyFrame::OnStartThread(wxCommandEvent& event) +void MyFrame::OnStartThread(wxCommandEvent& WXUNUSED(event) ) { MyThread *thread = new MyThread(this); @@ -166,9 +166,9 @@ void MyFrame::OnStartThread(wxCommandEvent& event) m_threads.Add(thread); } -void MyFrame::OnStopThread(wxCommandEvent& event) +void MyFrame::OnStopThread(wxCommandEvent& WXUNUSED(event) ) { - uint no_thrd = m_threads.Count()-1; + int no_thrd = m_threads.Count()-1; if (no_thrd < 0) return; @@ -177,10 +177,10 @@ void MyFrame::OnStopThread(wxCommandEvent& event) m_threads.Remove(no_thrd); } -void MyFrame::OnPauseThread(wxCommandEvent& event) +void MyFrame::OnPauseThread(wxCommandEvent& WXUNUSED(event) ) {} -void MyFrame::OnQuit(wxCommandEvent& event) +void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) ) { uint i; for (i=0;i #include #include -#include "zlib.h" +#include "../zlib/zlib.h" // don't change this, Robert #ifdef __BORLANDC__ #pragma hdrstop diff --git a/src/generic/gridg.cpp b/src/generic/gridg.cpp index 8ba5575071..1ce790515b 100644 --- a/src/generic/gridg.cpp +++ b/src/generic/gridg.cpp @@ -485,7 +485,7 @@ void wxGenericGrid::PaintGrid(wxDC& dc) // Erase (some of) the background. // Currently, a Windows-only optimisation. -void wxGenericGrid::OnEraseBackground(wxEraseEvent& event) +void wxGenericGrid::OnEraseBackground(wxEraseEvent& WXUNUSED(event) ) { wxClientDC dc(this); dc.BeginDrawing(); diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 788670089a..8e158cfaed 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -439,7 +439,7 @@ long wxListLineData::IsHit( int x, int y ) wxListItemData *item = (wxListItemData*)node->Data(); if (item->HasImage() && IsInRect( x, y, m_bound_icon )) return wxLIST_HITTEST_ONITEMICON; if (item->HasText() && IsInRect( x, y, m_bound_label )) return wxLIST_HITTEST_ONITEMLABEL; - if (!(item->HasImage() || item->HasText())) return 0; +// if (!(item->HasImage() || item->HasText())) return 0; }; // if there is no icon or text = empty if (IsInRect( x, y, m_bound_all )) return wxLIST_HITTEST_ONITEMICON; @@ -806,7 +806,7 @@ wxListMainWindow::wxListMainWindow( void ) m_lastOnSame = FALSE; // m_renameTimer = new wxRenameTimer( this ); m_isCreated = FALSE; - m_isDragging = FALSE; + m_dragCount = 0; }; wxListMainWindow::wxListMainWindow( wxWindow *parent, wxWindowID id, @@ -828,7 +828,7 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent, wxWindowID id, // AllowDoubleClick( TRUE ); m_myFont = wxNORMAL_FONT; m_hasFocus = FALSE; - m_isDragging = FALSE; + m_dragCount = 0; m_isCreated = FALSE; wxSize sz = size; sz.y = 25; @@ -1032,9 +1032,10 @@ void wxListMainWindow::OnRenameAccept() void wxListMainWindow::OnMouse( wxMouseEvent &event ) { + if (m_parent->ProcessEvent( event)) return; + if (!m_current) return; if (m_dirty) return; -// wxDragCanvas::OnEvent( event ); wxClientDC dc(this); PrepareDC(dc); @@ -1053,11 +1054,14 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event ) node = node->Next(); }; - if (!event.Dragging()) m_isDragging = FALSE; + if (!event.Dragging()) + m_dragCount = 0; + else + m_dragCount++; - if (event.Dragging() && (!m_isDragging)) + if (event.Dragging() && (m_dragCount > 3)) { - m_isDragging = TRUE; + m_dragCount = 0; wxListEvent le( wxEVT_COMMAND_LIST_BEGIN_DRAG, m_parent->GetId() ); le.SetEventObject( this ); le.m_code = 0; @@ -1555,6 +1559,25 @@ void wxListMainWindow::GetItemRect( long index, wxRectangle &rect ) }; }; +bool wxListMainWindow::GetItemPosition(long item, wxPoint& pos) +{ + wxNode *node = m_lines.Nth( item ); + if (node) + { + wxRectangle rect; + wxListLineData *line = (wxListLineData*)node->Data(); + line->GetRect( rect ); + pos.x = rect.x; + pos.y = rect.y; + } + else + { + pos.x = 0; + pos.y = 0; + }; + return TRUE; +}; + int wxListMainWindow::GetSelectedItemCount( void ) { int ret = 0; @@ -2197,9 +2220,10 @@ bool wxListCtrl::GetItemRect( long item, wxRectangle &rect, int WXUNUSED(code) return TRUE; }; -bool wxListCtrl::GetItemPosition( long WXUNUSED(item), wxPoint& WXUNUSED(pos) ) const +bool wxListCtrl::GetItemPosition( long item, wxPoint& pos ) { - return 0; + m_mainWin->GetItemPosition( item, pos ); + return TRUE; }; bool wxListCtrl::SetItemPosition( long WXUNUSED(item), const wxPoint& WXUNUSED(pos) ) @@ -2403,7 +2427,7 @@ bool wxListCtrl::SortItems( wxListCtrlCompare fn, long data ) return TRUE; }; -void wxListCtrl::OnIdle( wxIdleEvent &event ) +void wxListCtrl::OnIdle( wxIdleEvent &WXUNUSED(event) ) { if (!m_mainWin->m_dirty) return; diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 1540320787..0352e5eb13 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -87,10 +87,21 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC,wxDC) wxPaintDC::wxPaintDC(void) { + m_penGC = NULL; + m_brushGC = NULL; + m_textGC = NULL; + m_bgGC = NULL; + m_cmap = NULL; }; wxPaintDC::wxPaintDC( wxWindow *window ) { + m_penGC = NULL; + m_brushGC = NULL; + m_textGC = NULL; + m_bgGC = NULL; + m_cmap = NULL; + if (!window) return; GtkWidget *widget = window->m_wxwindow; if (!widget) return; @@ -777,9 +788,13 @@ void wxPaintDC::SetUpDC(void) { m_ok = TRUE; m_logicalFunction = wxCOPY; + if (m_penGC) gdk_gc_unref( m_penGC ); m_penGC = gdk_gc_new( m_window ); + if (m_brushGC) gdk_gc_unref( m_brushGC ); m_brushGC = gdk_gc_new( m_window ); + if (m_textGC) gdk_gc_unref( m_textGC ); m_textGC = gdk_gc_new( m_window ); + if (m_bgGC) gdk_gc_unref( m_bgGC ); m_bgGC = gdk_gc_new( m_window ); SetTextForeground( m_textForegroundColour ); SetTextBackground( m_textBackgroundColour ); diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index 9ba46a6c2c..896763a93c 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -46,9 +46,41 @@ void wxDropTarget::Drop( GdkEvent *event, int x, int y ) void wxDropTarget::UnregisterWidget( GtkWidget *widget ) { + if (!widget) return; + gtk_widget_dnd_drop_set( widget, FALSE, NULL, 0, FALSE ); }; +void wxDropTarget::RegisterWidget( GtkWidget *widget ) +{ + wxString formats; + int valid = 0; + + for ( uint i = 0; i < GetFormatCount(); i++ ) + { + wxDataFormat df = GetFormat( i ); + switch (df) + { + case wxDF_TEXT: + if (i > 0) formats += ";"; + formats += "text/plain"; + valid++; + break; + case wxDF_FILENAME: + if (i > 0) formats += ";"; + formats += "url:any"; + valid++; + break; + default: + break; + }; + } + + char *str = WXSTRINGCAST formats; + + gtk_widget_dnd_drop_set( widget, TRUE, &str, valid, FALSE ); +}; + // ---------------------------------------------------------------------------- // wxTextDropTarget // ---------------------------------------------------------------------------- @@ -66,63 +98,115 @@ bool wxTextDropTarget::OnDropText( long x, long y, const char *psz ) return TRUE; }; -void wxTextDropTarget::RegisterWidget( GtkWidget *widget ) +size_t wxTextDropTarget::GetFormatCount() const { - char *accepted_drop_types[] = { "text/plain" }; - gtk_widget_dnd_drop_set( widget, TRUE, accepted_drop_types, 1, FALSE ); -}; + return 1; +} + +wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const +{ + return wxDF_TEXT; +} + +// ---------------------------------------------------------------------------- +// wxFileDropTarget +// ---------------------------------------------------------------------------- + +bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const WXUNUSED(aszFiles)[] ) +{ + printf( "Got %d dropped files.\n", (int)nFiles ); + printf( "At x: %d, y: %d.\n", (int)x, (int)y ); + return TRUE; +} + +bool wxFileDropTarget::OnDrop(long x, long y, const void *WXUNUSED(pData) ) +{ + char *str = "/this/is/a/path.txt"; + + return OnDropFiles(x, y, 1, &str ); +} + +size_t wxFileDropTarget::GetFormatCount() const +{ + return 1; +} + +wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const +{ + return wxDF_FILENAME; +} //------------------------------------------------------------------------- -// wxDragSource +// wxDropSource //------------------------------------------------------------------------- //----------------------------------------------------------------------------- // drag request -void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDragSource *drag ) +void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDataObject *data ) { - printf( "OnDragRequest.\n" ); + printf( "Data requested for dropping.\n" ); + + uint size = data->GetDataSize(); + char *ptr = new char[size]; + data->GetDataHere( ptr ); + + gtk_widget_dnd_data_set( widget, event, ptr, size ); - gtk_widget_dnd_data_set( widget, event, drag->m_data, drag->m_size ); + delete ptr; }; -wxDragSource::wxDragSource( wxWindow *win ) +wxDropSource::wxDropSource( wxWindow *win ) { g_blockEventsOnDrag = TRUE; - + m_window = win; m_widget = win->m_widget; if (win->m_wxwindow) m_widget = win->m_wxwindow; - - m_data = NULL; - m_size = 0; + m_data = NULL; + m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY ); m_goaheadCursor = wxCursor( wxCURSOR_HAND ); }; -wxDragSource::~wxDragSource(void) +wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win ) { - g_blockEventsOnDrag = FALSE; + g_blockEventsOnDrag = TRUE; + + m_window = win; + m_widget = win->m_widget; + if (win->m_wxwindow) m_widget = win->m_wxwindow; + + m_data = &data; + + m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY ); + m_goaheadCursor = wxCursor( wxCURSOR_HAND ); }; - -void wxDragSource::SetData( char *data, long size ) + +void wxDropSource::SetData( wxDataObject &data ) { - m_size = size; - m_data = data; + m_data = &data; }; -void wxDragSource::Start( int x, int y ) +wxDropSource::~wxDropSource(void) { - if (gdk_dnd.dnd_grabbed) return; - if (gdk_dnd.drag_really) return; - if (m_size == 0) return; - if (!m_data) return; +// if (m_data) delete m_data; + + g_blockEventsOnDrag = FALSE; +}; + +wxDropSource::DragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) +{ + if (gdk_dnd.dnd_grabbed) return None; + if (gdk_dnd.drag_really) return None; + + if (!m_data) return None; + if (m_data->GetDataSize() == 0) return None; GdkWindowPrivate *wp = (GdkWindowPrivate*) m_widget->window; RegisterWindow(); - ConnectWindow(); gdk_dnd.drag_perhaps = TRUE; @@ -159,49 +243,53 @@ void wxDragSource::Start( int x, int y ) gdk_dnd.dnd_grabbed = TRUE; gdk_dnd.drag_really = 1; + + int x = 0; + int y = 0; + gdk_window_get_pointer( m_widget->window, &x, &y, NULL ); + gdk_dnd_display_drag_cursor( x, y, FALSE, TRUE ); while (gdk_dnd.drag_really || gdk_dnd.drag_perhaps) wxYield(); - UnconnectWindow(); UnregisterWindow(); + + return Copy; }; -void wxDragSource::ConnectWindow(void) +void wxDropSource::RegisterWindow(void) { - gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event", - GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)this ); -}; + if (!m_data) return; -void wxDragSource::UnconnectWindow(void) -{ - if (!m_widget) return; + wxString formats; + + wxDataFormat df = m_data->GetPreferredFormat(); - gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)this ); -}; - -void wxDragSource::UnregisterWindow(void) -{ - if (!m_widget) return; + switch (df) + { + case wxDF_TEXT: + formats += "text/plain"; + break; + case wxDF_FILENAME: + formats += "url:any"; + break; + default: + break; + } - gtk_widget_dnd_drag_set( m_widget, FALSE, NULL, 0 ); -}; + char *str = WXSTRINGCAST formats; -//------------------------------------------------------------------------- -// wxTextDragSource -//------------------------------------------------------------------------- + gtk_widget_dnd_drag_set( m_widget, TRUE, &str, 1 ); -void wxTextDragSource::SetTextData( const wxString &text ) -{ - m_tmp = text; - SetData( WXSTRINGCAST(m_tmp), m_tmp.Length()+1 ); + gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event", + GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)m_data ); }; -void wxTextDragSource::RegisterWindow(void) +void wxDropSource::UnregisterWindow(void) { if (!m_widget) return; - char *accepted_drop_types[] = { "text/plain" }; - gtk_widget_dnd_drag_set( m_widget, TRUE, accepted_drop_types, 1 ); + gtk_widget_dnd_drag_set( m_widget, FALSE, NULL, 0 ); + + gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)m_data ); }; - diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 2371b4c5ce..9e4f52a448 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -293,8 +293,7 @@ void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) for(wxNode *node = GetChildren()->First(); node; node = node->Next()) { wxWindow *win = (wxWindow *)node->Data(); - if (!win->IsKindOf(CLASSINFO(wxFrame)) && - !win->IsKindOf(CLASSINFO(wxDialog)) + if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog) #if 0 // not in m_children anyway && (win != m_frameMenuBar) && (win != m_frameToolBar) && @@ -318,6 +317,18 @@ void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) void wxFrame::AddChild( wxWindow *child ) { + // wxFrame and wxDialog as children aren't placed into the parents + + if (child->IsKindOf(CLASSINFO(wxFrame)) || child->IsKindOf(CLASSINFO(wxDialog))) + { + m_children.Append( child ); + + if ((child->m_x != -1) && (child->m_y != -1)) + gtk_widget_set_uposition( child->m_widget, child->m_x, child->m_y ); + + return; + } + if (m_addPrivateChild) { gtk_myfixed_put( GTK_MYFIXED(m_mainWindow), child->m_widget, child->m_x, child->m_y ); @@ -376,11 +387,11 @@ wxMenuBar *wxFrame::GetMenuBar(void) return m_frameMenuBar; }; -wxToolBar *wxFrame::CreateToolBar( int style, int WXUNUSED(orientation), int WXUNUSED(rowsOrColumns) ) +wxToolBar *wxFrame::CreateToolBar( long style , wxWindowID id, const wxString& name ) { m_addPrivateChild = TRUE; - m_frameToolBar = new wxToolBar( this, -1, wxDefaultPosition, wxDefaultSize, style ); + m_frameToolBar = new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name ); m_addPrivateChild = FALSE; @@ -392,15 +403,16 @@ wxToolBar *wxFrame::GetToolBar(void) return m_frameToolBar; }; -bool wxFrame::CreateStatusBar( int number ) +wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name ) { if (m_frameStatusBar) delete m_frameStatusBar; - m_frameStatusBar = new wxStatusBar( this, -1, wxPoint(0,0), wxSize(100,20) ); + m_frameStatusBar = new wxStatusBar( this, id, wxPoint(0,0), wxSize(100,20), style, name ); m_frameStatusBar->SetFieldsCount( number ); - return TRUE; + + return m_frameStatusBar; }; void wxFrame::SetStatusText( const wxString &text, int number ) diff --git a/src/gtk/gauge.cpp b/src/gtk/gauge.cpp index 905423d78a..7230b92816 100644 --- a/src/gtk/gauge.cpp +++ b/src/gtk/gauge.cpp @@ -26,8 +26,6 @@ bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range, { m_needParent = TRUE; - wxSize newSize = size; - PreCreation( parent, id, pos, size, style, name ); m_rangeMax = range; diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index aca4762937..f880a3291e 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -99,6 +99,8 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, PostCreation(); + gtk_widget_realize( GTK_WIDGET(m_list) ); + Show( TRUE ); return TRUE; @@ -321,4 +323,10 @@ int wxListBox::GetIndex( GtkWidget *item ) const return -1; }; +GtkWidget *wxListBox::GetDropTargetWidget(void) +{ + return GTK_WIDGET(m_list); +}; + + diff --git a/src/gtk/mdi.cpp b/src/gtk/mdi.cpp index fead398b88..4428a9edad 100644 --- a/src/gtk/mdi.cpp +++ b/src/gtk/mdi.cpp @@ -13,6 +13,7 @@ #endif #include "wx/mdi.h" +#include "wx/dialog.h" #include "wx/gtk/win_gtk.h" //----------------------------------------------------------------------------- @@ -174,6 +175,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxPanel) BEGIN_EVENT_TABLE(wxMDIChildFrame, wxPanel) EVT_CLOSE(wxMDIChildFrame::OnCloseWindow) + EVT_SIZE(wxMDIChildFrame::OnSize) END_EVENT_TABLE() wxMDIChildFrame::wxMDIChildFrame(void) @@ -223,6 +225,35 @@ void wxMDIChildFrame::OnCloseWindow( wxCloseEvent &event ) } }; +void wxMDIChildFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) +{ + if ( GetAutoLayout() ) + Layout(); + else { + // no child: go out ! + if (!GetChildren()->First()) + return; + + // do we have exactly one child? + wxWindow *child = NULL; + for(wxNode *node = GetChildren()->First(); node; node = node->Next()) + { + wxWindow *win = (wxWindow *)node->Data(); + if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog)) + { + if ( child ) // it's the second one: do nothing + return; + + child = win; + }; + }; + + // yes: set it's size to fill all the frame + int client_x, client_y; + GetClientSize(&client_x, &client_y); + child->SetSize( 1, 1, client_x-2, client_y); + } +}; bool wxMDIChildFrame::Destroy(void) { if (!wxPendingDelete.Member(this)) diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 089d875e5c..6ee2d57a76 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -109,10 +109,6 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* // wxNotebook //----------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(wxNotebook, wxControl) - EVT_SIZE(wxNotebook::OnSize) -END_EVENT_TABLE() - IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl) void wxNotebook::Init() @@ -400,11 +396,6 @@ wxWindow *wxNotebook::GetPage( int page ) const void wxNotebook::AddChild( wxWindow *win ) { - // @@@ normally done in wxWindow::AddChild but for some reason wxNotebook - // case is special there (Robert?) - // Robert: Don't you think the code below looks different from the one - // in wxWindow::AddChild :-) - m_children.Append(win); wxNotebookPage *page = new wxNotebookPage(); @@ -434,13 +425,13 @@ void wxNotebook::AddChild( wxWindow *win ) }; // override these 2 functions to do nothing: everything is done in OnSize -void wxNotebook::SetConstraintSizes(bool /* recurse */) +void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) ) { // don't set the sizes of the pages - their correct size is not yet known wxControl::SetConstraintSizes(FALSE); } -bool wxNotebook::DoPhase(int /* nPhase */) +bool wxNotebook::DoPhase( int WXUNUSED(nPhase) ) { return TRUE; } diff --git a/src/gtk/tbargtk.cpp b/src/gtk/tbargtk.cpp index abdf6ec1a8..d33ae7d3ed 100644 --- a/src/gtk/tbargtk.cpp +++ b/src/gtk/tbargtk.cpp @@ -179,7 +179,7 @@ void wxToolBar::ClearTools(void) { }; -void wxToolBar::Layout(void) +void wxToolBar::Realize(void) { m_x = 0; m_y = 0; diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 12f7e7203c..afd11f78a7 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -385,3 +385,11 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c) return *this; } +GtkWidget* wxTextCtrl::GetDropTargetWidget(void) +{ + return GTK_WIDGET(m_text); +}; + + + + diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index d0d75b07a9..d829d20532 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -349,7 +349,7 @@ typedef struct { } wxEndProcessData; static void GTK_EndProcessDetector(gpointer data, gint source, - GdkInputCondition condition) + GdkInputCondition WXUNUSED(condition) ) { wxEndProcessData *proc_data = (wxEndProcessData *)data; int pid; diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 9e1c673e78..d7f9e773f6 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -259,8 +259,8 @@ gint gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget), GdkEventKey *gd gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) { - if (widget->window != gdk_event->window) return FALSE; - if (g_blockEventsOnDrag) return FALSE; + if (widget->window != gdk_event->window) return TRUE; + if (g_blockEventsOnDrag) return TRUE; if (win->m_wxwindow) { @@ -278,7 +278,7 @@ gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_ev }; }; - if (!win->HasVMT()) return FALSE; + if (!win->HasVMT()) return TRUE; /* printf( "OnButtonPress from " ); @@ -342,9 +342,9 @@ gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_ { if (widget->window != gdk_event->window) return TRUE; - if (g_blockEventsOnDrag) return FALSE; + if (g_blockEventsOnDrag) return TRUE; - if (!win->HasVMT()) return FALSE; + if (!win->HasVMT()) return TRUE; /* printf( "OnButtonRelease from " ); @@ -374,7 +374,9 @@ gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_ event.m_y = (long)gdk_event->y; event.SetEventObject( win ); - return win->ProcessEvent( event ); + win->ProcessEvent( event ); + + return TRUE; }; //----------------------------------------------------------------------------- @@ -384,9 +386,9 @@ gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_e { if (widget->window != gdk_event->window) return TRUE; - if (g_blockEventsOnDrag) return FALSE; + if (g_blockEventsOnDrag) return TRUE; - if (!win->HasVMT()) return FALSE; + if (!win->HasVMT()) return TRUE; /* printf( "OnMotion from " ); @@ -410,7 +412,7 @@ gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_e win->ProcessEvent( event ); - return FALSE; + return TRUE; }; //----------------------------------------------------------------------------- @@ -418,7 +420,7 @@ gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_e gint gtk_window_focus_in_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxWindow *win ) { - if (g_blockEventsOnDrag) return FALSE; + if (g_blockEventsOnDrag) return TRUE; if (win->m_wxwindow) { if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow)) @@ -433,7 +435,7 @@ gint gtk_window_focus_in_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUS }; }; - if (!win->HasVMT()) return FALSE; + if (!win->HasVMT()) return TRUE; /* printf( "OnSetFocus from " ); @@ -446,7 +448,9 @@ gint gtk_window_focus_in_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUS wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() ); event.SetEventObject( win ); - return win->ProcessEvent( event ); + win->ProcessEvent( event ); + + return TRUE; }; //----------------------------------------------------------------------------- @@ -454,14 +458,14 @@ gint gtk_window_focus_in_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUS gint gtk_window_focus_out_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxWindow *win ) { - if (g_blockEventsOnDrag) return FALSE; + if (g_blockEventsOnDrag) return TRUE; if (win->m_wxwindow) { if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow)) GTK_WIDGET_UNSET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS); }; - if (!win->HasVMT()) return FALSE; + if (!win->HasVMT()) return TRUE; /* printf( "OnKillFocus from " ); @@ -472,7 +476,9 @@ gint gtk_window_focus_out_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNU wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() ); event.SetEventObject( win ); - return win->ProcessEvent( event ); + win->ProcessEvent( event ); + + return TRUE; }; //----------------------------------------------------------------------------- @@ -616,8 +622,6 @@ void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow * void gtk_window_drop_callback( GtkWidget *widget, GdkEvent *event, wxWindow *win ) { - printf( "OnDrop.\n" ); - if (win->GetDropTarget()) { int x = 0; @@ -961,9 +965,6 @@ void wxWindow::PostCreation(void) gtk_signal_connect( GTK_OBJECT(connect_widget), "focus_out_event", GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(connect_widget), "drop_data_available_event", - GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this ); - // Only for cursor handling gtk_signal_connect( GTK_OBJECT(m_widget), "enter_notify_event", @@ -1480,6 +1481,7 @@ void wxWindow::AddChild( wxWindow *child ) m_children.Append( child ); if (m_wxwindow) gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget, child->m_x, child->m_y ); + gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height ); }; @@ -1693,17 +1695,23 @@ void wxWindow::InitDialog(void) void wxWindow::SetDropTarget( wxDropTarget *dropTarget ) { - GtkWidget *connect_widget = m_widget; - if (m_wxwindow) connect_widget = m_wxwindow; + GtkWidget *dnd_widget = GetDropTargetWidget(); + if (m_pDropTarget) { - m_pDropTarget->UnregisterWidget( connect_widget ); + gtk_signal_disconnect_by_func( GTK_OBJECT(dnd_widget), + GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this ); + + m_pDropTarget->UnregisterWidget( dnd_widget ); delete m_pDropTarget; }; m_pDropTarget = dropTarget; if (m_pDropTarget) { - m_pDropTarget->RegisterWidget( connect_widget ); + m_pDropTarget->RegisterWidget( dnd_widget ); + + gtk_signal_connect( GTK_OBJECT(dnd_widget), "drop_data_available_event", + GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this ); }; }; @@ -1712,6 +1720,14 @@ wxDropTarget *wxWindow::GetDropTarget() const return m_pDropTarget; }; +GtkWidget* wxWindow::GetDropTargetWidget(void) +{ + GtkWidget *connect_widget = m_widget; + if (m_wxwindow) connect_widget = m_wxwindow; + + return connect_widget; +} + void wxWindow::SetFont( const wxFont &font ) { m_font = font; @@ -2445,7 +2461,7 @@ bool wxWindow::AcceptsFocus() const return IsEnabled() && IsShown(); } -void wxWindow::OnIdle(wxIdleEvent& event) +void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event) ) { UpdateWindowUI(); } diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 1540320787..0352e5eb13 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -87,10 +87,21 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC,wxDC) wxPaintDC::wxPaintDC(void) { + m_penGC = NULL; + m_brushGC = NULL; + m_textGC = NULL; + m_bgGC = NULL; + m_cmap = NULL; }; wxPaintDC::wxPaintDC( wxWindow *window ) { + m_penGC = NULL; + m_brushGC = NULL; + m_textGC = NULL; + m_bgGC = NULL; + m_cmap = NULL; + if (!window) return; GtkWidget *widget = window->m_wxwindow; if (!widget) return; @@ -777,9 +788,13 @@ void wxPaintDC::SetUpDC(void) { m_ok = TRUE; m_logicalFunction = wxCOPY; + if (m_penGC) gdk_gc_unref( m_penGC ); m_penGC = gdk_gc_new( m_window ); + if (m_brushGC) gdk_gc_unref( m_brushGC ); m_brushGC = gdk_gc_new( m_window ); + if (m_textGC) gdk_gc_unref( m_textGC ); m_textGC = gdk_gc_new( m_window ); + if (m_bgGC) gdk_gc_unref( m_bgGC ); m_bgGC = gdk_gc_new( m_window ); SetTextForeground( m_textForegroundColour ); SetTextBackground( m_textBackgroundColour ); diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index 9ba46a6c2c..896763a93c 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -46,9 +46,41 @@ void wxDropTarget::Drop( GdkEvent *event, int x, int y ) void wxDropTarget::UnregisterWidget( GtkWidget *widget ) { + if (!widget) return; + gtk_widget_dnd_drop_set( widget, FALSE, NULL, 0, FALSE ); }; +void wxDropTarget::RegisterWidget( GtkWidget *widget ) +{ + wxString formats; + int valid = 0; + + for ( uint i = 0; i < GetFormatCount(); i++ ) + { + wxDataFormat df = GetFormat( i ); + switch (df) + { + case wxDF_TEXT: + if (i > 0) formats += ";"; + formats += "text/plain"; + valid++; + break; + case wxDF_FILENAME: + if (i > 0) formats += ";"; + formats += "url:any"; + valid++; + break; + default: + break; + }; + } + + char *str = WXSTRINGCAST formats; + + gtk_widget_dnd_drop_set( widget, TRUE, &str, valid, FALSE ); +}; + // ---------------------------------------------------------------------------- // wxTextDropTarget // ---------------------------------------------------------------------------- @@ -66,63 +98,115 @@ bool wxTextDropTarget::OnDropText( long x, long y, const char *psz ) return TRUE; }; -void wxTextDropTarget::RegisterWidget( GtkWidget *widget ) +size_t wxTextDropTarget::GetFormatCount() const { - char *accepted_drop_types[] = { "text/plain" }; - gtk_widget_dnd_drop_set( widget, TRUE, accepted_drop_types, 1, FALSE ); -}; + return 1; +} + +wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const +{ + return wxDF_TEXT; +} + +// ---------------------------------------------------------------------------- +// wxFileDropTarget +// ---------------------------------------------------------------------------- + +bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const WXUNUSED(aszFiles)[] ) +{ + printf( "Got %d dropped files.\n", (int)nFiles ); + printf( "At x: %d, y: %d.\n", (int)x, (int)y ); + return TRUE; +} + +bool wxFileDropTarget::OnDrop(long x, long y, const void *WXUNUSED(pData) ) +{ + char *str = "/this/is/a/path.txt"; + + return OnDropFiles(x, y, 1, &str ); +} + +size_t wxFileDropTarget::GetFormatCount() const +{ + return 1; +} + +wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const +{ + return wxDF_FILENAME; +} //------------------------------------------------------------------------- -// wxDragSource +// wxDropSource //------------------------------------------------------------------------- //----------------------------------------------------------------------------- // drag request -void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDragSource *drag ) +void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDataObject *data ) { - printf( "OnDragRequest.\n" ); + printf( "Data requested for dropping.\n" ); + + uint size = data->GetDataSize(); + char *ptr = new char[size]; + data->GetDataHere( ptr ); + + gtk_widget_dnd_data_set( widget, event, ptr, size ); - gtk_widget_dnd_data_set( widget, event, drag->m_data, drag->m_size ); + delete ptr; }; -wxDragSource::wxDragSource( wxWindow *win ) +wxDropSource::wxDropSource( wxWindow *win ) { g_blockEventsOnDrag = TRUE; - + m_window = win; m_widget = win->m_widget; if (win->m_wxwindow) m_widget = win->m_wxwindow; - - m_data = NULL; - m_size = 0; + m_data = NULL; + m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY ); m_goaheadCursor = wxCursor( wxCURSOR_HAND ); }; -wxDragSource::~wxDragSource(void) +wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win ) { - g_blockEventsOnDrag = FALSE; + g_blockEventsOnDrag = TRUE; + + m_window = win; + m_widget = win->m_widget; + if (win->m_wxwindow) m_widget = win->m_wxwindow; + + m_data = &data; + + m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY ); + m_goaheadCursor = wxCursor( wxCURSOR_HAND ); }; - -void wxDragSource::SetData( char *data, long size ) + +void wxDropSource::SetData( wxDataObject &data ) { - m_size = size; - m_data = data; + m_data = &data; }; -void wxDragSource::Start( int x, int y ) +wxDropSource::~wxDropSource(void) { - if (gdk_dnd.dnd_grabbed) return; - if (gdk_dnd.drag_really) return; - if (m_size == 0) return; - if (!m_data) return; +// if (m_data) delete m_data; + + g_blockEventsOnDrag = FALSE; +}; + +wxDropSource::DragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) +{ + if (gdk_dnd.dnd_grabbed) return None; + if (gdk_dnd.drag_really) return None; + + if (!m_data) return None; + if (m_data->GetDataSize() == 0) return None; GdkWindowPrivate *wp = (GdkWindowPrivate*) m_widget->window; RegisterWindow(); - ConnectWindow(); gdk_dnd.drag_perhaps = TRUE; @@ -159,49 +243,53 @@ void wxDragSource::Start( int x, int y ) gdk_dnd.dnd_grabbed = TRUE; gdk_dnd.drag_really = 1; + + int x = 0; + int y = 0; + gdk_window_get_pointer( m_widget->window, &x, &y, NULL ); + gdk_dnd_display_drag_cursor( x, y, FALSE, TRUE ); while (gdk_dnd.drag_really || gdk_dnd.drag_perhaps) wxYield(); - UnconnectWindow(); UnregisterWindow(); + + return Copy; }; -void wxDragSource::ConnectWindow(void) +void wxDropSource::RegisterWindow(void) { - gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event", - GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)this ); -}; + if (!m_data) return; -void wxDragSource::UnconnectWindow(void) -{ - if (!m_widget) return; + wxString formats; + + wxDataFormat df = m_data->GetPreferredFormat(); - gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)this ); -}; - -void wxDragSource::UnregisterWindow(void) -{ - if (!m_widget) return; + switch (df) + { + case wxDF_TEXT: + formats += "text/plain"; + break; + case wxDF_FILENAME: + formats += "url:any"; + break; + default: + break; + } - gtk_widget_dnd_drag_set( m_widget, FALSE, NULL, 0 ); -}; + char *str = WXSTRINGCAST formats; -//------------------------------------------------------------------------- -// wxTextDragSource -//------------------------------------------------------------------------- + gtk_widget_dnd_drag_set( m_widget, TRUE, &str, 1 ); -void wxTextDragSource::SetTextData( const wxString &text ) -{ - m_tmp = text; - SetData( WXSTRINGCAST(m_tmp), m_tmp.Length()+1 ); + gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event", + GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)m_data ); }; -void wxTextDragSource::RegisterWindow(void) +void wxDropSource::UnregisterWindow(void) { if (!m_widget) return; - char *accepted_drop_types[] = { "text/plain" }; - gtk_widget_dnd_drag_set( m_widget, TRUE, accepted_drop_types, 1 ); + gtk_widget_dnd_drag_set( m_widget, FALSE, NULL, 0 ); + + gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)m_data ); }; - diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 2371b4c5ce..9e4f52a448 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -293,8 +293,7 @@ void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) for(wxNode *node = GetChildren()->First(); node; node = node->Next()) { wxWindow *win = (wxWindow *)node->Data(); - if (!win->IsKindOf(CLASSINFO(wxFrame)) && - !win->IsKindOf(CLASSINFO(wxDialog)) + if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog) #if 0 // not in m_children anyway && (win != m_frameMenuBar) && (win != m_frameToolBar) && @@ -318,6 +317,18 @@ void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) void wxFrame::AddChild( wxWindow *child ) { + // wxFrame and wxDialog as children aren't placed into the parents + + if (child->IsKindOf(CLASSINFO(wxFrame)) || child->IsKindOf(CLASSINFO(wxDialog))) + { + m_children.Append( child ); + + if ((child->m_x != -1) && (child->m_y != -1)) + gtk_widget_set_uposition( child->m_widget, child->m_x, child->m_y ); + + return; + } + if (m_addPrivateChild) { gtk_myfixed_put( GTK_MYFIXED(m_mainWindow), child->m_widget, child->m_x, child->m_y ); @@ -376,11 +387,11 @@ wxMenuBar *wxFrame::GetMenuBar(void) return m_frameMenuBar; }; -wxToolBar *wxFrame::CreateToolBar( int style, int WXUNUSED(orientation), int WXUNUSED(rowsOrColumns) ) +wxToolBar *wxFrame::CreateToolBar( long style , wxWindowID id, const wxString& name ) { m_addPrivateChild = TRUE; - m_frameToolBar = new wxToolBar( this, -1, wxDefaultPosition, wxDefaultSize, style ); + m_frameToolBar = new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name ); m_addPrivateChild = FALSE; @@ -392,15 +403,16 @@ wxToolBar *wxFrame::GetToolBar(void) return m_frameToolBar; }; -bool wxFrame::CreateStatusBar( int number ) +wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name ) { if (m_frameStatusBar) delete m_frameStatusBar; - m_frameStatusBar = new wxStatusBar( this, -1, wxPoint(0,0), wxSize(100,20) ); + m_frameStatusBar = new wxStatusBar( this, id, wxPoint(0,0), wxSize(100,20), style, name ); m_frameStatusBar->SetFieldsCount( number ); - return TRUE; + + return m_frameStatusBar; }; void wxFrame::SetStatusText( const wxString &text, int number ) diff --git a/src/gtk1/gauge.cpp b/src/gtk1/gauge.cpp index 905423d78a..7230b92816 100644 --- a/src/gtk1/gauge.cpp +++ b/src/gtk1/gauge.cpp @@ -26,8 +26,6 @@ bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range, { m_needParent = TRUE; - wxSize newSize = size; - PreCreation( parent, id, pos, size, style, name ); m_rangeMax = range; diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index aca4762937..f880a3291e 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -99,6 +99,8 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, PostCreation(); + gtk_widget_realize( GTK_WIDGET(m_list) ); + Show( TRUE ); return TRUE; @@ -321,4 +323,10 @@ int wxListBox::GetIndex( GtkWidget *item ) const return -1; }; +GtkWidget *wxListBox::GetDropTargetWidget(void) +{ + return GTK_WIDGET(m_list); +}; + + diff --git a/src/gtk1/mdi.cpp b/src/gtk1/mdi.cpp index fead398b88..4428a9edad 100644 --- a/src/gtk1/mdi.cpp +++ b/src/gtk1/mdi.cpp @@ -13,6 +13,7 @@ #endif #include "wx/mdi.h" +#include "wx/dialog.h" #include "wx/gtk/win_gtk.h" //----------------------------------------------------------------------------- @@ -174,6 +175,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxPanel) BEGIN_EVENT_TABLE(wxMDIChildFrame, wxPanel) EVT_CLOSE(wxMDIChildFrame::OnCloseWindow) + EVT_SIZE(wxMDIChildFrame::OnSize) END_EVENT_TABLE() wxMDIChildFrame::wxMDIChildFrame(void) @@ -223,6 +225,35 @@ void wxMDIChildFrame::OnCloseWindow( wxCloseEvent &event ) } }; +void wxMDIChildFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) +{ + if ( GetAutoLayout() ) + Layout(); + else { + // no child: go out ! + if (!GetChildren()->First()) + return; + + // do we have exactly one child? + wxWindow *child = NULL; + for(wxNode *node = GetChildren()->First(); node; node = node->Next()) + { + wxWindow *win = (wxWindow *)node->Data(); + if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog)) + { + if ( child ) // it's the second one: do nothing + return; + + child = win; + }; + }; + + // yes: set it's size to fill all the frame + int client_x, client_y; + GetClientSize(&client_x, &client_y); + child->SetSize( 1, 1, client_x-2, client_y); + } +}; bool wxMDIChildFrame::Destroy(void) { if (!wxPendingDelete.Member(this)) diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index 089d875e5c..6ee2d57a76 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -109,10 +109,6 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* // wxNotebook //----------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(wxNotebook, wxControl) - EVT_SIZE(wxNotebook::OnSize) -END_EVENT_TABLE() - IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl) void wxNotebook::Init() @@ -400,11 +396,6 @@ wxWindow *wxNotebook::GetPage( int page ) const void wxNotebook::AddChild( wxWindow *win ) { - // @@@ normally done in wxWindow::AddChild but for some reason wxNotebook - // case is special there (Robert?) - // Robert: Don't you think the code below looks different from the one - // in wxWindow::AddChild :-) - m_children.Append(win); wxNotebookPage *page = new wxNotebookPage(); @@ -434,13 +425,13 @@ void wxNotebook::AddChild( wxWindow *win ) }; // override these 2 functions to do nothing: everything is done in OnSize -void wxNotebook::SetConstraintSizes(bool /* recurse */) +void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) ) { // don't set the sizes of the pages - their correct size is not yet known wxControl::SetConstraintSizes(FALSE); } -bool wxNotebook::DoPhase(int /* nPhase */) +bool wxNotebook::DoPhase( int WXUNUSED(nPhase) ) { return TRUE; } diff --git a/src/gtk1/tbargtk.cpp b/src/gtk1/tbargtk.cpp index abdf6ec1a8..d33ae7d3ed 100644 --- a/src/gtk1/tbargtk.cpp +++ b/src/gtk1/tbargtk.cpp @@ -179,7 +179,7 @@ void wxToolBar::ClearTools(void) { }; -void wxToolBar::Layout(void) +void wxToolBar::Realize(void) { m_x = 0; m_y = 0; diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index 12f7e7203c..afd11f78a7 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -385,3 +385,11 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c) return *this; } +GtkWidget* wxTextCtrl::GetDropTargetWidget(void) +{ + return GTK_WIDGET(m_text); +}; + + + + diff --git a/src/gtk1/utilsgtk.cpp b/src/gtk1/utilsgtk.cpp index d0d75b07a9..d829d20532 100644 --- a/src/gtk1/utilsgtk.cpp +++ b/src/gtk1/utilsgtk.cpp @@ -349,7 +349,7 @@ typedef struct { } wxEndProcessData; static void GTK_EndProcessDetector(gpointer data, gint source, - GdkInputCondition condition) + GdkInputCondition WXUNUSED(condition) ) { wxEndProcessData *proc_data = (wxEndProcessData *)data; int pid; diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 9e1c673e78..d7f9e773f6 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -259,8 +259,8 @@ gint gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget), GdkEventKey *gd gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) { - if (widget->window != gdk_event->window) return FALSE; - if (g_blockEventsOnDrag) return FALSE; + if (widget->window != gdk_event->window) return TRUE; + if (g_blockEventsOnDrag) return TRUE; if (win->m_wxwindow) { @@ -278,7 +278,7 @@ gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_ev }; }; - if (!win->HasVMT()) return FALSE; + if (!win->HasVMT()) return TRUE; /* printf( "OnButtonPress from " ); @@ -342,9 +342,9 @@ gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_ { if (widget->window != gdk_event->window) return TRUE; - if (g_blockEventsOnDrag) return FALSE; + if (g_blockEventsOnDrag) return TRUE; - if (!win->HasVMT()) return FALSE; + if (!win->HasVMT()) return TRUE; /* printf( "OnButtonRelease from " ); @@ -374,7 +374,9 @@ gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_ event.m_y = (long)gdk_event->y; event.SetEventObject( win ); - return win->ProcessEvent( event ); + win->ProcessEvent( event ); + + return TRUE; }; //----------------------------------------------------------------------------- @@ -384,9 +386,9 @@ gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_e { if (widget->window != gdk_event->window) return TRUE; - if (g_blockEventsOnDrag) return FALSE; + if (g_blockEventsOnDrag) return TRUE; - if (!win->HasVMT()) return FALSE; + if (!win->HasVMT()) return TRUE; /* printf( "OnMotion from " ); @@ -410,7 +412,7 @@ gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_e win->ProcessEvent( event ); - return FALSE; + return TRUE; }; //----------------------------------------------------------------------------- @@ -418,7 +420,7 @@ gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_e gint gtk_window_focus_in_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxWindow *win ) { - if (g_blockEventsOnDrag) return FALSE; + if (g_blockEventsOnDrag) return TRUE; if (win->m_wxwindow) { if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow)) @@ -433,7 +435,7 @@ gint gtk_window_focus_in_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUS }; }; - if (!win->HasVMT()) return FALSE; + if (!win->HasVMT()) return TRUE; /* printf( "OnSetFocus from " ); @@ -446,7 +448,9 @@ gint gtk_window_focus_in_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUS wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() ); event.SetEventObject( win ); - return win->ProcessEvent( event ); + win->ProcessEvent( event ); + + return TRUE; }; //----------------------------------------------------------------------------- @@ -454,14 +458,14 @@ gint gtk_window_focus_in_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUS gint gtk_window_focus_out_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxWindow *win ) { - if (g_blockEventsOnDrag) return FALSE; + if (g_blockEventsOnDrag) return TRUE; if (win->m_wxwindow) { if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow)) GTK_WIDGET_UNSET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS); }; - if (!win->HasVMT()) return FALSE; + if (!win->HasVMT()) return TRUE; /* printf( "OnKillFocus from " ); @@ -472,7 +476,9 @@ gint gtk_window_focus_out_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNU wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() ); event.SetEventObject( win ); - return win->ProcessEvent( event ); + win->ProcessEvent( event ); + + return TRUE; }; //----------------------------------------------------------------------------- @@ -616,8 +622,6 @@ void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow * void gtk_window_drop_callback( GtkWidget *widget, GdkEvent *event, wxWindow *win ) { - printf( "OnDrop.\n" ); - if (win->GetDropTarget()) { int x = 0; @@ -961,9 +965,6 @@ void wxWindow::PostCreation(void) gtk_signal_connect( GTK_OBJECT(connect_widget), "focus_out_event", GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(connect_widget), "drop_data_available_event", - GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this ); - // Only for cursor handling gtk_signal_connect( GTK_OBJECT(m_widget), "enter_notify_event", @@ -1480,6 +1481,7 @@ void wxWindow::AddChild( wxWindow *child ) m_children.Append( child ); if (m_wxwindow) gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget, child->m_x, child->m_y ); + gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height ); }; @@ -1693,17 +1695,23 @@ void wxWindow::InitDialog(void) void wxWindow::SetDropTarget( wxDropTarget *dropTarget ) { - GtkWidget *connect_widget = m_widget; - if (m_wxwindow) connect_widget = m_wxwindow; + GtkWidget *dnd_widget = GetDropTargetWidget(); + if (m_pDropTarget) { - m_pDropTarget->UnregisterWidget( connect_widget ); + gtk_signal_disconnect_by_func( GTK_OBJECT(dnd_widget), + GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this ); + + m_pDropTarget->UnregisterWidget( dnd_widget ); delete m_pDropTarget; }; m_pDropTarget = dropTarget; if (m_pDropTarget) { - m_pDropTarget->RegisterWidget( connect_widget ); + m_pDropTarget->RegisterWidget( dnd_widget ); + + gtk_signal_connect( GTK_OBJECT(dnd_widget), "drop_data_available_event", + GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this ); }; }; @@ -1712,6 +1720,14 @@ wxDropTarget *wxWindow::GetDropTarget() const return m_pDropTarget; }; +GtkWidget* wxWindow::GetDropTargetWidget(void) +{ + GtkWidget *connect_widget = m_widget; + if (m_wxwindow) connect_widget = m_wxwindow; + + return connect_widget; +} + void wxWindow::SetFont( const wxFont &font ) { m_font = font; @@ -2445,7 +2461,7 @@ bool wxWindow::AcceptsFocus() const return IsEnabled() && IsShown(); } -void wxWindow::OnIdle(wxIdleEvent& event) +void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event) ) { UpdateWindowUI(); } diff --git a/src/iodbc/hdbc.c b/src/iodbc/hdbc.c index 710a9b558a..7157480dd1 100644 --- a/src/iodbc/hdbc.c +++ b/src/iodbc/hdbc.c @@ -28,6 +28,8 @@ #include <../iodbc/itrace.h> #include +extern RETCODE _iodbcdm_driverunload(); + RETCODE SQL_API SQLAllocConnect( HENV henv, HDBC FAR* phdbc ) @@ -156,7 +158,7 @@ RETCODE SQL_API SQLSetConnectOption( UWORD fOption, UDWORD vParam ) { - GENV_t FAR* genv; +/* GENV_t FAR* genv; */ DBC_t FAR* pdbc = (DBC_t FAR*)hdbc; STMT_t FAR* pstmt; HPROC hproc = SQL_NULL_HPROC; @@ -496,7 +498,7 @@ RETCODE SQL_API SQLGetConnectOption( UWORD fOption, PTR pvParam ) { - GENV_t FAR* genv; +/* GENV_t FAR* genv; */ DBC_t FAR* pdbc = (DBC_t FAR*)hdbc; int sqlstat = en_00000; HPROC hproc = SQL_NULL_HPROC; @@ -755,7 +757,7 @@ RETCODE SQL_API SQLTransact( GENV_t FAR* genv = (GENV_t FAR*)henv; DBC_t FAR* pdbc = (DBC_t FAR*)hdbc; HERR herr; - RETCODE retcode; + RETCODE retcode = 0; if( hdbc != SQL_NULL_HDBC ) { diff --git a/src/iodbc/hstmt.c b/src/iodbc/hstmt.c index 6850bda25b..0aec8ef807 100644 --- a/src/iodbc/hstmt.c +++ b/src/iodbc/hstmt.c @@ -189,7 +189,7 @@ RETCODE SQL_API SQLFreeStmt ( UWORD fOption ) { STMT_t FAR* pstmt = (STMT_t FAR*)hstmt; - STMT_t FAR* tpstmt; +/* STMT_t FAR* tpstmt; */ DBC_t FAR* pdbc; HPROC hproc = SQL_NULL_HPROC; diff --git a/user/wxFile/FMJobs.cpp b/user/wxFile/FMJobs.cpp new file mode 100644 index 0000000000..b6a5ce6691 --- /dev/null +++ b/user/wxFile/FMJobs.cpp @@ -0,0 +1,326 @@ +/* + * Program: FMJobs.cpp + * + * Author: Robert Roebling + * + * Copyright: (C) 1997, GNU (Robert Roebling) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef __GNUG__ +#pragma implementation "FMJobs.h" +#endif + +#include "FMJobs.h" +#include "wx/utils.h" +#include "wx/filefn.h" +#include "wx/msgdlg.h" + +//----------------------------------------------------------------------------- +// wxCopyStatusDia +//----------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxCopyStatusDia,wxDialog); + +const ID_CANCEL_COPY = 1000; + +BEGIN_EVENT_TABLE(wxCopyStatusDia,wxDialog) + EVT_BUTTON (ID_CANCEL_COPY, wxCopyStatusDia::OnCommand) +END_EVENT_TABLE() + +wxCopyStatusDia::wxCopyStatusDia( wxFrame *parent, const wxString &dest, wxArrayString *files ) : + wxDialog( parent, -1, "FileMaker copy job control", wxPoint(180,180), wxSize(500,200) ) +{ + int w = 0; + int h = 0; + GetSize( &w, &h ); + + m_dest = dest; + m_files = files; + m_stop = FALSE; + + (void)new wxStaticText( this, -1, "Copying files", wxPoint(10,10) ); + (void)new wxStaticText( this, -1, "from:", wxPoint(30,40) ); + m_sourceMsg = new wxStaticText( this, -1, "", wxPoint(80,40), wxSize(200,-1) ); + (void)new wxStaticText( this, -1, " to:", wxPoint(30,70) ); + m_destMsg = new wxStaticText( this, -1, "", wxPoint(80,70), wxSize(200,-1) ); + (void)new wxStaticText( this, -1, " Kb copied:", wxPoint(30,100) ); + m_statusMsg = new wxStaticText( this, -1, "0", wxPoint(120,100), wxSize(100,-1) ); + + m_cancelButton = new wxButton( this, ID_CANCEL_COPY, "Return", wxPoint(w-130,h-50), wxSize(85,30) ); + + Centre( wxVERTICAL | wxHORIZONTAL ); + + m_timer = new wxCopyTimer( this ); + m_timer->Start( 300, TRUE ); + + Show( TRUE ); +}; + +wxCopyStatusDia::~wxCopyStatusDia() +{ + delete m_timer; +}; + +void wxCopyStatusDia::OnCommand( wxCommandEvent &WXUNUSED(event) ) +{ + if (m_stop) EndModal(wxID_CANCEL); + m_stop = TRUE; +}; + +void wxCopyStatusDia::DoCopy(void) +{ + wxYield(); + + if (!wxDirExists(m_dest)) + { + wxMessageBox( "Target is not a directory or it doesn`t exist. Can`t copy.", "FileMaker" ); + return; + }; + + for (uint i = 0; i < m_files->Count(); i++) + { + wxString src = (*m_files)[i]; + if (wxDirExists( src )) + CopyDir( src, m_dest ); + else + CopyFile( src, m_dest ); + if (m_stop) return; + }; + m_stop = TRUE; +}; + +void wxCopyStatusDia::CopyDir( wxString &srcDir, wxString &destDir ) +{ + wxString src = srcDir; + wxString dest = destDir; + dest += "/"; + dest += wxFileNameFromPath( src ); + if (!wxMkdir( dest )) + { + wxMessageBox( "Could not create target directory.", "FileMaker" ); + return; + }; + + wxArrayString list; + src += "/*"; + char *f = wxFindFirstFile( src, wxDIR ); + while (f) + { + list.Add( f ); + f = wxFindNextFile(); + }; + + for (uint i = 0; i < list.Count(); i++) + { + wxString filename = list[i]; + if (wxDirExists( filename )) + CopyDir( filename, dest ); + else + CopyFile( filename, dest ); + if (m_stop) return; + }; +}; + +void wxCopyStatusDia::CopyFile( wxString &src, wxString &destDir ) +{ + m_sourceMsg->SetLabel( src ); + wxString dest = destDir; + dest += "/"; + dest += wxFileNameFromPath( src ); + m_destMsg->SetLabel( dest ); + + wxYield(); + + if (wxFileExists(dest)) + { + wxString s = "Target file "; + s += dest; + s += " exists already. Overwrite?"; + int ret = wxMessageBox( s, "FileMaker", wxYES_NO ); + if (ret == wxNO) return; + }; + + FILE *fs = NULL, *fd = NULL; + if (!(fs = fopen(src, "rb"))) + { + wxString s = "Cannot open source file "; + s += src; + s += "."; + wxMessageBox( s, "FileMaker" ); + return; + } + else + if (!(fd = fopen(dest, "wb"))) + { + fclose(fs); + wxString s = "Cannot open target file "; + s += dest; + s += "."; + wxMessageBox( s, "FileMaker" ); + return; + }; + int ch; + long kcounter = 0; + while (!m_stop) + { + int counter = 0; + while ((ch = getc( fs )) != EOF) + { + putc( ch, fd ); + counter++; + if (counter == 1000) break; + }; + kcounter++; + m_statusMsg->SetLabel( IntToString( kcounter) ); + wxYield(); + if (ch == EOF) break; + }; + fclose( fs ); + fclose( fd ); +}; + + +//----------------------------------------------------------------------------- +// wxDeleteStatusDia +//----------------------------------------------------------------------------- + +/* + +IMPLEMENT_DYNAMIC_CLASS(wxDeleteStatusDia,wxDialogBox); + +wxDeleteStatusDia::wxDeleteStatusDia( wxFrame *parent, wxStringList *files ) : + wxDialogBox( parent, "FileMaker delete job control", TRUE, + 180, 180, 500, 200, wxCAPTION | wxTRANSIENT ) +{ + int w = 0; + int h = 0; + GetSize( &w, &h ); + + m_files = files; + m_stop = FALSE; + m_countFiles = 0; + m_countDirs = 0; + + wxFont *myFont = wxTheFontList->FindOrCreateFont( 12, wxROMAN, wxNORMAL, wxNORMAL ); + SetLabelFont( myFont ); + SetButtonFont( myFont ); + + wxStaticText *msg = new wxStaticText( this, "Deleting file or directory:", 10, 10 ); + m_targetMsg = new wxStaticText( this, "", 80, 40, 300 ); + msg = new wxStaticText( this, " Directories deleted:", 10, 80 ); + m_dirsMsg = new wxStaticText( this, "0", 120, 80, 80 ); + msg = new wxStaticText( this, " Files deleted:", 10, 110 ); + m_filesMsg = new wxStaticText( this, "0", 120, 110, 100 ); + + m_cancelButton = new wxButton( this, NULL, "Return", w-130, h-50, 85, 30 ); + + Centre( wxVERTICAL | wxHORIZONTAL ); + + m_timer = new wxDeleteTimer( this ); + m_timer->Start( 300, TRUE ); + + Show( TRUE ); +}; + +wxDeleteStatusDia::~wxDeleteStatusDia() +{ + delete m_timer; +}; + +void wxDeleteStatusDia::OnCommand( wxWindow &win, wxCommandEvent &WXUNUSED(event) ) +{ + if (&win == m_cancelButton) + { + if (m_stop) Show( FALSE ); + m_stop = TRUE; + return; + }; +}; + +void wxDeleteStatusDia::DoDelete(void) +{ + while (wxTheApp->Pending()) wxTheApp->Dispatch(); + wxNode *node = m_files->First(); + while (node) + { + char *target = (char*)node->Data(); + if (wxDirExists( target )) + DeleteDir( target ); + else + DeleteFile( target ); + if (m_stop) return; + node = node->Next(); + }; + m_stop = TRUE; +}; + +void wxDeleteStatusDia::DeleteDir( char *target ) +{ + wxString s = target; + s += "// *"; + wxStringList list; + char *f = wxFindFirstFile( s ); + while (f) + { + list.Add( f ); + f = wxFindNextFile(); + }; + wxNode *node = list.First(); + while (node) + { + f = (char*)node->Data(); + if (wxDirExists( f )) + DeleteDir( f ); + else + DeleteFile( f ); + if (m_stop) return; + node = node->Next(); + }; + if (!wxRmdir( target )) + { + s = "Could not remove directory "; + s += target; + s += "."; + wxMessageBox( s, "FileMaker" ); + return; + } + else + { + m_countDirs++; + m_dirsMsg->SetLabel( wxIntToString( m_countDirs) ); + }; +}; + +void wxDeleteStatusDia::DeleteFile( char *target ) +{ + m_targetMsg->SetLabel( target ); + while (wxTheApp->Pending()) wxTheApp->Dispatch(); + if (!wxRemoveFile( target )) + { + wxString s = "Could not delete file "; + s += target; + s += "."; + wxMessageBox( s, "FileMaker" ); + } + else + { + m_countFiles++; + m_filesMsg->SetLabel( wxIntToString( m_countFiles) ); + }; +}; + +*/ diff --git a/user/wxFile/FMJobs.h b/user/wxFile/FMJobs.h new file mode 100644 index 0000000000..7d62e1539b --- /dev/null +++ b/user/wxFile/FMJobs.h @@ -0,0 +1,143 @@ +/* + * File: FMJobs.h + * + * Author: Robert Roebling + * + * Copyright: (C) 1997, GNU (Robert Roebling) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef FMJobs_h +#define FMJobs_h + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "wx/defs.h" +#include "wx/dialog.h" +#include "wx/frame.h" +#include "wx/button.h" +#include "wx/stattext.h" +#include "wx/timer.h" + +//----------------------------------------------------------------------------- +// derived classes +//----------------------------------------------------------------------------- + +class wxCopyStatusDia; +class wxDeleteStatusDia; +class wxCopyTimer; +class wxDeleteTimer; + +//----------------------------------------------------------------------------- +// wxCopyStatusDia +//----------------------------------------------------------------------------- + +class wxCopyStatusDia: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( wxCopyStatusDia ); + + private: + + wxString m_dest; + wxArrayString *m_files; + wxButton *m_cancelButton; + wxStaticText *m_sourceMsg; + wxStaticText *m_destMsg; + wxStaticText *m_statusMsg; + bool m_stop; + wxTimer *m_timer; + + public: + + wxCopyStatusDia(void) : wxDialog() {}; + wxCopyStatusDia( wxFrame *parent, const wxString &dest, wxArrayString *files ); + ~wxCopyStatusDia(); + void OnCommand( wxCommandEvent &event ); + void DoCopy(void); + + private: + void CopyDir( wxString &srcDir, wxString &destDir ); + void CopyFile( wxString &src, wxString &destDir ); + + DECLARE_EVENT_TABLE(); +}; + +//----------------------------------------------------------------------------- +// wxDeleteStatusDia +//----------------------------------------------------------------------------- + +/* +class wxDeleteStatusDia: public wxDialog +{ + DECLARE_DYNAMIC_CLASS( wxDeleteStatusDia ); + + private: + + wxArrayString *m_files; + wxButton *m_cancelButton; + wxStaticText *m_targetMsg; + wxStaticText *m_filesMsg,*m_dirsMsg; + bool m_stop; + wxTimer *m_timer; + int m_countFiles,m_countDirs; + + public: + + wxDeleteStatusDia(void) : wxDialog() {}; + wxDeleteStatusDia( wxFrame *parent, wxArrayString *files ); + ~wxDeleteStatusDia(); + void OnCommand( wxCommandEvent &event ); + void DoDelete(void); + + private: + void DeleteDir( wxString &target ); + void DeleteFile( wxString &target ); + + DECLARE_EVENT_TABLE(); +}; +*/ + +//----------------------------------------------------------------------------- +// wxTimer +//----------------------------------------------------------------------------- + +class wxCopyTimer: public wxTimer +{ + private: + wxCopyStatusDia *m_owner; + + public: + wxCopyTimer( wxCopyStatusDia *owner ) { m_owner = owner; }; + void Notify() { m_owner->DoCopy(); }; +}; + +/* +class wxDeleteTimer: public wxTimer +{ + private: + wxDeleteStatusDia *m_owner; + + public: + wxDeleteTimer( wxDeleteStatusDia *owner ) { m_owner = owner; }; + void Notify() { m_owner->DoDelete(); }; +}; +*/ + +#endif // FMJobs_h + + diff --git a/user/wxFile/Makefile.in b/user/wxFile/Makefile.in index 278eb64145..d7eebc5f25 100644 --- a/user/wxFile/Makefile.in +++ b/user/wxFile/Makefile.in @@ -10,11 +10,11 @@ RULE=bin BIN_TARGET=wxFile # define library sources BIN_SRC=\ -wxFile.cpp filectrl.cpp dirctrl.cpp +wxFile.cpp filectrl.cpp dirctrl.cpp FMJobs.cpp #define library objects BIN_OBJ=\ -wxFile.o filectrl.o dirctrl.o +wxFile.o filectrl.o dirctrl.o FMJobs.o # additional things needed to link BIN_LINK= diff --git a/user/wxFile/dirctrl.cpp b/user/wxFile/dirctrl.cpp index f4ee19aba7..98b18d709c 100644 --- a/user/wxFile/dirctrl.cpp +++ b/user/wxFile/dirctrl.cpp @@ -16,6 +16,7 @@ #include "dirctrl.h" #include "wx/gdicmn.h" #include "wx/utils.h" +#include "wx/dnd.h" //----------------------------------------------------------------------------- // wxDirInfo @@ -75,7 +76,6 @@ BEGIN_EVENT_TABLE(wxDirCtrl,wxTreeCtrl) EVT_TREE_ITEM_EXPANDED (-1, wxDirCtrl::OnExpandItem) EVT_TREE_ITEM_COLLAPSED (-1, wxDirCtrl::OnCollapseItem) EVT_TREE_DELETE_ITEM (-1, wxDirCtrl::OnDeleteItem) - EVT_MOUSE_EVENTS (wxDirCtrl::OnMouse) END_EVENT_TABLE() wxDirCtrl::wxDirCtrl(void) @@ -95,11 +95,9 @@ wxDirCtrl::wxDirCtrl(wxWindow *parent, const wxWindowID id, const wxString &WXUN item.m_mask = wxTREE_MASK_TEXT | wxTREE_MASK_CHILDREN | wxTREE_MASK_DATA; item.m_text = "Sections"; item.m_children = 1; -/* - wxDirInfo *info = new wxDirInfo( dir ); - item.m_data = (long)info; -*/ m_rootId = InsertItem( 0, item ); + + SetDropTarget( new wxFileDropTarget() ); }; void wxDirCtrl::OnExpandItem( const wxTreeEvent &event ) @@ -180,7 +178,8 @@ void wxDirCtrl::OnExpandItem( const wxTreeEvent &event ) (path != "/proc") && (path != "/mnt") ) - slist.Add( path ); // ref counting in action ! + + slist.Add( path ); // ref counting in action ! }; path = wxFindNextFile(); }; @@ -212,26 +211,3 @@ void wxDirCtrl::OnDeleteItem( const wxTreeEvent &event ) wxDirInfo *info = (wxDirInfo *)event.m_item.m_data; if (info) delete info; }; - -void wxDirCtrl::OnMouse( wxMouseEvent &event ) -{ - event.Skip(TRUE); - - if (event.LeftDown()) - { - m_dragX = event.GetX(); - m_dragY = event.GetY(); - return; - }; - - if (event.Dragging()) - { - if ((abs(m_dragX-event.GetX()) < 2) && - (abs(m_dragY-event.GetY()) < 2)) return; - - wxTextDragSource drag( this ); - drag.SetTextData( "Oh, what a drag." ); - drag.Start( event.GetX(), event.GetY() ); - }; -}; - diff --git a/user/wxFile/dirctrl.h b/user/wxFile/dirctrl.h index d67cf82aa1..d3ff13c9aa 100644 --- a/user/wxFile/dirctrl.h +++ b/user/wxFile/dirctrl.h @@ -67,7 +67,6 @@ class wxDirCtrl: public wxTreeCtrl void OnExpandItem( const wxTreeEvent &event ); void OnCollapseItem( const wxTreeEvent &event ); void OnDeleteItem( const wxTreeEvent &event ); - void OnMouse( wxMouseEvent &event ); DECLARE_EVENT_TABLE() }; diff --git a/user/wxFile/filectrl.cpp b/user/wxFile/filectrl.cpp index 3dcbf7050d..d84f468360 100644 --- a/user/wxFile/filectrl.cpp +++ b/user/wxFile/filectrl.cpp @@ -206,7 +206,7 @@ void wxFileData::MakeItem( wxListItem &item ) IMPLEMENT_DYNAMIC_CLASS(wxFileCtrl,wxListCtrl); BEGIN_EVENT_TABLE(wxFileCtrl,wxListCtrl) - EVT_SET_FOCUS (wxFileCtrl::OnSetFocus) + EVT_SET_FOCUS (wxFileCtrl::OnSetFocus) END_EVENT_TABLE() wxFileCtrl *wxFileCtrl::m_lastFocus = NULL; @@ -222,8 +222,8 @@ wxFileCtrl::wxFileCtrl( wxWindow *win, const wxWindowID id, const wxString &dirN const long style, const wxString &name ) : wxListCtrl( win, id, pos, size, style, name ) { - SetItemSpacing( 20 ); - wxImageList *imageList = new wxImageList( 18, 18 ); + SetItemSpacing( 40 ); + wxImageList *imageList = new wxImageList( 30, 30 ); imageList->Add( wxBitmap( folder_xpm ) ); imageList->Add( wxBitmap( txt_xpm ) ); imageList->Add( wxBitmap( list_xpm ) ); @@ -236,8 +236,12 @@ wxFileCtrl::wxFileCtrl( wxWindow *win, const wxWindowID id, const wxString &dirN Update(); m_lastFocus = this; - - SetDropTarget( new wxTextDropTarget() ); + + m_dragStartX = 0; + m_dragStartY = 0; + m_dragCount = 0; + + SetDropTarget( new wxFileDropTarget() ); }; void wxFileCtrl::ChangeToListMode() @@ -538,4 +542,3 @@ void wxFileCtrl::OnSetFocus( wxFocusEvent &event ) event.Skip(); }; - diff --git a/user/wxFile/filectrl.h b/user/wxFile/filectrl.h index eb812f9a5a..f2e202433b 100644 --- a/user/wxFile/filectrl.h +++ b/user/wxFile/filectrl.h @@ -79,6 +79,9 @@ class wxFileCtrl : public wxListCtrl private: wxString m_dirName; bool m_showHidden; + int m_dragStartX; + int m_dragStartY; + int m_dragCount; public: wxFileCtrl( void ); diff --git a/user/wxFile/wxFile.cpp b/user/wxFile/wxFile.cpp index c37f33a305..7a3282430b 100644 --- a/user/wxFile/wxFile.cpp +++ b/user/wxFile/wxFile.cpp @@ -312,8 +312,11 @@ void MyFrame::OnListEndLabelEdit( wxListEvent &event ) void MyFrame::OnListDrag( wxListEvent &event ) { - printf( "OnDrag.\n" ); - return; + wxFileDataObject data; + data.AddFile( "/home/karl/test.txt" ); + + wxDropSource drag( data, m_leftFile->m_lastFocus ); + drag.DoDragDrop(); }; void MyFrame::OnTreeSelected( wxTreeEvent &event ) -- 2.45.2