/src/wrappers/gtk/library/gtk_color_selection.e

http://github.com/tybor/Liberty · Specman e · 252 lines · 106 code · 30 blank · 116 comment · 2 complexity · a82bc857aa7432efd5ec5b94ccae8bc3 MD5 · raw file

  1. indexing
  2. description: "GtkColorSelection, a widget used to select a color."
  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. date: "$Date:$"
  19. revision: "$Revision:$"
  20. class GTK_COLOR_SELECTION
  21. -- The GtkColorSelection is a widget that is used to select a
  22. -- color. It consists of a color wheel and number of sliders and
  23. -- entry boxes for color parameters such as hue, saturation, value,
  24. -- red, green, blue, and opacity. It is found on the standard color
  25. -- selection dialog box GtkColorSelectionDialog.
  26. inherit GTK_VBOX
  27. rename
  28. make as vbox_make
  29. redefine
  30. struct_size
  31. end
  32. -- TODO: GtkColorSelection implements AtkImplementorIface.
  33. insert
  34. GTK_COLOR_SELECTION_EXTERNALS
  35. creation make, from_external_pointer
  36. feature -- size
  37. struct_size: INTEGER is
  38. external "C inline use <gtk/gtk.h>"
  39. alias "sizeof(GtkColorSelection)"
  40. end
  41. feature
  42. make is
  43. -- Creates a new GtkColorSelection.
  44. do
  45. from_external_pointer(gtk_color_selection_new)
  46. end
  47. feature
  48. current_color: GDK_COLOR is
  49. -- Returns the current color in the GTK_COLOR_SELECTION widget
  50. do
  51. create Result.make
  52. gtk_color_selection_get_current_color (handle, Result.handle)
  53. end
  54. set_current_color (a_color: GDK_COLOR) is
  55. -- Sets the current color to be a_color. The first time this is
  56. -- called, it will also set the original color to be a_color too.
  57. do
  58. gtk_color_selection_set_current_color (handle, a_color.handle)
  59. end
  60. set_has_opacity_control (a_setting: BOOLEAN) is
  61. -- Sets Current color selection to use or not use opacity.
  62. -- colorsel : a GtkColorSelection. has_opacity : TRUE if
  63. -- colorsel can set the opacity, FALSE otherwise.
  64. do
  65. gtk_color_selection_set_has_opacity_control
  66. (handle, a_setting.to_integer)
  67. end
  68. has_opacity_control: BOOLEAN is
  69. -- Does the color selection have an opacity control.
  70. do
  71. Result := (gtk_color_selection_get_has_opacity_control
  72. (handle).to_boolean)
  73. end
  74. set_has_palette (a_setting: BOOLEAN) is
  75. -- Shows or hides the palette based upon the value of `a_setting'.
  76. do
  77. gtk_color_selection_set_has_palette(handle, a_setting.to_integer)
  78. end
  79. has_palette: BOOLEAN is
  80. -- Does the selector have a palette?
  81. do
  82. Result := gtk_color_selection_get_has_palette(handle).to_boolean
  83. end
  84. current_alpha: INTEGER is
  85. -- the current alpha value.
  86. do
  87. Result:=gtk_color_selection_get_current_alpha(handle)
  88. ensure fit_natural_16: Result.in_range(0, 65535)
  89. end
  90. set_current_alpha (an_alpha: INTEGER) is
  91. -- Sets the current opacity to `an_alpha'. The first time
  92. -- this is called, it will also set the original opacity to
  93. -- `an_alpha'.
  94. require fit_natural_16: an_alpha.in_range(0, 65535)
  95. do
  96. gtk_color_selection_set_current_alpha(handle, an_alpha)
  97. ensure set: current_alpha = an_alpha
  98. end
  99. previous_alpha: INTEGER is
  100. -- the previous alpha value.
  101. do
  102. Result:=gtk_color_selection_get_previous_alpha(handle)
  103. ensure fit_natural_16: Result.in_range(0, 65535)
  104. end
  105. set_previous_alpha (an_alpha: INTEGER) is
  106. -- Sets the 'previous' alpha to `an_alpha'. This function
  107. -- should be called with some hesitations, as it might seem
  108. -- confusing to have that alpha change.
  109. require fit_natural_16: an_alpha.in_range(0, 65535)
  110. do
  111. gtk_color_selection_set_previous_alpha(handle, an_alpha)
  112. ensure set: previous_alpha = an_alpha
  113. end
  114. previous_color: GDK_COLOR is
  115. -- the original color value.
  116. do
  117. create Result.make
  118. gtk_color_selection_get_previous_color (handle, Result.handle)
  119. end
  120. set_previous_color (a_color: GDK_COLOR) is
  121. -- Sets the 'previous' color to `a_color'. This function
  122. -- should be called with some hesitations, as it might seem
  123. -- confusing to have that color change. Calling
  124. -- `set_current_color' will also set this color the first
  125. -- time it is called.
  126. require color_not_void: a_color /= Void
  127. do
  128. gtk_color_selection_set_previous_color(handle, a_color.handle)
  129. end
  130. is_adjusting: BOOLEAN is
  131. -- Is the user currently dragging a color around?
  132. do
  133. Result:=(gtk_color_selection_is_adjusting(handle).to_boolean)
  134. end
  135. -- gtk_color_selection_palette_from_string ()
  136. -- gboolean gtk_color_selection_palette_from_string (const gchar
  137. -- *str, GdkColor **colors, gint *n_colors);
  138. -- Parses a color palette string; the string is a colon-separated
  139. -- list of color names readable by gdk_color_parse().
  140. -- str : a string encoding a color palette.
  141. -- colors : return location for allocated array of GdkColor.
  142. -- n_colors : return location for length of array.
  143. -- Returns : TRUE if a palette was successfully parsed.
  144. -- gtk_color_selection_palette_to_string ()
  145. --
  146. -- gchar* gtk_color_selection_palette_to_string
  147. -- (const GdkColor *colors,
  148. -- gint n_colors);
  149. --
  150. -- Encodes a palette as a string, useful for persistent storage.
  151. --
  152. -- colors : an array of colors.
  153. -- n_colors : length of the array.
  154. -- Returns : allocated string encoding the palette.
  155. -- gtk_color_selection_set_change_palette_hook ()
  156. --
  157. -- gtk_color_selection_set_change_palette_with_screen_hook ()
  158. --
  159. -- GtkColorSelectionChangePaletteWithScreenFunc gtk_color_selection_set_change_palette_with_screen_hook
  160. -- (GtkColorSelectionChangePaletteWithScreenFunc func);
  161. --
  162. -- Installs a global function to be called whenever the user tries to modify the palette in a color selection. This function should save the new palette contents, and update the GtkSettings property "gtk-color-palette" so all GtkColorSelection widgets will be modified.
  163. --
  164. -- func : a function to call when the custom palette needs saving.
  165. -- Returns : the previous change palette hook (that was replaced).
  166. --
  167. -- Since 2.2
  168. -- GtkColorSelectionChangePaletteWithScreenFunc ()
  169. --
  170. -- void (*GtkColorSelectionChangePaletteWithScreenFunc)
  171. -- (GdkScreen *screen,
  172. -- const GdkColor *colors,
  173. -- gint n_colors);
  174. --
  175. -- screen :
  176. -- colors :
  177. -- n_colors :
  178. --
  179. -- Since 2.2
  180. feature -- Properties
  181. -- "current-alpha" guint : Read / Write
  182. -- "current-color" GdkColor : Read / Write
  183. -- "has-opacity-control" gboolean : Read / Write
  184. -- "has-palette" gboolean : Read / Write
  185. -- Property Details
  186. -- The "current-alpha" property
  187. --
  188. -- "current-alpha" guint : Read / Write
  189. --
  190. -- The current opacity value (0 fully transparent, 65535 fully opaque).
  191. --
  192. -- Allowed values: <= 65535
  193. --
  194. -- Default value: 65535
  195. -- The "current-color" property
  196. --
  197. -- "current-color" GdkColor : Read / Write
  198. --
  199. -- The current color.
  200. -- The "has-opacity-control" property
  201. --
  202. -- "has-opacity-control" gboolean : Read / Write
  203. --
  204. -- Whether the color selector should allow setting opacity.
  205. --
  206. -- Default value: FALSE
  207. -- The "has-palette" property
  208. --
  209. -- "has-palette" gboolean : Read / Write
  210. --
  211. -- Whether a palette should be used.
  212. --
  213. -- Default value: FALSE
  214. --
  215. feature -- The "color-changed" signal
  216. -- void user_function (GtkColorSelection *colorselection, gpointer
  217. -- user_data) : Run first
  218. -- This signal is emitted when the color changes in the
  219. -- GtkColorSelection according to its update policy.
  220. -- colorselection : the object which received the signal.
  221. -- user_data : user data set when the signal handler was connected.
  222. end -- class GTK_COLOR_SELECTION