You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

197 lines
6.3 KiB

  1. /* GTK - The GIMP Toolkit
  2. * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  3. *
  4. * GtkSpinButton widget for GTK+
  5. * Copyright (C) 1998 Lars Hamann and Stefan Jeske
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20. * Boston, MA 02111-1307, USA.
  21. */
  22. /*
  23. * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
  24. * file for a list of people on the GTK+ Team. See the ChangeLog
  25. * files for a list of changes. These files are distributed with
  26. * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  27. */
  28. #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
  29. #error "Only <gtk/gtk.h> can be included directly."
  30. #endif
  31. #ifndef __GTK_SPIN_BUTTON_H__
  32. #define __GTK_SPIN_BUTTON_H__
  33. #include <gtk/gtkentry.h>
  34. #include <gtk/gtkadjustment.h>
  35. G_BEGIN_DECLS
  36. #define GTK_TYPE_SPIN_BUTTON (gtk_spin_button_get_type ())
  37. #define GTK_SPIN_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SPIN_BUTTON, GtkSpinButton))
  38. #define GTK_SPIN_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SPIN_BUTTON, GtkSpinButtonClass))
  39. #define GTK_IS_SPIN_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SPIN_BUTTON))
  40. #define GTK_IS_SPIN_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SPIN_BUTTON))
  41. #define GTK_SPIN_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SPIN_BUTTON, GtkSpinButtonClass))
  42. #define GTK_INPUT_ERROR -1
  43. typedef enum
  44. {
  45. GTK_UPDATE_ALWAYS,
  46. GTK_UPDATE_IF_VALID
  47. } GtkSpinButtonUpdatePolicy;
  48. typedef enum
  49. {
  50. GTK_SPIN_STEP_FORWARD,
  51. GTK_SPIN_STEP_BACKWARD,
  52. GTK_SPIN_PAGE_FORWARD,
  53. GTK_SPIN_PAGE_BACKWARD,
  54. GTK_SPIN_HOME,
  55. GTK_SPIN_END,
  56. GTK_SPIN_USER_DEFINED
  57. } GtkSpinType;
  58. typedef struct _GtkSpinButton GtkSpinButton;
  59. typedef struct _GtkSpinButtonClass GtkSpinButtonClass;
  60. struct _GtkSpinButton
  61. {
  62. GtkEntry entry;
  63. GtkAdjustment *GSEAL (adjustment);
  64. GdkWindow *GSEAL (panel);
  65. guint32 GSEAL (timer);
  66. gdouble GSEAL (climb_rate);
  67. gdouble GSEAL (timer_step);
  68. GtkSpinButtonUpdatePolicy GSEAL (update_policy);
  69. guint GSEAL (in_child) : 2;
  70. guint GSEAL (click_child) : 2; /* valid: GTK_ARROW_UP=0, GTK_ARROW_DOWN=1 or 2=NONE/BOTH */
  71. guint GSEAL (button) : 2;
  72. guint GSEAL (need_timer) : 1;
  73. guint GSEAL (timer_calls) : 3;
  74. guint GSEAL (digits) : 10;
  75. guint GSEAL (numeric) : 1;
  76. guint GSEAL (wrap) : 1;
  77. guint GSEAL (snap_to_ticks) : 1;
  78. };
  79. struct _GtkSpinButtonClass
  80. {
  81. GtkEntryClass parent_class;
  82. gint (*input) (GtkSpinButton *spin_button,
  83. gdouble *new_value);
  84. gint (*output) (GtkSpinButton *spin_button);
  85. void (*value_changed) (GtkSpinButton *spin_button);
  86. /* Action signals for keybindings, do not connect to these */
  87. void (*change_value) (GtkSpinButton *spin_button,
  88. GtkScrollType scroll);
  89. void (*wrapped) (GtkSpinButton *spin_button);
  90. /* Padding for future expansion */
  91. void (*_gtk_reserved1) (void);
  92. void (*_gtk_reserved2) (void);
  93. void (*_gtk_reserved3) (void);
  94. };
  95. GType gtk_spin_button_get_type (void) G_GNUC_CONST;
  96. void gtk_spin_button_configure (GtkSpinButton *spin_button,
  97. GtkAdjustment *adjustment,
  98. gdouble climb_rate,
  99. guint digits);
  100. GtkWidget* gtk_spin_button_new (GtkAdjustment *adjustment,
  101. gdouble climb_rate,
  102. guint digits);
  103. GtkWidget* gtk_spin_button_new_with_range (gdouble min,
  104. gdouble max,
  105. gdouble step);
  106. void gtk_spin_button_set_adjustment (GtkSpinButton *spin_button,
  107. GtkAdjustment *adjustment);
  108. GtkAdjustment* gtk_spin_button_get_adjustment (GtkSpinButton *spin_button);
  109. void gtk_spin_button_set_digits (GtkSpinButton *spin_button,
  110. guint digits);
  111. guint gtk_spin_button_get_digits (GtkSpinButton *spin_button);
  112. void gtk_spin_button_set_increments (GtkSpinButton *spin_button,
  113. gdouble step,
  114. gdouble page);
  115. void gtk_spin_button_get_increments (GtkSpinButton *spin_button,
  116. gdouble *step,
  117. gdouble *page);
  118. void gtk_spin_button_set_range (GtkSpinButton *spin_button,
  119. gdouble min,
  120. gdouble max);
  121. void gtk_spin_button_get_range (GtkSpinButton *spin_button,
  122. gdouble *min,
  123. gdouble *max);
  124. gdouble gtk_spin_button_get_value (GtkSpinButton *spin_button);
  125. gint gtk_spin_button_get_value_as_int (GtkSpinButton *spin_button);
  126. void gtk_spin_button_set_value (GtkSpinButton *spin_button,
  127. gdouble value);
  128. void gtk_spin_button_set_update_policy (GtkSpinButton *spin_button,
  129. GtkSpinButtonUpdatePolicy policy);
  130. GtkSpinButtonUpdatePolicy gtk_spin_button_get_update_policy (GtkSpinButton *spin_button);
  131. void gtk_spin_button_set_numeric (GtkSpinButton *spin_button,
  132. gboolean numeric);
  133. gboolean gtk_spin_button_get_numeric (GtkSpinButton *spin_button);
  134. void gtk_spin_button_spin (GtkSpinButton *spin_button,
  135. GtkSpinType direction,
  136. gdouble increment);
  137. void gtk_spin_button_set_wrap (GtkSpinButton *spin_button,
  138. gboolean wrap);
  139. gboolean gtk_spin_button_get_wrap (GtkSpinButton *spin_button);
  140. void gtk_spin_button_set_snap_to_ticks (GtkSpinButton *spin_button,
  141. gboolean snap_to_ticks);
  142. gboolean gtk_spin_button_get_snap_to_ticks (GtkSpinButton *spin_button);
  143. void gtk_spin_button_update (GtkSpinButton *spin_button);
  144. #ifndef GTK_DISABLE_DEPRECATED
  145. #define gtk_spin_button_get_value_as_float gtk_spin_button_get_value
  146. #endif
  147. G_END_DECLS
  148. #endif /* __GTK_SPIN_BUTTON_H__ */