Rev 31 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ; adjustWindowDimensions |
2 | ; adjust menut window dimensions to get a certain work area size. |
||
3 | ; or so. who on earth cares anyway, i certinaly don't, i'm just |
||
4 | ; writing this code because i've got to kill time somehow... |
||
5 | ; |
||
6 | ; Copyright (c) 2002 Thomas Mathys |
||
7 | ; killer@vantage.ch |
||
8 | ; |
||
9 | ; This program is free software; you can redistribute it and/or modify |
||
10 | ; it under the terms of the GNU General Public License as published by |
||
11 | ; the Free Software Foundation; either version 2 of the License, or |
||
12 | ; (at your option) any later version. |
||
13 | ; |
||
14 | ; This program is distributed in the hope that it will be useful, |
||
15 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
16 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
17 | ; GNU General Public License for more details. |
||
18 | ; |
||
19 | ; You should have received a copy of the GNU General Public License |
||
20 | ; along with this program; if not, write to the Free Software |
||
21 | ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
22 | ; |
||
23 | %ifndef _ADJSTWND_INC |
||
24 | %define _ADJSTWND_INC |
||
25 | |||
26 | |||
27 | ;window types |
||
28 | ADJSTWND_TYPE_SKINNED equ 0 |
||
29 | |||
30 | |||
31 | ;******************************************************************** |
||
32 | ; adjust window dimensions to get a certain work area size |
||
33 | ; |
||
34 | ; - first the window width and height are adjusted |
||
35 | ; and clamped if they're too large for the screen. |
||
36 | ; - then the window positions are adjusted, if the |
||
37 | ; window goes out of the screen. |
||
38 | ; |
||
39 | ; input: |
||
40 | ; eax window type, one of the ADJSTWND_TYPE_xxx constants |
||
41 | ; ebx window x position |
||
42 | ; ecx window y position |
||
43 | ; edx desired work area width |
||
44 | ; esi desired work area height |
||
45 | ; |
||
46 | ; output: |
||
47 | ; eax return code. 0 = ok, -1 = invalid window type |
||
48 | ; ebx adjusted window x position |
||
49 | ; ecx adjusted window y position |
||
50 | ; edx window width to get desired work area width |
||
51 | ; esi window height to get desired work area height |
||
52 | ; |
||
53 | ; destroys: |
||
54 | ; nothing |
||
55 | ; |
||
56 | ; normally x and y are the upper left corner of the window, |
||
57 | ; relative to the upper left corner of the screen. |
||
58 | ; if you pass a negative x or y it will be treated as the |
||
59 | ; lower right corner of the window, relative to the lower |
||
60 | ; right corner of the screen. |
||
61 | ;******************************************************************** |
||
62 | adjustWindowDimensions: |
||
63 | push edi |
||
64 | push ebp |
||
65 | pushfd |
||
66 | |||
67 | ; adjust window dimensions, depending on the window type |
||
68 | cmp eax,ADJSTWND_TYPE_SKINNED |
||
69 | je .adjust_skinned |
||
70 | mov eax,-1 ; invalid window type, |
||
71 | jmp .bye ; return error code |
||
72 | |||
73 | ; clamp window dimensions |
||
74 | .clamp: |
||
75 | mov eax,MOS_SC_GETSCREENMAX ; get screen dimensions |
||
76 | int 0x40 |
||
77 | mov edi,eax ; edi = screen width |
||
78 | shr edi,16 |
||
79 | mov ebp,eax ; ebp = screen height |
||
80 | and ebp,0xffff |
||
81 | cmp edx,edi ; window width > screen width ? |
||
82 | jna .widthok |
||
83 | mov edx,edi ; yes -> use screen width |
||
84 | .widthok: |
||
85 | cmp esi,ebp ; wnd height > screen height ? |
||
86 | jna .heightok |
||
87 | mov esi,ebp ; yes -> use screen height |
||
88 | .heightok: |
||
89 | |||
90 | ; adjust x position |
||
91 | or ebx,ebx ; do the lower right corner |
||
92 | jns .foo ; stuff if x is negative. |
||
93 | add ebx,edi |
||
94 | sub ebx,edx |
||
95 | .foo: |
||
96 | or ebx,ebx ; x < 0 ? |
||
97 | jns .xnotnegative |
||
98 | xor ebx,ebx ; yes -> x = 0 |
||
99 | .xnotnegative: |
||
100 | mov eax,ebx ; x + width > screen width ? |
||
101 | add eax,edx |
||
102 | cmp eax,edi |
||
103 | jna .xok |
||
104 | sub eax,edi ; yes -> adjust |
||
105 | sub ebx,eax |
||
106 | .xok: |
||
107 | |||
108 | ; adjust y position |
||
109 | or ecx,ecx ; do the lower right corner |
||
110 | jns .bar ; stuff if y is negative. |
||
111 | add ecx,ebp |
||
112 | sub ecx,esi |
||
113 | .bar: |
||
114 | or ecx,ecx ; y < 0 ? |
||
115 | jns .ynotnegative |
||
116 | xor ecx,ecx ; yes -> y = 0 |
||
117 | .ynotnegative: |
||
118 | mov eax,ecx ; y + height > screen height ? |
||
119 | add eax,esi |
||
120 | cmp eax,ebp |
||
121 | jna .yok |
||
122 | sub eax,ebp ; yes -> adjust |
||
123 | sub ecx,eax |
||
124 | .yok: |
||
125 | |||
126 | .done: |
||
127 | xor eax,eax |
||
128 | .bye: |
||
129 | popfd |
||
130 | pop ebp |
||
131 | pop edi |
||
132 | ret |
||
133 | |||
134 | .adjust_skinned: |
||
135 | ; adjust width (edx) |
||
136 | add edx,MOS_WND_SKIN_BORDER_LEFT+MOS_WND_SKIN_BORDER_RIGHT |
||
137 | ; adjust height (esi). we need the skin height to do this. |
||
138 | push ebx |
||
139 | mov eax,MOS_SC_WINDOWPROPERTIES |
||
140 | mov ebx,4 |
||
141 | int 0x40 |
||
142 | lea esi,[esi+eax+MOS_WND_SKIN_BORDER_BOTTOM] |
||
143 | pop ebx |
||
144 | jmp .clamp |
||
145 | |||
146 | %endif>> |
||
147 |