]>
Commit | Line | Data |
---|---|---|
7c78e7c7 RR |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: dnd.cpp | |
3 | // Purpose: wxDropTarget class | |
4 | // Author: Robert Roebling | |
5 | // Copyright: Robert Roebling | |
6 | // Licence: wxWindows license | |
7 | /////////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | #ifdef __GNUG__ | |
10 | #pragma implementation "dnd.h" | |
11 | #endif | |
12 | ||
13 | #include "wx/dnd.h" | |
14 | #include "wx/window.h" | |
15 | #include "wx/app.h" | |
16 | #include "wx/gdicmn.h" | |
17 | ||
18 | // ---------------------------------------------------------------------------- | |
19 | // global | |
20 | // ---------------------------------------------------------------------------- | |
21 | ||
22 | extern bool g_blockEventsOnDrag; | |
23 | ||
24 | // ---------------------------------------------------------------------------- | |
25 | // wxDropTarget | |
26 | // ---------------------------------------------------------------------------- | |
27 | ||
28 | wxDropTarget::wxDropTarget() | |
29 | { | |
30 | }; | |
31 | ||
32 | wxDropTarget::~wxDropTarget() | |
33 | { | |
34 | }; | |
35 | ||
36 | // ---------------------------------------------------------------------------- | |
37 | // wxTextDropTarget | |
38 | // ---------------------------------------------------------------------------- | |
39 | ||
40 | bool wxTextDropTarget::OnDrop( long x, long y, const void *pData ) | |
41 | { | |
42 | OnDropText( x, y, (const char*)pData ); | |
43 | return TRUE; | |
44 | }; | |
45 | ||
46 | bool wxTextDropTarget::OnDropText( long x, long y, const char *psz ) | |
47 | { | |
48 | printf( "Got dropped text: %s.\n", psz ); | |
49 | printf( "At x: %d, y: %d.\n", (int)x, (int)y ); | |
50 | return TRUE; | |
51 | }; | |
52 | ||
53 | size_t wxTextDropTarget::GetFormatCount() const | |
54 | { | |
55 | return 1; | |
56 | } | |
57 | ||
58 | wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const | |
59 | { | |
60 | return wxDF_TEXT; | |
61 | } | |
62 | ||
63 | // ---------------------------------------------------------------------------- | |
64 | // wxFileDropTarget | |
65 | // ---------------------------------------------------------------------------- | |
66 | ||
67 | bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const WXUNUSED(aszFiles)[] ) | |
68 | { | |
69 | printf( "Got %d dropped files.\n", (int)nFiles ); | |
70 | printf( "At x: %d, y: %d.\n", (int)x, (int)y ); | |
71 | return TRUE; | |
72 | } | |
73 | ||
74 | bool wxFileDropTarget::OnDrop(long x, long y, const void *WXUNUSED(pData) ) | |
75 | { | |
76 | char *str = "/this/is/a/path.txt"; | |
77 | ||
78 | return OnDropFiles(x, y, 1, &str ); | |
79 | } | |
80 | ||
81 | size_t wxFileDropTarget::GetFormatCount() const | |
82 | { | |
83 | return 1; | |
84 | } | |
85 | ||
86 | wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const | |
87 | { | |
88 | return wxDF_FILENAME; | |
89 | } | |
90 | ||
91 | //------------------------------------------------------------------------- | |
92 | // wxDropSource | |
93 | //------------------------------------------------------------------------- | |
94 | ||
95 | wxDropSource::wxDropSource( wxWindow *WXUNUSED(win) ) | |
96 | { | |
97 | g_blockEventsOnDrag = TRUE; | |
98 | }; | |
99 | ||
100 | wxDropSource::wxDropSource( wxDataObject &data, wxWindow *WXUNUSED(win) ) | |
101 | { | |
102 | g_blockEventsOnDrag = TRUE; | |
103 | ||
104 | m_data = &data; | |
105 | }; | |
106 | ||
107 | void wxDropSource::SetData( wxDataObject &data ) | |
108 | { | |
109 | m_data = &data; | |
110 | }; | |
111 | ||
112 | wxDropSource::~wxDropSource(void) | |
113 | { | |
114 | // if (m_data) delete m_data; | |
115 | ||
116 | g_blockEventsOnDrag = FALSE; | |
117 | }; | |
118 | ||
119 | wxDropSource::DragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) | |
120 | { | |
121 | return Copy; | |
122 | }; | |
123 |