Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1003 leency 1
#code32 TRUE
2
 
3
char   os_name[8]   = {'M','E','N','U','E','T','0','1'};
4
dword  os_version   = 0x00000001;
5
dword  start_addr   = #main;
6
dword  final_addr   = #stop+32;
7
dword  alloc_mem    = 0x00100000;
8
dword  x86esp_reg   = 0x0007fff0;
9
dword  I_Param      = 0x0;
10
dword  I_Icon       = 0x0;
11
dword  skin_width;
12
 
13
#define evButton  3
14
#define evKey     2
15
#define evReDraw  1
16
#define evNet	  8
17
 
18
#define BT_DEL		0x80000000
19
#define BT_HIDE		0x40000000
20
#define BT_NOFRAME	0x20000000
21
 
22
 
23
 
24
inline fastcall dword WaitEvent(){
25
 EAX = 10;              // wait here for event
26
 $int 0x40
27
}
28
 
29
 
30
inline fastcall void ExitProcess(){
31
 EAX = -1;              // close this program
32
 $int 0x40
33
}
34
 
35
inline fastcall word GetKey(){
36
 EAX = 2;              // just read it key from buffer
37
 $int  0x40
38
 EAX = EAX >> 8;
39
}
40
 
41
inline fastcall word GetButtonID(){
42
 EAX = 17;            // Get ID
43
 $int  0x40
44
 EAX = EAX >> 8;
45
}
46
 
47
inline fastcall dword GetSkinWidth()
48
{
49
	EAX = 48;
50
	EBX = 4;
51
	$int 0x40
52
}
53
 
54
inline fastcall void DeleteButton(dword EDX)
55
{
56
	EAX = 8;
57
	EDX += BT_DEL;
58
	$int 0x40;
59
}
60
 
61
inline fastcall dword strlen(dword EDI){
62
	ECX=EAX=0;
63
	ECX--;
64
	$REPNE $SCASB
65
	EAX-=2+ECX;
66
}
67
 
68
 
69
inline fastcall void WindowRedrawStatus(dword EBX){
70
	EAX = 12;
71
	$int 0x40
72
}
73
 
74
 
75
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI)
76
{
77
	EBX = x << 16 + sizeX;
78
	ECX = y << 16 + sizeY;
79
	EDX = mainAreaType << 24 | mainAreaColour;
80
	ESI = headerType << 24 | headerColour;
81
	$xor eax,eax
82
	$int 0x40
83
}
84
 
85
void DefineButton(dword x,y,w,h,EDX,ESI)
86
{
87
 	EAX = 8;
88
	EBX = x<<16+w;
89
	ECX = skin_width+y<<16+h;
90
 	$int 0x40
91
}
92
 
93
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
94
{
95
	EAX = 4;
96
	EBX = x<<16+skin_width+y;
97
	ECX = fontType<<24+color;
98
	$int 0x40;
99
}
100
 
101
 
102
void DrawBar(dword x,y,w,h,EDX)
103
{
104
	EAX = 13;
105
	EBX = x<<16+w;
106
	ECX = skin_width+y<<16+h;
107
 	$int 0x40
108
}
109
 
110
 
111
void DrawRegion(dword x,y,width,height,color1)
112
{
113
	DrawBar(x,y,width,1,color1); //полоса гор сверху
114
	DrawBar(x,y+height,width,1,color1); //полоса гор снизу
115
	DrawBar(x,y,1,height,color1); //полоса верт слева
116
	DrawBar(x+width,y,1,height+1,color1); //полоса верт справа
117
}
118
 
119
void DrawFlatButton(dword x,y,width,height,id,color,text)
120
{
121
	DrawRegion(x,y,width,height,0x94AECE);
122
	DrawBar(x+1,y+1,width-1,1,0xFFFFFF); //полоса гор белая
123
	DrawBar(x+1,y+height-1,width-2,1,0xC7C7C7); //тень верт
124
	DrawBar(x+1,y+1,1,height-1,0xFFFFFF); //полоса верт белая
125
	DrawBar(x+width-1,y+2,1,height-2,0xC7C7C7); //тень верт
126
	DrawBar(x+2,y+2,width-3,height-3,color); //заливка
127
	IF (id<>0) DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //определяем кнопку
128
	WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
129
}
130
 
131
 
132
void PutImage(dword buf,w,h,x,y)
133
{
134
	EDI=buf;
135
	EAX = 7;
136
	EBX = buf;
137
	ECX = w<<16+h;
138
	EDX = x<<16+y+skin_width;
139
	$int 0x40
140
}
141
 
142
 
143
void copystr(dword s,d)
144
{
145
	$mov esi,s
146
	$mov edi,d
147
	$cld
148
l1:
149
	$lodsb
150
	$stosb
151
	$test al,al
152
	$jnz l1
153
}
154
 
155
 
156
char	buffer[11]="";
157
inline fastcall dword IntToStr(dword ESI)
158
{
159
     $mov     edi, #buffer
160
     $mov     ecx, 10
161
     $test     esi, esi
162
     $jns     f1
163
     $mov     al, '-'
164
     $stosb
165
     $neg     esi
166
f1:
167
     $mov     eax, esi
168
     $push     -'0'
169
f2:
170
     $xor     edx, edx
171
     $div     ecx
172
     $push     edx
173
     $test     eax, eax
174
     $jnz     f2
175
f3:
176
     $pop     eax
177
     $add     al, '0'
178
     $stosb
179
     $jnz     f3
180
     $mov     eax, #buffer
181
     $ret
182
}