Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1041 mario79 1
;
2
; Example for Box_lib: scrollbar, menubar, dinamic_button
3
; Copyright (c) 2009, Mario79
4
; All rights reserved.
5
;
6
; Redistribution and use in source and binary forms, with or without
7
; modification, are permitted provided that the following conditions are met:
1068 Lrz 8
;       * Redistributions of source code must retain the above copyright
9
;       notice, this list of conditions and the following disclaimer.
10
;       * Redistributions in binary form must reproduce the above copyright
11
;       notice, this list of conditions and the following disclaimer in the
12
;       documentation and/or other materials provided with the distribution.
13
;       * Neither the name of the  nor the
14
;       names of its contributors may be used to endorse or promote products
15
;       derived from this software without specific prior written permission.
1041 mario79 16
;
17
; THIS SOFTWARE IS PROVIDED BY Mario79 ''AS IS'' AND ANY
18
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
; DISCLAIMED. IN NO EVENT SHALL  BE LIABLE FOR ANY
21
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
;*****************************************************************************
28
; import_boxlib procedure written by 
29
;---------------------------------------------------------------------
30
 
1068 Lrz 31
        use32
32
        org     0x0
1041 mario79 33
 
1068 Lrz 34
        db      'MENUET01'
35
        dd      0x01
36
        dd      START
37
        dd      IM_END
38
        dd      I_END
39
        dd      stacktop
40
        dd      0x0
41
        dd      path
1041 mario79 42
 
43
include 'MACROS.INC'
1068 Lrz 44
include 'load_lib.mac'
1041 mario79 45
;---------------------------------------------------------------------
1068 Lrz 46
;---    Start of program        ----------------------------------------------
1041 mario79 47
;---------------------------------------------------------------------
48
START:
1068 Lrz 49
        mcall 68, 11
50
        mcall 66, 1, 1
51
        mcall 40, 0x27
52
;---------------------------------------------------------------------
1041 mario79 53
; Procinfo area for function 9 in MenuBar
1068 Lrz 54
        mcall   68,12,1024
55
        mov     [menu_data_1.procinfo],eax
56
        mov     [menu_data_2.procinfo],eax
57
;---------------------------------------------------------------------
1041 mario79 58
; loading Box_Lib library
1068 Lrz 59
load_libraries l_libs_start,end_l_libs
60
;sys_load_library  boxlib_name, path, file_name, system_dir, \
61
;er_message_found_lib, ihead_f_l, myimport, er_message_import, ihead_f_i
62
;        test    eax,eax
63
;        jnz  button.exit
1041 mario79 64
 
1068 Lrz 65
;----------------------------------old
66
;        mov     ebx,boxlib_name
67
;        mov     esi,path
68
;        mov     edi,file_name
69
;        call    copy_path
70
;
71
;        mcall 68,19,file_name ; load of alternative
72
;        test    eax,eax
73
;        jnz @f
74
;
75
;        mcall 68,19,system_dir ; load of sys directory
76
;        test    eax,eax
77
;        jz      button.exit
78
;@@:
79
;        call    import_boxlib
1041 mario79 80
;---------------------------------------------------------------------
81
; Load and convert BMP file for DinamicButton
82
; This procedures use cnv_bmp.obj and this module used only for
83
; demonstration of use DinamicButton
1068 Lrz 84
 
85
;        mov     ebx,plugin_BMP_name
86
;        mov     esi,path
87
;        mov     edi,file_name
88
	copy_path   plugin_BMP_name,path,file_name
1041 mario79 89
;
1068 Lrz 90
        mcall 68,19,file_name
91
        test    eax,eax
92
        jz  button.exit
93
 
94
        mov     eax,[eax+4]
95
        mov     [plugin],eax
1041 mario79 96
 
97
 
1068 Lrz 98
;проверка на сколько удачно загузилась наша либа
99
        mov     ebp,library01
100
        cmp     dword [ebp+ll_struc_size-4],0
101
        jnz     button.exit
102
;
103
;        mov     ebp,library02
104
;        cmp     dword [ebp+ll_struc_size-4],0x2
105
;        jnz     button.exit
106
;        mov     eax,dword [ebp+36]
107
;        mov     eax,[eax+4]
108
;        mov     [plugin],eax
109
 
110
 
1041 mario79 111
 
1068 Lrz 112
;        mov     ebx,icons_file_name
113
;        mov     esi,path
114
;        mov     edi,file_name
115
        copy_path    icons_file_name,path,file_name
116
 
117
        mcall 70, fileinfo
1041 mario79 118
 
1068 Lrz 119
        mov     [fileinfo+0],dword 0
1041 mario79 120
 
1068 Lrz 121
        mov     ecx,[file_info+32]
122
        mov     [fileinfo+12],ecx
123
        mov [img_size],ecx
124
 
1041 mario79 125
 
1068 Lrz 126
        mcall 68, 12
1041 mario79 127
 
128
 
1068 Lrz 129
        mov     [fileinfo+16],eax
130
        mov     [image_file],eax
1041 mario79 131
 
1068 Lrz 132
 
133
        mcall 70, fileinfo
134
 
135
        xor     eax,eax
136
        mov     [return_code],eax
137
        mov     eax,image_file
138
        call    [plugin]
139
 
140
        mov     ecx,[image_file]
141
        mcall 68, 13,
142
 
143
        cmp     [return_code],dword 0
144
        jne     button.exit
145
 
146
        mov     ebx,[raw_pointer]
147
        mov     eax,[ebx+4]
148
        ; set of button size
149
        mov     [dinamic_button_data_1.size_x],ax
150
        mov     [dinamic_button_data_1.size_y],ax
151
        mov     [dinamic_button_data_2.size_x],ax
152
        mov     [dinamic_button_data_2.size_y],ax
153
        mov     eax,[ebx+12]
154
        ; set of RAW resolution to pixel
155
        mov     [dinamic_button_data_1.resolution_raw],eax
156
        mov     [dinamic_button_data_2.resolution_raw],eax
157
        mov     eax,[ebx+20]
158
        add     eax,ebx
159
        ; set RAW palette, use else resolution 8bit or less
160
        mov     [dinamic_button_data_1.palette_raw],eax
161
        mov     [dinamic_button_data_2.palette_raw],eax
162
        mov     eax,[ebx+28]
163
        add     eax,ebx
164
        ; set RAW area for passive button
165
        mov     [dinamic_button_data_1.passive_raw],eax
166
        mov     [dinamic_button_data_2.passive_raw],eax
167
        mov     ecx,[ebx+4]
168
        imul ecx,[ebx+4]
169
        imul ecx,[ebx+12]
170
        shr     ecx,3
171
        add     eax,ecx
172
        ; set  RAW area for active button
173
        mov     [dinamic_button_data_1.active_raw],eax
174
        mov     [dinamic_button_data_2.active_raw],eax
175
        add     eax,ecx
176
        ; RAW area for click button
177
        mov     [dinamic_button_data_1.click_raw],eax
178
        mov     [dinamic_button_data_2.click_raw],eax
179
;---------------------------------------------------------------------
1041 mario79 180
red:
1068 Lrz 181
        call draw_window
1041 mario79 182
still:
1068 Lrz 183
        mcall 10
1041 mario79 184
 
1068 Lrz 185
        cmp     eax,1
186
        je      red
187
        cmp     eax,2
188
        je      key
189
        cmp     eax,3
190
        je      button
191
        cmp     eax,6
192
        je      mouse
193
        jmp     still
1041 mario79 194
 
195
 
196
;---------------------------------------------------------------------
1068 Lrz 197
        key:
198
        mcall 2
199
        jmp     still
1041 mario79 200
;---------------------------------------------------------------------
1068 Lrz 201
        button:
202
        mcall 17
203
        cmp     ah, 1
204
        jne     still
205
        .exit:
206
        mcall -1
1041 mario79 207
;---------------------------------------------------------------------
208
mouse:
209
;-----------------------------------------------
1068 Lrz 210
        cmp     [scroll_bar_data_horizontal.delta2],0
211
        jne     .horizontal
1041 mario79 212
.vertical:
213
    mov   eax,[scroll_bar_data_vertical.max_area]
214
    cmp   eax,[scroll_bar_data_vertical.cur_area]
215
    jbe   .horizontal
216
; mouse event for Vertical ScrollBar
1068 Lrz 217
        push dword scroll_bar_data_vertical
218
        call [scrollbar_ver_mouse]
219
        mov  eax,scroll_bar_data_vertical.redraw
220
        xor  ebx,ebx
221
        cmp     [eax],ebx
222
        je      @f
223
        mov     [eax],ebx
224
        jmp     .draw_cube
1041 mario79 225
@@:
1068 Lrz 226
        cmp     [scroll_bar_data_vertical.delta2],0
227
        jne     still
1041 mario79 228
.horizontal:
229
    mov   eax,[scroll_bar_data_horizontal.max_area]
230
    cmp   eax,[scroll_bar_data_horizontal.cur_area]
231
    jbe   .other
232
; mouse event for Horizontal ScrollBar
1068 Lrz 233
        push dword scroll_bar_data_horizontal
234
        call [scrollbar_hor_mouse]
235
        mov  eax,scroll_bar_data_horizontal.redraw
236
        xor  ebx,ebx
237
        cmp     [eax],ebx
238
        je      .other
239
        mov     [eax],ebx
1041 mario79 240
.draw_cube:
1068 Lrz 241
        call draw_cube
242
        jmp     still
1041 mario79 243
.other:
1068 Lrz 244
        cmp  [scroll_bar_data_vertical.delta2],0
245
        jne   still
246
        cmp  [scroll_bar_data_horizontal.delta2],0
247
        jne   still
1041 mario79 248
;-----------------------------------------------
249
.menu_bar_1:
1068 Lrz 250
        call   .set_mouse_flag
1041 mario79 251
@@:
252
; mouse event for Menu 1
1068 Lrz 253
        push    dword menu_data_1
254
        call    [menu_bar_mouse]
1041 mario79 255
    cmp   [menu_data_1.click],dword 1
1068 Lrz 256
        jne   .menu_bar_2
257
        cmp   [menu_data_1.cursor_out],dword 0
258
        jne    analyse_out_menu_1
259
        jmp    .menu_bar_1
1041 mario79 260
;--------------------------------------------
261
.menu_bar_2:
262
; mouse event for Menu 2
1068 Lrz 263
        push    dword menu_data_2
264
        call    [menu_bar_mouse]
1041 mario79 265
    cmp   [menu_data_2.click],dword 1
1068 Lrz 266
        jne   .mouse_dinamic_button
267
        cmp   [menu_data_2.cursor_out],dword 0
268
        jne    analyse_out_menu_2
1041 mario79 269
    jmp    .menu_bar_1
270
;--------------------------------------------
271
.mouse_dinamic_button:
272
; mouse event for Dinamic Button 1
1068 Lrz 273
        push    dword dinamic_button_data_1
274
        call    [dinamic_button_mouse]
275
        mov   eax,dinamic_button_data_1.click
1041 mario79 276
    cmp   [eax],dword 1
1068 Lrz 277
        jne   @f
1041 mario79 278
    mov   [eax],dword 0
1068 Lrz 279
        jmp   about
1041 mario79 280
@@:
281
; mouse event for Dinamic Button 2
1068 Lrz 282
        push    dword dinamic_button_data_2
283
        call    [dinamic_button_mouse]
284
        mov   eax,dinamic_button_data_2.click
1041 mario79 285
    cmp   [eax],dword 1
1068 Lrz 286
        jne   still  ;@f
1041 mario79 287
    mov   [eax],dword 0
1068 Lrz 288
        jmp   button.exit
1041 mario79 289
;---------------------------------------------------------------------
1068 Lrz 290
.set_mouse_flag:
291
        xor   eax,eax
292
        inc   eax
293
        mov   [menu_data_1.get_mouse_flag],eax
294
        mov   [menu_data_2.get_mouse_flag],eax
295
        ret
1041 mario79 296
;---------------------------------------------------------------------
297
analyse_out_menu_1:
298
; analyse result of Menu 1
1068 Lrz 299
        cmp [menu_data_1.cursor_out],dword 3
300
        je      button.exit
301
        jmp     still
302
 
1041 mario79 303
analyse_out_menu_2:
304
; analyse result of Menu 2
1068 Lrz 305
        cmp [menu_data_2.cursor_out],dword 2
306
        je      about
307
        jmp     still
1041 mario79 308
;---------------------------------------------------------------------
1068 Lrz 309
        about:
310
        mcall 51,1,thread3,thread
311
        jmp     still
1041 mario79 312
;---------------------------------------------------------------------
313
draw_window:
1068 Lrz 314
        mcall 12, 1
315
        mcall 0, <0,400>, <0,400>, 0x03AABBCC, 0x805080D0, 0x005080D0
316
        mcall 71, 1, header_1
1041 mario79 317
;---------------------------------------------
318
; draw for Menu 1
1068 Lrz 319
        push    dword menu_data_1
320
        call    [menu_bar_draw]
1041 mario79 321
; draw for Menu 2
1068 Lrz 322
        push    dword menu_data_2
323
        call    [menu_bar_draw]
1041 mario79 324
;---------------------------------------------
325
; draw for Dinamic Button 1
1068 Lrz 326
        push    dword dinamic_button_data_1
327
        call    [dinamic_button_draw]
1041 mario79 328
; draw for Dinamic Button 2
1068 Lrz 329
        push    dword dinamic_button_data_2
330
        call    [dinamic_button_draw]
1041 mario79 331
;---------------------------------------------
332
; set all_redraw flag for draw all ScrollBar
333
; In some cases it is necessity to draw only the area
334
; of moving of a "runner", for acceleration of output -
335
; in this case the flag needs to be reset to 0 (zero).
1068 Lrz 336
        xor     eax,eax
337
        inc     eax
338
        mov     [scroll_bar_data_vertical.all_redraw],eax
339
        mov     [scroll_bar_data_horizontal.all_redraw],eax
340
 
1041 mario79 341
; draw for Vertical ScrollBar
1068 Lrz 342
        push     dword scroll_bar_data_vertical
343
        call     [scrollbar_ver_draw]
1041 mario79 344
; draw for Horizontal ScrollBar
1068 Lrz 345
        push     dword scroll_bar_data_horizontal
346
        call     [scrollbar_hor_draw]
347
; reset all_redraw flag
348
        xor     eax,eax
349
        mov     [scroll_bar_data_vertical.all_redraw],eax
350
        mov     [scroll_bar_data_horizontal.all_redraw],eax
1041 mario79 351
;---------------------------------------------
1068 Lrz 352
        call draw_cube
353
        mcall 12, 2
354
        ret
1041 mario79 355
;---------------------------------------------------------------------
356
draw_cube:
1068 Lrz 357
        mcall 13,<30,301>,<50,301>,0xafafaf
358
        mov     ecx,[scroll_bar_data_vertical.position]
359
        add     ecx,50
360
        shl     ecx,16
361
        mov     cx,30
362
        mov     ebx,[scroll_bar_data_horizontal.position]
363
        add     ebx,30
364
        shl     ebx,16
365
        mov     bx,30
366
        mcall 13, , , 0x0
367
        ret
1041 mario79 368
 
1068 Lrz 369
include 'data.inc'
370
include 'w_about.inc'
1041 mario79 371
IM_END:
1068 Lrz 372
        rb 1024
1041 mario79 373
thread:
1068 Lrz 374
        rb 1024
1041 mario79 375
stacktop:
376
path:
1068 Lrz 377
        rb      4096
1041 mario79 378
file_name:
1068 Lrz 379
        rb 4096
1041 mario79 380
file_info:
1068 Lrz 381
        rb 40
1041 mario79 382
I_END:
383