]> git.saurik.com Git - wxWidgets.git/commitdiff
DnD updates
authorRobert Roebling <robert@roebling.de>
Tue, 8 Dec 1998 08:40:00 +0000 (08:40 +0000)
committerRobert Roebling <robert@roebling.de>
Tue, 8 Dec 1998 08:40:00 +0000 (08:40 +0000)
  Clipboard pasting (for wxDF_TEXT)
  print dialog looks better now
  font dialog ibid

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

include/wx/gtk/clipbrd.h
include/wx/gtk1/clipbrd.h
samples/controls/controls.cpp
samples/dnd/dnd.cpp
src/generic/fontdlgg.cpp
src/generic/prntdlgg.cpp
src/gtk/clipbrd.cpp
src/gtk/dnd.cpp
src/gtk1/clipbrd.cpp
src/gtk1/dnd.cpp

index aa46abbb0057ddc26e5a382339936a152105a581..b8d488a7471f4b66cc00a250b2f0b33548c2fb10 100644 (file)
 #include "wx/list.h"
 #include "wx/control.h"
 #include "wx/dnd.h"      // for wxDataObject
+#include "wx/module.h"
 
 //-----------------------------------------------------------------------------
 // classes
 //-----------------------------------------------------------------------------
 
 class wxClipboard;
-
-//-----------------------------------------------------------------------------
-// global functions
-//-----------------------------------------------------------------------------
-
-void wxInitClipboard();
-void wxDoneClipboard();
+class wxClipboardModule;
 
 //-----------------------------------------------------------------------------
 // global data
@@ -44,7 +39,7 @@ extern wxClipboard* wxTheClipboard;
 // wxClipboard
 //-----------------------------------------------------------------------------
 
-class  wxClipboard: public wxObject
+class wxClipboard: public wxObject
 {
   DECLARE_DYNAMIC_CLASS(wxClipboard)
 
@@ -54,18 +49,46 @@ public:
   ~wxClipboard();
 
   virtual void SetData( wxDataObject *data );
-  virtual void *GetData( wxDataFormat format, size_t *length );
-  virtual bool IsAvailable( wxDataFormat format );
+  
+  virtual bool IsSupportedFormat( wxDataFormat format );
+  virtual bool ObtainData( wxDataFormat format );
+  
+  // call these after ObtainData()
+  virtual size_t GetDataSize() const;
+  virtual void GetDataHere( void *data ) const;
+  
+  // clears wxTheClipboard and the system's clipboard if possible
+  virtual void Clear();
 
  // implementation 
   
-  wxDataObject  *m_data;
-  char          *m_sentString, 
-               *m_receivedString;
-  void          *m_receivedTargets;
-  size_t         m_receivedLength;
-  GtkWidget     *m_clipboardWidget;
+  wxDataObject     *m_data;
+  char             *m_sentString, 
+                  *m_receivedString;
+  void             *m_receivedTargets;
+  GtkWidget        *m_clipboardWidget;
+  
+  bool              m_formatSupported;
+  GdkAtom           m_targetRequested;
+
+  size_t            m_receivedSize;
+  char              *m_receivedData;
+};
+
+//-----------------------------------------------------------------------------
+// wxClipboardModule
+//-----------------------------------------------------------------------------
+
+class wxClipboardModule: public wxModule
+{
+  DECLARE_DYNAMIC_CLASS(wxClipboardModule)
+  
+public:
+    wxClipboardModule() {}
+    bool OnInit();
+    void OnExit();
 };
 
+
 #endif
     // __GTKCLIPBOARDH__
index aa46abbb0057ddc26e5a382339936a152105a581..b8d488a7471f4b66cc00a250b2f0b33548c2fb10 100644 (file)
 #include "wx/list.h"
 #include "wx/control.h"
 #include "wx/dnd.h"      // for wxDataObject
+#include "wx/module.h"
 
 //-----------------------------------------------------------------------------
 // classes
 //-----------------------------------------------------------------------------
 
 class wxClipboard;
-
-//-----------------------------------------------------------------------------
-// global functions
-//-----------------------------------------------------------------------------
-
-void wxInitClipboard();
-void wxDoneClipboard();
+class wxClipboardModule;
 
 //-----------------------------------------------------------------------------
 // global data
@@ -44,7 +39,7 @@ extern wxClipboard* wxTheClipboard;
 // wxClipboard
 //-----------------------------------------------------------------------------
 
-class  wxClipboard: public wxObject
+class wxClipboard: public wxObject
 {
   DECLARE_DYNAMIC_CLASS(wxClipboard)
 
@@ -54,18 +49,46 @@ public:
   ~wxClipboard();
 
   virtual void SetData( wxDataObject *data );
-  virtual void *GetData( wxDataFormat format, size_t *length );
-  virtual bool IsAvailable( wxDataFormat format );
+  
+  virtual bool IsSupportedFormat( wxDataFormat format );
+  virtual bool ObtainData( wxDataFormat format );
+  
+  // call these after ObtainData()
+  virtual size_t GetDataSize() const;
+  virtual void GetDataHere( void *data ) const;
+  
+  // clears wxTheClipboard and the system's clipboard if possible
+  virtual void Clear();
 
  // implementation 
   
-  wxDataObject  *m_data;
-  char          *m_sentString, 
-               *m_receivedString;
-  void          *m_receivedTargets;
-  size_t         m_receivedLength;
-  GtkWidget     *m_clipboardWidget;
+  wxDataObject     *m_data;
+  char             *m_sentString, 
+                  *m_receivedString;
+  void             *m_receivedTargets;
+  GtkWidget        *m_clipboardWidget;
+  
+  bool              m_formatSupported;
+  GdkAtom           m_targetRequested;
+
+  size_t            m_receivedSize;
+  char              *m_receivedData;
+};
+
+//-----------------------------------------------------------------------------
+// wxClipboardModule
+//-----------------------------------------------------------------------------
+
+class wxClipboardModule: public wxModule
+{
+  DECLARE_DYNAMIC_CLASS(wxClipboardModule)
+  
+public:
+    wxClipboardModule() {}
+    bool OnInit();
+    void OnExit();
 };
 
+
 #endif
     // __GTKCLIPBOARDH__
index 0d198eb43e8fadc2f12abfa237c0a27cc00b875c..84c39dc99d2b0d4249804ee7f79149482ebe3a76 100644 (file)
@@ -26,6 +26,7 @@
 #include "wx/spinbutt.h"
 #include "wx/notebook.h"
 #include "wx/imaglist.h"
+#include "wx/clipbrd.h"
 
 // XPM doesn't seem to work under Windows at present. Or, wxNotebook images
 // aren't working.
@@ -75,6 +76,9 @@ class MyPanel: public wxPanel
     void OnPageChanged( wxNotebookEvent &event );
     void OnSliderUpdate( wxCommandEvent &event );
     void OnSpinUpdate( wxSpinEvent &event );
+    void OnPasteFromClipboard( wxCommandEvent &event );
+    void OnCopyToClipboard( wxCommandEvent &event );
+    void OnCutToClipboard( wxCommandEvent &event );
     
     wxListBox     *m_listbox;
     wxChoice      *m_choice;
@@ -85,6 +89,7 @@ class MyPanel: public wxPanel
     wxButton      *m_fontButton;
     wxSpinButton  *m_spinbutton;
     wxTextCtrl    *m_spintext;
+    wxTextCtrl    *m_multitext;
     
     wxTextCtrl    *m_text;
     wxNotebook    *m_notebook;    
@@ -181,6 +186,9 @@ const int  ID_COMBO_FONT        = 146;
 const int  ID_COMBO_ENABLE      = 147;
 
 const int  ID_TEXT              = 150;
+const int  ID_PASTE_TEXT        = 151;
+const int  ID_COPY_TEXT         = 152;
+const int  ID_CUT_TEXT          = 153;
 
 const int  ID_RADIOBOX          = 160;
 const int  ID_RADIOBOX_SEL_NUM  = 161;
@@ -231,15 +239,18 @@ BEGIN_EVENT_TABLE(MyPanel, wxPanel)
   EVT_BUTTON    (ID_SET_FONT,             MyPanel::OnSetFont)
   EVT_SLIDER    (ID_SLIDER,               MyPanel::OnSliderUpdate)
   EVT_SPIN      (ID_SPIN,                 MyPanel::OnSpinUpdate)
+  EVT_BUTTON    (ID_PASTE_TEXT,           MyPanel::OnPasteFromClipboard)
+  EVT_BUTTON    (ID_COPY_TEXT,            MyPanel::OnCopyToClipboard)
+  EVT_BUTTON    (ID_CUT_TEXT,             MyPanel::OnCutToClipboard)
 END_EVENT_TABLE()
 
 MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
   wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) )
 {
-  SetBackgroundColour("cadet blue");
+//  SetBackgroundColour("cadet blue");
 
   m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE );
-  m_text->SetBackgroundColour("wheat");
+//  m_text->SetBackgroundColour("wheat");
   
   m_notebook = new wxNotebook( this, ID_NOTEBOOK, wxPoint(0,0), wxSize(200,150) );
   
@@ -284,29 +295,29 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
 
   wxButton *button = (wxButton*)NULL;
 
-  m_notebook->SetBackgroundColour("cadet blue");
+//  m_notebook->SetBackgroundColour("cadet blue");
 
   wxPanel *panel = (wxPanel*) NULL;
   panel = new wxPanel(m_notebook);
-  panel->SetBackgroundColour("cadet blue");
-  panel->SetForegroundColour("blue");
+//  panel->SetBackgroundColour("cadet blue");
+//  panel->SetForegroundColour("blue");
   m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 5, choices );
-  m_listbox->SetBackgroundColour("wheat");
+//  m_listbox->SetBackgroundColour("wheat");
   (void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
   (void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
   (void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
   (void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
   (void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
   button = new wxButton( panel, ID_LISTBOX_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) );
-  button->SetForegroundColour( "red" );
+//  button->SetForegroundColour( "red" );
   (void)new wxCheckBox( panel, ID_LISTBOX_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) );
   m_notebook->AddPage(panel, "wxList", FALSE, Image_List);
   
   panel = new wxPanel(m_notebook);
-  panel->SetBackgroundColour("cadet blue");
-  panel->SetForegroundColour("blue");
+//  panel->SetBackgroundColour("cadet blue");
+//  panel->SetForegroundColour("blue");
   m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices );
-  m_choice->SetBackgroundColour("wheat");
+//  m_choice->SetBackgroundColour("wheat");
   (void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
   (void)new wxButton( panel, ID_CHOICE_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
   (void)new wxButton( panel, ID_CHOICE_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
@@ -317,10 +328,10 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
   m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice);
   
   panel = new wxPanel(m_notebook);
-  panel->SetBackgroundColour("cadet blue");
-  panel->SetForegroundColour("blue");
+//  panel->SetBackgroundColour("cadet blue");
+//  panel->SetForegroundColour("blue");
   m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 5, choices );
-  m_combo->SetBackgroundColour("wheat");
+//  m_combo->SetBackgroundColour("wheat");
   (void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
   (void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
   (void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
@@ -331,14 +342,18 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
   m_notebook->AddPage(panel, "wxComboBox", FALSE, Image_Combo);
   
   panel = new wxPanel(m_notebook);
-  panel->SetBackgroundColour("cadet blue");
-  panel->SetForegroundColour("blue");
-  wxTextCtrl *tc = new wxTextCtrl( panel, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(350,28));
+//  panel->SetBackgroundColour("cadet blue");
+//  panel->SetForegroundColour("blue");
+  wxTextCtrl *tc = new wxTextCtrl( panel, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(320,28));
   (*tc) << " More text.";
-  tc->SetBackgroundColour("wheat");
-  tc = new wxTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(350,160), wxTE_MULTILINE  );
-  (*tc) << " More text.";
-  tc->SetBackgroundColour("wheat");
+//  tc->SetBackgroundColour("wheat");
+  m_multitext = new wxTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(320,160), wxTE_MULTILINE  );
+  (*m_multitext) << " More text.";
+//  m_multitext->SetBackgroundColour("wheat");
+  (void)new wxStaticBox( panel, -1, "wxClipboard", wxPoint(345,50), wxSize(160,145) );
+  (void)new wxButton( panel, ID_COPY_TEXT, "Copy text", wxPoint(370,70), wxSize(110,30) );
+  (void)new wxButton( panel, ID_PASTE_TEXT, "Paste text", wxPoint(370,110), wxSize(110,30) );
+  (void)new wxButton( panel, ID_CUT_TEXT, "Cut text", wxPoint(370,150), wxSize(110,30) );
   m_notebook->AddPage(panel, "wxTextCtrl" , FALSE, Image_Text);
   
   wxString choices2[] =
@@ -348,27 +363,28 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
   };
   
   panel = new wxPanel(m_notebook);
-  panel->SetBackgroundColour("cadet blue");
-  panel->SetForegroundColour("blue");
+//  panel->SetBackgroundColour("cadet blue");
+//  panel->SetForegroundColour("blue");
   m_radio = new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), 2, choices2, 1, wxRA_HORIZONTAL );
-  m_radio->SetBackgroundColour("wheat");
+//  m_radio->SetBackgroundColour("wheat");
   m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), 5, choices, 1, wxRA_VERTICAL );
-  m_radio->SetBackgroundColour("wheat");
+//  m_radio->SetBackgroundColour("wheat");
   (void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
   (void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(180,80), wxSize(140,30) );
-  (void)new wxButton( panel, ID_RADIOBOX_FONT, "Set Italic font", wxPoint(180,130), wxSize(140,30) );
+  m_fontButton = new wxButton( panel, ID_SET_FONT, "Set more Italic font", wxPoint(340,30), wxSize(140,30) );
+  m_fontButton->SetForegroundColour("blue");
+  (void)new wxButton( panel, ID_RADIOBOX_FONT, "Set Italic font", wxPoint(340,80), wxSize(140,30) );
   (void)new wxCheckBox( panel, ID_RADIOBOX_ENABLE, "Disable", wxPoint(340,130), wxSize(140,30) );
-  m_fontButton = new wxButton( panel, ID_SET_FONT, "Set more Italic font", wxPoint(340,30), wxSize(160,30) );
   m_notebook->AddPage(panel, "wxRadioBox", FALSE, Image_Radio);
   
   panel = new wxPanel(m_notebook);
-  panel->SetBackgroundColour("cadet blue");
-  panel->SetForegroundColour("blue");
+//  panel->SetBackgroundColour("cadet blue");
+//  panel->SetForegroundColour("blue");
   (void)new wxStaticBox( panel, -1, "wxGauge and wxSlider", wxPoint(10,10), wxSize(180,130) );
   m_gauge = new wxGauge( panel, -1, 200, wxPoint(18,50), wxSize(155,-1) );
-  m_gauge->SetBackgroundColour("wheat");
+//  m_gauge->SetBackgroundColour("wheat");
   m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200, wxPoint(18,90), wxSize(155,-1) );
-  m_slider->SetBackgroundColour("wheat");
+//  m_slider->SetBackgroundColour("wheat");
   (void)new wxStaticBox( panel, -1, "Explanation", wxPoint(200,10), wxSize(290,130) );
   (void)new wxStaticText( panel, -1, 
     "In order see the gauge (aka progress bar)\n" 
@@ -379,14 +395,45 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
     "to use static controls.\n",
     wxPoint(208,25) );
   m_spintext = new wxTextCtrl( panel, -1, "0", wxPoint(20,160), wxSize(80,-1) );
-  m_spintext->SetBackgroundColour("wheat");
+//  m_spintext->SetBackgroundColour("wheat");
   m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,159), wxSize(-1,-1) );
-  m_spinbutton->SetBackgroundColour("wheat");
+//  m_spinbutton->SetBackgroundColour("wheat");
   m_spinbutton->SetRange(0,100); 
     
   m_notebook->AddPage(panel, "wxGauge", FALSE, Image_Gauge);
 }
 
+void MyPanel::OnPasteFromClipboard( wxCommandEvent &WXUNUSED(event) )
+{
+#ifdef __WXGTK__
+
+  if (!wxTheClipboard->IsSupportedFormat( wxDF_TEXT )) return;
+  
+  if (!wxTheClipboard->ObtainData( wxDF_TEXT )) return;
+  
+  int size = wxTheClipboard->GetDataSize()+1;
+  
+  char *data = new char[size];
+  
+  data[size-1] = 0;
+  
+  wxTheClipboard->GetDataHere( data );
+  
+  *m_multitext << data << "\n";
+  
+  delete[] data;
+
+#endif
+}
+
+void MyPanel::OnCopyToClipboard( wxCommandEvent &WXUNUSED(event) )
+{
+}
+
+void MyPanel::OnCutToClipboard( wxCommandEvent &WXUNUSED(event) )
+{
+}
+
 void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) )
 {
   int x = 0;
index 15ac819ee3a1b9f1d8e3ed199a77da6cc5cb06ff..e3900dffe323fd6a9c39924defe7c6c14904e740 100644 (file)
@@ -84,7 +84,7 @@ public:
 
   void OnLeftDown(wxMouseEvent& event);
   void OnRightDown(wxMouseEvent& event);
-
+  
   bool OnClose();
   
   DECLARE_EVENT_TABLE()
@@ -117,8 +117,9 @@ BEGIN_EVENT_TABLE(DnDFrame, wxFrame)
   EVT_MENU(Menu_Drag,  DnDFrame::OnDrag)
   EVT_MENU(Menu_Help,  DnDFrame::OnHelp)
   EVT_MENU(Menu_Clear, DnDFrame::OnLogClear)
-  EVT_LEFT_DOWN(OnLeftDown)
-  EVT_RIGHT_DOWN(OnRightDown)
+  EVT_LEFT_DOWN(       DnDFrame::OnLeftDown)
+  EVT_RIGHT_DOWN(      DnDFrame::OnRightDown)
+  EVT_PAINT(           DnDFrame::OnPaint)
 END_EVENT_TABLE()
 
 // `Main program' equivalent, creating windows and returning main app frame
@@ -142,12 +143,8 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
 
 {
 
-#ifdef __WXMSW__
   // frame icon and status bar
-  SetIcon(wxIcon("mondrian"));
-#else
-  SetIcon(wxIcon(mondrian_xpm));
-#endif  
+  SetIcon(wxICON(mondrian));
   
 //  const int widths[] = { -1 };
   CreateStatusBar();
@@ -228,6 +225,17 @@ void DnDFrame::OnQuit(wxCommandEvent& /* event */)
   Close(TRUE);
 }
 
+void DnDFrame::OnPaint(wxPaintEvent& /*event*/)
+{
+  int w = 0;
+  int h = 0;
+  GetClientSize( &w, &h );
+  
+  wxPaintDC dc(this);
+  dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL ) );
+  dc.DrawText( "Drag text from here!", 20, h-20 );
+}
+
 void DnDFrame::OnDrag(wxCommandEvent& /* event */)
 {
   wxString strText = wxGetTextFromUser
index a6c2e46fc1a3291e76e09b04495b99f616d13161..aad482c103dddf0e657bb2dfc97aa5b33c326d83 100644 (file)
@@ -188,13 +188,13 @@ void wxGenericFontDialog::CreateWidgets(void)
 {
   wxBeginBusyCursor();
 
-  fontRect.x = 5;
+  fontRect.x = 10;
 #ifdef __X__
   fontRect.y = 125;
 #else
   fontRect.y = 115;
 #endif
-  fontRect.width = 350;
+  fontRect.width = 430;
   fontRect.height = 100;
 
   /*
@@ -254,10 +254,10 @@ void wxGenericFontDialog::CreateWidgets(void)
 
   fontRect.y+=y+5; //NL mod
 
-  int by = (fontRect.y + fontRect.height + 5);
+  int by = (fontRect.y + fontRect.height + 10);
 
-  wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(5, by));
-  (void) new wxButton(this, wxID_OK, _("Cancel"), wxPoint(50, by));
+  wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(220, by), wxSize(100,-1));
+  (void) new wxButton(this, wxID_OK, _("Cancel"), wxPoint(340, by), wxSize(100,-1));
 
   familyChoice->SetStringSelection( wxFontFamilyIntToString(dialogFont.GetFamily()) );
   styleChoice->SetStringSelection(wxFontStyleIntToString(dialogFont.GetStyle()));
index dbde8255cb1c549333a9f023d178d3945131eba0..1ec3f4acc305ed54171b345933ac27cf01e8fcfc 100644 (file)
@@ -30,6 +30,7 @@
 #include "wx/app.h"
 #include "wx/frame.h"
 #include "wx/stattext.h"
+#include "wx/statbox.h"
 #include "wx/button.h"
 #include "wx/checkbox.h"
 #include "wx/textctrl.h"
@@ -300,22 +301,10 @@ wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow *parent, wxPrintSe
   if ( data )
     printData = *data;
 
-  int buttonWidth = 65;
-  int buttonHeight = 25;
-  int spacing = 5;
-  int yPos = 5;
-  int xPos = 5;
-
-  wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(xPos, yPos), wxSize(buttonWidth, buttonHeight));
-  xPos += buttonWidth + spacing;
-  (void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(xPos, yPos), wxSize(buttonWidth, buttonHeight));
-
-  okButton->SetDefault();
-  okButton->SetFocus();
-
-  yPos += 35;
-  xPos = 5;
+  (void) new wxStaticBox(this, wxPRINTID_STATIC, _("Paper size"), wxPoint(10, 10), wxSize(200,60) );
 
+  int xPos = 20;
+  int yPos = 30;
   paperTypeChoice = CreatePaperTypeChoice(&xPos, &yPos);
 
   wxString *choices =  new wxString[2];
@@ -323,30 +312,29 @@ wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow *parent, wxPrintSe
   choices[1] = _("Landscape");
 
   orientationRadioBox = new wxRadioBox(this, wxPRINTID_ORIENTATION, _("Orientation"),
-    wxPoint(xPos, yPos), wxSize(-1, -1), 2, choices, 2);
+    wxPoint(10, 80), wxSize(-1, -1), 2, choices, 2);
   orientationRadioBox->SetSelection(0);
 
-  xPos += 200;
-
-  colourCheckBox = new wxCheckBox(this, wxPRINTID_PRINTCOLOUR, _("Print in colour"), wxPoint(xPos, yPos));
+  (void) new wxStaticBox(this, wxPRINTID_STATIC, _("Options"), wxPoint(10, 130), wxSize(200,50) );
+  
+  colourCheckBox = new wxCheckBox(this, wxPRINTID_PRINTCOLOUR, _("Print in colour"), wxPoint(15, 145));
+  
 
-  xPos = 5;
-  yPos += 60;
+  (void) new wxStaticBox(this, wxPRINTID_STATIC, _("Print spooling"), wxPoint(230, 10), wxSize(200,170) );
+  
+  (void) new wxStaticText(this, wxPRINTID_STATIC, _("Printer command:"), wxPoint(240, 30));
 
-  int staticWidth = 100;
-  int textWidth = 120;
-  spacing = 10;
+  printerCommandText = new wxTextCtrl(this, wxPRINTID_COMMAND, "", wxPoint(260, 55), wxSize(150, -1));
 
-  (void) new wxStaticText(this, wxPRINTID_STATIC, _("Printer command:"), wxPoint(xPos, yPos));
-  xPos += staticWidth;
+  (void) new wxStaticText(this, wxPRINTID_STATIC, _("Printer options:"), wxPoint(240, 110));
 
-  printerCommandText = new wxTextCtrl(this, wxPRINTID_COMMAND, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
-  xPos += textWidth + spacing;
+  printerOptionsText = new wxTextCtrl(this, wxPRINTID_OPTIONS, "", wxPoint(260, 135), wxSize(150, -1));
 
-  (void) new wxStaticText(this, wxPRINTID_STATIC, _("Printer options:"), wxPoint(xPos, yPos));
-  xPos += staticWidth;
+  wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(240, 200), wxSize(100, -1));
+  (void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(360, 200), wxSize(100, -1));
 
-  printerOptionsText = new wxTextCtrl(this, wxPRINTID_OPTIONS, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
+  okButton->SetDefault();
+  okButton->SetFocus();
 
   Fit();
   Centre(wxBOTH);
@@ -422,12 +410,9 @@ wxChoice *wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x, int *y)
       sel = i;
   }
 
-  (void) new wxStaticText(this, wxPRINTID_STATIC, _("Paper size"), wxPoint(*x, *y));
-  *y += 25;
-
-  wxChoice *choice = new wxChoice(this, wxPRINTID_PAPERSIZE, wxPoint(*x, *y), wxSize(300, -1), n,
+  wxChoice *choice = new wxChoice(this, wxPRINTID_PAPERSIZE, wxPoint(*x, *y), wxSize(170, -1), n,
     choices);
-  *y += 35;
+    
   delete[] choices;
 
   choice->SetSelection(sel);
index 10b56ff272ebbd410a14fb61f62d2b9bc97949f3..1ab6f2c545c4628422f54dc531bd10cda0be7435 100644 (file)
@@ -21,30 +21,87 @@ wxClipboard *wxTheClipboard = (wxClipboard*) NULL;
 
 GdkAtom  g_textAtom        = 0;
 GdkAtom  g_clipboardAtom   = 0;
+GdkAtom  g_targetsAtom     = 0;
 
 //-----------------------------------------------------------------------------
-// functions
+// reminder
 //-----------------------------------------------------------------------------
 
-void wxInitClipboard()
+/* The contents of a selection are returned in a GtkSelectionData
+   structure. selection/target identify the request. 
+   type specifies the type of the return; if length < 0, and
+   the data should be ignored. This structure has object semantics -
+   no fields should be modified directly, they should not be created
+   directly, and pointers to them should not be stored beyond the duration of
+   a callback. (If the last is changed, we'll need to add reference
+   counting)
+
+struct _GtkSelectionData
 {
-  if (wxTheClipboard) delete wxTheClipboard;
-  wxTheClipboard = new wxClipboard();
-}
+  GdkAtom selection;
+  GdkAtom target;
+  GdkAtom type;
+  gint   format;
+  guchar *data;
+  gint   length;
+};
+
+*/
 
-void wxDoneClipboard()
+//-----------------------------------------------------------------------------
+// "selection_received" for targets
+//-----------------------------------------------------------------------------
+
+static void
+targets_selection_received( GtkWidget *WXUNUSED(widget), 
+                            GtkSelectionData *selection_data, 
+                           wxClipboard *clipboard )
 {
-  if (wxTheClipboard) delete wxTheClipboard;
-  wxTheClipboard = (wxClipboard*) NULL;
+  if (!wxTheClipboard) return;
+  
+  if (selection_data->length <= 0) return;
+  
+  // make sure we got the data in the correct form 
+  if (selection_data->type != GDK_SELECTION_TYPE_ATOM) return;
+  
+  // the atoms we received, holding a list of targets (= formats) 
+  GdkAtom *atoms = (GdkAtom *)selection_data->data;
+
+  for (unsigned int i=0; i<selection_data->length/sizeof(GdkAtom); i++)
+  {
+     if (atoms[i] == clipboard->m_targetRequested)
+     {
+       clipboard->m_formatSupported = TRUE;
+       return;
+     }
+  }
+
+  return;
 }
 
 //-----------------------------------------------------------------------------
-// "selection_received"
+// "selection_received" for the actual data
 //-----------------------------------------------------------------------------
 
 static void 
-selection_received( GtkWidget *widget, GtkSelectionData *selection_data, gpointer data )
+selection_received( GtkWidget *WXUNUSED(widget), 
+                    GtkSelectionData *selection_data, 
+                   wxClipboard *clipboard )
 {
+  if (!wxTheClipboard) return;
+  
+  if (selection_data->length <= 0) return;
+  
+  size_t size = (size_t) selection_data->length;
+  
+  // make sure we got the data in the correct form 
+  if (selection_data->type != GDK_SELECTION_TYPE_STRING) return;
+  
+  clipboard->m_receivedSize = size;
+  
+  clipboard->m_receivedData = new char[size+1];
+  
+  memcpy( clipboard->m_receivedData, selection_data->data, size);  
 }
 
 //-----------------------------------------------------------------------------
@@ -52,13 +109,13 @@ selection_received( GtkWidget *widget, GtkSelectionData *selection_data, gpointe
 //-----------------------------------------------------------------------------
 
 static gint
-selection_clear( GtkWidget *widget, GdkEventSelection *event )
+selection_clear( GtkWidget *WXUNUSED(widget), GdkEventSelection *WXUNUSED(event) )
 {
-  /* The clipboard is no longer in our hands. We can delete the
-   * clipboard data. I hope I got that one right... */
-    
   if (!wxTheClipboard) return TRUE;
   
+  /* the clipboard is no longer in our hands. we can delete the
+   * clipboard data. I hope I got that one right... */
+    
   wxTheClipboard->SetData( (wxDataObject*) NULL );
   
   return TRUE;
@@ -115,9 +172,22 @@ wxClipboard::wxClipboard()
                      
   if (!g_clipboardAtom) g_clipboardAtom = gdk_atom_intern( "CLIPBOARD", FALSE );
   if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
+  if (!g_targetsAtom) g_targetsAtom = gdk_atom_intern ("TARGETS", FALSE);
+  
+  m_receivedData = (char*)NULL;
+  m_receivedSize = 0;
+  m_formatSupported = FALSE;
+  m_targetRequested = 0;
 }
 
 wxClipboard::~wxClipboard()
+{
+  Clear();  
+  
+  if (m_clipboardWidget) gtk_widget_destroy( m_clipboardWidget );
+}
+
+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 */
@@ -127,7 +197,18 @@ wxClipboard::~wxClipboard()
     delete m_data;
     gtk_selection_owner_set( (GtkWidget*) NULL, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME );
   }
-  if (m_clipboardWidget) gtk_widget_destroy( m_clipboardWidget );
+  
+  m_receivedSize = 0;
+  
+  if (m_receivedData)
+  {
+    delete[] m_receivedData;
+    m_receivedData = (char*) NULL;
+  }
+  
+  m_targetRequested = 0;
+  
+  m_formatSupported = FALSE;
 }
 
 void wxClipboard::SetData( wxDataObject *data )
@@ -147,14 +228,6 @@ void wxClipboard::SetData( wxDataObject *data )
   
   switch (m_data->GetPreferredFormat())
   {
-/*
-    case wxDF_STRING:
-      gtk_selection_add_handler( m_clipboardWidget, 
-                                 g_clipboardAtom, 
-                                GDK_TARGET_STRING,
-                                selection_handler,
-                                NULL );
-      break;
     case wxDF_TEXT:
       gtk_selection_add_handler( m_clipboardWidget, 
                                  g_clipboardAtom, 
@@ -162,23 +235,108 @@ void wxClipboard::SetData( wxDataObject *data )
                                 selection_handler,
                                 NULL );
       break;
-*/
     default:
       break;
   }
 }
 
-void *wxClipboard::GetData( wxDataFormat format, size_t *length )
+bool wxClipboard::IsSupportedFormat( wxDataFormat format )
+{
+  m_targetRequested = 0;
+  
+  if (format == wxDF_TEXT)
+  {
+//     m_targetRequested = g_textAtom;
+     m_targetRequested = GDK_TARGET_STRING;
+  }
+  
+  if (m_targetRequested == 0) return FALSE;
+
+  gtk_signal_connect( GTK_OBJECT(m_clipboardWidget), 
+                      "selection_received",
+                     GTK_SIGNAL_FUNC( targets_selection_received ), 
+                     (gpointer) this );
+  
+  m_formatSupported = FALSE;
+  
+  gtk_selection_convert( m_clipboardWidget,
+                        g_clipboardAtom, 
+                        g_targetsAtom,
+                        GDK_CURRENT_TIME );
+
+  gtk_signal_disconnect_by_func( GTK_OBJECT(m_clipboardWidget), 
+                                GTK_SIGNAL_FUNC( targets_selection_received ),
+                                (gpointer) this );
+  
+  if (!m_formatSupported) return FALSE;
+  
+  return TRUE;
+}
+
+bool wxClipboard::ObtainData( wxDataFormat format )
 {
-  if (!IsAvailable(format))
+  m_receivedSize = 0;
+  
+  if (m_receivedData)
   {
-    if (length) *length = 0;
-    return NULL;
+    delete[] m_receivedData;
+    m_receivedData = (char*) NULL;
   }
-  return NULL;
+  
+  m_targetRequested = 0;
+  
+  if (format == wxDF_TEXT)
+  {
+//     m_targetRequested = g_textAtom;
+     m_targetRequested = GDK_TARGET_STRING;
+  }
+  
+  if (m_targetRequested == 0) return FALSE;
+
+  gtk_signal_connect( GTK_OBJECT(m_clipboardWidget), 
+                      "selection_received",
+                     GTK_SIGNAL_FUNC( selection_received ), 
+                     (gpointer) this );
+
+  gtk_selection_convert( m_clipboardWidget,
+                        g_clipboardAtom, 
+                        m_targetRequested,
+                        GDK_CURRENT_TIME );
+  
+  gtk_signal_disconnect_by_func( GTK_OBJECT(m_clipboardWidget), 
+                                GTK_SIGNAL_FUNC( selection_received ),
+                                (gpointer) this );
+    
+  if (m_receivedSize == 0) return FALSE;
+  
+  return TRUE;
+}
+
+size_t wxClipboard::GetDataSize() const
+{
+  return m_receivedSize;
+}
+
+void wxClipboard::GetDataHere( void *data ) const
+{
+  memcpy(data, m_receivedData, m_receivedSize );
 }
 
-bool wxClipboard::IsAvailable( wxDataFormat WXUNUSED(format) )
+//-----------------------------------------------------------------------------
+// wxClipboardModule
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule,wxModule)
+
+bool wxClipboardModule::OnInit()
+{
+  wxTheClipboard = new wxClipboard();
+  
+  return TRUE;
+}
+
+void wxClipboardModule::OnExit()
 {
-  return FALSE;
+  if (wxTheClipboard) delete wxTheClipboard;
+  wxTheClipboard = (wxClipboard*) NULL;
 }
index 2b894ea99552c3b9e344ccd6e5bfa98e8fa0b0c9..8df9096096e06ab6cf4fafeb038f32e005b2de88 100644 (file)
@@ -15,7 +15,8 @@
 #include "wx/window.h"
 #include "wx/app.h"
 #include "wx/gdicmn.h"
-#include <wx/intl.h>
+#include "wx/intl.h"
+#include "wx/utils.h"
 
 #include "gdk/gdkprivate.h"
 
@@ -622,6 +623,10 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
 // wxDropSource
 //-------------------------------------------------------------------------
 
+static void
+shape_motion (GtkWidget      *widget, 
+             GdkEventMotion */*event*/);
+             
 //-----------------------------------------------------------------------------
 // drag request
 
@@ -722,8 +727,9 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
 
          gtk_widget_hide (drop_icon);
        }
+       
 
-      gdk_dnd_set_drag_shape(drag_icon->window,
+    gdk_dnd_set_drag_shape( drag_icon->window,
                             &hotspot_1,
                             drop_icon->window,
                             &hotspot_2);
@@ -771,10 +777,15 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
   
   int x = 0;
   int y = 0;
-  gdk_window_get_pointer( m_widget->window, &x, &y, (GdkModifierType *) NULL );
+  wxGetMousePosition( &x, &y );  
   
   gdk_dnd_display_drag_cursor( x, y, FALSE, TRUE );
   
+/*
+    shape_motion( drag_icon, (GdkEventMotion *)NULL );
+    shape_motion( drop_icon, (GdkEventMotion *)NULL );
+*/
+    
   while (gdk_dnd.drag_really || gdk_dnd.drag_perhaps) wxYield();
   
   UnregisterWindow();
@@ -838,15 +849,16 @@ shape_pressed (GtkWidget *widget, GdkEventButton *event)
   if (event->type != GDK_BUTTON_PRESS)
     return;
 
-  p = gtk_object_get_user_data (GTK_OBJECT(widget));
+  p = (CursorOffset *)gtk_object_get_user_data (GTK_OBJECT(widget));
   p->x = (int) event->x;
   p->y = (int) event->y;
 
   gtk_grab_add (widget);
   gdk_pointer_grab (widget->window, TRUE,
-                   GDK_BUTTON_RELEASE_MASK |
-                   GDK_BUTTON_MOTION_MASK |
-                   GDK_POINTER_MOTION_HINT_MASK,
+                   (GdkEventMask)
+                     (GDK_BUTTON_RELEASE_MASK |
+                      GDK_BUTTON_MOTION_MASK |
+                      GDK_POINTER_MOTION_HINT_MASK),
                    NULL, NULL, 0);
 }
 
@@ -860,13 +872,13 @@ shape_released (GtkWidget *widget)
 
 static void
 shape_motion (GtkWidget      *widget, 
-             GdkEventMotion *event)
+             GdkEventMotion */*event*/)
 {
   gint xp, yp;
   CursorOffset * p;
   GdkModifierType mask;
 
-  p = gtk_object_get_user_data (GTK_OBJECT (widget));
+  p = (CursorOffset *)gtk_object_get_user_data (GTK_OBJECT (widget));
 
   /*
    * Can't use event->x / event->y here 
@@ -899,7 +911,7 @@ shape_create_icon (char     **data,
   /*
    * GDK_WINDOW_TOPLEVEL works also, giving you a title border
    */
-  window = gtk_window_new (window_type);
+  window = gtk_window_new ((GtkWindowType)window_type);
   
   fixed = gtk_fixed_new ();
   gtk_widget_set_usize (fixed, 100,100);
index 10b56ff272ebbd410a14fb61f62d2b9bc97949f3..1ab6f2c545c4628422f54dc531bd10cda0be7435 100644 (file)
@@ -21,30 +21,87 @@ wxClipboard *wxTheClipboard = (wxClipboard*) NULL;
 
 GdkAtom  g_textAtom        = 0;
 GdkAtom  g_clipboardAtom   = 0;
+GdkAtom  g_targetsAtom     = 0;
 
 //-----------------------------------------------------------------------------
-// functions
+// reminder
 //-----------------------------------------------------------------------------
 
-void wxInitClipboard()
+/* The contents of a selection are returned in a GtkSelectionData
+   structure. selection/target identify the request. 
+   type specifies the type of the return; if length < 0, and
+   the data should be ignored. This structure has object semantics -
+   no fields should be modified directly, they should not be created
+   directly, and pointers to them should not be stored beyond the duration of
+   a callback. (If the last is changed, we'll need to add reference
+   counting)
+
+struct _GtkSelectionData
 {
-  if (wxTheClipboard) delete wxTheClipboard;
-  wxTheClipboard = new wxClipboard();
-}
+  GdkAtom selection;
+  GdkAtom target;
+  GdkAtom type;
+  gint   format;
+  guchar *data;
+  gint   length;
+};
+
+*/
 
-void wxDoneClipboard()
+//-----------------------------------------------------------------------------
+// "selection_received" for targets
+//-----------------------------------------------------------------------------
+
+static void
+targets_selection_received( GtkWidget *WXUNUSED(widget), 
+                            GtkSelectionData *selection_data, 
+                           wxClipboard *clipboard )
 {
-  if (wxTheClipboard) delete wxTheClipboard;
-  wxTheClipboard = (wxClipboard*) NULL;
+  if (!wxTheClipboard) return;
+  
+  if (selection_data->length <= 0) return;
+  
+  // make sure we got the data in the correct form 
+  if (selection_data->type != GDK_SELECTION_TYPE_ATOM) return;
+  
+  // the atoms we received, holding a list of targets (= formats) 
+  GdkAtom *atoms = (GdkAtom *)selection_data->data;
+
+  for (unsigned int i=0; i<selection_data->length/sizeof(GdkAtom); i++)
+  {
+     if (atoms[i] == clipboard->m_targetRequested)
+     {
+       clipboard->m_formatSupported = TRUE;
+       return;
+     }
+  }
+
+  return;
 }
 
 //-----------------------------------------------------------------------------
-// "selection_received"
+// "selection_received" for the actual data
 //-----------------------------------------------------------------------------
 
 static void 
-selection_received( GtkWidget *widget, GtkSelectionData *selection_data, gpointer data )
+selection_received( GtkWidget *WXUNUSED(widget), 
+                    GtkSelectionData *selection_data, 
+                   wxClipboard *clipboard )
 {
+  if (!wxTheClipboard) return;
+  
+  if (selection_data->length <= 0) return;
+  
+  size_t size = (size_t) selection_data->length;
+  
+  // make sure we got the data in the correct form 
+  if (selection_data->type != GDK_SELECTION_TYPE_STRING) return;
+  
+  clipboard->m_receivedSize = size;
+  
+  clipboard->m_receivedData = new char[size+1];
+  
+  memcpy( clipboard->m_receivedData, selection_data->data, size);  
 }
 
 //-----------------------------------------------------------------------------
@@ -52,13 +109,13 @@ selection_received( GtkWidget *widget, GtkSelectionData *selection_data, gpointe
 //-----------------------------------------------------------------------------
 
 static gint
-selection_clear( GtkWidget *widget, GdkEventSelection *event )
+selection_clear( GtkWidget *WXUNUSED(widget), GdkEventSelection *WXUNUSED(event) )
 {
-  /* The clipboard is no longer in our hands. We can delete the
-   * clipboard data. I hope I got that one right... */
-    
   if (!wxTheClipboard) return TRUE;
   
+  /* the clipboard is no longer in our hands. we can delete the
+   * clipboard data. I hope I got that one right... */
+    
   wxTheClipboard->SetData( (wxDataObject*) NULL );
   
   return TRUE;
@@ -115,9 +172,22 @@ wxClipboard::wxClipboard()
                      
   if (!g_clipboardAtom) g_clipboardAtom = gdk_atom_intern( "CLIPBOARD", FALSE );
   if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
+  if (!g_targetsAtom) g_targetsAtom = gdk_atom_intern ("TARGETS", FALSE);
+  
+  m_receivedData = (char*)NULL;
+  m_receivedSize = 0;
+  m_formatSupported = FALSE;
+  m_targetRequested = 0;
 }
 
 wxClipboard::~wxClipboard()
+{
+  Clear();  
+  
+  if (m_clipboardWidget) gtk_widget_destroy( m_clipboardWidget );
+}
+
+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 */
@@ -127,7 +197,18 @@ wxClipboard::~wxClipboard()
     delete m_data;
     gtk_selection_owner_set( (GtkWidget*) NULL, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME );
   }
-  if (m_clipboardWidget) gtk_widget_destroy( m_clipboardWidget );
+  
+  m_receivedSize = 0;
+  
+  if (m_receivedData)
+  {
+    delete[] m_receivedData;
+    m_receivedData = (char*) NULL;
+  }
+  
+  m_targetRequested = 0;
+  
+  m_formatSupported = FALSE;
 }
 
 void wxClipboard::SetData( wxDataObject *data )
@@ -147,14 +228,6 @@ void wxClipboard::SetData( wxDataObject *data )
   
   switch (m_data->GetPreferredFormat())
   {
-/*
-    case wxDF_STRING:
-      gtk_selection_add_handler( m_clipboardWidget, 
-                                 g_clipboardAtom, 
-                                GDK_TARGET_STRING,
-                                selection_handler,
-                                NULL );
-      break;
     case wxDF_TEXT:
       gtk_selection_add_handler( m_clipboardWidget, 
                                  g_clipboardAtom, 
@@ -162,23 +235,108 @@ void wxClipboard::SetData( wxDataObject *data )
                                 selection_handler,
                                 NULL );
       break;
-*/
     default:
       break;
   }
 }
 
-void *wxClipboard::GetData( wxDataFormat format, size_t *length )
+bool wxClipboard::IsSupportedFormat( wxDataFormat format )
+{
+  m_targetRequested = 0;
+  
+  if (format == wxDF_TEXT)
+  {
+//     m_targetRequested = g_textAtom;
+     m_targetRequested = GDK_TARGET_STRING;
+  }
+  
+  if (m_targetRequested == 0) return FALSE;
+
+  gtk_signal_connect( GTK_OBJECT(m_clipboardWidget), 
+                      "selection_received",
+                     GTK_SIGNAL_FUNC( targets_selection_received ), 
+                     (gpointer) this );
+  
+  m_formatSupported = FALSE;
+  
+  gtk_selection_convert( m_clipboardWidget,
+                        g_clipboardAtom, 
+                        g_targetsAtom,
+                        GDK_CURRENT_TIME );
+
+  gtk_signal_disconnect_by_func( GTK_OBJECT(m_clipboardWidget), 
+                                GTK_SIGNAL_FUNC( targets_selection_received ),
+                                (gpointer) this );
+  
+  if (!m_formatSupported) return FALSE;
+  
+  return TRUE;
+}
+
+bool wxClipboard::ObtainData( wxDataFormat format )
 {
-  if (!IsAvailable(format))
+  m_receivedSize = 0;
+  
+  if (m_receivedData)
   {
-    if (length) *length = 0;
-    return NULL;
+    delete[] m_receivedData;
+    m_receivedData = (char*) NULL;
   }
-  return NULL;
+  
+  m_targetRequested = 0;
+  
+  if (format == wxDF_TEXT)
+  {
+//     m_targetRequested = g_textAtom;
+     m_targetRequested = GDK_TARGET_STRING;
+  }
+  
+  if (m_targetRequested == 0) return FALSE;
+
+  gtk_signal_connect( GTK_OBJECT(m_clipboardWidget), 
+                      "selection_received",
+                     GTK_SIGNAL_FUNC( selection_received ), 
+                     (gpointer) this );
+
+  gtk_selection_convert( m_clipboardWidget,
+                        g_clipboardAtom, 
+                        m_targetRequested,
+                        GDK_CURRENT_TIME );
+  
+  gtk_signal_disconnect_by_func( GTK_OBJECT(m_clipboardWidget), 
+                                GTK_SIGNAL_FUNC( selection_received ),
+                                (gpointer) this );
+    
+  if (m_receivedSize == 0) return FALSE;
+  
+  return TRUE;
+}
+
+size_t wxClipboard::GetDataSize() const
+{
+  return m_receivedSize;
+}
+
+void wxClipboard::GetDataHere( void *data ) const
+{
+  memcpy(data, m_receivedData, m_receivedSize );
 }
 
-bool wxClipboard::IsAvailable( wxDataFormat WXUNUSED(format) )
+//-----------------------------------------------------------------------------
+// wxClipboardModule
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule,wxModule)
+
+bool wxClipboardModule::OnInit()
+{
+  wxTheClipboard = new wxClipboard();
+  
+  return TRUE;
+}
+
+void wxClipboardModule::OnExit()
 {
-  return FALSE;
+  if (wxTheClipboard) delete wxTheClipboard;
+  wxTheClipboard = (wxClipboard*) NULL;
 }
index 2b894ea99552c3b9e344ccd6e5bfa98e8fa0b0c9..8df9096096e06ab6cf4fafeb038f32e005b2de88 100644 (file)
@@ -15,7 +15,8 @@
 #include "wx/window.h"
 #include "wx/app.h"
 #include "wx/gdicmn.h"
-#include <wx/intl.h>
+#include "wx/intl.h"
+#include "wx/utils.h"
 
 #include "gdk/gdkprivate.h"
 
@@ -622,6 +623,10 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
 // wxDropSource
 //-------------------------------------------------------------------------
 
+static void
+shape_motion (GtkWidget      *widget, 
+             GdkEventMotion */*event*/);
+             
 //-----------------------------------------------------------------------------
 // drag request
 
@@ -722,8 +727,9 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
 
          gtk_widget_hide (drop_icon);
        }
+       
 
-      gdk_dnd_set_drag_shape(drag_icon->window,
+    gdk_dnd_set_drag_shape( drag_icon->window,
                             &hotspot_1,
                             drop_icon->window,
                             &hotspot_2);
@@ -771,10 +777,15 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
   
   int x = 0;
   int y = 0;
-  gdk_window_get_pointer( m_widget->window, &x, &y, (GdkModifierType *) NULL );
+  wxGetMousePosition( &x, &y );  
   
   gdk_dnd_display_drag_cursor( x, y, FALSE, TRUE );
   
+/*
+    shape_motion( drag_icon, (GdkEventMotion *)NULL );
+    shape_motion( drop_icon, (GdkEventMotion *)NULL );
+*/
+    
   while (gdk_dnd.drag_really || gdk_dnd.drag_perhaps) wxYield();
   
   UnregisterWindow();
@@ -838,15 +849,16 @@ shape_pressed (GtkWidget *widget, GdkEventButton *event)
   if (event->type != GDK_BUTTON_PRESS)
     return;
 
-  p = gtk_object_get_user_data (GTK_OBJECT(widget));
+  p = (CursorOffset *)gtk_object_get_user_data (GTK_OBJECT(widget));
   p->x = (int) event->x;
   p->y = (int) event->y;
 
   gtk_grab_add (widget);
   gdk_pointer_grab (widget->window, TRUE,
-                   GDK_BUTTON_RELEASE_MASK |
-                   GDK_BUTTON_MOTION_MASK |
-                   GDK_POINTER_MOTION_HINT_MASK,
+                   (GdkEventMask)
+                     (GDK_BUTTON_RELEASE_MASK |
+                      GDK_BUTTON_MOTION_MASK |
+                      GDK_POINTER_MOTION_HINT_MASK),
                    NULL, NULL, 0);
 }
 
@@ -860,13 +872,13 @@ shape_released (GtkWidget *widget)
 
 static void
 shape_motion (GtkWidget      *widget, 
-             GdkEventMotion *event)
+             GdkEventMotion */*event*/)
 {
   gint xp, yp;
   CursorOffset * p;
   GdkModifierType mask;
 
-  p = gtk_object_get_user_data (GTK_OBJECT (widget));
+  p = (CursorOffset *)gtk_object_get_user_data (GTK_OBJECT (widget));
 
   /*
    * Can't use event->x / event->y here 
@@ -899,7 +911,7 @@ shape_create_icon (char     **data,
   /*
    * GDK_WINDOW_TOPLEVEL works also, giving you a title border
    */
-  window = gtk_window_new (window_type);
+  window = gtk_window_new ((GtkWindowType)window_type);
   
   fixed = gtk_fixed_new ();
   gtk_widget_set_usize (fixed, 100,100);