Subversion Repositories Kolibri OS

Rev

Rev 485 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 485 Rev 6224
Line 1... Line 1...
1
;
1
;
2
;   MENU EXAMPLE
2
;   MENU EXAMPLE
3
;
3
;
4
;   Compile with FASM for Menuet
4
;   Compile with FASM for Kolibri
5
;
5
;
Line 6... Line 6...
6
 
6
 
7
  use32
7
  use32
8
  org    0x0
-
 
9
 
8
  org    0x0
10
  db     'MENUET01'    ; 8 byte id
9
  db     'MENUET01'    ; 8 byte id
11
  dd     0x01          ; header version
10
  dd     0x01          ; header version
12
  dd     START         ; start of code
11
  dd     start         ; start of code
13
  dd     I_END         ; size of image
-
 
14
  dd     0x1000        ; memory for app
-
 
15
  dd     0x1000        ; esp
12
  dd     i_end         ; size of image
Line 16... Line 13...
16
  dd     0x0 , 0x0     ; I_Param , I_Icon
13
  dd     mem, stacktop, file_name, sys_path
17
 
14
 
-
 
15
include 'lang.inc'
-
 
16
include '../../../../macros.inc'
-
 
17
include '../../../../proc32.inc'
-
 
18
include '../../../../KOSfuncs.inc'
-
 
19
include '../../../../develop/libraries/box_lib/load_lib.mac'
-
 
20
include '../../../../dll.inc'
-
 
21
 
-
 
22
KMENUITEM_NORMAL equ 0
-
 
23
KMENUITEM_SUBMENU equ 1
-
 
24
KMENUITEM_SEPARATOR equ 2
18
include  'lang.inc'
25
 
19
include  '..\..\..\..\macros.inc'
26
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
-
 
27
 
-
 
28
start:                             ; start of execution
-
 
29
 
-
 
30
	load_libraries l_libs_start,l_libs_end
-
 
31
	mov	ebp,lib_0
-
 
32
	.test_lib_open:
-
 
33
	cmp	dword [ebp+ll_struc_size-4],0
-
 
34
	jz	@f
-
 
35
		mcall SF_TERMINATE_PROCESS ;exit not correct
-
 
36
	@@:
-
 
37
	add ebp,ll_struc_size
-
 
38
	cmp ebp,l_libs_end
-
 
39
	jl .test_lib_open
-
 
40
 
-
 
41
	mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
-
 
42
	mcall SF_SET_EVENTS_MASK,0x27
-
 
43
 
-
 
44
	;kmenu initialisation
-
 
45
	stdcall [kmenu_init],sc
-
 
46
	stdcall [ksubmenu_new]
-
 
47
	mov [main_menu], eax
-
 
48
 
-
 
49
	stdcall [ksubmenu_new]
-
 
50
	mov [main_menu_File], eax
-
 
51
	stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_Load, 110
-
 
52
	stdcall [ksubmenu_add], [main_menu_File], eax
-
 
53
	stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_Save, 111
-
 
54
	stdcall [ksubmenu_add], [main_menu_File], eax
-
 
55
	stdcall [kmenuitem_new], KMENUITEM_SEPARATOR, 0, 0
-
 
56
	stdcall [ksubmenu_add], [main_menu_File], eax
-
 
57
	stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_Quit, 112
-
 
58
	stdcall [ksubmenu_add], [main_menu_File], eax
-
 
59
	stdcall [kmenuitem_new], KMENUITEM_SUBMENU, sz_File, [main_menu_File]
-
 
60
	stdcall [ksubmenu_add], [main_menu], eax
-
 
61
 
-
 
62
	stdcall [ksubmenu_new]
-
 
63
	mov [main_menu_Edit], eax
-
 
64
	stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_Copy, 120
-
 
65
	stdcall [ksubmenu_add], [main_menu_Edit], eax
-
 
66
	stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_Paste, 121
-
 
67
	stdcall [ksubmenu_add], [main_menu_Edit], eax
-
 
68
	stdcall [kmenuitem_new], KMENUITEM_SUBMENU, sz_Edit, [main_menu_Edit]
-
 
69
	stdcall [ksubmenu_add], [main_menu], eax
-
 
70
 
-
 
71
	stdcall [ksubmenu_new]
-
 
72
	mov [main_menu_Test], eax
-
 
73
	stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_Test1, 130
-
 
74
	stdcall [ksubmenu_add], [main_menu_Test], eax
-
 
75
	stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_Test2, 131
-
 
76
	stdcall [ksubmenu_add], [main_menu_Test], eax
-
 
77
	stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_Test3, 132
-
 
78
	stdcall [ksubmenu_add], [main_menu_Test], eax
-
 
79
	stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_Test4, 133
-
 
80
	stdcall [ksubmenu_add], [main_menu_Test], eax
-
 
81
	stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_Test5, 134
-
 
82
	stdcall [ksubmenu_add], [main_menu_Test], eax
-
 
83
	stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_Test6, 134
-
 
84
	stdcall [ksubmenu_add], [main_menu_Test], eax
-
 
85
	stdcall [kmenuitem_new], KMENUITEM_SUBMENU, sz_Test, [main_menu_Test]
-
 
86
	stdcall [ksubmenu_add], [main_menu], eax
-
 
87
 
-
 
88
	stdcall [ksubmenu_new]
-
 
89
	mov [main_menu_Help], eax
-
 
90
	stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_Setup, 140
-
 
91
	stdcall [ksubmenu_add], [main_menu_Help], eax
-
 
92
	stdcall [kmenuitem_new], KMENUITEM_NORMAL, sz_About, 141
-
 
93
	stdcall [ksubmenu_add], [main_menu_Help], eax
Line 20... Line 94...
20
 
94
	stdcall [kmenuitem_new], KMENUITEM_SUBMENU, sz_Help, [main_menu_Help]
21
START:                             ; start of execution
95
	stdcall [ksubmenu_add], [main_menu], eax
22
 
96
 
Line 23... Line 97...
23
  red: 
97
  red: 
24
    call draw_window               ; draw window
-
 
25
    call clear_data                ; clear status bar
-
 
26
 
98
    call draw_window               ; draw window
Line 27... Line 99...
27
still:
99
	stdcall [kmainmenu_draw], [main_menu]
28
 
100
 
29
    mov  eax,10                    ; wait here for event
101
still:
-
 
102
    mcall SF_WAIT_EVENT
-
 
103
 
30
    mcall                      ; do it
104
    cmp  eax,1                     ; redraw request ?
-
 
105
    jz   red                       ; yes jump to it
-
 
106
    cmp  eax,2
-
 
107
    jz   key
-
 
108
    cmp  eax,3
-
 
109
    jz   button
Line 31... Line 110...
31
 
110
	cmp  eax,6
32
    cmp  eax,1                     ; redraw request ?
-
 
33
    jz   red                       ; yes jump to it
111
	jne  @f 
34
    cmp  eax,2                     ; key in buffer ?
112
		call mouse
Line 35... Line 113...
35
    jnz   button
113
		jmp still
36
 
-
 
37
  key:                             ; key
114
	@@:
Line 38... Line -...
38
    mov  eax,2                     ; just read it and ignore
-
 
39
    mcall                      ; do it
-
 
40
    jmp  still                     ; start again
-
 
41
 
-
 
42
  button:                          ; button
-
 
43
    mov  eax,17                    ; get id
-
 
44
    mcall                      ; do it
-
 
45
 
-
 
46
    cmp  ah,1                      ; is it the close button
-
 
47
    jne  noclose                   ; no then jump code
-
 
48
    or   eax,-1                    ; close this program
-
 
49
    mcall                      ; do it
-
 
50
noclose:
-
 
51
 
-
 
52
    cmp  ah,100                    ; is it main menu
-
 
53
    jb   not_menu                  ; no then jump code
-
 
54
    cmp  ah,104                    ; is it main menu
-
 
55
    ja   not_menu                  ; no then jump code
-
 
56
    call draw_window               ; redraw window
-
 
57
    call clear_data                ; clear status info
-
 
58
    call draw_data                 ; update status info
-
 
59
    call write_sub                 ; draw a sub menu
-
 
60
    jmp  still                     ; start again
-
 
61
not_menu:
115
 
62
 
-
 
63
    cmp  ah,110                    ; is it a sub menu
116
key:
64
    jb   not_sub                   ; no then jump code
-
 
65
    cmp  ah,145                    ; is it a sub menu
117
    mcall SF_GET_KEY
Line -... Line 118...
-
 
118
    jmp  still                     ; start again
66
    ja   not_sub                   ; no then jump code
119
 
-
 
120
button:
Line -... Line 121...
-
 
121
	mcall SF_GET_BUTTON
-
 
122
 
-
 
123
	mov  [button_press],eax
Line 67... Line 124...
67
    call draw_window               ; redraw window
124
	shr  dword[button_press],8
68
    call clear_data                ; clear status info
125
	call draw_data
69
    mov  [button_press],1          ; sub button pressed
126
 
Line 70... Line 127...
70
    call draw_data                 ; update status info
127
	cmp  ah,1                      ; is it the close button
Line 71... Line 128...
71
    mov  [button_press],0          ; clear pressed
128
	jne  still                     ; no then jump code
-
 
129
	mcall SF_TERMINATE_PROCESS     ; close this program
Line 72... Line -...
72
    jmp  still                     ; start again
-
 
73
not_sub:
-
 
74
 
-
 
75
    jmp  still                     ; start again
-
 
76
 
-
 
77
 
130
 
78
;   *********************************************
131
mouse:
79
;   *******  WINDOW DEFINITIONS AND DRAW ********
132
	stdcall [kmainmenu_dispatch_cursorevent], [main_menu]
80
;   *********************************************
133
	ret
81
 
-
 
82
draw_window:
-
 
83
 
134
 
84
    push eax                       ; save register
-
 
85
 
-
 
86
    mov  eax,12                    ; function 12: tell os about windowdraw
-
 
87
    mov  ebx,1                     ; 1, start of draw
-
 
88
    mcall                      ; do it
-
 
89
 
-
 
90
    mov  eax,0                     ; function 0: define and draw window
-
 
91
    mov  ebx,50*65536              ; [x start] *65536
-
 
92
    add  ebx,[x_size]              ; add [x size]
-
 
93
    mov  ecx,50*65536              ; [y start] *65536
-
 
94
    add  ecx,[y_size]              ; add [y size]
-
 
95
    mov  edx,0x80ffffff            ; colour of work area RRGGBB
-
 
96
    mov  esi,0x806688dd            ; grab bar colour. negative glide
-
 
97
    mcall                      ; do it
-
 
Line 98... Line -...
98
 
-
 
99
    mov  eax,4                     ; function 4: write text to window
135
;   *********************************************
100
    mov  ebx,6*65536+7             ; [x start] *65536 + [y start]
136
;   *******  WINDOW DEFINITIONS AND DRAW ********
101
    mov  ecx,0x00ffffff            ; text colour
137
;   *********************************************
102
    mov  edx,window_text           ; pointer to text beginning
138
 
103
    mov  esi,12                    ; text length
139
draw_window:
104
    mcall                      ; do it
140
 
105
 
141
    push eax                       ; save register
106
    mov  eax,8                     ; function 8: define and draw button
-
 
107
    mov  ebx,(381-18)*65536+13     ; [x start] *65536 + [x size]
142
    mcall SF_REDRAW,SSF_BEGIN_DRAW
Line 108... Line -...
108
    mov  ecx,4*65536+13            ; [y start] *65536 + [y size]
-
 
109
    mov  edx,1                     ; button id
143
 
110
    mov  esi,0x6688dd              ; button color RRGGBB
144
    mov  ebx,50*65536              ; [x start] *65536
111
    mcall                      ; do it
145
    add  ebx,[x_size]              ; add [x size]
112
 
-
 
113
    mov  eax,13                    ; function 13: draw bar
-
 
114
    mov  ebx,1*65536               ; [x start] *65536
-
 
115
    add  ebx,[x_size]              ; add [x size]
-
 
116
    dec  ebx                       ; x size - 1
-
 
117
    mov  ecx,[y_size]              ; [y start] *65536
-
 
118
    sub  ecx,17                    ; minus height
-
 
119
    shl  ecx,16                    ; *65536
-
 
120
    add  ecx,17                    ; add height
-
 
121
    mov  edx,0x006688dd            ; bar colour
-
 
122
    mcall                      ; do it
-
 
123
 
-
 
124
    mov  eax,4                     ; function 4 : write text to window
-
 
125
    mov  ebx,5*65536               ; [x start] *65536
-
 
126
    add  ebx,[y_size]              ; add [y start]
-
 
127
    sub  ebx,12                    ; move up
-
 
128
    xor  ecx,ecx                   ; text colour
-
 
129
    mov  edx,button_no             ; pointer to text beginning
-
 
130
    mov  esi,14                    ; text length
-
 
131
    mcall                      ; do it
-
 
132
 
-
 
133
    add  ebx,95*65536              ; move xy position
-
 
134
    mov  edx,menu_text             ; pointer to text beginning
-
 
135
    mcall                      ; do it
-
 
136
 
-
 
137
    call write_main                ; draw menu
-
 
138
 
-
 
139
    mov  eax,12                    ; function 12: tell os about windowdraw
-
 
140
    mov  ebx,2                     ; 2, end of draw
-
 
141
    mcall                      ; do it
-
 
142
 
-
 
143
    pop  eax                       ; restore register
-
 
144
    ret                            ; return
-
 
145
 
-
 
146
 ; ************* WRITE MAIN *************
-
 
147
 
-
 
148
write_main:
-
 
149
 
-
 
150
    mov  eax,13                    ; function 13: draw bar
-
 
151
    mov  ebx,1*65536               ; [x start] *65536
-
 
152
    add  ebx,[x_size]              ; +[x_size]
-
 
153
    dec  ebx                       ; x size - 1
-
 
154
    mov  ecx,21*65536+17           ; [y start] *65536 +[y size]
-
 
155
    mov  edx,[menu_colour]         ; menu colour
-
 
156
    mcall                      ; do it
-
 
157
 
-
 
158
    mov  [main_pos],1              ; start position first button
-
 
159
    xor  edi,edi                   ; data offset = 0
-
 
160
 
-
 
161
next_main_item:
-
 
162
    mov  al,[MENU_DATA+edi]        ; get byte at menu_data + offset
-
 
163
    cmp  al,'E'                    ; is it the END
-
 
164
    je   main_get_out              ; yes then exit
-
 
165
    cmp  al,'0'                    ; is it a main menu item
-
 
166
    jne  not_main_menu             ; no then jump code
-
 
167
 
146
    mov  ecx,50*65536              ; [y start] *65536
168
main_menu:
-
 
169
    mov  al,[MENU_DATA+edi+1]      ; get byte at menu_data + offset + 1
-
 
170
    cmp  al,'0'                    ; is it a divider
-
 
171
    je   is_main_bar               ; yes then jump code
147
    add  ecx,[y_size]              ; add [y size]
172
    mov  eax,8                     ; function 8: define button
-
 
173
    mov  ebx,[main_pos]            ; [x start]
-
 
174
    shl  ebx,16                    ; *65536
-
 
175
    add  bl,75                     ; +[x size]
-
 
176
    mov  ecx,21*65536+16           ; [y start] *65536 +[y size]
-
 
177
    xor  edx,edx                   ; clear register
-
 
178
    mov  dl,[MENU_DATA+edi+2]      ; get byte button id number
-
 
Line 179... Line 148...
179
    mov  esi,[menu_colour]         ; button colour
148
    mcall SF_CREATE_WINDOW,,,0xb3ffffff,,window_text
Line -... Line 149...
-
 
149
 
-
 
150
    mov  ebx,1*65536               ; [x start] *65536
180
    mcall                      ; do it
151
    add  ebx,[x_size]              ; add [x size]
Line 181... Line 152...
181
    mov  eax,4                     ; function 4: write text to window
152
    sub  ebx,11                    ; x size - 11
Line 182... Line 153...
182
    add  ebx,6*65536-49            ; move xy position
153
    mov  ecx,[y_size]              ; [y start] *65536
Line 183... Line 154...
183
    xor  ecx,ecx                   ; text colour
154
    sub  ecx,47                    ; minus height
184
    mov  edx,MENU_DATA+3           ; point at menu text
-
 
185
    add  edx,edi                   ; add our offset
-
 
186
    mov  esi,11                    ; number of characters
-
 
187
    mcall                      ; do it
-
 
188
 
-
 
189
is_main_bar:
-
 
190
    add  [main_pos],76             ; update button position
-
 
191
 
-
 
192
not_main_menu:
-
 
193
    add  edi,14                    ; update offset
-
 
194
    jmp  next_main_item            ; do next menu item
-
 
195
 
-
 
196
main_get_out:
-
 
197
 
-
 
198
    ret                            ; return
-
 
199
 
-
 
200
; *********** DRAW DATA ***********
-
 
201
 
-
 
202
draw_data:
-
 
203
 
-
 
204
    push eax                       ; save register
-
 
205
    mov  ebx,0x00030000            ; display 3 decimal characters
-
 
206
    xor  ecx,ecx                   ; clear register
-
 
207
    mov  cl,ah                     ; swap data
-
 
208
    mov  eax,47                    ; function 47: display number to window
-
 
209
    mov  edx,70*65536              ; [x start] *65536
-
 
210
    add  edx,[y_size]              ; +[y start]
-
 
211
    sub  edx,12                    ; move position
-
 
212
    xor  esi,esi                   ; text colour
-
 
213
    mcall                      ; do it
-
 
214
    pop  eax                       ; restore register
-
 
215
 
-
 
216
    cmp  [button_press],1          ; has a sub button been pressed
-
 
217
    je   draw_get_out              ; then jump code
-
 
218
 
-
 
219
    push eax                       ; save register
-
 
220
    xor  edx,edx                   ; clear register
-
 
221
    shr  ax,8                      ; move button id into al
-
 
222
    sub  eax,100                   ; subtract 100
-
 
223
    mov  dx,14                     ; use record length as multiplier
-
 
224
    mul  dx                        ; multiply
-
 
225
    mov  edx,eax                   ; swap registers
-
 
226
    add  edx,MENU_DATA             ; add offset
155
    shl  ecx,16                    ; *65536
227
    inc  edx                       ; add 1
156
    add  ecx,17                    ; add height
228
    mov  ebx,188*65536             ; [x start] *65536
157
    mcall SF_DRAW_RECT,,,0x006688dd
229
    add  ebx,[y_size]              ; +[y start]
158
 
230
    sub  ebx,12                    ; move position
159
    mov  ebx,5*65536               ; [x start] *65536
231
    mov  esi,1                     ; 1 character
160
    add  ebx,[y_size]              ; add [y start]
232
    mov  eax,4                     ; function 4: write text to window
-
 
233
    xor  ecx,ecx                   ; text colour
-
 
Line -... Line 161...
-
 
161
    sub  ebx,42                    ; move up
-
 
162
    xor  ecx,ecx                   ; text colour
-
 
163
    mcall SF_DRAW_TEXT,,,button_no,9
-
 
164
 
-
 
165
	call draw_data
-
 
166
 
-
 
167
    mcall SF_REDRAW,SSF_END_DRAW
234
    mcall                      ; do it
168
    pop  eax                       ; restore register
235
    pop  eax                       ; restore register
-
 
236
 
-
 
237
draw_get_out:
-
 
238
    ret                            ; return
-
 
239
 
-
 
240
; **************** CLEAR DATA ******************
-
 
241
 
-
 
242
clear_data:
-
 
243
 
-
 
244
    push eax                       ; save register
-
 
245
    mov  eax,13                    ; function 13: draw bar
-
 
246
    mov  ebx,67*65536+23           ; [x start] *65536 +[x size]
-
 
247
    mov  ecx,[y_size]              ; [y start]
-
 
248
    sub  ecx,15                    ; move position
-
 
249
    shl  ecx,16                    ; *65536
-
 
250
    add  ecx,13                    ; [y size]
-
 
251
    mov  edx,0x00aaaaaa            ; bar colour
-
 
252
    mcall                      ; do it
-
 
253
    mov  ebx,185*65536+11          ; move position
-
 
254
    mcall                      ; do it again
-
 
255
 
-
 
256
    pop  eax                       ; restore register
-
 
257
    ret                            ; return
-
 
258
 
-
 
259
 ; ************* WRITE SUB *************
-
 
260
 
-
 
261
write_sub:
-
 
262
 
-
 
263
    push eax                       ; save register
-
 
264
    mov  [but_pos],38              ; y start position offset
-
 
265
    mov  [sub_pos],1               ; x start position offset
-
 
266
    xor  edx,edx                   ; clear register
-
 
267
    shr  ax,8                      ; move button id into al
-
 
268
    sub  eax,100                   ; subtract 100
-
 
269
    mov  dx,76                     ; menu width + 1
-
 
270
    mul  dx                        ; multiply
-
 
271
    add  [sub_pos],eax             ; add menu position to offset
-
 
272
    pop  eax                       ; restore register
-
 
273
 
-
 
274
    xor  edx,edx                   ; clear register
-
 
275
    shr  ax,8                      ; move button id into al
-
 
276
    sub  eax,100                   ; subtract 100
-
 
277
    mov  dx,14                     ; use record length as multiplier
-
 
278
    mul  dx                        ; multiply
-
 
279
    add  eax,MENU_DATA             ; add offset
-
 
280
    inc  eax                       ; plus 1
-
 
281
    mov  al,[eax]                  ; get menu number byte
-
 
282
    mov  [menu_number],al          ; save it
-
 
283
 
-
 
284
    xor  edi,edi                   ; clear offset
-
 
285
 
-
 
286
next_sub_item:
-
 
287
    mov  al,[MENU_DATA+edi]        ; get byte at menu_data + offset
-
 
288
    cmp  al,'E'                    ; is it the END
-
 
289
    je   sub_get_out               ; yes then exit
-
 
290
    cmp  al,[menu_number]          ; is it sub menu item
-
 
291
    jne  not_sub_menu              ; no then jump code
-
 
292
 
-
 
293
sub_menu:
-
 
294
    mov  al,[MENU_DATA+edi+1]      ; get byte at menu_data + offset + 1
-
 
295
    cmp  al,'0'                    ; is it a divider
-
 
296
    jne  is_sub_button             ; no then jump code
-
 
297
    mov  eax,13                    ; function 13: draw bar
-
 
298
    mov  edx,[menu_colour]         ; bar colour
-
 
299
    mov  ebx,[sub_pos]             ; [x start]
-
 
300
    shl  ebx,16                    ; *65536
-
 
301
    add  ebx,76                    ; [x size]
-
 
302
    mov  ecx,[but_pos]             ; [y start]
-
 
303
    shl  ecx,16                    ; *65536
-
 
304
    add  ecx,17                    ; [y size]
-
 
305
    mcall                      ; do it
-
 
306
    jmp  is_sub_bar                ; jump button code
-
 
307
 
-
 
308
is_sub_button:
-
 
309
    mov  eax,8                     ; function 8: define and draw button
-
 
310
    xor  edx,edx                   ; clear register
-
 
311
    mov  dl,[MENU_DATA+edi+2]      ; get byte button id number
-
 
312
    mov  ebx,[sub_pos]             ; [x start]
-
 
313
    shl  ebx,16                    ; *65536
-
 
314
    add  ebx,75                    ; [x size]
-
 
315
    mov  ecx,[but_pos]             ; [y start]
-
 
316
    shl  ecx,16                    ; *65536
-
 
317
    add  ecx,16                    ; [y size]
-
 
Line 318... Line 169...
318
    mov  esi,[menu_colour]         ; button colour
169
    ret                            ; return
Line 319... Line 170...
319
    mcall                      ; do it
170
 
Line 320... Line 171...
320
 
171
; *********** DRAW DATA ***********
321
    mov  ebx,[sub_pos]             ; [x start]
172
 
Line -... Line 173...
-
 
173
draw_data:
-
 
174
 
-
 
175
    push eax                       ; save register
-
 
176
    mov  ecx,[y_size]              ; [y start]
322
    shl  ebx,16                    ; *65536
177
    sub  ecx,45                    ; move position
323
    add  ebx,6*65536               ; move position
178
    shl  ecx,16                    ; *65536
-
 
179
    add  ecx,13                    ; [y size]
-
 
180
    mov  edx,0x00aaaaaa            ; bar colour
-
 
181
    mcall SF_DRAW_RECT, (67 shl 16)+23
-
 
182
 
-
 
183
    mov  ebx,0x00030000            ; display 3 decimal characters
-
 
184
    mov  ecx,[button_press]        ; menu id
-
 
185
    mov  edx,70*65536              ; [x start] *65536
-
 
186
    add  edx,[y_size]              ; +[y start]
-
 
187
    sub  edx,42                    ; move position
-
 
188
    xor  esi,esi                   ; text colour
-
 
189
    mcall SF_DRAW_NUMBER
-
 
190
    pop  eax                       ; restore register
-
 
191
 
-
 
192
    ret                            ; return
-
 
193
 
-
 
194
; ***************** DATA AREA ******************
-
 
195
 
-
 
196
x_size:       dd 381               ; window x size
-
 
197
y_size:       dd 200               ; window y size
-
 
198
 
-
 
199
if lang eq ru
-
 
200
window_text   db 'à¨¬¥à ¬¥­î',0
-
 
201
button_no     db 'Š­®¯ª  N:'
-
 
202
else
-
 
203
window_text   db 'Menu example',0  ; grab bar text
-
 
204
button_no     db 'Button N:'  ; status bar text
-
 
205
end if
-
 
206
 
-
 
207
main_menu dd 0
324
    add  ebx,[but_pos]             ; [y start]
208
main_menu_File dd 0
-
 
209
main_menu_Edit dd 0
-
 
210
main_menu_Test dd 0
-
 
211
main_menu_Help dd 0
-
 
212
 
-
 
213
if lang eq ru
-
 
214
 
-
 
215
sz_File db '” ©«',0
-
 
216
sz_Load db 'Žâªàëâì',0
-
 
217
sz_Save db '‘®åà ­¨âì',0
-
 
218
sz_Quit db '‚ë室',0
-
 
219
 
-
 
220
sz_Edit db 'à ¢ª ',0
-
 
221
sz_Copy db 'Š®¯¨à®¢ âì',0
-
 
222
sz_Paste db '‚áâ ¢¨âì',0
-
 
223
 
-
 
224
sz_Test db '’¥áâ',0
-
 
225
sz_Test1 db '’¥áâ 1',0
-
 
226
sz_Test2 db '’¥áâ 2',0
-
 
227
sz_Test3 db '’¥áâ 3',0
-
 
228
sz_Test4 db '’¥áâ 4',0
-
 
229
sz_Test5 db '’¥áâ 5',0
-
 
230
sz_Test6 db '’¥áâ 6',0
-
 
231
 
Line 325... Line 232...
325
    add  bl,5                      ; move position
232
sz_Help db '®¬®éì',0
326
    xor  ecx,ecx                   ; clear register
-
 
327
    mov  edx,MENU_DATA+3           ; point to button text
-
 
328
    add  edx,edi                   ; add offset
-
 
329
    mov  esi,11                    ; number of characters
-
 
Line 330... Line -...
330
    mov  eax,4                     ; function 4: write text to window
-
 
331
    mcall                      ; do it
-
 
332
is_sub_bar:
-
 
333
    add  [but_pos],17              ; move y position
-
 
334
 
-
 
335
not_sub_menu:
-
 
336
    add  edi,14                    ; move offset
-
 
337
    jmp  next_sub_item             ; do next button
-
 
338
 
-
 
339
sub_get_out:
-
 
340
 
-
 
341
    ret                            ; return
-
 
342
 
-
 
343
; ***************** DATA AREA ******************
-
 
344
 
-
 
345
x_size:       dd 381               ; window x size
-
 
346
y_size:       dd 200               ; window y size
-
 
347
 
-
 
348
window_text   db 'MENU EXAMPLE'    ; grab bar text
-
 
349
button_no     db 'BUTTON No:    '  ; status bar text
-
 
350
menu_text     db 'MENU SELECTED:'  ; status bar text
-
 
351
 
-
 
352
button_press  dd 0
-
 
353
 
-
 
354
menu_colour   dd 0x00aaaaaa        ; menu & button colour
-
 
355
 
-
 
356
menu_number   db '0'               ; menu selection
-
 
357
 
-
 
358
sub_pos       dd 1                 ; sub menu x position
-
 
359
but_pos       dd 38                ; sub menu y position
-
 
360
 
-
 
361
main_pos      dd 1                 ; main menu x position
-
 
362
 
-
 
363
MENU_DATA:    db '01'              ; MAIN MENU = 0 - 1 = menu
-
 
364
              db 100               ; button id
-
 
365
              db 'FILE       '     ; button text
-
 
366
              db '02'              ; MAIN MENU = 0 - 2 = menu
-
 
367
              db 101               ; button id
-
 
368
              db 'EDIT       '     ; button text
-
 
369
              db '04'              ; MAIN MENU = 0 - 3 = menu
-
 
370
              db 102               ; button id
-
 
371
              db 'TEST       '     ; button text
-
 
372
              db '00'              ; MAIN MENU = 0 - 0 = divider
-
 
373
              db 103               ; SPACER ID
-
 
374
              db '           '     ; SPACER TEXT padding
-
 
375
              db '03'              ; MAIN MENU = 0 - 4 = menu
-
 
376
              db 104               ; button id
-
 
377
              db 'HELP       '     ; button text
-
 
378
 
-
 
379
              db '11'              ; menu level = 1 - 1 = button
233
sz_Setup db ' áâனª¨',0
380
              db 110               ; button id
-
 
381
              db 'LOAD       '     ; button text
-
 
382
              db '11'              ; menu level = 1 - 1 = button
-
 
383
              db 111               ; button id
-
 
384
              db 'SAVE       '     ; button text
-
 
385
              db '10'              ; menu level = 1 - 0 = divider
-
 
386
              db 112               ; SPACER ID
-
 
387
              db '           '     ; SPACER TEXT padding
-
 
388
              db '11'              ; menu level = 1 - 1 = button
-
 
389
              db 113               ; button id
-
 
390
              db 'QUIT       '     ; button text
-
 
391
 
-
 
392
              db '21'              ; menu level = 2 - 1 = button
-
 
393
              db 120               ; button id
-
 
394
              db 'COPY       '     ; button text
-
 
395
              db '21'              ; menu level = 2 - 1 = button
-
 
Line -... Line 234...
-
 
234
sz_About db 'Ž ¯à®£à ¬¬¥..',0
-
 
235
 
-
 
236
else
-
 
237
 
-
 
238
sz_File db 'File',0
-
 
239
sz_Load db 'Load',0
-
 
240
sz_Save db 'Save',0
-
 
241
sz_Quit db 'Quit',0
-
 
242
 
-
 
243
sz_Edit db 'Edit',0
-
 
244
sz_Copy db 'Copy',0
-
 
245
sz_Paste db 'Paste',0
-
 
246
 
-
 
247
sz_Test db 'Test',0
-
 
248
sz_Test1 db 'Test 1',0
-
 
249
sz_Test2 db 'Test 2',0
-
 
250
sz_Test3 db 'Test 3',0
-
 
251
sz_Test4 db 'Test 4',0
396
              db 121               ; button id
252
sz_Test5 db 'Test 5',0
-
 
253
sz_Test6 db 'Test 6',0
-
 
254
 
-
 
255
sz_Help db 'Help',0
-
 
256
sz_Setup db 'Setup',0
-
 
257
sz_About db 'About..',0
-
 
258
 
-
 
259
end if
-
 
260
 
-
 
261
button_press  dd 0
-
 
262
 
-
 
263
align 4
-
 
264
system_dir_0 db '/sys/lib/'
-
 
265
lib_name_0 db 'kmenu.obj',0
-
 
266
 
-
 
267
if lang eq ru
-
 
268
	head_f_i:
-
 
269
	head_f_l db '‘¨á⥬­ ï ®è¨¡ª ',0
-
 
270
	err_msg_found_lib_0 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'kmenu.obj',39,0
-
 
271
	err_msg_import_0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'kmenu',39,0
-
 
272
else
-
 
273
	head_f_i:
-
 
274
	head_f_l db 'System error',0
-
 
275
	err_msg_found_lib_0 db 'Sorry I cannot found library ',39,'kmenu.obj',39,0
-
 
276
	err_msg_import_0 db 'Error on load import library ',39,'kmenu.obj',39,0
-
 
277
end if
-
 
278
 
-
 
279
align 4
397
              db 'PASTE      '     ; button text
280
l_libs_start:
-
 
281
	lib_0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\
-
 
282
		err_msg_found_lib_0, head_f_l, import_libkmenu,err_msg_import_0,head_f_i
-
 
283
l_libs_end:
-
 
284
 
-
 
285
align 4
-
 
286
import_libkmenu: