File: gdk_input_function.e

package info (click to toggle)
egtk 0.3.5.cvs20020302-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,900 kB
  • ctags: 5,118
  • sloc: ansic: 2,212; makefile: 247; sh: 113
file content (117 lines) | stat: -rw-r--r-- 2,363 bytes parent folder | download | duplicates (3)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
-- Copyright (C) 2000  Richie Bielak and others
-- Licensed under Eiffel Forum Freeware License, version 1;
-- (see forum.txt)
--
indexing

	description: "GDK_INPUT_FUNCTION - functions that will be called %
                 %if an I/O event occurs on some file descriptor"
	author: "Richie Bielak"
	version: "v 0.3.5 GTK+ 1.2.x"

class GDK_INPUT_FUNCTION

inherit

	MEMORY
		redefine
			dispose
		end

	EGTK_NON_PORTABLE

feature

	source_fd: INTEGER
			-- file descriptor watched for input

	set_source_fd (fd: INTEGER) is
			-- set the file descriptor to watch
		require
			fd_valid: fd >= 0
		do
			source_fd := fd
		end

	input_add (input_condition: INTEGER; destroy_callback: BOOLEAN) is
			-- define input function
		require
			valid_fd: source_fd >= 0
		do
			if not destroy_callback then
				input_function_id := gdk_npc.c_gdk_input_add (source_fd, 
															  input_condition,
															  Current,
															  $execute,
															  $call_block_pointer)
			else
				input_function_id := gdk_npc.c_gdk_input_add_full (source_fd, 
																   input_condition,
																   Current,
																   $execute,
																   $notify_of_fd_destruction,
																   $call_block_pointer)


			end
		ensure
			defined: input_function_id >= 0
		end

	input_function_id: INTEGER
			-- id assigned by GDK to this input function

	remove_input is
		require
			input_function_id_valid: input_function_id /= 0
		do
			gdk_input_remove (input_function_id)
			input_function_id := 0
		end


feature

	execute (input_condition: INTEGER) is
			-- called when file descriptor is ready for I/O
			-- redefine in descendant
		do
		end

	notify_of_fd_destruction is
			-- redefine in descendant as needed
		do
		end

	
feature {NONE}

	gdk_input_remove (id: INTEGER) is
		external "C"
		end

feature {NONE} -- ISE implementation


	call_block_pointer: POINTER
			-- callback block for input function

	destroy_call_block_pointer: POINTER
			-- callback block for notify destroy function

	dispose is
		do
			if call_block_pointer /= default_pointer then
				c_free_call_back_block (call_block_pointer)
			end
			if destroy_call_block_pointer /= default_pointer then
				c_free_call_back_block (destroy_call_block_pointer)
			end
		end

	c_free_call_back_block (p: POINTER) is
			-- called from dispose
		external "C"
		end

end