Subversion Repositories Kolibri OS

Rev

Rev 180 | Rev 283 | 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:
6
.flags          dd      ?
7
.x              dd      ?
8
.y              dd      ?
9
.width          dd      ?
10
.height         dd      ?
11
.border_size_x  dd      ?
12
.border_size_y  dd      ?
13
.title          dd      ?
14
.main_color     db      ?
15
.border_color   db      ?
16
.header_color   db      ?
17
                db      ?       ; align
183 diamond 18
.size = $
180 heavyiron 19
end virtual
20
 
183 diamond 21
GenericBox:
180 heavyiron 22
        pushad
183 diamond 23
        mov     ebx, [esp+20h+4]
24
; center window if required
25
        cmp     [ebx+dlgtemplate.x], -1
26
        jnz     @f
27
        mov     eax, [cur_width]
28
        sub     eax, [ebx+dlgtemplate.width]
29
        shr     eax, 1
30
        mov     [ebx+dlgtemplate.x], eax
31
@@:
32
        cmp     [ebx+dlgtemplate.y], -1
33
        jnz     @f
34
        mov     eax, [cur_height]
35
        sub     eax, [ebx+dlgtemplate.height]
36
        shr     eax, 1
37
        mov     [ebx+dlgtemplate.y], eax
38
@@:
180 heavyiron 39
; some checks
40
        mov     eax, [ebx+dlgtemplate.x]
41
        cmp     eax, 1
42
        jl      .sizeerr
43
        add     eax, [ebx+dlgtemplate.width]
44
        cmp     eax, [cur_width]
45
        jge     .sizeerr
46
        mov     eax, [ebx+dlgtemplate.y]
47
        cmp     eax, 1
48
        jl      .sizeerr
49
        add     eax, [ebx+dlgtemplate.height]
50
        cmp     eax, [cur_height]
51
        jge     .sizeerr
52
        cmp     [ebx+dlgtemplate.border_size_x], 1
53
        jl      .sizeerr
54
        cmp     [ebx+dlgtemplate.border_size_y], 1
55
        jge     .sizeok
56
.sizeerr:
57
        popad
58
        or      eax, -1
59
        ret     8
60
.sizeok:
61
; allocate memory for data under dialog
62
        mov     eax, [ebx+dlgtemplate.width]
63
        add     eax, [ebx+dlgtemplate.border_size_x]
64
        add     eax, [ebx+dlgtemplate.border_size_x]
65
        inc     eax
66
        inc     eax
67
        mov     edx, [ebx+dlgtemplate.height]
68
        add     edx, [ebx+dlgtemplate.border_size_y]
69
        add     edx, [ebx+dlgtemplate.border_size_y]
70
        inc     edx
71
        mul     edx
72
        add     eax, eax
73
        call    mf_alloc
74
        test    eax, eax
75
        jnz     @f
76
; TODO: add error message
77
        popad
78
        or      eax, -1
79
        ret     8
80
@@:
81
        mov     ebp, eax
82
; save data
83
        mov     eax, [ebx+dlgtemplate.y]
84
        add     eax, [ebx+dlgtemplate.height]
85
        add     eax, [ebx+dlgtemplate.border_size_y]
86
        inc     eax
87
        push    eax
88
        mov     eax, [ebx+dlgtemplate.x]
89
        add     eax, [ebx+dlgtemplate.width]
90
        add     eax, [ebx+dlgtemplate.border_size_x]
91
        inc     eax
92
        inc     eax
93
        push    eax
94
        mov     eax, [ebx+dlgtemplate.y]
95
        sub     eax, [ebx+dlgtemplate.border_size_y]
96
        push    eax
97
        mov     eax, [ebx+dlgtemplate.x]
98
        sub     eax, [ebx+dlgtemplate.border_size_x]
99
        push    eax
100
        call    save_console_data
101
; draw shadow
102
        mov     eax, [ebx+dlgtemplate.x]
103
        sub     eax, [ebx+dlgtemplate.border_size_x]
104
        ja      @f
105
        xor     eax, eax
106
@@:
107
        push    eax     ; save real window left
108
        inc     eax
109
        inc     eax
110
        mov     edx, [ebx+dlgtemplate.y]
111
        sub     edx, [ebx+dlgtemplate.border_size_y]
112
        ja      @f
113
        xor     edx, edx
114
@@:
115
        push    edx     ; save real window top
116
        inc     edx
117
        call    get_console_ptr
118
        mov     ecx, [ebx+dlgtemplate.y]
119
        add     ecx, [ebx+dlgtemplate.height]
120
        add     ecx, [ebx+dlgtemplate.border_size_y]
121
        inc     ecx
122
        cmp     ecx, [cur_height]
123
        jb      @f
124
        mov     ecx, [cur_height]
125
@@:
126
        sub     ecx, edx
127
        mov     edx, ecx
128
        mov     ecx, [ebx+dlgtemplate.x]
129
        add     ecx, [ebx+dlgtemplate.width]
130
        add     ecx, [ebx+dlgtemplate.border_size_x]
131
        inc     ecx
132
        inc     ecx
133
        cmp     ecx, [cur_width]
134
        jb      @f
135
        mov     ecx, [cur_width]
136
@@:
137
        sub     ecx, eax
138
        mov     eax, ecx
139
.shadow_loop:
140
        mov     ecx, eax
141
        push    edi
142
.sl1:
143
        inc     edi
144
        test    byte [edi], 0x0F
145
        jnz     @f
146
        or      byte [edi], 8
147
@@:
148
        and     byte [edi], 0x0F
149
        inc     edi
150
        loop    .sl1
151
        pop     edi
152
        add     edi, [cur_width]
153
        add     edi, [cur_width]
154
        dec     edx
155
        jnz     .shadow_loop
156
; draw area background
157
        pop     edx
158
        pop     eax
159
        call    get_console_ptr
160
        mov     ecx, [ebx+dlgtemplate.x]
161
        add     ecx, [ebx+dlgtemplate.width]
162
        add     ecx, [ebx+dlgtemplate.border_size_x]
163
        cmp     ecx, [cur_width]
164
        jb      @f
165
        mov     ecx, [cur_width]
166
@@:
167
        sub     ecx, eax
168
        mov     esi, ecx
169
        mov     ecx, [ebx+dlgtemplate.y]
170
        add     ecx, [ebx+dlgtemplate.height]
171
        add     ecx, [ebx+dlgtemplate.border_size_y]
172
        cmp     ecx, [cur_height]
173
        jb      @f
174
        mov     ecx, [cur_height]
175
@@:
176
        sub     ecx, edx
177
        mov     edx, ecx
178
        mov     al, ' '
179
        mov     ah, [ebx+dlgtemplate.border_color]
180
.1:
181
        mov     ecx, esi
182
        push    edi
183
        rep     stosw
184
        pop     edi
185
        add     edi, [cur_width]
186
        add     edi, [cur_width]
187
        dec     edx
188
        jnz     .1
189
; draw border
190
        mov     eax, [ebx+dlgtemplate.x]
191
        dec     eax
192
        mov     edx, [ebx+dlgtemplate.y]
193
        dec     edx
194
        call    get_console_ptr
195
        mov     edx, [ebx+dlgtemplate.height]
196
        inc     edx
197
        inc     edx
198
        mov     ah, [ebx+dlgtemplate.border_color]
199
        push    ebx
200
        mov     ebx, [ebx+dlgtemplate.width]
201
        inc     ebx
202
        inc     ebx
203
        call    draw_border
204
        pop     ebx
205
; draw header
206
        mov     esi, [ebx+dlgtemplate.title]
207
        test    esi, esi
208
        jz      .noheader
209
        cmp     byte [esi], 0
210
        jz      .noheader
211
        push    esi
212
@@:     lodsb
213
        test    al, al
214
        jnz     @b
215
        mov     eax, esi
216
        pop     esi
217
        sub     eax, esi
218
        inc     eax     ; eax = длина заголовка + 2
219
        mov     ecx, [ebx+dlgtemplate.width]
220
        cmp     eax, ecx
221
        jbe     .fullhea
222
        sub     ecx, 5
223
        jb      .noheader
224
        xor     edx, edx
225
        jmp     .drawhea
226
.fullhea:
227
        mov     edx, ecx
228
        sub     edx, eax
229
        shr     edx, 1
230
.drawhea:
231
        mov     eax, [ebx+dlgtemplate.x]
232
        add     eax, edx
233
        mov     edx, [ebx+dlgtemplate.y]
234
        dec     edx
235
        call    get_console_ptr
236
        mov     ah, [ebx+dlgtemplate.header_color]
237
        mov     al, ' '
238
        stosw
239
        dec     ecx
240
.2:
241
        jecxz   .3
242
        lodsb
243
        test    al, al
244
        jz      .4
245
        stosw
246
        jmp     .2
247
.3:
248
        mov     al, '.'
249
        stosw
250
        stosw
251
        stosw
252
.4:
253
        mov     al, ' '
254
        stosw
255
.noheader:
256
; draw window background
257
        mov     eax, [ebx+dlgtemplate.x]
258
        mov     edx, [ebx+dlgtemplate.y]
259
        call    get_console_ptr
260
        mov     ah, [ebx+dlgtemplate.main_color]
261
        mov     al, ' '
262
        mov     edx, [ebx+dlgtemplate.height]
263
@@:
264
        mov     ecx, [e