forked from cztomczak/cefpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrag_data.pyx
More file actions
51 lines (38 loc) · 1.81 KB
/
drag_data.pyx
File metadata and controls
51 lines (38 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright (c) 2016 CEF Python, see the Authors file.
# All rights reserved. Licensed under BSD 3-clause license.
# Project website: https://github.com/cztomczak/cefpython
include "cefpython.pyx"
cdef DragData_Init(CefRefPtr[CefDragData] cef_drag_data):
cdef DragData drag_data = DragData()
drag_data.cef_drag_data = cef_drag_data
return drag_data
cdef class DragData:
cdef CefRefPtr[CefDragData] cef_drag_data
def __init__(self):
self.cef_drag_data = CefDragData_Create()
self.cef_drag_data.get().SetFragmentText(PyToCefStringValue("none"))
self.cef_drag_data.get().SetFragmentHtml(PyToCefStringValue("none"))
self.cef_drag_data.get().SetFragmentBaseURL(PyToCefStringValue(""))
cpdef py_bool IsLink(self):
return self.cef_drag_data.get().IsLink()
cpdef py_bool IsFragment(self):
return self.cef_drag_data.get().IsFragment()
cpdef py_string GetLinkUrl(self):
return CefToPyString(self.cef_drag_data.get().GetLinkURL())
cpdef py_string GetLinkTitle(self):
return CefToPyString(self.cef_drag_data.get().GetLinkTitle())
cpdef py_string GetFragmentText(self):
return CefToPyString(self.cef_drag_data.get().GetFragmentText())
cpdef py_string GetFragmentHtml(self):
return CefToPyString(self.cef_drag_data.get().GetFragmentHtml())
cpdef PyImage GetImage(self):
cdef CefRefPtr[CefImage] cef_image =\
self.cef_drag_data.get().GetImage()
if not cef_image.get():
raise Exception("Image is not available")
return PyImage_Init(cef_image)
cpdef tuple GetImageHotspot(self):
cdef CefPoint point = self.cef_drag_data.get().GetImageHotspot()
return point.x, point.y
cpdef py_bool HasImage(self):
return self.cef_drag_data.get().HasImage()