CoreGTK  3.10.0
CoreGTK is an Objective-C language binding for the GTK+ widget toolkit
 All Classes Functions Variables
CGTKSpinButton.m
1 /*
2  * CGTKSpinButton.m
3  * This file is part of CoreGTK
4  *
5  * Copyright (C) 2015 - Tyler Burton
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.1 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 Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /*
23  * Modified by the CoreGTK Team, 2015. See the AUTHORS file for a
24  * list of people on the CoreGTK Team.
25  * See the ChangeLog files for a list of changes.
26  *
27  */
28 
29 /*
30  * Objective-C imports
31  */
32 #import "CoreGTK/CGTKSpinButton.h"
33 
34 @implementation CGTKSpinButton
35 
36 -(id)initWithAdjustment:(GtkAdjustment*) adjustment andClimbRate:(gdouble) climbRate andDigits:(guint) digits
37 {
38  self = [super initWithGObject:(GObject *)gtk_spin_button_new(adjustment, climbRate, digits)];
39 
40  if(self)
41  {
42  //Do nothing
43  }
44 
45  return self;
46 }
47 
48 -(id)initWithRangeWithMin:(gdouble) min andMax:(gdouble) max andStep:(gdouble) step
49 {
50  self = [super initWithGObject:(GObject *)gtk_spin_button_new_with_range(min, max, step)];
51 
52  if(self)
53  {
54  //Do nothing
55  }
56 
57  return self;
58 }
59 
60 -(GtkSpinButton*)SPINBUTTON
61 {
62  return GTK_SPIN_BUTTON([self GOBJECT]);
63 }
64 
65 -(void)configureWithAdjustment:(GtkAdjustment*) adjustment andClimbRate:(gdouble) climbRate andDigits:(guint) digits
66 {
67  gtk_spin_button_configure(GTK_SPIN_BUTTON([self GOBJECT]), adjustment, climbRate, digits);
68 }
69 
70 -(GtkAdjustment*)getAdjustment
71 {
72  return gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON([self GOBJECT]));
73 }
74 
75 -(guint)getDigits
76 {
77  return gtk_spin_button_get_digits(GTK_SPIN_BUTTON([self GOBJECT]));
78 }
79 
80 -(void)getIncrementsWithStep:(gdouble*) step andPage:(gdouble*) page
81 {
82  gtk_spin_button_get_increments(GTK_SPIN_BUTTON([self GOBJECT]), step, page);
83 }
84 
85 -(BOOL)getNumeric
86 {
87  return (gtk_spin_button_get_numeric(GTK_SPIN_BUTTON([self GOBJECT])) ? YES : NO);
88 }
89 
90 -(void)getRangeWithMin:(gdouble*) min andMax:(gdouble*) max
91 {
92  gtk_spin_button_get_range(GTK_SPIN_BUTTON([self GOBJECT]), min, max);
93 }
94 
96 {
97  return (gtk_spin_button_get_snap_to_ticks(GTK_SPIN_BUTTON([self GOBJECT])) ? YES : NO);
98 }
99 
100 -(GtkSpinButtonUpdatePolicy)getUpdatePolicy
101 {
102  return gtk_spin_button_get_update_policy(GTK_SPIN_BUTTON([self GOBJECT]));
103 }
104 
105 -(gdouble)getValue
106 {
107  return gtk_spin_button_get_value(GTK_SPIN_BUTTON([self GOBJECT]));
108 }
109 
111 {
112  return gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON([self GOBJECT]));
113 }
114 
115 -(BOOL)getWrap
116 {
117  return (gtk_spin_button_get_wrap(GTK_SPIN_BUTTON([self GOBJECT])) ? YES : NO);
118 }
119 
120 -(void)setAdjustment:(GtkAdjustment*) adjustment
121 {
122  gtk_spin_button_set_adjustment(GTK_SPIN_BUTTON([self GOBJECT]), adjustment);
123 }
124 
125 -(void)setDigits:(guint) digits
126 {
127  gtk_spin_button_set_digits(GTK_SPIN_BUTTON([self GOBJECT]), digits);
128 }
129 
130 -(void)setIncrementsWithStep:(gdouble) step andPage:(gdouble) page
131 {
132  gtk_spin_button_set_increments(GTK_SPIN_BUTTON([self GOBJECT]), step, page);
133 }
134 
135 -(void)setNumeric:(BOOL) numeric
136 {
137  gtk_spin_button_set_numeric(GTK_SPIN_BUTTON([self GOBJECT]), (numeric ? TRUE : FALSE));
138 }
139 
140 -(void)setRangeWithMin:(gdouble) min andMax:(gdouble) max
141 {
142  gtk_spin_button_set_range(GTK_SPIN_BUTTON([self GOBJECT]), min, max);
143 }
144 
145 -(void)setSnapToTicks:(BOOL) snapToTicks
146 {
147  gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON([self GOBJECT]), (snapToTicks ? TRUE : FALSE));
148 }
149 
150 -(void)setUpdatePolicy:(GtkSpinButtonUpdatePolicy) policy
151 {
152  gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON([self GOBJECT]), policy);
153 }
154 
155 -(void)setValue:(gdouble) value
156 {
157  gtk_spin_button_set_value(GTK_SPIN_BUTTON([self GOBJECT]), value);
158 }
159 
160 -(void)setWrap:(BOOL) wrap
161 {
162  gtk_spin_button_set_wrap(GTK_SPIN_BUTTON([self GOBJECT]), (wrap ? TRUE : FALSE));
163 }
164 
165 -(void)spinWithDirection:(GtkSpinType) direction andIncrement:(gdouble) increment
166 {
167  gtk_spin_button_spin(GTK_SPIN_BUTTON([self GOBJECT]), direction, increment);
168 }
169 
170 -(void)update
171 {
172  gtk_spin_button_update(GTK_SPIN_BUTTON([self GOBJECT]));
173 }
174 
175 
176 @end
GObject * GOBJECT()
Definition: CGTKBase.m:82
id initWithGObject:(GObject *obj)
Definition: CGTKBase.m:48
GtkAdjustment * getAdjustment()
GtkSpinButton * SPINBUTTON()
GtkSpinButtonUpdatePolicy getUpdatePolicy()