Rev 109 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ; windows.inc |
2 | ; Copyright (c) 2002 Thomas Mathys |
||
3 | ; killer@vantage.ch |
||
4 | ; |
||
5 | ; This program is free software; you can redistribute it and/or modify |
||
6 | ; it under the terms of the GNU General Public License as published by |
||
7 | ; the Free Software Foundation; either version 2 of the License, or |
||
8 | ; (at your option) any later version. |
||
9 | ; |
||
10 | ; This program is distributed in the hope that it will be useful, |
||
11 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
12 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
13 | ; GNU General Public License for more details. |
||
14 | ; |
||
15 | ; You should have received a copy of the GNU General Public License |
||
16 | ; along with this program; if not, write to the Free Software |
||
17 | ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
18 | |||
19 | %ifndef _WINDOWS_INC |
||
20 | %define _WINDOWS_INC |
||
21 | |||
22 | |||
23 | WND_CENTER equ (1 << 0) |
||
24 | WND_DEFAULT_WORKCOLOR equ (1 << 1) |
||
25 | WND_DEFAULT_GRABCOLOR equ (1 << 2) |
||
26 | WND_DEFAULT_FRAMECOLOR equ (1 << 3) |
||
27 | WND_DEFAULT_CAPTIONCOLOR equ (1 << 4) |
||
28 | WND_DEFAULT_COLORS equ (WND_DEFAULT_WORKCOLOR | WND_DEFAULT_GRABCOLOR | WND_DEFAULT_FRAMECOLOR | WND_DEFAULT_CAPTIONCOLOR) |
||
29 | |||
30 | |||
31 | struc WND |
||
32 | .xposandsize resd 1 ; x position and size (like syscall) |
||
33 | .yposandsize resd 1 ; y position and size (like syscall) |
||
34 | .workcolor resd 1 ; work area color (like syscall) |
||
35 | .grabcolor resd 1 ; grab bar color (like syscall) |
||
36 | .framecolor resd 1 ; frame color (like syscall) |
||
37 | .caption resd 1 ; pointer to caption (zero terminated) |
||
38 | ; can be zero, if no caption is desired. |
||
39 | .captioncolor resd 1 ; caption color |
||
40 | .flags resd 1 ; combination of WND_xxx flags, or zero. |
||
41 | endstruc |
||
42 | |||
43 | |||
44 | BUTTON_COLOR_GRAB equ 0x01000000 |
||
45 | BUTTON_COLOR_WORK equ 0x02000000 |
||
46 | |||
47 | |||
48 | struc BUTTON |
||
49 | .xposandsize resd 1 ; x position and size (like syscall) |
||
50 | .yposandsize resd 1 ; y position and size (like syscall) |
||
51 | .id resd 1 ; button id |
||
52 | .color resd 1 ; button color. can be a real color |
||
53 | ; or one of the BUTTON_COLOR_xxx constants |
||
54 | endstruc |
||
55 | |||
56 | |||
57 | LABEL_COLOR_GRABBUTTON equ 0x01000000 ; use grab button text default color |
||
58 | LABEL_COLOR_GRAB equ 0x02000000 ; use grab text default color |
||
59 | LABEL_COLOR_WORKBUTTON equ 0x03000000 ; use work button text default color |
||
60 | LABEL_COLOR_WORK equ 0x04000000 ; use work text default color |
||
61 | LABEL_BGCOLOR_TRANSPARENT equ 0x01000000 ; transparent |
||
62 | LABEL_BGCOLOR_WORK equ 0x02000000 ; use work area color |
||
63 | |||
64 | |||
65 | struc LABEL |
||
66 | .position resd 1 ; position, x in upper word, y in lower word |
||
67 | .caption resd 1 ; pointer to caption (zero terminated) |
||
68 | ; if this is field is zero, the label will |
||
69 | ; not be drawn. |
||
70 | .color resd 1 ; text color, or a LABEL_COLOR_xxx constant |
||
71 | .bgcolor resd 1 ; background color, or a LABEL_BGCOLOR_xxx constant |
||
72 | endstruc |
||
73 | |||
74 | |||
75 | section .text |
||
76 | |||
77 | |||
78 | ;*********************************************************** |
||
79 | ; draw a window |
||
80 | ; |
||
81 | ; input: edi = pointer to a WND structure |
||
82 | ; output: nothing |
||
83 | ; destroys: nothing |
||
84 | ; notes: you must call begin redraw/end redraw |
||
85 | ; yourself, before and after calling |
||
86 | ; this function. |
||
87 | ;*********************************************************** |
||
88 | |||
89 | drawWindow: |
||
90 | |||
91 | %define WNDCOLORS ebp-MOS_WNDCOLORS_size |
||
92 | |||
93 | enter MOS_WNDCOLORS_size,0 |
||
94 | pushfd |
||
95 | pushad |
||
96 | |||
97 | ; get default window colors |
||
98 | mov ebx,3 |
||
99 | lea ecx,[WNDCOLORS] |
||
100 | mov edx,MOS_WNDCOLORS_size |
||
101 | mov eax,MOS_SC_WINDOWPROPERTIES |
||
102 | int 0x40 |
||
103 | |||
104 | ; |
||
105 | ; window position |
||
106 | ; |
||
107 | test dword [edi + WND.flags],WND_CENTER ; center window ? |
||
108 | jnz short .center |
||
109 | mov ebx,[edi + WND.xposandsize] ; nope -> just load dimensions |
||
110 | mov ecx,[edi + WND.yposandsize] |
||
111 | jmp short .positionok |
||
112 | .center: ; so let's center this window... |
||
113 | MOS_GETSCREENMAX ; get screen dimensions |
||
114 | mov ebx,eax ; xpos = (screenx-width)/2 |
||
115 | shr ebx,16 |
||
116 | sub bx,[edi + WND.xposandsize] |
||
117 | jns short .xok |
||
118 | xor ebx,ebx |
||
119 | .xok: |
||
120 | shl ebx,15 ; / 2, move result to hi-word |
||
121 | mov bx,[edi + WND.xposandsize] |
||
122 | movzx ecx,ax ; same for ypos |
||
123 | sub cx,[edi + WND.yposandsize] |
||
124 | jns short .yok |
||
125 | xor ecx,ecx |
||
126 | .yok: |
||
127 | shl ecx,15 |
||
128 | mov cx,[edi + WND.yposandsize] |
||
129 | .positionok: ; ebx/ecx contain dimensions |
||
130 | |||
131 | ; |
||
132 | ; colors |
||
133 | ; |
||
134 | push edi |
||
135 | mov edx,[edi + WND.workcolor] |
||
136 | test dword [edi + WND.flags],WND_DEFAULT_WORKCOLOR |
||
137 | jz short .workcolorok |
||
138 | and edx,0xff000000 |
||
139 | or edx,[WNDCOLORS + MOS_WNDCOLORS.work] |
||
140 | .workcolorok: |
||
141 | mov esi,[edi + WND.grabcolor] |
||
142 | test dword [edi + WND.flags],WND_DEFAULT_GRABCOLOR |
||
143 | jz short .grabcolorok |
||
144 | and esi,0xff000000 |
||
145 | or esi,[WNDCOLORS + MOS_WNDCOLORS.grab] |
||
146 | .grabcolorok: |
||
147 | test dword [edi + WND.flags],WND_DEFAULT_FRAMECOLOR |
||
148 | mov edi,[edi + WND.framecolor] |
||
149 | jz short .framecolorok |
||
150 | and edi,0xff000000 |
||
151 | or edi,[WNDCOLORS + MOS_WNDCOLORS.frame] |
||
152 | .framecolorok: |
||
153 | |||
154 | ; define window |
||
155 | mov eax,MOS_SC_DEFINEWINDOW |
||
156 | int 0x40 |
||
157 | pop edi |
||
158 | |||
159 | ; |
||
160 | ; caption |
||
161 | ; |
||
162 | cmp dword [edi + WND.caption],0 ; is there a caption ? |
||
163 | je short .captionok ; nope -> do nothing |
||
164 | mov ebx,MOS_DWORD(8,8) ; ebx = position |
||
165 | mov edx,[edi + WND.caption] ; edx -> string |
||
166 | push edi ; get string length |
||
167 | mov edi,edx |
||
168 | mov ecx,-1 |
||
169 | xor al,al ; scan for zero byte |
||
170 | repne scasb |
||
171 | sub edi,edx |
||
172 | dec edi |
||
173 | mov esi,edi |
||
174 | pop edi ; esi = string length |
||
175 | mov ecx,[edi + WND.captioncolor] |
||
176 | test dword [edi + WND.flags],WND_DEFAULT_CAPTIONCOLOR |
||
177 | jz short .captioncolorok |
||
178 | mov ecx,[WNDCOLORS + MOS_WNDCOLORS.grabText] |
||
179 | .captioncolorok: |
||
180 | mov eax,MOS_SC_WRITETEXT |
||
181 | int 0x40 |
||
182 | .captionok: |
||
183 | |||
184 | popad |
||
185 | popfd |
||
186 | leave |
||
187 | ret |
||
188 | %undef WNDCOLORS |
||
189 | |||
190 | |||
191 | ;*********************************************************** |
||
192 | ; draw a bunch of buttons |
||
193 | ; |
||
194 | ; input: edi = pointer to an array of BUTTON structs |
||
195 | ; ecx = # of buttons to draw |
||
196 | ; output: nothing |
||
197 | ; destroys: nothing |
||
198 | ; notes: you must call begin redraw/end redraw yourself |
||
199 | ;*********************************************************** |
||
200 | |||
201 | drawButtons: |
||
202 | |||
203 | %define WNDCOLORS ebp-MOS_WNDCOLORS_size |
||
204 | |||
205 | or ecx,ecx |
||
206 | jnz short .ok |
||
207 | ret |
||
208 | .ok: |
||
209 | enter MOS_WNDCOLORS_size,0 |
||
210 | pushfd |
||
211 | pushad |
||
212 | |||
213 | ; get default window colors |
||
214 | push ecx |
||
215 | mov ebx,3 |
||
216 | lea ecx,[WNDCOLORS] |
||
217 | mov edx,MOS_WNDCOLORS_size |
||
218 | mov eax,MOS_SC_WINDOWPROPERTIES |
||
219 | int 0x40 |
||
220 | pop ecx |
||
221 | |||
222 | .drawall: |
||
223 | push ecx |
||
224 | mov ebx,[edi + BUTTON.xposandsize] |
||
225 | mov ecx,[edi + BUTTON.yposandsize] |
||
226 | mov edx,[edi + BUTTON.id] |
||
227 | mov esi,[edi + BUTTON.color] |
||
228 | cmp esi,BUTTON_COLOR_GRAB ; use a default color ? |
||
229 | jne .ok1 |
||
230 | mov esi,[WNDCOLORS + MOS_WNDCOLORS.grabButton] |
||
231 | .ok1: |
||
232 | cmp esi,BUTTON_COLOR_WORK |
||
233 | jne .ok2 |
||
234 | mov esi,[WNDCOLORS + MOS_WNDCOLORS.workButton] |
||
235 | .ok2: |
||
236 | mov eax,MOS_SC_DEFINEBUTTON |
||
237 | int 0x40 |
||
238 | add edi,BUTTON_size |
||
239 | pop ecx |
||
240 | loop .drawall |
||
241 | |||
242 | popad |
||
243 | popfd |
||
244 | leave |
||
245 | ret |
||
246 | %undef WNDCOLORS |
||
247 | |||
248 | |||
249 | ;*********************************************************** |
||
250 | ; draw a bunch of labels |
||
251 | ; |
||
252 | ; input: edi = pointer to an array of LABEL structs |
||
253 | ; ecx = # of labels to draw |
||
254 | ; output: nothing |
||
255 | ; destroys: nothing |
||
256 | ;*********************************************************** |
||
257 | |||
258 | drawLabels: |
||
259 | |||
260 | %define WNDCOLORS ebp-MOS_WNDCOLORS_size |
||
261 | |||
262 | or ecx,ecx |
||
263 | jnz short .ok |
||
264 | ret |
||
265 | .ok: |
||
266 | enter MOS_WNDCOLORS_size,0 |
||
267 | pushfd |
||
268 | pushad |
||
269 | |||
270 | ; get default window colors |
||
271 | push ecx |
||
272 | mov ebx,3 |
||
273 | lea ecx,[WNDCOLORS] |
||
274 | mov edx,MOS_WNDCOLORS_size |
||
275 | mov eax,MOS_SC_WINDOWPROPERTIES |
||
276 | int 0x40 |
||
277 | pop ecx |
||
278 | |||
279 | .drawall: |
||
280 | push ecx |
||
281 | |||
282 | cmp dword [edi + LABEL.caption],0 |
||
283 | jne short .notnull |
||
284 | jmp .next |
||
285 | .notnull: |
||
286 | |||
287 | ; get caption length |
||
288 | push edi |
||
289 | mov edi,[edi + LABEL.caption] |
||
290 | mov ecx,-1 |
||
291 | xor al,al |
||
292 | repne scasb ; search for zero byte |
||
293 | mov esi,edi |
||
294 | pop edi |
||
295 | sub esi,[edi + LABEL.caption] |
||
296 | dec esi ; esi = string length |
||
297 | |||
298 | ; clear background, if necessary |
||
299 | cmp dword [edi + LABEL.bgcolor],LABEL_BGCOLOR_TRANSPARENT |
||
300 | je .clearok |
||
301 | mov ebx,[edi + LABEL.position] ; ebx = xstart/width |
||
302 | mov eax,esi ; width = stringlength * 6 |
||
303 | mov edx,6 |
||
304 | mul edx |
||
305 | mov bx,ax |
||
306 | mov ecx,[edi + LABEL.position] ; ecx = ystart/height |
||
307 | shl ecx,16 |
||
308 | mov cx,8 |
||
309 | mov edx,[edi + LABEL.bgcolor] |
||
310 | cmp edx,LABEL_BGCOLOR_WORK |
||
311 | jne short .bgcolorok |
||
312 | mov edx,[WNDCOLORS + MOS_WNDCOLORS.work] |
||
313 | .bgcolorok: |
||
314 | mov eax,MOS_SC_DRAWBAR |
||
315 | int 0x40 |
||
316 | .clearok: |
||
317 | |||
318 | ; draw label |
||
319 | mov ebx,[edi + LABEL.position] ; ebx = label position |
||
320 | mov edx,[edi + LABEL.caption] ; edx -> caption |
||
321 | mov ecx,[edi + LABEL.color] ; ecx = color |
||
322 | cmp ecx,LABEL_COLOR_GRABBUTTON |
||
323 | jne short .ok1 |
||
324 | mov ecx,[WNDCOLORS + MOS_WNDCOLORS.grabButtonText] |
||
325 | .ok1: |
||
326 | cmp ecx,LABEL_COLOR_GRAB |
||
327 | jne short .ok2 |
||
328 | mov ecx,[WNDCOLORS + MOS_WNDCOLORS.grabText] |
||
329 | .ok2: |
||
330 | cmp ecx,LABEL_COLOR_WORKBUTTON |
||
331 | jne short .ok3 |
||
332 | mov ecx,[WNDCOLORS + MOS_WNDCOLORS.workButtonText] |
||
333 | .ok3: |
||
334 | cmp ecx,LABEL_COLOR_WORK |
||
335 | jne short .ok4 |
||
336 | mov ecx,[WNDCOLORS + MOS_WNDCOLORS.workText] |
||
337 | .ok4: |
||
338 | mov eax,MOS_SC_WRITETEXT |
||
339 | int 0x40 |
||
340 | |||
1821 | yogev_ezra | 341 | .next: |
31 | halyavin | 342 | add edi,LABEL_size ; next label |
343 | pop ecx |
||
344 | dec ecx |
||
345 | jz .done |
||
346 | jmp .drawall |
||
347 | .done: |
||
348 | |||
349 | popad |
||
350 | popfd |
||
351 | leave |
||
352 | ret |
||
353 | %undef WNDCOLORS |
||
354 | |||
355 | |||
356 | %endif><>><>><>><>><> |