File: gdk_pixmap.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 (154 lines) | stat: -rw-r--r-- 2,915 bytes parent folder | download
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
-- Copyright (C) 1999 Richie Bielak and others
-- Licensed under Eiffel Forum Freeware License, version 1;
-- (see forum.txt)
--
indexing

   description: "GDK_PIXMAP"
   author: "Richie Bielak"
   version: "v 0.3.5 GTK+ 1.2.x"

class GDK_PIXMAP

inherit

   GDK_DRAWABLE
      rename
	 drawable as pixmap
      redefine
	 dispose
      end

   GDK_PIXMAP_EXTERNALS
      undefine
	 is_equal, copy
      end

   EGTK_NON_PORTABLE
      undefine
	 is_equal, copy
      end

creation

   make,
   make_from_pointer,
   make_from_data,
   make_from_xpm,
   make_from_xpm_d,
   make_from_pointers

feature

   make (window: GDK_WINDOW; 
	 width, height, depth: INTEGER) is
      require
	 window_not_void: window  /= Void
	 valid_dimensions: (width >= 0) and (height >= 0) and (depth >= 0)
      do
	 pixmap := gdk_pixmap_new(window.window, width, height, depth);
	 ref
      end

   make_from_data (window: GDK_WINDOW; 
		   data: STRING; 
		   width, height, depth: INTEGER;
		   fg, bg: GDK_COLOR) is
      require
	 window_not_void: window  /= Void
	 valid_dimensions: (width >= 0) and (height >= 0) and (depth >= 0)
	 data_not_void: data /= Void
	 colors_not_void: (fg /= Void) and (bg /= Void)
      do
	 pixmap := gdk_npc.np_gdk_pixmap_create_from_data (window.window,
							   data,
							   width, height, depth,
							   fg.color, bg.color)
	 ref
      end

   make_from_xpm (window: GDK_WINDOW; 
		  transparent_color: GDK_COLOR;
		  fname: STRING) is
      require
	 window_not_void: window  /= Void
	 fname_not_void: fname /= Void
      local
	 color: POINTER
      do
	 if transparent_color /= Void then
	    color := transparent_color.color
	 end
	 pixmap := gdk_npc.np_gdk_pixmap_create_from_xpm (window.window,
							  $a_mask,
							  color,
							  fname)
	 ref
	 !!mask.make_from_pointer (a_mask)
      end

   make_from_xpm_d (window: GDK_WINDOW; 
		    transparent_color: GDK_COLOR;
		    data: STRING) is
      require
	 window_not_void: window  /= Void
	 data_not_void: data /= Void
      local
	 color: POINTER
      do
	 if transparent_color /= Void then
	    color := transparent_color.color
	 end
	 pixmap := gdk_npc.np_gdk_pixmap_create_from_xpm_d (window.window,
							    $a_mask,
							    color,
							    data)
	 ref
	 !!mask.make_from_pointer (a_mask)
      end

   make_from_pointers(p, b: POINTER) is
      do
	 make_from_pointer(p)
	 ref
	 !!mask.make_from_pointer(b)
      end
	
   make_from_pointer (p: POINTER) is
      require
	 p_not_void: p /= Void
      do
	 pixmap := p
	 ref
      end

feature -- corresponding mask

   mask: GDK_BITMAP

feature {NONE}

   a_mask: POINTER

feature -- needed for external memory management

   ref is
      do
	 -- returns the value of its argument
	 pixmap := gdk_pixmap_ref (pixmap)
      end

   unref is
      do
	 gdk_pixmap_unref (pixmap)
      end

feature {NONE}

   dispose is
      do
	 precursor
	 unref
      end

end