Subversion Repositories Kolibri OS

Rev

Rev 2703 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2703 Rev 9647
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;                                          ;
2
;                                          ;
3
;   Color Slider Control Demonstration     ;
3
;   Color Slider Control Demonstration     ;
4
;                                          ;
4
;                                          ;
5
;   Compile with FASM for Menuet           ;
5
;   Compile with FASM for Kolibri          ;
6
;                                          ;
6
;                                          ;
7
;   Author: Jason Delozier                 ;
7
;   Author: Jason Delozier                 ;
8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 9... Line 9...
9
 
9
 
Line 19... Line 19...
19
               dd     0x1000                  ; esp
19
               dd     0x1000                  ; esp
20
               dd     0x0 , 0x0               ; I_Param , I_Icon
20
               dd     0x0 , 0x0               ; I_Param , I_Icon
Line 21... Line 21...
21
 
21
 
22
include 'lang.inc'
22
include 'lang.inc'
-
 
23
include '..\..\..\macros.inc'
23
include '..\..\..\macros.inc'
24
include '..\..\..\KOSfuncs.inc'
Line 24... Line 25...
24
START:                          ; start of execution
25
START:                          ; start of execution
Line 25... Line 26...
25
 
26
 
26
    call draw_window            ; at first, draw the window
27
    call draw_window            ; at first, draw the window
Line 27... Line 28...
27
 
28
 
Line 28... Line 29...
28
still:
29
still:
29
    call mouse_info
30
    call mouse_info
30
 
31
 
31
    mcall 23, 2
32
    mcall SF_WAIT_EVENT_TIMEOUT, 2
Line 42... Line 43...
42
  red:                          ; redraw
43
  red:                          ; redraw
43
    call draw_window
44
    call draw_window
44
    jmp  still
45
    jmp  still
Line 45... Line 46...
45
 
46
 
46
  key:                          ; key
47
  key:                          ; key
47
    mcall 2                  ; just read it and ignore
48
    mcall SF_GET_KEY            ; just read it and ignore
Line 48... Line 49...
48
    jmp  still
49
    jmp  still
49
 
50
 
Line 50... Line 51...
50
  button:                       ; button
51
  button:                       ; button
Line 51... Line 52...
51
    mcall 17                 ; get id
52
    mcall SF_GET_BUTTON         ; get id
52
    
53
    
53
    shr  eax,8
54
    shr  eax,8
54
 
55
 
Line 55... Line 56...
55
    cmp  eax,1                   ; button id=1 ?
56
    cmp  eax,1                   ; button id=1 ?
56
    jne  noclose
57
    jne  noclose
Line 66... Line 67...
66
;   *******  WINDOW DEFINITIONS AND DRAW ********
67
;   *******  WINDOW DEFINITIONS AND DRAW ********
67
;   *********************************************
68
;   *********************************************
Line 68... Line 69...
68
 
69
 
69
 
70
 
70
draw_window:
71
draw_window:
71
    mcall 12, 1                    ; 1, start of draw
72
    mcall SF_REDRAW, SSF_BEGIN_DRAW
Line 72... Line 73...
72
    mcall 0, <100,200>, <100,200>, 0x14ffffff, , title ; DRAW WINDOW
73
    mcall SF_CREATE_WINDOW, <100,200>, <100,200>, 0x14ffffff, , title
Line 73... Line 74...
73
    mcall 12,2                    ; end WINDOW redraw
74
    mcall SF_REDRAW, SSF_END_DRAW
74
	
75
	
Line 93... Line 94...
93
mousey dw 0
94
mousey dw 0
94
mousex dw 0
95
mousex dw 0
95
mouseb dd 0
96
mouseb dd 0
Line 96... Line 97...
96
 
97
 
97
mouse_info:
98
mouse_info:
98
   mcall 37, 1            ;get mouse cordinates
99
   mcall SF_MOUSE_GET, SSF_WINDOW_POSITION
99
   mov ecx, eax           ;
100
   mov ecx, eax           ;
100
   push ecx               ;
101
   push ecx               ;
101
   mcall  37, 2           ;get mouse buttons
102
   mcall SF_MOUSE_GET, SSF_BUTTON
102
   cmp [mouseb], eax      ;compare old mouse states to new states
103
   cmp [mouseb], eax      ;compare old mouse states to new states
103
   jne redraw_mouse_info  ;
104
   jne redraw_mouse_info  ;
104
   cmp [mousey], cx       ;
105
   cmp [mousey], cx       ;
105
   jne redraw_mouse_info  ;
106
   jne redraw_mouse_info  ;
Line 148... Line 149...
148
;***********************************************
149
;***********************************************
Line 149... Line 150...
149
 
150
 
150
 
151
 
151
draw_slider_info:
152
draw_slider_info:
152
;Repaint value background
153
;Repaint value background
153
   mcall 13, 144*65536+36, 72*65536+9, 0x00ffffff 
154
   mcall SF_DRAW_RECT, 144*65536+36, 72*65536+9, 0x00ffffff 
154
;Draw Color Box
155
;Draw Color Box
155
   xor edx, edx
156
   xor edx, edx
156
   movzx ecx,word [slider_1+12]
157
   movzx ecx,word [slider_1+12]
Line 160... Line 161...
160
   shl edx, 8
161
   shl edx, 8
161
   movzx ecx,word [slider_3+12]
162
   movzx ecx,word [slider_3+12]
162
   mov dl,cl
163
   mov dl,cl
163
   mov ebx, 0x00860035
164
   mov ebx, 0x00860035
164
   mov ecx, 0x00590040
165
   mov ecx, 0x00590040
165
   mov eax, 13
166
   mov eax, SF_DRAW_RECT
166
   mcall 
167
   mcall 
167
;draw current value of slider
168
;draw current value of slider
168
   mov ecx, edx
169
   mov ecx, edx
169
   mov eax, 47
170
   mov eax, SF_DRAW_NUMBER
170
   mov ebx, 0x00060100
171
   mov ebx, 0x00060100
171
   mov esi, 0
172
   mov esi, 0
172
   mov edx, 144*65536+72
173
   mov edx, 144*65536+72
173
   mcall
174
   mcall
174
ret
175
ret
Line 232... Line 233...
232
;**************************************
233
;**************************************
Line 233... Line 234...
233
 
234
 
Line 234... Line 235...
234
box_h dw 10  ;static slider box height
235
box_h dw 10  ;static slider box height
235
 
-
 
236
draw_slider:
-
 
237
   push eax
-
 
238
   push ebx
236
 
239
   push ecx
237
draw_slider:
240
   push edx
238
   push eax ebx ecx edx
241
;Draw slider background
239
;Draw slider background
242
   mov   eax, 13         ;slider background
240
   mov   eax, SF_DRAW_RECT ;slider background
243
   mov   ebx, [ebp]      ;x start/width
241
   mov   ebx, [ebp]      ;x start/width
244
   mov   ecx, [ebp+4]    ;y start/height
242
   mov   ecx, [ebp+4]    ;y start/height
245
   mov   edx, 0x00EBEBEB ;color
243
   mov   edx, 0x00EBEBEB ;color
Line 273... Line 271...
273
   shr   edx, 1            ;
271
   shr   edx, 1            ;
274
   sub   ecx, edx          ;
272
   sub   ecx, edx          ;
275
   sub   ecx, eax          ;*slide box y position
273
   sub   ecx, eax          ;*slide box y position
276
   shl   ecx, 16           ;
274
   shl   ecx, 16           ;
277
   mov    cx, [box_h]      ;height
275
   mov    cx, [box_h]      ;height
278
   mov   eax, 13           ;draw bar sys function
276
   mov   eax, SF_DRAW_RECT ;draw bar sys function
279
   mov   edx, 0x00         ;color
277
   mov   edx, 0x00         ;color
280
   mcall               ;draw slider box
278
   mcall               ;draw slider box
281
   pop edx
-
 
282
   pop ecx
-
 
283
   pop ebx
-
 
284
   pop eax
279
   pop edx ecx ebx eax
285
ret
280
ret
Line 286... Line 281...
286
 
281
 
287
slider_mouse_over:
-
 
288
   push eax
-
 
289
   push ebx
-
 
290
   push ecx
282
slider_mouse_over:
291
   push edx
283
   push eax ebx ecx edx
292
   cmp [mouseb], 1
284
   cmp [mouseb], 1
293
   jne slider_mouse_over_done
285
   jne slider_mouse_over_done
294
   movzx eax,word [ebp+4]
286
   movzx eax,word [ebp+4]
295
   add    ax, [ebp+6]
287
   add    ax, [ebp+6]
Line 320... Line 312...
320
slider_mouse_change:        ;
312
slider_mouse_change:        ;
321
   mov   [ebp+12],bx        ;new slider current position
313
   mov   [ebp+12],bx        ;new slider current position
322
   call draw_slider         ;
314
   call draw_slider         ;
323
   call draw_slider_info    ;
315
   call draw_slider_info    ;
324
slider_mouse_over_done:     ;
316
slider_mouse_over_done:     ;
325
   pop edx
-
 
326
   pop ecx
-
 
327
   pop ebx
-
 
328
   pop eax
317
   pop edx ecx ebx eax
329
ret
318
ret
Line 330... Line 319...
330
 
319
 
331
 
320