]> git.saurik.com Git - wxWidgets.git/commitdiff
wxClipboard now serves the primary selection as well
authorRobert Roebling <robert@roebling.de>
Fri, 18 Dec 1998 15:49:10 +0000 (15:49 +0000)
committerRobert Roebling <robert@roebling.de>
Fri, 18 Dec 1998 15:49:10 +0000 (15:49 +0000)
  wxPython fixes
  warning mesages

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1239 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/clipbrd.h
include/wx/gtk/menu.h
include/wx/gtk1/clipbrd.h
include/wx/gtk1/menu.h
src/gtk/clipbrd.cpp
src/gtk/palette.cpp
src/gtk1/clipbrd.cpp
src/gtk1/palette.cpp
utils/wxPython/src/Setup [new file with mode: 0644]
utils/wxPython/src/gdi.i
utils/wxPython/src/windows.i

index 5f7a92eead4d654426a58d8f1ba164270e2a078f..f34bcb9f8d670d52796367cc094563024620950d 100644 (file)
@@ -73,10 +73,10 @@ public:
  
   bool              m_open;
   
+  bool              m_ownsClipboard;
+  bool              m_ownsPrimarySelection;
+  
   wxList            m_dataObjects;
-  char             *m_sentString, 
-                  *m_receivedString;
-  void             *m_receivedTargets;
   GtkWidget        *m_clipboardWidget;
   
   bool              m_formatSupported;
index 71a9fde5b39e6a362462af634b3138c1c8101ced..a4656258ede72269212ffe22c07a0aac8639f28a 100644 (file)
@@ -49,7 +49,7 @@ public:
 
   int FindMenuItem( const wxString &menuString, const wxString &itemString ) const;
   wxMenuItem* FindMenuItemById( int id ) const;
-  inline wxMenuItem* FindMenuItemForId( int id ) const
+  inline wxMenuItem* FindItemForId( int id ) const
     { return FindMenuItemById( id ); }
   
   void Check( int id, bool check );
index 5f7a92eead4d654426a58d8f1ba164270e2a078f..f34bcb9f8d670d52796367cc094563024620950d 100644 (file)
@@ -73,10 +73,10 @@ public:
  
   bool              m_open;
   
+  bool              m_ownsClipboard;
+  bool              m_ownsPrimarySelection;
+  
   wxList            m_dataObjects;
-  char             *m_sentString, 
-                  *m_receivedString;
-  void             *m_receivedTargets;
   GtkWidget        *m_clipboardWidget;
   
   bool              m_formatSupported;
index 71a9fde5b39e6a362462af634b3138c1c8101ced..a4656258ede72269212ffe22c07a0aac8639f28a 100644 (file)
@@ -49,7 +49,7 @@ public:
 
   int FindMenuItem( const wxString &menuString, const wxString &itemString ) const;
   wxMenuItem* FindMenuItemById( int id ) const;
-  inline wxMenuItem* FindMenuItemForId( int id ) const
+  inline wxMenuItem* FindItemForId( int id ) const
     { return FindMenuItemById( id ); }
   
   void Check( int id, bool check );
index f0110301a8dd5681ec4a76057c8da384d5274daa..f220a49abdd8b72d7f4b75fc8a681c4825de5709 100644 (file)
@@ -152,14 +152,32 @@ selection_received( GtkWidget *WXUNUSED(widget),
 //-----------------------------------------------------------------------------
 
 static gint
-selection_clear( GtkWidget *WXUNUSED(widget), GdkEventSelection *WXUNUSED(event) )
+selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event )
 {
     if (!wxTheClipboard) return TRUE;
     
-    // the clipboard is no longer in our hands. we have to delete the
-    // clipboard data.
+    if (event->selection == GDK_SELECTION_PRIMARY)
+    {
+        wxTheClipboard->m_ownsPrimarySelection = FALSE;
+    }
+    else
+    if (event->selection == g_clipboardAtom)
+    {
+        wxTheClipboard->m_ownsClipboard = FALSE;
+    }
+    else
+    {
+        return FALSE;
+    }
+    
+    if ((!wxTheClipboard->m_ownsPrimarySelection) &&
+        (!wxTheClipboard->m_ownsClipboard))
+    {
+        // the clipboard is no longer in our hands. we can the
+        // clipboard data.
     
-    wxTheClipboard->m_dataObjects.Clear();
+        wxTheClipboard->m_dataObjects.Clear();
+    }
   
     return TRUE;
 }
@@ -247,6 +265,9 @@ wxClipboard::wxClipboard()
 {
     m_open = FALSE;
 
+    m_ownsClipboard = FALSE;
+    m_ownsPrimarySelection = FALSE;
+
     m_dataObjects.DeleteContents( TRUE );
   
     m_receivedData = (wxDataObject*) NULL;
@@ -256,7 +277,7 @@ wxClipboard::wxClipboard()
 
     gtk_signal_connect( GTK_OBJECT(m_clipboardWidget), 
                         "selection_clear_event",
-                       GTK_SIGNAL_FUNC( selection_clear ), 
+                       GTK_SIGNAL_FUNC( selection_clear_clip ), 
                        (gpointer) NULL );
                      
     if (!g_clipboardAtom) g_clipboardAtom = gdk_atom_intern( "CLIPBOARD", FALSE );
@@ -281,11 +302,16 @@ void wxClipboard::Clear()
         /*  As we have data we also own the clipboard. Once we no longer own
             it, clear_selection is called which will set m_data to zero */
      
-        if (gdk_selection_owner_get( g_clipboardAtom) == m_clipboardWidget->window)
+        if (gdk_selection_owner_get( g_clipboardAtom ) == m_clipboardWidget->window)
         {
             gtk_selection_owner_set( (GtkWidget*) NULL, g_clipboardAtom, GDK_CURRENT_TIME );
         }
     
+        if (gdk_selection_owner_get( GDK_SELECTION_PRIMARY ) == m_clipboardWidget->window)
+        {
+            gtk_selection_owner_set( (GtkWidget*) NULL, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME );
+        }
+    
         m_dataObjects.Clear();
     }
   
@@ -339,7 +365,12 @@ bool wxClipboard::SetData( wxDataObject *data )
     {
         data->m_formatAtom = GetTargetAtom( data->GetFormat() );
     }
+    
+    // This should happen automatically
       
+    m_ownsClipboard = FALSE;
+    m_ownsPrimarySelection = FALSE;
+    
     // Add handlers if someone requests data
   
     gtk_selection_add_handler( m_clipboardWidget, 
@@ -348,6 +379,12 @@ bool wxClipboard::SetData( wxDataObject *data )
                               selection_handler,
                               NULL );
                               
+    gtk_selection_add_handler( m_clipboardWidget, 
+                               GDK_SELECTION_PRIMARY,
+                              data->m_formatAtom,
+                              selection_handler,
+                              NULL );
+                              
     // Tell the world we offer clipboard data
   
     if (!gtk_selection_owner_set( m_clipboardWidget, 
@@ -356,6 +393,15 @@ bool wxClipboard::SetData( wxDataObject *data )
     {
         return FALSE;
     }
+    m_ownsClipboard = TRUE;
+    
+    if (!gtk_selection_owner_set( m_clipboardWidget, 
+                                  GDK_SELECTION_PRIMARY,
+                                 GDK_CURRENT_TIME ))
+    {
+        return FALSE;
+    }
+    m_ownsPrimarySelection = TRUE;
                             
     return TRUE;
 }
index 07d99dc13ccf95e5074661024a876bb6f1872d0e..c94a33616d8d7fce621505d0a1fe37524a9b3614 100644 (file)
@@ -86,21 +86,29 @@ bool wxPalette::Ok(void) const
   return (m_refData);
 };
 
-bool wxPalette::Create( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
+bool wxPalette::Create( int WXUNUSED(n), 
+                        const unsigned char *WXUNUSED(red), 
+                       const unsigned char *WXUNUSED(green), 
+                       const unsigned char *WXUNUSED(blue) )
 {
   wxFAIL_MSG("not implemented");
 
   return FALSE;
 };
 
-int wxPalette::GetPixel( const unsigned char red, const unsigned char green, const unsigned char blue ) const
+int wxPalette::GetPixel( const unsigned char WXUNUSED(red), 
+                         const unsigned char WXUNUSED(green), 
+                        const unsigned char WXUNUSED(blue) ) const
 {
   wxFAIL_MSG("not implemented");
 
   return 0;
 };
 
-bool wxPalette::GetRGB( int pixel, unsigned char *red, unsigned char *green, unsigned char *blue ) const
+bool wxPalette::GetRGB( int WXUNUSED(pixel), 
+                        unsigned char *WXUNUSED(red), 
+                       unsigned char *WXUNUSED(green), 
+                       unsigned char *WXUNUSED(blue) ) const
 {
   wxFAIL_MSG("not implemented");
 
index f0110301a8dd5681ec4a76057c8da384d5274daa..f220a49abdd8b72d7f4b75fc8a681c4825de5709 100644 (file)
@@ -152,14 +152,32 @@ selection_received( GtkWidget *WXUNUSED(widget),
 //-----------------------------------------------------------------------------
 
 static gint
-selection_clear( GtkWidget *WXUNUSED(widget), GdkEventSelection *WXUNUSED(event) )
+selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event )
 {
     if (!wxTheClipboard) return TRUE;
     
-    // the clipboard is no longer in our hands. we have to delete the
-    // clipboard data.
+    if (event->selection == GDK_SELECTION_PRIMARY)
+    {
+        wxTheClipboard->m_ownsPrimarySelection = FALSE;
+    }
+    else
+    if (event->selection == g_clipboardAtom)
+    {
+        wxTheClipboard->m_ownsClipboard = FALSE;
+    }
+    else
+    {
+        return FALSE;
+    }
+    
+    if ((!wxTheClipboard->m_ownsPrimarySelection) &&
+        (!wxTheClipboard->m_ownsClipboard))
+    {
+        // the clipboard is no longer in our hands. we can the
+        // clipboard data.
     
-    wxTheClipboard->m_dataObjects.Clear();
+        wxTheClipboard->m_dataObjects.Clear();
+    }
   
     return TRUE;
 }
@@ -247,6 +265,9 @@ wxClipboard::wxClipboard()
 {
     m_open = FALSE;
 
+    m_ownsClipboard = FALSE;
+    m_ownsPrimarySelection = FALSE;
+
     m_dataObjects.DeleteContents( TRUE );
   
     m_receivedData = (wxDataObject*) NULL;
@@ -256,7 +277,7 @@ wxClipboard::wxClipboard()
 
     gtk_signal_connect( GTK_OBJECT(m_clipboardWidget), 
                         "selection_clear_event",
-                       GTK_SIGNAL_FUNC( selection_clear ), 
+                       GTK_SIGNAL_FUNC( selection_clear_clip ), 
                        (gpointer) NULL );
                      
     if (!g_clipboardAtom) g_clipboardAtom = gdk_atom_intern( "CLIPBOARD", FALSE );
@@ -281,11 +302,16 @@ void wxClipboard::Clear()
         /*  As we have data we also own the clipboard. Once we no longer own
             it, clear_selection is called which will set m_data to zero */
      
-        if (gdk_selection_owner_get( g_clipboardAtom) == m_clipboardWidget->window)
+        if (gdk_selection_owner_get( g_clipboardAtom ) == m_clipboardWidget->window)
         {
             gtk_selection_owner_set( (GtkWidget*) NULL, g_clipboardAtom, GDK_CURRENT_TIME );
         }
     
+        if (gdk_selection_owner_get( GDK_SELECTION_PRIMARY ) == m_clipboardWidget->window)
+        {
+            gtk_selection_owner_set( (GtkWidget*) NULL, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME );
+        }
+    
         m_dataObjects.Clear();
     }
   
@@ -339,7 +365,12 @@ bool wxClipboard::SetData( wxDataObject *data )
     {
         data->m_formatAtom = GetTargetAtom( data->GetFormat() );
     }
+    
+    // This should happen automatically
       
+    m_ownsClipboard = FALSE;
+    m_ownsPrimarySelection = FALSE;
+    
     // Add handlers if someone requests data
   
     gtk_selection_add_handler( m_clipboardWidget, 
@@ -348,6 +379,12 @@ bool wxClipboard::SetData( wxDataObject *data )
                               selection_handler,
                               NULL );
                               
+    gtk_selection_add_handler( m_clipboardWidget, 
+                               GDK_SELECTION_PRIMARY,
+                              data->m_formatAtom,
+                              selection_handler,
+                              NULL );
+                              
     // Tell the world we offer clipboard data
   
     if (!gtk_selection_owner_set( m_clipboardWidget, 
@@ -356,6 +393,15 @@ bool wxClipboard::SetData( wxDataObject *data )
     {
         return FALSE;
     }
+    m_ownsClipboard = TRUE;
+    
+    if (!gtk_selection_owner_set( m_clipboardWidget, 
+                                  GDK_SELECTION_PRIMARY,
+                                 GDK_CURRENT_TIME ))
+    {
+        return FALSE;
+    }
+    m_ownsPrimarySelection = TRUE;
                             
     return TRUE;
 }
index 07d99dc13ccf95e5074661024a876bb6f1872d0e..c94a33616d8d7fce621505d0a1fe37524a9b3614 100644 (file)
@@ -86,21 +86,29 @@ bool wxPalette::Ok(void) const
   return (m_refData);
 };
 
-bool wxPalette::Create( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
+bool wxPalette::Create( int WXUNUSED(n), 
+                        const unsigned char *WXUNUSED(red), 
+                       const unsigned char *WXUNUSED(green), 
+                       const unsigned char *WXUNUSED(blue) )
 {
   wxFAIL_MSG("not implemented");
 
   return FALSE;
 };
 
-int wxPalette::GetPixel( const unsigned char red, const unsigned char green, const unsigned char blue ) const
+int wxPalette::GetPixel( const unsigned char WXUNUSED(red), 
+                         const unsigned char WXUNUSED(green), 
+                        const unsigned char WXUNUSED(blue) ) const
 {
   wxFAIL_MSG("not implemented");
 
   return 0;
 };
 
-bool wxPalette::GetRGB( int pixel, unsigned char *red, unsigned char *green, unsigned char *blue ) const
+bool wxPalette::GetRGB( int WXUNUSED(pixel), 
+                        unsigned char *WXUNUSED(red), 
+                       unsigned char *WXUNUSED(green), 
+                       unsigned char *WXUNUSED(blue) ) const
 {
   wxFAIL_MSG("not implemented");
 
diff --git a/utils/wxPython/src/Setup b/utils/wxPython/src/Setup
new file mode 100644 (file)
index 0000000..c6c1741
--- /dev/null
@@ -0,0 +1,41 @@
+# This file gives the details of what is needed to build this extension
+# module so the Makefile can be created.
+
+###
+### This file should be created by configure.  Currently it is tweaked by hand.
+###
+
+*shared*
+
+CCC=g++
+WXWIN=~/wxWindows
+GENCODEDIR=gtk
+srcdir=$(GENCODEDIR)
+WX_CONFIG_CFLAGS=`wx-config --cflags`
+WX_CONFIG_LIBS=`wx-config --libs`
+
+# Depending on how your Python was built, you may have to set this
+# value to use the C++ driver to link with instead of the default
+# C driver.  For example:
+MY_LDSHARED=$(CCC) -shared $(WX_CONFIG_LIBS)
+
+# Same as above, but for statically linking Python and wxPython together,
+# in other words, if you comment out the *shared* above.  If this is the
+# case then you should ensure that the main() function is Python's, not
+# wxWindows'.  You can rebuild $(WXWIN)/src/gtk/app.cpp with NOMAIN defined
+# to force this...
+MY_LINKCC=$(CCC)
+
+
+## Pick one of these, or set your own.  This is where the
+## wxPython module should be installed.  It should be a
+## subdirectory named wxPython.
+TARGETDIR=..
+#TARGETDIR=$(BINLIBDEST)/site-packages/wxPython
+
+
+wxc    wx.cpp helpers.cpp windows.cpp events.cpp misc.cpp gdi.cpp \
+       mdi.cpp controls.cpp controls2.cpp windows2.cpp cmndlgs.cpp \
+       frames.cpp stattool.cpp utils.cpp \
+       -I. $(WX_CONFIG_CFLAGS) -DSWIG_GLOBAL
+       
index 9509803bc297591502723334a9f2a33ecfb53228..ee3afcb66014b6925704b899b207270b393c54f8 100644 (file)
@@ -152,14 +152,12 @@ public:
     int GetStyle();
     bool GetUnderlined();
     int GetWeight();
-#ifdef __WXMSW__
     void SetFaceName(const wxString& faceName);
     void SetFamily(int family);
     void SetPointSize(int pointSize);
     void SetStyle(int style);
     void SetUnderlined(bool underlined);
     void SetWeight(int weight);
-#endif
 };
 
 //----------------------------------------------------------------------
@@ -210,24 +208,23 @@ public:
     int GetCap();
     wxColour& GetColour();
 
-#ifdef __WXMSW__
-            // **** This one needs to return a list of ints (wxDash)
-    int GetDashes(wxDash **dashes);
-    wxBitmap* GetStipple();
-#endif
     int GetJoin();
     int GetStyle();
     int GetWidth();
     bool Ok();
     void SetCap(int cap_style);
     void SetColour(wxColour& colour);
+    void SetJoin(int join_style);
+    void SetStyle(int style);
+    void SetWidth(int width);
+    
 #ifdef __WXMSW__
+            // **** This one needs to return a list of ints (wxDash)
+    int GetDashes(wxDash **dashes);
+    wxBitmap* GetStipple();
     void SetDashes(int LCOUNT, wxDash* LIST);
     void SetStipple(wxBitmap& stipple);
 #endif
-    void SetJoin(int join_style);
-    void SetStyle(int style);
-    void SetWidth(int width);
 };
 
 //----------------------------------------------------------------------
@@ -505,7 +502,13 @@ public:
 /////////////////////////////////////////////////////////////////////////////
 //
 // $Log$
+// Revision 1.11  1998/12/18 15:49:05  RR
+//   wxClipboard now serves the primary selection as well
+//   wxPython fixes
+//   warning mesages
+//
 // Revision 1.10  1998/12/17 18:05:50  RD
+//
 // wxPython 0.5.2
 // Minor fixes and SWIG code generation for RR's changes.  MSW and GTK
 // versions are much closer now!
index 1d5140a1fffc0560724fb13f9870b070acc98dfc..e9d4ba8014cce81a799fef71adcd8c60dc8b49d2 100644 (file)
@@ -310,8 +310,8 @@ public:
     void Enable(int id, bool enable);
     bool Enabled(int id);
     int FindMenuItem(const wxString& menuString, const wxString& itemString);
-#ifdef __WXMSW__
     wxMenuItem * FindItemForId(int id);
+#ifdef __WXMSW__
     void EnableTop(int pos, bool enable);
     wxString GetHelpString(int id);
     wxString GetLabel(int id);
@@ -351,7 +351,13 @@ public:
 /////////////////////////////////////////////////////////////////////////////
 //
 // $Log$
+// Revision 1.11  1998/12/18 15:49:10  RR
+//   wxClipboard now serves the primary selection as well
+//   wxPython fixes
+//   warning mesages
+//
 // Revision 1.10  1998/12/17 17:52:20  RD
+//
 // wxPython 0.5.2
 // Minor fixes and SWIG code generation for RR's changes.  MSW and GTK
 // versions are much closer now!