summaryrefslogtreecommitdiff
path: root/src/Gtk/Types.icl
blob: f43a800f969173c460807fa3dbdfc6d4d37a23ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
implementation module Gtk.Types

import StdEnv
import StdDebug

instance toInt GType
where
	toInt type = id << 2
	where
		id = case type of
			GTypeBool   ->  5
			GTypeChar   ->  3
			GTypeInt    ->  6
			GTypeReal   -> 15
			GTypeString -> 16

instance toInt GdkModifier
where
	toInt modifier = 1 << shift
	where
		shift = case modifier of
			ShiftMask   ->  0
			LockMask    ->  1
			ControlMask ->  2
			Mod1Mask    ->  3
			Mod2Mask    ->  4
			Mod3Mask    ->  5
			Mod4Mask    ->  6
			Mod5Mask    ->  7
			Button1Mask ->  8
			Button2Mask ->  9
			Button3Mask -> 10
			Button4Mask -> 11
			Button5Mask -> 12
			SuperMask   -> 26
			HyperMask   -> 27
			MetaMask    -> 28

instance toInt [GdkModifier]
where
	toInt [m:ms] = toInt m bitor toInt ms
	toInt []     = 0

instance toInt GtkAlign
where
	toInt align = case align of
		AlignFill     -> 0
		AlignStart    -> 1
		AlignEnd      -> 2
		AlignCenter   -> 3
		AlignBaseline -> 4

instance toInt GtkButtonsType
where
	toInt type = case type of
		NoButtons       -> 0
		OkButton        -> 1
		CloseButton     -> 2
		CancelButton    -> 3
		YesNoButtons    -> 4
		OkCancelButtons -> 5

instance toInt GtkFileChooserAction
where
	toInt action = case action of
		OpenAction         -> 0
		SaveAction         -> 1
		SelectFolderAction -> 2
		CreateFolderAction -> 3

instance toInt GtkIconSize
where
	toInt size = case size of
		MenuIconSize         -> 1
		SmallToolbarIconSize -> 2
		LargeToolbarIconSize -> 3
		ButtonIconSize       -> 4
		DragAndDropIconSize  -> 5
		DialogIconSize       -> 6

instance toInt GtkJustification
where
	toInt justification = case justification of
		JustifyLeft   -> 0
		JustifyRight  -> 1
		JustifyCenter -> 2
		JustifyFill   -> 3

margin :: !Int -> GtkMargins
margin n =
	{ left   = n
	, top    = n
	, right  = n
	, bottom = n
	}

instance toInt GtkMessageType
where
	toInt type = case type of
		InfoMessage     -> 0
		WarningMessage  -> 1
		QuestionMessage -> 2
		ErrorMessage    -> 3
		OtherMessage    -> 4

instance fromInt GtkResponse
where
	fromInt response = case response of
		-1  -> ResponseNone
		-2  -> ResponseReject
		-3  -> ResponseAccept
		-4  -> ResponseDeleteEvent
		-5  -> ResponseOk
		-6  -> ResponseCancel
		-7  -> ResponseClose
		-8  -> ResponseYes
		-9  -> ResponseNo
		-10 -> ResponseApply
		-11 -> ResponseHelp
		r  -> trace_n ("fromInt GtkResponse: illegal value "+++toString r) ResponseNone

instance toInt GtkResponse
where
	toInt response = case response of
		ResponseNone        ->  -1
		ResponseReject      ->  -2
		ResponseAccept      ->  -3
		ResponseDeleteEvent ->  -4
		ResponseOk          ->  -5
		ResponseCancel      ->  -6
		ResponseClose       ->  -7
		ResponseYes         ->  -8
		ResponseNo          ->  -9
		ResponseApply       -> -10
		ResponseHelp        -> -11

instance toInt GtkScrollbarPolicy
where
	toInt policy = case policy of
		PersistentScrollbar -> 0
		AutoScrollbar       -> 1
		NoScrollbar         -> 2

instance toInt GtkStylePriority
where
	toInt prio = case prio of
		StylePriorityFallback     ->   1
		StylePriorityTheme        -> 200
		StylePrioritySettings     -> 400
		StylePriorityApplication  -> 600
		StylePriorityUser         -> 800

instance toInt GtkTreeViewColumnSizing
where
	toInt sizing = case sizing of
		OnlyGrow  -> 0
		AutoSize  -> 1
		FixedSize -> 2

instance toInt GtkWrapMode
where
	toInt mode = case mode of
		WrapNone       -> 0
		WrapChar       -> 1
		WrapWord       -> 2
		WrapWordOrChar -> 3