1
1
package nativex.gtk.widgets.range
2
2
3
+ import glib.gpointer
4
+ import gobject.GCallback
3
5
import gtk.*
4
6
import kotlinx.cinterop.*
5
7
import nativex.glib.bool
6
8
import nativex.glib.gtk
9
+ import nativex.gobject.SignalManager
10
+ import nativex.gobject.Signals
11
+ import nativex.gobject.signalManager
7
12
import nativex.gtk.Adjustment
8
13
import nativex.gtk.Orientable
9
14
import nativex.gtk.common.enums.Orientation
10
15
import nativex.gtk.common.enums.PositionType
16
+ import nativex.pango.Layout
17
+ import nativex.pango.Layout.Companion.wrap
11
18
12
19
/* *
13
20
* kotlinx-gtk
21
+ *
14
22
* 14 / 03 / 2021
23
+ *
24
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html">GtkScale</a>
15
25
*/
16
26
class Scale (
17
- val scalePointer : CPointer <GtkScale >
27
+ val scalePointer : CPointer <GtkScale >
18
28
) : Range(scalePointer.reinterpret()), Orientable {
19
29
20
30
override val orientablePointer: CPointer <GtkOrientable > by lazy { scalePointer.reinterpret() }
21
31
32
+ /* *
33
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-new">
34
+ * gtk_scale_new</a>
35
+ */
22
36
constructor (
23
37
orientation: Orientation ,
24
38
adjustment: Adjustment ? = null
25
39
) : this (
26
40
gtk_scale_new(orientation.gtk, adjustment?.adjustmentPointer)!! .reinterpret()
27
41
)
28
42
43
+ /* *
44
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-new-with-range">
45
+ * gtk_scale_new_with_range</a>
46
+ */
29
47
constructor (
30
48
orientation: Orientation ,
31
49
min: Double ,
@@ -40,18 +58,42 @@ class Scale(
40
58
)!! .reinterpret()
41
59
)
42
60
61
+ /* *
62
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-get-digits">
63
+ * gtk_scale_get_digits</a>
64
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-set-digits">
65
+ * gtk_scale_set_digits</a>
66
+ */
43
67
var digits: Int
44
68
get() = gtk_scale_get_digits(scalePointer)
45
69
set(value) = gtk_scale_set_digits(scalePointer, value)
46
70
71
+ /* *
72
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-get-draw-value">
73
+ * gtk_scale_get_draw_value</a>
74
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-set-draw-value">
75
+ * gtk_scale_set_draw_value</a>
76
+ */
47
77
var drawValue: Boolean
48
78
get() = gtk_scale_get_draw_value(scalePointer).bool
49
79
set(value) = gtk_scale_set_draw_value(scalePointer, value.gtk)
50
80
81
+ /* *
82
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-get-has-origin">
83
+ * gtk_scale_get_has_origin</a>
84
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-set-has-origin">
85
+ * gtk_scale_set_has_origin</a>
86
+ */
51
87
var hasOrigin: Boolean
52
88
get() = gtk_scale_get_has_origin(scalePointer).bool
53
89
set(value) = gtk_scale_set_has_origin(scalePointer, value.gtk)
54
90
91
+ /* *
92
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-get-value-pos">
93
+ * gtk_scale_get_value_pos</a>
94
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-set-value-pos">
95
+ * gtk_scale_set_value_pos</a>
96
+ */
55
97
var valuePos: PositionType
56
98
get() = PositionType .valueOf(
57
99
gtk_scale_get_value_pos(
@@ -60,10 +102,17 @@ class Scale(
60
102
)!!
61
103
set(value) = gtk_scale_set_value_pos(scalePointer, value.gtk)
62
104
63
- fun getLayout () {
64
- TODO (" gtk_scale_get_layout" )
65
- }
105
+ /* *
106
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-get-layout">
107
+ * gtk_scale_get_layout</a>
108
+ */
109
+ val layout: Layout ?
110
+ get() = gtk_scale_get_layout(scalePointer).wrap()
66
111
112
+ /* *
113
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-get-layout-offsets">
114
+ * gtk_scale_get_layout_offsets</a>
115
+ */
67
116
fun getLayoutOffsets (): Pair <Int , Int > {
68
117
val x = cValue<IntVar >()
69
118
val y = cValue<IntVar >()
@@ -73,6 +122,9 @@ class Scale(
73
122
}
74
123
}
75
124
125
+ /* *
126
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-add-mark">gtk_scale_add_mark</a>
127
+ */
76
128
fun addMark (
77
129
value : Double ,
78
130
positionType : PositionType ,
@@ -81,8 +133,34 @@ class Scale(
81
133
gtk_scale_add_mark(scalePointer, value, positionType.gtk, markup)
82
134
}
83
135
136
+ /* *
137
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#gtk-scale-clear-marks">
138
+ * gtk_scale_clear_marks</a>
139
+ */
84
140
fun clearMarks () {
85
141
gtk_scale_clear_marks(scalePointer)
86
142
}
87
143
88
- }
144
+ /* *
145
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#GtkScale-format-value">format-value</a>
146
+ */
147
+ fun addOnFormatValueCallback (action : ScaleFormatValueFunction ): SignalManager =
148
+ signalManager(
149
+ scalePointer,
150
+ Signals .FORMAT_VALUE ,
151
+ StableRef .create(action).asCPointer(),
152
+ staticFormatValueCallback
153
+ )
154
+
155
+ companion object {
156
+ private val staticFormatValueCallback: GCallback =
157
+ staticCFunction { _: gpointer, value: Double , data: gpointer ->
158
+ data.asStableRef<ScaleFormatValueFunction >().get().invoke(value).cstr
159
+ }.reinterpret()
160
+ }
161
+ }
162
+
163
+ /* *
164
+ * @see <a href="https://developer.gnome.org/gtk3/stable/GtkScale.html#GtkScale-format-value">format-value</a>
165
+ */
166
+ typealias ScaleFormatValueFunction = (value: Double ) -> String
0 commit comments