Subversion Repositories Kolibri OS

Rev

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

Rev 4865 Rev 4875
Line 1... Line 1...
1
VERSION equ "0.1Å"
1
VERSION equ "0.2Å"
2
 
-
 
3
    use32
2
    use32
4
    org     0
3
    org     0
5
    db	    'MENUET01'
4
    db	    'MENUET01'
6
    dd	    1, main, dataend, memory, stacktop, 0, 0
5
    dd	    1, main, dataend, memory, stacktop, 0, 0
Line 7... Line 6...
7
 
6
 
8
    include "../../proc32.inc"
7
    include "../../proc32.inc"
9
    include "../../macros.inc"
8
    include "../../macros.inc"
10
    include "../../dll.inc"
9
    include "../../dll.inc"
11
    include "../../develop/libraries/box_lib/trunk/box_lib.mac"
10
    include "../../develop/libraries/box_lib/trunk/box_lib.mac"
-
 
11
    include "parser.inc"
Line 12... Line 12...
12
    include "parser.inc"
12
    ;include "../../debug.inc"
Line 13... Line 13...
13
 
13
 
14
 ;===============================
14
 ;===============================
15
 
15
 
16
    sz_head db "Calc+ [v", VERSION, "]", 0
16
    sz_head db "Calc+ [v", VERSION, "]", 0
Line 17... Line 17...
17
    buttons db "1234567890.%-+*/()"
17
    buttons db "123456789()%^-+/*0"
18
    edb1    edit_box 184, 8, 12, 0, 0, 0, 0, 0, 500, \
18
    edb1    edit_box 184, 8, 12, 0, 0, 0, 0, 0, 500, \
Line 42... Line 42...
42
    stdcall dll.Load, imports
42
    stdcall dll.Load, imports
Line 43... Line 43...
43
 
43
 
Line 44... Line 44...
44
 ;----------------------
44
 ;----------------------
45
 
45
 
Line 46... Line 46...
46
 update:
46
 update:
47
    mcall   23, 50
47
    mcall   23, 5
48
 
48
 
49
    cmp     eax, EV_REDRAW
49
    cmp     eax, EV_REDRAW
Line 66... Line 66...
66
 ev_redraw:
66
 ev_redraw:
67
    mov     edx, [scn.win_body]
67
    mov     edx, [scn.win_body]
68
    or	    edx, 0x34 shl 24
68
    or	    edx, 0x34 shl 24
69
    mcall    0, <100, 236>, <100, 164>, , , sz_head
69
    mcall    0, <100, 236>, <100, 164>, , , sz_head
Line 70... Line -...
70
 
-
 
71
    mcall   13, <  4, 220>, <  8,  23>, [scn.gui_frame]
-
 
72
    mov     edx, [scn.gui_face]
-
 
73
    cmp     [error_n], 0
-
 
74
    je	    @f
-
 
75
    mov     edx, 0xFFAAAA
-
 
76
  @@:
-
 
77
    mcall   13, <  5, 218>, <  9, 21>
-
 
78
    mcall     , <  5, 218>, <  9,  1>, [scn.3d_face]
-
 
79
    mcall     , <  5,	1>, < 10, 20>
-
 
80
    mcall     , <  5, 218>, < 31,  1>, [scn.3d_light]
-
 
81
 
-
 
82
    mov     ebx, 224
-
 
83
    sub     ebx, [ans.size]
-
 
84
    shl     ebx, 16
-
 
85
    inc     ebx
-
 
86
    mcall     , 	  , < 9, 21>, [scn.gui_frame]
-
 
87
    add     ebx, [ans.size]
-
 
88
    add     ebx, 1 shl 16
-
 
89
    sub     ebx, 3
-
 
90
    mcall     , 	  ,	    , [scn.3d_light]
-
 
91
    add     ebx, 1 shl 16
-
 
92
    add     ecx, 1 shl 16
-
 
93
    dec     ebx
-
 
94
    dec     ecx
-
 
95
    mcall     , 	  ,	    , [scn.win_face]
-
 
96
    shr     ecx, 16
-
 
97
    mov     bx, cx
-
 
98
    add     ebx, 3 shl 16 + 6
-
 
99
    mov     ecx, [scn.win_text]
-
 
100
    or	    ecx, 1b shl 31
-
 
101
    mcall   4, , , ans.buffer
-
 
102
 
-
 
103
    mcall    1,   4,  8, [scn.win_body]
-
 
104
    mcall     , 223
-
 
105
    mcall     ,    , 30, [scn.3d_light]
70
 
106
    mcall     ,   4
-
 
107
 
-
 
108
    mov     ebx, 214
-
 
109
    sub     ebx, [ans.size]
-
 
110
    cmp     ebx, 24
-
 
111
    jg	    @f
-
 
112
    mov     ebx, 24
-
 
113
  @@:
-
 
114
    mov     [edb1.width], ebx
-
 
115
    m2m     [edb1.color],	       [scn.gui_face]
-
 
116
    m2m     [edb1.focus_border_color], [scn.gui_face]
-
 
117
    cmp     [error_n],	0
-
 
118
    je	    @f
-
 
119
    mov     [edb1.color],	       0xFFAAAA
-
 
120
    mov     [edb1.focus_border_color], 0xFFAAAA
-
 
121
  @@:
-
 
Line 122... Line 71...
122
    invoke  editbox.draw, edb1
71
    call    draw_textbox
123
 
72
 
-
 
73
    mov     [but_id], 0x4000000A
-
 
74
    mov     [txt_id], buttons
124
    mov     [but_id], 0x4000000A
75
    mov     [txt_x], 16
125
    stdcall draw_button,   4, 38,  42, buttons + 00, 15
76
    mov     [but_w], 38
126
    stdcall draw_button,  46, 38,  42, buttons + 01, 15
77
    stdcall draw_button,   4,  42
127
    stdcall draw_button,  88, 38,  42, buttons + 02, 15
78
    stdcall draw_button,  46,  42
128
    stdcall draw_button,   4, 38,  66, buttons + 03, 15
79
    stdcall draw_button,  88,  42
129
    stdcall draw_button,  46, 38,  66, buttons + 04, 15
80
    stdcall draw_button,   4,  66
130
    stdcall draw_button,  88, 38,  66, buttons + 05, 15
81
    stdcall draw_button,  46,  66
131
    stdcall draw_button,   4, 38,  90, buttons + 06, 15
82
    stdcall draw_button,  88,  66
132
    stdcall draw_button,  46, 38,  90, buttons + 07, 15
83
    stdcall draw_button,   4,  90
133
    stdcall draw_button,  88, 38,  90, buttons + 08, 15
84
    stdcall draw_button,  46,  90
134
    stdcall draw_button,   4, 80, 114, buttons + 09, 35
85
    stdcall draw_button,  88,  90
135
    stdcall draw_button,  88, 38, 114, buttons + 10, 15
86
    stdcall draw_button,  88, 114
136
 
87
 
137
    stdcall draw_button, 144, 38,  42, buttons + 11, 15
88
    stdcall draw_button, 144,  42
138
    stdcall draw_button, 186, 38,  42, buttons + 12, 15
89
    stdcall draw_button, 186,  42
139
    stdcall draw_button, 144, 38,  66, buttons + 13, 15
90
    stdcall draw_button, 144,  66
140
    stdcall draw_button, 186, 38,  66, buttons + 14, 15
91
    stdcall draw_button, 186,  66
141
    stdcall draw_button, 144, 38,  90, buttons + 15, 15
92
    stdcall draw_button, 144,  90
142
    stdcall draw_button, 186, 38,  90, buttons + 16, 15
93
    stdcall draw_button, 186,  90
-
 
94
    stdcall draw_button, 144, 114
-
 
95
    stdcall draw_button, 186, 114
-
 
96
 
-
 
97
    mov     [txt_x], 37
Line 143... Line 98...
143
    stdcall draw_button, 144, 38, 114, buttons + 17, 15
98
    mov     [but_w], 80
Line 144... Line 99...
144
    stdcall draw_button, 186, 38, 114, buttons + 18, 15
99
    stdcall draw_button,   4, 114
Line 145... Line 100...
145
 
100
 
146
    jmp     update
101
    jmp     update
Line 147... Line 102...
147
 
102
 
148
 ;----------------------
103
 ;----------------------
149
 
104
 
150
 ev_key:
105
 ev_key:
151
    mov     [timer], 1
106
    mov     [timer], 10
Line 152... Line 107...
152
 
107
 
Line 153... Line 108...
153
    mcall   2
108
    mcall   2
154
    cmp     ah, 27
109
    cmp     ah, 27
Line 155... Line 110...
155
    je	    exit
110
    je	    exit
Line 156... Line 111...
156
    invoke  editbox.key, edb1
111
    invoke  editbox.key, edb1
157
    jmp     update
112
    jmp     update
Line 158... Line 113...
158
 
113
 
-
 
114
 ;----------------------
-
 
115
 
-
 
116
 ev_button:
-
 
117
    mov     [timer], 10
-
 
118
 
-
 
119
    mcall   17
-
 
120
 
-
 
121
    cmp     ah, 1
-
 
122
    je	    exit
-
 
123
 
-
 
124
    cmp     ah, 2
-
 
125
    jne     .not_copy
-
 
126
 
-
 
127
 .copy:
-
 
128
 
-
 
129
    mov     eax, exp
-
 
130
    mov     ebx, ans.buffer
-
 
131
    mov     ecx, 0
-
 
132
  @@:
-
 
133
    mov     dl, [ebx]
-
 
134
    mov     [eax], dl
-
 
135
    inc     eax
-
 
136
    inc     ebx
-
 
137
    inc     ecx
-
 
138
    cmp     [eax - 1], byte 0
159
 ;----------------------
139
    jne     @b
Line -... Line 140...
-
 
140
 
-
 
141
    dec     ecx
160
 
142
    mov     [edb1.size], ecx
161
 ev_button:
143
    m2m     [edb1.pos], [edb1.size]
162
    mov     [timer], 1
144
 
163
 
145
    jmp     .redraw
164
    mcall   17
146
 
Line 186... Line 168...
186
    jmp     @b
168
    jmp     @b
187
  @@:
169
  @@:
188
    dec     [edb1.pos]
170
    dec     [edb1.pos]
189
    dec     [edb1.size]
171
    dec     [edb1.size]
190
    m2m     [edb1.shift], [edb1.pos]
172
    m2m     [edb1.shift], [edb1.pos]
191
    jmp     ev_redraw
173
    jmp     .redraw
Line 192... Line 174...
192
 
174
 
Line 193... Line 175...
193
 .not_del:
175
 .not_del:
194
 
176
 
Line 217... Line 199...
217
 
199
 
218
    mov     [ebx], al
200
    mov     [ebx], al
219
    inc     [edb1.size]
201
    inc     [edb1.size]
Line -... Line 202...
-
 
202
    inc     [edb1.pos]
-
 
203
 
220
    inc     [edb1.pos]
204
 .redraw:
Line 221... Line 205...
221
 
205
    call    draw_textbox
Line 222... Line 206...
222
    jmp     ev_redraw
206
    jmp     update
223
 
207
 
Line 243... Line 227...
243
 
227
 
244
    stdcall convert_to_str, eax, ans.buffer
228
    stdcall convert_to_str, eax, ans.buffer
245
    imul    eax, 6
229
    imul    eax, 6
246
    add     eax, 9
230
    add     eax, 9
247
    mov     [ans.size], eax
231
    mov     [ans.size], eax
Line 248... Line 232...
248
    jmp     ev_redraw
232
    jmp     .redraw
249
 
233
 
250
 .error:
234
 .error:
-
 
235
    cmp     [error_n], 1
-
 
236
    je	    .err_1
-
 
237
    cmp     [error_n], 4
-
 
238
    je	    .err_4
-
 
239
 
-
 
240
    mov     [ans.buffer +  0], dword "Expe"
-
 
241
    mov     [ans.buffer +  4], dword "cted"
-
 
242
    mov     [ans.buffer +  8], dword " ')'"
-
 
243
    mov     [ans.buffer + 12], byte 0
-
 
244
    mov     [ans.size], 81
251
    cmp     [error_n], 1
245
 
-
 
246
    cmp     [error_n], 2
-
 
247
    je	    .redraw
252
    je	    .err_1
248
    cmp     [error_n], 3
253
    jmp     ev_redraw
249
    je	    .err_3
254
 .err_1:
250
 .err_1:
-
 
251
    mov     [ans.buffer +  0], dword "Div."
-
 
252
    mov     [ans.buffer +  4], dword " by "
-
 
253
    mov     [ans.buffer +  8], byte  "0"
-
 
254
    mov     [ans.buffer +  9], byte 0
-
 
255
    mov     [ans.size], 63
-
 
256
    jmp     .redraw
-
 
257
 .err_4:
255
    mov     [ans.buffer +  0], dword "Div."
258
    mov     [ans.buffer +  0], dword "Inpu"
256
    mov     [ans.buffer +  4], dword " by "
259
    mov     [ans.buffer +  4], dword "t er"
257
    mov     [ans.buffer +  8], dword "zero"
260
    mov     [ans.buffer +  8], dword "rror"
258
    mov     [ans.buffer + 12], byte 0
261
    mov     [ans.buffer + 12], byte 0
-
 
262
    mov     [ans.size], 81
-
 
263
    jmp     .redraw
-
 
264
 .err_3:
-
 
265
    mov     [ans.buffer + 10], byte "("
-
 
266
    jmp     .redraw
-
 
267
 
-
 
268
 .redraw:
Line 259... Line 269...
259
    mov     [ans.size], 81
269
    call    draw_textbox
Line 260... Line 270...
260
    jmp     ev_redraw
270
    jmp     update
261
 
271
 
Line 262... Line 272...
262
 ;----------------------
272
 ;----------------------
263
 
273
 
264
 proc draw_button, x, w, y, txt, txtx
274
 proc draw_button, x, y
265
    mcall   13, <[x], [w]>, <[y], 20>, [scn.gui_frame]
275
    mcall   13, <[x], [but_w]>, <[y], 20>, [scn.gui_frame]
Line 280... Line 290...
280
    dec     ecx
290
    dec     ecx
281
    mcall   , , , [scn.win_face]
291
    mcall   , , , [scn.win_face]
Line 282... Line 292...
282
 
292
 
Line 283... Line 293...
283
    mcall   1, [x], [y], [scn.win_body]
293
    mcall   1, [x], [y], [scn.win_body]
284
 
294
 
285
    add     ebx, [w]
295
    add     ebx, [but_w]
Line 286... Line 296...
286
    dec     ebx
296
    dec     ebx
287
    mcall
297
    mcall
288
 
298
 
Line 289... Line 299...
289
    add     ecx, 20
299
    add     ecx, 20
290
    dec     ecx
300
    dec     ecx
291
    mcall
301
    mcall
Line 292... Line 302...
292
 
302
 
293
    sub     ebx, [w]
303
    sub     ebx, [but_w]
294
    inc     ebx
304
    inc     ebx
295
    mcall
305
    mcall
296
 
306
 
297
    mov     ebx, [x]
307
    mov     ebx, [x]
298
    inc     ebx
308
    inc     ebx
299
    shl     ebx, 16
309
    shl     ebx, 16
300
    add     ebx, [w]
310
    add     ebx, [but_w]
301
    sub     ebx, 3
311
    sub     ebx, 3
302
    mov     ecx, [y]
312
    mov     ecx, [y]
303
    inc     ecx
313
    inc     ecx
304
    shl     ecx, 16
-
 
Line 305... Line 314...
305
    add     ecx, 20
314
    shl     ecx, 16
306
    sub     ecx, 3
315
    add     ecx, 20
307
    mov     edx, [but_id]
316
    sub     ecx, 3
308
    mcall   8
317
    mov     edx, [but_id]
309
    inc     dword[but_id]
318
    mcall   8
310
 
319
 
-
 
320
    mov     ebx, [x]
-
 
321
    add     ebx, [txt_x]
-
 
322
    shl     ebx, 16
-
 
323
    add     ebx, [y]
-
 
324
    add     ebx, 7
-
 
325
    mcall   4, , [scn.win_text], [txt_id], 1
-
 
326
 
-
 
327
    inc     dword [txt_id]
-
 
328
    inc     dword [but_id]
-
 
329
 
-
 
330
    ret
-
 
331
 endp
-
 
332
 
-
 
333
 ;----------------------
-
 
334
 
-
 
335
 proc draw_textbox
-
 
336
    mcall   13, <  4, 220>, <  8,  23>, [scn.gui_frame]
-
 
337
    mov     edx, [scn.gui_face]
-
 
338
    cmp     [error_n], 0
-
 
339
    je	    @f
-
 
340
    mov     edx, 0xFFAAAA
-
 
341
  @@:
-
 
342
    mcall   13, <  5, 218>, <  9, 21>
-
 
343
    mcall     , <  5, 218>, <  9,  1>, [scn.3d_face]
-
 
344
    mcall     , <  5,	1>, < 10, 20>
-
 
345
    mcall     , <  5, 218>, < 31,  1>, [scn.3d_light]
-
 
346
 
-
 
347
    mov     ebx, 224
-
 
348
    sub     ebx, [ans.size]
-
 
349
    shl     ebx, 16
-
 
350
    inc     ebx
-
 
351
    mcall     , 	  , < 9, 21>, [scn.gui_frame]
-
 
352
    add     ebx, [ans.size]
-
 
353
    add     ebx, 1 shl 16
-
 
354
    sub     ebx, 3
-
 
355
    mcall     , 	  ,	    , [scn.3d_light]
-
 
356
    cmp     [error_n], 0
-
 
357
    jne     .btn_not
-
 
358
    mcall   8, , , 0x40000002
-
 
359
 .btn_not:
-
 
360
    add     ebx, 1 shl 16
-
 
361
    add     ecx, 1 shl 16
-
 
362
    dec     ebx
-
 
363
    dec     ecx
-
 
364
    mcall   13, 	  ,	    , [scn.win_face]
-
 
365
    shr     ecx, 16
-
 
366
    mov     bx, cx
-
 
367
    add     ebx, 3 shl 16 + 6
-
 
368
    mov     ecx, [scn.win_text]
-
 
369
    or	    ecx, 1b shl 31
-
 
370
    mcall   4, , , ans.buffer
-
 
371
 
-
 
372
    mcall    1,   4,  8, [scn.win_body]
-
 
373
    mcall     , 223
-
 
374
    mcall     ,    , 30, [scn.3d_light]
-
 
375
    mcall     ,   4
-
 
376
 
-
 
377
    mov     ebx, 214
-
 
378
    sub     ebx, [ans.size]
-
 
379
    cmp     ebx, 24
-
 
380
    jg	    @f
-
 
381
    mov     ebx, 24
-
 
382
  @@:
-
 
383
    mov     [edb1.width], ebx
-
 
384
    m2m     [edb1.color],	       [scn.gui_face]
-
 
385
    m2m     [edb1.focus_border_color], [scn.gui_face]
Line 311... Line 386...
311
    mov     ebx, [x]
386
    cmp     [error_n],	0
312
    add     ebx, [txtx]
387
    je	    @f
Line 313... Line 388...
313
    shl     ebx, 16
388
    mov     [edb1.color],	       0xFFAAAA
Line 337... Line 412...
337
 error_n    rd 1
412
 error_n    rd 1
Line 338... Line 413...
338
 
413
 
339
 scn	    sys_colors_new
414
 scn	    sys_colors_new
340
 timer	    rd 1
415
 timer	    rd 1
-
 
416
 but_id     rd 1
-
 
417
 but_w	    rd 1
-
 
418
 txt_id     rd 1
Line 341... Line 419...
341
 but_id     rd 1
419
 txt_x	    rd 1