/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

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