PageRenderTime 21ms CodeModel.GetById 14ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/src/wrappers/gtk/library/gtk_style.e

http://github.com/tybor/Liberty
Specman e | 93 lines | 65 code | 18 blank | 10 comment | 2 complexity | 568198d6328a7ec9a6a90cae532e4c9a MD5 | raw file
 1indexing
 2	description: "Styles -- Functions for drawing widget parts"
 3	copyright: "[
 4					Copyright (C) 2006 eiffel-libraries team, GTK+ team
 5					
 6					This library is free software; you can redistribute it and/or
 7					modify it under the terms of the GNU Lesser General Public License
 8					as published by the Free Software Foundation; either version 2.1 of
 9					the License, or (at your option) any later version.
10					
11					This library is distributed in the hope that it will be useful, but
12					WITHOUT ANY WARRANTY; without even the implied warranty of
13					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14					Lesser General Public License for more details.
15
16					You should have received a copy of the GNU Lesser General Public
17					License along with this library; if not, write to the Free Software
18					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19					02110-1301 USA
20			]"
21
22class GTK_STYLE
23
24	-- The C structure associated to this wrapper
25	-- represents a widget's style.  As such
26	-- it shouldn't be freed by our code, but
27	-- shall be freed by C when the widget is freed.
28
29inherit G_OBJECT
30
31insert
32	GTK_STATE_TYPE
33	GTK_STYLE_EXTERNALS
34
35creation from_external_pointer
36
37feature -- size
38
39	struct_size: INTEGER is
40		external "C inline use <gtk/gtk.h>"
41		alias "sizeof(GtkStyle)"
42		end
43
44feature -- Accessq
45	-- Using strings for color lookups is inefficient! And it is much less
46	-- efficient to search for the index of an item in an array which contains
47	-- the given "pen-name" and then using it to get access the low-level C
48	-- array. Not to speak of correctness. How easy is to break the contract!
49	-- As easy as a mistype or much subtler as easy as issuing
50	-- "states.put(2,Void)". Paolo 2008-08-01
51
52	states: FAST_ARRAY [STRING] is
53		once
54			Result := {FAST_ARRAY[STRING] <<"NORMAL", "ACTIVE", "PRELIGHT", "SELECTED", "INSENSITIVE">>}
55		end
56
57	background_color (a_state: STRING): GDK_COLOR is
58		require
59			states.has (a_state)
60		do
61			create Result.from_external_pointer (gtk_style_get_bg (handle, states.first_index_of(a_state)))
62		end
63
64	foreground_color (a_state: STRING): GDK_COLOR is
65		require
66			states.has (a_state)
67		do
68			create Result.from_external_pointer (gtk_style_get_fg (handle, states.first_index_of(a_state)))
69		end
70
71	text_color (a_state: STRING): GDK_COLOR is
72		require
73			states.has (a_state)
74		do
75			create Result.from_external_pointer (gtk_style_get_text (handle, states.first_index_of(a_state)))
76		end
77
78	base_color (a_state: STRING): GDK_COLOR is
79		require
80			states.has (a_state)
81		do
82			create Result.from_external_pointer (gtk_style_get_base (handle, states.first_index_of(a_state)))
83		end
84
85feature -- Operations
86	set_background_pixmap (a_pixmap: GDK_PIXMAP; a_state: INTEGER) is
87		require
88			is_valid_gtk_state_type (a_state)
89		do
90			gtk_style_set_background(handle, a_pixmap.handle, a_state)
91		end
92
93end -- class GTK_STYLE