Subversion Repositories Kolibri OS

Rev

Rev 814 | Rev 9014 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
183 diamond 1
; int __stdcall GenericBox(DLGTEMPLATE* dlg, void* DlgProc);
2
;       int __stdcall DlgProc(DLGTEMPLATE* dlg, int msg, int param1, int param2);
180 heavyiron 3
 
4
virtual at 0
5
dlgtemplate:
314 diamond 6
; Флаги:
7
; бит 0: использовать стандартные цвета диалога
8
; бит 1: использовать стандартные цвета предупреждения/ошибки
9
; (если любой из этих битов установлен, поля main_color,border_color,header_color
10
;  игнорируются)
814 diamond 11
; бит 2: не рисовать тень
180 heavyiron 12
.flags          dd      ?
13
.x              dd      ?
14
.y              dd      ?
15
.width          dd      ?
16
.height         dd      ?
17
.border_size_x  dd      ?
18
.border_size_y  dd      ?
19
.title          dd      ?
20
.main_color     db      ?
21
.border_color   db      ?
22
.header_color   db      ?
23
                db      ?       ; align
814 diamond 24
.dataptr        dd      ?       ; used internally, ignored on input
183 diamond 25
.size = $
180 heavyiron 26
end virtual
27
 
183 diamond 28
GenericBox:
814 diamond 29
        push    [cursor_x]
30
        push    [cursor_y]
31
        push    dword [esp+8+8]
32
        push    dword [esp+8+8]
33
        call    ShowGenericBox
34
        test    eax, eax
35
        jz      @f
36
        pop     [cursor_y]
37
        pop     [cursor_x]
38
        ret
39
@@:
180 heavyiron 40
        pushad
814 diamond 41
; message loop
42
.event:
997 diamond 43
;        call    get_event
814 diamond 44
        push    10
45
        pop     eax
46
        int     40h
47
        dec     eax
48
        jz      .redraw
49
        dec     eax
50
        jz      .key
51
        jmp     exit
52
.redraw:
53
        call    draw_window
54
        jmp     .event
55
.key:
56
        mov     al, 2
57
        int     40h
58
        shr     eax, 8
59
        cmp     al, 0xE0
60
        jnz     @f
61
        mov     [bWasE0], 1
62
        jmp     .event
63
@@:
64
        xchg    ah, [bWasE0]
65
        cmp     al, 0x1D
66
        jz      .ctrl_down
67
        cmp     al, 0x9D
68
        jz      .ctrl_up
69
        cmp     al, 0x2A
70
        jz      .lshift_down
71
        cmp     al, 0xAA
72
        jz      .lshift_up
73
        cmp     al, 0x36
74
        jz      .rshift_down
75
        cmp     al, 0xB6
76
        jz      .rshift_up
77
        cmp     al, 0x38
78
        jz      .alt_down
79
        cmp     al, 0xB8
80
        jz      .alt_up
81
        mov     ebx, [esp+24h+8]
82
        mov     ecx, [esp+28h+8]
83
        push    0
84
        push    eax
85
        push    2
86
        push    ebx
87
        call    ecx
88
        test    eax, eax
89
        jz      .event
90
        mov     [esp+28], eax
91
        jmp     .exit
92
.ctrl_down:
93
        test    ah, ah
94
        jnz     .rctrl_down
95
        or      [ctrlstate], 4
96
        jmp     .event
97
.rctrl_down:
98
        or      [ctrlstate], 8
99
        jmp     .event
100
.ctrl_up:
101
        test    ah, ah
102
        jnz     .rctrl_up
103
        and     [ctrlstate], not 4
104
        jmp     .event
105
.rctrl_up:
106
        and     [ctrlstate], not 8
107
        jmp     .event
108
.lshift_down:
109
        test    ah, ah
110
        jnz     @f
111
        or      [ctrlstate], 1
112
@@:     jmp     .event
113
.lshift_up:
114
        test    ah, ah
115
        jnz     @b
116
        and     [ctrlstate], not 1
117
        jmp     @b
118
.rshift_down:
119
        or      [ctrlstate], 2
120
        jmp     .event
121
.rshift_up:
122
        and     [ctrlstate], not 2
123
        jmp     .event
124
.alt_down:
125
        test    ah, ah
126
        jnz     .ralt_down
127
        or      [ctrlstate], 0x10
128
        jmp     .event
129
.ralt_down:
130
        or      [ctrlstate], 0x20
131
        jmp     .event
132
.alt_up:
133
        test    ah, ah
134
        jnz     .ralt_up
135
        and     [ctrlstate], not 0x10
136
        jmp     .event
137
.ralt_up:
138
        and     [ctrlstate], not 0x20
139
        jmp     .event
140
.exit:
141
        popad
142
        push    eax
143
        push    0
144
        push    dword [esp+12+8]
145
        call    HideGenericBox
146
        pop     eax
147
        pop     [cursor_y]
148
        pop     [cursor_x]
149
        pushad
150
        call    draw_image
151
        popad
152
        ret     8
153
 
154
; int __stdcall ShowGenericBox(DLGTEMPLATE* dlg, void* DlgProc);
155
ShowGenericBox:
156
        pushad
183 diamond 157
        mov     ebx, [esp+20h+4]
158
; center window if required
474 diamond 159
        push    [ebx+dlgtemplate.x]
160
        push    [ebx+dlgtemplate.y]
183 diamond 161
        cmp     [ebx+dlgtemplate.x], -1
162
        jnz     @f
163
        mov     eax, [cur_width]
164
        sub     eax, [ebx+dlgtemplate.width]
165
        shr     eax, 1
166
        mov     [ebx+dlgtemplate.x], eax
167
@@:
168
        cmp     [ebx+dlgtemplate.y], -1
169
        jnz     @f
170
        mov     eax, [cur_height]
171
        sub     eax, [ebx+dlgtemplate.height]
172
        shr     eax, 1
173
        mov     [ebx+dlgtemplate.y], eax
174
@@:
180 heavyiron 175
; some checks
176
        mov     eax, [ebx+dlgtemplate.x]
177
        cmp     eax, 1
178
        jl      .sizeerr
179
        add     eax, [ebx+dlgtemplate.width]
180
        cmp     eax, [cur_width]
181
        jge     .sizeerr
182
        mov     eax, [ebx+dlgtemplate.y]
183
        cmp     eax, 1
184
        jl      .sizeerr
185
        add     eax, [ebx+dlgtemplate.height]
186
        cmp     eax, [cur_height]
187
        jge     .sizeerr
188
        cmp     [ebx+dlgtemplate.border_size_x], 1
189
        jl      .sizeerr
190
        cmp     [ebx+dlgtemplate.border_size_y], 1
191
        jge     .sizeok
192
.sizeerr:
474 diamond 193
        pop     [ebx+dlgtemplate.y]
194
        pop     [ebx+dlgtemplate.x]
180 heavyiron 195
        popad
196
        or      eax, -1
197
        ret     8
198
.sizeok:
314 diamond 199
; set color if required
200
        test    byte [ebx+dlgtemplate.flags], 1
201
        jz      @f
202
        mov     edi, dialog_colors
203
        jmp     .setcolor
204
@@:
205
        test    byte [ebx+dlgtemplate.flags], 2
206
        jz      @f
207
        mov     edi, warning_colors
208
.setcolor:
474 diamond 209
        mov     al, [edi + dialog_main_color-dialog_colors]
314 diamond 210
        mov     [ebx+dlgtemplate.main_color], al
474 diamond 211
        mov     al, [edi + dialog_border_color-dialog_colors]
314 diamond 212
        mov     [ebx+dlgtemplate.border_color], al
474 diamond 213
        mov     al, [edi + dialog_header_color-dialog_colors]
314 diamond 214
        mov     [ebx+dlgtemplate.header_color], al
215
@@:
180 heavyiron 216
; allocate memory for data under dialog
314 diamond 217
; for 'No memory' dialog use static data area
814 diamond 218
        mov     eax, nomem_dlgsavearea
314 diamond 219
        cmp     ebx, nomem_dlgdata
220
        jz      .allocated
180 heavyiron 221
        mov     eax, [ebx+dlgtemplate.width]
222
        add     eax, [ebx+dlgtemplate.border_size_x]
223
        add     eax, [ebx+dlgtemplate.border_size_x]
224
        inc     eax
225
        inc     eax
226
        mov     edx, [ebx+dlgtemplate.height]
227
        add     edx, [ebx+dlgtemplate.border_size_y]
228
        add     edx, [ebx+dlgtemplate.border_size_y]
229
        inc     edx
230
        mul     edx
814 diamond 231
        lea     ecx, [eax*2+8]
474 diamond 232
        call    xpgalloc
180 heavyiron 233
        test    eax, eax
234
        jnz     @f
474 diamond 235
        pop     [ebx+dlgtemplate.y]
236
        pop     [ebx+dlgtemplate.x]
180 heavyiron 237
        popad
238
        or      eax, -1
239
        ret     8
240
@@: